|
@ -926,6 +926,7 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public List<CustomerTreeDTO> getCustomerTree(TokenDto tokenDto) { |
|
|
public List<CustomerTreeDTO> getCustomerTree(TokenDto tokenDto) { |
|
|
|
|
|
List<CustomerTreeDTO> resultList = new ArrayList<>(); |
|
|
List<CustomerTreeDTO> rootList = customerAgencyDao.selectRootCustomer(null, null); |
|
|
List<CustomerTreeDTO> rootList = customerAgencyDao.selectRootCustomer(null, null); |
|
|
List<CustomerTreeDTO> treeList = new ArrayList<>(); |
|
|
List<CustomerTreeDTO> treeList = new ArrayList<>(); |
|
|
Map<String, CustomerTreeDTO> treeMap = new HashMap<>(); |
|
|
Map<String, CustomerTreeDTO> treeMap = new HashMap<>(); |
|
@ -934,26 +935,13 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
rootList.forEach(item -> { |
|
|
rootList.forEach(item -> { |
|
|
customerHandle(item, treeList); |
|
|
customerHandle(item, treeList); |
|
|
}); |
|
|
}); |
|
|
treeMap = treeList.stream().collect(Collectors.toMap(CustomerTreeDTO::getAreaCode, Function.identity(), (val1, val2) -> val2)); |
|
|
// treeMap = treeList.stream().collect(Collectors.toMap(CustomerTreeDTO::getAreaCode, Function.identity(), (val1, val2) -> val2));
|
|
|
// 组合成组织树
|
|
|
// 组合成组织树
|
|
|
rootList = getCustomerTree(treeList); |
|
|
resultList = getCustomerTree(treeList); |
|
|
// 回显客户名称
|
|
|
|
|
|
rootList.forEach(item -> { |
|
|
|
|
|
List<String> customerNames = new ArrayList<>(); |
|
|
|
|
|
List<CustomerTreeDTO> subList = customerAgencyDao.selectRootCustomer(item.getAreaCode(), item.getLevel()); |
|
|
|
|
|
if (!subList.isEmpty()) { |
|
|
|
|
|
CustomerDTO customerDTO = new CustomerDTO(); |
|
|
|
|
|
customerDTO.setId(item.getCustomerId()); |
|
|
|
|
|
Result<CustomerDTO> customerResult = operCrmFeignClient.getCustomerInfo(customerDTO); |
|
|
|
|
|
if (customerResult.success() && null != customerResult.getData()) { |
|
|
|
|
|
customerNames.add(customerResult.getData().getCustomerName()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
item.setCustomerName(Joiner.on(",").join(customerNames)); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return rootList; |
|
|
return resultList; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private CustomerAgencyEntity constructInsertEntity(AddAgencyV2FormDTO formDTO, CustomerAgencyDTO parent) { |
|
|
private CustomerAgencyEntity constructInsertEntity(AddAgencyV2FormDTO formDTO, CustomerAgencyDTO parent) { |
|
@ -1027,12 +1015,27 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
* |
|
|
* |
|
|
* @param |
|
|
* @param |
|
|
* @return com.epmet.dto.result.CustomerTreeDTO |
|
|
* @return com.epmet.dto.result.CustomerTreeDTO |
|
|
* @author zhy |
|
|
* @author wgf |
|
|
* @date 2022/7/6 13:54 |
|
|
* @date 2022/7/6 13:54 |
|
|
*/ |
|
|
*/ |
|
|
private List<CustomerTreeDTO> getCustomerTree(List<CustomerTreeDTO> treeList) { |
|
|
private List<CustomerTreeDTO> getCustomerTree(List<CustomerTreeDTO> treeList) { |
|
|
treeList = treeList.stream().distinct().collect(Collectors.toList()); |
|
|
treeList = treeList.stream().distinct().collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
// 回显客户名称
|
|
|
|
|
|
treeList.forEach(item -> { |
|
|
|
|
|
List<String> customerNames = new ArrayList<>(); |
|
|
|
|
|
List<CustomerTreeDTO> subList = customerAgencyDao.selectRootCustomer(item.getAreaCode(), item.getLevel()); |
|
|
|
|
|
subList.forEach(customer -> { |
|
|
|
|
|
CustomerDTO customerDTO = new CustomerDTO(); |
|
|
|
|
|
customerDTO.setId(customer.getCustomerId()); |
|
|
|
|
|
Result<CustomerDTO> customerResult = operCrmFeignClient.getCustomerInfo(customerDTO); |
|
|
|
|
|
if (customerResult.success() && null != customerResult.getData()) { |
|
|
|
|
|
customerNames.add(customerResult.getData().getCustomerName()); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
item.setCustomerName(Joiner.on(",").join(customerNames)); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
// 省
|
|
|
// 省
|
|
|
List<CustomerTreeDTO> province = new ArrayList<CustomerTreeDTO>(); |
|
|
List<CustomerTreeDTO> province = new ArrayList<CustomerTreeDTO>(); |
|
|
// 市
|
|
|
// 市
|
|
@ -1043,35 +1046,35 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
List<CustomerTreeDTO> street = new ArrayList<CustomerTreeDTO>(); |
|
|
List<CustomerTreeDTO> street = new ArrayList<CustomerTreeDTO>(); |
|
|
// 社区
|
|
|
// 社区
|
|
|
List<CustomerTreeDTO> community = new ArrayList<CustomerTreeDTO>(); |
|
|
List<CustomerTreeDTO> community = new ArrayList<CustomerTreeDTO>(); |
|
|
for(int i = 0 ; i < treeList.size() ; i++){ |
|
|
for (int i = 0; i < treeList.size(); i++) { |
|
|
if("province".equals(treeList.get(i).getLevel())){ |
|
|
if ("province".equals(treeList.get(i).getLevel())) { |
|
|
province.add(treeList.get(i)); |
|
|
province.add(treeList.get(i)); |
|
|
} else if("city".equals(treeList.get(i).getLevel())){ |
|
|
} else if ("city".equals(treeList.get(i).getLevel())) { |
|
|
city.add(treeList.get(i)); |
|
|
city.add(treeList.get(i)); |
|
|
} else if("district".equals(treeList.get(i).getLevel())){ |
|
|
} else if ("district".equals(treeList.get(i).getLevel())) { |
|
|
district.add(treeList.get(i)); |
|
|
district.add(treeList.get(i)); |
|
|
} else if("street".equals(treeList.get(i).getLevel())){ |
|
|
} else if ("street".equals(treeList.get(i).getLevel())) { |
|
|
street.add(treeList.get(i)); |
|
|
street.add(treeList.get(i)); |
|
|
} else if("community".equals(treeList.get(i).getLevel())){ |
|
|
} else if ("community".equals(treeList.get(i).getLevel())) { |
|
|
community.add(treeList.get(i)); |
|
|
community.add(treeList.get(i)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 组装街道树
|
|
|
// 组装街道树
|
|
|
for(CustomerTreeDTO streetDto : street){ |
|
|
for (CustomerTreeDTO streetDto : street) { |
|
|
this.addChild(streetDto,community); |
|
|
this.addChild(streetDto, community); |
|
|
} |
|
|
} |
|
|
// 组装区树
|
|
|
// 组装区树
|
|
|
for(CustomerTreeDTO districtDto : district){ |
|
|
for (CustomerTreeDTO districtDto : district) { |
|
|
this.addChild(districtDto,street); |
|
|
this.addChild(districtDto, street); |
|
|
} |
|
|
} |
|
|
// 组装市树
|
|
|
// 组装市树
|
|
|
for(CustomerTreeDTO cityDto : city){ |
|
|
for (CustomerTreeDTO cityDto : city) { |
|
|
this.addChild(cityDto,district); |
|
|
this.addChild(cityDto, district); |
|
|
} |
|
|
} |
|
|
// 组装省树
|
|
|
// 组装省树
|
|
|
for(CustomerTreeDTO provinceDto : province){ |
|
|
for (CustomerTreeDTO provinceDto : province) { |
|
|
this.addChild(provinceDto,city); |
|
|
this.addChild(provinceDto, city); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return province; |
|
|
return province; |
|
@ -1080,13 +1083,14 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 组装子项 |
|
|
* 组装子项 |
|
|
|
|
|
* |
|
|
* @param parentDto |
|
|
* @param parentDto |
|
|
* @param childList |
|
|
* @param childList |
|
|
*/ |
|
|
*/ |
|
|
private void addChild(CustomerTreeDTO parentDto,List<CustomerTreeDTO> childList){ |
|
|
private void addChild(CustomerTreeDTO parentDto, List<CustomerTreeDTO> childList) { |
|
|
List<CustomerTreeDTO> children = new ArrayList<CustomerTreeDTO>(); |
|
|
List<CustomerTreeDTO> children = new ArrayList<CustomerTreeDTO>(); |
|
|
for(CustomerTreeDTO childDto : childList){ |
|
|
for (CustomerTreeDTO childDto : childList) { |
|
|
if(parentDto.getAreaCode().equals(childDto.getParentCode())){ |
|
|
if (parentDto.getAreaCode().equals(childDto.getParentCode())) { |
|
|
children.add(childDto); |
|
|
children.add(childDto); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|