Browse Source

Merge branch 'feature/dev_union'

master
wanggongfeng 3 years ago
parent
commit
daa94615bd
  1. 2
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/AreaCodeDTO.java
  2. 13
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/AreaCodeDetailFormDTO.java
  3. 76
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/CustomerTreeDTO.java
  4. 22
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java
  5. 10
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java
  6. 28
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/AreaCodeController.java
  7. 10
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/AreaCodeDao.java
  8. 10
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/AreaCodeService.java
  9. 113
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java
  10. 10
      epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/AreaCodeChildDao.xml
  11. 31
      epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/AreaCodeDao.xml
  12. 128
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencyAreaResultDTO.java
  13. 29
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java
  14. 23
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java
  15. 21
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java
  16. 155
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java
  17. 51
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml
  18. 5
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/CustomerRelationDTO.java
  19. 41
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerRelationFormDTO.java
  20. 111
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CustomerRelationTreeDTO.java
  21. 12
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java
  22. 5
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java
  23. 6
      epmet-module/oper-crm/oper-crm-server/pom.xml
  24. 104
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerRelationController.java
  25. 33
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerRelationDao.java
  26. 5
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerRelationEntity.java
  27. 25
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerRelationService.java
  28. 59
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerRelationServiceImpl.java
  29. 42
      epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerRelationDao.xml

2
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/AreaCodeDTO.java

@ -37,7 +37,7 @@ public class AreaCodeDTO implements Serializable {
/**
* 主键
*/
private Integer id;
private String id;
/**
* 省份code

13
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/AreaCodeDetailFormDTO.java

@ -0,0 +1,13 @@
package com.epmet.dto.form;
import lombok.Data;
@Data
public class AreaCodeDetailFormDTO {
private String areaCode;
/**
* 省级:province; 市级: city; 区县级: district ;街道:street ;社区级community
*/
private String level;
}

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

@ -0,0 +1,76 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 客户关系表(01.14 add)
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-02-03
*/
@Data
public class CustomerTreeDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 客户id
*/
private String customerId;
/**
* 当前客户级别社区级community
街道:street,
区县级: district,
市级: city
省级:province
*/
private String level;
/**
* 当前客户的地区编码实际就是根组织的area_code
*/
private String areaCode;
/**
* 当前客户的地区名称
*/
private String areaName;
/**
* 当前客户的父节点地区名称
*/
private String parentCode;
/**
* 客户名称
*/
private String customerName;
/**
* 下一级
*/
private List<CustomerTreeDTO> children;
}

22
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java

@ -98,6 +98,28 @@ public interface EpmetCommonServiceOpenFeignClient {
@PostMapping("commonservice/workday/workminutes")
Result<Map<String,Integer>> workMinutes(@RequestBody WorkMinuteFormDTO param);
/**
* 行政地区编码查询
*
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.result.AreaCodeDictResultDTO>>
* @author zhy
* @date 2022/7/6 15:07
*/
@PostMapping("commonservice/areacode/areacodedetail")
Result<AreaCodeResultDTO> areaCodeDetail(@RequestBody AreaCodeDetailFormDTO formDTO);
/**
* 行政地区编码树查询
*
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.result.AreaCodeDictResultDTO>>
* @author zhy
* @date 2022/7/6 15:07
*/
@PostMapping("commonservice/areacode/areacodetree")
Result<List<CustomerTreeDTO>> areaCodeTree(@RequestBody CustomerTreeDTO formDTO);
/**
* @Description 行政地区编码查询
* @Param formDTO

10
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java

@ -79,6 +79,16 @@ public class EpmetCommonServiceOpenFeignClientFallback implements EpmetCommonSer
return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "workMinutes", param);
}
@Override
public Result<AreaCodeResultDTO> areaCodeDetail(AreaCodeDetailFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "areaCodeDetail", formDTO);
}
@Override
public Result<List<CustomerTreeDTO>> areaCodeTree(CustomerTreeDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "areaCodeTree", formDTO);
}
@Override
public Result<List<AreaCodeDictResultDTO>> areaCodeDictTree(AreaCodeDictFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "areaCodeDictTree", formDTO);

28
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/AreaCodeController.java

@ -25,12 +25,10 @@ import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.AreaCodeDTO;
import com.epmet.dto.form.AddAreaCodeDictFormDTO;
import com.epmet.dto.form.AddAreaCodeFormDTO;
import com.epmet.dto.form.AreaCodeDictFormDTO;
import com.epmet.dto.form.AreaCodeFormDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.AreaCodeDictResultDTO;
import com.epmet.dto.result.AreaCodeResultDTO;
import com.epmet.dto.result.CustomerTreeDTO;
import com.epmet.service.AreaCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -133,4 +131,26 @@ public class AreaCodeController {
public Result<List<AreaCodeResultDTO>> nextArea(@RequestBody AreaCodeFormDTO formDTO){
return new Result<List<AreaCodeResultDTO>>().ok(areaCodeService.nextArea(formDTO));
}
/**
* @Description 行政地区编码查询
* @Param formDTO
* @author zxc
* @date 2021/1/7 下午1:41
*/
@PostMapping("areacodedetail")
public Result<AreaCodeResultDTO> areaCodeDetail(@RequestBody AreaCodeDetailFormDTO formDTO){
return new Result<AreaCodeResultDTO>().ok(areaCodeService.getAreaCodeDetail(formDTO));
}
/**
* @Description 行政地区编码查询
* @Param formDTO
* @author zxc
* @date 2021/1/7 下午1:41
*/
@PostMapping("areacodetree")
public Result<List<CustomerTreeDTO>> areaCodeTree(@RequestBody CustomerTreeDTO formDTO){
return new Result<List<CustomerTreeDTO>>().ok(areaCodeService.getAreaCodeTree(formDTO));
}
}

10
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/AreaCodeDao.java

@ -37,9 +37,15 @@ public interface AreaCodeDao extends BaseDao<AreaCodeEntity> {
List<AreaCodeDTO> selectAllArea();
AreaCodeDTO selectByCountyCode(String countyCode);
AreaCodeDTO selectByCountyCode(@Param("countyCode") String countyCode);
AreaCodeDTO selectByCityCode(String cityCode);
AreaCodeDTO selectByCityCode(@Param("cityCode") String cityCode);
AreaCodeDTO selectByProvinceCode(@Param("provinceCode") String provinceCode);
AreaCodeResultDTO selectByStreetCode(@Param("streetCode") String streetCode);
AreaCodeResultDTO selectByCommunityCode(@Param("communityCode") String communityCode);
AreaCodeDTO selectMaxCounty(String cityCode);

10
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/AreaCodeService.java

@ -20,12 +20,10 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.AreaCodeDTO;
import com.epmet.dto.form.AddAreaCodeDictFormDTO;
import com.epmet.dto.form.AddAreaCodeFormDTO;
import com.epmet.dto.form.AreaCodeDictFormDTO;
import com.epmet.dto.form.AreaCodeFormDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.AreaCodeDictResultDTO;
import com.epmet.dto.result.AreaCodeResultDTO;
import com.epmet.dto.result.CustomerTreeDTO;
import com.epmet.entity.AreaCodeEntity;
import java.util.List;
@ -127,4 +125,8 @@ public interface AreaCodeService extends BaseService<AreaCodeEntity> {
String addAreaCode(AddAreaCodeFormDTO formDTO);
List<AreaCodeResultDTO> nextArea(AreaCodeFormDTO formDTO);
AreaCodeResultDTO getAreaCodeDetail(AreaCodeDetailFormDTO formDTO);
List<CustomerTreeDTO> getAreaCodeTree(CustomerTreeDTO formDTO);
}

113
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java

@ -36,12 +36,10 @@ import com.epmet.dao.AreaCodeChildDao;
import com.epmet.dao.AreaCodeDao;
import com.epmet.dto.AreaCodeChildDTO;
import com.epmet.dto.AreaCodeDTO;
import com.epmet.dto.form.AddAreaCodeDictFormDTO;
import com.epmet.dto.form.AddAreaCodeFormDTO;
import com.epmet.dto.form.AreaCodeDictFormDTO;
import com.epmet.dto.form.AreaCodeFormDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.AreaCodeDictResultDTO;
import com.epmet.dto.result.AreaCodeResultDTO;
import com.epmet.dto.result.CustomerTreeDTO;
import com.epmet.entity.AreaCodeEntity;
import com.epmet.redis.AreaCodeRedis;
import com.epmet.service.AreaCodeChildService;
@ -72,6 +70,7 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
private AreaCodeChildDao childDao;
@Autowired
private AreaCodeChildService areaCodeChildService;
@Override
public PageData<AreaCodeDTO> page(Map<String, Object> params) {
IPage<AreaCodeEntity> page = baseDao.selectPage(
@ -240,14 +239,11 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
/**
* @Description 根据节点获取组织区域树遍历传参只能是 区级别 暂时这样循环太多了
*
*
* <p>
* <p>
* 暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样
* ==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==
* 暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样
*
*
*
* @Param tree
* @Param rootAreaCode
* @author zxc
@ -734,6 +730,105 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
return list;
}
@Override
public AreaCodeResultDTO getAreaCodeDetail(AreaCodeDetailFormDTO formDTO) {
AreaCodeResultDTO result = new AreaCodeResultDTO();
switch (formDTO.getLevel()) {
case AreaCodeConstant.PROVINCE:
AreaCodeDTO province = baseDao.selectByProvinceCode(formDTO.getAreaCode());
if (province != null) {
result.setAreaName(province.getProvinceName());
result.setAreaCode(province.getProvinceCode());
result.setParentCode(NumConstant.ZERO_STR);
result.setLevel(AreaCodeConstant.PROVINCE);
}
break;
case AreaCodeConstant.CITY:
AreaCodeDTO city = baseDao.selectByCityCode(formDTO.getAreaCode());
if (city != null) {
result.setAreaName(city.getCityName());
result.setAreaCode(city.getCityName());
result.setParentCode(city.getProvinceCode());
result.setLevel(AreaCodeConstant.CITY);
}
break;
case AreaCodeConstant.DISTRICT:
AreaCodeDTO county = baseDao.selectByCountyCode(formDTO.getAreaCode());
if (county != null) {
result.setAreaName(county.getCountyName());
result.setAreaCode(county.getCountyCode());
result.setParentCode(county.getCityCode());
result.setLevel(AreaCodeConstant.DISTRICT);
}
break;
case AreaCodeConstant.STREET:
result = baseDao.selectByStreetCode(formDTO.getAreaCode());
break;
case AreaCodeConstant.COMMUNITY:
result = baseDao.selectByCommunityCode(formDTO.getAreaCode());
break;
default:
log.warn("Level错误:" + formDTO.getLevel());
}
return result;
}
@Override
public List<CustomerTreeDTO> getAreaCodeTree(CustomerTreeDTO formDTO) {
List<AreaCodeResultDTO> tree = new ArrayList<>();
areaCodeHandle(formDTO.getLevel(), formDTO.getAreaCode(), tree);
return ConvertUtils.sourceToTarget(tree, CustomerTreeDTO.class);
}
private void areaCodeHandle(String level, String areaCode, List<AreaCodeResultDTO> tree) {
AreaCodeResultDTO result = new AreaCodeResultDTO();
switch (level) {
case AreaCodeConstant.PROVINCE:
AreaCodeDTO province = baseDao.selectByProvinceCode(areaCode);
if (province != null) {
result.setAreaName(province.getProvinceName());
result.setAreaCode(province.getProvinceCode());
result.setParentCode(NumConstant.ZERO_STR);
result.setLevel(AreaCodeConstant.PROVINCE);
tree.add(result);
}
break;
case AreaCodeConstant.CITY:
AreaCodeDTO city = baseDao.selectByCityCode(areaCode);
if (city != null) {
result.setAreaName(city.getCityName());
result.setAreaCode(city.getCityCode());
result.setParentCode(city.getProvinceCode());
result.setLevel(AreaCodeConstant.CITY);
tree.add(result);
areaCodeHandle(AreaCodeConstant.PROVINCE, city.getProvinceCode(), tree);
}
break;
case AreaCodeConstant.DISTRICT:
AreaCodeDTO county = baseDao.selectByCountyCode(areaCode);
if (county != null) {
result.setAreaName(county.getCountyName());
result.setAreaCode(county.getCountyCode());
result.setParentCode(county.getCityCode());
result.setLevel(AreaCodeConstant.DISTRICT);
tree.add(result);
areaCodeHandle(AreaCodeConstant.CITY, county.getCityCode(), tree);
}
break;
case AreaCodeConstant.STREET:
result = baseDao.selectByStreetCode(areaCode);
tree.add(result);
areaCodeHandle(AreaCodeConstant.DISTRICT, result.getParentCode(), tree);
break;
case AreaCodeConstant.COMMUNITY:
result = baseDao.selectByCommunityCode(areaCode);
tree.add(result);
areaCodeHandle(AreaCodeConstant.STREET, result.getParentCode(), tree);
break;
default:
log.warn("Level错误:" + level);
}
}
private String addDistrictAreaCode(String cityCode, String countyName) {
AreaCodeDTO city = baseDao.selectByCityCode(cityCode);

10
epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/AreaCodeChildDao.xml

@ -20,6 +20,16 @@
and m.`CODE`=#{code}
</select>
<select id="getByCode" resultType="com.epmet.dto.result.AreaCodeResultDTO">
SELECT
*
FROM
area_code_child m
WHERE
m.DEL_FLAG = '0'
and m.`CODE`= #{code}
</select>
<!-- 根据p_code、name查询社区列表 -->
<select id="selectByPCodeAndName" resultType="com.epmet.dto.AreaCodeChildDTO">
SELECT

31
epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/AreaCodeDao.xml

@ -19,6 +19,13 @@
and ac.CITY_CODE=#{cityCode}
</select>
<select id="selectByProvinceCode" resultType="com.epmet.dto.AreaCodeDTO">
select distinct ac.PROVINCE_CODE,ac.PROVINCE_NAME
from area_code ac
where ac.DEL_FLAG='0'
and ac.PROVINCE_CODE=#{provinceCode}
</select>
<select id="selectMaxCounty" resultType="com.epmet.dto.AreaCodeDTO" parameterType="java.lang.String">
select *
from area_code ac
@ -106,4 +113,28 @@
ORDER BY
ac.`code` ASC
</select>
<select id="selectByStreetCode" resultType="com.epmet.dto.result.AreaCodeResultDTO">
SELECT
ac.`code` AS areaCode,
ac.`name` AS areaName,
ac.p_code AS parentCode,
'street' AS LEVEL
FROM
area_code_child ac
WHERE
ac.DEL_FLAG = '0'
AND ac.`code` = #{streetCode}
</select>
<select id="selectByCommunityCode" resultType="com.epmet.dto.result.AreaCodeResultDTO">
SELECT
ac.`code` AS areaCode,
ac.`name` AS areaName,
ac.p_code AS parentCode,
'street' AS LEVEL
FROM
area_code_child ac
WHERE
ac.DEL_FLAG = '0'
AND ac.`code` = #{communityCode}
</select>
</mapper>

128
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencyAreaResultDTO.java

@ -0,0 +1,128 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* 组织信息
*
* @author sun
*/
@Data
public class AgencyAreaResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 客户ID
*/
private String customerId;
/**
* 客户名称
*/
private String customerName;
/**
* 上级组织机构ID
*/
private String pid;
/**
* 所有上级组织机构ID(以英文:隔开)
*/
private String pids;
/**
* 所有上级名称,-连接
*/
private String allParentName;
/**
* 组织名称
*/
private String organizationName;
/**
* 机关级别社区级community
街道:street,
区县级: district,
市级: city
省级:province 机关级别社区级community街道:street,区县级: district,市级: city省级:province
*/
private String level;
/**
* 地区编码
*/
private String areaCode;
/**
* 总人数
*/
private Integer totalUser;
/**
*
*/
private String province;
/**
* 城市名称
*/
private String city;
/**
* 区县名称
*/
private String district;
/**
* 当前组织的上级行政地区编码add0204;举例平阴县对应的是济南市3701
*/
private String parentAreaCode;
/**
* 街道
*/
private String street;
/**
* 社区名称0409
*/
private String community;
/**
* 组织编码
*/
private String code;
/**
* 负责人姓名
*/
private String contacts;
/**
* 联系电话
*/
private String mobile;
}

29
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java

@ -505,4 +505,33 @@ public class AgencyController {
List<AgencyAddressBookTreeResultDTO> dto = agencyService.getAddressTree(name, customerId);
return new Result<List<AgencyAddressBookTreeResultDTO>>().ok(dto);
}
/**
* 获取区域编码下级的所有客户信息
*
* @param areaCode
* @return com.epmet.commons.tools.utils.Result<java.util.List < com.epmet.dto.result.AgencyAreaResultDTO>>
* @author zhy
* @date 2022/7/7 10:12
*/
@GetMapping("/areasubagency/{areaCode}")
public Result<List<AgencyAreaResultDTO>> getAreaSubAgency(@LoginUser TokenDto tokenDto, @PathVariable String areaCode) {
List<AgencyAreaResultDTO> dto = agencyService.getAreaSubAgency(tokenDto, areaCode);
return new Result<List<AgencyAreaResultDTO>>().ok(dto);
}
/**
* 客户树
*
* @param
* @return com.epmet.commons.tools.utils.Result<java.util.List < com.epmet.dto.result.CustomerRelationTreeDTO>>
* @author zhy
* @date 2022/7/6 13:24
*/
@RequestMapping("customertree")
public Result<List<CustomerTreeDTO>> customerTree(@LoginUser TokenDto tokenDto) {
return new Result<List<CustomerTreeDTO>>().ok(agencyService.getCustomerTree(tokenDto));
}
}

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

@ -353,5 +353,28 @@ public interface CustomerAgencyDao extends BaseDao<CustomerAgencyEntity> {
CommunityInfoResultDTO getCommunityInfo(OrgInfoPointFormDTO formDTO);
CommunityInfoResultDTO getCommunityInfoByUserId(@Param("userId") String userId);
/**
* 获取区域编码下级的所有客户信息
*
* @param areaCode
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.result.AgencyAreaResultDTO>>
* @author zhy
* @date 2022/7/7 10:12
*/
List<AgencyAreaResultDTO> getAreaSubAgency(@Param("areaCode") String areaCode);
/**
* 客户树根节点
*
* @param
* @return java.util.List<com.epmet.dto.result.CustomerTreeDTO>
* @author zhy
* @date 2022/7/6 13:32
*/
List<CustomerTreeDTO> selectRootCustomer(@Param("areaCode") String areaCode, @Param("level") String level);
CustomerAgencyEntity getAreaRootAgency(@Param("customerId") String customerId);
}

21
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java

@ -178,4 +178,25 @@ public interface AgencyService {
* @date 2022/5/16 10:43
*/
List<AgencyAddressBookTreeResultDTO> getAddressTree(String name, String customerId);
/**
* 获取区域编码下级的所有客户信息
*
* @param areaCode
* @return com.epmet.commons.tools.utils.Result<java.util.List < com.epmet.dto.result.AgencyAreaResultDTO>>
* @author zhy
* @date 2022/7/7 10:12
*/
List<AgencyAreaResultDTO> getAreaSubAgency(TokenDto tokenDto, String areaCode);
/**
* 客户树
*
* @param tokenDto
* @return java.util.List<com.epmet.dto.result.CustomerTreeDTO>
* @author zhy
* @date 2022/7/6 13:32
*/
List<CustomerTreeDTO> getCustomerTree(TokenDto tokenDto);
}

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

@ -43,6 +43,7 @@ import com.epmet.dao.CustomerDepartmentDao;
import com.epmet.dao.CustomerGridDao;
import com.epmet.dao.IcBuildingDao;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.CustomerDTO;
import com.epmet.dto.GovStaffRoleDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
@ -50,12 +51,14 @@ import com.epmet.entity.CustomerAgencyEntity;
import com.epmet.entity.CustomerDepartmentEntity;
import com.epmet.entity.CustomerGridEntity;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.feign.EpmetMessageOpenFeignClient;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.feign.OperCrmFeignClient;
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;
import org.slf4j.Logger;
@ -66,10 +69,9 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* 机关单位信息
@ -99,7 +101,7 @@ public class AgencyServiceImpl implements AgencyService {
@Autowired
private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient;
@Autowired
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient;
private OperCrmFeignClient operCrmFeignClient;
@Autowired
private IcBuildingDao icBuildingDao;
@Autowired
@ -902,6 +904,58 @@ public class AgencyServiceImpl implements AgencyService {
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> 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));
// 组合成组织树
rootList = 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;
}
private CustomerAgencyEntity constructInsertEntity(AddAgencyV2FormDTO formDTO, CustomerAgencyDTO parent) {
CustomerAgencyEntity insertEntity = ConvertUtils.sourceToTarget(formDTO, CustomerAgencyEntity.class);
insertEntity.setOrganizationName(formDTO.getAgencyName());
@ -951,4 +1005,93 @@ public class AgencyServiceImpl implements AgencyService {
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 zhy
* @date 2022/7/6 13:54
*/
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);
}
}

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

@ -930,4 +930,55 @@
limit 1
</select>
<select id="getAreaSubAgency" resultType="com.epmet.dto.result.AgencyAreaResultDTO">
SELECT
ac.*
FROM
customer_agency ac
INNER JOIN customer_org_parameter cop ON cop.CUSTOMER_ID = ac.CUSTOMER_ID
WHERE
ac.DEL_FLAG = '0'
AND cop.DEL_FLAG = '0'
AND cop.PARAMETER_KEY = 'area_code_switch'
AND ac.PID = '0'
AND cop.PARAMETER_VALUE = 'open'
<if test="areaCode != null and areaCode != ''">
AND ac.AREA_CODE LIKE CONCAT(#{areaCode}, '%')
</if>
</select>
<select id="selectRootCustomer" resultType="com.epmet.dto.result.CustomerTreeDTO">
SELECT
c.*
FROM
customer_agency c
WHERE
c.DEL_FLAG = '0'
AND c.pid = '0'
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 id="getAreaRootAgency" resultType="com.epmet.entity.CustomerAgencyEntity">
SELECT
ac.*
FROM
customer_agency ac
INNER JOIN customer_org_parameter cop ON cop.CUSTOMER_ID = ac.CUSTOMER_ID
WHERE
ac.DEL_FLAG = '0'
AND cop.DEL_FLAG = '0'
AND cop.PARAMETER_KEY = 'area_code_switch'
AND ac.PID = '0'
AND cop.PARAMETER_VALUE = 'open'
<if test="customerId != null and customerId != ''">
AND ac.CUSTOMER_ID = #{customerId}
</if>
</select>
</mapper>

5
epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/CustomerRelationDTO.java

@ -83,6 +83,11 @@ public class CustomerRelationDTO implements Serializable {
*/
private String areaCode;
/**
* 当前客户的地区编码实际就是根组织的area_code
*/
private String parentAreaCode;
/**
* 删除标识0未删除1已删除
*/

41
epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerRelationFormDTO.java

@ -0,0 +1,41 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* 客户关系表(01.14 add)
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-02-03
*/
@Data
public class CustomerRelationFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 客户id
*/
private String customerId;
}

111
epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CustomerRelationTreeDTO.java

@ -0,0 +1,111 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 客户关系表(01.14 add)
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-02-03
*/
@Data
public class CustomerRelationTreeDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
private String id;
/**
* 客户id
*/
private String customerId;
/**
* 父级客户id;如果是顶级客户此列=0
*/
private String parentCustomerId;
/**
* 当前客户的所有父级客户id,以英文冒号隔开如果是顶级客户此列=0
*/
private String pids;
/**
* 当前客户类型取值 external:外部客户internal:内部客户
*/
private String customerType;
/**
* 父级客户类型取值 external:外部客户internal:内部客户;如果是顶级客户此列=0
*/
private String parentCustomerType;
/**
* open,closed是否启用
*/
private String status;
/**
* 当前客户级别社区级community
街道:street,
区县级: district,
市级: city
省级:province
*/
private String level;
/**
* 当前客户的地区编码实际就是根组织的area_code
*/
private String areaCode;
/**
* 当前客户的地区名称
*/
private String areaName;
/**
* 客户名称
*/
private String customerName;
/**
* 有效期
*/
private Date validityTime;
/**
* 客户logo
*/
private String logo;
/**
* 下一级
*/
private List<CustomerRelationTreeDTO> children;
}

12
epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java

@ -133,4 +133,16 @@ public interface OperCrmOpenFeignClient {
**/
@GetMapping("/oper/crm/customer/getexternalandparentcustomerid/{customerId}")
Result<String> getExternalAndParentCustomerId(@PathVariable("customerId") String customerId);
/**
* 获取子客户
*
* @param customerId
* @return com.epmet.commons.tools.utils.Result<java.util.List<java.lang.String>>
* @author zhy
* @date 2022/7/8 13:41
*/
@GetMapping("/oper/crm/customerRelation/subcustomer/{customerId}")
Result<List<String>> getSubCustomer(@PathVariable("customerId") String customerId);
}

5
epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java

@ -99,4 +99,9 @@ public class OperCrmOpenFeignClientFallback implements OperCrmOpenFeignClient {
public Result<String> getExternalAndParentCustomerId(String customerId) {
return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getExternalAndParentCustomerId", customerId);
}
@Override
public Result<List<String>> getSubCustomer(String customerId) {
return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getSubCustomer", customerId);
}
}

6
epmet-module/oper-crm/oper-crm-server/pom.xml

@ -111,6 +111,12 @@
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>common-service-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

104
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerRelationController.java

@ -0,0 +1,104 @@
package com.epmet.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.CustomerRelationDTO;
import com.epmet.dto.result.CustomerRelationTreeDTO;
import com.epmet.service.CustomerRelationService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* 客户关系表(01.14 add)
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-07-06
*/
@RestController
@RequestMapping("customerRelation")
public class CustomerRelationController {
@Autowired
private CustomerRelationService customerRelationService;
@RequestMapping("page")
public Result<PageData<CustomerRelationDTO>> page(@RequestParam Map<String, Object> params) {
PageData<CustomerRelationDTO> page = customerRelationService.page(params);
return new Result<PageData<CustomerRelationDTO>>().ok(page);
}
@RequestMapping(value = "{id}", method = {RequestMethod.POST, RequestMethod.GET})
public Result<CustomerRelationDTO> get(@PathVariable("id") String id) {
CustomerRelationDTO data = customerRelationService.get(id);
return new Result<CustomerRelationDTO>().ok(data);
}
@NoRepeatSubmit
@PostMapping("save")
public Result save(@RequestBody CustomerRelationDTO dto) {
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
customerRelationService.saveV2(dto);
return new Result();
}
@NoRepeatSubmit
@PostMapping("update")
public Result update(@RequestBody CustomerRelationDTO dto) {
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
customerRelationService.update(dto);
return new Result();
}
@RequestMapping(value = "delete", method = {RequestMethod.POST, RequestMethod.DELETE})
public Result delete(@RequestBody String[] ids) {
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
customerRelationService.delete(ids);
return new Result();
}
/**
* 客户树
*
* @param
* @return com.epmet.commons.tools.utils.Result<java.util.List < com.epmet.dto.result.CustomerRelationTreeDTO>>
* @author zhy
* @date 2022/7/6 13:24
*/
@RequestMapping("customertree")
public Result<List<CustomerRelationTreeDTO>> customerTree(@LoginUser TokenDto tokenDto) {
return new Result<List<CustomerRelationTreeDTO>>().ok(customerRelationService.getCustomerTree(tokenDto));
}
/**
* 获取子客户
*
* @param customerId
* @return com.epmet.commons.tools.utils.Result<java.util.List<java.lang.String>>
* @author zhy
* @date 2022/7/8 13:41
*/
@GetMapping("subcustomer/{customerId}")
public Result<List<String>> getSubCustomer(@PathVariable("customerId") String customerId) {
if(StringUtils.isNotBlank(customerId)){
List<String> result = customerRelationService.getSubCustomer(customerId);
return new Result<List<String>>().ok(result);
}
return new Result<>();
}
}

33
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerRelationDao.java

@ -19,8 +19,10 @@ package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.CustomerRelationDTO;
import com.epmet.dto.result.CustomerRelationTreeDTO;
import com.epmet.entity.CustomerRelationEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -48,4 +50,35 @@ public interface CustomerRelationDao extends BaseDao<CustomerRelationEntity> {
* @return java.util.List<java.lang.String>
*/
List<String> selectAllSubCustomerIds(String customerId);
/**
* 客户树根节点
*
* @param customerId
* @return java.util.List<com.epmet.dto.result.CustomerRelationTreeDTO>
* @author zhy
* @date 2022/7/6 13:32
*/
List<CustomerRelationTreeDTO> selectRootCustomerByCustomerId(@Param("customerId") String customerId);
/**
* 客户树子节点
*
* @param customerPid
* @return java.util.List<com.epmet.dto.result.CustomerRelationTreeDTO>
* @author zhy
* @date 2022/7/6 13:32
*/
List<CustomerRelationTreeDTO> selectSubCustomerByPid(@Param("customerPid") String customerPid);
/**
* 获取子客户
*
* @param customerId
* @return com.epmet.commons.tools.utils.Result<java.util.List<java.lang.String>>
* @author zhy
* @date 2022/7/8 13:41
*/
List<String> getSubCustomer(@Param("customerId") String customerId);
}

5
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerRelationEntity.java

@ -79,4 +79,9 @@ public class CustomerRelationEntity extends BaseEpmetEntity {
*/
private String areaCode;
/**
* 当前客户的地区编码实际就是根组织的area_code
*/
private String parentAreaCode;
}

25
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerRelationService.java

@ -19,7 +19,9 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.dto.CustomerRelationDTO;
import com.epmet.dto.result.CustomerRelationTreeDTO;
import com.epmet.entity.CustomerRelationEntity;
import java.util.List;
@ -73,6 +75,16 @@ public interface CustomerRelationService extends BaseService<CustomerRelationEnt
*/
void save(CustomerRelationDTO dto);
/**
* 默认保存-数据融合版本
*
* @param dto
* @return void
* @author zhy
* @date 2022/7/7 14:56
*/
void saveV2(CustomerRelationDTO dto);
/**
* 默认更新
*
@ -121,4 +133,17 @@ public interface CustomerRelationService extends BaseService<CustomerRelationEnt
* @Date 2021/2/3 21:37
**/
List<String> getAllSubCustomerIds(String customerId);
/**
* 客户树
*
* @param tokenDto
* @return java.util.List<com.epmet.dto.result.CustomerRelationTreeDTO>
* @author zhy
* @date 2022/7/6 13:32
*/
List<CustomerRelationTreeDTO> getCustomerTree(TokenDto tokenDto);
List<String> getSubCustomer(String customerId);
}

59
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerRelationServiceImpl.java

@ -25,11 +25,17 @@ import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.CustomerRelationDao;
import com.epmet.dto.CustomerDTO;
import com.epmet.dto.CustomerRelationDTO;
import com.epmet.dto.form.AreaCodeDetailFormDTO;
import com.epmet.dto.result.AreaCodeResultDTO;
import com.epmet.dto.result.CustomerRelationTreeDTO;
import com.epmet.entity.CustomerRelationEntity;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.redis.CustomerRedis;
import com.epmet.service.CustomerRelationService;
import com.epmet.service.CustomerService;
@ -58,6 +64,8 @@ public class CustomerRelationServiceImpl extends BaseServiceImpl<CustomerRelatio
private CustomerRedis customerRedis;
@Autowired
private CustomerService customerService;
@Autowired
private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient;
@Override
public PageData<CustomerRelationDTO> page(Map<String, Object> params) {
@ -97,6 +105,15 @@ public class CustomerRelationServiceImpl extends BaseServiceImpl<CustomerRelatio
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void saveV2(CustomerRelationDTO dto) {
CustomerRelationEntity entity = ConvertUtils.sourceToTarget(dto, CustomerRelationEntity.class);
entity.setCustomerType("internal");
entity.setParentCustomerType("internal");
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(CustomerRelationDTO dto) {
@ -170,4 +187,46 @@ public class CustomerRelationServiceImpl extends BaseServiceImpl<CustomerRelatio
return new ArrayList<>();
}
@Override
public List<CustomerRelationTreeDTO> getCustomerTree(TokenDto tokenDto) {
// String customerId = tokenDto.getCustomerId();
String customerId = "78e2b2227c07de1fe54da14e2b2d9eb6";
List<CustomerRelationTreeDTO> rootList = baseDao.selectRootCustomerByCustomerId(customerId);
if (!rootList.isEmpty()) {
rootList.forEach(this::getSubCustomer);
}
return rootList;
}
@Override
public List<String> getSubCustomer(String customerId) {
return baseDao.getSubCustomer(customerId);
}
/**
* 处理子客户
*
* @param customer
* @return com.epmet.dto.result.CustomerRelationTreeDTO
* @author zhy
* @date 2022/7/6 13:54
*/
private CustomerRelationTreeDTO getSubCustomer(CustomerRelationTreeDTO customer) {
AreaCodeDetailFormDTO formDTO = new AreaCodeDetailFormDTO();
formDTO.setAreaCode(customer.getAreaCode());
formDTO.setLevel(customer.getLevel());
Result<AreaCodeResultDTO> area = epmetCommonServiceOpenFeignClient.areaCodeDetail(formDTO);
if (area.success()) {
if (area.getData() != null) {
customer.setAreaName(area.getData().getAreaName());
}
}
List<CustomerRelationTreeDTO> children = baseDao.selectSubCustomerByPid(customer.getCustomerId());
customer.setChildren(children);
if (!children.isEmpty()) {
children.forEach(this::getSubCustomer);
}
return customer;
}
}

42
epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerRelationDao.xml

@ -23,4 +23,46 @@
cr.DEL_FLAG = '0'
AND cr.PIDS like CONCAT(#{customerId},'%')
</select>
<select id="selectRootCustomerByCustomerId" parameterType="java.lang.String" resultType="com.epmet.dto.result.CustomerRelationTreeDTO">
SELECT
cr.*,
c.CUSTOMER_NAME,
c.VALIDITY_TIME,
c.LOGO
FROM
customer_relation cr
LEFT JOIN customer c ON c.id = cr.CUSTOMER_ID
WHERE
cr.DEL_FLAG = '0'
-- AND c.DEL_FLAG = '0'
AND cr.CUSTOMER_ID = #{customerId}
</select>
<select id="selectSubCustomerByPid" parameterType="java.lang.String" resultType="com.epmet.dto.result.CustomerRelationTreeDTO">
SELECT
cr.*,
c.CUSTOMER_NAME,
c.VALIDITY_TIME,
c.LOGO
FROM
customer_relation cr
LEFT JOIN customer c ON c.id = cr.CUSTOMER_ID
WHERE
cr.DEL_FLAG = '0'
-- AND c.DEL_FLAG = '0'
AND cr.PARENT_CUSTOMER_ID = #{customerPid}
</select>
<select id="getSubCustomer" parameterType="java.lang.String" resultType="java.lang.String">
SELECT
CUSTOMER_ID
FROM
customer_relation
WHERE
`STATUS` = 'open'
AND FIND_IN_SET( #{customerId}, pids )
AND DEL_FLAG = '0'
</select>
</mapper>
Loading…
Cancel
Save