From 40a0bb4765a466f72b05963ba93d0798ce415dd6 Mon Sep 17 00:00:00 2001 From: wxz Date: Mon, 22 Jun 2020 18:02:16 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=EF=BC=9A=E8=B0=83=E6=95=B4?= =?UTF-8?q?agency=E7=BB=B4=E5=BA=A6=E7=9A=84=E7=94=9F=E6=88=90=EF=BC=8C?= =?UTF-8?q?=E7=94=9F=E6=88=90=E6=9C=AC=E8=BA=AB=E5=8F=8A=E6=89=80=E6=9C=89?= =?UTF-8?q?=E4=B8=8B=E7=BA=A7(all)=EF=BC=8C=E6=9C=AC=E8=BA=AB(self)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/constant/DimAgencyConstant.java | 10 ++++ .../epmet/entity/stats/DimAgencyEntity.java | 5 ++ .../stats/impl/DimAgencyServiceImpl.java | 49 ++++++++++++++----- .../migration/V0.0.2__dim_ag_add_col_type.sql | 1 + 4 files changed, 53 insertions(+), 12 deletions(-) create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/DimAgencyConstant.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.2__dim_ag_add_col_type.sql diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/DimAgencyConstant.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/DimAgencyConstant.java new file mode 100644 index 0000000000..b447c1f2da --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/DimAgencyConstant.java @@ -0,0 +1,10 @@ +package com.epmet.constant; + +public interface DimAgencyConstant { + + String TYPE_ALL = "all"; + String TYPE_SELF = "self"; + + String TYPE_SELF_ID_SUFFIX = "-self"; + +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/DimAgencyEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/DimAgencyEntity.java index 2ca7c2a168..28b471f0a2 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/DimAgencyEntity.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/DimAgencyEntity.java @@ -58,6 +58,11 @@ public class DimAgencyEntity extends BaseEpmetEntity { */ private String pids; + /** + * 机关维度类型。self:机关本身自己,all:机关自己+下级+网格+部门等 + */ + private String agencyDimType; + /** * 所有上级名称,以-连接 */ diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java index 16e627c42c..ef1c918895 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java @@ -25,6 +25,7 @@ import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.constant.DimAgencyConstant; import com.epmet.constant.RobotConstant; import com.epmet.constant.StatsSubject; import com.epmet.dao.stats.DimAgencyDao; @@ -44,7 +45,6 @@ import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; /** * 机关维度 @@ -125,22 +125,47 @@ public class DimAgencyServiceImpl extends BaseServiceImpl agencies) { for (CustomerAgencyEntity agency : agencies) { - DimAgencyEntity dimAgencyEntity = new DimAgencyEntity(); - dimAgencyEntity.setAgencyName(agency.getOrganizationName()); - dimAgencyEntity.setAllParentName(agency.getAllParentName()); - dimAgencyEntity.setCustomerId(agency.getCustomerId()); - dimAgencyEntity.setLevel(agency.getLevel()); - dimAgencyEntity.setPid(agency.getPid()); - dimAgencyEntity.setPids(agency.getPids()); - dimAgencyEntity.setCreatedBy(RobotConstant.DIMENSION_ROBOT); - dimAgencyEntity.setUpdatedBy(RobotConstant.DIMENSION_ROBOT); - dimAgencyEntity.setId(agency.getId()); - baseDao.insert(dimAgencyEntity); + initAgencyAllDim(agency); + initAgencySelfDim(agency); } lastExecRecordDao.updateExecTimeBySubject(new Date(), StatsSubject.DIM_AGENCY); } + public void initAgencyAllDim(CustomerAgencyEntity agency) { + DimAgencyEntity dimAgencyEntity = new DimAgencyEntity(); + dimAgencyEntity.setAgencyName(agency.getOrganizationName()); + dimAgencyEntity.setAllParentName(agency.getAllParentName()); + dimAgencyEntity.setCustomerId(agency.getCustomerId()); + dimAgencyEntity.setLevel(agency.getLevel()); + dimAgencyEntity.setAgencyDimType(DimAgencyConstant.TYPE_ALL); + dimAgencyEntity.setPid(agency.getPid()); + dimAgencyEntity.setPids(agency.getPids()); + dimAgencyEntity.setCreatedBy(RobotConstant.DIMENSION_ROBOT); + dimAgencyEntity.setUpdatedBy(RobotConstant.DIMENSION_ROBOT); + dimAgencyEntity.setId(agency.getId()); + baseDao.insert(dimAgencyEntity); + } + + /** + * 初始化机关单位本身的维度(不包含本身) + * @param agency + */ + public void initAgencySelfDim(CustomerAgencyEntity agency) { + DimAgencyEntity dimAgencyEntity = new DimAgencyEntity(); + dimAgencyEntity.setAgencyName(agency.getOrganizationName()); + dimAgencyEntity.setAllParentName(agency.getAllParentName()); + dimAgencyEntity.setCustomerId(agency.getCustomerId()); + dimAgencyEntity.setLevel(agency.getLevel()); + dimAgencyEntity.setPid(agency.getId()); + dimAgencyEntity.setAgencyDimType(DimAgencyConstant.TYPE_SELF); + dimAgencyEntity.setPids(agency.getPids().concat(":").concat(agency.getId())); + dimAgencyEntity.setCreatedBy(RobotConstant.DIMENSION_ROBOT); + dimAgencyEntity.setUpdatedBy(RobotConstant.DIMENSION_ROBOT); + dimAgencyEntity.setId(agency.getId().concat(DimAgencyConstant.TYPE_SELF_ID_SUFFIX)); + baseDao.insert(dimAgencyEntity); + } + /** * @Description 查询所有机关以及它下级机关的信息 * @param diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.2__dim_ag_add_col_type.sql b/epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.2__dim_ag_add_col_type.sql new file mode 100644 index 0000000000..9f1554015e --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.2__dim_ag_add_col_type.sql @@ -0,0 +1 @@ +ALTER TABLE dim_agency ADD COLUMN AGENCY_DIM_TYPE VARCHAR(10) NOT NULL COMMENT '机关维度类型。self:机关本身自己,all:机关自己+下级+网格+部门等'; \ No newline at end of file