| | |
| | | import com.ruoyi.production.bean.dto.ProductionPlanDto; |
| | | import com.ruoyi.production.bean.dto.ProductionPlanImportDto; |
| | | import com.ruoyi.production.bean.vo.ProductionPlanVo; |
| | | import com.ruoyi.production.enums.ProductOrderStatusEnum; |
| | | import com.ruoyi.production.mapper.ProductionOrderMapper; |
| | | import com.ruoyi.production.mapper.ProductionPlanMapper; |
| | | import com.ruoyi.production.pojo.ProductionOrder; |
| | |
| | | |
| | | @Override |
| | | public IPage<ProductionPlanVo> listPage(Page<ProductionPlanDto> page, ProductionPlanDto productionPlanDto) { |
| | | |
| | | IPage<ProductionPlanVo> planVoIPage = productionPlanMapper.listPage(page, productionPlanDto) |
| | | .convert(dto -> { |
| | | ProductionPlanVo vo = new ProductionPlanVo(); |
| | | BeanUtils.copyProperties(dto, vo); |
| | | return vo; |
| | | }); |
| | | return planVoIPage; |
| | | return productionPlanMapper.listPage(page, productionPlanDto); |
| | | } |
| | | |
| | | /** |
| | |
| | | ProductionOrder productionOrder = new ProductionOrder(); |
| | | productionOrder.setQuantity(productionPlanDto.getTotalAssignedQuantity()); |
| | | productionOrder.setPlanCompleteTime(productionPlanDto.getPlanCompleteTime()); |
| | | productionOrder.setStatus(ProductOrderStatusEnum.WAIT.getCode()); |
| | | // // 叠加剩余方数 |
| | | // BigDecimal totalRemainingVolume = plans.stream() |
| | | // .map(ProductionPlan::getRemainingVolume) |
| | | // .filter(Objects::nonNull) |
| | | // .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | // // 判断下发数量是否大于等于剩余方数 |
| | | // if (productionPlanDto.getTotalAssignedQuantity().compareTo(totalRemainingVolume) > 0) { |
| | | // throw new BaseException("操作失败,下发数量不能大于剩余方数"); |
| | | // } |
| | | // |
| | | // // 创建生产订单 |
| | | // ProductOrder productOrder = new ProductOrder(); |
| | | // productOrder.setQuantity(productionPlanDto.getTotalAssignedQuantity()); |
| | | // productOrder.setPlanCompleteTime(productionPlanDto.getPlanCompleteTime()); |
| | | // productOrder.setStatus(ProductOrderStatusEnum.WAIT.getCode()); |
| | | // productOrder.setStrength(productionPlanDto.getStrength()); |
| | | // productOrder.setProductMaterialSkuId(plans.get(0).getProductMaterialSkuId()); |
| | | // |
| | | // Long orderId = productOrderService.insertProductOrder(productOrder); |
| | | // |
| | | // // 当下发的产品为砌块或板材,就拉取BOM子集与工艺路线子集数据存入到附表中 |
| | | // if ("砌块".equals(productionPlanDto.getProductName())) { |
| | | // productOrder.setRouteId(productionOrderAppendixService.populateBlocks(orderId, productionPlanDto)); |
| | | // } |
| | | // if ("板材".equals(productionPlanDto.getProductName())) { |
| | | // productOrder.setRouteId(productionOrderAppendixService.populatePlates(orderId, productionPlanDto)); |
| | | // } |
| | | // // 更新绑定的工艺路线 |
| | | // productOrderService.updateById(productOrder); |
| | | // |
| | | // // 根据下发数量,从第一个生产计划开始分配方数 |
| | | // BigDecimal assignedVolume = BigDecimal.ZERO; |
| | | // for (ProductionPlan plan : plans) { |
| | | // BigDecimal volume = plan.getVolume(); |
| | | // if (volume == null) { |
| | | // continue; |
| | | // } |
| | | // // 计算剩余方数 |
| | | // BigDecimal remainingVolume = plan.getRemainingVolume(); |
| | | // if (remainingVolume.compareTo(BigDecimal.ZERO) <= 0) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // ProductOrderPlan productOrderPlan = new ProductOrderPlan(); |
| | | // productOrderPlan.setProductOrderId(productOrder.getId()); |
| | | // productOrderPlan.setProductionPlanId(plan.getId()); |
| | | // |
| | | // if (assignedVolume.add(remainingVolume).compareTo(productionPlanDto.getTotalAssignedQuantity()) >= 0) { |
| | | // // 最后一个计划,分配剩余方数 |
| | | // BigDecimal lastRemainingVolume = productionPlanDto.getTotalAssignedQuantity().subtract(assignedVolume); |
| | | // 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); |
| | | // break; |
| | | // } |
| | | // |
| | | // // 分配当前计划方数 |
| | | // 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; |
| | | } |
| | | |