|
@ -43,6 +43,7 @@ import com.epmet.dao.CustomerDepartmentDao; |
|
|
import com.epmet.dao.CustomerGridDao; |
|
|
import com.epmet.dao.CustomerGridDao; |
|
|
import com.epmet.dao.IcBuildingDao; |
|
|
import com.epmet.dao.IcBuildingDao; |
|
|
import com.epmet.dto.CustomerAgencyDTO; |
|
|
import com.epmet.dto.CustomerAgencyDTO; |
|
|
|
|
|
import com.epmet.dto.CustomerDTO; |
|
|
import com.epmet.dto.GovStaffRoleDTO; |
|
|
import com.epmet.dto.GovStaffRoleDTO; |
|
|
import com.epmet.dto.form.*; |
|
|
import com.epmet.dto.form.*; |
|
|
import com.epmet.dto.result.*; |
|
|
import com.epmet.dto.result.*; |
|
@ -50,12 +51,14 @@ import com.epmet.entity.CustomerAgencyEntity; |
|
|
import com.epmet.entity.CustomerDepartmentEntity; |
|
|
import com.epmet.entity.CustomerDepartmentEntity; |
|
|
import com.epmet.entity.CustomerGridEntity; |
|
|
import com.epmet.entity.CustomerGridEntity; |
|
|
import com.epmet.feign.EpmetCommonServiceOpenFeignClient; |
|
|
import com.epmet.feign.EpmetCommonServiceOpenFeignClient; |
|
|
import com.epmet.feign.EpmetMessageOpenFeignClient; |
|
|
|
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
|
|
|
import com.epmet.feign.OperCrmFeignClient; |
|
|
import com.epmet.redis.CustomerAgencyRedis; |
|
|
import com.epmet.redis.CustomerAgencyRedis; |
|
|
import com.epmet.service.AgencyService; |
|
|
import com.epmet.service.AgencyService; |
|
|
import com.epmet.service.CustomerAgencyService; |
|
|
import com.epmet.service.CustomerAgencyService; |
|
|
import com.epmet.service.CustomerOrgParameterService; |
|
|
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.collections4.CollectionUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.slf4j.Logger; |
|
|
import org.slf4j.Logger; |
|
@ -66,10 +69,9 @@ import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
import java.util.ArrayList; |
|
|
import java.util.*; |
|
|
import java.util.Arrays; |
|
|
import java.util.function.Function; |
|
|
import java.util.Date; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 机关单位信息 |
|
|
* 机关单位信息 |
|
@ -99,7 +101,7 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient; |
|
|
private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; |
|
|
private OperCrmFeignClient operCrmFeignClient; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private IcBuildingDao icBuildingDao; |
|
|
private IcBuildingDao icBuildingDao; |
|
|
@Autowired |
|
|
@Autowired |
|
@ -902,6 +904,46 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
return NodeTreeUtils.build(list); |
|
|
return NodeTreeUtils.build(list); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public List<AgencyAreaResultDTO> getAreaSubAgency(TokenDto tokenDto, String areaCode) { |
|
|
|
|
|
if (NumConstant.ZERO_STR.equals(areaCode)) { |
|
|
|
|
|
CustomerAgencyEntity root = customerAgencyDao.getAreaRootAgency(tokenDto.getCustomerId()); |
|
|
|
|
|
areaCode = root.getAreaCode(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<AgencyAreaResultDTO> list = customerAgencyDao.getAreaSubAgency(areaCode); |
|
|
|
|
|
list.forEach(item -> { |
|
|
|
|
|
CustomerDTO customerDTO = new CustomerDTO(); |
|
|
|
|
|
customerDTO.setId(item.getCustomerId()); |
|
|
|
|
|
Result<CustomerDTO> customerResult = operCrmFeignClient.getCustomerInfo(customerDTO); |
|
|
|
|
|
if (customerResult.success() && null != customerResult.getData()) { |
|
|
|
|
|
item.setCustomerName(item.getOrganizationName().concat(StrConstant.HYPHEN).concat(customerResult.getData().getCustomerName())); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return list; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public List<CustomerTreeDTO> getCustomerTree(TokenDto tokenDto) { |
|
|
|
|
|
List<CustomerTreeDTO> resultList = new ArrayList<>(); |
|
|
|
|
|
List<CustomerTreeDTO> rootList = customerAgencyDao.selectRootCustomer(null, null); |
|
|
|
|
|
List<CustomerTreeDTO> treeList = new ArrayList<>(); |
|
|
|
|
|
Map<String, CustomerTreeDTO> treeMap = new HashMap<>(); |
|
|
|
|
|
if (!rootList.isEmpty()) { |
|
|
|
|
|
// 获取已有客户的所有组织架构,并转换成map,保证唯一
|
|
|
|
|
|
rootList.forEach(item -> { |
|
|
|
|
|
customerHandle(item, treeList); |
|
|
|
|
|
}); |
|
|
|
|
|
// treeMap = treeList.stream().collect(Collectors.toMap(CustomerTreeDTO::getAreaCode, Function.identity(), (val1, val2) -> val2));
|
|
|
|
|
|
// 组合成组织树
|
|
|
|
|
|
resultList = getCustomerTree(treeList); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return resultList; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private CustomerAgencyEntity constructInsertEntity(AddAgencyV2FormDTO formDTO, CustomerAgencyDTO parent) { |
|
|
private CustomerAgencyEntity constructInsertEntity(AddAgencyV2FormDTO formDTO, CustomerAgencyDTO parent) { |
|
|
CustomerAgencyEntity insertEntity = ConvertUtils.sourceToTarget(formDTO, CustomerAgencyEntity.class); |
|
|
CustomerAgencyEntity insertEntity = ConvertUtils.sourceToTarget(formDTO, CustomerAgencyEntity.class); |
|
|
insertEntity.setOrganizationName(formDTO.getAgencyName()); |
|
|
insertEntity.setOrganizationName(formDTO.getAgencyName()); |
|
@ -951,4 +993,109 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
return insertEntity; |
|
|
return insertEntity; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 处理子客户 |
|
|
|
|
|
* |
|
|
|
|
|
* @param customer |
|
|
|
|
|
* @return com.epmet.dto.result.CustomerTreeDTO |
|
|
|
|
|
* @author zhy |
|
|
|
|
|
* @date 2022/7/6 13:54 |
|
|
|
|
|
*/ |
|
|
|
|
|
private void customerHandle(CustomerTreeDTO customer, List<CustomerTreeDTO> treeList) { |
|
|
|
|
|
Result<List<CustomerTreeDTO>> area = epmetCommonServiceOpenFeignClient.areaCodeTree(customer); |
|
|
|
|
|
if (area.success()) { |
|
|
|
|
|
if (area.getData() != null) { |
|
|
|
|
|
treeList.addAll(area.getData()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 生成客户树 |
|
|
|
|
|
* |
|
|
|
|
|
* @param |
|
|
|
|
|
* @return com.epmet.dto.result.CustomerTreeDTO |
|
|
|
|
|
* @author wgf |
|
|
|
|
|
* @date 2022/7/6 13:54 |
|
|
|
|
|
*/ |
|
|
|
|
|
private List<CustomerTreeDTO> getCustomerTree(List<CustomerTreeDTO> treeList) { |
|
|
|
|
|
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> 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); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|