From 006d263997d2bf202509fd2d60cf8ea63fd12fe4 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Tue, 12 Apr 2022 14:55:21 +0800 Subject: [PATCH] areaCodePath --- .../redis/common/bean/AgencyInfoCache.java | 6 ++ .../entity/govorg/CustomerAgencyEntity.java | 7 ++ .../govorg/impl/GovOrgServiceImpl.java | 76 ++++++++++--------- .../dto/result/StaffBasicInfoResultDTO.java | 5 +- .../impl/CustomerStaffServiceImpl.java | 2 +- 5 files changed, 58 insertions(+), 38 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/AgencyInfoCache.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/AgencyInfoCache.java index 684440db65..1a842d3987 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/AgencyInfoCache.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/AgencyInfoCache.java @@ -4,6 +4,7 @@ import lombok.Data; import java.io.Serializable; import java.util.Date; +import java.util.List; /** * @Author zxc @@ -59,6 +60,11 @@ public class AgencyInfoCache implements Serializable { */ private String areaCode; + /** + * 地区编码全路径:例如:37,3702,370203,370203005,370203005015 + */ + private List areaCodePath; + /** * 删除标识 */ diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/govorg/CustomerAgencyEntity.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/govorg/CustomerAgencyEntity.java index 171e01198f..28bf2d90a8 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/govorg/CustomerAgencyEntity.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/govorg/CustomerAgencyEntity.java @@ -22,6 +22,8 @@ import com.epmet.commons.mybatis.entity.BaseEpmetEntity; import lombok.Data; import lombok.EqualsAndHashCode; +import java.util.List; + /** * 机关单位信息表 * @@ -74,6 +76,11 @@ public class CustomerAgencyEntity extends BaseEpmetEntity { */ private String areaCode; + /** + * 地区编码全路径:例如:37,3702,370203,370203005,370203005015 + */ + private List areaCodePath; + /** * 总人数 */ diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java index 4d1b356fd3..dd8f54cab7 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java @@ -6,6 +6,7 @@ import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; import com.alibaba.fastjson.JSON; import com.dingtalk.api.request.OapiRobotSendRequest; import com.epmet.commons.dynamic.datasource.annotation.DataSource; +import com.epmet.commons.tools.constant.Constant; import com.epmet.commons.tools.constant.DingDingRobotConstant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; @@ -250,41 +251,6 @@ public class GovOrgServiceImpl implements GovOrgService { return result; } - public static void main(String[] args) { - List allList = new ArrayList<>(); - NextAreaCodeResultDTO m1 = new NextAreaCodeResultDTO(); - m1.setAreaCode("1"); - m1.setAreaName("a"); - allList.add(m1); - - NextAreaCodeResultDTO m2 = new NextAreaCodeResultDTO(); - m2.setAreaCode("2"); - m2.setAreaName("b"); - allList.add(m2); - - - NextAreaCodeResultDTO m3 = new NextAreaCodeResultDTO(); - m3.setAreaCode("3"); - m3.setAreaName("c"); - allList.add(m3); - - List stringList = new ArrayList<>(); - stringList.add("1"); - stringList.add("2"); - - Iterator iterator = allList.iterator(); - while (iterator.hasNext()) { - NextAreaCodeResultDTO next = iterator.next(); - for (String usedAreaCode : stringList) { - if (next.getAreaCode().equals(usedAreaCode)) { - iterator.remove(); - } - } - - } - System.out.println(JSON.toJSONString(allList, true)); - } - /** * @param staffId * @Author sun @@ -643,7 +609,45 @@ public class GovOrgServiceImpl implements GovOrgService { */ @Override public CustomerAgencyEntity getAgencyInfo(String agencyId) { - return customerAgencyDao.selectById(agencyId); + CustomerAgencyEntity customerAgencyEntity=customerAgencyDao.selectById(agencyId); + //设置行政地区编码全路径 + if (StringUtils.isNotBlank(customerAgencyEntity.getAreaCode()) && StringUtils.isNotBlank(customerAgencyEntity.getParentAreaCode())) { + customerAgencyEntity.setAreaCodePath(queryAreaCodePath(customerAgencyEntity)); + } + + return customerAgencyEntity; + } + + private List queryAreaCodePath(CustomerAgencyEntity customerAgencyEntity) { + List areaCodePath = new ArrayList<>(); + switch (customerAgencyEntity.getLevel()) { + case Constant.COMMUNITY: + areaCodePath.add(customerAgencyEntity.getAreaCode().substring(NumConstant.ZERO, NumConstant.TWO)); + areaCodePath.add(customerAgencyEntity.getAreaCode().substring(NumConstant.ZERO, NumConstant.FOUR)); + areaCodePath.add(customerAgencyEntity.getAreaCode().substring(NumConstant.ZERO, NumConstant.SIX)); + areaCodePath.add(customerAgencyEntity.getParentAreaCode()); + areaCodePath.add(customerAgencyEntity.getAreaCode()); + break; + case Constant.STREET: + areaCodePath.add(customerAgencyEntity.getAreaCode().substring(NumConstant.ZERO, NumConstant.TWO)); + areaCodePath.add(customerAgencyEntity.getAreaCode().substring(NumConstant.ZERO, NumConstant.FOUR)); + areaCodePath.add(customerAgencyEntity.getParentAreaCode()); + areaCodePath.add(customerAgencyEntity.getAreaCode()); + break; + case Constant.DISTRICT: + areaCodePath.add(customerAgencyEntity.getAreaCode().substring(NumConstant.ZERO, NumConstant.TWO)); + areaCodePath.add(customerAgencyEntity.getParentAreaCode()); + areaCodePath.add(customerAgencyEntity.getAreaCode()); + break; + case Constant.CITY: + areaCodePath.add(customerAgencyEntity.getParentAreaCode()); + areaCodePath.add(customerAgencyEntity.getAreaCode()); + break; + case Constant.PROVINCE: + areaCodePath.add(customerAgencyEntity.getAreaCode()); + break; + } + return areaCodePath; } /** diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StaffBasicInfoResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StaffBasicInfoResultDTO.java index c062414971..33416972ae 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StaffBasicInfoResultDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StaffBasicInfoResultDTO.java @@ -92,5 +92,8 @@ public class StaffBasicInfoResultDTO implements Serializable { */ private String latitude; - private String areaCode; + /** + * 地区编码全路径:例如:37,3702,370203,370203005,370203005015 + */ + private List areaCodePath; } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java index b534d917cb..2991b7e39c 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java @@ -745,7 +745,7 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl()); } //获取工作人员所属客户名 CustomerDTO dto = new CustomerDTO();