Przeglądaj źródła

fix:结算单新增提交校验-结算的验收货物必须全部选择

CAYK\miaosen.zhao 6 miesięcy temu
rodzic
commit
9063f8ff4d

+ 20 - 0
src/main/java/com/inkasso/factoring/settlement/service/Impl/SettlementManagementServiceImpl.java

@@ -778,8 +778,18 @@ public class SettlementManagementServiceImpl extends ServiceImpl<SettlementBasic
             //校验验收单货物
             List<Long> acceptanceBasicInfoIds = settlementGoodsInfos.stream().map(SettlementGoodsInfo::getcAcceptanceBasicInfoId)
                     .distinct().collect(Collectors.toList());
+//          //结算货物按验收单编号分组
+            LinkedHashMap<Long, List<SettlementGoodsInfo>> acceptanceGoodsNumbers = settlementGoodsInfos.stream()
+                    .collect(Collectors.groupingBy((b) -> b.getcAcceptanceBasicInfoId(), LinkedHashMap::new, Collectors.toList()));
             acceptanceBasicInfoIds.forEach(id -> {
                 CAcceptanceBasicInfo basicInfo = icAcceptanceBasicInfoService.getById(id);
+                List<CAcceptanceGoodsInfo> cAcceptanceGoodsInfos = icAcceptanceGoodsInfoService.list(new QueryWrapper<CAcceptanceGoodsInfo>().eq("c_acceptance_basic_info_id", id));
+                if(CollectionUtil.isNotEmpty(cAcceptanceGoodsInfos)){
+                    List<SettlementGoodsInfo> settlementGoodsInfos1 = acceptanceGoodsNumbers.get(id);
+                    if(CollectionUtil.isNotEmpty(settlementGoodsInfos1) && settlementGoodsInfos1.size() != cAcceptanceGoodsInfos.size()){
+                        throw new BusinessException(CodeUtil.FAIL, "验收单编号:"+basicInfo.getAcceptanceNumber()+"存在货物未选中结算,请新选择结算货物");
+                    }
+                }
                 if (basicInfo.getSettlement()) {
                     throw new BusinessException(CodeUtil.FAIL, "存在已结算或者正在结算的货物");
                 } else {
@@ -1061,8 +1071,18 @@ public class SettlementManagementServiceImpl extends ServiceImpl<SettlementBasic
             //校验验收单货物
             List<Long> acceptanceBasicInfoIds = settlementGoodsInfos.stream().map(SettlementGoodsInfo::getcAcceptanceBasicInfoId)
                     .distinct().collect(Collectors.toList());
+            //          //结算货物按验收单编号分组
+            LinkedHashMap<Long, List<SettlementGoodsInfo>> acceptanceGoodsNumbers = settlementGoodsInfos.stream()
+                    .collect(Collectors.groupingBy((b) -> b.getcAcceptanceBasicInfoId(), LinkedHashMap::new, Collectors.toList()));
             acceptanceBasicInfoIds.forEach(id -> {
                 CAcceptanceBasicInfo basicInfo = icAcceptanceBasicInfoService.getById(id);
+                List<CAcceptanceGoodsInfo> cAcceptanceGoodsInfos = icAcceptanceGoodsInfoService.list(new QueryWrapper<CAcceptanceGoodsInfo>().eq("c_acceptance_basic_info_id", id));
+                if(CollectionUtil.isNotEmpty(cAcceptanceGoodsInfos)){
+                    List<SettlementGoodsInfo> settlementGoodsInfos1 = acceptanceGoodsNumbers.get(id);
+                    if(CollectionUtil.isNotEmpty(settlementGoodsInfos1) && settlementGoodsInfos1.size() != cAcceptanceGoodsInfos.size()){
+                        throw new BusinessException(CodeUtil.FAIL, "验收单编号:"+basicInfo.getAcceptanceNumber()+"存在货物未选中结算,请新选择结算货物");
+                    }
+                }
                 if (basicInfo.getSettlement()) {
                     throw new BusinessException(CodeUtil.FAIL, "存在已结算或者正在结算的货物");
                 } else {