| | |
| | | } |
| | | |
| | | // 校验是否存在不同的产品规格 |
| | | String firstProductSpec = plans.get(0).getSpecification(); |
| | | if (plans.stream().anyMatch(p -> p.getSpecification() == null || !p.getSpecification().equals(firstProductSpec))) { |
| | | String firstProductSpec = plans.get(0).getModel(); |
| | | if (plans.stream().anyMatch(p -> p.getModel() == null || !p.getModel().equals(firstProductSpec))) { |
| | | throw new BaseException("合并失败,存在不同的产品规格"); |
| | | } |
| | | |
| | |
| | | // 最后一个计划,分配剩余方数 |
| | | BigDecimal lastRemainingVolume = productionPlanDto.getTotalAssignedQuantity().subtract(assignedVolume); |
| | | plan.setStatus(1); |
| | | if (lastRemainingVolume.compareTo(BigDecimal.ZERO) <= 0) { |
| | | plan.setAssignedQuantity(plan.getAssignedQuantity().add(lastRemainingVolume)); |
| | | if (plan.getAssignedQuantity().compareTo(plan.getVolume()) >= 0) { |
| | | plan.setStatus(2); |
| | | } |
| | | plan.setAssignedQuantity(plan.getAssignedQuantity().add(lastRemainingVolume)); |
| | | productOrderPlan.setAssignedQuantity(lastRemainingVolume); |
| | | productionPlanMapper.updateById(plan); |
| | | productOrderPlanMapper.insert(productOrderPlan); |