|
|
@ -57,6 +57,7 @@ import com.epmet.redis.CustomerAgencyRedis; |
|
|
|
import com.epmet.service.AgencyService; |
|
|
|
import com.epmet.service.CustomerAgencyService; |
|
|
|
import com.epmet.service.CustomerOrgParameterService; |
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
|
import com.google.common.base.Joiner; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
@ -935,7 +936,7 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
}); |
|
|
|
treeMap = treeList.stream().collect(Collectors.toMap(CustomerTreeDTO::getAreaCode, Function.identity(), (val1, val2) -> val2)); |
|
|
|
// 组合成组织树
|
|
|
|
rootList = getCustomerTree(treeMap); |
|
|
|
rootList = getCustomerTree(treeList); |
|
|
|
// 回显客户名称
|
|
|
|
rootList.forEach(item -> { |
|
|
|
List<String> customerNames = new ArrayList<>(); |
|
|
@ -1029,10 +1030,68 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
* @author zhy |
|
|
|
* @date 2022/7/6 13:54 |
|
|
|
*/ |
|
|
|
private List<CustomerTreeDTO> getCustomerTree(Map<String, CustomerTreeDTO> treeMap) { |
|
|
|
List<CustomerTreeDTO> tree = new ArrayList<>(); |
|
|
|
// todo 组合树形结构
|
|
|
|
return tree; |
|
|
|
private List<CustomerTreeDTO> getCustomerTree(List<CustomerTreeDTO> treeList) { |
|
|
|
treeList = treeList.stream().distinct().collect(Collectors.toList()); |
|
|
|
|
|
|
|
// 省
|
|
|
|
List<CustomerTreeDTO> province = new ArrayList<CustomerTreeDTO>(); |
|
|
|
// 市
|
|
|
|
List<CustomerTreeDTO> city = new ArrayList<CustomerTreeDTO>(); |
|
|
|
// 区
|
|
|
|
List<CustomerTreeDTO> district = new ArrayList<CustomerTreeDTO>(); |
|
|
|
// 街道
|
|
|
|
List<CustomerTreeDTO> street = new ArrayList<CustomerTreeDTO>(); |
|
|
|
// 社区
|
|
|
|
List<CustomerTreeDTO> community = new ArrayList<CustomerTreeDTO>(); |
|
|
|
for(int i = 0 ; i < treeList.size() ; i++){ |
|
|
|
if("province".equals(treeList.get(i).getLevel())){ |
|
|
|
province.add(treeList.get(i)); |
|
|
|
} else if("city".equals(treeList.get(i).getLevel())){ |
|
|
|
city.add(treeList.get(i)); |
|
|
|
} else if("district".equals(treeList.get(i).getLevel())){ |
|
|
|
district.add(treeList.get(i)); |
|
|
|
} else if("street".equals(treeList.get(i).getLevel())){ |
|
|
|
street.add(treeList.get(i)); |
|
|
|
} else if("community".equals(treeList.get(i).getLevel())){ |
|
|
|
community.add(treeList.get(i)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 组装街道树
|
|
|
|
for(CustomerTreeDTO streetDto : street){ |
|
|
|
this.addChild(streetDto,community); |
|
|
|
} |
|
|
|
// 组装区树
|
|
|
|
for(CustomerTreeDTO districtDto : district){ |
|
|
|
this.addChild(districtDto,street); |
|
|
|
} |
|
|
|
// 组装市树
|
|
|
|
for(CustomerTreeDTO cityDto : city){ |
|
|
|
this.addChild(cityDto,district); |
|
|
|
} |
|
|
|
// 组装省树
|
|
|
|
for(CustomerTreeDTO provinceDto : province){ |
|
|
|
this.addChild(provinceDto,city); |
|
|
|
} |
|
|
|
|
|
|
|
return province; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 组装子项 |
|
|
|
* @param parentDto |
|
|
|
* @param childList |
|
|
|
*/ |
|
|
|
private void addChild(CustomerTreeDTO parentDto,List<CustomerTreeDTO> childList){ |
|
|
|
List<CustomerTreeDTO> children = new ArrayList<CustomerTreeDTO>(); |
|
|
|
for(CustomerTreeDTO childDto : childList){ |
|
|
|
if(parentDto.getAreaCode().equals(childDto.getParentCode())){ |
|
|
|
children.add(childDto); |
|
|
|
} |
|
|
|
} |
|
|
|
parentDto.setChildren(children); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|