Browse Source

Merge branch 'master' of http://git.elinkit.com.cn:7070/r/epmet-cloud into pingyin_master

master
wangxianzhang 3 years ago
parent
commit
e6b1e62080
  1. 2
      epmet-admin/epmet-admin-server/deploy/docker-compose-dev.yml
  2. 26
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  3. 18
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisUtils.java
  4. 8
      epmet-commons/epmet-commons-tools/src/main/resources/logback-base.xml
  5. 2
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/AreaCodeDTO.java
  6. 13
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/AreaCodeDetailFormDTO.java
  7. 76
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/CustomerTreeDTO.java
  8. 22
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java
  9. 10
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java
  10. 28
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/AreaCodeController.java
  11. 18
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/AreaCodeDao.java
  12. 10
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/AreaCodeService.java
  13. 321
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java
  14. 10
      epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/AreaCodeChildDao.xml
  15. 31
      epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/AreaCodeDao.xml
  16. 36
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ic/IcDataSyncTask.java
  17. 1
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java
  18. 128
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencyAreaResultDTO.java
  19. 12
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/OrganizationCodeResultDTO.java
  20. 29
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java
  21. 14
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java
  22. 23
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java
  23. 21
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java
  24. 159
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java
  25. 1
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java
  26. 51
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml
  27. 4
      epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/IcDemandFormDTO.java
  28. 2
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/IcEventServiceImpl.java
  29. 5
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/CustomerRelationDTO.java
  30. 41
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerRelationFormDTO.java
  31. 111
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CustomerRelationTreeDTO.java
  32. 12
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java
  33. 5
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java
  34. 6
      epmet-module/oper-crm/oper-crm-server/pom.xml
  35. 104
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerRelationController.java
  36. 33
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerRelationDao.java
  37. 5
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerRelationEntity.java
  38. 25
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerRelationService.java
  39. 69
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerRelationServiceImpl.java
  40. 42
      epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerRelationDao.xml
  41. 5
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcUserBelongToChangedFormDTO.java
  42. 11
      epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java
  43. 5
      epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java
  44. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/ChangeWelfareController.java
  45. 27
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java
  46. 101
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserDataSyncController.java
  47. 4
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java
  48. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcStatsResiWarnDao.java
  49. 86
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/ChangeWelfareExcel.java
  50. 6
      epmet-user/epmet-user-server/src/main/java/com/epmet/mq/listener/ICWarnStatsEventListener.java
  51. 36
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserDataSyncService.java
  52. 55
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserDataSyncServiceImpl.java
  53. 21
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java
  54. 7
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java
  55. 5
      epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml
  56. 7
      epmet-user/epmet-user-server/src/main/resources/mapper/IcStatsResiWarnDao.xml

2
epmet-admin/epmet-admin-server/deploy/docker-compose-dev.yml

@ -9,7 +9,7 @@ services:
volumes:
- "/opt/epmet-cloud-logs/dev:/logs"
environment:
RUN_INSTRUCT: "java -Xms32m -Xmx200m -jar ../target/epmet-admin-server.jar"
RUN_INSTRUCT: "java -Xms32m -Xmx200m -jar ./epmet-admin.jar"
restart: "unless-stopped"
logging:
driver: local

26
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java

@ -778,6 +778,18 @@ public class RedisKeys {
return rootPrefix.concat("lock:").concat(methodName);
}
/**
* desc:获取分布式锁key
* @param customerId
* @return
*/
public static String getXiaoquEditLock(String customerId) {
if (StringUtils.isBlank(customerId)){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"参数错误");
}
return rootPrefix.concat("lock:xiaoquedit").concat(customerId);
}
/**
* desc:获取更新 房屋内有居民数量的key
* @param customerId
@ -791,4 +803,18 @@ public class RedisKeys {
}
/**
* desc: 数据同步业务key 根据方法名区分
*
* @param bizType [resi]
* @return java.lang.String
* @author LiuJanJun
* @date 2022/7/16 7:12 下午
*/
public static String getDataSyncKey(String bizType) {
if (StringUtils.isBlank(bizType)){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"参数错误");
}
return rootPrefix.concat("datasync:").concat(bizType);
}
}

18
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisUtils.java

@ -357,6 +357,24 @@ public class RedisUtils {
return redisTemplate.opsForSet().members(key);
}
/**
* @Description 获取一个set
* @param key
* @author zxc
*/
public Object sPop(String key){
return redisTemplate.opsForSet().pop(key);
}
/**
* @Description 添加一个元素set
* @param key
* @author zxc
*/
public Long sAdd(String key,Object value){
return redisTemplate.opsForSet().add(key,value);
}
/**
* @Description 获取 zset 中带score的集合
* @param key

8
epmet-commons/epmet-commons-tools/src/main/resources/logback-base.xml

@ -7,11 +7,13 @@ Base logback configuration provided for compatibility with Spring Boot 1.1
<included>
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<!--<property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}}/spring.log}"/>-->
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
<!--该配置主要是配置了console控制台日志的输出级别以及appender,配置只输出到CONSOLE,而不输出到file即可避免产生spring.log-->
<!--<property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}}/spring.log}"/>-->
<!--<include resource="org/springframework/boot/logging/logback/file-appender.xml" />-->
<root level="INFO">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
<!--<appender-ref ref="FILE" />-->
</root>
</included>

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));
}
}

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

@ -37,19 +37,25 @@ 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);
List<AreaCodeResultDTO> selectProvince();
List<AreaCodeResultDTO> selectCity(@Param("pCode")String pCode);
List<AreaCodeResultDTO> selectCity(@Param("pCode") String pCode);
List<AreaCodeResultDTO> selectDistrict(@Param("pCode")String pCode);
List<AreaCodeResultDTO> selectDistrict(@Param("pCode") String pCode);
List<AreaCodeResultDTO> selectStreet(@Param("pCode")String pCode);
List<AreaCodeResultDTO> selectStreet(@Param("pCode") String pCode);
List<AreaCodeResultDTO> selectCommunity(@Param("pCode")String pCode);
List<AreaCodeResultDTO> selectCommunity(@Param("pCode") String pCode);
}

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);
}

321
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(
@ -88,8 +87,8 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
return ConvertUtils.sourceToTarget(entityList, AreaCodeDTO.class);
}
private QueryWrapper<AreaCodeEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
private QueryWrapper<AreaCodeEntity> getWrapper(Map<String, Object> params) {
String id = (String) params.get(FieldConstant.ID_HUMP);
QueryWrapper<AreaCodeEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
@ -125,7 +124,7 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
}
/**
* @Description 行政地区编码查询
* @Description 行政地区编码查询
* @Param formDTO
* @author zxc
* @date 2021/1/7 下午1:41
@ -134,14 +133,14 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
public List<AreaCodeDictResultDTO> areaCodeDictTree(AreaCodeDictFormDTO formDTO) {
List<AreaCodeDictResultDTO> tree = new ArrayList<>();
String s = areaCodeRedis.get(AreaCodeConstant.SCREEN_TREE);
if (StringUtils.isNotBlank(s)){
tree = JSON.parseArray(s,AreaCodeDictResultDTO.class);
}else {
if (StringUtils.isNotBlank(s)) {
tree = JSON.parseArray(s, AreaCodeDictResultDTO.class);
} else {
List<AreaCodeDictResultDTO> areaCodeDictResultDTOS = disposeTree(formDTO);
areaCodeRedis.set(AreaCodeConstant.SCREEN_TREE,areaCodeDictResultDTOS);
areaCodeRedis.set(AreaCodeConstant.SCREEN_TREE, areaCodeDictResultDTOS);
tree = areaCodeDictResultDTOS;
}
if (StringUtils.isBlank(formDTO.getRootAreaCode())){
if (StringUtils.isBlank(formDTO.getRootAreaCode())) {
return tree;
}
List<AreaCodeDictResultDTO> treeByRootAreaCode = getTreeByRootAreaCode(tree, formDTO.getRootAreaCode());
@ -149,12 +148,12 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
}
/**
* @Description 行政区树查询
* @Description 行政区树查询
* @Param
* @author zxc
* @date 2021/1/8 上午8:57
*/
public List<AreaCodeDictResultDTO> disposeTree(AreaCodeDictFormDTO formDTO){
public List<AreaCodeDictResultDTO> disposeTree(AreaCodeDictFormDTO formDTO) {
// 查询所有省市区
List<AreaCodeDTO> areaCodeDTOS = baseDao.selectAllArea();
// 查询所有街道、社区
@ -173,8 +172,8 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
dto.setCode(four.getCode());
dto.setName(four.getName());
dto.setParentCode(four.getPCode());
groupByPCode.forEach((pCode,v) -> {
if (dto.getCode().equals(pCode)){
groupByPCode.forEach((pCode, v) -> {
if (dto.getCode().equals(pCode)) {
List<AreaCodeDictResultDTO> fiveResult = new ArrayList<>();
v.forEach(five -> {
AreaCodeDictResultDTO fiveDto = new AreaCodeDictResultDTO();
@ -189,7 +188,7 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
fourResult.add(dto);
});
List<AreaCodeDictResultDTO> fourSort = new ArrayList<>();
if (!CollectionUtils.isEmpty(fourResult)){
if (!CollectionUtils.isEmpty(fourResult)) {
fourSort = fourResult.stream().sorted(Comparator.comparing(AreaCodeDictResultDTO::getCode)).collect(Collectors.toList());
}
@ -209,7 +208,7 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
dto.setName(three.getCountyName());
List<AreaCodeDictResultDTO> fourOnceResult = new ArrayList<>();
finalFourSort.forEach(four -> {
if (dto.getCode().equals(four.getParentCode())){
if (dto.getCode().equals(four.getParentCode())) {
fourOnceResult.add(four);
}
});
@ -220,13 +219,13 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
cityDto.setChildren(threeSort);
cityResult.add(cityDto);
});
groupByProvince.forEach((p,v) -> {
groupByProvince.forEach((p, v) -> {
AreaCodeDictResultDTO dto = new AreaCodeDictResultDTO();
dto.setCode(p);
dto.setName(v.get(NumConstant.ZERO).getProvinceName());
List<AreaCodeDictResultDTO> cityOnceResult = new ArrayList<>();
cityResult.forEach(c -> {
if (dto.getCode().equals(c.getParentCode())){
if (dto.getCode().equals(c.getParentCode())) {
cityOnceResult.add(c);
}
});
@ -239,54 +238,51 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
}
/**
* @Description 根据节点获取组织区域树遍历传参只能是 区级别 暂时这样循环太多了
*
*
* @Description 根据节点获取组织区域树遍历传参只能是 区级别 暂时这样循环太多了
* <p>
* <p>
* 暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样
* ==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==
* 暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样
*
*
*
* ==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==
* 暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样
* @Param tree
* @Param rootAreaCode
* @author zxc
* @date 2021/1/8 上午10:02
*/
public List<AreaCodeDictResultDTO> getTreeByRootAreaCode(List<AreaCodeDictResultDTO> tree , String rootAreaCode){
public List<AreaCodeDictResultDTO> getTreeByRootAreaCode(List<AreaCodeDictResultDTO> tree, String rootAreaCode) {
List<AreaCodeDictResultDTO> result = new ArrayList<>();
if (!CollectionUtils.isEmpty(tree)){
if (!CollectionUtils.isEmpty(tree)) {
// 省级获取
for (AreaCodeDictResultDTO dto : tree) {
if (rootAreaCode.equals(dto.getCode())){
if (rootAreaCode.equals(dto.getCode())) {
result.add(dto);
return result;
}
// 市级获取
if (!CollectionUtils.isEmpty(dto.getChildren())){
if (!CollectionUtils.isEmpty(dto.getChildren())) {
for (AreaCodeDictResultDTO child : dto.getChildren()) {
if (rootAreaCode.equals(child.getCode())){
if (rootAreaCode.equals(child.getCode())) {
result.add(child);
return result;
}
// 区级获取
if (!CollectionUtils.isEmpty(child.getChildren())){
if (!CollectionUtils.isEmpty(child.getChildren())) {
for (AreaCodeDictResultDTO threeChild : child.getChildren()) {
if (rootAreaCode.equals(threeChild.getCode())){
if (rootAreaCode.equals(threeChild.getCode())) {
result.add(threeChild);
return result;
}
// 街道获取
if (!CollectionUtils.isEmpty(threeChild.getChildren())){
if (!CollectionUtils.isEmpty(threeChild.getChildren())) {
for (AreaCodeDictResultDTO fourChild : threeChild.getChildren()) {
if (rootAreaCode.equals(fourChild.getCode())){
if (rootAreaCode.equals(fourChild.getCode())) {
result.add(fourChild);
return result;
}
// 社区获取
if (!CollectionUtils.isEmpty(fourChild.getChildren())){
if (!CollectionUtils.isEmpty(fourChild.getChildren())) {
for (AreaCodeDictResultDTO fiveChild : fourChild.getChildren()) {
if (rootAreaCode.equals(fiveChild.getCode())){
if (rootAreaCode.equals(fiveChild.getCode())) {
result.add(fiveChild);
return result;
}
@ -304,40 +300,40 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
}
@Override
public List<AreaCodeDictResultDTO> areaCodeDictTreePlus(AreaCodeDictFormDTO formDTO){
public List<AreaCodeDictResultDTO> areaCodeDictTreePlus(AreaCodeDictFormDTO formDTO) {
List<AreaCodeDictResultDTO> tree = new ArrayList<>();
String s = areaCodeRedis.get(AreaCodeConstant.THREE_SCREEN_TREE);
if (StringUtils.isNotBlank(s)){
tree = JSON.parseArray(s,AreaCodeDictResultDTO.class);
}else {
if (StringUtils.isNotBlank(s)) {
tree = JSON.parseArray(s, AreaCodeDictResultDTO.class);
} else {
List<AreaCodeDictResultDTO> threeTree = beforeThreeTree();
areaCodeRedis.set(AreaCodeConstant.THREE_SCREEN_TREE,threeTree);
areaCodeRedis.set(AreaCodeConstant.THREE_SCREEN_TREE, threeTree);
tree = threeTree;
}
if (StringUtils.isBlank(formDTO.getRootAreaCode())){
if (StringUtils.isBlank(formDTO.getRootAreaCode())) {
return tree;
}
if (StringUtils.isBlank(formDTO.getRootAreaLevel())){
if (StringUtils.isBlank(formDTO.getRootAreaLevel())) {
throw new RenException(AreaCodeConstant.ROOT_AGENCY_LEVEL_IS_LEVEL);
}
// 传参为街道-社区级
if (formDTO.getRootAreaLevel().equals(AreaCodeConstant.STREET) || formDTO.getRootAreaLevel().equals(AreaCodeConstant.COMMUNITY)){
if (formDTO.getRootAreaLevel().equals(AreaCodeConstant.STREET) || formDTO.getRootAreaLevel().equals(AreaCodeConstant.COMMUNITY)) {
tree = disposeAfterTwoLevel(formDTO);
}else if (formDTO.getRootAreaLevel().equals(AreaCodeConstant.PROVINCE) || formDTO.getRootAreaLevel().equals(AreaCodeConstant.CITY) || formDTO.getRootAreaLevel().equals(AreaCodeConstant.DISTRICT)){
tree = disposeBeforeThreeLevelFinal(formDTO,tree);
}else {
throw new RenException(String.format(AreaCodeConstant.LEVEL_ERROR,formDTO.getRootAreaLevel()));
} else if (formDTO.getRootAreaLevel().equals(AreaCodeConstant.PROVINCE) || formDTO.getRootAreaLevel().equals(AreaCodeConstant.CITY) || formDTO.getRootAreaLevel().equals(AreaCodeConstant.DISTRICT)) {
tree = disposeBeforeThreeLevelFinal(formDTO, tree);
} else {
throw new RenException(String.format(AreaCodeConstant.LEVEL_ERROR, formDTO.getRootAreaLevel()));
}
return tree;
}
/**
* @Description 省市区三级联动查询
* @Description 省市区三级联动查询
* @Param
* @author zxc
* @date 2021/1/11 上午9:35
*/
public List<AreaCodeDictResultDTO> beforeThreeTree(){
public List<AreaCodeDictResultDTO> beforeThreeTree() {
// 查询所有省市区
List<AreaCodeDTO> areaCodeDTOS = baseDao.selectAllArea();
Map<String, List<AreaCodeDTO>> groupByCity = areaCodeDTOS.stream().collect(Collectors.groupingBy(AreaCodeDTO::getCityCode));
@ -362,13 +358,13 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
cityDto.setChildren(threeSort);
cityResult.add(cityDto);
});
groupByProvince.forEach((p,v) -> {
groupByProvince.forEach((p, v) -> {
AreaCodeDictResultDTO dto = new AreaCodeDictResultDTO();
dto.setCode(p);
dto.setName(v.get(NumConstant.ZERO).getProvinceName());
List<AreaCodeDictResultDTO> cityOnceResult = new ArrayList<>();
cityResult.forEach(c -> {
if (dto.getCode().equals(c.getParentCode())){
if (dto.getCode().equals(c.getParentCode())) {
cityOnceResult.add(c);
}
});
@ -383,12 +379,12 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
}
/**
* @Description 街道-社区组织树查询
* @Description 街道-社区组织树查询
* @Param
* @author zxc
* @date 2021/1/11 上午9:48
*/
public List<AreaCodeDictResultDTO> afterTwoTree(AreaCodeDictFormDTO form){
public List<AreaCodeDictResultDTO> afterTwoTree(AreaCodeDictFormDTO form) {
// 查询所有街道、社区
List<AreaCodeChildDTO> areaCodeChildDTOS = childDao.selectAllChild(form.getRootAreaCode());
List<AreaCodeDictResultDTO> fourResult = new ArrayList<>();
@ -399,7 +395,7 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
List<AreaCodeChildDTO> levelFive = org.apache.commons.collections4.CollectionUtils.isNotEmpty(groupByLevel.get(NumConstant.FIVE)) ? groupByLevel.get(NumConstant.FIVE) : new ArrayList<>();
Map<String, List<AreaCodeChildDTO>> groupByPCode = CollectionUtils.isEmpty(levelFive) ? new HashMap<>() : levelFive.stream().collect(Collectors.groupingBy(AreaCodeChildDTO::getPCode));
//街道
List<AreaCodeChildDTO> levelFour = org.apache.commons.collections4.CollectionUtils.isNotEmpty(groupByLevel.get(NumConstant.FOUR)) ?groupByLevel.get(NumConstant.FOUR):new ArrayList<>();
List<AreaCodeChildDTO> levelFour = org.apache.commons.collections4.CollectionUtils.isNotEmpty(groupByLevel.get(NumConstant.FOUR)) ? groupByLevel.get(NumConstant.FOUR) : new ArrayList<>();
// 6级
List<AreaCodeChildDTO> levelSix = groupByLevel.get(NumConstant.SIX);
Map<String, List<AreaCodeChildDTO>> groupBySixPCode = CollectionUtils.isEmpty(levelSix) ? new HashMap<>() : levelSix.stream().collect(Collectors.groupingBy(AreaCodeChildDTO::getPCode));
@ -409,8 +405,8 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
dto.setCode(f.getCode());
dto.setName(f.getName());
dto.setParentCode(f.getPCode());
groupBySixPCode.forEach((k,v) -> {
if (dto.getCode().equals(k)){
groupBySixPCode.forEach((k, v) -> {
if (dto.getCode().equals(k)) {
List<AreaCodeDictResultDTO> six = new ArrayList<>();
v.forEach(s -> {
AreaCodeDictResultDTO sixDto = new AreaCodeDictResultDTO();
@ -431,8 +427,8 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
dto.setCode(four.getCode());
dto.setName(four.getName());
dto.setParentCode(four.getPCode());
groupByFivePCode.forEach((pCode,v) -> {
if (dto.getCode().equals(pCode)){
groupByFivePCode.forEach((pCode, v) -> {
if (dto.getCode().equals(pCode)) {
dto.setChildren(v);
}
});
@ -443,28 +439,28 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
}
/**
* @Description 街道-社区组织树处理
* @Description 街道-社区组织树处理
* @Param form
* @author zxc
* @date 2021/1/11 上午9:58
*/
public List<AreaCodeDictResultDTO> disposeAfterTwoLevel(AreaCodeDictFormDTO form){
public List<AreaCodeDictResultDTO> disposeAfterTwoLevel(AreaCodeDictFormDTO form) {
List<AreaCodeDictResultDTO> result = new ArrayList<>();
List<AreaCodeDictResultDTO> areaCodeDictResultDTOS = afterTwoTree(form);
if (CollectionUtils.isEmpty(areaCodeDictResultDTOS)){
if (CollectionUtils.isEmpty(areaCodeDictResultDTOS)) {
return new ArrayList<>();
}
if (form.getRootAreaLevel().equals(AreaCodeConstant.STREET)){
if (form.getRootAreaLevel().equals(AreaCodeConstant.STREET)) {
for (AreaCodeDictResultDTO dto : areaCodeDictResultDTOS) {
if (dto.getCode().equals(form.getRootAreaCode())){
if (dto.getCode().equals(form.getRootAreaCode())) {
result.add(dto);
}
}
}else {
} else {
for (AreaCodeDictResultDTO dto : areaCodeDictResultDTOS) {
if (!CollectionUtils.isEmpty(dto.getChildren())){
if (!CollectionUtils.isEmpty(dto.getChildren())) {
for (AreaCodeDictResultDTO child : dto.getChildren()) {
if (child.getCode().equals(form.getRootAreaCode())){
if (child.getCode().equals(form.getRootAreaCode())) {
result.add(child);
}
}
@ -475,42 +471,42 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
}
/**
* @Description 省市区获取
* @Description 省市区获取
* @Param form
* @Param tree
* @author zxc
* @date 2021/1/12 上午9:22
*/
public List<AreaCodeDictResultDTO> disposeBeforeThreeLevel(AreaCodeDictFormDTO form,List<AreaCodeDictResultDTO> tree){
public List<AreaCodeDictResultDTO> disposeBeforeThreeLevel(AreaCodeDictFormDTO form, List<AreaCodeDictResultDTO> tree) {
List<AreaCodeDictResultDTO> result = new ArrayList<>();
if (CollectionUtils.isEmpty(tree)){
if (CollectionUtils.isEmpty(tree)) {
return new ArrayList<>();
}
if (form.getRootAreaLevel().equals(AreaCodeConstant.PROVINCE)){
if (form.getRootAreaLevel().equals(AreaCodeConstant.PROVINCE)) {
for (AreaCodeDictResultDTO dto : tree) {
if (dto.getCode().equals(form.getRootAreaCode())){
if (dto.getCode().equals(form.getRootAreaCode())) {
result.add(dto);
return result;
}
}
}else if (form.getRootAreaLevel().equals(AreaCodeConstant.CITY)){
} else if (form.getRootAreaLevel().equals(AreaCodeConstant.CITY)) {
for (AreaCodeDictResultDTO dto : tree) {
if (!CollectionUtils.isEmpty(dto.getChildren())){
if (!CollectionUtils.isEmpty(dto.getChildren())) {
for (AreaCodeDictResultDTO city : dto.getChildren()) {
if (city.getCode().equals(form.getRootAreaCode())){
if (city.getCode().equals(form.getRootAreaCode())) {
result.add(city);
return result;
}
}
}
}
}else if (form.getRootAreaLevel().equals(AreaCodeConstant.DISTRICT)){
} else if (form.getRootAreaLevel().equals(AreaCodeConstant.DISTRICT)) {
for (AreaCodeDictResultDTO dto : tree) {
if (!CollectionUtils.isEmpty(dto.getChildren())){
if (!CollectionUtils.isEmpty(dto.getChildren())) {
for (AreaCodeDictResultDTO city : dto.getChildren()) {
if (!CollectionUtils.isEmpty(city.getChildren())){
if (!CollectionUtils.isEmpty(city.getChildren())) {
for (AreaCodeDictResultDTO child : city.getChildren()) {
if (child.getCode().equals(form.getRootAreaCode())){
if (child.getCode().equals(form.getRootAreaCode())) {
result.add(child);
return result;
}
@ -524,29 +520,29 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
}
/**
* @Description 拼接 街道-社区
* @Description 拼接 街道-社区
* @Param form
* @Param tree
* @author zxc
* @date 2021/1/12 上午9:21
*/
public List<AreaCodeDictResultDTO> disposeBeforeThreeLevelFinal(AreaCodeDictFormDTO form,List<AreaCodeDictResultDTO> tree){
public List<AreaCodeDictResultDTO> disposeBeforeThreeLevelFinal(AreaCodeDictFormDTO form, List<AreaCodeDictResultDTO> tree) {
List<AreaCodeDictResultDTO> threeDto = disposeBeforeThreeLevel(form, tree);
List<AreaCodeDictResultDTO> twoDto = afterTwoTree(form);
if (CollectionUtils.isEmpty(threeDto)){
if (CollectionUtils.isEmpty(threeDto)) {
return new ArrayList<>();
}
if (!CollectionUtils.isEmpty(twoDto)){
if (form.getRootAreaLevel().equals(AreaCodeConstant.PROVINCE)){
if (!CollectionUtils.isEmpty(twoDto)) {
if (form.getRootAreaLevel().equals(AreaCodeConstant.PROVINCE)) {
for (AreaCodeDictResultDTO dto : tree) {
if (dto.getCode().equals(form.getRootAreaCode())){
if (!CollectionUtils.isEmpty(dto.getChildren())){
if (dto.getCode().equals(form.getRootAreaCode())) {
if (!CollectionUtils.isEmpty(dto.getChildren())) {
for (AreaCodeDictResultDTO city : dto.getChildren()) {
if (!CollectionUtils.isEmpty(city.getChildren())){
if (!CollectionUtils.isEmpty(city.getChildren())) {
for (AreaCodeDictResultDTO child : city.getChildren()) {
List<AreaCodeDictResultDTO> areaList = new ArrayList<>();
for (AreaCodeDictResultDTO area : twoDto) {
if (child.getCode().equals(area.getParentCode())){
if (child.getCode().equals(area.getParentCode())) {
areaList.add(area);
}
}
@ -557,13 +553,13 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
}
}
}
}else if (form.getRootAreaLevel().equals(AreaCodeConstant.CITY)){
} else if (form.getRootAreaLevel().equals(AreaCodeConstant.CITY)) {
for (AreaCodeDictResultDTO dto : threeDto) {
if (!CollectionUtils.isEmpty(dto.getChildren())){
if (!CollectionUtils.isEmpty(dto.getChildren())) {
for (AreaCodeDictResultDTO child : dto.getChildren()) {
List<AreaCodeDictResultDTO> areaList = new ArrayList<>();
for (AreaCodeDictResultDTO area : twoDto) {
if (child.getCode().equals(area.getParentCode())){
if (child.getCode().equals(area.getParentCode())) {
areaList.add(area);
}
}
@ -571,11 +567,11 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
}
}
}
}else{
} else {
for (AreaCodeDictResultDTO dto : threeDto) {
List<AreaCodeDictResultDTO> areaList = new ArrayList<>();
for (AreaCodeDictResultDTO area : twoDto) {
if (dto.getCode().equals(area.getParentCode())){
if (dto.getCode().equals(area.getParentCode())) {
areaList.add(area);
}
}
@ -677,35 +673,35 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
String areaCode = "";
switch (formDTO.getCurrentAreaLevel()) {
case AreaCodeConstant.DISTRICT:
areaCode = addDistrictAreaCode(formDTO.getParentAreaCode(),formDTO.getName());
areaCode = addDistrictAreaCode(formDTO.getParentAreaCode(), formDTO.getName());
break;
case AreaCodeConstant.STREET:
areaCode = addStreetCommAreaCode(ConvertUtils.sourceToTarget(formDTO,AddAreaCodeDictFormDTO.class));
areaCode = addStreetCommAreaCode(ConvertUtils.sourceToTarget(formDTO, AddAreaCodeDictFormDTO.class));
break;
case AreaCodeConstant.COMMUNITY:
areaCode = addStreetCommAreaCode(ConvertUtils.sourceToTarget(formDTO,AddAreaCodeDictFormDTO.class));
areaCode = addStreetCommAreaCode(ConvertUtils.sourceToTarget(formDTO, AddAreaCodeDictFormDTO.class));
break;
default:
log.info("currentAreaLevel值为"+formDTO.getCurrentAreaLevel());
log.info("currentAreaLevel值为" + formDTO.getCurrentAreaLevel());
}
return areaCode;
}
@Override
public List<AreaCodeResultDTO> nextArea(AreaCodeFormDTO formDTO) {
if(StringUtils.isBlank(formDTO.getParentAreaCode())&&StringUtils.isBlank(formDTO.getParentLevel())){
String pKey=RedisKeys.getNextAreaCodeKey(NumConstant.ZERO_STR);
List<AreaCodeResultDTO> list=areaCodeRedis.getNextAreaCodeKey(pKey);
if(org.apache.commons.collections4.CollectionUtils.isNotEmpty(list)){
if (StringUtils.isBlank(formDTO.getParentAreaCode()) && StringUtils.isBlank(formDTO.getParentLevel())) {
String pKey = RedisKeys.getNextAreaCodeKey(NumConstant.ZERO_STR);
List<AreaCodeResultDTO> list = areaCodeRedis.getNextAreaCodeKey(pKey);
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(list)) {
return list;
}
List<AreaCodeResultDTO> pList=baseDao.selectProvince();
areaCodeRedis.setNextAreaCodeKey(pKey,pList);
List<AreaCodeResultDTO> pList = baseDao.selectProvince();
areaCodeRedis.setNextAreaCodeKey(pKey, pList);
return pList;
}
String key=RedisKeys.getNextAreaCodeKey(formDTO.getParentAreaCode());
List<AreaCodeResultDTO> list=areaCodeRedis.getNextAreaCodeKey(key);
if(org.apache.commons.collections4.CollectionUtils.isNotEmpty(list)){
String key = RedisKeys.getNextAreaCodeKey(formDTO.getParentAreaCode());
List<AreaCodeResultDTO> list = areaCodeRedis.getNextAreaCodeKey(key);
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(list)) {
return list;
}
switch (formDTO.getParentLevel()) {
@ -723,17 +719,116 @@ public class AreaCodeServiceImpl extends BaseServiceImpl<AreaCodeDao, AreaCodeEn
break;
case AreaCodeConstant.COMMUNITY:
log.info("社区无下级");
list=null;
list = null;
break;
default:
log.warn("parentLevel错误:"+formDTO.getParentLevel());
log.warn("parentLevel错误:" + formDTO.getParentLevel());
}
if(org.apache.commons.collections4.CollectionUtils.isNotEmpty(list)){
areaCodeRedis.setNextAreaCodeKey(key,list);
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(list)) {
areaCodeRedis.setNextAreaCodeKey(key, list);
}
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>

36
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ic/IcDataSyncTask.java

@ -0,0 +1,36 @@
package com.epmet.task.ic;
import com.epmet.commons.tools.utils.Result;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.task.ITask;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* desc:定时弥补数据 保证数据的一致性
*/
@Slf4j
@Component("icDataSyncTask")
public class IcDataSyncTask implements ITask {
@Resource
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
/**
* 执行定时任务接口
*
* @param params 参数多参数使用JSON数据
*/
@Override
public void run(String customerId) {
log.info("icDataSyncTask定时任务正在执行,参数为customerId:{}", customerId);
Result result = epmetUserOpenFeignClient.icDataSyncTask(customerId);
if (result.success()) {
log.info("icDataSyncTask定时任务正在执行定时任务执行成功");
} else {
log.warn("icDataSyncTask定时任务正在执行定时任务执行失败:" + result.getMsg());
}
}
}

1
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java

@ -141,6 +141,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService {
WxResult<String> result = new WxResult<>();
String url = WxMaCodeConstant.SUBMIT_AUDIT_URL + "?" + "access_token=" + accessToken;
Result<String> submitResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(auditRequest));
log.info("submitAudit result:{}",JSON.toJSONString(submitResult));
if (!submitResult.success()) {
result.setErrorCode(submitResult.getCode());
result.setErrorMsg(submitResult.getMsg());

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;
}

12
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/OrganizationCodeResultDTO.java

@ -6,7 +6,7 @@ import java.io.Serializable;
/**
* @program: epmet-cloud
* @description:小区-楼栋-房屋编码
* @description:小区-楼栋-单元-房屋编码
* @author: wangtong
* @create: 2022-06-29 09:51
**/
@ -14,13 +14,17 @@ import java.io.Serializable;
public class OrganizationCodeResultDTO implements Serializable {
/**
* 可编辑的楼栋编码
* 可编辑的编码
*/
private String coding;
/**
* 不可编辑的楼栋编码
* 不可编辑的编码
*/
private String sysCoding;
/**
* 不可编辑的前缀编码
*/
private String preCoding;
}

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));
}
}

14
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java

@ -21,6 +21,8 @@ import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.distributedlock.DistributedLock;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
@ -33,6 +35,7 @@ import com.epmet.entity.IcBuildingEntity;
import com.epmet.service.NeighborHoodService;
import com.epmet.util.ExcelPoiUtils;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RLock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping;
@ -44,6 +47,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
@ -61,6 +65,8 @@ public class NeighborHoodController {
private NeighborHoodService neighborHoodService;
@Resource
private IcBuildingDao icBuildingDao;
@Autowired
private DistributedLock distributedLock;
@PostMapping("neighborhoodlist")
@ -88,7 +94,13 @@ public class NeighborHoodController {
ValidatorUtils.validateEntity(formDTO, IcNeighborHoodAddFormDTO.UpdateShowGroup.class);
String customerId = tokenDTO.getCustomerId();
// String customerId = "123123";
neighborHoodService.updateNeighborhood(customerId,formDTO);
RLock lock = null;
try {
lock = distributedLock.getLock(RedisKeys.getXiaoquEditLock(tokenDTO.getCustomerId()), 120L, 3L, TimeUnit.SECONDS);
neighborHoodService.updateNeighborhood(customerId,formDTO);
} finally {
distributedLock.unLock(lock);
}
return new Result();
}

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);
}

159
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,46 @@ 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> 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) {
CustomerAgencyEntity insertEntity = ConvertUtils.sourceToTarget(formDTO, CustomerAgencyEntity.class);
insertEntity.setOrganizationName(formDTO.getAgencyName());
@ -951,4 +993,109 @@ 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 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);
}
}

1
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java

@ -207,6 +207,7 @@ public class NeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao,I
//如果更新了网格 则需要更新网格下的居民所属关系
if (!icNeighborHoodEntity.getGridId().equals(icNeighborHoodDTO.getGridId())){
IcUserBelongToChangedFormDTO userForm = new IcUserBelongToChangedFormDTO();
userForm.setNeighborhoodId(icNeighborHoodEntity.getId());
userForm.setSourceGridId(icNeighborHoodEntity.getGridId());
userForm.setTargetGridId(icNeighborHoodDTO.getGridId());
Result<Boolean> updateResult = epmetUserOpenFeignClient.changeIcResiUserBelongTo(userForm);

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>

4
epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/IcDemandFormDTO.java

@ -115,7 +115,7 @@ public class IcDemandFormDTO implements Serializable {
/**
* 需求人联系电话
*/
@NotNull(message = "需求人不能为空",groups = AddUserShowGroup.class)
@NotNull(message = "需求人联系电话不能为空",groups = AddUserShowGroup.class)
private String demandUserMobile;
/**
@ -168,7 +168,7 @@ public class IcDemandFormDTO implements Serializable {
/**
* 二级分类Id
*/
@NotBlank(message = "分类id不能为空",groups = AddUserInternalGroup.class)
//@NotBlank(message = "分类id不能为空",groups = AddUserInternalGroup.class)
private String categoryId;
}

2
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/IcEventServiceImpl.java

@ -173,7 +173,7 @@ public class IcEventServiceImpl extends BaseServiceImpl<IcEventDao, IcEventEntit
//1.参数校验,安全校验
//1-1.判断是否勾选处理方式,勾选了则分类不能为空
//勾选了立项或转需求或已完成时分类必须传
if (((StringUtils.isNotBlank(formDTO.getOperationType()) && !"0".equals(formDTO.getOperationType()))
if (((StringUtils.isNotBlank(formDTO.getOperationType()) && "1".equals(formDTO.getOperationType()))
|| (StringUtils.isNotBlank(formDTO.getStatus()) && "closed_case".equals(formDTO.getStatus()))) && CollectionUtils.isEmpty(formDTO.getCategoryList())) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "事件分类不能为空");
}

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);
}

69
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) {
@ -75,8 +83,8 @@ public class CustomerRelationServiceImpl extends BaseServiceImpl<CustomerRelatio
return ConvertUtils.sourceToTarget(entityList, CustomerRelationDTO.class);
}
private QueryWrapper<CustomerRelationEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
private QueryWrapper<CustomerRelationEntity> getWrapper(Map<String, Object> params) {
String id = (String) params.get(FieldConstant.ID_HUMP);
QueryWrapper<CustomerRelationEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
@ -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) {
@ -134,12 +151,12 @@ public class CustomerRelationServiceImpl extends BaseServiceImpl<CustomerRelatio
*/
@Override
public String getRootCustomerId(String customerId) {
CustomerRelationDTO customerRelationDTO=this.getByCustomerId(customerId);
CustomerRelationDTO customerRelationDTO = this.getByCustomerId(customerId);
if (null == customerRelationDTO) {
log.info(String.format("根据客户id:%s查找customer_relation为空",customerId));
log.info(String.format("根据客户id:%s查找customer_relation为空", customerId));
return StrConstant.EPMETY_STR;
}
log.info(JSON.toJSONString(customerRelationDTO,true));
log.info(JSON.toJSONString(customerRelationDTO, true));
if (!NumConstant.ZERO_STR.equals(customerRelationDTO.getParentCustomerId())) {
log.info("parentCustomerId is not equals 0 so continue");
return getRootCustomerId(customerRelationDTO.getParentCustomerId());
@ -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>

5
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcUserBelongToChangedFormDTO.java

@ -19,6 +19,11 @@ public class IcUserBelongToChangedFormDTO implements Serializable {
* 客户Id
*/
private String customerId;
/**
* 小区ID
*/
private String neighborhoodId;
/**
* 原网格Id
*/

11
epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java

@ -835,4 +835,15 @@ public interface EpmetUserOpenFeignClient {
*/
@PostMapping("/epmetuser/icresiuser/getIcUserCount")
Result<Map<String, Integer>> getIcUserCount(@RequestBody IcUserCountFormDTO formDTO);
/**
* desc: 同步数据房内居民数量 类别统计数据量等只用客户id当条件
*
* @param customerId
* @return com.epmet.commons.tools.utils.Result<java.lang.String>
* @author LiuJanJun
* @date 2022/7/16 6:53 下午
*/
@PostMapping("/epmetuser/icResiUserDataSync/icDataSyncTask")
Result<Boolean> icDataSyncTask(String customerId);
}

5
epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java

@ -636,4 +636,9 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getIcUserCount", formDTO);
}
@Override
public Result<Boolean> icDataSyncTask(String customerId) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "icDataSyncTask", customerId);
}
}

2
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/ChangeWelfareController.java

@ -77,7 +77,7 @@ public class ChangeWelfareController {
@GetMapping("export")
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<ChangeWelfareDTO> list = changeWelfareService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, ChangeWelfareExcel.class);
ExcelUtils.exportEpmetExcel(response, null, list, ChangeWelfareExcel.class);
}
/**

27
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java

@ -30,6 +30,7 @@ import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.constant.Constant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.distributedlock.DistributedLock;
import com.epmet.commons.tools.dto.form.mq.MqBaseFormDTO;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.dto.result.OptionDataResultDTO;
@ -48,7 +49,6 @@ import com.epmet.commons.tools.security.user.LoginUserUtil;
import com.epmet.commons.tools.utils.*;
import com.epmet.commons.tools.utils.poi.excel.handler.FreezeAndFilter;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.constant.OrgInfoConstant;
import com.epmet.constant.SystemMessageType;
import com.epmet.constants.ImportTaskConstants;
import com.epmet.dto.IcResiUserDTO;
@ -76,6 +76,7 @@ import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.poifs.filesystem.OfficeXmlFileException;
import org.jetbrains.annotations.NotNull;
import org.redisson.api.RLock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -90,6 +91,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@ -139,6 +141,8 @@ public class IcResiUserController implements ResultDataResolver {
private RequestInterceptor requestInterceptor;
@Autowired
private ExecutorService executorService;
@Autowired
private DistributedLock distributedLock;
/**
* 模板枚举
@ -247,11 +251,17 @@ public class IcResiUserController implements ResultDataResolver {
@NoRepeatSubmit
@PostMapping("edit")
public Result edit(@LoginUser TokenDto tokenDto, @RequestBody List<IcResiUserFormDTO> formDTO) {
String resiUserId = icResiUserService.edit(tokenDto, formDTO);
//推送MQ事件
editResiMq(tokenDto.getCustomerId(), resiUserId);
RLock lock = null;
try {
lock = distributedLock.getLock(RedisKeys.getXiaoquEditLock(tokenDto.getCustomerId()), 120L, 3L, TimeUnit.SECONDS);
String resiUserId = icResiUserService.edit(tokenDto, formDTO);
//推送MQ事件
editResiMq(tokenDto.getCustomerId(), resiUserId);
this.sendVolunteerMsg(tokenDto.getCustomerId(), resiUserId);
this.sendVolunteerMsg(tokenDto.getCustomerId(), resiUserId);
} finally {
distributedLock.unLock(lock);
}
return new Result();
}
@ -599,7 +609,9 @@ public class IcResiUserController implements ResultDataResolver {
// 三.异步执行导入
executorService.execute(() -> {
boolean isAllSuccess = false;
RLock lock = null;
try {
lock = distributedLock.getLock(RedisKeys.getXiaoquEditLock(customerId), 120L, 3L, TimeUnit.SECONDS);
List<FormItemResult> formItemList = icResiUserService.listFormItems(customerId, IcFormCodeEnum.RESI_BASE_INFO.getCode());
isAllSuccess = icResiUserImportService.importIcResiInfoFromExcel(importTaskId, formItemList, importTempFileSavePath.toString(), response, IC_RESI_UPLOAD_DIR);
} catch (Throwable e) {
@ -638,6 +650,11 @@ public class IcResiUserController implements ResultDataResolver {
form.setMessageType(SystemMessageType.IC_RESI_USER_ADD);
form.setContent(mqMsg);
epmetMessageOpenFeignClient.sendSystemMsgByMQ(form);
//解锁
if (lock != null) {
lock.unlock();
}
}
});

101
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserDataSyncController.java

@ -0,0 +1,101 @@
/**
* 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.controller;
import com.epmet.commons.tools.distributedlock.DistributedLock;
import com.epmet.commons.tools.feign.ResultDataResolver;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.service.IcResiUserDataSyncService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.redisson.api.RLock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* 用户基础信息同步计算入口
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-10-26
*/
@Slf4j
@RestController
@RequestMapping("icResiUserDataSync")
public class IcResiUserDataSyncController implements ResultDataResolver {
@Autowired
private IcResiUserDataSyncService icResiUserDataSyncService;
@Autowired
private RedisUtils redisUtils;
@Autowired
private DistributedLock distributedLock;
/**
* 获取录入居民的数量
*
* @Param formDTO
* @Return {@link Result<Map<String, Integer>>}
* @Author zhaoqifeng
* @Date 2022/6/30 9:35
*/
@PostMapping("icDataSyncTask")
public Result<Boolean> icDataSyncTask(@RequestParam(value = "customerId",required = false) String customerId) {
RLock lock = null;
String key = RedisKeys.getDataSyncKey("resi");
try {
lock = distributedLock.getLock(RedisKeys.getLockByMethodName("icDataSyncTask"),
30L, 30L, TimeUnit.SECONDS);
if (StringUtils.isBlank(customerId)) {
Object customerIdObj = redisUtils.sPop(key);
while (customerIdObj != null) {
try {
icResiUserDataSyncService.icDataSyncTask(customerIdObj.toString());
log.debug("icDataSyncTask customerId:{} execute success", customerIdObj);
customerIdObj = redisUtils.sPop(key);
} catch (Exception e) {
log.error("icDataSyncTask exception msg:{},customerId:{}", e.getMessage(), customerIdObj);
redisUtils.sAdd(key, customerIdObj);
}
log.debug("icDataSyncTask finish customerId:{} execute success", customerIdObj);
}
} else {
icResiUserDataSyncService.icDataSyncTask(customerId);
log.debug("icDataSyncTask customerId:{} execute success", customerId);
}
} catch (Exception e) {
if (StringUtils.isNotBlank(customerId)) {
redisUtils.sAdd(key, customerId);
}
log.error("icDataSyncTask exception msg:{},customerId:{}", e.getMessage(), customerId);
} finally {
distributedLock.unLock(lock);
}
return new Result<Boolean>().ok(true);
}
}

4
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java

@ -322,9 +322,10 @@ public interface IcResiUserDao extends BaseDao<IcResiUserEntity> {
*
* @param customerId
* @param gridId
* @param neighborhoodId
* @return
*/
List<String> listUserIds(@Param("customerId") String customerId, @Param("gridId") String gridId);
List<String> listUserIds(@Param("customerId") String customerId, @Param("gridId") String gridId, @Param("neighborhoodId") String neighborhoodId);
List<String> getAllUserIds(@Param("idCard") String idCard, @Param("customerId") String customerId);
@ -412,6 +413,7 @@ public interface IcResiUserDao extends BaseDao<IcResiUserEntity> {
/**
* 通过社区ID获取所属人员
*
* @param communityId
* @return
*/

2
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcStatsResiWarnDao.java

@ -87,4 +87,6 @@ public interface IcStatsResiWarnDao extends BaseDao<IcStatsResiWarnEntity> {
List<IcUserWarnNoticeResultDTO> queryUserWarnNotice(@Param("customerId") String customerId,
@Param("agencyId") String agencyId,
@Param("configIds") List<String> configIds);
int deleteByCustomerIdAndConfigId(@Param("configId") String configId, @Param("customerId")String customerId);
}

86
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/ChangeWelfareExcel.java

@ -3,8 +3,6 @@ package com.epmet.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.util.Date;
/**
* 福利表
*
@ -14,14 +12,14 @@ import java.util.Date;
@Data
public class ChangeWelfareExcel {
@Excel(name = "主键")
private String id;
@Excel(name = "epmet用户主键")
private String userId;
@Excel(name = "epmet网格ID")
private String gridId;
// @Excel(name = "主键")
// private String id;
//
// @Excel(name = "epmet用户主键")
// private String userId;
//
// @Excel(name = "epmet网格ID")
// private String gridId;
@Excel(name = "姓名")
private String name;
@ -32,44 +30,44 @@ public class ChangeWelfareExcel {
@Excel(name = "手机号")
private String mobile;
@Excel(name = "性别 0女 1男")
@Excel(name = "性别",replace = { "男_1", "女_0", "女_2", " _null"} )
private String gender;
@Excel(name = "类型")
private String type;
// @Excel(name = "类型")
// private String type;
//
@Excel(name = "加入时间")
private String joinDate;
@Excel(name = "加入原因")
private String joinReason;
@Excel(name = "移除时间")
private String removeDate;
@Excel(name = "移除原因")
private String removeReason;
@Excel(name = "删除标记 0:未删除,1:已删除")
private String delFlag;
@Excel(name = "乐观锁")
private Integer revision;
@Excel(name = "创建人")
private String createdBy;
@Excel(name = "创建时间")
private Date createdTime;
@Excel(name = "更新人")
private String updatedBy;
@Excel(name = "更新时间")
private Date updatedTime;
@Excel(name = "客户ID")
private String customerId;
//
// @Excel(name = "加入原因")
// private String joinReason;
// @Excel(name = "移除时间")
// private String removeDate;
//
// @Excel(name = "移除原因")
// private String removeReason;
//
// @Excel(name = "删除标记 0:未删除,1:已删除")
// private String delFlag;
// @Excel(name = "乐观锁")
// private Integer revision;
//
// @Excel(name = "创建人")
// private String createdBy;
//
// @Excel(name = "创建时间")
// private Date createdTime;
//
// @Excel(name = "更新人")
// private String updatedBy;
//
// @Excel(name = "更新时间")
// private Date updatedTime;
//
// @Excel(name = "客户ID")
// private String customerId;
}

6
epmet-user/epmet-user-server/src/main/java/com/epmet/mq/listener/ICWarnStatsEventListener.java

@ -70,7 +70,11 @@ public class ICWarnStatsEventListener implements MessageListenerConcurrently {
IcResiUserAddMQMsg obj = JSON.parseObject(msg, IcResiUserAddMQMsg.class);
log.info("obj is {}", JSON.toJSONString(obj));
try {
if (!resiWarnStats(obj)||!updateIcNatResiFlag(tags, obj)||!updateIcHouseResiNumber(obj)){
String key = RedisKeys.getDataSyncKey("resi");
redisUtils.sAdd(key, obj.getCustomerId());
//todo 统计预警人数和 更新屋内居民数 用定时任务跑吧 这样太费劲
//||!updateIcHouseResiNumber(obj) !resiWarnStats(obj)|| installed of IcDataSyncTask
if (!updateIcNatResiFlag(tags, obj)){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"消费失败,等待重新消费");
}
} catch (RenException e) {

36
epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserDataSyncService.java

@ -0,0 +1,36 @@
/**
* 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.service;
/**
* 用户基础信息
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-10-26
*/
public interface IcResiUserDataSyncService {
/**
* desc: 同步与居民相关的数据
*
* @param customerId
* @return java.lang.String
* @author LiuJanJun
* @date 2022/7/16 8:06 下午
*/
Boolean icDataSyncTask(String customerId);
}

55
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserDataSyncServiceImpl.java

@ -0,0 +1,55 @@
package com.epmet.service.impl;
import com.epmet.service.IcResiUserDataSyncService;
import com.epmet.service.IcResiUserService;
import com.epmet.service.StatsResiWarnService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.concurrent.ExecutorService;
/**
* desc:
*
* @author: LiuJanJun
* @date: 2022/7/16 8:07 下午
* @version: 1.0
*/
@Slf4j
@Service
public class IcResiUserDataSyncServiceImpl implements IcResiUserDataSyncService {
@Autowired
private IcResiUserService icResiUserService;
@Autowired
private StatsResiWarnService statsResiWarnService;
@Autowired
private ExecutorService executorService;
/**
* desc: 同步与居民相关的数据
*
* @param customerId
* @return java.lang.String
* @author LiuJanJun
* @date 2022/7/16 8:06 下午
*/
@Override
public Boolean icDataSyncTask(String customerId) {
Boolean flag = true;
try {
statsResiWarnService.resiWarn(customerId);
} catch (Exception e) {
flag = false;
log.error("icDataSyncTask resiWarn exception:{}", e.getMessage(), customerId);
}
try {
icResiUserService.updateIcHouseResiNumber(customerId);
} catch (Exception e) {
flag = false;
log.error("icDataSyncTask updateIcHouseResiNumber exception:{}", e.getMessage(), customerId);
}
return flag;
}
}

21
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java

@ -26,6 +26,7 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.epmet.bean.ResiExportBaseInfoData;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.*;
import com.epmet.commons.tools.distributedlock.DistributedLock;
import com.epmet.commons.tools.dto.form.DictListFormDTO;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.dto.result.DictListResultDTO;
@ -153,6 +154,8 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
private UserBaseInfoDao userBaseInfoDao;
@Autowired
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
@Autowired
private DistributedLock distributedLock;
@ -2213,7 +2216,20 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
@Transactional(rollbackFor = Exception.class)
@Override
public List<String> changeIcResiUserBelongTo(TokenDto tokenDto, IcUserBelongToChangedFormDTO formDTO) {
List<String> resiUserIdList = baseDao.listUserIds(formDTO.getCustomerId(), formDTO.getSourceGridId());
List<String> resiUserIdList = baseDao.listUserIds(formDTO.getCustomerId(), formDTO.getSourceGridId(), formDTO.getNeighborhoodId());
if (StringUtils.isBlank(formDTO.getCustomerId()) || StringUtils.isBlank(formDTO.getSourceGridId())
||StringUtils.isBlank(formDTO.getTargetGridId())){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"参数错误","参数错误");
}
IcResiUserEntity entity = new IcResiUserEntity();
entity.setGridId(formDTO.getTargetGridId());
LambdaQueryWrapper<IcResiUserEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(IcResiUserEntity::getGridId,formDTO.getSourceGridId())
.eq(IcResiUserEntity::getVillageId,formDTO.getNeighborhoodId())
.eq(IcResiUserEntity::getCustomerId,formDTO.getCustomerId());
baseDao.update(entity,wrapper);
//不调用原来的更新居民了 太慢
/*List<String> resiUserIdList = baseDao.listUserIds(formDTO.getCustomerId(), formDTO.getSourceGridId());
if (CollectionUtils.isEmpty(resiUserIdList)) {
return null;
}
@ -2231,8 +2247,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
resiUserIdList.forEach(userId -> {
map.put(FieldConstant.ID, userId);
this.edit(tokenDto, icResiUserFormDTOS);
});
});*/
return resiUserIdList;
}

7
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java

@ -306,7 +306,12 @@ public class StatsResiWarnServiceImpl implements StatsResiWarnService {
//保存数据
List<IcStatsResiWarnEntity> icStatsResiWarnEntities = new ArrayList<>();
for (IcResiCategoryWarnConfigDTO item : icResiCategoryWarnConfigDTOList) {
icStatsResiWarnDao.delete(new QueryWrapper<IcStatsResiWarnEntity>().lambda().eq(IcStatsResiWarnEntity::getConfigId,item.getId()).eq(IcStatsResiWarnEntity::getCustomerId,customerId));
int deleteNum;
do {
// deleteNum = icStatsResiWarnDao.delete(new QueryWrapper<IcStatsResiWarnEntity>().lambda().eq(IcStatsResiWarnEntity::getConfigId,item.getId())
// .eq(IcStatsResiWarnEntity::getCustomerId,customerId));
deleteNum = icStatsResiWarnDao.deleteByCustomerIdAndConfigId(item.getId(),customerId);
} while (deleteNum > NumConstant.ZERO);
List<IcStatsResiWarnEntity> maps = icStatsResiWarnDao.resiWarn(customerId,item.getTableName(), item.getColumnName());

5
epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml

@ -206,8 +206,8 @@
)
</if>
</where>
group by IC_RESI_USER.id
<if test="null != groupByTables and groupByTables.size() > 0">
group by IC_RESI_USER.id
<foreach item="groupTableName" collection="groupByTables" open="," separator="," close="">
${groupTableName}.ID
</foreach>
@ -1045,8 +1045,9 @@
SELECT ID from ic_resi_user
WHERE
GRID_ID = #{gridId}
AND DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
and VILLAGE_ID = #{neighborhoodId}
AND DEL_FLAG = '0'
</select>
<select id="getAllUserIds" parameterType="map" resultType="java.lang.String">

7
epmet-user/epmet-user-server/src/main/resources/mapper/IcStatsResiWarnDao.xml

@ -206,4 +206,11 @@
</foreach>
)
</select>
<delete id="deleteByCustomerIdAndConfigId" parameterType="map">
DELETE FROM ic_stats_resi_warn
WHERE config_id = #{configId}
and customer_id = #{customerId}
limit 1000
</delete>
</mapper>

Loading…
Cancel
Save