diff --git a/epmet-admin/epmet-admin-server/deploy/docker-compose-dev.yml b/epmet-admin/epmet-admin-server/deploy/docker-compose-dev.yml
index 6d65b5a344..fbb645ddbc 100644
--- a/epmet-admin/epmet-admin-server/deploy/docker-compose-dev.yml
+++ b/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
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
index b9795ef8dc..579f8ee9cf 100644
--- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
+++ b/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);
+ }
}
diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisUtils.java
index 27636e435a..a324a5970a 100644
--- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisUtils.java
+++ b/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
diff --git a/epmet-commons/epmet-commons-tools/src/main/resources/logback-base.xml b/epmet-commons/epmet-commons-tools/src/main/resources/logback-base.xml
index 4d40231ff9..8b34bed209 100644
--- a/epmet-commons/epmet-commons-tools/src/main/resources/logback-base.xml
+++ b/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
-
-
+
+
+
+
-
+
\ No newline at end of file
diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/AreaCodeDTO.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/AreaCodeDTO.java
index 920d48f56b..6726f0547a 100644
--- a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/AreaCodeDTO.java
+++ b/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
diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/AreaCodeDetailFormDTO.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/AreaCodeDetailFormDTO.java
new file mode 100644
index 0000000000..f4ca97d775
--- /dev/null
+++ b/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;
+}
diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/CustomerTreeDTO.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/CustomerTreeDTO.java
new file mode 100644
index 0000000000..80bf551608
--- /dev/null
+++ b/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
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+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 children;
+}
\ No newline at end of file
diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java
index 4214e77cf8..43766990ba 100644
--- a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java
+++ b/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> workMinutes(@RequestBody WorkMinuteFormDTO param);
+ /**
+ * 行政地区编码查询
+ *
+ * @param formDTO
+ * @return com.epmet.commons.tools.utils.Result>
+ * @author zhy
+ * @date 2022/7/6 15:07
+ */
+ @PostMapping("commonservice/areacode/areacodedetail")
+ Result areaCodeDetail(@RequestBody AreaCodeDetailFormDTO formDTO);
+
+ /**
+ * 行政地区编码树查询
+ *
+ * @param formDTO
+ * @return com.epmet.commons.tools.utils.Result>
+ * @author zhy
+ * @date 2022/7/6 15:07
+ */
+ @PostMapping("commonservice/areacode/areacodetree")
+ Result> areaCodeTree(@RequestBody CustomerTreeDTO formDTO);
+
/**
* @Description 行政地区编码查询
* @Param formDTO
diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java
index 21f7fe531a..05b73bba65 100644
--- a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java
+++ b/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 areaCodeDetail(AreaCodeDetailFormDTO formDTO) {
+ return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "areaCodeDetail", formDTO);
+ }
+
+ @Override
+ public Result> areaCodeTree(CustomerTreeDTO formDTO) {
+ return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "areaCodeTree", formDTO);
+ }
+
@Override
public Result> areaCodeDictTree(AreaCodeDictFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "areaCodeDictTree", formDTO);
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/AreaCodeController.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/AreaCodeController.java
index 7bf4e537f8..ca212e908f 100644
--- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/AreaCodeController.java
+++ b/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> nextArea(@RequestBody AreaCodeFormDTO formDTO){
return new Result>().ok(areaCodeService.nextArea(formDTO));
}
+
+ /**
+ * @Description 行政地区编码查询
+ * @Param formDTO
+ * @author zxc
+ * @date 2021/1/7 下午1:41
+ */
+ @PostMapping("areacodedetail")
+ public Result areaCodeDetail(@RequestBody AreaCodeDetailFormDTO formDTO){
+ return new Result().ok(areaCodeService.getAreaCodeDetail(formDTO));
+ }
+
+ /**
+ * @Description 行政地区编码查询
+ * @Param formDTO
+ * @author zxc
+ * @date 2021/1/7 下午1:41
+ */
+ @PostMapping("areacodetree")
+ public Result> areaCodeTree(@RequestBody CustomerTreeDTO formDTO){
+ return new Result>().ok(areaCodeService.getAreaCodeTree(formDTO));
+ }
}
\ No newline at end of file
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/AreaCodeDao.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/AreaCodeDao.java
index bfe5c8139e..ab101aba89 100644
--- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/AreaCodeDao.java
+++ b/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 {
List 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 selectProvince();
- List selectCity(@Param("pCode")String pCode);
+ List selectCity(@Param("pCode") String pCode);
- List selectDistrict(@Param("pCode")String pCode);
+ List selectDistrict(@Param("pCode") String pCode);
- List selectStreet(@Param("pCode")String pCode);
+ List selectStreet(@Param("pCode") String pCode);
- List selectCommunity(@Param("pCode")String pCode);
+ List selectCommunity(@Param("pCode") String pCode);
}
\ No newline at end of file
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/AreaCodeService.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/AreaCodeService.java
index e452332fea..6467bb82f0 100644
--- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/AreaCodeService.java
+++ b/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 {
String addAreaCode(AddAreaCodeFormDTO formDTO);
List nextArea(AreaCodeFormDTO formDTO);
+
+ AreaCodeResultDTO getAreaCodeDetail(AreaCodeDetailFormDTO formDTO);
+
+ List getAreaCodeTree(CustomerTreeDTO formDTO);
}
\ No newline at end of file
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java
index 4d873b333e..b0f519a3ac 100644
--- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/AreaCodeServiceImpl.java
+++ b/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 page(Map params) {
IPage page = baseDao.selectPage(
@@ -88,8 +87,8 @@ public class AreaCodeServiceImpl extends BaseServiceImpl getWrapper(Map params){
- String id = (String)params.get(FieldConstant.ID_HUMP);
+ private QueryWrapper getWrapper(Map params) {
+ String id = (String) params.get(FieldConstant.ID_HUMP);
QueryWrapper wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
@@ -125,7 +124,7 @@ public class AreaCodeServiceImpl extends BaseServiceImpl areaCodeDictTree(AreaCodeDictFormDTO formDTO) {
List 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 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 treeByRootAreaCode = getTreeByRootAreaCode(tree, formDTO.getRootAreaCode());
@@ -149,12 +148,12 @@ public class AreaCodeServiceImpl extends BaseServiceImpl disposeTree(AreaCodeDictFormDTO formDTO){
+ public List disposeTree(AreaCodeDictFormDTO formDTO) {
// 查询所有省市区
List areaCodeDTOS = baseDao.selectAllArea();
// 查询所有街道、社区
@@ -173,8 +172,8 @@ public class AreaCodeServiceImpl extends BaseServiceImpl {
- if (dto.getCode().equals(pCode)){
+ groupByPCode.forEach((pCode, v) -> {
+ if (dto.getCode().equals(pCode)) {
List fiveResult = new ArrayList<>();
v.forEach(five -> {
AreaCodeDictResultDTO fiveDto = new AreaCodeDictResultDTO();
@@ -189,7 +188,7 @@ public class AreaCodeServiceImpl extends BaseServiceImpl 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 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 {
+ groupByProvince.forEach((p, v) -> {
AreaCodeDictResultDTO dto = new AreaCodeDictResultDTO();
dto.setCode(p);
dto.setName(v.get(NumConstant.ZERO).getProvinceName());
List 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
+ *
* 暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样
- * ==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==
- * 暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样
- *
- *
- *
+ * ==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==
+ * 暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样==暂时这样
* @Param tree
* @Param rootAreaCode
* @author zxc
* @date 2021/1/8 上午10:02
*/
- public List getTreeByRootAreaCode(List tree , String rootAreaCode){
+ public List getTreeByRootAreaCode(List tree, String rootAreaCode) {
List 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 areaCodeDictTreePlus(AreaCodeDictFormDTO formDTO){
+ public List areaCodeDictTreePlus(AreaCodeDictFormDTO formDTO) {
List 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 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 beforeThreeTree(){
+ public List beforeThreeTree() {
// 查询所有省市区
List areaCodeDTOS = baseDao.selectAllArea();
Map> groupByCity = areaCodeDTOS.stream().collect(Collectors.groupingBy(AreaCodeDTO::getCityCode));
@@ -362,13 +358,13 @@ public class AreaCodeServiceImpl extends BaseServiceImpl {
+ groupByProvince.forEach((p, v) -> {
AreaCodeDictResultDTO dto = new AreaCodeDictResultDTO();
dto.setCode(p);
dto.setName(v.get(NumConstant.ZERO).getProvinceName());
List 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 afterTwoTree(AreaCodeDictFormDTO form){
+ public List afterTwoTree(AreaCodeDictFormDTO form) {
// 查询所有街道、社区
List areaCodeChildDTOS = childDao.selectAllChild(form.getRootAreaCode());
List fourResult = new ArrayList<>();
@@ -399,7 +395,7 @@ public class AreaCodeServiceImpl extends BaseServiceImpl levelFive = org.apache.commons.collections4.CollectionUtils.isNotEmpty(groupByLevel.get(NumConstant.FIVE)) ? groupByLevel.get(NumConstant.FIVE) : new ArrayList<>();
Map> groupByPCode = CollectionUtils.isEmpty(levelFive) ? new HashMap<>() : levelFive.stream().collect(Collectors.groupingBy(AreaCodeChildDTO::getPCode));
//街道
- List levelFour = org.apache.commons.collections4.CollectionUtils.isNotEmpty(groupByLevel.get(NumConstant.FOUR)) ?groupByLevel.get(NumConstant.FOUR):new ArrayList<>();
+ List levelFour = org.apache.commons.collections4.CollectionUtils.isNotEmpty(groupByLevel.get(NumConstant.FOUR)) ? groupByLevel.get(NumConstant.FOUR) : new ArrayList<>();
// 6级
List levelSix = groupByLevel.get(NumConstant.SIX);
Map> groupBySixPCode = CollectionUtils.isEmpty(levelSix) ? new HashMap<>() : levelSix.stream().collect(Collectors.groupingBy(AreaCodeChildDTO::getPCode));
@@ -409,8 +405,8 @@ public class AreaCodeServiceImpl extends BaseServiceImpl {
- if (dto.getCode().equals(k)){
+ groupBySixPCode.forEach((k, v) -> {
+ if (dto.getCode().equals(k)) {
List six = new ArrayList<>();
v.forEach(s -> {
AreaCodeDictResultDTO sixDto = new AreaCodeDictResultDTO();
@@ -431,8 +427,8 @@ public class AreaCodeServiceImpl extends BaseServiceImpl {
- 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 disposeAfterTwoLevel(AreaCodeDictFormDTO form){
+ public List disposeAfterTwoLevel(AreaCodeDictFormDTO form) {
List result = new ArrayList<>();
List 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 disposeBeforeThreeLevel(AreaCodeDictFormDTO form,List tree){
+ public List disposeBeforeThreeLevel(AreaCodeDictFormDTO form, List tree) {
List 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 disposeBeforeThreeLevelFinal(AreaCodeDictFormDTO form,List tree){
+ public List disposeBeforeThreeLevelFinal(AreaCodeDictFormDTO form, List tree) {
List threeDto = disposeBeforeThreeLevel(form, tree);
List 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 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 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 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 nextArea(AreaCodeFormDTO formDTO) {
- if(StringUtils.isBlank(formDTO.getParentAreaCode())&&StringUtils.isBlank(formDTO.getParentLevel())){
- String pKey=RedisKeys.getNextAreaCodeKey(NumConstant.ZERO_STR);
- List 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 list = areaCodeRedis.getNextAreaCodeKey(pKey);
+ if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(list)) {
return list;
}
- List pList=baseDao.selectProvince();
- areaCodeRedis.setNextAreaCodeKey(pKey,pList);
+ List pList = baseDao.selectProvince();
+ areaCodeRedis.setNextAreaCodeKey(pKey, pList);
return pList;
}
- String key=RedisKeys.getNextAreaCodeKey(formDTO.getParentAreaCode());
- List list=areaCodeRedis.getNextAreaCodeKey(key);
- if(org.apache.commons.collections4.CollectionUtils.isNotEmpty(list)){
+ String key = RedisKeys.getNextAreaCodeKey(formDTO.getParentAreaCode());
+ List 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 getAreaCodeTree(CustomerTreeDTO formDTO) {
+ List tree = new ArrayList<>();
+ areaCodeHandle(formDTO.getLevel(), formDTO.getAreaCode(), tree);
+ return ConvertUtils.sourceToTarget(tree, CustomerTreeDTO.class);
+ }
+
+ private void areaCodeHandle(String level, String areaCode, List 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);
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/AreaCodeChildDao.xml b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/AreaCodeChildDao.xml
index 34877f6c08..052b4369f7 100644
--- a/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/AreaCodeChildDao.xml
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/AreaCodeChildDao.xml
@@ -20,6 +20,16 @@
and m.`CODE`=#{code}
+
+ SELECT
+ *
+ FROM
+ area_code_child m
+ WHERE
+ m.DEL_FLAG = '0'
+ and m.`CODE`= #{code}
+
+
SELECT
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/AreaCodeDao.xml b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/AreaCodeDao.xml
index 324edf5f0f..629b1edb04 100644
--- a/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/AreaCodeDao.xml
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/AreaCodeDao.xml
@@ -19,6 +19,13 @@
and ac.CITY_CODE=#{cityCode}
+
+ select distinct ac.PROVINCE_CODE,ac.PROVINCE_NAME
+ from area_code ac
+ where ac.DEL_FLAG='0'
+ and ac.PROVINCE_CODE=#{provinceCode}
+
+
select *
from area_code ac
@@ -106,4 +113,28 @@
ORDER BY
ac.`code` ASC
+
+ 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}
+
+
\ No newline at end of file
diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ic/IcDataSyncTask.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ic/IcDataSyncTask.java
new file mode 100644
index 0000000000..c92144ca26
--- /dev/null
+++ b/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());
+ }
+ }
+}
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java
index 52d258308a..70b6bdb9ae 100644
--- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java
+++ b/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 result = new WxResult<>();
String url = WxMaCodeConstant.SUBMIT_AUDIT_URL + "?" + "access_token=" + accessToken;
Result 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());
diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencyAreaResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencyAreaResultDTO.java
new file mode 100644
index 0000000000..3eaaf991df
--- /dev/null
+++ b/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
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+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;
+
+}
diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/OrganizationCodeResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/OrganizationCodeResultDTO.java
index c370f5bbe3..d74033d924 100644
--- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/OrganizationCodeResultDTO.java
+++ b/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;
}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java
index 1ff1bc303c..ae07816fa2 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java
@@ -505,4 +505,33 @@ public class AgencyController {
List dto = agencyService.getAddressTree(name, customerId);
return new Result>().ok(dto);
}
+
+ /**
+ * 获取区域编码下级的所有客户信息
+ *
+ * @param areaCode
+ * @return com.epmet.commons.tools.utils.Result>
+ * @author zhy
+ * @date 2022/7/7 10:12
+ */
+ @GetMapping("/areasubagency/{areaCode}")
+ public Result> getAreaSubAgency(@LoginUser TokenDto tokenDto, @PathVariable String areaCode) {
+ List dto = agencyService.getAreaSubAgency(tokenDto, areaCode);
+ return new Result>().ok(dto);
+ }
+
+ /**
+ * 客户树
+ *
+ * @param
+ * @return com.epmet.commons.tools.utils.Result>
+ * @author zhy
+ * @date 2022/7/6 13:24
+ */
+ @RequestMapping("customertree")
+ public Result> customerTree(@LoginUser TokenDto tokenDto) {
+ return new Result>().ok(agencyService.getCustomerTree(tokenDto));
+ }
+
+
}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java
index 743254c2d4..ece90f219d 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java
+++ b/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();
}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java
index 1c4aa9394c..3059b5a1cf 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java
@@ -353,5 +353,28 @@ public interface CustomerAgencyDao extends BaseDao {
CommunityInfoResultDTO getCommunityInfo(OrgInfoPointFormDTO formDTO);
CommunityInfoResultDTO getCommunityInfoByUserId(@Param("userId") String userId);
+
+ /**
+ * 获取区域编码下级的所有客户信息
+ *
+ * @param areaCode
+ * @return com.epmet.commons.tools.utils.Result>
+ * @author zhy
+ * @date 2022/7/7 10:12
+ */
+ List getAreaSubAgency(@Param("areaCode") String areaCode);
+
+ /**
+ * 客户树根节点
+ *
+ * @param
+ * @return java.util.List
+ * @author zhy
+ * @date 2022/7/6 13:32
+ */
+ List selectRootCustomer(@Param("areaCode") String areaCode, @Param("level") String level);
+
+ CustomerAgencyEntity getAreaRootAgency(@Param("customerId") String customerId);
+
}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java
index 4ae4672647..04c73a7756 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java
+++ b/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 getAddressTree(String name, String customerId);
+
+ /**
+ * 获取区域编码下级的所有客户信息
+ *
+ * @param areaCode
+ * @return com.epmet.commons.tools.utils.Result>
+ * @author zhy
+ * @date 2022/7/7 10:12
+ */
+ List getAreaSubAgency(TokenDto tokenDto, String areaCode);
+
+ /**
+ * 客户树
+ *
+ * @param tokenDto
+ * @return java.util.List
+ * @author zhy
+ * @date 2022/7/6 13:32
+ */
+ List getCustomerTree(TokenDto tokenDto);
+
}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java
index cf2016de58..1505018fa9 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java
+++ b/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 getAreaSubAgency(TokenDto tokenDto, String areaCode) {
+ if (NumConstant.ZERO_STR.equals(areaCode)) {
+ CustomerAgencyEntity root = customerAgencyDao.getAreaRootAgency(tokenDto.getCustomerId());
+ areaCode = root.getAreaCode();
+ }
+
+ List list = customerAgencyDao.getAreaSubAgency(areaCode);
+ list.forEach(item -> {
+ CustomerDTO customerDTO = new CustomerDTO();
+ customerDTO.setId(item.getCustomerId());
+ Result 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 getCustomerTree(TokenDto tokenDto) {
+ List resultList = new ArrayList<>();
+ List rootList = customerAgencyDao.selectRootCustomer(null, null);
+ List treeList = new ArrayList<>();
+ Map 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 treeList) {
+ Result> 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 getCustomerTree(List treeList) {
+ treeList = treeList.stream().distinct().collect(Collectors.toList());
+
+ // 回显客户名称
+ treeList.forEach(item -> {
+ List customerNames = new ArrayList<>();
+ List subList = customerAgencyDao.selectRootCustomer(item.getAreaCode(), item.getLevel());
+ subList.forEach(customer -> {
+ CustomerDTO customerDTO = new CustomerDTO();
+ customerDTO.setId(customer.getCustomerId());
+ Result customerResult = operCrmFeignClient.getCustomerInfo(customerDTO);
+ if (customerResult.success() && null != customerResult.getData()) {
+ customerNames.add(customerResult.getData().getCustomerName());
+ }
+ });
+ item.setCustomerName(Joiner.on(",").join(customerNames));
+ });
+
+ // 省
+ List province = new ArrayList();
+ // 市
+ List city = new ArrayList();
+ // 区
+ List district = new ArrayList();
+ // 街道
+ List street = new ArrayList();
+ // 社区
+ List community = new ArrayList();
+ 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 childList) {
+ List children = new ArrayList();
+ for (CustomerTreeDTO childDto : childList) {
+ if (parentDto.getAreaCode().equals(childDto.getParentCode())) {
+ children.add(childDto);
+ }
+ }
+ parentDto.setChildren(children);
+
+ }
+
}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java
index 65eb7c90e2..0f5079181b 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java
+++ b/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 updateResult = epmetUserOpenFeignClient.changeIcResiUserBelongTo(userForm);
diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml
index 136341dc18..d0e2d2e34c 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml
+++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml
@@ -930,4 +930,55 @@
limit 1
+
+ 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'
+
+ AND ac.AREA_CODE LIKE CONCAT(#{areaCode}, '%')
+
+
+
+
+ SELECT
+ c.*
+ FROM
+ customer_agency c
+ WHERE
+ c.DEL_FLAG = '0'
+ AND c.pid = '0'
+ AND c.AREA_CODE IS NOT NULL
+
+ AND c.AREA_CODE = #{areaCode}
+
+
+ AND c.LEVEL = #{level}
+
+
+
+
+ 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'
+
+ AND ac.CUSTOMER_ID = #{customerId}
+
+
+
diff --git a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/IcDemandFormDTO.java b/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/IcDemandFormDTO.java
index 0e2bc16a97..2140591842 100644
--- a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/IcDemandFormDTO.java
+++ b/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;
}
diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/IcEventServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/IcEventServiceImpl.java
index d6bfb0baba..bc2534911c 100644
--- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/IcEventServiceImpl.java
+++ b/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
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+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;
+
+}
\ No newline at end of file
diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CustomerRelationTreeDTO.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CustomerRelationTreeDTO.java
new file mode 100644
index 0000000000..895e46051b
--- /dev/null
+++ b/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
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+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 children;
+}
\ No newline at end of file
diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java
index c6fc44b140..cda0889b35 100644
--- a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java
+++ b/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 getExternalAndParentCustomerId(@PathVariable("customerId") String customerId);
+
+ /**
+ * 获取子客户
+ *
+ * @param customerId
+ * @return com.epmet.commons.tools.utils.Result>
+ * @author zhy
+ * @date 2022/7/8 13:41
+ */
+ @GetMapping("/oper/crm/customerRelation/subcustomer/{customerId}")
+ Result> getSubCustomer(@PathVariable("customerId") String customerId);
+
}
diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java
index 8366657fa8..380ed077fa 100644
--- a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java
+++ b/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 getExternalAndParentCustomerId(String customerId) {
return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getExternalAndParentCustomerId", customerId);
}
+
+ @Override
+ public Result> getSubCustomer(String customerId) {
+ return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getSubCustomer", customerId);
+ }
}
diff --git a/epmet-module/oper-crm/oper-crm-server/pom.xml b/epmet-module/oper-crm/oper-crm-server/pom.xml
index 5dc49b7305..c6c9ff870a 100644
--- a/epmet-module/oper-crm/oper-crm-server/pom.xml
+++ b/epmet-module/oper-crm/oper-crm-server/pom.xml
@@ -111,6 +111,12 @@
2.0.0
compile
+
+ com.epmet
+ common-service-client
+ 2.0.0
+ compile
+
diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerRelationController.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerRelationController.java
new file mode 100644
index 0000000000..e6a4bc2f25
--- /dev/null
+++ b/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> page(@RequestParam Map params) {
+ PageData page = customerRelationService.page(params);
+ return new Result>().ok(page);
+ }
+
+ @RequestMapping(value = "{id}", method = {RequestMethod.POST, RequestMethod.GET})
+ public Result get(@PathVariable("id") String id) {
+ CustomerRelationDTO data = customerRelationService.get(id);
+ return new Result().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>
+ * @author zhy
+ * @date 2022/7/6 13:24
+ */
+ @RequestMapping("customertree")
+ public Result> customerTree(@LoginUser TokenDto tokenDto) {
+ return new Result>().ok(customerRelationService.getCustomerTree(tokenDto));
+ }
+
+ /**
+ * 获取子客户
+ *
+ * @param customerId
+ * @return com.epmet.commons.tools.utils.Result>
+ * @author zhy
+ * @date 2022/7/8 13:41
+ */
+ @GetMapping("subcustomer/{customerId}")
+ public Result> getSubCustomer(@PathVariable("customerId") String customerId) {
+ if(StringUtils.isNotBlank(customerId)){
+ List result = customerRelationService.getSubCustomer(customerId);
+ return new Result>().ok(result);
+ }
+ return new Result<>();
+ }
+}
diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerRelationDao.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerRelationDao.java
index 948937062c..ee8e6255ce 100644
--- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerRelationDao.java
+++ b/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 {
* @return java.util.List
*/
List selectAllSubCustomerIds(String customerId);
+
+ /**
+ * 客户树根节点
+ *
+ * @param customerId
+ * @return java.util.List
+ * @author zhy
+ * @date 2022/7/6 13:32
+ */
+ List selectRootCustomerByCustomerId(@Param("customerId") String customerId);
+
+ /**
+ * 客户树子节点
+ *
+ * @param customerPid
+ * @return java.util.List
+ * @author zhy
+ * @date 2022/7/6 13:32
+ */
+ List selectSubCustomerByPid(@Param("customerPid") String customerPid);
+
+ /**
+ * 获取子客户
+ *
+ * @param customerId
+ * @return com.epmet.commons.tools.utils.Result>
+ * @author zhy
+ * @date 2022/7/8 13:41
+ */
+ List getSubCustomer(@Param("customerId") String customerId);
+
}
\ No newline at end of file
diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerRelationEntity.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerRelationEntity.java
index 9c33664b50..1c0a077b14 100644
--- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerRelationEntity.java
+++ b/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;
+
}
diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerRelationService.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerRelationService.java
index 2776c8b0cf..05ee703d22 100644
--- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerRelationService.java
+++ b/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 getAllSubCustomerIds(String customerId);
+
+ /**
+ * 客户树
+ *
+ * @param tokenDto
+ * @return java.util.List
+ * @author zhy
+ * @date 2022/7/6 13:32
+ */
+ List getCustomerTree(TokenDto tokenDto);
+
+ List getSubCustomer(String customerId);
+
}
\ No newline at end of file
diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerRelationServiceImpl.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerRelationServiceImpl.java
index 6a68df0455..415a6c831a 100644
--- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerRelationServiceImpl.java
+++ b/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 page(Map params) {
@@ -75,8 +83,8 @@ public class CustomerRelationServiceImpl extends BaseServiceImpl getWrapper(Map params){
- String id = (String)params.get(FieldConstant.ID_HUMP);
+ private QueryWrapper getWrapper(Map params) {
+ String id = (String) params.get(FieldConstant.ID_HUMP);
QueryWrapper wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
@@ -97,6 +105,15 @@ public class CustomerRelationServiceImpl extends BaseServiceImpl();
}
+ @Override
+ public List getCustomerTree(TokenDto tokenDto) {
+// String customerId = tokenDto.getCustomerId();
+ String customerId = "78e2b2227c07de1fe54da14e2b2d9eb6";
+ List rootList = baseDao.selectRootCustomerByCustomerId(customerId);
+ if (!rootList.isEmpty()) {
+ rootList.forEach(this::getSubCustomer);
+ }
+ return rootList;
+ }
+
+ @Override
+ public List 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 area = epmetCommonServiceOpenFeignClient.areaCodeDetail(formDTO);
+ if (area.success()) {
+ if (area.getData() != null) {
+ customer.setAreaName(area.getData().getAreaName());
+ }
+ }
+ List children = baseDao.selectSubCustomerByPid(customer.getCustomerId());
+ customer.setChildren(children);
+ if (!children.isEmpty()) {
+ children.forEach(this::getSubCustomer);
+ }
+ return customer;
+ }
+
}
diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerRelationDao.xml b/epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerRelationDao.xml
index f757a48b51..525e388cf4 100644
--- a/epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerRelationDao.xml
+++ b/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
+ 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
+ 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
+ CUSTOMER_ID
+ FROM
+ customer_relation
+ WHERE
+ `STATUS` = 'open'
+ AND FIND_IN_SET( #{customerId}, pids )
+ AND DEL_FLAG = '0'
+
+
\ No newline at end of file
diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcUserBelongToChangedFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcUserBelongToChangedFormDTO.java
index da773e7266..102bbd9c9b 100644
--- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcUserBelongToChangedFormDTO.java
+++ b/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
*/
diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java
index 65e7b7b850..d52625b704 100644
--- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java
+++ b/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> getIcUserCount(@RequestBody IcUserCountFormDTO formDTO);
+
+ /**
+ * desc: 同步数据,房内居民数量 类别统计数据量等只用客户id当条件
+ *
+ * @param customerId
+ * @return com.epmet.commons.tools.utils.Result
+ * @author LiuJanJun
+ * @date 2022/7/16 6:53 下午
+ */
+ @PostMapping("/epmetuser/icResiUserDataSync/icDataSyncTask")
+ Result icDataSyncTask(String customerId);
}
diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java
index 8c47cdb204..56b203743a 100644
--- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java
+++ b/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 icDataSyncTask(String customerId) {
+ return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "icDataSyncTask", customerId);
+ }
+
}
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/ChangeWelfareController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/ChangeWelfareController.java
index 8f95f22f45..c1cac171ec 100644
--- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/ChangeWelfareController.java
+++ b/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 params, HttpServletResponse response) throws Exception {
List list = changeWelfareService.list(params);
- ExcelUtils.exportExcelToTarget(response, null, list, ChangeWelfareExcel.class);
+ ExcelUtils.exportEpmetExcel(response, null, list, ChangeWelfareExcel.class);
}
/**
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java
index 161be43e92..8ed931e7ed 100644
--- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java
+++ b/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 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 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();
+ }
}
});
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserDataSyncController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserDataSyncController.java
new file mode 100644
index 0000000000..ae875c7acf
--- /dev/null
+++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserDataSyncController.java
@@ -0,0 +1,101 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+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>}
+ * @Author zhaoqifeng
+ * @Date 2022/6/30 9:35
+ */
+ @PostMapping("icDataSyncTask")
+ public Result 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().ok(true);
+ }
+}
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java
index 73e5247785..4dcf2a8537 100644
--- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java
+++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java
@@ -322,9 +322,10 @@ public interface IcResiUserDao extends BaseDao {
*
* @param customerId
* @param gridId
+ * @param neighborhoodId
* @return
*/
- List listUserIds(@Param("customerId") String customerId, @Param("gridId") String gridId);
+ List listUserIds(@Param("customerId") String customerId, @Param("gridId") String gridId, @Param("neighborhoodId") String neighborhoodId);
List getAllUserIds(@Param("idCard") String idCard, @Param("customerId") String customerId);
@@ -412,6 +413,7 @@ public interface IcResiUserDao extends BaseDao {
/**
* 通过社区ID获取所属人员
+ *
* @param communityId
* @return
*/
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcStatsResiWarnDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcStatsResiWarnDao.java
index 3e261b041f..e3c7d35318 100644
--- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcStatsResiWarnDao.java
+++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcStatsResiWarnDao.java
@@ -87,4 +87,6 @@ public interface IcStatsResiWarnDao extends BaseDao {
List queryUserWarnNotice(@Param("customerId") String customerId,
@Param("agencyId") String agencyId,
@Param("configIds") List configIds);
+
+ int deleteByCustomerIdAndConfigId(@Param("configId") String configId, @Param("customerId")String customerId);
}
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/ChangeWelfareExcel.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/ChangeWelfareExcel.java
index 909294dfa9..99437aa726 100644
--- a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/ChangeWelfareExcel.java
+++ b/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;
}
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/mq/listener/ICWarnStatsEventListener.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/mq/listener/ICWarnStatsEventListener.java
index e74c011246..c1328f548a 100644
--- a/epmet-user/epmet-user-server/src/main/java/com/epmet/mq/listener/ICWarnStatsEventListener.java
+++ b/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) {
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserDataSyncService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserDataSyncService.java
new file mode 100644
index 0000000000..7e1ccc9a24
--- /dev/null
+++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserDataSyncService.java
@@ -0,0 +1,36 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+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);
+}
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserDataSyncServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserDataSyncServiceImpl.java
new file mode 100644
index 0000000000..95c5f97e34
--- /dev/null
+++ b/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;
+ }
+}
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java
index 0616392e8e..810015eab3 100644
--- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java
+++ b/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 changeIcResiUserBelongTo(TokenDto tokenDto, IcUserBelongToChangedFormDTO formDTO) {
- List resiUserIdList = baseDao.listUserIds(formDTO.getCustomerId(), formDTO.getSourceGridId());
+ List 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 wrapper = new LambdaQueryWrapper<>();
+ wrapper.eq(IcResiUserEntity::getGridId,formDTO.getSourceGridId())
+ .eq(IcResiUserEntity::getVillageId,formDTO.getNeighborhoodId())
+ .eq(IcResiUserEntity::getCustomerId,formDTO.getCustomerId());
+ baseDao.update(entity,wrapper);
+ //不调用原来的更新居民了 太慢
+ /*List resiUserIdList = baseDao.listUserIds(formDTO.getCustomerId(), formDTO.getSourceGridId());
if (CollectionUtils.isEmpty(resiUserIdList)) {
return null;
}
@@ -2231,8 +2247,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl {
map.put(FieldConstant.ID, userId);
this.edit(tokenDto, icResiUserFormDTOS);
- });
-
+ });*/
return resiUserIdList;
}
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java
index 13645f9047..cced7c95b1 100644
--- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java
+++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java
@@ -306,7 +306,12 @@ public class StatsResiWarnServiceImpl implements StatsResiWarnService {
//保存数据
List icStatsResiWarnEntities = new ArrayList<>();
for (IcResiCategoryWarnConfigDTO item : icResiCategoryWarnConfigDTOList) {
- icStatsResiWarnDao.delete(new QueryWrapper().lambda().eq(IcStatsResiWarnEntity::getConfigId,item.getId()).eq(IcStatsResiWarnEntity::getCustomerId,customerId));
+ int deleteNum;
+ do {
+ // deleteNum = icStatsResiWarnDao.delete(new QueryWrapper().lambda().eq(IcStatsResiWarnEntity::getConfigId,item.getId())
+ // .eq(IcStatsResiWarnEntity::getCustomerId,customerId));
+ deleteNum = icStatsResiWarnDao.deleteByCustomerIdAndConfigId(item.getId(),customerId);
+ } while (deleteNum > NumConstant.ZERO);
List maps = icStatsResiWarnDao.resiWarn(customerId,item.getTableName(), item.getColumnName());
diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml
index ce42de4964..c71227da0d 100644
--- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml
+++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml
@@ -206,8 +206,8 @@
)
- group by IC_RESI_USER.id
+ group by IC_RESI_USER.id
${groupTableName}.ID
@@ -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'
diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcStatsResiWarnDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcStatsResiWarnDao.xml
index 24e607f3c7..9efaf62361 100644
--- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcStatsResiWarnDao.xml
+++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcStatsResiWarnDao.xml
@@ -206,4 +206,11 @@
)
+
+
+ DELETE FROM ic_stats_resi_warn
+ WHERE config_id = #{configId}
+ and customer_id = #{customerId}
+ limit 1000
+