Sfoglia il codice sorgente

aps-订单合金成分修改校验

sucheng 8 mesi fa
parent
commit
d8bcd30293

+ 3 - 0
cx-aps/cx-aps-common/src/main/java/com/rongwei/bscommon/sys/dao/ApsProductionOrderDao.java

@@ -81,6 +81,9 @@ public interface ApsProductionOrderDao extends BaseMapper<ApsProductionOrderDo>
     List<BlankIdAndWorkShopVo> getWorkShopByBlankId(@Param("blankIdList") List<String> blankIdList);
 
     List<ApsProcessOperationDo> selectListAndPlanDate(@Param("blankIdList") List<String> blankIdList);
+
+    @Select("select DISTINCT apop.CHANGEALLOY from aps_blank_order abo LEFT JOIN aps_process_output_product apop ON abo.ID = apop.BLANKID AND apop.DELETED = 0 WHERE abo.DELETED = 0 AND abo.PRODUCTIONORDERID = #{id} AND apop.CHANGEALLOY != '' AND apop.CHANGEALLOY is not null ")
+    List<String> selectChangeAlloyByOrderId(@Param("id") String id);
 }
 
 

+ 72 - 0
cx-aps/cx-aps-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ApsProductionOrderServiceImpl.java

@@ -127,6 +127,8 @@ public class ApsProductionOrderServiceImpl extends ServiceImpl<ApsProductionOrde
     private ProcessInstService processInstService;
     @Resource
     private CXAdminFeginClient cxAdminFeginClient;
+    @Autowired
+    private ApsProductionTechnicalRequirementService apsProductionTechnicalRequirementService;
 
 
     public static final String ERROR_MSG = "%s上诉订单的排程交货期大于承诺交货期";
@@ -331,6 +333,76 @@ public class ApsProductionOrderServiceImpl extends ServiceImpl<ApsProductionOrde
 //            }
 //        }
 
+            //==========校验订单技术要求============
+            /**
+             * 如果技术要求的订单产品在产品明细中不存在,错误提示:技术要求的订单产品{订单产品}已删除或已变更,请重新选择该技术要求的订单产品
+             * 如果有产品明细没有技术要求,错误提示:请填写{订单产品1},{订单产品2}的技术要求
+             * 如果合金成分要求为空,错误提示:请加载合金成分要求
+             * 校验所有坯料输出成品合金成分
+             *  如果坯料输出成品没有替代合金,并且合金没有加载合金成分要求,错误提示:{合金}合金成分要求没有加载
+             *  如果坯料输出成品有替代合金,并且替代合金没有加载合金成分要求,错误提示:{合金}替代合金成分要求没有加载
+             * 如果合金有多个合金成分要求,错误提示:{合金}合金成分要求不能有多个
+             */
+            //已有的产品明细的ID集合
+            List<String> nowOrderDetailIdList = apsProductDetailVoList.stream().map(ApsProductDetailVo::getId).collect(Collectors.toList());
+            //查询技术要求
+            List<ApsProductionTechnicalRequirementDo> apsProductionTechnicalRequirementDoList = apsProductionTechnicalRequirementService.list(new LambdaQueryWrapper<ApsProductionTechnicalRequirementDo>().eq(ApsProductionTechnicalRequirementDo::getOrderid, id));
+            //技术要求对应的产品明细ID集合
+            List<String> technicalHaveDetailIdList = new LinkedList<>();
+            for (ApsProductionTechnicalRequirementDo apsProductionTechnicalRequirementDo : apsProductionTechnicalRequirementDoList) {
+                if (ObjectUtil.isNotEmpty(apsProductionTechnicalRequirementDo.getOrderdetailids())) {
+                    String[] split1 = apsProductionTechnicalRequirementDo.getOrderdetailids().split(",");
+                    technicalHaveDetailIdList.addAll(Arrays.asList(split1));
+                    String[] split2 = apsProductionTechnicalRequirementDo.getOrderdetailnames().split(",");
+                    for (int i = 0; i < split1.length; i++) {
+                        String orderDetailId = split1[i];
+                        if (!nowOrderDetailIdList.contains(orderDetailId)) {
+                            return R.error("技术要求的订单产品" + split2[i] + "已删除或已变更,请重新选择该技术要求的订单产品");
+                        }
+                    }
+                }
+            }
+            for (String nowOrderDetailId : nowOrderDetailIdList) {
+                if (!technicalHaveDetailIdList.contains(nowOrderDetailId)) {
+                    ApsProductDetailVo apsProductDetailVo = apsProductDetailVoList.stream().filter(item -> item.getId().equals(nowOrderDetailId)).findFirst().orElse(null);
+                    return R.error("请填写" + apsProductDetailVo.getInputmaterialdescription() + "的技术要求");
+                }
+            }
+
+            List<ApsOrderAlloyCompositionDo> apsOrderAlloyCompositionDoList = apsOrderAlloyCompositionService.list(new LambdaQueryWrapper<ApsOrderAlloyCompositionDo>().eq(ApsOrderAlloyCompositionDo::getProductionorderid, id));
+            if (ObjectUtil.isEmpty(apsOrderAlloyCompositionDoList)) {
+                return R.error("请加载合金成分要求");
+            }
+            List<String> productDetailAlloyList = apsProductDetailVoList.stream().map(ApsProductDetailVo::getAlloy).collect(Collectors.toList());
+            for (String productDetailAlloy : productDetailAlloyList) {
+                if (ObjectUtil.isEmpty(apsOrderAlloyCompositionDoList.stream().filter(item -> item.getAlloy().equals(productDetailAlloy)).findFirst().orElse(null))) {
+                    return R.error(productDetailAlloy + "合金成分要求没有加载");
+                }
+
+            }
+
+            List<String> changeAlloyList = this.baseMapper.selectChangeAlloyByOrderId(id);
+            for (String changeAlloy : changeAlloyList) {
+                if (ObjectUtil.isEmpty(apsOrderAlloyCompositionDoList.stream().filter(item -> item.getAlloy().equals(changeAlloy)).findFirst().orElse(null))) {
+                    return R.error(changeAlloy + "替代合金成分要求没有加载");
+                }
+            }
+
+            Map<String, Integer> alloyCountMap = new HashMap<>();
+            apsOrderAlloyCompositionDoList.forEach(item -> {
+                if (alloyCountMap.containsKey(item.getAlloy())) {
+                    alloyCountMap.put(item.getAlloy(), alloyCountMap.get(item.getAlloy()) + 1);
+                } else {
+                    alloyCountMap.put(item.getAlloy(), 1);
+                }
+            });
+            for (String key : alloyCountMap.keySet()) {
+                if (alloyCountMap.get(key) > 1) {
+                    return R.error(key + "合金成分要求不能有多个");
+                }
+            }
+
+
             /**
              * 校验每个订单产品
              * 如果订单产品暂不评审=否,并且坯料计划输出总重量 = 0,则错误提示:订单产品 {输入物料描述}坯料计划未填写