浏览代码

客户详情添加关联合同、合同详情添加关联项目

lizhenhao 2 年之前
父节点
当前提交
875ca27e00

+ 7 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/contractRegistration/controller/ContractInfoController.java

@@ -106,4 +106,11 @@ public class ContractInfoController {
     public void updateInfo(@RequestBody ContractInfo info) {
         service.updateInfo(info);
     }
+
+    @ApiOperation(value = "根据客户id查询关联的项目")
+    @GetMapping("/getByClientId")
+    public ResponseEntity<List<ContractInfo>> getByClientId(String clientId) {
+        List<ContractInfo> list = service.getByClientId(clientId);
+        return ResponseEntity.ok(list);
+    }
 }

+ 12 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/contractRegistration/domain/ContractInfo.java

@@ -173,4 +173,16 @@ public class ContractInfo extends BaseEntity {
      */
     @TableField(exist = false)
     private String clientContactsName;
+
+    /**
+     * 创建人
+     */
+    @TableField(exist = false)
+    private String createName;
+
+    /**
+     * 创建时间
+     */
+    @TableField(exist = false)
+    private Date createDate;
 }

+ 6 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/contractRegistration/mapper/ContractInfoMapper.java

@@ -57,4 +57,10 @@ public interface ContractInfoMapper extends BaseMapper<ContractInfo> {
                     @Param("contractApprovalType") String contractApprovalType);
 
     List<String> findChildIds(String department);
+
+    List<ContractInfo> getByClientId(@Param("ids") List<String> ids);
+
+    // 没有使用客户id作为参数,而是直接查询,是因为 合同与客户的关联表 中没有 客户id 的字段,只有客户编号的字段
+    List<String> getClientListByClientNo(@Param("no") String no);
+
 }

+ 26 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/contractRegistration/mapper/xml/ContractInfoMapper.xml

@@ -195,4 +195,30 @@
     <select id="findFileInfoById" resultType="com.jeeplus.test.cw.contractRegistration.domain.ContractInfo">
         select * from cw_work_contract_info where id = #{id}
     </select>
+    <select id="getByClientId" resultType="com.jeeplus.test.cw.contractRegistration.domain.ContractInfo" parameterType="string">
+        select
+            cw_wci.contract_name,
+            cw_wci.id,
+            cw_wci.contract_no,
+            cw_wci.signing_date,
+            cw_wci.contract_amount,
+            cw_wci.department,
+            cw_wci.create_date,
+            cw_wci.create_by as create_id,
+            su.name as create_name,
+            so.name as department_name
+        from cw_work_contract_info cw_wci
+        left join sys_user su on su.id = cw_wci.create_by and su.del_flag = '0'
+        left join sys_office so on so.id = cw_wci.department and so.del_flag = '0'
+        where cw_wci.del_flag = '0' and cw_wci.id in
+        <foreach collection="ids" item="item" separator="," open="(" close=")">
+            #{item}
+        </foreach>
+    </select>
+    <select id="getClientListByClientNo" resultType="string">
+        select
+            cw_wcp.contract_info_id
+        from cw_work_contract_participant cw_wcp
+        where cw_wcp.del_flag = '0' and cw_wcp.customer_no = #{no}
+    </select>
 </mapper>

+ 20 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/contractRegistration/service/ContractInfoService.java

@@ -1,5 +1,7 @@
 package com.jeeplus.test.cw.contractRegistration.service;
 
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.druid.sql.visitor.functions.If;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -17,6 +19,8 @@ import com.jeeplus.test.cw.contractRegistration.mapper.ContractFileMapper;
 import com.jeeplus.test.cw.contractRegistration.mapper.ContractFilePaperMapper;
 import com.jeeplus.test.cw.contractRegistration.mapper.ContractInfoMapper;
 import com.jeeplus.test.cw.contractRegistration.mapper.ContractParticipantMapper;
+import com.jeeplus.test.cw.workClientInfo.domain.CwWorkClientBase;
+import com.jeeplus.test.cw.workClientInfo.service.CwWorkClientService;
 import com.jeeplus.test.cw.workClientInfo.service.dto.CwWorkClientBaseDTO;
 import com.jeeplus.test.mould.service.SerialnumTplService;
 import com.jeeplus.test.oss.domain.WorkAttachment;
@@ -60,6 +64,9 @@ public class ContractInfoService {
     @Resource
     private ContractParticipantMapper participantMapper;
 
+    @Resource
+    private CwWorkClientService cwWorkClientService;
+
     /**
      * 根据id修改status
      */
@@ -563,4 +570,17 @@ public class ContractInfoService {
             }
         }
     }
+
+    public List<ContractInfo> getByClientId(String clientId){
+        CwWorkClientBase cwWorkClientBase = cwWorkClientService.getById(clientId);
+        if (ObjectUtil.isNotEmpty(cwWorkClientBase)) {
+            if (StringUtils.isNotBlank(cwWorkClientBase.getNo())) {
+                List<String> ids = mapper.getClientListByClientNo(cwWorkClientBase.getNo());
+                if (CollectionUtil.isNotEmpty(ids)){
+                    return mapper.getByClientId(ids);
+                }
+            }
+        }
+        return new ArrayList<>();
+    }
 }

+ 12 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/projectRecords/controller/CwProjectRecordsController.java

@@ -167,4 +167,16 @@ public class CwProjectRecordsController {
         return ResponseEntity.ok(cwProjectRecordsDTOList);
     }
 
+    /**
+     * 根据合同id获取关联的项目信息
+     * @param contractId
+     * @return
+     */
+    @ApiOperation(value = "根据合同id获取关联的项目信息")
+    @GetMapping(value = "/getByContractId")
+    public ResponseEntity<List<CwProjectRecordsDTO>> getByContractId(String contractId) {
+        List<CwProjectRecordsDTO> cwProjectRecordsDTOList = cwProjectRecordsService.getByContractId(contractId);
+        return ResponseEntity.ok(cwProjectRecordsDTOList);
+    }
+
 }

+ 2 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/projectRecords/mapper/CwProjectRecordsMapper.java

@@ -52,4 +52,6 @@ public interface CwProjectRecordsMapper extends BaseMapper<CwProjectRecords> {
     List<String> getProjectIdByClientId(@Param("id") String id);
 
     List<CwProjectRecordsDTO> getProjectByIdList(@Param("ids") List<String> ids);
+
+    List<CwProjectRecordsDTO> getByContractId(@Param("id") String id);
 }

+ 11 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/projectRecords/mapper/xml/CwProjectRecordsMapper.xml

@@ -234,4 +234,15 @@
         </foreach>
         order by a.create_date desc
     </select>
+
+    <select id="getByContractId" resultType="com.jeeplus.test.cw.projectRecords.service.dto.CwProjectRecordsDTO">
+        select
+            <include refid="Base_Column_List"></include>,
+            su.name as create_name,
+            su2.name as project_master_name
+        from cw_project_records a
+        left join sys_user su on su.id = a.create_by and su.del_flag = '0'
+        left join sys_user su2 on su2.id = a.project_master_id and su2.del_flag = '0'
+        where a.contract_id = #{id} and a.del_flag = '0'
+    </select>
 </mapper>

+ 9 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/projectRecords/service/CwProjectRecordsService.java

@@ -205,6 +205,15 @@ public class CwProjectRecordsService extends ServiceImpl<CwProjectRecordsMapper,
         }
     }
 
+    /**
+     * 根据合同id获取关联的项目信息
+     * @param contractId
+     * @return
+     */
+    public List<CwProjectRecordsDTO> getByContractId(String contractId) {
+        return cwProjectRecordsMapper.getByContractId(contractId);
+    }
+