From 4e5d5dbb194f097a19ad8ed0ebb8b0d2247230f3 Mon Sep 17 00:00:00 2001 From: chenrui <1187576398@qq.com> Date: 星期二, 08 四月 2025 15:35:28 +0800 Subject: [PATCH] 成品下单检验项查询修改 --- basic-server/src/main/java/com/ruoyi/basic/service/impl/StandardProductListServiceImpl.java | 161 ++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 114 insertions(+), 47 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 5a53933..79e3f49 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 @@ -12,11 +12,13 @@ import com.ruoyi.basic.mapper.*; import com.ruoyi.basic.pojo.*; 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.aspectj.weaver.ast.Var; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -68,6 +70,15 @@ @Autowired private StandardProductListUpdateRecordRelMapper standardProductListUpdateRecordRelMapper; + @Autowired + private StandardProductListSupplierAskService standardProductListSupplierAskService; + + @Autowired + private StandardProductListSupplierAskBackupRelMapper standardProductListSupplierAskBackupRelMapper; + + @Autowired + private StandardMethodMapper standardMethodMapper; + @Override public int upStandardProductList(StandardProductList list) { @@ -80,6 +91,15 @@ 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)){ @@ -87,6 +107,10 @@ BeanUtils.copyProperties(standardProductList, productListBackupRel); standardProductListBackupRelMapper.insert(productListBackupRel); } + // 鍏宠仈鍟嗗澶囦唤 + StandardProductListSupplierAsk standardProductListSupplierAsk = new StandardProductListSupplierAsk(); + standardProductListSupplierAsk.setProductListId(list.getId()); + standardProductListSupplierAskService.backupSupplierAsk(standardProductListSupplierAsk); // 淇敼鐘舵�� list.setCheckStatus(StandardProductListChcekTypeEnums.WAIT_CHECK.getCode()); return standardProductListMapper.updateById(list); @@ -95,45 +119,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(), "")) { @@ -372,14 +369,27 @@ if(StringUtils.isEmpty(checkItemQueryTree.toString())){ return map; } + // 鍒ゆ柇鏄惁涓哄鎵樿姹傛爣鍑� + StandardMethod standardMethod = standardMethodMapper.selectById(id); + if(ObjectUtils.isEmpty(standardMethod)){ + return map; + } + StructureItemParameterDto structureItemParameterDto = new StructureItemParameterDto(); + if(standardMethod.getName().equals("濮旀墭瑕佹眰")){ + structureItemParameterDto.setDelegateRequestFlag("1"); + }else { + structureItemParameterDto.setDelegateRequestFlag("0"); + } + structureItemParameterDto.setTree(checkItemQueryTree.toString()); + // 鏍规嵁妫�楠屽璞�/浜у搧鏌ヨ妫�楠岄」 - List<StructureItemParameter> structureItemParameterList = structureItemParameterMapper.selectItemParameterBySample(checkItemQueryTree.toString()); + List<StructureItemParameter> structureItemParameterList = structureItemParameterMapper.selectItemParameterBySample(structureItemParameterDto); // 濡傛灉鏄骇鍝佺殑妫�鏌ラ」涓虹┖鍚戜笂鎺� if(CollectionUtils.isEmpty(structureItemParameterList)){ String query = "[\"" + sampleType + "\"]"; - structureItemParameterList = structureItemParameterMapper.selectItemParameterBySample(query); + structureItemParameterDto.setTree(query); + structureItemParameterList = structureItemParameterMapper.selectItemParameterBySample(structureItemParameterDto); } - // 鏌ヨ鏍囧噯搴撳凡缁戝畾妫�鏌ラ」鐩� List<StandardProductList> standardProductList = standardProductListMapper.selectList(Wrappers.<StandardProductList>lambdaQuery() .eq(StandardProductList::getStandardMethodListId, id) @@ -489,6 +499,28 @@ */ @Override public boolean updateSection(StandardProductList list) { + // 鏍规嵁id 鏌ヨ鍒板師濮嬪�� + StandardProductList standardProductList = standardProductListMapper.selectById(list.getId()); + if(ObjectUtils.isEmpty(standardProductList)){ + throw new RuntimeException("鏇存柊澶辫触,鏈煡鎵惧埌妫�鏌ラ」"); + } + // 鍒ゆ柇褰撳墠鐘舵�� 濡傛灉鏄鏍镐腑 + if(StandardProductListChcekTypeEnums.CHECK_ING.getCode().equals(list.getCheckStatus())){ + throw new RuntimeException("瀹℃牳涓笉鏀寔淇敼"); + } + // 鏌ヨ鏈�鏂扮殑涓�娆″叧鑱斿浠� 濡傛灉瀛樺湪璇存槑鏈鏍稿畬缁х画淇敼浜嗐�備笉鍋氭暟鎹鐞嗐�� + StandardProductListBackupRel standardProductListBackupRel = standardProductListBackupRelMapper.selectById(list.getId()); + if(ObjectUtils.isEmpty(standardProductListBackupRel)){ + StandardProductListBackupRel productListBackupRel = new StandardProductListBackupRel(); + BeanUtils.copyProperties(standardProductList, productListBackupRel); + standardProductListBackupRelMapper.insert(productListBackupRel); + } + // 鍏宠仈鍟嗗澶囦唤 + StandardProductListSupplierAsk standardProductListSupplierAsk = new StandardProductListSupplierAsk(); + standardProductListSupplierAsk.setProductListId(list.getId()); + standardProductListSupplierAskService.backupSupplierAsk(standardProductListSupplierAsk); + // 淇敼鐘舵�� + list.setCheckStatus(StandardProductListChcekTypeEnums.WAIT_CHECK.getCode()); standardProductListMapper.updateSection(list); return true; } @@ -652,7 +684,9 @@ QueryWrapper<StandardProductList> queryWrapper = new QueryWrapper<>(); queryWrapper.eq("check_status",StandardProductListChcekTypeEnums.WAIT_CHECK.getCode()); List<StandardProductList> unCheckStandardProductListArray = standardProductListMapper.selectList(queryWrapper); - + if(CollectionUtils.isEmpty(unCheckStandardProductListArray)){ + throw new RuntimeException("鏆傛棤淇敼鏁版嵁"); + } List<Long> standardProductListIds = new ArrayList<>(); // 鎻掑叆淇敼璁板綍 standardProductListUpdateRecordMapper.insert(standardProductListUpdateRecord); @@ -693,27 +727,60 @@ } // 瀹℃牳閫氳繃 if(StandardProductListChcekTypeEnums.PASS_CHECK.getCode().equals(standardProductListUpdateRecord.getCheckStatus())){ - // 鍒犻櫎澶囦唤鏁版嵁 - standardProductListBackupRelMapper.deleteBatchIds(standardProductListIds); // 淇敼鐘舵�� standardProductListMapper.updateProductListCheckStatus(standardProductListIds,StandardProductListChcekTypeEnums.PASS_CHECK.getCode()); } // 瀹℃牳鏈�氳繃 if(StandardProductListChcekTypeEnums.NO_PASS_CHECK.getCode().equals(standardProductListUpdateRecord.getCheckStatus())){ - // 鏌ヨ鎵�鏈夌殑澶囦唤鏁版嵁 + // 鏌ヨ鎵�鏈夋爣鍑嗘爲涓嬬殑妫�楠岄」鐩浠芥暟鎹� List<StandardProductListBackupRel> standardProductListBackupRelList = standardProductListBackupRelMapper.selectBatchIds(standardProductListIds); - // 鍥炴粴鏁版嵁 + // 鍥炴粴鏍囧噯鏍戜笅鐨勬楠岄」鐩暟鎹� for (StandardProductListBackupRel standardProductListBackupRel : standardProductListBackupRelList) { StandardProductList standardProductList = new StandardProductList(); BeanUtils.copyProperties(standardProductListBackupRel, standardProductList); - standardProductList.setCheckStatus(""); standardProductListMapper.updateById(standardProductList); } - // 鍒犻櫎澶囦唤鏁版嵁 - standardProductListBackupRelMapper.deleteBatchIds(standardProductListIds); + // 鍥炴粴妫�楠岄」鐩巶瀹跺瘑搴︾粦瀹氳〃鏁版嵁 + QueryWrapper<StandardProductListSupplierAskBackupRel> supplierAskBackupRelQueryWrapper = new QueryWrapper<>(); + supplierAskBackupRelQueryWrapper.in("product_list_id",standardProductListIds); + List<StandardProductListSupplierAskBackupRel> standardProductListSupplierAskBackupRelList = standardProductListSupplierAskBackupRelMapper.selectList(supplierAskBackupRelQueryWrapper); + if(!CollectionUtils.isEmpty(standardProductListSupplierAskBackupRelList)){ + QueryWrapper<StandardProductListSupplierAsk> deleteWrapper = new QueryWrapper<>(); + deleteWrapper.in("product_list_id",standardProductListIds); + standardProductListSupplierAskMapper.delete(deleteWrapper); + ArrayList<StandardProductListSupplierAsk> supplierAskRollBackList = new ArrayList<>(); + for (StandardProductListSupplierAskBackupRel standardProductListSupplierAskBackupRel : standardProductListSupplierAskBackupRelList) { + StandardProductListSupplierAsk standardProductListSupplierAsk = new StandardProductListSupplierAsk(); + BeanUtils.copyProperties(standardProductListSupplierAskBackupRel, standardProductListSupplierAsk); + supplierAskRollBackList.add(standardProductListSupplierAsk); + } + standardProductListSupplierAskMapper.batchInsertSupplierAsk(supplierAskRollBackList); + } + } + // 鍒犻櫎鏍囧噯鏍戜笅鐨勬楠岄」鐩浠芥暟鎹� + standardProductListBackupRelMapper.deleteBatchIds(standardProductListIds); + // 鍒犻櫎缁戝畾鍘傚澶囦唤鏁版嵁 + standardProductListSupplierAskBackupRelMapper.batchDeleteByProductIds(standardProductListIds); standardProductListUpdateRecordMapper.updateById(standardProductListUpdateRecord); } + + /** + * 鏌ヨ鏍囧噯搴撴槸鍚﹀瓨鍦ㄥ鏍镐腑鐘舵�� + * + * @return + */ + @Override + public boolean existCheckingRecord() { + QueryWrapper<StandardProductListUpdateRecord> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("check_status",StandardProductListChcekTypeEnums.CHECK_ING.getCode()); + List<StandardProductListUpdateRecord> standardProductListUpdateRecordList = standardProductListUpdateRecordMapper.selectList(queryWrapper); + if(CollectionUtils.isEmpty(standardProductListUpdateRecordList)){ + return false; + }else { + return true; + } + } } -- Gitblit v1.9.3