瀏覽代碼

根据贸易合同查询单位信息

chenxiaofei 9 小時之前
父節點
當前提交
a097e73eea

+ 10 - 0
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/controller/KwcContractSaleController.java

@@ -7,6 +7,7 @@ import com.sckw.contract.api.model.dto.res.LogisticsOrderDto;
 import com.sckw.contract.model.vo.req.*;
 import com.sckw.contract.model.vo.res.ContractDetailResp;
 import com.sckw.contract.model.vo.res.ContractStatusCountResp;
+import com.sckw.contract.model.vo.res.ContractTradeEntResp;
 import com.sckw.contract.model.vo.res.QueryListResVo;
 import com.sckw.contract.service.operateService.KwcContractTradeService;
 import com.sckw.core.model.enums.EntTypeEnum;
@@ -265,6 +266,15 @@ public class KwcContractSaleController {
         return BaseResult.success(kwcContractTradeService.queryContractDetail(req));
     }
 
+    /**
+     * 根据贸易合同查询采购、供应及代理企业
+     */
+    @PostMapping("/queryContractTradeEnt")
+    @Operation(summary = "查询贸易合同关联企业")
+    public BaseResult<ContractTradeEntResp> queryContractTradeEnt(@Valid @RequestBody IdReqVo reqVo) {
+        return BaseResult.success(kwcContractTradeService.queryContractTradeEnt(reqVo.getId()));
+    }
+
     /**
      * 查询物流合同
      */

+ 57 - 0
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/model/vo/res/ContractTradeEntResp.java

@@ -0,0 +1,57 @@
+package com.sckw.contract.model.vo.res;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * 贸易合同关联企业信息
+ */
+@Data
+public class ContractTradeEntResp implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    @Schema(description = "合同id")
+    private Long contractId;
+
+    @Schema(description = "合同编号")
+    private String contractCode;
+
+    @Schema(description = "合同名称")
+    private String contractName;
+
+    @Schema(description = "采购企业")
+    private EntUnitInfo purchaseEnt;
+
+    @Schema(description = "供应企业")
+    private EntUnitInfo provideEnt;
+
+    @Schema(description = "代理企业")
+    private EntUnitInfo agentEnt;
+
+    @Data
+    public static class EntUnitInfo implements Serializable {
+
+        @Serial
+        private static final long serialVersionUID = 1L;
+
+        @Schema(description = "企业id")
+        private Long entId;
+
+        @Schema(description = "企业名称")
+        private String firmName;
+
+        @Schema(description = "联系人")
+        private String contacts;
+
+        @Schema(description = "联系电话")
+        private String phone;
+
+        @Schema(description = "签约联系电话")
+        private String signPhone;
+    }
+}

+ 36 - 0
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/service/operateService/KwcContractTradeService.java

@@ -1801,6 +1801,42 @@ public class KwcContractTradeService {
         return tradeBaseInfo;
     }
 
+    /**
+     * 根据贸易合同查询采购、供应及代理企业信息
+     */
+    public ContractTradeEntResp queryContractTradeEnt(Long contractId) {
+        KwcContractTrade kwcContractTrade = kwcContractTradeRepository.queryByContractId(contractId);
+        if (Objects.isNull(kwcContractTrade)) {
+            return new ContractTradeEntResp();
+        }
+        List<KwcContractTradeUnit> tradeUnits = kwcContractTradeUnitRepository.queryByContractId(contractId);
+        Map<Integer, KwcContractTradeUnit> unitTypeMap = CollectionUtils.isEmpty(tradeUnits)
+                ? Collections.emptyMap()
+                : tradeUnits.stream().collect(Collectors.toMap(KwcContractTradeUnit::getUnitType, Function.identity(), (v1, v2) -> v1));
+
+        ContractTradeEntResp resp = new ContractTradeEntResp();
+        resp.setContractId(kwcContractTrade.getId());
+        resp.setContractCode(kwcContractTrade.getContractNo());
+        resp.setContractName(kwcContractTrade.getName());
+        resp.setPurchaseEnt(toEntUnitInfo(unitTypeMap.get(CooperateTypeEnum.PURCHASER.getCode())));
+        resp.setProvideEnt(toEntUnitInfo(unitTypeMap.get(CooperateTypeEnum.SUPPLIER.getCode())));
+        resp.setAgentEnt(toEntUnitInfo(unitTypeMap.get(KwcContractTradeUnitService.TRADE_AGENT_UNIT_TYPE)));
+        return resp;
+    }
+
+    private static ContractTradeEntResp.EntUnitInfo toEntUnitInfo(KwcContractTradeUnit unit) {
+        if (Objects.isNull(unit) || Objects.isNull(unit.getEntId())) {
+            return null;
+        }
+        ContractTradeEntResp.EntUnitInfo entUnitInfo = new ContractTradeEntResp.EntUnitInfo();
+        entUnitInfo.setEntId(unit.getEntId());
+        entUnitInfo.setFirmName(unit.getFirmName());
+        entUnitInfo.setContacts(unit.getContacts());
+        entUnitInfo.setPhone(unit.getPhone());
+        entUnitInfo.setSignPhone(unit.getSignPhone());
+        return entUnitInfo;
+    }
+
     public List<QueryListResVo> queryTradeListByPage(QueryTradeReq req) {
 
         Long entId;

+ 5 - 0
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/model/vo/req/AddressQueryReqVo.java

@@ -61,4 +61,9 @@ public class AddressQueryReqVo extends PageRequest implements Serializable {
      */
     private String ids;
 
+    /**
+     * 企业id(传入时按该企业查询地址)
+     */
+    private Long entId;
+
 }

+ 6 - 6
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/KwmAddressService.java

@@ -110,8 +110,12 @@ public class KwmAddressService {
      */
     private List<KwmAddress> findList(AddressQueryReqVo reqVo, List<Long> authEntIdList) {
         LambdaQueryWrapper<KwmAddress> wrapper = new LambdaQueryWrapper<>();
-        if (CollectionUtils.isNotEmpty(authEntIdList)) {
-            wrapper.in(KwmAddress::getEntId, authEntIdList);
+        if (Objects.nonNull(reqVo.getEntId())) {
+            wrapper.eq(KwmAddress::getEntId, reqVo.getEntId());
+        } else {
+            if (CollectionUtils.isNotEmpty(authEntIdList)) {
+                wrapper.in(KwmAddress::getEntId, authEntIdList);
+            }
         }
         wrapper.in(Objects.nonNull(reqVo.getCityCode()), KwmAddress::getCityCode, reqVo.getCityCodeList()).
                 eq(Objects.nonNull(reqVo.getType()), KwmAddress::getType, reqVo.getType()).
@@ -135,10 +139,6 @@ public class KwmAddressService {
             wrapper.in(KwmAddress::getId, StringUtils.splitStrToList(reqVo.getIds(), Long.class));
         }
 
-        if (!Objects.equals(LoginUserHolder.getSystemType(), SystemTypeEnum.MANAGE.getCode())) {
-            wrapper.eq(KwmAddress::getEntId, LoginUserHolder.getEntId());
-        }
-
         return kwmAddressMapper.selectList(wrapper);
     }