Browse Source

提交修改贸易合同代理商

chenxiaofei 8 hours ago
parent
commit
cfb37fa700

+ 6 - 0
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/model/vo/req/QueryListReqVo.java

@@ -117,6 +117,12 @@ public class QueryListReqVo extends PageReq implements Serializable {
     @Schema(description = "供应单位id")
     private String supplyEntId;
 
+    /**
+     * 代理单位id
+     */
+    @Schema(description = "代理单位id")
+    private String agentEntId;
+
     /**
      * 派车方式
      */

+ 5 - 0
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/model/vo/req/QueryTradeReq.java

@@ -42,6 +42,11 @@ public class QueryTradeReq extends PageReq implements Serializable {
      */
     @Schema(description = "供应单位id")
     private String supplyEntId;
+    /**
+     * 代理单位id
+     */
+    @Schema(description = "代理单位id")
+    private String agentEntId;
     /**
      * 合同状态  0已签约 1已完结 2已保存(草稿) 3签约中
      */

+ 12 - 0
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/model/vo/res/QueryListResVo.java

@@ -63,6 +63,18 @@ public class QueryListResVo implements Serializable {
     @Schema(description = "供应单位名")
     private String provideEntName;
 
+    /**
+     * 代理单位id
+     */
+    @Schema(description = "代理单位id")
+    private String agentEntId;
+
+    /**
+     * 代理单位名
+     */
+    @Schema(description = "代理单位名")
+    private String agentEntName;
+
     /**
      * 托运单位名
      */

+ 42 - 1
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/service/operateService/KwcContractTradeService.java

@@ -202,6 +202,7 @@ public class KwcContractTradeService {
         queryTradeReq.setSupplementCode(reqVo.getSupplementCode());
         queryTradeReq.setPurchaseEntId(reqVo.getPurchaseEntId());
         queryTradeReq.setSupplyEntId(reqVo.getSupplyEntId());
+        queryTradeReq.setAgentEntId(reqVo.getAgentEntId());
         queryTradeReq.setDispatchWay(reqVo.getDispatchWay());
         queryTradeReq.setStatus(reqVo.getStatus());
         queryTradeReq.setAgentFlag(reqVo.getAgentFlag());
@@ -1738,6 +1739,9 @@ public class KwcContractTradeService {
             entIds.add(Long.valueOf(req.getSupplyEntId()));
             //type = CooperateTypeEnum.SUPPLIER.getCode();
         }
+        if (org.apache.commons.lang3.StringUtils.isNotBlank(req.getAgentEntId())) {
+            entIds.add(Long.valueOf(req.getAgentEntId()));
+        }
         Set<Long> contractIds = buildTradeQueryContractIds(entId, req, entIds);
         if (org.apache.commons.collections4.CollectionUtils.isEmpty(contractIds)) {
             return Collections.emptyList();
@@ -1874,6 +1878,11 @@ public class KwcContractTradeService {
                     .filter(x -> org.apache.commons.lang3.StringUtils.equals(x.getProvideEntId(), req.getSupplyEntId()))
                     .collect(Collectors.toList());
         }
+        if (org.apache.commons.lang3.StringUtils.isNotBlank(req.getAgentEntId())) {
+            queryListResVos = queryListResVos.stream()
+                    .filter(x -> org.apache.commons.lang3.StringUtils.equals(x.getAgentEntId(), req.getAgentEntId()))
+                    .collect(Collectors.toList());
+        }
         return queryListResVos.stream()
                 .sorted(Comparator.comparing(QueryListResVo::getUpdateTime).reversed()
                         .thenComparing(Comparator.comparing(QueryListResVo::getId).reversed()))
@@ -1959,6 +1968,22 @@ public class KwcContractTradeService {
             log.debug("供应方过滤后剩余合同数量: {} (原数量: {})", contractIds.size(), beforeSize);
         }
 
+        if (org.apache.commons.lang3.StringUtils.isNotBlank(req.getAgentEntId())) {
+            Long agentEntId = Long.valueOf(req.getAgentEntId());
+            log.debug("应用代理单位过滤条件: agentEntId = {}", agentEntId);
+
+            Set<Long> agentContractIds = units.stream()
+                    .filter(unit -> Objects.equals(unit.getEntId(), agentEntId))
+                    .filter(unit -> Objects.equals(unit.getUnitType(), CooperateTypeEnum.SUPPLIER.getCode()))
+                    .map(KwcContractTradeUnit::getContractId)
+                    .filter(Objects::nonNull)
+                    .collect(Collectors.toSet());
+
+            int beforeSize = contractIds.size();
+            contractIds.retainAll(agentContractIds);
+            log.debug("代理单位过滤后剩余合同数量: {} (原数量: {})", contractIds.size(), beforeSize);
+        }
+
         log.info("最终构建的合同ID集合大小: {}, entId: {}, purchaseEntId: {}, supplyEntId: {}", 
                 contractIds.size(), entId, req.getPurchaseEntId(), req.getSupplyEntId());
         return contractIds;
@@ -1979,6 +2004,9 @@ public class KwcContractTradeService {
         if (org.apache.commons.lang3.StringUtils.isNotBlank(req.getSupplyEntId())) {
             entIds.add(Long.valueOf(req.getSupplyEntId()));
         }
+        if (org.apache.commons.lang3.StringUtils.isNotBlank(req.getAgentEntId())) {
+            entIds.add(Long.valueOf(req.getAgentEntId()));
+        }
         Set<Long> contractIds = buildTradeQueryContractIds(entId, req, entIds);
         if (org.apache.commons.collections4.CollectionUtils.isEmpty(contractIds)) {
             return 0L;
@@ -2038,7 +2066,8 @@ public class KwcContractTradeService {
         }
 
         if (org.apache.commons.lang3.StringUtils.isNotBlank(req.getPurchaseEntId())
-                || org.apache.commons.lang3.StringUtils.isNotBlank(req.getSupplyEntId())) {
+                || org.apache.commons.lang3.StringUtils.isNotBlank(req.getSupplyEntId())
+                || org.apache.commons.lang3.StringUtils.isNotBlank(req.getAgentEntId())) {
             Set<Long> tradeContractIds = records.stream().map(KwcContractTrade::getId).collect(Collectors.toSet());
             List<KwcContractTradeUnit> tradeUnits = kwcContractTradeUnitRepository.queryByContractIds(tradeContractIds);
             Map<String, KwcContractTradeUnit> contractUnitTypeKeyAndUnitMap = Maps.newHashMap();
@@ -2065,6 +2094,14 @@ public class KwcContractTradeService {
                     return org.apache.commons.lang3.StringUtils.equals(String.valueOf(provideEnt.getEntId()), req.getSupplyEntId());
                 }).collect(Collectors.toList());
             }
+            if (org.apache.commons.lang3.StringUtils.isNotBlank(req.getAgentEntId())) {
+                records = records.stream().filter(record -> {
+                    KwcContractTradeUnit provideEnt =
+                            finalContractUnitTypeKeyAndUnitMap.getOrDefault(record.getId() + "-" + CooperateTypeEnum.SUPPLIER.getCode(),
+                                    new KwcContractTradeUnit());
+                    return org.apache.commons.lang3.StringUtils.equals(String.valueOf(provideEnt.getEntId()), req.getAgentEntId());
+                }).collect(Collectors.toList());
+            }
         }
         return records.size();
     }
@@ -2123,6 +2160,10 @@ public class KwcContractTradeService {
                         new KwcContractTradeUnit());
         queryListResVo.setProvideEntId(String.valueOf(provideEnt.getEntId()));
         queryListResVo.setProvideEntName(provideEnt.getFirmName());
+        if (Objects.equals(t.getAgentFlag(), Global.YES)) {
+            queryListResVo.setAgentEntId(String.valueOf(provideEnt.getEntId()));
+            queryListResVo.setAgentEntName(provideEnt.getFirmName());
+        }
         //queryListResVo.setCheckedEntName();
         queryListResVo.setContractNo(t.getContractNo());
         queryListResVo.setContractName(t.getName());