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] 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 @@
+
+
+
+
+