Browse Source

完善客户树

master
zhangyuan 3 years ago
parent
commit
6f0f4f2ea9
  1. 5
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/CustomerTreeDTO.java
  2. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java
  3. 44
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java
  4. 6
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml

5
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/CustomerTreeDTO.java

@ -34,11 +34,6 @@ public class CustomerTreeDTO implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/**
* 主键
*/
private String id;
/** /**
* 客户id * 客户id
*/ */

2
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java

@ -372,7 +372,7 @@ public interface CustomerAgencyDao extends BaseDao<CustomerAgencyEntity> {
* @author zhy * @author zhy
* @date 2022/7/6 13:32 * @date 2022/7/6 13:32
*/ */
List<CustomerTreeDTO> selectRootCustomer(); List<CustomerTreeDTO> selectRootCustomer(@Param("areaCode") String areaCode, @Param("level") String level);
CustomerAgencyEntity getAreaRootAgency(@Param("customerId") String customerId); CustomerAgencyEntity getAreaRootAgency(@Param("customerId") String customerId);

44
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java

@ -57,6 +57,7 @@ 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.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;
@ -922,13 +923,31 @@ public class AgencyServiceImpl implements AgencyService {
@Override @Override
public List<CustomerTreeDTO> getCustomerTree(TokenDto tokenDto) { public List<CustomerTreeDTO> getCustomerTree(TokenDto tokenDto) {
List<CustomerTreeDTO> rootList = customerAgencyDao.selectRootCustomer(); List<CustomerTreeDTO> rootList = customerAgencyDao.selectRootCustomer(null, null);
Map<String, CustomerTreeDTO> treeMap = new HashMap<>(); Map<String, CustomerTreeDTO> treeMap = new HashMap<>();
if (!rootList.isEmpty()) { if (!rootList.isEmpty()) {
// 获取已有客户的所有组织架构,并转换成map,保证唯一
rootList.forEach(item -> { 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; return rootList;
} }
@ -989,16 +1008,27 @@ public class AgencyServiceImpl implements AgencyService {
* @author zhy * @author zhy
* @date 2022/7/6 13:54 * @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); Result<List<CustomerTreeDTO>> area = epmetCommonServiceOpenFeignClient.areaCodeTree(customer);
if (area.success()) { if (area.success()) {
if (area.getData() != null) { if (area.getData() != null) {
area.getData().forEach(item->{ area.getData().forEach(item -> treeMap.put(item.getAreaCode(), 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;
} }
} }

6
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml

@ -956,6 +956,12 @@
c.DEL_FLAG = '0' c.DEL_FLAG = '0'
AND c.pid = '0' AND c.pid = '0'
AND c.AREA_CODE IS NOT NULL AND c.AREA_CODE IS NOT NULL
<if test="areaCode != null and areaCode != ''">
AND c.AREA_CODE = #{areaCode}
</if>
<if test="level != null and level != ''">
AND c.LEVEL = #{level}
</if>
</select> </select>
<select id="getAreaRootAgency" resultType="com.epmet.entity.CustomerAgencyEntity"> <select id="getAreaRootAgency" resultType="com.epmet.entity.CustomerAgencyEntity">

Loading…
Cancel
Save