| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.appendix.service.AppendixService; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.config.AliDingConfig; |
| | | import com.ruoyi.framework.util.AliDingUtils; |
| | | import com.ruoyi.production.enums.ProductOrderStatusEnum; |
| | | import com.ruoyi.production.pojo.ProductMaterialSku; |
| | | import com.ruoyi.production.pojo.ProductOrder; |
| | | import com.ruoyi.production.service.ProductMaterialService; |
| | |
| | | @Autowired |
| | | private ProductMaterialService productMaterialService; |
| | | |
| | | @Autowired |
| | | private AppendixService appendixService; |
| | | |
| | | /** |
| | | * 同步锁,确保手动和定时任务不同时执行 |
| | | */ |
| | |
| | | } |
| | | |
| | | // 校验是否存在不同的产品规格 |
| | | 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("合并失败,存在不同的产品规格"); |
| | | } |
| | | |
| | |
| | | ProductOrder productOrder = new ProductOrder(); |
| | | productOrder.setQuantity(productionPlanDto.getTotalAssignedQuantity()); |
| | | productOrder.setPlanCompleteTime(productionPlanDto.getPlanCompleteTime()); |
| | | productOrder.setStatus(ProductOrderStatusEnum.WAIT.getCode()); |
| | | |
| | | // 当下发的产品为砌块或板材,就拉取BOM子集与工艺路线子集数据存入到附表中 |
| | | if ("砌块".equals(productionPlanDto.getProductName())) { |
| | | productOrder.setRouteId(appendixService.populateBlocks(productionPlanDto)); |
| | | } |
| | | if ("板材".equals(productionPlanDto.getProductName())) { |
| | | productOrder.setRouteId(appendixService.populatePlates(productionPlanDto)); |
| | | } |
| | | productOrderService.addProductOrder(productOrder); |
| | | |
| | | // 根据下发数量,从第一个生产计划开始分配方数 |
| | |
| | | // 最后一个计划,分配剩余方数 |
| | | 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); |