From 804c80b0fd284c7464066efbd5e5833ddacfb635 Mon Sep 17 00:00:00 2001 From: liding <756868258@qq.com> Date: 星期五, 11 四月 2025 13:11:16 +0800 Subject: [PATCH] 原辅材下单优化 --- basic-server/src/main/java/com/ruoyi/basic/service/impl/StandardProductListServiceImpl.java | 221 +++++++++++++++++++++++++++++------------------------- 1 files changed, 118 insertions(+), 103 deletions(-) diff --git a/basic-server/src/main/java/com/ruoyi/basic/service/impl/StandardProductListServiceImpl.java b/basic-server/src/main/java/com/ruoyi/basic/service/impl/StandardProductListServiceImpl.java index 1f2e03a..7603c55 100644 --- a/basic-server/src/main/java/com/ruoyi/basic/service/impl/StandardProductListServiceImpl.java +++ b/basic-server/src/main/java/com/ruoyi/basic/service/impl/StandardProductListServiceImpl.java @@ -14,12 +14,10 @@ import com.ruoyi.basic.service.StandardMethodListService; import com.ruoyi.basic.service.StandardProductListSupplierAskService; import com.ruoyi.common.exception.base.BaseException; -import com.ruoyi.common.utils.QueryWrappers; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.basic.service.StandardProductListService; import lombok.AllArgsConstructor; import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -49,33 +47,24 @@ private ProductPartMapper productPartMapper; - private StructureTestObjectPartMapper structureTestObjectPartMapper; + private StructureTestObjectPartMapper structureTestObjectPartMapper; - @Autowired private StandardMethodListService standardMethodListService; - @Autowired private StructureItemParameterMapper structureItemParameterMapper; - @Autowired private ModelMapper modelMapper; - @Autowired private StandardProductListBackupRelMapper standardProductListBackupRelMapper; - @Autowired private StandardProductListUpdateRecordMapper standardProductListUpdateRecordMapper; - @Autowired private StandardProductListUpdateRecordRelMapper standardProductListUpdateRecordRelMapper; - @Autowired private StandardProductListSupplierAskService standardProductListSupplierAskService; - @Autowired - private StandardProductListSupplierAskBackupRelMapper standardProductListSupplierAskBackupRelMapper; + private StandardProductListSupplierAskBackupRelMapper standardProductListSupplierAskBackupRelMapper; - @Autowired private StandardMethodMapper standardMethodMapper; @@ -83,16 +72,25 @@ public int upStandardProductList(StandardProductList list) { // 鏍规嵁id 鏌ヨ鍒板師濮嬪�� StandardProductList standardProductList = standardProductListMapper.selectById(list.getId()); - if(ObjectUtils.isEmpty(standardProductList)){ + if (ObjectUtils.isEmpty(standardProductList)) { throw new RuntimeException("鏇存柊澶辫触,鏈煡鎵惧埌妫�鏌ラ」"); } // 鍒ゆ柇褰撳墠鐘舵�� 濡傛灉鏄鏍镐腑 - if(StandardProductListChcekTypeEnums.CHECK_ING.getCode().equals(list.getCheckStatus())){ + if (StandardProductListChcekTypeEnums.CHECK_ING.getCode().equals(list.getCheckStatus())) { throw new RuntimeException("瀹℃牳涓笉鏀寔淇敼"); + } + // 鍒ゆ柇妫�楠岄」鏄惁涓烘槸鍚﹀鎵樿姹� 鏄殑璇濅笉闇�瑕佸仛澶囦唤鍜岀姸鎬佷慨鏀圭洿鎺ユ洿鏂� + StructureItemParameter structureItemParameter = structureItemParameterMapper.selectById(standardProductList.getStructureItemParameterId()); + if (!ObjectUtils.isEmpty(structureItemParameter) && "1".equals(structureItemParameter.getDelegateRequestFlag())) { + return standardProductListMapper.updateById(list); + } + // 鍒ゆ柇鏄惁涓虹敓鏁堢殑淇敼濡傛灉鏄笉鍋氬浠� + if (null != list.getState()) { + return standardProductListMapper.updateById(list); } // 鏌ヨ鏈�鏂扮殑涓�娆″叧鑱斿浠� 濡傛灉瀛樺湪璇存槑鏈鏍稿畬缁х画淇敼浜嗐�備笉鍋氭暟鎹鐞嗐�� StandardProductListBackupRel standardProductListBackupRel = standardProductListBackupRelMapper.selectById(list.getId()); - if(ObjectUtils.isEmpty(standardProductListBackupRel)){ + if (ObjectUtils.isEmpty(standardProductListBackupRel)) { StandardProductListBackupRel productListBackupRel = new StandardProductListBackupRel(); BeanUtils.copyProperties(standardProductList, productListBackupRel); standardProductListBackupRelMapper.insert(productListBackupRel); @@ -109,45 +107,18 @@ @Override public List<StandardProductList> selectStandardProductList(InsSampleReceiveDto insSample) { - // 鏄惁娌℃湁浜у搧 - boolean isNoSample = false; -// String[] models = insSample.getModel().split("-(?=[^-]*$)");//鎷嗗垎鏈�鍚庝竴涓��-銆� String model = insSample.getModel(); String modelNum = insSample.getModelNum(); - List<StandardProductList> list = standardProductListMapper.selectDetail(insSample.getStandardMethodListId(), 1, model, insSample.getIsCableTag()); - if (list.size() == 0) { - if (Objects.equals(insSample.getFactory(), "") || insSample.getFactory() == null) { - return null; - } - String[] split = insSample.getFactory().split(" - "); - split[3] = split[3].replace("- ", ""); - String tree = split[0] + " - " + split[1] + " - " + split[2] + " - " + split[3] + " - null"; - list = standardProductListMapper.selectDetail2(insSample.getStandardMethodListId(), 1, tree, insSample.getIsCableTag()); - if (list.size() == 0) { - String tree1 = split[0] + " - " + split[1] + " - " + split[2] + " - null - " + split[3]; - list = standardProductListMapper.selectDetail2(insSample.getStandardMethodListId(), 1, tree1, insSample.getIsCableTag()); - - // 鍙湁瀵硅薄鐨勪竴灞� - if (list.size() == 0) { - String tree2 = split[0] + " - " + split[1] + " - " + split[2] + " - null - null"; - list = standardProductListMapper.selectDetail2(insSample.getStandardMethodListId(), 1, tree2, insSample.getIsCableTag()); - // 鏍峰搧鐩存帴璧嬪�兼牱鍝佸垎绫� - list.forEach(standardProductList -> standardProductList.setSample(standardProductList.getSampleType())); - isNoSample = true; - } - } + // 鏌ヨ妫�鏌ラ」鐩� + StandardProductListDto standardProductListDto = new StandardProductListDto(); + standardProductListDto.setTree(insSample.getFactory()); + standardProductListDto.setStandardMethodListIds(insSample.getStandardMethodListIds()); + standardProductListDto.setState(insSample.getState()); + List<StandardProductList> list = new ArrayList<>(); + if (CollectionUtils.isEmpty(standardProductListDto.getStandardMethodListIds())) { + return list; } - String[] split1 = insSample.getFactory().split(" - "); - if (!isNoSample) { - //鍒ゆ柇闀垮害 - if (split1.length > 4) { - if (ObjectUtils.isNotEmpty(split1[3])) { - list = list.stream().filter(list1 -> Objects.nonNull(list1.getSample()) && Objects.equals(list1.getSample(), split1[3])).collect(Collectors.toList()); - } else if (split1[3].equals("")) { - list = list.stream().filter(list1 -> Objects.nonNull(list1.getSampleType()) && Objects.equals(list1.getSampleType(), split1[2])).collect(Collectors.toList()); - } - } - } + list = standardProductListMapper.standardProductListNoPage(standardProductListDto); list = list.stream().filter(a -> { try { if (a.getSection() != null && !Objects.equals(a.getSection(), "")) { @@ -162,18 +133,54 @@ if (Objects.equals(a.getBsm(), "1")) { return true; } else { - if (sections.get(i).contains("&")) { - String[] split = sections.get(i).split("&"); - isIf = getIsIf(split[0], modelNum, cores.get(i), conductorMaterials.get(i), conductorTypes.get(i), insSample) - && getIsIf(split[1], modelNum, cores.get(i), conductorMaterials.get(i), conductorTypes.get(i), insSample); - } else { - isIf = getIsIf(sections.get(i), modelNum, cores.get(i), conductorMaterials.get(i), conductorTypes.get(i), insSample); + int firstIndex = a.getTree().indexOf(" - "); + String result2 = null; + if (firstIndex != -1) { + int secondIndex = a.getTree().indexOf(" - ", firstIndex + 3); + if (secondIndex != -1) { + int thirdIndex = a.getTree().indexOf(" - ", secondIndex + 3); + if (thirdIndex != -1) { + result2 = a.getTree().substring(secondIndex + 3, thirdIndex); + } + } } - if (isIf) { - a.setSection(sections.get(i)); - a.setAsk(asks.get(i)); - a.setTell(tells.get(i)); - return true; + // 鍒ゆ柇 鍘熻緟鏉� 鍖呮潗 + Set<String> targetStrings = new HashSet<>(); + targetStrings.add("鍘熻緟鏉�"); + targetStrings.add("鍖呮潗"); + boolean isType; + isType = targetStrings.contains(result2); + if (isType) { + if (StringUtils.isNotEmpty(modelNum)){ + String currentSection = sections.get(i); + String sectionValue = currentSection; + int equalIndex = currentSection.indexOf("="); + if (equalIndex != -1) { + sectionValue = currentSection.substring(equalIndex + 1); + } + if (modelNum.equals(sectionValue)) { + a.setSection(sections.get(i)); + a.setAsk(asks.get(i)); + a.setTell(tells.get(i)); + return true; + } + }else { + return false; + } + } else { + if (sections.get(i).contains("&")) { + String[] split = sections.get(i).split("&"); + isIf = getIsIf(split[0], modelNum, cores.get(i), conductorMaterials.get(i), conductorTypes.get(i), insSample) + && getIsIf(split[1], modelNum, cores.get(i), conductorMaterials.get(i), conductorTypes.get(i), insSample); + } else { + isIf = getIsIf(sections.get(i), modelNum, cores.get(i), conductorMaterials.get(i), conductorTypes.get(i), insSample); + } + if (isIf) { + a.setSection(sections.get(i)); + a.setAsk(asks.get(i)); + a.setTell(tells.get(i)); + return true; + } } } } @@ -238,18 +245,18 @@ } ProductPart productPart = productPartMapper.selectOne(new LambdaQueryWrapper<ProductPart>().eq(ProductPart::getPartNo, insSample.getPartNo())); - if (productPart != null){ - if (StringUtils.isNotEmpty(productPart.getInspectionItem())){ + if (productPart != null) { + if (StringUtils.isNotEmpty(productPart.getInspectionItem())) { String inspectionItem = productPart.getInspectionItem(); list = list.stream() - .filter(standardProductList -> inspectionItem.equals(standardProductList.getInspectionItem())) + .filter(standardProductList -> inspectionItem.contains(standardProductList.getInspectionItem())) .collect(Collectors.toList()); } } StructureTestObjectPart structureTestObjectPart = structureTestObjectPartMapper.selectOne(new LambdaQueryWrapper<StructureTestObjectPart>().eq(StructureTestObjectPart::getPartNo, insSample.getPartNo())); - if (structureTestObjectPart != null){ - if (StringUtils.isNotEmpty(structureTestObjectPart.getInspectionItem())){ + if (structureTestObjectPart != null) { + if (StringUtils.isNotEmpty(structureTestObjectPart.getInspectionItem())) { String inspectionItem = structureTestObjectPart.getInspectionItem(); list = list.stream() .filter(standardProductList -> inspectionItem.equals(standardProductList.getInspectionItem())) @@ -260,16 +267,15 @@ } /** - * - * @param str 鍒ゅ畾鍏紡 - * @param model 鍨嬪彿 - * @param standardCores 鑺暟 - * @param conductorMaterial 瀵间綋鏉愯川 - * @param conductorType 瀵间綋绫诲瀷 + * @param str 鍒ゅ畾鍏紡 + * @param model 鍨嬪彿 + * @param standardCores 鑺暟 + * @param conductorMaterial 瀵间綋鏉愯川 + * @param conductorType 瀵间綋绫诲瀷 * @param insSample * @return */ - private boolean getIsIf(String str, String model, String standardCores, String conductorMaterial, String conductorType,InsSampleReceiveDto insSample) { + private boolean getIsIf(String str, String model, String standardCores, String conductorMaterial, String conductorType, InsSampleReceiveDto insSample) { Matcher matcher = Pattern.compile("\\d+(\\.\\d+)?").matcher(model); String model2 = ""; while (matcher.find()) { @@ -342,11 +348,11 @@ boolean existWorkShopFlag = standardMethodListService.existWorkShop(tree); // 鎷兼帴鏍� String[] trees = tree.split(" - "); - if(trees == null && trees.length < 4){ + if (trees == null && trees.length < 4) { return map; } // 杞﹂棿灞傜骇澶氫竴灞傜骇 - if(existWorkShopFlag){ + if (existWorkShopFlag) { switch (trees.length) { case 7: sampleType = trees[4]; @@ -364,7 +370,7 @@ checkItemQueryTree.append("[").append("\"").append(trees[4]).append("\"").append("]"); break; } - }else { + } else { switch (trees.length) { case 6: sampleType = trees[3]; @@ -383,24 +389,26 @@ break; } } - if(StringUtils.isEmpty(checkItemQueryTree.toString())){ + if (StringUtils.isEmpty(checkItemQueryTree.toString())) { return map; } // 鍒ゆ柇鏄惁涓哄鎵樿姹傛爣鍑� StandardMethod standardMethod = standardMethodMapper.selectById(id); - if(ObjectUtils.isEmpty(standardMethod)){ + if (ObjectUtils.isEmpty(standardMethod)) { return map; } StructureItemParameterDto structureItemParameterDto = new StructureItemParameterDto(); - if(standardMethod.getName().equals("濮旀墭瑕佹眰")){ + if (standardMethod.getName().equals("濮旀墭瑕佹眰")) { structureItemParameterDto.setDelegateRequestFlag("1"); + } else { + structureItemParameterDto.setDelegateRequestFlag("0"); } structureItemParameterDto.setTree(checkItemQueryTree.toString()); // 鏍规嵁妫�楠屽璞�/浜у搧鏌ヨ妫�楠岄」 List<StructureItemParameter> structureItemParameterList = structureItemParameterMapper.selectItemParameterBySample(structureItemParameterDto); // 濡傛灉鏄骇鍝佺殑妫�鏌ラ」涓虹┖鍚戜笂鎺� - if(CollectionUtils.isEmpty(structureItemParameterList)){ + if (CollectionUtils.isEmpty(structureItemParameterList)) { String query = "[\"" + sampleType + "\"]"; structureItemParameterDto.setTree(query); structureItemParameterList = structureItemParameterMapper.selectItemParameterBySample(structureItemParameterDto); @@ -418,17 +426,18 @@ boolean existFlag = false; // 鍒ゆ柇鏄惁宸茬粦瀹� for (StandardProductList productList : standardProductList) { - if(structureItemParameter.getId().equals(productList.getStructureItemParameterId())) { + if (structureItemParameter.getId().equals(productList.getStructureItemParameterId())) { BeanUtils.copyProperties(productList, addStandProductList); existFlag = true; break; } } // 濡傛灉鏈粦瀹� - if(!existFlag){ + if (!existFlag) { BeanUtils.copyProperties(structureItemParameter, addStandProductList); + addStandProductList.setTell(structureItemParameter.getAskTell()); addStandProductList.setStructureItemParameterId(structureItemParameter.getId()); - + addStandProductList.setManHour(Objects.toString(structureItemParameter.getManHour(), "")); } addStandProductList.setId(addStandProductList.getId() != null ? addStandProductList.getId() : IdWorker.getId()); batchInsertStandardProductListArray.add(addStandProductList); @@ -509,6 +518,7 @@ /** * 淇敼鏍囧噯搴撳尯闂� + * * @param list * @return */ @@ -516,16 +526,16 @@ public boolean updateSection(StandardProductList list) { // 鏍规嵁id 鏌ヨ鍒板師濮嬪�� StandardProductList standardProductList = standardProductListMapper.selectById(list.getId()); - if(ObjectUtils.isEmpty(standardProductList)){ + if (ObjectUtils.isEmpty(standardProductList)) { throw new RuntimeException("鏇存柊澶辫触,鏈煡鎵惧埌妫�鏌ラ」"); } // 鍒ゆ柇褰撳墠鐘舵�� 濡傛灉鏄鏍镐腑 - if(StandardProductListChcekTypeEnums.CHECK_ING.getCode().equals(list.getCheckStatus())){ + if (StandardProductListChcekTypeEnums.CHECK_ING.getCode().equals(list.getCheckStatus())) { throw new RuntimeException("瀹℃牳涓笉鏀寔淇敼"); } // 鏌ヨ鏈�鏂扮殑涓�娆″叧鑱斿浠� 濡傛灉瀛樺湪璇存槑鏈鏍稿畬缁х画淇敼浜嗐�備笉鍋氭暟鎹鐞嗐�� StandardProductListBackupRel standardProductListBackupRel = standardProductListBackupRelMapper.selectById(list.getId()); - if(ObjectUtils.isEmpty(standardProductListBackupRel)){ + if (ObjectUtils.isEmpty(standardProductListBackupRel)) { StandardProductListBackupRel productListBackupRel = new StandardProductListBackupRel(); BeanUtils.copyProperties(standardProductList, productListBackupRel); standardProductListBackupRelMapper.insert(productListBackupRel); @@ -543,6 +553,7 @@ /** * 鏍囧噯搴撴嫋鎷� + * * @param resetTreeDragDTO */ @Override @@ -561,7 +572,7 @@ resetTreeDragDTO.getTree()); // 浠庝笅寰�涓� - } else if (beginIndex > endIndex){ + } else if (beginIndex > endIndex) { standardProductListMapper.updateSortDown(beginIndex, endIndex, methodId, @@ -582,6 +593,7 @@ /** * 妫�楠岄」瑕佹眰鍊煎姣� + * * @param copyDto * @return */ @@ -625,6 +637,7 @@ /** * 妫�楠岄」澶嶅埗瀵规瘮涓�涓� + * * @param dto * @return */ @@ -659,6 +672,7 @@ /** * 妫�楠岄」澶嶅埗鎺掑簭 + * * @param copyDto * @return */ @@ -697,9 +711,9 @@ public void productListSubmit(StandardProductListUpdateRecord standardProductListUpdateRecord) { // 鏌ヨ鎵�鏈夊緟瀹℃牳鐨勬暟鎹� QueryWrapper<StandardProductList> queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("check_status",StandardProductListChcekTypeEnums.WAIT_CHECK.getCode()); + queryWrapper.eq("check_status", StandardProductListChcekTypeEnums.WAIT_CHECK.getCode()); List<StandardProductList> unCheckStandardProductListArray = standardProductListMapper.selectList(queryWrapper); - if(CollectionUtils.isEmpty(unCheckStandardProductListArray)){ + if (CollectionUtils.isEmpty(unCheckStandardProductListArray)) { throw new RuntimeException("鏆傛棤淇敼鏁版嵁"); } List<Long> standardProductListIds = new ArrayList<>(); @@ -719,11 +733,12 @@ } // 淇敼鏍囧噯鏍戜笅妫�鏌ラ」鐘舵�佷负瀹℃牳涓� - standardProductListMapper.updateProductListCheckStatus(standardProductListIds,StandardProductListChcekTypeEnums.CHECK_ING.getCode()); + standardProductListMapper.updateProductListCheckStatus(standardProductListIds, StandardProductListChcekTypeEnums.CHECK_ING.getCode()); } /** * 鏍囧噯鏍戜笅妫�楠岄」瀹℃牳 + * * @param standardProductListUpdateRecord */ @Override @@ -731,9 +746,9 @@ public void productListCheck(StandardProductListUpdateRecord standardProductListUpdateRecord) { // 鏌ヨ鎵�鏈夊鏍镐腑鐨勬暟鎹� QueryWrapper<StandardProductList> queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("check_status",StandardProductListChcekTypeEnums.CHECK_ING.getCode()); + queryWrapper.eq("check_status", StandardProductListChcekTypeEnums.CHECK_ING.getCode()); List<StandardProductList> standardProductListArray = standardProductListMapper.selectList(queryWrapper); - if(CollectionUtils.isEmpty(standardProductListArray)){ + if (CollectionUtils.isEmpty(standardProductListArray)) { return; } List<Long> standardProductListIds = new ArrayList<>(); @@ -741,12 +756,12 @@ standardProductListIds.add(standardProductList.getId()); } // 瀹℃牳閫氳繃 - if(StandardProductListChcekTypeEnums.PASS_CHECK.getCode().equals(standardProductListUpdateRecord.getCheckStatus())){ + if (StandardProductListChcekTypeEnums.PASS_CHECK.getCode().equals(standardProductListUpdateRecord.getCheckStatus())) { // 淇敼鐘舵�� - standardProductListMapper.updateProductListCheckStatus(standardProductListIds,StandardProductListChcekTypeEnums.PASS_CHECK.getCode()); + standardProductListMapper.updateProductListCheckStatus(standardProductListIds, StandardProductListChcekTypeEnums.PASS_CHECK.getCode()); } // 瀹℃牳鏈�氳繃 - if(StandardProductListChcekTypeEnums.NO_PASS_CHECK.getCode().equals(standardProductListUpdateRecord.getCheckStatus())){ + if (StandardProductListChcekTypeEnums.NO_PASS_CHECK.getCode().equals(standardProductListUpdateRecord.getCheckStatus())) { // 鏌ヨ鎵�鏈夋爣鍑嗘爲涓嬬殑妫�楠岄」鐩浠芥暟鎹� List<StandardProductListBackupRel> standardProductListBackupRelList = standardProductListBackupRelMapper.selectBatchIds(standardProductListIds); // 鍥炴粴鏍囧噯鏍戜笅鐨勬楠岄」鐩暟鎹� @@ -757,11 +772,11 @@ } // 鍥炴粴妫�楠岄」鐩巶瀹跺瘑搴︾粦瀹氳〃鏁版嵁 QueryWrapper<StandardProductListSupplierAskBackupRel> supplierAskBackupRelQueryWrapper = new QueryWrapper<>(); - supplierAskBackupRelQueryWrapper.in("product_list_id",standardProductListIds); + supplierAskBackupRelQueryWrapper.in("product_list_id", standardProductListIds); List<StandardProductListSupplierAskBackupRel> standardProductListSupplierAskBackupRelList = standardProductListSupplierAskBackupRelMapper.selectList(supplierAskBackupRelQueryWrapper); - if(!CollectionUtils.isEmpty(standardProductListSupplierAskBackupRelList)){ + if (!CollectionUtils.isEmpty(standardProductListSupplierAskBackupRelList)) { QueryWrapper<StandardProductListSupplierAsk> deleteWrapper = new QueryWrapper<>(); - deleteWrapper.in("product_list_id",standardProductListIds); + deleteWrapper.in("product_list_id", standardProductListIds); standardProductListSupplierAskMapper.delete(deleteWrapper); ArrayList<StandardProductListSupplierAsk> supplierAskRollBackList = new ArrayList<>(); for (StandardProductListSupplierAskBackupRel standardProductListSupplierAskBackupRel : standardProductListSupplierAskBackupRelList) { @@ -788,11 +803,11 @@ @Override public boolean existCheckingRecord() { QueryWrapper<StandardProductListUpdateRecord> queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("check_status",StandardProductListChcekTypeEnums.CHECK_ING.getCode()); + queryWrapper.eq("check_status", StandardProductListChcekTypeEnums.CHECK_ING.getCode()); List<StandardProductListUpdateRecord> standardProductListUpdateRecordList = standardProductListUpdateRecordMapper.selectList(queryWrapper); - if(CollectionUtils.isEmpty(standardProductListUpdateRecordList)){ + if (CollectionUtils.isEmpty(standardProductListUpdateRecordList)) { return false; - }else { + } else { return true; } } -- Gitblit v1.9.3