Kaynağa Gözat

Merge remote-tracking branch 'origin/master'

user5 6 ay önce
ebeveyn
işleme
276eb605df

+ 66 - 1
src/main/java/com/jeeplus/common/szCcpm/controller/CcpmList.java

@@ -51,6 +51,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.*;
+import java.util.stream.Collectors;
+
 @RestController
 @RequestMapping(value = "${adminPath}/ccpmList/ccpmList")
 public class CcpmList{
@@ -246,7 +248,70 @@ public class CcpmList{
     @RequestMapping(value = "/getAllClient",method = RequestMethod.GET)
     @ResponseBody
     public List<WorkClientInfo> getClient(){
-        List<WorkClientInfo> clientInfoList=workClientInfoDao.getAllClient();
+        List<Office> list = getList();
+        // 使用HashSet来去重
+        Set<WorkClientInfo> clientInfoSet = new HashSet<>();
+        //获取所有的客户信息
+        List<WorkClientInfo> allClient = workClientInfoDao.getAllClient();
+        //存放客户id
+        ArrayList<String> ids = new ArrayList<>();
+        // 创建一个以 id 为键的 Map,以便快速查找
+        Map<String, WorkClientInfo> clientInfoMap = allClient.stream()
+                .collect(Collectors.toMap(WorkClientInfo::getId, client -> client));
+
+        // 遍历每个办公室
+        for (Office office : list) {
+            // 先获取苏州分公司创建的信息
+            if (allClient != null){
+                for (WorkClientInfo workClientInfo : allClient) {
+                    if (workClientInfo.getOfficeId().equals(office.getId())){
+                        ids.add(workClientInfo.getId());
+                    }
+                }
+            }
+
+            // 获取苏州分公司创建的合同所使用的委托方
+            List<WorkContractInfo> contractInfos = workContractInfoDao.getListByOffice(office.getId());
+            if (contractInfos != null) {
+                for (WorkContractInfo contractInfo : contractInfos) {
+                    // 获取客户联系人信息
+                    if (StringUtils.isNotBlank(contractInfo.getClient().getId())) {
+                        ids.add(contractInfo.getClient().getId());
+                    }
+                }
+            }
+
+            // 查询项目下的委托方及施工方信息
+            List<RuralProjectRecords> projectRecords = projectRecordsService.getListByOffice(office.getId());
+            if (projectRecords != null) {
+                for (RuralProjectRecords projectRecord : projectRecords) {
+                    // 获取项目委托方
+                    List<WorkClientLinkman> clientLinkmanList = workClientLinkmanDao.queryProjectLinkmans(projectRecord.getId(), 1);
+                    if (clientLinkmanList != null) {
+                        for (WorkClientLinkman linkman : clientLinkmanList) {
+                            ids.add(linkman.getClientId().getId());
+                        }
+                    }
+
+                    // 获取项目施工方
+                    List<WorkClientLinkman> constructionLinkmanList = workClientLinkmanDao.queryProjectLinkmans(projectRecord.getId(), 3);
+                    for (WorkClientLinkman linkman : constructionLinkmanList) {
+                        ids.add(linkman.getClientId().getId());
+                    }
+                }
+            }
+
+        }
+        if (ids != null){
+            for (String id : ids) {
+                WorkClientInfo clientInfo = clientInfoMap.get(id);
+                if (clientInfo != null) {
+                    clientInfoSet.add(clientInfo);  // 如果找到匹配项,添加到 clientInfoSet
+                }
+            }
+        }
+        List<WorkClientInfo> clientInfoList = new ArrayList<>(clientInfoSet);
+
         //根据客户id查询客户的相关客户类型
         if(clientInfoList!=null && clientInfoList.size()>0){
             for (int i = 0; i < clientInfoList.size(); i++) {

+ 12 - 0
src/main/java/com/jeeplus/modules/workclientinfo/dao/WorkClientInfoDao.java

@@ -68,5 +68,17 @@ public interface WorkClientInfoDao extends CrudDao<WorkClientInfo> {
      */
     WorkClientInfo getByName(String name);
 
+    /**
+     * 查询客户信息
+     * @param officeId
+     * @return
+     */
     List<WorkClientInfo> getAllClient();
+
+    /**
+     * 根据id查询客户信息(做同步处理)
+     * @param id
+     * @return
+     */
+    WorkClientInfo getById(String id);
 }

+ 13 - 0
src/main/resources/mappings/modules/workclientinfo/WorkClientInfoDao.xml

@@ -166,6 +166,7 @@
 		<include refid="workClientInfoColumns"/>
 		,su.name as "userName"
 		,su.mobile as "createMobile"
+		,a.office_id as "officeId"
 		FROM work_client_info a
 		<include refid="workClientInfoJoinsLink"/>
 		left join sys_user su on su.id = a.create_by
@@ -173,6 +174,18 @@
 		where a.del_flag = '0'
 	</select>
 
+	<select id="getById" resultType="WorkClientInfo">
+		SELECT
+		<include refid="workClientInfoColumns"/>
+		,su.name as "userName"
+		,su.mobile as "createMobile"
+		FROM work_client_info a
+		<include refid="workClientInfoJoinsLink"/>
+		left join sys_user su on su.id = a.create_by
+		left join sys_office so on so.id = su.office_id
+		where a.del_flag = '0' and a.id = #{id}
+	</select>
+
 	<select id="findAll" resultType="WorkClientInfo" >
 		SELECT
 		<include refid="workClientInfoColumns"/>