Browse Source

aps-订单产品明细关键字段变更时增加判断是否变更

sucheng 10 months ago
parent
commit
3041101424

+ 88 - 82
cx-aps/cx-aps-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ApsProductDetailServiceImpl.java

@@ -491,93 +491,99 @@ public class ApsProductDetailServiceImpl extends ServiceImpl<ApsProductDetailDao
             //产品明细变更
             ApsProductDetailDo apsProductDetailDo = nowUpdateList.get(0);
 
-            //复制新的产品明细
-            apsProductDetailDo.setId(SecurityUtil.getUUID());
-            updateOrInsertDetailList.add(apsProductDetailDo);
-
-            //====================更新坯料计划及其输出成品===========================
-            //检查订单产品明细对应的所有相关的坯料计划的输出成品,
-            //如果订单产品明细的订单产品字段值不等于坯料计划输出成品的订单产品字段值,
-            //则订单产品明细ID=(新ID),更新订单产品明细的坯料计划输出总重量=0
-            //查询当前产品明细ID对应的坯料计划输出成品
-            List<ApsProcessOutputProductAndBlankStatusVo> apsProcessOutputProductAndBlankStatusVoList = this.baseMapper.selectAboutBlankOutputByDetailId(nowId);
-            //筛选其中待排程和待发布的坯料计划的输出成品
-            List<ApsProcessOutputProductAndBlankStatusVo> needUpdateOutputList = apsProcessOutputProductAndBlankStatusVoList.stream().filter(item ->
-                    ObjectUtil.isNotEmpty(item.getBlankStatus())
-                            //坯料计划的生产状态为 待排程或待发布
-                            && Integer.parseInt(item.getBlankStatus()) <= Integer.parseInt(SaveConstans.ProductionStatus.TO_BE_PUBLISHED)).collect(Collectors.toList());
-            if (apsProcessOutputProductAndBlankStatusVoList.size() > 0) {
-                Set<String> needUpdateBlankIds = new HashSet<>();
-                for (ApsProcessOutputProductAndBlankStatusVo vo : needUpdateOutputList) {
-                    if (!vo.getProductname().equals(apsProductDetailDo.getInputmaterialdescription())) {
-                        //变更产品明细对应的输出成品
-                        ApsProcessOutputProductDo apsProcessOutputProductDo = new ApsProcessOutputProductDo();
-                        apsProcessOutputProductDo.setId(vo.getId());
-                        apsProcessOutputProductDo.setAlloy(apsProductDetailDo.getAlloy());
-                        apsProcessOutputProductDo.setAlloystatus(apsProductDetailDo.getAlloystatus());
-                        apsProcessOutputProductDo.setThickness(apsProductDetailDo.getThickness());
-                        apsProcessOutputProductDo.setProwidth(apsProductDetailDo.getProwidth());
-                        apsProcessOutputProductDo.setProlength(apsProductDetailDo.getProlength());
-                        apsProcessOutputProductDo.setRollweightrequirement(apsProductDetailDo.getRollweightrequirement());
-                        apsProcessOutputProductDo.setRolldiameterrequirement(apsProductDetailDo.getRolldiameterrequirement());
-                        apsProcessOutputProductDo.setRollnumberrequirement(apsProductDetailDo.getRollnumberrequirement());
-                        apsProcessOutputProductDo.setProductname(apsProductDetailDo.getInputmaterialdescription());
-                        apsProcessOutputProductDo.setProductid(apsProductDetailDo.getId());
-                        String alloy = apsProcessOutputProductDo.getAlloy();
-                        String alloyStatus = apsProcessOutputProductDo.getAlloystatus();
-                        String productType = vo.getProducttype();
-                        if (ObjectUtil.isNotEmpty(vo.getChangealloy())) {
-                            alloy = vo.getChangealloy();
-                        }
-                        if (ObjectUtil.isNotEmpty(vo.getChangealloystatus())) {
-                            alloyStatus = vo.getChangealloystatus();
-                        }
-                        if (ObjectUtil.isNotEmpty(vo.getChangeproducttype())) {
-                            productType = vo.getChangeproducttype();
-                        }
+            ApsProductDetailDo oldProductDetail = this.getById(apsProductDetailDo.getId());
 
-                        //拼接输出成品的输出物料类型字段
-                        apsProcessOutputProductDo.setOutmatertype(alloy + productType + apsProcessOutputProductDo.getThickness());
-                        //拼接输出成品的输出物料规格字段
-                        apsProcessOutputProductDo.setOutmaterspecification(alloy + alloyStatus + productType + " " + apsProcessOutputProductDo.getProductname().split(" ")[1]);
-                        //拼接输出成品的输出成品字段
-                        apsProcessOutputProductDo.setOutputresult(apsProcessOutputProductDo.getOutmaterspecification() + " " + CXCommonUtils.removeExtraZerosAndDecimal(vo.getOutputonerollweigth()) + "吨 * " + vo.getPlanoutputorderroll() + "卷");
+            //如果订单产品明细的订单产品字段值改变了
+            if (!oldProductDetail.getInputmaterialdescription().equals(apsProductDetailDo.getInputmaterialdescription())) {
 
-                        apsProcessOutputProductService.updateById(apsProcessOutputProductDo);
-                        needUpdateBlankIds.add(vo.getBlankId());
+                //复制新的产品明细
+                apsProductDetailDo.setId(SecurityUtil.getUUID());
+                updateOrInsertDetailList.add(apsProductDetailDo);
+
+                //====================更新坯料计划及其输出成品===========================
+                //检查订单产品明细对应的所有相关的坯料计划的输出成品,
+                //如果订单产品明细的订单产品字段值不等于坯料计划输出成品的订单产品字段值,
+                //则订单产品明细ID=(新ID),更新订单产品明细的坯料计划输出总重量=0
+                //查询当前产品明细ID对应的坯料计划输出成品
+                List<ApsProcessOutputProductAndBlankStatusVo> apsProcessOutputProductAndBlankStatusVoList = this.baseMapper.selectAboutBlankOutputByDetailId(nowId);
+                //筛选其中待排程和待发布的坯料计划的输出成品
+                List<ApsProcessOutputProductAndBlankStatusVo> needUpdateOutputList = apsProcessOutputProductAndBlankStatusVoList.stream().filter(item ->
+                        ObjectUtil.isNotEmpty(item.getBlankStatus())
+                                //坯料计划的生产状态为 待排程或待发布
+                                && Integer.parseInt(item.getBlankStatus()) <= Integer.parseInt(SaveConstans.ProductionStatus.TO_BE_PUBLISHED)).collect(Collectors.toList());
+                if (apsProcessOutputProductAndBlankStatusVoList.size() > 0) {
+                    Set<String> needUpdateBlankIds = new HashSet<>();
+                    for (ApsProcessOutputProductAndBlankStatusVo vo : needUpdateOutputList) {
+                        if (!vo.getProductname().equals(apsProductDetailDo.getInputmaterialdescription())) {
+                            //变更产品明细对应的输出成品
+                            ApsProcessOutputProductDo apsProcessOutputProductDo = new ApsProcessOutputProductDo();
+                            apsProcessOutputProductDo.setId(vo.getId());
+                            apsProcessOutputProductDo.setAlloy(apsProductDetailDo.getAlloy());
+                            apsProcessOutputProductDo.setAlloystatus(apsProductDetailDo.getAlloystatus());
+                            apsProcessOutputProductDo.setThickness(apsProductDetailDo.getThickness());
+                            apsProcessOutputProductDo.setProwidth(apsProductDetailDo.getProwidth());
+                            apsProcessOutputProductDo.setProlength(apsProductDetailDo.getProlength());
+                            apsProcessOutputProductDo.setRollweightrequirement(apsProductDetailDo.getRollweightrequirement());
+                            apsProcessOutputProductDo.setRolldiameterrequirement(apsProductDetailDo.getRolldiameterrequirement());
+                            apsProcessOutputProductDo.setRollnumberrequirement(apsProductDetailDo.getRollnumberrequirement());
+                            apsProcessOutputProductDo.setProductname(apsProductDetailDo.getInputmaterialdescription());
+                            apsProcessOutputProductDo.setProductid(apsProductDetailDo.getId());
+                            String alloy = apsProcessOutputProductDo.getAlloy();
+                            String alloyStatus = apsProcessOutputProductDo.getAlloystatus();
+                            String productType = vo.getProducttype();
+                            if (ObjectUtil.isNotEmpty(vo.getChangealloy())) {
+                                alloy = vo.getChangealloy();
+                            }
+                            if (ObjectUtil.isNotEmpty(vo.getChangealloystatus())) {
+                                alloyStatus = vo.getChangealloystatus();
+                            }
+                            if (ObjectUtil.isNotEmpty(vo.getChangeproducttype())) {
+                                productType = vo.getChangeproducttype();
+                            }
+
+                            //拼接输出成品的输出物料类型字段
+                            apsProcessOutputProductDo.setOutmatertype(alloy + productType + apsProcessOutputProductDo.getThickness());
+                            //拼接输出成品的输出物料规格字段
+                            apsProcessOutputProductDo.setOutmaterspecification(alloy + alloyStatus + productType + " " + apsProcessOutputProductDo.getProductname().split(" ")[1]);
+                            //拼接输出成品的输出成品字段
+                            apsProcessOutputProductDo.setOutputresult(apsProcessOutputProductDo.getOutmaterspecification() + " " + CXCommonUtils.removeExtraZerosAndDecimal(vo.getOutputonerollweigth()) + "吨 * " + vo.getPlanoutputorderroll() + "卷");
+
+                            apsProcessOutputProductService.updateById(apsProcessOutputProductDo);
+                            needUpdateBlankIds.add(vo.getBlankId());
+                        }
+                    }
+                    //遍历需要更新的坯料计划,更新 输出订单产品、输出成品、坯料输出物料类型、坯料输出物料规格
+                    for (String needUpdateBlankId : needUpdateBlankIds) {
+                        apsBlankOrderService.updateBlankSplicingColumn(needUpdateBlankId);
                     }
                 }
-                //遍历需要更新的坯料计划,更新 输出订单产品、输出成品、坯料输出物料类型、坯料输出物料规格
-                for (String needUpdateBlankId : needUpdateBlankIds) {
-                    apsBlankOrderService.updateBlankSplicingColumn(needUpdateBlankId);
-                }
-            }
 
-            //=================更新技术要求==========================
-            //查询相关的技术要求
-            List<ApsProductionTechnicalRequirementDo> apsProductionTechnicalRequirementDoList = apsProductionTechnicalRequirementService.list(new QueryWrapper<ApsProductionTechnicalRequirementDo>().lambda().like(ApsProductionTechnicalRequirementDo::getOrderdetailids, nowId).orderByDesc(ApsProductionTechnicalRequirementDo::getModifydate));
-            if (apsProductionTechnicalRequirementDoList.size() > 0) {
-                //只会存在一个
-                ApsProductionTechnicalRequirementDo apsProductionTechnicalRequirementDo = apsProductionTechnicalRequirementDoList.get(0);
-                //更新原来的产品明细为新的产品明细
-                ApsProductionTechnicalRequirementDo updateTechnicalRequirement = new ApsProductionTechnicalRequirementDo();
-                updateTechnicalRequirement.setId(apsProductionTechnicalRequirementDo.getId());
-
-                //获取原来的产品明细IDs和产品明细的名称
-                String orderdetailids = apsProductionTechnicalRequirementDo.getOrderdetailids();
-                String orderdetailnames = apsProductionTechnicalRequirementDo.getOrderdetailnames();
-                List<String> orderDetailIdList = Arrays.asList(orderdetailids.split(","));
-                List<String> orderDetailNameList = Arrays.asList(orderdetailnames.split(",\r\n"));
-                //获取 原产品明细的ID的下标
-                int index = orderDetailIdList.indexOf(nowId);
-                //替换成新的产品明细
-                orderDetailIdList.set(index, apsProductDetailDo.getId());
-                orderDetailNameList.set(index, apsProductDetailDo.getInputmaterialdescription());
-
-                updateTechnicalRequirement.setOrderdetailids(String.join(",", orderDetailIdList));
-                updateTechnicalRequirement.setOrderdetailnames(String.join(",\r\n", orderDetailNameList));
-                //更新技术要求
-                apsProductionTechnicalRequirementService.updateById(updateTechnicalRequirement);
+                //=================更新技术要求==========================
+                //查询相关的技术要求
+                List<ApsProductionTechnicalRequirementDo> apsProductionTechnicalRequirementDoList = apsProductionTechnicalRequirementService.list(new QueryWrapper<ApsProductionTechnicalRequirementDo>().lambda().like(ApsProductionTechnicalRequirementDo::getOrderdetailids, nowId).orderByDesc(ApsProductionTechnicalRequirementDo::getModifydate));
+                if (apsProductionTechnicalRequirementDoList.size() > 0) {
+                    //只会存在一个
+                    ApsProductionTechnicalRequirementDo apsProductionTechnicalRequirementDo = apsProductionTechnicalRequirementDoList.get(0);
+                    //更新原来的产品明细为新的产品明细
+                    ApsProductionTechnicalRequirementDo updateTechnicalRequirement = new ApsProductionTechnicalRequirementDo();
+                    updateTechnicalRequirement.setId(apsProductionTechnicalRequirementDo.getId());
+
+                    //获取原来的产品明细IDs和产品明细的名称
+                    String orderdetailids = apsProductionTechnicalRequirementDo.getOrderdetailids();
+                    String orderdetailnames = apsProductionTechnicalRequirementDo.getOrderdetailnames();
+                    List<String> orderDetailIdList = Arrays.asList(orderdetailids.split(","));
+                    List<String> orderDetailNameList = Arrays.asList(orderdetailnames.split(",\r\n"));
+                    //获取 原产品明细的ID的下标
+                    int index = orderDetailIdList.indexOf(nowId);
+                    //替换成新的产品明细
+                    orderDetailIdList.set(index, apsProductDetailDo.getId());
+                    orderDetailNameList.set(index, apsProductDetailDo.getInputmaterialdescription());
+
+                    updateTechnicalRequirement.setOrderdetailids(String.join(",", orderDetailIdList));
+                    updateTechnicalRequirement.setOrderdetailnames(String.join(",\r\n", orderDetailNameList));
+                    //更新技术要求
+                    apsProductionTechnicalRequirementService.updateById(updateTechnicalRequirement);
+                }
             }
         }