|
|
@ -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.google.common.base.Joiner; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
@ -922,13 +923,31 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<CustomerTreeDTO> getCustomerTree(TokenDto tokenDto) { |
|
|
|
List<CustomerTreeDTO> rootList = customerAgencyDao.selectRootCustomer(); |
|
|
|
List<CustomerTreeDTO> rootList = customerAgencyDao.selectRootCustomer(null, null); |
|
|
|
Map<String, CustomerTreeDTO> treeMap = new HashMap<>(); |
|
|
|
if (!rootList.isEmpty()) { |
|
|
|
// 获取已有客户的所有组织架构,并转换成map,保证唯一
|
|
|
|
rootList.forEach(item -> { |
|
|
|
getSubCustomer(item, treeMap); |
|
|
|
customerHandle(item, treeMap); |
|
|
|
}); |
|
|
|
// 组合成组织树
|
|
|
|
rootList = getCustomerTree(treeMap); |
|
|
|
// 回显客户名称
|
|
|
|
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; |
|
|
|
} |
|
|
|
|
|
|
@ -989,16 +1008,27 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
* @author zhy |
|
|
|
* @date 2022/7/6 13:54 |
|
|
|
*/ |
|
|
|
private void getSubCustomer(CustomerTreeDTO customer,Map<String, CustomerTreeDTO> treeMap) { |
|
|
|
|
|
|
|
private void customerHandle(CustomerTreeDTO customer, Map<String, CustomerTreeDTO> treeMap) { |
|
|
|
Result<List<CustomerTreeDTO>> area = epmetCommonServiceOpenFeignClient.areaCodeTree(customer); |
|
|
|
if (area.success()) { |
|
|
|
if (area.getData() != null) { |
|
|
|
area.getData().forEach(item->{ |
|
|
|
treeMap.put(item.getAreaCode(),item); |
|
|
|
}); |
|
|
|
area.getData().forEach(item -> treeMap.put(item.getAreaCode(), item)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 生成客户树 |
|
|
|
* |
|
|
|
* @param |
|
|
|
* @return com.epmet.dto.result.CustomerTreeDTO |
|
|
|
* @author zhy |
|
|
|
* @date 2022/7/6 13:54 |
|
|
|
*/ |
|
|
|
private List<CustomerTreeDTO> getCustomerTree(Map<String, CustomerTreeDTO> treeMap) { |
|
|
|
List<CustomerTreeDTO> tree = new ArrayList<>(); |
|
|
|
// todo 组合树形结构
|
|
|
|
return tree; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|