|
@@ -51,6 +51,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping(value = "${adminPath}/ccpmList/ccpmList")
|
|
@RequestMapping(value = "${adminPath}/ccpmList/ccpmList")
|
|
public class CcpmList{
|
|
public class CcpmList{
|
|
@@ -246,7 +248,70 @@ public class CcpmList{
|
|
@RequestMapping(value = "/getAllClient",method = RequestMethod.GET)
|
|
@RequestMapping(value = "/getAllClient",method = RequestMethod.GET)
|
|
@ResponseBody
|
|
@ResponseBody
|
|
public List<WorkClientInfo> getClient(){
|
|
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查询客户的相关客户类型
|
|
//根据客户id查询客户的相关客户类型
|
|
if(clientInfoList!=null && clientInfoList.size()>0){
|
|
if(clientInfoList!=null && clientInfoList.size()>0){
|
|
for (int i = 0; i < clientInfoList.size(); i++) {
|
|
for (int i = 0; i < clientInfoList.size(); i++) {
|