From 3956d3e5b889edb48a34c03ee3a440d2a42f7fa3 Mon Sep 17 00:00:00 2001
From: yinzuomei <576302893@qq.com>
Date: Tue, 18 Jan 2022 14:50:21 +0800
Subject: [PATCH 1/8] zancun
---
.../epmet/constant/DataSourceConstant.java | 1 +
.../customize/IcResiCategoryConfigDTO.java | 18 +++
.../IcUserCategoryAnalysisDailyFormDTO.java | 32 ++++
.../dto/user/result/OrgIcUserTotalDTO.java | 12 ++
.../data-statistical-server/pom.xml | 26 +++
.../com/epmet/controller/IcController.java | 76 +++++++++
.../IcResiCategoryStatsConfigDao.java | 14 ++
.../FactIcuserCategoryAnalysisDailyDao.java | 20 +++
.../main/java/com/epmet/dao/user/UserDao.java | 9 ++
...FactIcuserCategoryAnalysisDailyEntity.java | 71 ++++++++
.../IcResiCategoryStatsConfigService.java | 22 +++
.../IcResiCategoryStatsConfigServiceImpl.java | 40 +++++
.../screen/ScreenCustomerGridService.java | 3 +
.../impl/ScreenCustomerGridServiceImpl.java | 9 ++
...actIcuserCategoryAnalysisDailyService.java | 20 +++
...cuserCategoryAnalysisDailyServiceImpl.java | 153 ++++++++++++++++++
.../com/epmet/service/user/UserService.java | 19 +++
.../service/user/impl/UserServiceImpl.java | 75 +++++++++
.../src/main/resources/bootstrap.yml | 5 +
.../IcResiCategoryStatsConfigDao.xml | 23 +++
.../FactIcuserCategoryAnalysisDailyDao.xml | 13 ++
.../main/resources/mapper/user/UserDao.xml | 51 ++++++
22 files changed, 712 insertions(+)
create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/customize/IcResiCategoryConfigDTO.java
create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/form/IcUserCategoryAnalysisDailyFormDTO.java
create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/OrgIcUserTotalDTO.java
create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IcController.java
create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/customize/IcResiCategoryStatsConfigDao.java
create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactIcuserCategoryAnalysisDailyDao.java
create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/FactIcuserCategoryAnalysisDailyEntity.java
create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/customize/IcResiCategoryStatsConfigService.java
create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/customize/impl/IcResiCategoryStatsConfigServiceImpl.java
create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactIcuserCategoryAnalysisDailyService.java
create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactIcuserCategoryAnalysisDailyServiceImpl.java
create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/customize/IcResiCategoryStatsConfigDao.xml
create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactIcuserCategoryAnalysisDailyDao.xml
diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/DataSourceConstant.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/DataSourceConstant.java
index 064104b9b2..1ae7002dc4 100644
--- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/DataSourceConstant.java
+++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/DataSourceConstant.java
@@ -15,4 +15,5 @@ public interface DataSourceConstant {
String PARTY_MEMBER = "partyMember";
String EPMET_HEART="epmetHeart";
String EPMET_POINT = "epmetPoint";
+ String OPER_CUSTOMIZE="operCustomize";
}
diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/customize/IcResiCategoryConfigDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/customize/IcResiCategoryConfigDTO.java
new file mode 100644
index 0000000000..ea519b9b20
--- /dev/null
+++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/customize/IcResiCategoryConfigDTO.java
@@ -0,0 +1,18 @@
+package com.epmet.dto.customize;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+
+
+@Data
+public class IcResiCategoryConfigDTO implements Serializable {
+ private String configId;
+ /**
+ * 列名
+ */
+ private String columnName;
+
+ private String itemLabel;
+}
diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/form/IcUserCategoryAnalysisDailyFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/form/IcUserCategoryAnalysisDailyFormDTO.java
new file mode 100644
index 0000000000..4804125448
--- /dev/null
+++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/form/IcUserCategoryAnalysisDailyFormDTO.java
@@ -0,0 +1,32 @@
+package com.epmet.dto.extract.form;
+
+import lombok.Data;
+import org.hibernate.validator.constraints.Length;
+
+import java.io.Serializable;
+
+/**
+ * 数字社区-人员类别分析,按天计算,入参
+ * 以下参数都可以为空
+ */
+@Data
+public class IcUserCategoryAnalysisDailyFormDTO implements Serializable {
+ public interface AddUserInternalGroup {
+ }
+
+ private String customerId;
+ @Length(max = 8, message = "日期格式:yyyyMMdd", groups = AddUserInternalGroup.class)
+ private String dateId;
+
+ /**
+ * 开始时间
+ */
+ @Length(max = 8, message = "开始日期日期格式:yyyyMMdd", groups = AddUserInternalGroup.class)
+ private String startDate;
+ /**
+ * 结束时间
+ */
+ @Length(max = 8, message = "截止日期格式:yyyyMMdd", groups = AddUserInternalGroup.class)
+ private String endDate;
+
+}
diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/OrgIcUserTotalDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/OrgIcUserTotalDTO.java
new file mode 100644
index 0000000000..b7360d975d
--- /dev/null
+++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/user/result/OrgIcUserTotalDTO.java
@@ -0,0 +1,12 @@
+package com.epmet.dto.user.result;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class OrgIcUserTotalDTO implements Serializable {
+ private String orgId;
+ private Integer total;
+ private String columnName;
+}
diff --git a/epmet-module/data-statistical/data-statistical-server/pom.xml b/epmet-module/data-statistical/data-statistical-server/pom.xml
index 6c21774ece..8b145da840 100644
--- a/epmet-module/data-statistical/data-statistical-server/pom.xml
+++ b/epmet-module/data-statistical/data-statistical-server/pom.xml
@@ -260,6 +260,13 @@
epmet_point_user
EpmEt-db-UsEr
+
+
+
+
+ epmet_oper_customize_user
+ EpmEt-db-UsEr
+
0
192.168.1.140
@@ -382,6 +389,13 @@
epmet_point_user
EpmEt-db-UsEr
+
+
+
+
+ epmet_oper_customize_user
+ EpmEt-db-UsEr
+
0
192.168.1.140
@@ -504,6 +518,12 @@
epmet
elink@833066
+
+
+
+ epmet
+ elink@833066
+
0
r-m5eoz5b6tkx09y6bpz.redis.rds.aliyuncs.com
@@ -622,6 +642,12 @@
epmet_point_user
EpmEt-db-UsEr
+
+
+
+ epmet_oper_customize_user
+ EpmEt-db-UsEr
+
0
r-m5ez3n1j0qc3ykq2ut.redis.rds.aliyuncs.com
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IcController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IcController.java
new file mode 100644
index 0000000000..5f93d62c1e
--- /dev/null
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IcController.java
@@ -0,0 +1,76 @@
+package com.epmet.controller;
+
+
+import com.epmet.commons.tools.constant.NumConstant;
+import com.epmet.commons.tools.utils.DateUtils;
+import com.epmet.commons.tools.utils.Result;
+import com.epmet.commons.tools.validator.ValidatorUtils;
+import com.epmet.dto.extract.form.IcUserCategoryAnalysisDailyFormDTO;
+import com.epmet.service.stats.DimCustomerService;
+import com.epmet.service.stats.FactIcuserCategoryAnalysisDailyService;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Description 数字社区相关统计任务可以放这,目前只有人员类别分析
+ * @Author yinzuomei
+ * @Date 2022/01/17
+ * @Version 1.0
+ */
+@RestController
+@RequestMapping("ic")
+public class IcController {
+
+ @Autowired
+ private FactIcuserCategoryAnalysisDailyService userCategoryAnalysisDailyService;
+ @Autowired
+ private DimCustomerService dimCustomerService;
+
+ /**
+ * 数字社区-基础信息-人员类别分析-每个类别的人员总数、较上月迁入迁出人数
+ * 说明:安调统计,截止到当前dateId的党员总数;+30:迁入党员+之前的居民在本月内变更为党员身份的;-10:在本月丢失党员身份的人+迁出的人
+ * @return
+ */
+ @PostMapping("/user/category-analysis-daily")
+ public Result statUserCategoryDaily(@RequestBody IcUserCategoryAnalysisDailyFormDTO formDTO) {
+ ValidatorUtils.validateEntity(formDTO, IcUserCategoryAnalysisDailyFormDTO.AddUserInternalGroup.class);
+ List customerIds = new ArrayList<>();
+ if (StringUtils.isNotBlank(formDTO.getCustomerId())) {
+ customerIds.add(formDTO.getCustomerId());
+ } else {
+ //未指定客户,则查询dim_customer表
+ customerIds = dimCustomerService.selectCustomerIdPage(NumConstant.ONE, NumConstant.ONE_THOUSAND);
+ }
+ if (CollectionUtils.isNotEmpty(customerIds)) {
+ customerIds.forEach(customerId -> {
+ if (StringUtils.isNotBlank(formDTO.getStartDate()) && StringUtils.isNotBlank(formDTO.getEndDate())) {
+ //[a,b]yyyyMMdd
+ List daysBetween = DateUtils.getDaysBetween(formDTO.getStartDate(), formDTO.getEndDate());
+ daysBetween.forEach(dateId -> {
+ //计算网格维度的数据
+ userCategoryAnalysisDailyService.statUserCategoryGridDaily(customerId, dateId);
+ });
+ } else if (StringUtils.isNotBlank(formDTO.getDateId())) {
+ //计算网格维度的数据
+ userCategoryAnalysisDailyService.statUserCategoryGridDaily(customerId, formDTO.getDateId());
+ } else {
+ //计算网格维度的数据
+ //当前时间的前一天yyyyMMdd
+ String dateId = LocalDate.now().minusDays(NumConstant.ONE).toString().replace("-", "");
+ userCategoryAnalysisDailyService.statUserCategoryGridDaily(customerId, dateId);
+ }
+ });
+ }
+ return new Result();
+ }
+
+}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/customize/IcResiCategoryStatsConfigDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/customize/IcResiCategoryStatsConfigDao.java
new file mode 100644
index 0000000000..43b78b9b73
--- /dev/null
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/customize/IcResiCategoryStatsConfigDao.java
@@ -0,0 +1,14 @@
+package com.epmet.dao.customize;
+
+
+import com.epmet.dto.customize.IcResiCategoryConfigDTO;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+@Mapper
+public interface IcResiCategoryStatsConfigDao {
+
+
+ List queryDataColumn(String customerId);
+}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactIcuserCategoryAnalysisDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactIcuserCategoryAnalysisDailyDao.java
new file mode 100644
index 0000000000..2b963f71d5
--- /dev/null
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactIcuserCategoryAnalysisDailyDao.java
@@ -0,0 +1,20 @@
+package com.epmet.dao.stats;
+
+import com.epmet.commons.mybatis.dao.BaseDao;
+import com.epmet.entity.stats.FactIcuserCategoryAnalysisDailyEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 人员类别分析
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2022-01-17
+ */
+@Mapper
+public interface FactIcuserCategoryAnalysisDailyDao extends BaseDao {
+
+ int limitDelete(@Param("customerId")String customerId,
+ @Param("dateId")String dateId,
+ @Param("orgType")String orgType);
+}
\ No newline at end of file
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java
index 547cc164b7..a6ecca8319 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java
@@ -269,5 +269,14 @@ public interface UserDao {
List filterUserIds(@Param("userIds") List userIds, @Param("roleKey") String roleKey);
List selectRoutineWorkListByDateId(@Param("customerId") String customerId, @Param("dateId") String dateId);
+
+ List selectCountForGrid(@Param("customerId") String customerId,
+ @Param("columnName") String columnName);
+
+ OrgIcUserTotalDTO selectCountForAgency(@Param("customerId") String customerId,
+ @Param("columnName") String columnName,
+ @Param("agencyId") String agencyId);
+
+ List selectGridIcUserCategoryTotal(@Param("customerId")String customerId, @Param("dateId")String dateId);
}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/FactIcuserCategoryAnalysisDailyEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/FactIcuserCategoryAnalysisDailyEntity.java
new file mode 100644
index 0000000000..d1db22e1e9
--- /dev/null
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/FactIcuserCategoryAnalysisDailyEntity.java
@@ -0,0 +1,71 @@
+package com.epmet.entity.stats;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 人员类别分析
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2022-01-17
+ */
+@Data
+@EqualsAndHashCode(callSuper=false)
+@TableName("fact_icuser_category_analysis_daily")
+public class FactIcuserCategoryAnalysisDailyEntity extends BaseEpmetEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 客户id
+ */
+ private String customerId;
+
+ /**
+ * 预警配置ID
+ */
+ private String configId;
+
+ /**
+ * 当前数据是截止到XXX的:yyyyMMdd
+ */
+ private String dateId;
+
+ /**
+ * 网格id或者组织id
+ */
+ private String orgId;
+
+ /**
+ * grid或者agency
+ */
+ private String orgType;
+
+ /**
+ * orgid的上级
+ */
+ private String pid;
+
+ /**
+ * orgid的所有上级
+ */
+ private String pids;
+
+ /**
+ * 当前类别总人数
+ */
+ private Integer total;
+
+ /**
+ * 较上月迁出
+ */
+ private Integer qcIncr;
+
+ /**
+ * 较上月迁入
+ */
+ private Integer qrIncr;
+
+}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/customize/IcResiCategoryStatsConfigService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/customize/IcResiCategoryStatsConfigService.java
new file mode 100644
index 0000000000..dfbaa5b85a
--- /dev/null
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/customize/IcResiCategoryStatsConfigService.java
@@ -0,0 +1,22 @@
+package com.epmet.service.customize;
+
+
+import com.epmet.dto.customize.IcResiCategoryConfigDTO;
+
+import java.util.List;
+
+/**
+ * 居民类别配置表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2021-11-04
+ */
+public interface IcResiCategoryStatsConfigService {
+
+ /**
+ * 返回用于数据分析的列名+居民类别配置表的id
+ * @param customerId
+ * @return
+ */
+ List queryDataColumn(String customerId);
+}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/customize/impl/IcResiCategoryStatsConfigServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/customize/impl/IcResiCategoryStatsConfigServiceImpl.java
new file mode 100644
index 0000000000..2aba7c4480
--- /dev/null
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/customize/impl/IcResiCategoryStatsConfigServiceImpl.java
@@ -0,0 +1,40 @@
+package com.epmet.service.customize.impl;
+
+import com.epmet.commons.dynamic.datasource.annotation.DataSource;
+import com.epmet.constant.DataSourceConstant;
+import com.epmet.dao.customize.IcResiCategoryStatsConfigDao;
+import com.epmet.dto.customize.IcResiCategoryConfigDTO;
+import com.epmet.service.customize.IcResiCategoryStatsConfigService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+
+/**
+ * 居民类别配置表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2021-11-04
+ */
+@Slf4j
+@DataSource(DataSourceConstant.OPER_CUSTOMIZE)
+@Service
+public class IcResiCategoryStatsConfigServiceImpl implements IcResiCategoryStatsConfigService{
+
+ @Autowired
+ private IcResiCategoryStatsConfigDao baseDao;
+
+
+ /**
+ * 返回用于数据分析的列名+居民类别配置表的id
+ *
+ * @param customerId
+ * @return
+ */
+ @Override
+ public List queryDataColumn(String customerId) {
+ return baseDao.queryDataColumn(customerId);
+ }
+}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java
index e7e08d78b2..5ea9362398 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java
@@ -19,6 +19,7 @@ package com.epmet.service.evaluationindex.screen;
import com.epmet.commons.mybatis.service.BaseService;
+import com.epmet.dto.CustomerGridDTO;
import com.epmet.dto.extract.form.*;
import com.epmet.dto.extract.result.GridInfoResultDTO;
import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO;
@@ -136,4 +137,6 @@ public interface ScreenCustomerGridService extends BaseService getByCustomerId(String customerId);
}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java
index edf9ef160f..fe3f1a863e 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java
@@ -29,6 +29,7 @@ import com.epmet.constant.DataSourceConstant;
import com.epmet.constant.OrgSourceTypeConstant;
import com.epmet.dao.evaluationindex.screen.DimLastSyncRecordDao;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerGridDao;
+import com.epmet.dto.CustomerGridDTO;
import com.epmet.dto.extract.form.*;
import com.epmet.dto.extract.result.GridInfoResultDTO;
import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO;
@@ -290,4 +291,12 @@ public class ScreenCustomerGridServiceImpl extends BaseServiceImpl getByCustomerId(String customerId) {
+ LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
+ wrapper.eq(ScreenCustomerGridEntity::getCustomerId, customerId);
+ List list = baseDao.selectList(wrapper);
+ return ConvertUtils.sourceToTarget(list,CustomerGridDTO.class);
+ }
}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactIcuserCategoryAnalysisDailyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactIcuserCategoryAnalysisDailyService.java
new file mode 100644
index 0000000000..afa940d37b
--- /dev/null
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactIcuserCategoryAnalysisDailyService.java
@@ -0,0 +1,20 @@
+package com.epmet.service.stats;
+
+import com.epmet.commons.mybatis.service.BaseService;
+import com.epmet.entity.stats.FactIcuserCategoryAnalysisDailyEntity;
+
+/**
+ * 人员类别分析
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2022-01-17
+ */
+public interface FactIcuserCategoryAnalysisDailyService extends BaseService {
+ /**
+ * 数字社区-基础信息-人员类别分析-每个类别的人员总数、较上月迁入迁出人数
+ * 网格
+ * @param customerId
+ * @param dateId
+ */
+ void statUserCategoryGridDaily(String customerId, String dateId);
+}
\ No newline at end of file
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactIcuserCategoryAnalysisDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactIcuserCategoryAnalysisDailyServiceImpl.java
new file mode 100644
index 0000000000..9384c21423
--- /dev/null
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactIcuserCategoryAnalysisDailyServiceImpl.java
@@ -0,0 +1,153 @@
+package com.epmet.service.stats.impl;
+
+import com.epmet.commons.dynamic.datasource.annotation.DataSource;
+import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
+import com.epmet.commons.tools.constant.NumConstant;
+import com.epmet.commons.tools.enums.OrgTypeEnum;
+import com.epmet.constant.DataSourceConstant;
+import com.epmet.dao.stats.FactIcuserCategoryAnalysisDailyDao;
+import com.epmet.dto.CustomerGridDTO;
+import com.epmet.dto.customize.IcResiCategoryConfigDTO;
+import com.epmet.dto.user.result.OrgIcUserTotalDTO;
+import com.epmet.entity.stats.FactIcuserCategoryAnalysisDailyEntity;
+import com.epmet.service.customize.IcResiCategoryStatsConfigService;
+import com.epmet.service.evaluationindex.screen.ScreenCustomerAgencyService;
+import com.epmet.service.evaluationindex.screen.ScreenCustomerGridService;
+import com.epmet.service.stats.FactIcuserCategoryAnalysisDailyService;
+import com.epmet.service.user.UserService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * 人员类别分析
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2022-01-17
+ */
+@Service
+@Slf4j
+@DataSource(DataSourceConstant.STATS)
+public class FactIcuserCategoryAnalysisDailyServiceImpl extends BaseServiceImpl implements FactIcuserCategoryAnalysisDailyService {
+
+ @Autowired
+ private IcResiCategoryStatsConfigService icResiCategoryStatsConfigService;
+ @Autowired
+ private ScreenCustomerAgencyService agencyService;
+ @Autowired
+ private ScreenCustomerGridService gridService;
+ @Autowired
+ private UserService userService;
+ /**
+ * 数字社区-基础信息-人员类别分析-每个类别的人员总数、较上月迁入迁出人数
+ *
+ * @param customerId
+ * @param dateId
+ */
+ @Override
+ public void statUserCategoryGridDaily(String customerId, String dateId) {
+ //查询出所有用语数据分析的类别column_name,没有则不计算
+ List columnList=icResiCategoryStatsConfigService.queryDataColumn(customerId);
+ if(CollectionUtils.isEmpty(columnList)){
+ return;
+ }
+ // //所有网格和组织查询出来
+ // List agencyDTOList=agencyService.getByCustomerId(customerId);
+ List gridDTOList=gridService.getByCustomerId(customerId);
+ //网格维度、组织维度初始好数据
+ List initList=constructInitValue(customerId,dateId,gridDTOList,columnList);
+ if(CollectionUtils.isEmpty(initList)){
+ return;
+ }
+ // 批量插入数据
+
+
+ //删除旧数据
+ clearOldDatas(customerId,dateId,OrgTypeEnum.GRID.getCode());
+ }
+
+ private void clearOldDatas(String customerId, String dateId,String orgType) {
+ int deleteNum;
+ do {
+ //每次删除1000条
+ deleteNum = baseDao.limitDelete(customerId,dateId,orgType);
+ } while (deleteNum != NumConstant.ZERO);
+ }
+
+ /**
+ *
+ * @param customerId
+ * @param dateId yyyyMMdd
+ * @param gridDTOList 当前客户下所有的网格
+ * @param columnList 所有需要分析的类别对应的ic_resi_user的列名,目前只有18类
+ * @return
+ */
+ private List constructInitValue(String customerId,String dateId, List gridDTOList,List columnList) {
+ List list=new ArrayList<>();
+ if(CollectionUtils.isEmpty(gridDTOList)){
+ //没有配置的类别,退出吧
+ return list;
+ }
+
+ //1、total
+ // 查询明细ic_user_change_detailed变更明细表,各个网格的各个分类的总人数
+ Map> totalMapList=userService.calGridIcUserTotal(customerId,dateId);
+
+ String monthId=dateId.substring(NumConstant.ZERO,NumConstant.SIX);
+ String startDate=monthId.concat("01");
+ String endDate=dateId;
+
+ //2、迁入+30:eg:dateId:20211226, [20211201,20211226],类别sum值=1的
+ Map> qrList=userService.calGridIcUserQr(customerId,dateId);
+
+ //3、迁出 -10 :eg:dateId:20211226, [20211201,20211226],类别sum值 !=1的
+ Map> qrList=userService.calGridIcUserQr(customerId,dateId);
+
+ for(IcResiCategoryConfigDTO config:columnList){
+ gridDTOList.forEach(grid->{
+ FactIcuserCategoryAnalysisDailyEntity gridData=new FactIcuserCategoryAnalysisDailyEntity();
+ gridData.setCustomerId(customerId);
+ gridData.setConfigId(config.getConfigId());
+ gridData.setDateId(dateId);
+ gridData.setOrgId(grid.getId());
+ gridData.setOrgType(OrgTypeEnum.GRID.getCode());
+ gridData.setPid(StringUtils.isNotBlank(grid.getPid())?grid.getPid(): NumConstant.ZERO_STR);
+ gridData.setPids(grid.getPids());
+
+ boolean zeroFlag=true;
+ if(MapUtils.isNotEmpty(totalMapList)&&totalMapList.containsKey(grid.getId())){
+ //当前网格下,有的类别
+ List crrentGrid=totalMapList.get(grid.getId());
+ if(CollectionUtils.isNotEmpty(crrentGrid)){
+ //各个类别对应的数
+ Map categoryTotalMap=crrentGrid.stream().collect(Collectors.toMap(OrgIcUserTotalDTO::getColumnName, OrgIcUserTotalDTO::getTotal, (key1, key2) -> key2));
+ if(MapUtils.isNotEmpty(categoryTotalMap)&&categoryTotalMap.containsKey(config.getColumnName())){
+ zeroFlag=false;
+ gridData.setTotal(categoryTotalMap.get(config.getColumnName()));
+ }
+ }
+ }
+ if(zeroFlag){
+ gridData.setTotal(NumConstant.ZERO);
+ }
+ gridData.setQcIncr(NumConstant.ZERO);
+ gridData.setQrIncr(NumConstant.ZERO);
+ list.add(gridData);
+ });
+ }
+ return list;
+ }
+
+ public static void main(String[] args) {
+ String dateId="20211225";
+ System.out.println(dateId.substring(0,6));
+ }
+}
\ No newline at end of file
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java
index 29e5e6d149..522e6eeaa5 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java
@@ -157,4 +157,23 @@ public interface UserService {
* @return
*/
List selectRoutineWorkListByDateId(String customerId, String dateId);
+
+ Map selectCountForGrid(String customerId, String columnName);
+
+ /**
+ *
+ * @param customerId
+ * @param columnName
+ * @param agencyIds
+ * @return
+ */
+ Map selectCountForGrid(String customerId, String columnName, List agencyIds);
+
+ /**
+ *
+ * @param customerId
+ * @param dateId 截止到这一天的,各个网格下,每个分类的总人数
+ * @return
+ */
+ Map> calGridIcUserTotal(String customerId, String dateId);
}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java
index f6c78dbfb0..007cad7e2b 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java
@@ -1126,4 +1126,79 @@ public class UserServiceImpl implements UserService {
public List selectRoutineWorkListByDateId(String customerId, String dateId) {
return userDao.selectRoutineWorkListByDateId(customerId, dateId);
}
+
+ /**
+ *
+ * @param customerId
+ * @param columnName
+ * @return 截止到目前,每个网格内,某个分类的总人数
+ */
+ @Override
+ public Map selectCountForGrid(String customerId, String columnName) {
+ Map map = new HashMap<>();
+ List list = userDao.selectCountForGrid(customerId, columnName);
+ if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(list)) {
+ map = list.stream().collect(Collectors.toMap(OrgIcUserTotalDTO::getOrgId, OrgIcUserTotalDTO::getTotal));
+ }
+ return map;
+ }
+
+ /**
+ * @param customerId
+ * @param columnName
+ * @param agencyIds
+ * @return 截止到目前,各个组织内,某个分类的总人数
+ */
+ @Override
+ public Map selectCountForGrid(String customerId, String columnName, List agencyIds) {
+ Map map = new HashMap<>();
+ if (CollectionUtils.isEmpty(agencyIds)) {
+ return map;
+ }
+ List list = new ArrayList<>();
+ for (String agencyId:agencyIds) {
+ OrgIcUserTotalDTO dto=new OrgIcUserTotalDTO();
+ dto.setOrgId(agencyId);
+ OrgIcUserTotalDTO totalDto=userDao.selectCountForAgency(customerId,columnName,agencyId);
+ dto.setTotal(null!=totalDto?totalDto.getTotal():NumConstant.ZERO);
+ list.add(dto);
+ }
+ if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(list)) {
+ map = list.stream().collect(Collectors.toMap(OrgIcUserTotalDTO::getOrgId, OrgIcUserTotalDTO::getTotal));
+ }
+ return map;
+ }
+
+ /**
+ * @param customerId
+ * @param dateId 截止到这一天的,各个网格下,每个分类的总人数
+ * @return
+ */
+ @Override
+ public Map> calGridIcUserTotal(String customerId, String dateId) {
+ Map> resultMap=new HashMap<>();
+ List list=userDao.selectGridIcUserCategoryTotal(customerId,dateId);
+ if(CollectionUtils.isEmpty(list)){
+ return resultMap;
+ }
+ // list 数据
+ // gridId columnName total
+ // 1001 IS_DBH 1
+ // 1001 IS_PARTY 1
+ // 1002 IS_DBH 1
+ // 1002 IS_ENSURE_HOUSE 1
+ // 1003 IS_VETERANS 1
+ // 1004 IS_PARTY 1
+ for(OrgIcUserTotalDTO dto:list){
+ if(resultMap.containsKey(dto.getOrgId())){
+ resultMap.get(dto.getOrgId()).add(dto);
+ continue;
+ }
+ List newList=new ArrayList<>();
+ newList.add(dto);
+ resultMap.put(dto.getOrgId(),newList);
+ }
+ return resultMap;
+ }
+
}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml
index 1f2089ea27..c70278a240 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml
@@ -188,6 +188,11 @@ dynamic:
url: @datasource.druid.epmetPoint.url@
username: @datasource.druid.epmetPoint.username@
password: @datasource.druid.epmetPoint.password@
+ operCustomize:
+ driver-class-name: com.mysql.cj.jdbc.Driver
+ url: @datasource.druid.operCustomize.url@
+ username: @datasource.druid.operCustomize.username@
+ password: @datasource.druid.operCustomize.password@
thread:
# 线程池配置
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/customize/IcResiCategoryStatsConfigDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/customize/IcResiCategoryStatsConfigDao.xml
new file mode 100644
index 0000000000..566e6f2c9d
--- /dev/null
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/customize/IcResiCategoryStatsConfigDao.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactIcuserCategoryAnalysisDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactIcuserCategoryAnalysisDailyDao.xml
new file mode 100644
index 0000000000..01f0963249
--- /dev/null
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactIcuserCategoryAnalysisDailyDao.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+ delete from fact_icuser_category_analysis_daily
+ where CUSTOMER_ID = #{customerId}
+ and date_id=#{dateId}
+ and org_type=#{orgType}
+ limit 1000
+
+
\ No newline at end of file
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml
index 6e8e25fefa..7bec8ecc7b 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml
@@ -1074,4 +1074,55 @@
+
+
+
+
+
From fb2bdcb0e1d9af838f5e32f3768a54fe4d6739ee Mon Sep 17 00:00:00 2001
From: sunyuchao
Date: Tue, 18 Jan 2022 15:57:58 +0800
Subject: [PATCH 2/8] =?UTF-8?q?=E4=BA=BA=E5=91=98=E7=8A=B6=E6=80=81?=
=?UTF-8?q?=E3=80=81=E4=BA=BA=E5=91=98=E8=B0=83=E5=8A=A8=E3=80=81=E5=8F=98?=
=?UTF-8?q?=E6=9B=B4=E8=AE=B0=E5=BD=95=E3=80=81=E5=8F=98=E6=9B=B4=E6=98=8E?=
=?UTF-8?q?=E7=BB=86sql=E8=84=9A=E6=9C=AC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../V0.0.23__ic_user_transfer_and_change.sql | 96 +++++++++++++++++++
1 file changed, 96 insertions(+)
create mode 100644 epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.23__ic_user_transfer_and_change.sql
diff --git a/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.23__ic_user_transfer_and_change.sql b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.23__ic_user_transfer_and_change.sql
new file mode 100644
index 0000000000..0ec0f9e094
--- /dev/null
+++ b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.23__ic_user_transfer_and_change.sql
@@ -0,0 +1,96 @@
+
+ALTER TABLE `ic_resi_user`
+ADD COLUMN `STATUS` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '用户状态【0:正常 1:转出】' AFTER `JTXX_REMAKES`;
+
+ALTER TABLE `ic_resi_user`
+DROP INDEX `customer_idcard_unique`;
+
+CREATE TABLE `ic_user_transfer_record` (
+ `ID` varchar(64) NOT NULL COMMENT '唯一标识',
+ `IC_USER_ID` varchar(64) NOT NULL COMMENT '被调动人Id【ic_resi_user表id】',
+ `OPERATOR_ID` varchar(64) NOT NULL COMMENT '调动(工作)人员Id【customer_staff表userId】',
+ `IC_USER_NAME` varchar(64) NOT NULL COMMENT '被调动人名称【ic_resi_user表name】',
+ `OPERATOR_NAME` varchar(64) NOT NULL COMMENT '调动(工作)人员名称【customer_staff表real_name】',
+ `OLD_CUSTOMER_ID` varchar(64) NOT NULL COMMENT '调动前客户Id',
+ `NEW_CUSTOMER_ID` varchar(64) DEFAULT NULL COMMENT '调动后客户Id',
+ `OLD_AGENCY_ID` varchar(64) DEFAULT NULL COMMENT '调动前组织Id',
+ `NEW_AGENCY_ID` varchar(64) DEFAULT NULL COMMENT '调动后组织Id',
+ `OLD_AGENCY_NAME` varchar(64) DEFAULT NULL COMMENT '调动前组织名称',
+ `NEW_AGENCY_NAME` varchar(255) DEFAULT NULL COMMENT '调动后组织名称',
+ `OLD_GRID_ID` varchar(64) DEFAULT NULL COMMENT '调动前网格Id',
+ `NEW_GRID_ID` varchar(64) DEFAULT NULL COMMENT '调动后网格Id',
+ `OLD_GRID_NAME` varchar(255) DEFAULT NULL COMMENT '调动前网格名称',
+ `NEW_GRID_NAME` varchar(255) DEFAULT NULL COMMENT '调动后网格名称',
+ `OLD_NEIGHBOR_HOOD_ID` varchar(64) DEFAULT NULL COMMENT '调动前小区Id',
+ `NEW_NEIGHBOR_HOOD_ID` varchar(64) DEFAULT NULL COMMENT '调动后小区Id',
+ `OLD_NEIGHBOR_HOOD_NAME` varchar(255) DEFAULT NULL COMMENT '调动前小区名称',
+ `NEW_NEIGHBOR_HOOD_NAME` varchar(255) DEFAULT NULL COMMENT '调动后小区名称',
+ `OLD_BUILDING_ID` varchar(64) DEFAULT NULL COMMENT '调动前楼栋Id',
+ `NEW_BUILDING_ID` varchar(64) DEFAULT NULL COMMENT '调动后楼栋Id',
+ `OLD_BUILDING_NAME` varchar(255) DEFAULT NULL COMMENT '调动前楼栋名称',
+ `NEW_BUILDING_NAME` varchar(255) DEFAULT NULL COMMENT '调动后楼栋名称',
+ `OLD_BUILDING_UNIT_ID` varchar(64) DEFAULT NULL COMMENT '调动前单元Id',
+ `NEW_BUILDING_UNIT_ID` varchar(64) DEFAULT NULL COMMENT '调动后单元Id',
+ `OLD_BUILDING_UNIT_NAME` varchar(255) DEFAULT NULL COMMENT '调动前单元名称',
+ `NEW_BUILDING_UNIT_NAME` varchar(255) DEFAULT NULL COMMENT '调动后单元名称',
+ `OLD_HOUSE_ID` varchar(64) DEFAULT NULL COMMENT '调动前房屋Id',
+ `NEW_HOUSE_ID` varchar(64) DEFAULT NULL COMMENT '调动后房屋Id',
+ `OLD_HOUSE_NAME` varchar(255) DEFAULT NULL COMMENT '调动前房屋名称',
+ `NEW_HOUSE_NAME` varchar(255) DEFAULT NULL COMMENT '调动后房屋名称',
+ `TRANSFER_TIME` datetime NOT NULL COMMENT '调动时间',
+ `REMARK` varchar(512) DEFAULT NULL COMMENT '备注说明',
+ `DEL_FLAG` varchar(1) NOT NULL COMMENT '删除标识',
+ `REVISION` int(10) NOT NULL COMMENT '乐观锁',
+ `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人',
+ `CREATED_TIME` datetime NOT NULL COMMENT '创建时间',
+ `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人',
+ `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间',
+ PRIMARY KEY (`ID`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='居民调动记录表';
+
+CREATE TABLE `ic_user_change_record` (
+ `ID` varchar(64) NOT NULL COMMENT '唯一标识',
+ `IC_USER_TRANSFER_RECORD_ID` varchar(64) DEFAULT NULL COMMENT '调动表Id【只有调动记录此列才有值】',
+ `CUSTOMER_ID` varchar(64) DEFAULT NULL COMMENT '当前所属客户Id[迁出客户的此列没值]',
+ `OPERATOR_ID` varchar(64) NOT NULL COMMENT '操作人Id【customer_staff表userId】',
+ `IC_USER_ID` varchar(64) NOT NULL COMMENT '被操作人Id【ic_resi_user表id】',
+ `OPERATOR_NAME` varchar(64) NOT NULL COMMENT '操作人名称【customer_staff表real_name】',
+ `IC_USER_NAME` varchar(64) NOT NULL COMMENT '被操作人名称【ic_resi_user表name】',
+ `TYPE` varchar(64) NOT NULL COMMENT '操作类型【add:新增 category:类别 transfer:调动】',
+ `TYPE_NAME` varchar(64) NOT NULL COMMENT '操作类型名称【add:新增 category:类别 transfer:调动】',
+ `BEFORE_CHANGE_NAME` varchar(512) DEFAULT NULL COMMENT '变更前文字描述',
+ `AFTER_CHANGE_NAME` varchar(512) DEFAULT NULL COMMENT '变更后文字描述',
+ `CHANGE_TIME` datetime NOT NULL COMMENT '调整时间',
+ `REMARK` varchar(512) DEFAULT NULL COMMENT '备注说明',
+ `DEL_FLAG` varchar(1) NOT NULL COMMENT '删除标识',
+ `REVISION` int(10) NOT NULL COMMENT '乐观锁',
+ `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人',
+ `CREATED_TIME` datetime NOT NULL COMMENT '创建时间',
+ `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人',
+ `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间',
+ PRIMARY KEY (`ID`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='居民变更记录表';
+
+CREATE TABLE `ic_user_change_detailed` (
+ `ID` varchar(64) NOT NULL COMMENT '唯一标识',
+ `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户Id',
+ `IC_USER_CHANGE_RECORD_ID` varchar(64) NOT NULL COMMENT '变更记录表主键【ic_user_change_record.id】',
+ `AGENCY_ID` varchar(64) NOT NULL COMMENT '组织Id',
+ `GRID_ID` varchar(64) NOT NULL COMMENT '网格Id',
+ `NEIGHBOR_HOOD_ID` varchar(64) NOT NULL COMMENT '小区Id',
+ `BUILDING_ID` varchar(64) NOT NULL COMMENT '楼栋Id',
+ `BUILDING_UNIT_ID` varchar(64) NOT NULL COMMENT '单元Id',
+ `HOUSE_ID` varchar(64) NOT NULL COMMENT '房屋Id',
+ `IC_USER_ID` varchar(64) NOT NULL COMMENT '变更人Id',
+ `TYPE` varchar(255) NOT NULL COMMENT '操作类型【add:新增 category:类别 in:迁入 out:迁出】',
+ `TYPE_NAME` varchar(255) NOT NULL COMMENT '操作类型名称【add:新增 category:类别 in:迁入 out:迁出】',
+ `FIELD_NAME` varchar(64) NOT NULL COMMENT '字段名【18类对应的ic_resi_user表字段名】',
+ `VALUE` int(3) NOT NULL COMMENT '当前类别的值',
+ `DEL_FLAG` varchar(1) NOT NULL COMMENT '删除标识',
+ `REVISION` int(10) NOT NULL COMMENT '乐观锁',
+ `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人',
+ `CREATED_TIME` datetime NOT NULL COMMENT '创建时间',
+ `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人',
+ `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间',
+ PRIMARY KEY (`ID`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='变更明细表\r\n[一条变更记录对应多条人员类别数据]';
\ No newline at end of file
From cbe0ff7d87db9ef459d1de66476e99f015db87b3 Mon Sep 17 00:00:00 2001
From: zxc <1272811460@qq.com>
Date: Tue, 18 Jan 2022 16:09:31 +0800
Subject: [PATCH 3/8] =?UTF-8?q?=E6=88=BF=E5=B1=8B=E7=BC=93=E5=AD=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../epmet/commons/tools/redis/RedisKeys.java | 4 +++
.../com/epmet/dto/result/HouseInfoDTO.java | 5 +++
.../main/java/com/epmet/dao/IcHouseDao.java | 2 ++
.../java/com/epmet/redis/IcHouseRedis.java | 35 +++++++++++++++++++
.../epmet/service/impl/HouseServiceImpl.java | 10 +++++-
.../src/main/resources/mapper/IcHouseDao.xml | 24 +++++++++++++
6 files changed, 79 insertions(+), 1 deletion(-)
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 f3c669d7cd..1390ed7a3a 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
@@ -636,4 +636,8 @@ public class RedisKeys {
public static String getOrgTreeCacheKey(String agencyId) {
return rootPrefix.concat("org:temp:orgtree").concat(agencyId);
}
+
+ public static String getHouseInfoCacheKey(String houseId){
+ return rootPrefix.concat("house:").concat(houseId);
+ }
}
diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseInfoDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseInfoDTO.java
index 853558739b..312befe6ca 100644
--- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseInfoDTO.java
+++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseInfoDTO.java
@@ -71,4 +71,9 @@ public class HouseInfoDTO implements Serializable {
* 楼的纬度
*/
private String buildingLatitude;
+
+ /**
+ * 小区名+楼栋名+单元名+房屋名
+ */
+ private String allName;
}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java
index 93c5af18e5..a394aaaef5 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java
@@ -59,6 +59,8 @@ public interface IcHouseDao extends BaseDao {
List queryHouseInfo(@Param("houseIdList") Set houseIdList);
+ HouseInfoDTO queryHouseInfoByHouseId(@Param("houseId") String houseId);
+
/**
* @Description 查询房屋信息
* @param idCard
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java
index 9159c6eb88..f5b7b8639b 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java
@@ -17,9 +17,17 @@
package com.epmet.redis;
+import cn.hutool.core.bean.BeanUtil;
+import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
+import com.epmet.commons.tools.utils.ConvertUtils;
+import com.epmet.dao.IcHouseDao;
+import com.epmet.dto.result.HouseInfoDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+import java.util.Map;
/**
* 房屋信息
@@ -32,6 +40,9 @@ public class IcHouseRedis {
@Autowired
private RedisUtils redisUtils;
+ @Autowired
+ private IcHouseDao icHouseDao;
+
public void delete(Object[] ids) {
}
@@ -44,4 +55,28 @@ public class IcHouseRedis {
return null;
}
+ /**
+ * @Description 往缓存放房屋信息
+ * @param houseId
+ * @param map
+ * @author zxc
+ * @date 2022/1/18 3:55 下午
+ */
+ public void setHouseInfo(String houseId, Map map){
+ String key = RedisKeys.getHouseInfoCacheKey(houseId);
+ redisUtils.hMSet(key, map);
+ }
+
+ public HouseInfoDTO getHouseInfo(String houseId){
+ String key = RedisKeys.getHouseInfoCacheKey(houseId);
+ Map map = redisUtils.hGetAll(key);
+ if (!CollectionUtils.isEmpty(map)){
+ return ConvertUtils.mapToEntity(map,HouseInfoDTO.class);
+ }
+ HouseInfoDTO houseInfo = icHouseDao.queryHouseInfoByHouseId(houseId);
+ Map result = BeanUtil.beanToMap(houseInfo, false, true);
+ setHouseInfo(houseId,result);
+ return houseInfo;
+ }
+
}
\ No newline at end of file
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java
index 90a46acfc0..551cd9a82f 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java
@@ -1,6 +1,7 @@
package com.epmet.service.impl;
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
+import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.epmet.commons.tools.constant.NumConstant;
@@ -31,6 +32,7 @@ import com.epmet.enums.HouseRentFlagEnums;
import com.epmet.enums.HouseTypeEnums;
import com.epmet.excel.IcHouseExcel;
import com.epmet.feign.GovOrgOpenFeignClient;
+import com.epmet.redis.IcHouseRedis;
import com.epmet.service.HouseService;
import com.epmet.service.IcBuildingService;
import com.epmet.service.IcBuildingUnitService;
@@ -69,6 +71,8 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver {
private IcHouseDao icHouseDao;
@Autowired
private GovOrgOpenFeignClient govOrgOpenFeignClient;
+ @Autowired
+ private IcHouseRedis icHouseRedis;
@Override
@Transactional(rollbackFor = Exception.class)
@@ -313,6 +317,10 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver {
if(org.apache.commons.collections4.CollectionUtils.isEmpty(houseIdList)){
return new ArrayList<>();
}
- return icHouseDao.queryHouseInfo(houseIdList);
+ List result = new ArrayList<>();
+ houseIdList.forEach(h -> {
+ result.add(icHouseRedis.getHouseInfo(h));
+ });
+ return result;
}
}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml
index b5a8b72a25..900d34ba66 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml
+++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml
@@ -300,4 +300,28 @@
and ih.id !=#{houseId}
+
From bcd20d014802febc6a342866c051b01dd3b653f2 Mon Sep 17 00:00:00 2001
From: jianjun
Date: Tue, 18 Jan 2022 16:18:16 +0800
Subject: [PATCH 4/8] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=BD=91=E6=A0=BC?=
=?UTF-8?q?=E5=86=85=E5=B7=A5=E4=BD=9C=E4=BA=BA=E5=91=98=20=E5=8E=BB?=
=?UTF-8?q?=E6=8E=89=E5=AE=A2=E6=88=B7id?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/main/java/com/epmet/controller/StaffRoleController.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java
index ee25f967f5..0cf0bc1760 100644
--- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java
+++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java
@@ -208,7 +208,7 @@ public class StaffRoleController {
* @date 2022/1/17 2:26 下午
*/
@PostMapping("getGridStaffList")
- Result> getGridStaffList(@RequestHeader("customerId") String customerId, @RequestBody GridStaffFormDTO formDTO){
+ Result> getGridStaffList(@RequestHeader(value = "customerId",required = false) String customerId, @RequestBody GridStaffFormDTO formDTO){
//tokenDto.setCustomerId("45687aa479955f9d06204d415238f7cc");
if (StringUtils.isBlank(formDTO.getCustomerId())){
formDTO.setCustomerId(customerId);
From af777cb478b6f12ddbab43918d5c522a768597f3 Mon Sep 17 00:00:00 2001
From: yinzuomei <576302893@qq.com>
Date: Tue, 18 Jan 2022 16:19:20 +0800
Subject: [PATCH 5/8] =?UTF-8?q?=E7=BD=91=E6=A0=BC=E4=BA=BA=E5=91=98?=
=?UTF-8?q?=E7=B1=BB=E5=88=AB=E5=88=86=E6=9E=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../main/java/com/epmet/dao/user/UserDao.java | 5 +
...FactIcuserCategoryAnalysisDailyEntity.java | 5 +-
.../screen/ScreenCustomerGridService.java | 3 +-
.../impl/ScreenCustomerGridServiceImpl.java | 6 +-
...cuserCategoryAnalysisDailyServiceImpl.java | 145 ++++++++++++------
.../com/epmet/service/user/UserService.java | 10 ++
.../service/user/impl/UserServiceImpl.java | 26 ++++
.../main/resources/mapper/user/UserDao.xml | 35 ++++-
8 files changed, 176 insertions(+), 59 deletions(-)
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java
index a6ecca8319..58c9b870ff 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/UserDao.java
@@ -278,5 +278,10 @@ public interface UserDao {
@Param("agencyId") String agencyId);
List selectGridIcUserCategoryTotal(@Param("customerId")String customerId, @Param("dateId")String dateId);
+
+ List selectGridIcUserCategoryIncr(@Param("customerId")String customerId,
+ @Param("startDate")String startDate,
+ @Param("endDate")String endDate,
+ @Param("type")String type);
}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/FactIcuserCategoryAnalysisDailyEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/FactIcuserCategoryAnalysisDailyEntity.java
index d1db22e1e9..ff98e8bea5 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/FactIcuserCategoryAnalysisDailyEntity.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/stats/FactIcuserCategoryAnalysisDailyEntity.java
@@ -27,7 +27,10 @@ public class FactIcuserCategoryAnalysisDailyEntity extends BaseEpmetEntity {
* 预警配置ID
*/
private String configId;
-
+ /**
+ * 类别列名,对个数据太麻烦了,在这个表存一下
+ */
+ private String columnName;
/**
* 当前数据是截止到XXX的:yyyyMMdd
*/
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java
index 5ea9362398..053dee1079 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java
@@ -19,7 +19,6 @@ package com.epmet.service.evaluationindex.screen;
import com.epmet.commons.mybatis.service.BaseService;
-import com.epmet.dto.CustomerGridDTO;
import com.epmet.dto.extract.form.*;
import com.epmet.dto.extract.result.GridInfoResultDTO;
import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO;
@@ -138,5 +137,5 @@ public interface ScreenCustomerGridService extends BaseService getByCustomerId(String customerId);
+ List getByCustomerId(String customerId);
}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java
index fe3f1a863e..d184f762d1 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java
@@ -29,7 +29,6 @@ import com.epmet.constant.DataSourceConstant;
import com.epmet.constant.OrgSourceTypeConstant;
import com.epmet.dao.evaluationindex.screen.DimLastSyncRecordDao;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerGridDao;
-import com.epmet.dto.CustomerGridDTO;
import com.epmet.dto.extract.form.*;
import com.epmet.dto.extract.result.GridInfoResultDTO;
import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO;
@@ -293,10 +292,9 @@ public class ScreenCustomerGridServiceImpl extends BaseServiceImpl getByCustomerId(String customerId) {
+ public List getByCustomerId(String customerId) {
LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ScreenCustomerGridEntity::getCustomerId, customerId);
- List list = baseDao.selectList(wrapper);
- return ConvertUtils.sourceToTarget(list,CustomerGridDTO.class);
+ return baseDao.selectList(wrapper);
}
}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactIcuserCategoryAnalysisDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactIcuserCategoryAnalysisDailyServiceImpl.java
index 9384c21423..a3d0b5ab26 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactIcuserCategoryAnalysisDailyServiceImpl.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactIcuserCategoryAnalysisDailyServiceImpl.java
@@ -6,15 +6,16 @@ import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.enums.OrgTypeEnum;
import com.epmet.constant.DataSourceConstant;
import com.epmet.dao.stats.FactIcuserCategoryAnalysisDailyDao;
-import com.epmet.dto.CustomerGridDTO;
import com.epmet.dto.customize.IcResiCategoryConfigDTO;
import com.epmet.dto.user.result.OrgIcUserTotalDTO;
+import com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity;
import com.epmet.entity.stats.FactIcuserCategoryAnalysisDailyEntity;
import com.epmet.service.customize.IcResiCategoryStatsConfigService;
import com.epmet.service.evaluationindex.screen.ScreenCustomerAgencyService;
import com.epmet.service.evaluationindex.screen.ScreenCustomerGridService;
import com.epmet.service.stats.FactIcuserCategoryAnalysisDailyService;
import com.epmet.service.user.UserService;
+import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
@@ -45,7 +46,8 @@ public class FactIcuserCategoryAnalysisDailyServiceImpl extends BaseServiceImpl<
@Autowired
private ScreenCustomerGridService gridService;
@Autowired
- private UserService userService;
+ private UserService userService;
+
/**
* 数字社区-基础信息-人员类别分析-每个类别的人员总数、较上月迁入迁出人数
*
@@ -55,99 +57,142 @@ public class FactIcuserCategoryAnalysisDailyServiceImpl extends BaseServiceImpl<
@Override
public void statUserCategoryGridDaily(String customerId, String dateId) {
//查询出所有用语数据分析的类别column_name,没有则不计算
- List columnList=icResiCategoryStatsConfigService.queryDataColumn(customerId);
- if(CollectionUtils.isEmpty(columnList)){
+ List columnList = icResiCategoryStatsConfigService.queryDataColumn(customerId);
+ if (CollectionUtils.isEmpty(columnList)) {
+ return;
+ }
+ //所有网格查询出来
+ List gridDTOList = gridService.getByCustomerId(customerId);
+ if (CollectionUtils.isEmpty(gridDTOList)) {
return;
}
- // //所有网格和组织查询出来
- // List agencyDTOList=agencyService.getByCustomerId(customerId);
- List gridDTOList=gridService.getByCustomerId(customerId);
//网格维度、组织维度初始好数据
- List initList=constructInitValue(customerId,dateId,gridDTOList,columnList);
- if(CollectionUtils.isEmpty(initList)){
+ List initList = constructInitValue(customerId, dateId, gridDTOList, columnList);
+ if (CollectionUtils.isEmpty(initList)) {
return;
}
- // 批量插入数据
-
-
+ //当这3个数都为0的时候不插入数据库了
+ List insertList = initList.stream().filter(entity -> (null != entity.getTotal() && entity.getTotal() > 0)
+ || (null != entity.getQcIncr() && entity.getQcIncr() > 0)
+ || (null != entity.getQrIncr() && entity.getQrIncr() > 0)).collect(Collectors.toList());
//删除旧数据
- clearOldDatas(customerId,dateId,OrgTypeEnum.GRID.getCode());
+ clearOldDatas(customerId, dateId, OrgTypeEnum.GRID.getCode());
+ // 批量插入数据
+ Lists.partition(insertList, NumConstant.ONE_HUNDRED).forEach(list -> {
+ insertBatch(list);
+ });
}
- private void clearOldDatas(String customerId, String dateId,String orgType) {
+ /**
+ * 删除旧数据
+ *
+ * @param customerId
+ * @param dateId
+ * @param orgType grid、agency
+ */
+ private void clearOldDatas(String customerId, String dateId, String orgType) {
int deleteNum;
do {
//每次删除1000条
- deleteNum = baseDao.limitDelete(customerId,dateId,orgType);
+ deleteNum = baseDao.limitDelete(customerId, dateId, orgType);
} while (deleteNum != NumConstant.ZERO);
}
/**
- *
* @param customerId
- * @param dateId yyyyMMdd
+ * @param dateId yyyyMMdd
* @param gridDTOList 当前客户下所有的网格
- * @param columnList 所有需要分析的类别对应的ic_resi_user的列名,目前只有18类
+ * @param columnList 所有需要分析的类别对应的ic_resi_user的列名,目前只有18类
* @return
*/
- private List constructInitValue(String customerId,String dateId, List gridDTOList,List columnList) {
- List list=new ArrayList<>();
- if(CollectionUtils.isEmpty(gridDTOList)){
- //没有配置的类别,退出吧
- return list;
- }
+ private List constructInitValue(String customerId, String dateId, List gridDTOList, List columnList) {
+ List list = new ArrayList<>();
//1、total
// 查询明细ic_user_change_detailed变更明细表,各个网格的各个分类的总人数
- Map> totalMapList=userService.calGridIcUserTotal(customerId,dateId);
+ Map> totalMapList = userService.calGridIcUserTotal(customerId, dateId);
- String monthId=dateId.substring(NumConstant.ZERO,NumConstant.SIX);
- String startDate=monthId.concat("01");
- String endDate=dateId;
+ String monthId = dateId.substring(NumConstant.ZERO, NumConstant.SIX);
+ String startDate = monthId.concat("01");
+ String endDate = dateId;
//2、迁入+30:eg:dateId:20211226, [20211201,20211226],类别sum值=1的
- Map> qrList=userService.calGridIcUserQr(customerId,dateId);
+ Map> qrList = userService.calGridIcUserIncr(customerId, startDate, endDate, "qr");
//3、迁出 -10 :eg:dateId:20211226, [20211201,20211226],类别sum值 !=1的
- Map> qrList=userService.calGridIcUserQr(customerId,dateId);
+ Map> qcList = userService.calGridIcUserIncr(customerId, startDate, endDate, "qc");
- for(IcResiCategoryConfigDTO config:columnList){
- gridDTOList.forEach(grid->{
- FactIcuserCategoryAnalysisDailyEntity gridData=new FactIcuserCategoryAnalysisDailyEntity();
+ for (IcResiCategoryConfigDTO config : columnList) {
+ gridDTOList.forEach(grid -> {
+ FactIcuserCategoryAnalysisDailyEntity gridData = new FactIcuserCategoryAnalysisDailyEntity();
gridData.setCustomerId(customerId);
gridData.setConfigId(config.getConfigId());
+ gridData.setColumnName(config.getColumnName());
gridData.setDateId(dateId);
- gridData.setOrgId(grid.getId());
+ gridData.setOrgId(grid.getGridId());
gridData.setOrgType(OrgTypeEnum.GRID.getCode());
- gridData.setPid(StringUtils.isNotBlank(grid.getPid())?grid.getPid(): NumConstant.ZERO_STR);
- gridData.setPids(grid.getPids());
+ gridData.setPid(StringUtils.isNotBlank(grid.getParentAgencyId()) ? grid.getParentAgencyId() : NumConstant.ZERO_STR);
+ gridData.setPids(grid.getAllParentIds());
- boolean zeroFlag=true;
- if(MapUtils.isNotEmpty(totalMapList)&&totalMapList.containsKey(grid.getId())){
+ //截止到目前累计值
+ boolean totalZeroFlag = true;
+ if (MapUtils.isNotEmpty(totalMapList) && totalMapList.containsKey(grid.getGridId())) {
//当前网格下,有的类别
- List crrentGrid=totalMapList.get(grid.getId());
- if(CollectionUtils.isNotEmpty(crrentGrid)){
+ List crrentGrid = totalMapList.get(grid.getGridId());
+ if (CollectionUtils.isNotEmpty(crrentGrid)) {
//各个类别对应的数
- Map categoryTotalMap=crrentGrid.stream().collect(Collectors.toMap(OrgIcUserTotalDTO::getColumnName, OrgIcUserTotalDTO::getTotal, (key1, key2) -> key2));
- if(MapUtils.isNotEmpty(categoryTotalMap)&&categoryTotalMap.containsKey(config.getColumnName())){
- zeroFlag=false;
+ Map categoryTotalMap = crrentGrid.stream().collect(Collectors.toMap(OrgIcUserTotalDTO::getColumnName, OrgIcUserTotalDTO::getTotal, (key1, key2) -> key2));
+ if (MapUtils.isNotEmpty(categoryTotalMap) && categoryTotalMap.containsKey(config.getColumnName())) {
+ totalZeroFlag = false;
gridData.setTotal(categoryTotalMap.get(config.getColumnName()));
}
}
}
- if(zeroFlag){
+ if (totalZeroFlag) {
gridData.setTotal(NumConstant.ZERO);
}
- gridData.setQcIncr(NumConstant.ZERO);
- gridData.setQrIncr(NumConstant.ZERO);
+
+ //较上月迁入
+ boolean incrZeroFlag = true;
+ if (MapUtils.isNotEmpty(qrList) && qrList.containsKey(grid.getGridId())) {
+ //当前网格下,有的类别
+ List crrentGrid = qrList.get(grid.getGridId());
+ if (CollectionUtils.isNotEmpty(crrentGrid)) {
+ //各个类别对应的数
+ Map categoryTotalMap = crrentGrid.stream().collect(Collectors.toMap(OrgIcUserTotalDTO::getColumnName, OrgIcUserTotalDTO::getTotal, (key1, key2) -> key2));
+ if (MapUtils.isNotEmpty(categoryTotalMap) && categoryTotalMap.containsKey(config.getColumnName())) {
+ incrZeroFlag = false;
+ gridData.setQrIncr(categoryTotalMap.get(config.getColumnName()));
+ }
+ }
+ }
+ if (incrZeroFlag) {
+ gridData.setQrIncr(NumConstant.ZERO);
+ }
+
+ // 较上月迁出:
+ boolean qcZeroFlag = true;
+ if (MapUtils.isNotEmpty(qcList) && qcList.containsKey(grid.getGridId())) {
+ //当前网格下,有的类别
+ List crrentGridQc = qcList.get(grid.getGridId());
+ if (CollectionUtils.isNotEmpty(crrentGridQc)) {
+ //各个类别对应的数
+ Map categoryTotalMap = crrentGridQc.stream().collect(Collectors.toMap(OrgIcUserTotalDTO::getColumnName, OrgIcUserTotalDTO::getTotal, (key1, key2) -> key2));
+ if (MapUtils.isNotEmpty(categoryTotalMap) && categoryTotalMap.containsKey(config.getColumnName())) {
+ qcZeroFlag = false;
+ gridData.setQcIncr(categoryTotalMap.get(config.getColumnName()));
+ }
+ }
+ }
+ if (qcZeroFlag) {
+ gridData.setQcIncr(NumConstant.ZERO);
+ }
+
list.add(gridData);
});
}
return list;
}
- public static void main(String[] args) {
- String dateId="20211225";
- System.out.println(dateId.substring(0,6));
- }
+
}
\ No newline at end of file
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java
index 522e6eeaa5..69482594fb 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/UserService.java
@@ -176,4 +176,14 @@ public interface UserService {
* @return
*/
Map> calGridIcUserTotal(String customerId, String dateId);
+
+ /**
+ *
+ * @param customerId
+ * @param startDate :变动时间在此范围内的 yyyyMMdd
+ * @param endDate :yyyyMMdd
+ * @param type:qr:迁入;qc:迁出
+ * @return
+ */
+ Map> calGridIcUserIncr(String customerId, String startDate, String endDate, String type);
}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java
index 007cad7e2b..06c94a0392 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/UserServiceImpl.java
@@ -1201,4 +1201,30 @@ public class UserServiceImpl implements UserService {
return resultMap;
}
+ /**
+ * @param customerId
+ * @param startDate :变动时间在此范围内的 yyyyMMdd
+ * @param endDate :yyyyMMdd
+ * @param type :qr:迁入;qc:迁出
+ * @return
+ */
+ @Override
+ public Map> calGridIcUserIncr(String customerId, String startDate, String endDate, String type) {
+ Map> resultMap=new HashMap<>();
+ List list=userDao.selectGridIcUserCategoryIncr(customerId,startDate,endDate,type);
+ if(CollectionUtils.isEmpty(list)){
+ return resultMap;
+ }
+ for(OrgIcUserTotalDTO dto:list){
+ if(resultMap.containsKey(dto.getOrgId())){
+ resultMap.get(dto.getOrgId()).add(dto);
+ continue;
+ }
+ List newList=new ArrayList<>();
+ newList.add(dto);
+ resultMap.put(dto.getOrgId(),newList);
+ }
+ return resultMap;
+ }
+
}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml
index 7bec8ecc7b..11d9e4aaef 100644
--- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/UserDao.xml
@@ -1107,7 +1107,7 @@
select
temp.orgId,
temp.FIELD_NAME as columnName,
- count(distinct temp.IC_USER_ID) as total
+ count(temp.IC_USER_ID) as total
from (
SELECT
d.GRID_ID as orgId,
@@ -1120,9 +1120,40 @@
d.DEL_FLAG = '0'
AND d.CUSTOMER_ID = #{customerId}
AND DATE_FORMAT( d.CREATED_TIME, '%Y%m%d' ) <= #{dateId}
- group by d.orgId,d.IC_USER_ID,d.FIELD_NAME
+ group by d.GRID_ID,d.IC_USER_ID,d.FIELD_NAME
)temp
where temp.result=1
group by temp.orgId,temp.FIELD_NAME
+
+
+
From 3cbb59cd91320a640893b67939b9bd2365e23742 Mon Sep 17 00:00:00 2001
From: zxc <1272811460@qq.com>
Date: Tue, 18 Jan 2022 16:27:19 +0800
Subject: [PATCH 6/8] =?UTF-8?q?=E6=88=BF=E5=B1=8B=E7=BC=93=E5=AD=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../java/com/epmet/commons/tools/redis/RedisKeys.java | 4 ++--
.../epmet/service/impl/IcUserDemandRecServiceImpl.java | 4 ++--
.../main/java/com/epmet/dto/result/HouseInfoDTO.java | 2 ++
.../java/com/epmet/feign/GovOrgOpenFeignClient.java | 2 +-
.../feign/fallback/GovOrgOpenFeignClientFallback.java | 4 ++--
.../java/com/epmet/controller/HouseController.java | 4 ++--
.../src/main/java/com/epmet/redis/IcHouseRedis.java | 10 +++++-----
.../src/main/java/com/epmet/service/HouseService.java | 2 +-
.../java/com/epmet/service/impl/HouseServiceImpl.java | 4 ++--
.../src/main/resources/mapper/IcHouseDao.xml | 1 +
.../com/epmet/service/impl/IcResiUserServiceImpl.java | 4 ++--
11 files changed, 22 insertions(+), 19 deletions(-)
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 1390ed7a3a..dc3fb232bc 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
@@ -637,7 +637,7 @@ public class RedisKeys {
return rootPrefix.concat("org:temp:orgtree").concat(agencyId);
}
- public static String getHouseInfoCacheKey(String houseId){
- return rootPrefix.concat("house:").concat(houseId);
+ public static String getHouseInfoCacheKey(String houseId,String customerId){
+ return rootPrefix.concat("house:").concat(customerId).concat(":").concat(houseId);
}
}
diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java
index 591d08130c..ffb5bac51c 100644
--- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java
+++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java
@@ -154,7 +154,7 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl houseIds=new HashSet<>();
houseIds.add(updateEntity.getDemandUserHouseId());
- Result> houseInfoRes=govOrgOpenFeignClient.queryListHouseInfo(houseIds);
+ Result> houseInfoRes=govOrgOpenFeignClient.queryListHouseInfo(houseIds,dto.getCustomerId());
if(!houseInfoRes.success()||CollectionUtils.isEmpty(houseInfoRes.getData())){
throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "查询需求人房屋地址信息异常"+JSON.toJSONString(houseInfoRes));
}
@@ -223,7 +223,7 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl houseIds=new HashSet<>();
houseIds.add(insertEntity.getDemandUserHouseId());
- Result> houseInfoRes=govOrgOpenFeignClient.queryListHouseInfo(houseIds);
+ Result> houseInfoRes=govOrgOpenFeignClient.queryListHouseInfo(houseIds, fromDTO.getCustomerId());
if(!houseInfoRes.success()||CollectionUtils.isEmpty(houseInfoRes.getData())){
throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "查询需求人房屋地址信息异常"+JSON.toJSONString(houseInfoRes));
}
diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseInfoDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseInfoDTO.java
index 312befe6ca..3a3ca19096 100644
--- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseInfoDTO.java
+++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseInfoDTO.java
@@ -76,4 +76,6 @@ public class HouseInfoDTO implements Serializable {
* 小区名+楼栋名+单元名+房屋名
*/
private String allName;
+
+ private String customerId;
}
diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java
index 497cae9547..9293546170 100644
--- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java
+++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java
@@ -460,7 +460,7 @@ public interface GovOrgOpenFeignClient {
Result getGridBaseInfoByGridId(CustomerGridFormDTO customerGridFormDTO);
@PostMapping(value = "/gov/org/house/queryListHouseInfo",consumes = MediaType.APPLICATION_JSON_VALUE)
- Result> queryListHouseInfo(@RequestBody Set houseIds);
+ Result> queryListHouseInfo(@RequestBody Set houseIds, @RequestParam("customerId") String customerId);
diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java
index d4330f90d0..7b245ec735 100644
--- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java
+++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java
@@ -276,8 +276,8 @@ public class GovOrgOpenFeignClientFallback implements GovOrgOpenFeignClient {
}
@Override
- public Result> queryListHouseInfo(Set houseIds) {
- return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "queryListHouseInfo", houseIds);
+ public Result> queryListHouseInfo(Set houseIds ,String customerId) {
+ return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "queryListHouseInfo", houseIds, customerId);
}
@Override
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java
index f593287e77..cd54f15e64 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java
@@ -229,7 +229,7 @@ public class HouseController implements ResultDataResolver {
}
@PostMapping( "queryListHouseInfo")
- Result> queryListHouseInfo(@RequestBody Set houseIds){
- return new Result>().ok(houseService.queryListHouseInfo(houseIds));
+ Result> queryListHouseInfo(@RequestBody Set houseIds, @RequestParam("customerId") String customerId){
+ return new Result>().ok(houseService.queryListHouseInfo(houseIds,customerId));
}
}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java
index f5b7b8639b..4f3ece54a8 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java
@@ -62,20 +62,20 @@ public class IcHouseRedis {
* @author zxc
* @date 2022/1/18 3:55 下午
*/
- public void setHouseInfo(String houseId, Map map){
- String key = RedisKeys.getHouseInfoCacheKey(houseId);
+ public void setHouseInfo(String houseId, Map map,String customerId){
+ String key = RedisKeys.getHouseInfoCacheKey(houseId,customerId);
redisUtils.hMSet(key, map);
}
- public HouseInfoDTO getHouseInfo(String houseId){
- String key = RedisKeys.getHouseInfoCacheKey(houseId);
+ public HouseInfoDTO getHouseInfo(String houseId,String customerId){
+ String key = RedisKeys.getHouseInfoCacheKey(houseId,customerId);
Map map = redisUtils.hGetAll(key);
if (!CollectionUtils.isEmpty(map)){
return ConvertUtils.mapToEntity(map,HouseInfoDTO.class);
}
HouseInfoDTO houseInfo = icHouseDao.queryHouseInfoByHouseId(houseId);
Map result = BeanUtil.beanToMap(houseInfo, false, true);
- setHouseInfo(houseId,result);
+ setHouseInfo(houseId,result,houseInfo.getCustomerId());
return houseInfo;
}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java
index ac7f28dbbc..ad5d1d69cb 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java
@@ -61,5 +61,5 @@ public interface HouseService {
void exportBuildinginfo(ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception;
- List queryListHouseInfo(Set houseIds);
+ List queryListHouseInfo(Set houseIds, String customerId);
}
\ No newline at end of file
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java
index 551cd9a82f..d8ad9630ef 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java
@@ -313,13 +313,13 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver {
}*/
@Override
- public List queryListHouseInfo(Set houseIdList) {
+ public List queryListHouseInfo(Set houseIdList, String customerId) {
if(org.apache.commons.collections4.CollectionUtils.isEmpty(houseIdList)){
return new ArrayList<>();
}
List result = new ArrayList<>();
houseIdList.forEach(h -> {
- result.add(icHouseRedis.getHouseInfo(h));
+ result.add(icHouseRedis.getHouseInfo(h,customerId));
});
return result;
}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml
index 900d34ba66..7411fb6575 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml
+++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml
@@ -315,6 +315,7 @@
IFNULL(ih.HOUSE_NAME,'') as HOUSE_NAME,
IFNULL(ib.LONGITUDE,'') as buildingLongitude,
IFNULL(ib.LATITUDE,'') as buildingLatitude,
+ ih.CUSTOMER_ID AS customerId,
concat(IFNULL(n.NEIGHBOR_HOOD_NAME,''),IFNULL(ib.BUILDING_NAME,''),IFNULL(u.UNIT_NAME,''),IFNULL(ih.HOUSE_NAME,'')) AS allName
FROM ic_house ih
left JOIN ic_neighbor_hood n ON ( ih.NEIGHBOR_HOOD_ID = n.id )
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 0e4630e9db..4e02d02cea 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
@@ -526,7 +526,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl gridInfoMap = gridInfoList.stream().collect(Collectors.toMap(AllGridsByUserIdResultDTO::getGridId, Function.identity()));
//查询房子名称
- Result> houseInfoRes=govOrgOpenFeignClient.queryListHouseInfo(houseIds);
+ Result> houseInfoRes=govOrgOpenFeignClient.queryListHouseInfo(houseIds,formDTO.getCustomerId());
List houseInfoDTOList = houseInfoRes.success() && !CollectionUtils.isEmpty(houseInfoRes.getData()) ? houseInfoRes.getData() : new ArrayList<>();
Map houseInfoMap = houseInfoDTOList.stream().collect(Collectors.toMap(HouseInfoDTO::getHomeId, Function.identity()));
for (Map resultMap : list) {
@@ -1119,7 +1119,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl userList = disposeCategory(list, configList);
- Result> houseInfosResult = govOrgOpenFeignClient.queryListHouseInfo(userList.stream().distinct().map(m -> m.getHomeId()).collect(Collectors.toSet()));
+ Result> houseInfosResult = govOrgOpenFeignClient.queryListHouseInfo(userList.stream().distinct().map(m -> m.getHomeId()).collect(Collectors.toSet()),tokenDto.getCustomerId());
if (!houseInfosResult.success()){
throw new EpmetException("查询房屋信息失败...");
}
From e54149303efbc4cf040dc977791cd5484370dbb1 Mon Sep 17 00:00:00 2001
From: sunyuchao
Date: Tue, 18 Jan 2022 16:32:11 +0800
Subject: [PATCH 7/8] =?UTF-8?q?=E4=BA=BA=E5=91=98=E5=8F=98=E6=9B=B4?=
=?UTF-8?q?=E8=AE=B0=E5=BD=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../impl/CustomerAgencyServiceImpl.java | 8 +--
.../service/impl/IcResiUserServiceImpl.java | 37 +++++-----
.../impl/IcUserTransferRecordServiceImpl.java | 71 ++++++++++---------
3 files changed, 62 insertions(+), 54 deletions(-)
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java
index 372aafa390..7403df24f9 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java
@@ -1387,10 +1387,10 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl map) {
- Date date = (Date) new java.util.Date();
+ java.util.Date date = new java.util.Date();
//1.判断维度数据是否修改【网格、小区、楼栋、单元、房间有变化则先走人员调动逻辑】
if ((map.containsKey("GRID_ID") && !entity.getGridId().equals(map.get("GRID_ID"))) || (map.containsKey("VILLAGE_ID") && !entity.getVillageId().equals(map.get("VILLAGE_ID")))
|| (map.containsKey("BUILD_ID") && !entity.getBuildId().equals(map.get("BUILD_ID"))) || (map.containsKey("UNIT_ID") && !entity.getUnitId().equals(map.get("UNIT_ID")))
@@ -413,22 +413,25 @@ public class IcResiUserServiceImpl extends BaseServiceImpl l.setIcUserChangeRecordId(changeRecordEntity.getId()));
- icUserChangeDetailedService.insertBatch(list);
+ //居民信息修改中有类别修改的才会生成变更记录和变更明细
+ if (list.size() > NumConstant.ZERO) {
+ //变更记录
+ CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId());
+ changeRecordEntity.setCustomerId(tokenDto.getCustomerId());
+ changeRecordEntity.setOperatorId(tokenDto.getUserId());
+ changeRecordEntity.setIcUserId(entity.getId());
+ changeRecordEntity.setOperatorName(staffInfoCache.getRealName());
+ changeRecordEntity.setIcUserName(map.containsKey("NAME") ? map.get("NAME") : entity.getName());
+ changeRecordEntity.setType("category");
+ changeRecordEntity.setTypeName("类别");
+ changeRecordEntity.setBeforeChangeName(beforeChangeName.toString());
+ changeRecordEntity.setAfterChangeName(afterChangeName.toString());
+ changeRecordEntity.setChangeTime(date);
+ icUserChangeRecordService.insert(changeRecordEntity);
+
+ list.forEach(l -> l.setIcUserChangeRecordId(changeRecordEntity.getId()));
+ icUserChangeDetailedService.insertBatch(list);
+ }
}
/**
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcUserTransferRecordServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcUserTransferRecordServiceImpl.java
index e2616d2842..1d994dd30c 100644
--- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcUserTransferRecordServiceImpl.java
+++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcUserTransferRecordServiceImpl.java
@@ -98,22 +98,24 @@ public class IcUserTransferRecordServiceImpl extends BaseServiceImpl result2 = govOrgOpenFeignClient.icResiUserOrgMsg(orgMsgFormDTO2);
- if (!result2.success() || null == result2.getData().getAgencyDTO() || null == result2.getData().getGridDTO() || null == result2.getData().getNeighborHoodDTO()
- || null == result2.getData().getBuildingDTO() || null == result2.getData().getBuildingUnitDTO() || null == result2.getData().getHouseDTO()) {
- log.warn("查找被调动人调动后的组织、网格、小区、楼栋、单元、房屋信息失败");
- throw new RenException("9000", "获取被调动人基础信息失败");
+ Result result2 = new Result<>();
+ if("in".equals(formDTO.getType())){
+ IcResiUserOrgMsgFormDTO orgMsgFormDTO2 = new IcResiUserOrgMsgFormDTO();
+ orgMsgFormDTO2.setCustomerId(formDTO.getCustomerId());
+ orgMsgFormDTO2.setAgencyId(formDTO.getNewAgencyId());
+ orgMsgFormDTO2.setGridId(formDTO.getNewGridId());
+ orgMsgFormDTO2.setNeighborHoodId(formDTO.getNewNeighborHoodId());
+ orgMsgFormDTO2.setBuildingId(formDTO.getNewBuildingId());
+ orgMsgFormDTO2.setBuildingUnitId(formDTO.getNewBuildingUnitId());
+ orgMsgFormDTO2.setHouseId(formDTO.getNewHouseId());
+ result2 = govOrgOpenFeignClient.icResiUserOrgMsg(orgMsgFormDTO2);
+ if (!result2.success() || null == result2.getData().getAgencyDTO() || null == result2.getData().getGridDTO() || null == result2.getData().getNeighborHoodDTO()
+ || null == result2.getData().getBuildingDTO() || null == result2.getData().getBuildingUnitDTO() || null == result2.getData().getHouseDTO()) {
+ log.warn("查找被调动人调动后的组织、网格、小区、楼栋、单元、房屋信息失败");
+ throw new RenException("9000", "获取被调动人基础信息失败");
+ }
}
-
//4.修改被调动人所属各维度信息或人员状态信息
if (formDTO.getIdEdit()) {
IcResiUserEntity userEntity = new IcResiUserEntity();
@@ -156,10 +158,12 @@ public class IcUserTransferRecordServiceImpl extends BaseServiceImpl
Date: Tue, 18 Jan 2022 16:49:08 +0800
Subject: [PATCH 8/8] =?UTF-8?q?=E6=95=B0=E5=AD=97=E7=A4=BE=E5=8C=BA?=
=?UTF-8?q?=E5=8D=95=E7=8B=AC=E9=83=A8=E7=BD=B2=20=E6=94=AF=E6=8C=81?=
=?UTF-8?q?=E7=9A=84=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../feign/DataStatisticalOpenFeignClient.java | 11 ++
...ataStatisticalOpenFeignClientFallBack.java | 5 +
.../controller/ShiBeiICJobController.java | 101 ++++++++++++++++++
.../task/IcPrivateDeploySupportTask.java | 31 ++++++
4 files changed, 148 insertions(+)
create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ShiBeiICJobController.java
create mode 100644 epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/IcPrivateDeploySupportTask.java
diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java
index dab2edf301..69feca31d5 100644
--- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java
+++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java
@@ -353,4 +353,15 @@ public interface DataStatisticalOpenFeignClient {
*/
@PostMapping("/data/stats/demand/volunteer/daily")
Result statsVolunteerDemandServicesDaily(@RequestParam(value = "customer-id", required = false) String customerId);
+
+ /**
+ * desc: 市北私有化部署需要 支持的任务之一
+ *
+ * @param formDTO
+ * @return com.epmet.commons.tools.utils.Result
+ * @author LiuJanJun
+ * @date 2022/1/18 4:37 下午
+ */
+ @PostMapping("/data/stats/shibeiICJob/userPointAndProjectStatus")
+ Result userPointAndProjectStatus(@RequestBody ExtractOriginFormDTO formDTO);
}
diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java
index 56fea9c03f..5ace88fac3 100644
--- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java
+++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java
@@ -339,4 +339,9 @@ public class DataStatisticalOpenFeignClientFallBack implements DataStatisticalOp
public Result statsVolunteerDemandServicesDaily(String customerId) {
return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "statsVolunteerDemandServicesDaily", customerId);
}
+
+ @Override
+ public Result userPointAndProjectStatus(ExtractOriginFormDTO formDTO) {
+ return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "userPointAndProjectStatus", formDTO);
+ }
}
diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ShiBeiICJobController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ShiBeiICJobController.java
new file mode 100644
index 0000000000..3963c5f579
--- /dev/null
+++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ShiBeiICJobController.java
@@ -0,0 +1,101 @@
+package com.epmet.controller;
+
+import com.epmet.commons.tools.constant.NumConstant;
+import com.epmet.commons.tools.constant.StrConstant;
+import com.epmet.commons.tools.exception.EpmetErrorCode;
+import com.epmet.commons.tools.redis.RedisKeys;
+import com.epmet.commons.tools.redis.RedisUtils;
+import com.epmet.commons.tools.utils.DateUtils;
+import com.epmet.commons.tools.utils.Result;
+import com.epmet.dto.StatsFormDTO;
+import com.epmet.dto.extract.form.ExtractOriginFormDTO;
+import com.epmet.dto.screen.form.ScreenCentralZoneDataFormDTO;
+import com.epmet.service.StatsProjectService;
+import com.epmet.service.evaluationindex.extract.toscreen.ScreenGrassrootsGovernDataAbsorptionService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * desc:市北数字社区 单独部署 job入口 【用户积分排名及项目状态数据】
+ */
+@RequestMapping("shibeiICJob")
+@RestController
+@Slf4j
+public class ShiBeiICJobController {
+ @Autowired
+ private ScreenGrassrootsGovernDataAbsorptionService screenGrassrootsGovernDataAbsorptionService;
+ @Autowired
+ private StatsProjectService statsProjectService;
+ @Autowired
+ private RedisUtils redisUtils;
+
+ @PostMapping("userPointAndProjectStatus")
+ public Result userPointAndProjectStatus(@RequestBody ExtractOriginFormDTO formDTO) {
+ if (StringUtils.isBlank(formDTO.getCustomerId())){
+ return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"参数错误cid不能为空");
+ }
+ long start = System.currentTimeMillis();
+ Set result = new LinkedHashSet<>();
+ if (StringUtils.isNotBlank(formDTO.getStartDate()) && StringUtils.isNotBlank(formDTO.getEndDate())) {
+ List daysBetween = DateUtils.getDaysBetween(formDTO.getStartDate(), formDTO.getEndDate());
+ daysBetween.forEach(d -> {
+ this.extractUserPointData(formDTO.getCustomerId(), d);
+ this.agencyProjectStats(formDTO.getCustomerId(), formDTO.getDateId());
+ result.add(d);
+ redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("userPointAndProjectStatus"), formDTO.getCustomerId(), result, 3 * 24 * 60 * 60L);
+ });
+ } else {
+ if (StringUtils.isBlank(formDTO.getDateId())){
+ formDTO.setDateId(DateUtils.getBeforeNDay(NumConstant.ONE));
+ }
+ this.extractUserPointData(formDTO.getCustomerId(), formDTO.getDateId());
+ this.agencyProjectStats(formDTO.getCustomerId(), formDTO.getDateId());
+ result.add(formDTO.getDateId());
+ redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("userPointAndProjectStatus"), formDTO.getCustomerId(), result, 3 * 24 * 60 * 60L);
+ }
+ long end = System.currentTimeMillis();
+ long l = (end - start) / 1000;
+ return new Result().ok("userPointAndProjectStatus耗时" + l + "s");
+ }
+
+ /**
+ * @Author sun
+ * @Description 数据-项目-机关日(月)统计
+ **/
+ private Result agencyProjectStats(String customerId, String dateId) {
+ try {
+ if (StringUtils.isNotBlank(dateId)) {
+ dateId = DateUtils.format(DateUtils.parseDate(dateId, DateUtils.DATE_PATTERN_YYYYMMDD));
+ }
+ StatsFormDTO formDTO = new StatsFormDTO();
+ formDTO.setCustomerId(customerId);
+ formDTO.setDate(dateId);
+
+ statsProjectService.agencyProjectStats(formDTO);
+ } catch (Exception e) {
+ log.error("市北-项目状态数据写入失败,参数为:{}" + customerId + StrConstant.HYPHEN + dateId, e);
+ }
+ return new Result();
+ }
+
+ private void extractUserPointData(String customerId, String dateId) {
+ try {
+ //基层治理 - 热心市民 screen_party_user_rank_data
+ ScreenCentralZoneDataFormDTO param = new ScreenCentralZoneDataFormDTO();
+ param.setCustomerId(customerId);
+ param.setDateId(dateId);
+ screenGrassrootsGovernDataAbsorptionService.userScoreDataHub(param);
+ } catch (Exception e) {
+ log.error("市北-热心市民/党员得分数据写入失败,参数为:{}" + customerId + StrConstant.HYPHEN + dateId, e);
+ }
+ }
+}
diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/IcPrivateDeploySupportTask.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/IcPrivateDeploySupportTask.java
new file mode 100644
index 0000000000..80dc22febb
--- /dev/null
+++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/IcPrivateDeploySupportTask.java
@@ -0,0 +1,31 @@
+package com.epmet.task;
+
+
+import com.alibaba.fastjson.JSON;
+import com.epmet.commons.tools.utils.Result;
+import com.epmet.dto.extract.form.ExtractOriginFormDTO;
+import com.epmet.feign.DataStatisticalOpenFeignClient;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * desc:数字社区私有化部署 任务之一还有【autoEvaluateDemandTask,statsDemandTask,dailyStatisticalVoteTask】
+ */
+@Slf4j
+@Component("icPrivateDeploySupportTask")
+public class IcPrivateDeploySupportTask implements ITask {
+ @Autowired
+ private DataStatisticalOpenFeignClient dataStatisticalOpenFeignClient;
+
+ @Override
+ public void run(String params) {
+ ExtractOriginFormDTO formDTO = new ExtractOriginFormDTO();
+ if (StringUtils.isNotBlank(params)) {
+ formDTO = JSON.parseObject(params, ExtractOriginFormDTO.class);
+ }
+ Result result = dataStatisticalOpenFeignClient.userPointAndProjectStatus(formDTO);
+ log.info("IcPrivateDeploySupportTask excute end,param:{},result:{}",params,result);
+ }
+}