| | |
| | | if (assignedVolume.add(remainingVolume).compareTo(productionPlanDto.getTotalAssignedQuantity()) >= 0) { |
| | | // 最后一个计划,分配剩余方数 |
| | | BigDecimal lastRemainingVolume = productionPlanDto.getTotalAssignedQuantity().subtract(assignedVolume); |
| | | plan.setStatus(1); |
| | | plan.setAssignedQuantity(plan.getAssignedQuantity().add(lastRemainingVolume)); |
| | | if (plan.getAssignedQuantity().compareTo(plan.getVolume()) >= 0) { |
| | | plan.setStatus(2); |
| | | } |
| | | BigDecimal assignedQuantity = Optional.ofNullable(plan.getAssignedQuantity()).orElse(BigDecimal.ZERO).add(lastRemainingVolume); |
| | | plan.setAssignedQuantity(assignedQuantity); |
| | | plan.setStatus(assignedQuantity.compareTo(plan.getVolume()) >= 0 ? 2 : 1); |
| | | productOrderPlan.setAssignedQuantity(lastRemainingVolume); |
| | | productionPlanMapper.updateById(plan); |
| | | productOrderPlanMapper.insert(productOrderPlan); |
| | |
| | | } |
| | | |
| | | // 分配当前计划方数 |
| | | plan.setStatus(1); |
| | | if (remainingVolume.compareTo(BigDecimal.ZERO) <= 0) { |
| | | plan.setStatus(2); |
| | | } |
| | | plan.setAssignedQuantity(plan.getAssignedQuantity().add(remainingVolume)); |
| | | BigDecimal assignedQuantity = Optional.ofNullable(plan.getAssignedQuantity()).orElse(BigDecimal.ZERO).add(remainingVolume); |
| | | plan.setAssignedQuantity(assignedQuantity); |
| | | plan.setStatus(assignedQuantity.compareTo(plan.getVolume()) >= 0 ? 2 : 1); |
| | | productOrderPlan.setAssignedQuantity(remainingVolume); |
| | | // 更新生产计划 |
| | | productionPlanMapper.updateById(plan); |
| | |
| | | productOrderPlanMapper.insert(productOrderPlan); |
| | | assignedVolume = assignedVolume.add(remainingVolume); |
| | | } |
| | | |
| | | for (ProductionPlan plan : plans) { |
| | | BigDecimal assignedQuantity = Optional.ofNullable(plan.getAssignedQuantity()).orElse(BigDecimal.ZERO); |
| | | BigDecimal volume = Optional.ofNullable(plan.getVolume()).orElse(BigDecimal.ZERO); |
| | | if (assignedQuantity.compareTo(BigDecimal.ZERO) <= 0) { |
| | | plan.setStatus(0); |
| | | } else if (assignedQuantity.compareTo(volume) >= 0) { |
| | | plan.setStatus(2); |
| | | } else { |
| | | plan.setStatus(1); |
| | | } |
| | | productionPlanMapper.updateById(plan); |
| | | } |
| | | return true; |
| | | } |
| | | |