From 7968b940bbe8a602ec4048889afe0589b67650b8 Mon Sep 17 00:00:00 2001 From: zxc <954985706@qq.com> Date: Sat, 20 Jun 2020 10:11:26 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=91=E6=A0=BC=E5=B0=8F=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/constant/GroupConstant.java | 13 + .../java/com/epmet/dto/group/AgencyDTO.java | 44 ++++ .../form/AgencyGridTotalCountFormDTO.java | 25 ++ .../dto/group/form/AgencyMonthlyFormDTO.java | 116 +++++++++ .../AgencyGridGroupPeopleResultDTO.java | 35 +++ .../AgencyGridGroupPeopleTotalResultDTO.java | 30 +++ .../group/result/AgencyGridInfoResultDTO.java | 27 +++ .../result/AgencyGridTotalCountResultDTO.java | 27 +++ .../result/AgencyGroupDailyResultDTO.java | 126 ++++++++++ .../result/AgencyGroupIncrResultDTO.java | 29 +++ .../result/AgencyGroupMonthlyResultDTO.java | 25 ++ .../AgencyGroupTotalCountResultDTO.java | 31 +++ .../group/result/GroupGridDailyResultDTO.java | 10 +- .../result/GroupPeopleCountResultDTO.java | 25 ++ .../group/result/SubAgencyIdResultDTO.java | 30 +++ .../controller/StatsGroupController.java | 52 +++- .../com/epmet/dao/group/GroupDataDao.java | 41 +++- .../com/epmet/dao/org/CustomerGridDao.java | 9 + .../com/epmet/dao/stats/DimAgencyDao.java | 14 ++ .../java/com/epmet/dao/stats/DimGridDao.java | 21 +- .../dao/stats/FactGroupAgencyDailyDao.java | 27 +++ .../dao/stats/FactGroupAgencyMonthlyDao.java | 11 + .../com/epmet/service/StatsGroupService.java | 14 +- .../epmet/service/group/GroupDataService.java | 45 +++- .../group/impl/GroupDataServiceImpl.java | 123 ++++++++-- .../service/impl/StatsGroupServiceImpl.java | 225 ++++++++++++++++-- .../service/org/CustomerGridService.java | 9 + .../org/impl/CustomerGridServiceImpl.java | 12 + .../epmet/service/stats/DimAgencyService.java | 14 ++ .../epmet/service/stats/DimGridService.java | 17 ++ .../stats/FactGroupAgencyDailyService.java | 25 ++ .../stats/FactGroupAgencyMonthlyService.java | 9 + .../stats/impl/DimAgencyServiceImpl.java | 20 ++ .../stats/impl/DimGridServiceImpl.java | 23 ++ .../impl/FactGroupAgencyDailyServiceImpl.java | 41 ++++ .../FactGroupAgencyMonthlyServiceImpl.java | 15 ++ .../impl/FactGroupGridDailyServiceImpl.java | 4 + .../resources/mapper/group/GroupDataDao.xml | 90 +++++++ .../resources/mapper/org/CustomerGridDao.xml | 16 ++ .../resources/mapper/stats/DimAgencyDao.xml | 25 ++ .../resources/mapper/stats/DimGridDao.xml | 41 +++- .../mapper/stats/FactGroupAgencyDailyDao.xml | 78 ++++++ .../stats/FactGroupAgencyMonthlyDao.xml | 35 +++ 43 files changed, 1564 insertions(+), 85 deletions(-) create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/AgencyDTO.java create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/AgencyGridTotalCountFormDTO.java create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/AgencyMonthlyFormDTO.java create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGridGroupPeopleResultDTO.java create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGridGroupPeopleTotalResultDTO.java create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGridInfoResultDTO.java create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGridTotalCountResultDTO.java create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGroupDailyResultDTO.java create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGroupIncrResultDTO.java create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGroupMonthlyResultDTO.java create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGroupTotalCountResultDTO.java create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/GroupPeopleCountResultDTO.java create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/SubAgencyIdResultDTO.java diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/GroupConstant.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/GroupConstant.java index b5465e4a7b..255b463cdb 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/GroupConstant.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/GroupConstant.java @@ -16,4 +16,17 @@ public interface GroupConstant { */ String Q = "Q"; + /** + * 机关级别(社区级:community, + * 乡(镇、街道)级:street, + * 区县级: district, + * 市级: city + * 省级: province + */ + String COMMUNITY = "community"; + String STREET = "street"; + String DISTRICT = "district"; + String CITY = "city"; + String PROVINCE = "province"; + } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/AgencyDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/AgencyDTO.java new file mode 100644 index 0000000000..767adaad61 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/AgencyDTO.java @@ -0,0 +1,44 @@ +package com.epmet.dto.group; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @CreateTime 2020/6/18 11:06 + */ +@Data +public class AgencyDTO implements Serializable { + + private static final long serialVersionUID = -1644032762160525169L; + + /** + * 组织ID AGENCY_ID + */ + private String id; + + /** + * 客户ID + */ + private String customerId; + + /** + * 上级组织机构ID,根组织为0 + */ + private String pid; + + /** + * 所有上级组织机构ID(以英文:隔开) + */ + private String pids; + + /** + * 机关级别(社区级:community, + * 乡(镇、街道)级:street, + * 区县级: district, + * 市级: city + * 省级:province) + */ + private String level; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/AgencyGridTotalCountFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/AgencyGridTotalCountFormDTO.java new file mode 100644 index 0000000000..5990fd7de5 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/AgencyGridTotalCountFormDTO.java @@ -0,0 +1,25 @@ +package com.epmet.dto.group.form; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @CreateTime 2020/6/18 14:39 + */ +@Data +public class AgencyGridTotalCountFormDTO implements Serializable { + + private static final long serialVersionUID = -4219157085337388583L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 机关ID + */ + private String agencyId; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/AgencyMonthlyFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/AgencyMonthlyFormDTO.java new file mode 100644 index 0000000000..32c14a94a9 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/form/AgencyMonthlyFormDTO.java @@ -0,0 +1,116 @@ +package com.epmet.dto.group.form; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * @Author zxc + * @CreateTime 2020/6/19 21:22 + */ +@Data +public class AgencyMonthlyFormDTO implements Serializable { + + private static final long serialVersionUID = -5920961528060576749L; + + /** + * 唯一标识 + */ + private String id; + + /** + * 机关ID + */ + private String agencyId; + + /** + * 父级机关ID + */ + private String pid; + + /** + * 统计月份ID 关联月份dim表 + */ + private String monthId; + + /** + * 统计季度ID + */ + private String quarterId; + + /** + * 统计年份ID + */ + private String yearId; + + /** + * 网格数 截至到月末的机关下网格数 + */ + private Integer gridTotal = 0; + + /** + * 小组数 截止到月末的新增数(该月内所有的新增数字之和) + */ + private Integer groupTotal = 0; + + /** + * 机关下网格组内总人数 不去重 + */ + private Integer groupMemberTotal = 0; + + /** + * 小组平均人数 月末一天的平均数 + */ + private Integer groupMemberAvgCount = 0; + + /** + * 小组中位数 月末一天的中位数(人) + */ + private Integer groupMedian = 0; + + /** + * 小组增量 + */ + private Integer groupIncr = 0; + + /** + * 小组成员最大数 + */ + private Integer groupMemberMaxCount = 0; + + /** + * 成员最多小组ID + */ + private String maxMemberGroupId; + + /** + * 小组成员最小数 + */ + private Integer groupMemberMinCount = 0; + + /** + * 成员最少小组ID + */ + private String minMemberGroupId; + + /** + * 删除标识 未删除:0,已删除:1 + */ + private String delFlag = "0"; + + /** + * 乐观锁 + */ + private Integer revision = 0; + + /** + * 创建人 + */ + private String createdBy = "APP_USER"; + + /** + * 更新人 + */ + private String updatedBy = "APP_USER"; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGridGroupPeopleResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGridGroupPeopleResultDTO.java new file mode 100644 index 0000000000..9c96b40583 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGridGroupPeopleResultDTO.java @@ -0,0 +1,35 @@ +package com.epmet.dto.group.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @CreateTime 2020/6/16 16:31 + */ +@Data +public class AgencyGridGroupPeopleResultDTO implements Serializable { + + private static final long serialVersionUID = 225708056690809761L; + + /** + * 机关ID + */ + private String agencyId; + + /** + * 网格ID + */ + private String gridId; + + /** + * 小组ID + */ + private String groupId; + + /** + * 网格下-每个小组内成员的数量【人员状态 不为 removed】 + */ + private Integer groupCount; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGridGroupPeopleTotalResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGridGroupPeopleTotalResultDTO.java new file mode 100644 index 0000000000..5d1b2f259e --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGridGroupPeopleTotalResultDTO.java @@ -0,0 +1,30 @@ +package com.epmet.dto.group.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @CreateTime 2020/6/16 16:31 + */ +@Data +public class AgencyGridGroupPeopleTotalResultDTO implements Serializable { + + private static final long serialVersionUID = -8693107487048855351L; + + /** + * 机关ID + */ + private String agencyId; + + /** + * 网格ID + */ + private String gridId; + + /** + * 网格下的小组成员总数量 + */ + private Integer gridGroupPeopleTotal; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGridInfoResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGridInfoResultDTO.java new file mode 100644 index 0000000000..ea51f65bf4 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGridInfoResultDTO.java @@ -0,0 +1,27 @@ +package com.epmet.dto.group.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @CreateTime 2020/6/18 14:35 + */ +@Data +public class AgencyGridInfoResultDTO implements Serializable { + + private static final long serialVersionUID = -1979735889806617714L; + + /** + * 机关ID + */ + private String agencyId; + + /** + * 网格Id + */ + private String gridId; + + +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGridTotalCountResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGridTotalCountResultDTO.java new file mode 100644 index 0000000000..73ccde44d3 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGridTotalCountResultDTO.java @@ -0,0 +1,27 @@ +package com.epmet.dto.group.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @CreateTime 2020/6/18 14:35 + */ +@Data +public class AgencyGridTotalCountResultDTO implements Serializable { + + private static final long serialVersionUID = -3528033317344272299L; + + /** + * 机关ID + */ + private String agencyId; + + /** + * 机关下的网格数量 + */ + private Integer gridTotal; + + +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGroupDailyResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGroupDailyResultDTO.java new file mode 100644 index 0000000000..3858767dda --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGroupDailyResultDTO.java @@ -0,0 +1,126 @@ +package com.epmet.dto.group.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @CreateTime 2020/6/18 10:09 + */ +@Data +public class AgencyGroupDailyResultDTO implements Serializable { + + private static final long serialVersionUID = 7862398525119326819L; + + /** + * 唯一标识 + */ + private String id; + + /** + * 机构ID + */ + private String agencyId; + + /** + * 父级机关ID + */ + private String pid; + + /** + * 统计日期 关联日期dim表 + */ + private String dateId; + + /** + * 周ID + */ + private String weekId; + + /** + * 月ID + */ + private String monthId; + + /** + * 季ID + */ + private String quarterId; + + /** + * 年ID + */ + private String yearId; + + /** + * 网格总数 截至统计日期 + */ + private Integer gridTotal = 0; + + /** + * 网格小组数(包含所有下级机关的网格小组) 截至统计日期 + */ + private Integer groupTotalCount = 0; + + /** + * 机关下网格小组人数总计 不去重 + */ + private Integer groupMemberTotalCount = 0; + + /** + * 小组平均人数 截至统计日期 + */ + private Integer groupMemberAvgCount = 0; + + /** + * 小组中位数 截至统计日期,小组人数依次由小到大排开取中位数 + */ + private Integer groupMedian = 0; + + /** + * 当天小组增量 + */ + private Integer groupIncr = 0; + + /** + * 小组最大成员数 + */ + private Integer groupMemberMaxCount = 0; + + /** + * 最多成员小组ID + */ + private String maxMemberGroupId; + + /** + * 小组最小成员数 + */ + private Integer groupMemberMinCount = 0; + + /** + * 最少成员小组ID + */ + private String minMemberGroupId; + + /** + * 删除标识 未删除:0,已删除:1 + */ + private String delFlag = "0"; + + /** + * 乐观锁 + */ + private Integer revision = 0; + + /** + * 创建人 + */ + private String createdBy = "APP_USER"; + + /** + * 更新人 + */ + private String updatedBy = "APP_USER"; + +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGroupIncrResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGroupIncrResultDTO.java new file mode 100644 index 0000000000..dcf9a9694c --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGroupIncrResultDTO.java @@ -0,0 +1,29 @@ +package com.epmet.dto.group.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @CreateTime 2020/6/17 16:48 + */ +@Data +public class AgencyGroupIncrResultDTO implements Serializable { + + private static final long serialVersionUID = 8397311844636364561L; + /** + * 机关ID + */ + private String agencyId; + + /** + * 网格ID + */ + private String gridId; + + /** + * 小组日增数 + */ + private Integer groupIncr = 0; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGroupMonthlyResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGroupMonthlyResultDTO.java new file mode 100644 index 0000000000..354eb918e7 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGroupMonthlyResultDTO.java @@ -0,0 +1,25 @@ +package com.epmet.dto.group.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @CreateTime 2020/6/19 22:12 + */ +@Data +public class AgencyGroupMonthlyResultDTO implements Serializable { + + private static final long serialVersionUID = 8436524201080875660L; + + /** + * 机关ID + */ + private String agencyId; + + /** + * 小组月增长数量 + */ + private Integer monthGroupIncr; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGroupTotalCountResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGroupTotalCountResultDTO.java new file mode 100644 index 0000000000..069bddcfd1 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/AgencyGroupTotalCountResultDTO.java @@ -0,0 +1,31 @@ +package com.epmet.dto.group.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @CreateTime 2020/6/18 17:35 + */ +@Data +public class AgencyGroupTotalCountResultDTO implements Serializable { + + private static final long serialVersionUID = 1166957004076377211L; + + /** + * 机关ID + */ + private String agencyId; + + /** + * 网格ID + */ + private String gridId; + + /** + * 每个网格下的小组数 + */ + private Integer gridGroupCount; + +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/GroupGridDailyResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/GroupGridDailyResultDTO.java index 23a9312e63..b33c9c38ad 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/GroupGridDailyResultDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/GroupGridDailyResultDTO.java @@ -66,17 +66,17 @@ public class GroupGridDailyResultDTO implements Serializable { /** * 网格下所有组内总人数 不去重 */ - private Integer groupMemberTotal; + private Integer groupMemberTotal = 0; /** * 小组平均人数 */ - private Integer groupMemberAvgCount; + private Integer groupMemberAvgCount = 0; /** * 小组中位数 截至统计日期,小组人数依次由小到大排开取中位数 */ - private Integer groupMedian; + private Integer groupMedian = 0; /** * 小组增量 @@ -86,7 +86,7 @@ public class GroupGridDailyResultDTO implements Serializable { /** * 小组成员最大数 */ - private Integer groupMemberMaxCount; + private Integer groupMemberMaxCount = 0; /** * 最多成员小组ID @@ -96,7 +96,7 @@ public class GroupGridDailyResultDTO implements Serializable { /** * 小组成员最小数 */ - private Integer groupMemberMinCount = 1; + private Integer groupMemberMinCount = 0; /** * 最少成员小组ID diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/GroupPeopleCountResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/GroupPeopleCountResultDTO.java new file mode 100644 index 0000000000..6cfa4ed9f5 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/GroupPeopleCountResultDTO.java @@ -0,0 +1,25 @@ +package com.epmet.dto.group.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @CreateTime 2020/6/19 15:43 + */ +@Data +public class GroupPeopleCountResultDTO implements Serializable { + + private static final long serialVersionUID = 7804052387414894768L; + + /** + * 小组ID + */ + private String groupId; + + /** + * 网格下-每个小组内成员的数量【人员状态 不为 removed】 + */ + private Integer groupCount; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/SubAgencyIdResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/SubAgencyIdResultDTO.java new file mode 100644 index 0000000000..8690179371 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/group/result/SubAgencyIdResultDTO.java @@ -0,0 +1,30 @@ +package com.epmet.dto.group.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @CreateTime 2020/6/19 10:41 + */ +@Data +public class SubAgencyIdResultDTO implements Serializable { + + private static final long serialVersionUID = -5375229459340391098L; + + /** + * 机关ID + */ + private String agencyId; + + /** + * 下级机关ID + */ + private String subAgencyId; + + /** + * 网格数量 + */ + private Integer gridTotal; +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsGroupController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsGroupController.java index 7f2dd5ee76..c33979545d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsGroupController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsGroupController.java @@ -1,14 +1,15 @@ package com.epmet.controller; -import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.service.StatsGroupService; -import com.epmet.service.group.GroupDataService; -import com.epmet.service.stats.FactGroupGridDailyService; +import com.epmet.service.stats.DimCustomerService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + /** * @Author zxc * @CreateTime 2020/6/16 13:21 @@ -19,18 +20,59 @@ public class StatsGroupController { @Autowired private StatsGroupService statsGroupService; + @Autowired + private DimCustomerService dimCustomerService; /** - * @Description 统计 “小组” 有关数据, dim:【网格-日】 * 网格数、小组数、网格下所有组内人数(不去重) * 小组平均人数、小组人数中位数、小组增量 * 小组成员最大数、最多成员小组ID * 小组成员最小数、最少成员小组ID + */ + + /** + * @Description 统计 “网格小组”, dim:【网格-日】 * @author zxc */ @PostMapping("groupgriddaily") public void groupGridDaily(){ - statsGroupService.groupGridDaily(); + Integer pageNo = NumConstant.ONE; + Integer pageSize = NumConstant.ONE_HUNDRED; + List customerIds = dimCustomerService.selectCustomerIdPage(pageNo,pageSize); + if (customerIds.size() == NumConstant.ZERO){ + return; + } + customerIds.forEach(customerId -> { + statsGroupService.groupGridDaily(customerId); + }); + } + + /** + * @Description 统计 “网格小组”, dim:【机关-日】 + * @param + * @author zxc + */ + @PostMapping("groupagencydaily") + public void groupAgencyDaily(){ + Integer pageNo = NumConstant.ONE; + Integer pageSize = NumConstant.ONE_HUNDRED; + List customerIds = dimCustomerService.selectCustomerIdPage(pageNo,pageSize); + if (customerIds.size() == NumConstant.ZERO){ + return; + } + customerIds.forEach(customerId -> { + statsGroupService.groupAgencyDaily(customerId); + }); + } + + /** + * @Description 统计 “网格小组”, dim:【机关-月】 + * @param + * @author zxc + */ + @PostMapping("groupagencymonthly") + public void groupAgencyMonthly(){ + statsGroupService.groupAgencyMonthly(); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/group/GroupDataDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/group/GroupDataDao.java index bd93d50689..5a226cad20 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/group/GroupDataDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/group/GroupDataDao.java @@ -4,11 +4,9 @@ import com.epmet.dto.group.form.GridGroupPeopleFormDTO; import com.epmet.dto.group.form.GridGroupPeopleTotalFormDTO; import com.epmet.dto.group.form.GridGroupTotalFormDTO; import com.epmet.dto.group.form.GroupIncrFormDTO; -import com.epmet.dto.group.result.GridGroupPeopleResultDTO; -import com.epmet.dto.group.result.GridGroupPeopleTotalResultDTO; -import com.epmet.dto.group.result.GridGroupTotalResultDTO; -import com.epmet.dto.group.result.GroupIncrResultDTO; +import com.epmet.dto.group.result.*; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -47,4 +45,39 @@ public interface GroupDataDao { */ List selectGroupIncr(GroupIncrFormDTO formDTO); + /** + * @Description 获取机关下网格下的小组数量 【待优化】 + * @param + * @author zxc + */ + List getAgencyGroupTotalCount(@Param("allGrid") List allGrid); + + /** + * @Description 查询机关下网格内的小组人数 【待优化】 + * @param + * @author zxc + */ + List selectAgencyGridGroupPeopleTotal(@Param("allGrid") List allGrid); + + /** + * @Description 查询机关下每个小组的人数 【待优化】 + * @param + * @author zxc + */ + List selectAgencyEveryGroupPeopleCount(@Param("allGrid") List allGrid); + + /** + * @Description 查询机关下的小组日增数 【待优化】 + * @param + * @param yesterday + * @author zxc + */ + List selectAgencyGroupIncr(@Param("allGrid") List allGrid,@Param("yesterday")String yesterday); + + /** + * @Description 查询机关下所有网格小组人数 + * @param gridIds + * @author zxc + */ + List getAgencyGrid(@Param("gridIds")List gridIds); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java index ee1547a190..4b2c3621b3 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java @@ -18,6 +18,8 @@ package com.epmet.dao.org; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.group.AgencyDTO; +import com.epmet.dto.group.result.AgencyGridTotalCountResultDTO; import com.epmet.entity.org.CustomerGridEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -41,4 +43,11 @@ public interface CustomerGridDao extends BaseDao { * @return */ List listGridsByCreateTime(@Param("start") Date start, @Param("end") Date end); + + /** + * @Description 查询机关下的网格总数 + * @param formDto + * @author zxc + */ + List selectAgencyGridTotalCount(@Param("formDto") List formDto, @Param("dateId")String dateId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimAgencyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimAgencyDao.java index f4d1477562..3c70225c26 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimAgencyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimAgencyDao.java @@ -109,4 +109,18 @@ public interface DimAgencyDao extends BaseDao { * @date 2020.06.18 09:26 **/ List selectTopAgencyWithDept(); + + /** + * @Description 查询所有客户的机关数据 + * @author zxc + */ + List selectDimAgencyByCustomerId(@Param("customerId")String customerId); + + /** + * @Description 根据机关Id获取上级机关ID + * @param agencyId + * @author zxc + */ + String getPidByAgencyId(@Param("agencyId") String agencyId); + } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java index 0582f19669..669e8a08a0 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java @@ -18,7 +18,9 @@ package com.epmet.dao.stats; import com.epmet.commons.mybatis.dao.BaseDao; -import com.epmet.dto.group.result.CustomerGridInfoResultDTO; +import com.epmet.dto.group.AgencyDTO; +import com.epmet.dto.group.result.AgencyGridInfoResultDTO; +import com.epmet.dto.group.result.SubAgencyIdResultDTO; import com.epmet.entity.stats.DimGridEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -36,13 +38,24 @@ public interface DimGridDao extends BaseDao { DimGridEntity getLastCreatedGridDimEntity(); - - List selectCustomerGrid(); - /** * desc:根据客户Id获取 该客户下的网格数据 * @param customerId * @return */ List getGridListByCustomerId(@Param("customerId") String customerId); + + /** + * @Description 查询机关下的网格 + * @param formDTO + * @author zxc + */ + List selectAgencyGridInfo(@Param("formDTO") List formDTO); + + /** + * @Description 根据当前机关ID查询下级机关ID + * @param formDTO + * @author zxc + */ + List selectSubAgencyId(@Param("formDTO")List formDTO); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupAgencyDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupAgencyDailyDao.java index 6a3f343a9a..aaf4312dd9 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupAgencyDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupAgencyDailyDao.java @@ -18,8 +18,14 @@ package com.epmet.dao.stats; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.group.form.AgencyMonthlyFormDTO; +import com.epmet.dto.group.result.AgencyGroupDailyResultDTO; +import com.epmet.dto.group.result.AgencyGroupMonthlyResultDTO; import com.epmet.entity.stats.FactGroupAgencyDailyEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 组-机关日统计数据 @@ -29,5 +35,26 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface FactGroupAgencyDailyDao extends BaseDao { + + /** + * @Description 插入网格小组数据 【机关-日】 + * @param agencyList + * @author zxc + */ + void insertGroupAgencyDaily(@Param("agencyList") List agencyList); + + /** + * @Description 获取 网格小组【机关-日统计】的最后一天数据 + * @param + * @author zxc + */ + List getLastDayAgency(); + + /** + * @Description 查询 月的小组增量 + * @param monthId + * @author zxc + */ + List getMonthGroupIncr(@Param("monthId")String monthId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupAgencyMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupAgencyMonthlyDao.java index 7928b13b0a..0e0ed99f21 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupAgencyMonthlyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/FactGroupAgencyMonthlyDao.java @@ -18,8 +18,12 @@ package com.epmet.dao.stats; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.group.form.AgencyMonthlyFormDTO; import com.epmet.entity.stats.FactGroupAgencyMonthlyEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 组-机关月统计数据 @@ -29,5 +33,12 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface FactGroupAgencyMonthlyDao extends BaseDao { + + /** + * @Description 统计网格小组 【机关-月】 + * @param agencyMonth + * @author zxc + */ + void insertAgencyGroupMonthly(@Param("agencyMonth") List agencyMonth); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsGroupService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsGroupService.java index d792170796..8042fd0c83 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsGroupService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsGroupService.java @@ -10,6 +10,18 @@ public interface StatsGroupService { * @Description 统计 “小组” 有关数据, dim:【网格-日】 * @author zxc */ - void groupGridDaily(); + void groupGridDaily(String customerId); + + /** + * @Description 统计 “小组” 有关数据, dim:【机关-日】 + * @author zxc + */ + void groupAgencyDaily(String customerId); + + /** + * @Description 统计 “小组” 有关数据, dim:【机关-月】 + * @author zxc + */ + void groupAgencyMonthly(); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/GroupDataService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/GroupDataService.java index 2b921314cb..babd6e6503 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/GroupDataService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/GroupDataService.java @@ -1,7 +1,9 @@ package com.epmet.service.group; -import com.epmet.dto.group.result.CustomerGridInfoResultDTO; -import com.epmet.dto.group.result.GroupGridDailyResultDTO; +import com.epmet.dto.group.result.*; +import com.epmet.entity.stats.DimGridEntity; +import com.epmet.util.DimIdGenerator; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -14,9 +16,44 @@ public interface GroupDataService { /** * @Description 统计 “小组” 有关数据, dim:【网格-日】 * @param customerId - * @param gridsInfo * @author zxc */ - List groupGridDaily(String customerId, List gridsInfo); + List groupGridDaily(String customerId, DimIdGenerator.DimIdBean dimIdBean, List gridsInfo); + + /** + * @Description 获取同级机关下网格下的小组数量 + * @param allGrid + * @author zxc + */ + List getAgencyGroupTotalCount(List allGrid); + + /** + * @Description 查询机关下网格内的小组人数 + * @param + * @author zxc + */ + List selectAgencyGridGroupPeopleTotal(List allGrid); + + /** + * @Description 查询机关下每个小组的人数 + * @param + * @author zxc + */ + List selectAgencyEveryGroupPeopleCount(List allGrid); + + /** + * @Description 查询机关下的小组日增数 + * @param + * @param yesterday + * @author zxc + */ + List selectAgencyGroupIncr(List allGrid,String yesterday); + + /** + * @Description 查询机关下所有网格小组人数 + * @param gridIds + * @author zxc + */ + List getAgencyGrid(@Param("gridIds") List gridIds); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/impl/GroupDataServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/impl/GroupDataServiceImpl.java index 01a8cd979d..2ee8c38550 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/impl/GroupDataServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/impl/GroupDataServiceImpl.java @@ -4,18 +4,18 @@ import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.constant.DataSourceConstant; import com.epmet.dao.group.GroupDataDao; -import com.epmet.dao.stats.DimDateDao; import com.epmet.dto.group.form.GridGroupPeopleFormDTO; import com.epmet.dto.group.form.GridGroupPeopleTotalFormDTO; import com.epmet.dto.group.form.GridGroupTotalFormDTO; import com.epmet.dto.group.form.GroupIncrFormDTO; import com.epmet.dto.group.result.*; +import com.epmet.entity.stats.DimGridEntity; import com.epmet.service.group.GroupDataService; +import com.epmet.util.DimIdGenerator; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.time.LocalDate; import java.util.*; import java.util.stream.Collectors; @@ -29,41 +29,47 @@ public class GroupDataServiceImpl implements GroupDataService { @Autowired private GroupDataDao groupDataDao; - @Autowired - private DimDateDao dimDateDao; - - public DimTimeResultDTO getTimeDim(){ - String dateId = LocalDate.now().minusDays(NumConstant.ONE).toString().replace("-", ""); - return dimDateDao.selectDimTime(dateId); - } /** * @Description 统计 “小组” 有关数据, dim:【网格-日】 * @param customerId - * @param gridsInfo * @author zxc */ @Override - public List groupGridDaily(String customerId, List gridsInfo) { - DimTimeResultDTO dimTime = this.getTimeDim(); + public List groupGridDaily(String customerId, DimIdGenerator.DimIdBean dimTime, List gridsInfo) { List result = new ArrayList<>(); - - // 1. 网格下有多少小组,只算 state = ‘approved’ - GridGroupTotalFormDTO formDTO = new GridGroupTotalFormDTO(); - formDTO.setCustomerId(customerId); - List gridGroupTotalResultDTOS = groupDataDao.selectGridGroupTotal(formDTO); + if (gridsInfo.size() == NumConstant.ZERO){ + return new ArrayList<>(); + } gridsInfo.forEach(grid -> { GroupGridDailyResultDTO dailyResult = new GroupGridDailyResultDTO(); BeanUtils.copyProperties(dimTime,dailyResult); dailyResult.setAgencyId(grid.getAgencyId()); - gridGroupTotalResultDTOS.forEach(groupTotal -> { - if (grid.getGridId().equals(groupTotal.getGridId())){ - dailyResult.setGroupTotal(groupTotal.getGridGroupTotal()); - dailyResult.setGridId(grid.getGridId()); - } - }); + dailyResult.setGridId(grid.getId()); result.add(dailyResult); }); + + // 1. 网格下有多少小组,只算 state = ‘approved’ + GridGroupTotalFormDTO formDTO = new GridGroupTotalFormDTO(); + formDTO.setCustomerId(customerId); + List gridGroupTotalResultDTOS = groupDataDao.selectGridGroupTotal(formDTO); + if (gridGroupTotalResultDTOS.size() == NumConstant.ZERO){ + result.forEach(grid -> { + grid.setGroupTotal(NumConstant.ZERO); + }); + }else { + result.forEach(grid -> { + GroupGridDailyResultDTO dailyResult = new GroupGridDailyResultDTO(); + BeanUtils.copyProperties(dimTime, dailyResult); + dailyResult.setAgencyId(grid.getAgencyId()); + gridGroupTotalResultDTOS.forEach(groupTotal -> { + if (grid.getGridId().equals(groupTotal.getGridId())) { + dailyResult.setGroupTotal(groupTotal.getGridGroupTotal()); + } + }); + + }); + } // 2. 网格下所有组内人数和(不需要去重) 人员状态 != "removed" GridGroupPeopleTotalFormDTO peopleTotalFormDTO = new GridGroupPeopleTotalFormDTO(); peopleTotalFormDTO.setCustomerId(customerId); @@ -77,9 +83,9 @@ public class GroupDataServiceImpl implements GroupDataService { }); // 3. 网格下小组平均人数 result.forEach(grid -> { - grid.setGroupMemberAvgCount(grid.getGroupMemberTotal()/grid.getGroupTotal()); + grid.setGroupMemberAvgCount(grid.getGroupTotal() == NumConstant.ZERO ? NumConstant.ZERO : grid.getGroupMemberTotal()/grid.getGroupTotal()); }); - // 4. 网格下小组人数中位数 + // 4. 网格下小组人数中位数 小组最大(小)成员数、最多(少)成员小组ID GridGroupPeopleFormDTO everyGroupPeople = new GridGroupPeopleFormDTO(); everyGroupPeople.setCustomerId(customerId); List everyGroupPeopleCount = groupDataDao.selectEveryGroupPeopleCount(everyGroupPeople); @@ -105,7 +111,7 @@ public class GroupDataServiceImpl implements GroupDataService { } }); }); - //TODO 网格下小组增量 + // 5. 网格下小组增量 GroupIncrFormDTO groupIncr = new GroupIncrFormDTO(); groupIncr.setCustomerId(customerId); groupIncr.setYesterday(dimTime.getDateId()); @@ -119,4 +125,69 @@ public class GroupDataServiceImpl implements GroupDataService { }); return result; } + + /** + * @Description 获取同级机关下网格下的小组数量 + * @param + * @author zxc + */ + public List getAgencyGroupTotalCount(List allGrid){ + if (allGrid.size() == NumConstant.ZERO){ + return new ArrayList<>(); + } + return groupDataDao.getAgencyGroupTotalCount(allGrid); + } + + /** + * @Description 查询机关下网格内的小组人数 + * @param + * @author zxc + */ + @Override + public List selectAgencyGridGroupPeopleTotal(List allGrid) { + if (allGrid.size() == NumConstant.ZERO){ + return new ArrayList<>(); + } + return groupDataDao.selectAgencyGridGroupPeopleTotal(allGrid); + } + + /** + * @Description 查询机关下每个小组的人数 + * @param + * @author zxc + */ + public List selectAgencyEveryGroupPeopleCount(List allGrid){ + if (allGrid.size() == NumConstant.ZERO){ + return new ArrayList<>(); + } + return groupDataDao.selectAgencyEveryGroupPeopleCount(allGrid); + } + + /** + * @Description 查询机关下的小组日增数 + * @param + * @param yesterday + * @author zxc + */ + public List selectAgencyGroupIncr(List allGrid,String yesterday){ + if (allGrid.size() == NumConstant.ZERO){ + return new ArrayList<>(); + } + return groupDataDao.selectAgencyGroupIncr(allGrid, yesterday); + } + + /** + * @Description 查询机关下所有网格小组人数 + * @param gridIds + * @author zxc + */ + @Override + public List getAgencyGrid(List gridIds) { + if (gridIds.size() == NumConstant.ZERO){ + return new ArrayList<>(); + } + return groupDataDao.getAgencyGrid(gridIds); + } + + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java index f647c7439a..df312995fb 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java @@ -1,19 +1,26 @@ package com.epmet.service.impl; import com.epmet.commons.tools.constant.NumConstant; -import com.epmet.dao.stats.DimGridDao; -import com.epmet.dao.stats.FactGroupGridDailyDao; -import com.epmet.dto.group.result.CustomerGridInfoResultDTO; -import com.epmet.dto.group.result.GroupGridDailyResultDTO; +import com.epmet.dto.AgencySubTreeDto; +import com.epmet.dto.group.form.AgencyMonthlyFormDTO; +import com.epmet.dto.group.result.*; +import com.epmet.dto.stats.DimAgencyDTO; +import com.epmet.entity.stats.DimAgencyEntity; +import com.epmet.entity.stats.DimGridEntity; import com.epmet.service.StatsGroupService; import com.epmet.service.group.GroupDataService; -import com.epmet.service.stats.FactGroupGridDailyService; +import com.epmet.service.stats.*; +import com.epmet.util.DimIdGenerator; +import com.epmet.util.ModuleConstant; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.time.LocalDate; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.util.*; import java.util.stream.Collectors; /** @@ -24,11 +31,17 @@ import java.util.stream.Collectors; public class StatsGroupServiceImpl implements StatsGroupService { @Autowired - private DimGridDao dimGridDao; + private DimGridService dimGridService; + @Autowired + private DimAgencyService dimAgencyService; @Autowired private GroupDataService groupDataService; @Autowired private FactGroupGridDailyService factGroupGridDailyService; + @Autowired + private FactGroupAgencyDailyService factGroupAgencyDailyService; + @Autowired + private FactGroupAgencyMonthlyService factGroupAgencyMonthlyService; /** * @Description 统计【网格-日】 @@ -36,25 +49,189 @@ public class StatsGroupServiceImpl implements StatsGroupService { * @author zxc */ @Override - public void groupGridDaily() { + public void groupGridDaily(String customerId) { + DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(); + List gridsInfo = dimGridService.getGridListByCustomerId(customerId); + List resultDTOS = groupDataService.groupGridDaily(customerId,dimIdBean,gridsInfo); + factGroupGridDailyService.statisticsGroupGridDaily(resultDTOS); + } + + /** + * @Description 统计 “小组” 有关数据, dim:【机关-日】 + * @author zxc + */ + @Override + public void groupAgencyDaily(String customerId) { + DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(); + List customerAgencyInfos = dimAgencyService.getAgencyInfoByCustomerId(customerId); + List agencyGroupDaily = this.getAgencyGroupDaily(customerAgencyInfos, dimIdBean, customerId); + factGroupAgencyDailyService.insertGroupAgencyDaily(agencyGroupDaily); + + } + + /** + * @Description 统计 “小组” 有关数据, dim:【机关-月】 + * @author zxc String customerId + */ + @Override + public void groupAgencyMonthly() { + List lastDayAgency = factGroupAgencyDailyService.getLastDayAgency(); + DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(); + List monthGroupIncr = factGroupAgencyDailyService.getMonthGroupIncr(dimIdBean.getMonthId()); + if (monthGroupIncr.size() == NumConstant.ZERO){ + lastDayAgency.forEach(agency -> { + agency.setGroupIncr(NumConstant.ZERO); + }); + }else { + lastDayAgency.forEach(agency -> { + monthGroupIncr.forEach(monthIncr -> { + if (agency.getAgencyId().equals(monthIncr.getAgencyId())){ + agency.setGroupIncr(monthIncr.getMonthGroupIncr()); + } + }); + }); + } + factGroupAgencyMonthlyService.insertAgencyGroupMonthly(lastDayAgency); + } - //每个客户下的网格信息 - List customerGridInfos = dimGridDao.selectCustomerGrid(); - if (customerGridInfos.size() == NumConstant.ZERO){ - return; + public List getAgencyGroupDaily(List customerAgencyInfos, DimIdGenerator.DimIdBean timeDim,String customerId){ + if (customerAgencyInfos.size() == NumConstant.ZERO){ + return new ArrayList<>(); } - //根据customerId分组 - Map> collect = customerGridInfos.stream().collect(Collectors.groupingBy(gridInfo -> gridInfo.getCustomerId())); - Set>> entries = collect.entrySet(); - entries.forEach(customerGridInfo -> { - String customerId = customerGridInfo.getKey(); - List gridsInfo = customerGridInfo.getValue(); - if (gridsInfo.size() != NumConstant.ZERO){ - List resultDTOS = groupDataService.groupGridDaily(customerId, gridsInfo); - //执行插入 fact_group_grid_daily - factGroupGridDailyService.statisticsGroupGridDaily(resultDTOS); + List result = new ArrayList<>(); + List agencyList = dimAgencyService.getAgencyListByCustomerId(customerId); + agencyList.forEach(agency -> { + AgencyGroupDailyResultDTO agencyResult = new AgencyGroupDailyResultDTO(); + String agencyId = agency.getId(); + agencyResult.setAgencyId(agencyId); + BeanUtils.copyProperties(timeDim,agencyResult); + //机关下的所有网格(包括直属网格) + List allGrid = this.getAllGrid(agencyId); + String pidByAgencyId = dimAgencyService.getPidByAgencyId(agencyId); + agencyResult.setPid(StringUtils.isBlank(pidByAgencyId)?"0":pidByAgencyId); + // TODO 1. 机关下有多少网格 + agencyResult.setGridTotal(allGrid.size()); + + // TODO 2. 机关下有多少小组,只算 state = ‘approved’ + List agencyGroupTotalCount = groupDataService.getAgencyGroupTotalCount(allGrid); + Integer groupCount = agencyGroupTotalCount.stream().collect(Collectors.summingInt(AgencyGroupTotalCountResultDTO::getGridGroupCount)); + agencyResult.setGroupTotalCount(groupCount); + // TODO 3. 机关下所有组内人数和(不需要去重) 人员状态 != "removed" + List agencyGridGroupPeopleTotal = groupDataService.selectAgencyGridGroupPeopleTotal(allGrid); + Integer groupPeopleCount = agencyGridGroupPeopleTotal.stream().collect(Collectors.summingInt(AgencyGridGroupPeopleTotalResultDTO::getGridGroupPeopleTotal)); + agencyResult.setGroupMemberTotalCount(groupPeopleCount); + + // TODO 4. 机关下小组平均人数 + agencyResult.setGroupMemberAvgCount( + agencyResult.getGroupTotalCount() == NumConstant.ZERO ? NumConstant.ZERO : + agencyResult.getGroupMemberTotalCount()/agencyResult.getGroupTotalCount()); + + // TODO 5. 机关下小组人数中位数 小组最大(小)成员数、最多(少)成员小组ID + List agencyGridGroupPeople = groupDataService.selectAgencyEveryGroupPeopleCount(allGrid); + List sorted = agencyGridGroupPeople.stream().sorted(Comparator.comparing(AgencyGridGroupPeopleResultDTO::getGroupCount).reversed()).collect(Collectors.toList()); + Integer groupPeopleMedian; + if (sorted.size() == NumConstant.ONE){ + agencyResult.setGroupMemberMaxCount(sorted.get(NumConstant.ZERO).getGroupCount()); + agencyResult.setMaxMemberGroupId(sorted.get(NumConstant.ZERO).getGroupId()); + agencyResult.setGroupMemberMinCount(sorted.get(NumConstant.ZERO).getGroupCount()); + agencyResult.setMinMemberGroupId(sorted.get(NumConstant.ZERO).getGroupId()); + }else if (sorted.size() >= NumConstant.TWO){ + groupPeopleMedian = sorted.size() % 2 == 0 ? + (sorted.get(sorted.size() / 2 - 1).getGroupCount() + sorted.get(sorted.size() / 2).getGroupCount()) / 2 : + sorted.get(sorted.size() / 2).getGroupCount(); + agencyResult.setGroupMedian(groupPeopleMedian); + + agencyResult.setGroupMemberMaxCount(sorted.get(NumConstant.ZERO).getGroupCount()); + agencyResult.setMaxMemberGroupId(sorted.get(NumConstant.ZERO).getGroupId()); + agencyResult.setGroupMemberMinCount(sorted.get(sorted.size() - NumConstant.ONE).getGroupCount()); + agencyResult.setMinMemberGroupId(sorted.get(sorted.size() - NumConstant.ONE).getGroupId()); + } + // TODO 6. 机关下小组增量 + List agencyGroupIncr = groupDataService.selectAgencyGroupIncr(allGrid, timeDim.getDateId()); + Integer groupIncr = agencyGroupIncr.stream().collect(Collectors.summingInt(AgencyGroupIncrResultDTO::getGroupIncr)); + agencyResult.setGroupIncr(groupIncr); + result.add(agencyResult); + }); + return result; + } + + /** + * @Description 根据当前机关ID,查询出直属网格和所有下级机关的网格 + * @param agencyId + * @author zxc + */ + public List getAllGrid(String agencyId){ + List result = new ArrayList<>(); + List allAgency = dimAgencyService.getAllAgency(); + + Map> subGridOfAgency = new HashMap<>(); + allAgency.forEach(agency -> { + this.initAgencyGridMap(agency.getAgencyId(),agency,subGridOfAgency); + }); + Set>> entries = subGridOfAgency.entrySet(); + entries.forEach(entry -> { + String key = entry.getKey(); + Set value = entry.getValue(); + if (key.equals(agencyId)){ + result.addAll(value); + } + }); + return result; + } + + /** + * @Description 递归获取机关下的网格id【包括直属机关】 + * @param pid + * @param agency + * @param subGridOfAgency + * @author zxc + */ + void initAgencyGridMap(String pid, AgencySubTreeDto agency, Map> subGridOfAgency){ + + //向map中放入数据 + if(subGridOfAgency.containsKey(pid)){ + //包含key + Set grids = subGridOfAgency.get(pid); + if(null == grids){ + grids = new HashSet<>(); + subGridOfAgency.put(pid,grids); + } + if(null != agency.getGridIds() && agency.getGridIds().size() > NumConstant.ZERO){ + grids.addAll(agency.getGridIds()); } + }else{ + //不包含key + Set grids = new HashSet<>(agency.getGridIds()); + subGridOfAgency.put(pid,grids); + } + + //定义递归出口 + if(StringUtils.equals(ModuleConstant.AGENCY_LEVEL_COMMUNITY,agency.getLevel()) || null == agency.getSubAgencies() || agency.getSubAgencies().size() == NumConstant.ZERO){ + return ; + } + + + //定义递归入口 + agency.getSubAgencies().forEach(obj -> { + initAgencyGridMap(pid,obj,subGridOfAgency); }); + } + + /** + * @Description 获取时间维度 dateId--weekId--monthId--quarterId--yearId + * @param + * @author zxc + */ + public DimIdGenerator.DimIdBean getDimIdBean(){ + ZoneId zoneId = ZoneId.systemDefault(); + LocalDate localDate = LocalDate.now(); + ZonedDateTime zdt = localDate.atStartOfDay(zoneId); + Date date = Date.from(zdt.toInstant()); + return DimIdGenerator.getDimIdBean(date); + } + + public List getAgencyAllGrid(String customerId,String agencyId){ + return null; } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java index b8308aede1..2c7c0f523c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java @@ -1,5 +1,7 @@ package com.epmet.service.org; +import com.epmet.dto.group.AgencyDTO; +import com.epmet.dto.group.result.AgencyGridTotalCountResultDTO; import com.epmet.entity.org.CustomerGridEntity; import java.util.Date; @@ -14,4 +16,11 @@ public interface CustomerGridService { * @Param("start") Date start, @Param("end") Date end */ List listGridsByCreateTime(Date start, Date end); + + /** + * @Description 查询机关下有多少网格 + * @param community + * @author zxc + */ + List selectAgencyGridTotalCount(List community, String dateId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java index 191b074d19..3e2c071400 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java @@ -3,6 +3,8 @@ package com.epmet.service.org.impl; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.constant.DataSourceConstant; import com.epmet.dao.org.CustomerGridDao; +import com.epmet.dto.group.AgencyDTO; +import com.epmet.dto.group.result.AgencyGridTotalCountResultDTO; import com.epmet.entity.org.CustomerGridEntity; import com.epmet.service.org.CustomerGridService; import org.springframework.beans.factory.annotation.Autowired; @@ -22,4 +24,14 @@ public class CustomerGridServiceImpl implements CustomerGridService { public List listGridsByCreateTime(Date start, Date end) { return customerGridDao.listGridsByCreateTime(start, end); } + + /** + * @Description 查询机关下有多少网格 + * @param community + * @author zxc + */ + @Override + public List selectAgencyGridTotalCount(List community, String dateId) { + return customerGridDao.selectAgencyGridTotalCount(community,dateId); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimAgencyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimAgencyService.java index fe9fbd9765..95c305943d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimAgencyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimAgencyService.java @@ -159,4 +159,18 @@ public interface DimAgencyService extends BaseService { * @date 2020.06.18 09:45 **/ List getTopAgencyWithDept(); + + /** + * @Description 根据customerId获取机关信息 + * @param customerId + * @author zxc + */ + List getAgencyInfoByCustomerId(String customerId); + + /** + * @Description 根据机关Id获取上级机关ID + * @param agencyId + * @author zxc + */ + String getPidByAgencyId(String agencyId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java index c31774399f..312659eb96 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java @@ -19,6 +19,9 @@ package com.epmet.service.stats; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.group.AgencyDTO; +import com.epmet.dto.group.result.AgencyGridInfoResultDTO; +import com.epmet.dto.group.result.SubAgencyIdResultDTO; import com.epmet.dto.stats.DimGridDTO; import com.epmet.entity.stats.DimGridEntity; import com.epmet.entity.stats.LastExecRecordEntity; @@ -111,4 +114,18 @@ public interface DimGridService extends BaseService { * @author: jianjun liu */ List getGridListByCustomerId(String customerId); + + /** + * @Description 查询机关下的网格 + * @param formDTO + * @author zxc + */ + List selectAgencyGridInfo(List formDTO); + + /** + * @Description 根据当前机关ID查询下级机关ID + * @param formDTO + * @author zxc + */ + List selectSubAgencyId(List formDTO); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGroupAgencyDailyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGroupAgencyDailyService.java index 3801b7b9b2..30ff917431 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGroupAgencyDailyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGroupAgencyDailyService.java @@ -19,8 +19,12 @@ package com.epmet.service.stats; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.group.form.AgencyMonthlyFormDTO; +import com.epmet.dto.group.result.AgencyGroupDailyResultDTO; +import com.epmet.dto.group.result.AgencyGroupMonthlyResultDTO; import com.epmet.dto.stats.FactGroupAgencyDailyDTO; import com.epmet.entity.stats.FactGroupAgencyDailyEntity; +import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; @@ -92,4 +96,25 @@ public interface FactGroupAgencyDailyService extends BaseService agencyList); + + /** + * @Description 获取 网格小组【机关-日统计】的最后一天数据 + * @param + * @author zxc + */ + List getLastDayAgency(); + + /** + * @Description 查询 月的小组增量 + * @param monthId + * @author zxc + */ + List getMonthGroupIncr(String monthId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGroupAgencyMonthlyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGroupAgencyMonthlyService.java index 7e851aa6da..75e43242c7 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGroupAgencyMonthlyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGroupAgencyMonthlyService.java @@ -19,8 +19,10 @@ package com.epmet.service.stats; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.group.form.AgencyMonthlyFormDTO; import com.epmet.dto.stats.FactGroupAgencyMonthlyDTO; import com.epmet.entity.stats.FactGroupAgencyMonthlyEntity; +import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; @@ -92,4 +94,11 @@ public interface FactGroupAgencyMonthlyService extends BaseService agencyMonth); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java index 0c86f00ef4..16e627c42c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java @@ -201,4 +201,24 @@ public class DimAgencyServiceImpl extends BaseServiceImpl getAgencyInfoByCustomerId(String customerId) { + return baseDao.selectDimAgencyByCustomerId(customerId); + } + + /** + * @Description 根据机关Id获取上级机关ID + * @param agencyId + * @author zxc + */ + @Override + public String getPidByAgencyId(String agencyId) { + return baseDao.getPidByAgencyId(agencyId); + } + } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimGridServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimGridServiceImpl.java index 1caeb9d473..72bdafb3c4 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimGridServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimGridServiceImpl.java @@ -28,6 +28,9 @@ import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.constant.StatsSubject; import com.epmet.dao.stats.DimGridDao; import com.epmet.dao.stats.LastExecRecordDao; +import com.epmet.dto.group.AgencyDTO; +import com.epmet.dto.group.result.AgencyGridInfoResultDTO; +import com.epmet.dto.group.result.SubAgencyIdResultDTO; import com.epmet.dto.stats.DimGridDTO; import com.epmet.entity.stats.DimGridEntity; import com.epmet.entity.stats.LastExecRecordEntity; @@ -133,4 +136,24 @@ public class DimGridServiceImpl extends BaseServiceImpl selectAgencyGridInfo(List formDTO) { + return baseDao.selectAgencyGridInfo(formDTO); + } + + /** + * @Description 根据当前机关ID查询下级机关ID + * @param formDTO + * @author zxc + */ + @Override + public List selectSubAgencyId(List formDTO) { + return baseDao.selectSubAgencyId(formDTO); + } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupAgencyDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupAgencyDailyServiceImpl.java index 7f2822e763..dc34d3b9e7 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupAgencyDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupAgencyDailyServiceImpl.java @@ -20,10 +20,14 @@ package com.epmet.service.stats.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.dao.stats.FactGroupAgencyDailyDao; +import com.epmet.dto.group.form.AgencyMonthlyFormDTO; +import com.epmet.dto.group.result.AgencyGroupDailyResultDTO; +import com.epmet.dto.group.result.AgencyGroupMonthlyResultDTO; import com.epmet.dto.stats.FactGroupAgencyDailyDTO; import com.epmet.entity.stats.FactGroupAgencyDailyEntity; import com.epmet.service.stats.FactGroupAgencyDailyService; @@ -32,6 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -97,4 +102,40 @@ public class FactGroupAgencyDailyServiceImpl extends BaseServiceImpl agencyList) { + if (agencyList.size() != NumConstant.ZERO){ + baseDao.insertGroupAgencyDaily(agencyList); + } + + } + + /** + * @Description 获取 网格小组【机关-日统计】的最后一天数据 + * @param + * @author zxc + */ + public List getLastDayAgency(){ + return baseDao.getLastDayAgency(); + } + + /** + * @Description 查询 月的小组增量 + * @param monthId + * @author zxc + */ + @Override + public List getMonthGroupIncr(String monthId) { + if (StringUtils.isBlank(monthId)){ + return new ArrayList<>(); + } + return baseDao.getMonthGroupIncr(monthId); + } + } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupAgencyMonthlyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupAgencyMonthlyServiceImpl.java index bf8da031c4..85a216373d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupAgencyMonthlyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupAgencyMonthlyServiceImpl.java @@ -20,10 +20,12 @@ package com.epmet.service.stats.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.dao.stats.FactGroupAgencyMonthlyDao; +import com.epmet.dto.group.form.AgencyMonthlyFormDTO; import com.epmet.dto.stats.FactGroupAgencyMonthlyDTO; import com.epmet.entity.stats.FactGroupAgencyMonthlyEntity; import com.epmet.service.stats.FactGroupAgencyMonthlyService; @@ -96,4 +98,17 @@ public class FactGroupAgencyMonthlyServiceImpl extends BaseServiceImpl agencyMonth) { + if (agencyMonth.size() == NumConstant.ZERO){ + return; + } + baseDao.insertAgencyGroupMonthly(agencyMonth); + } + } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupGridDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupGridDailyServiceImpl.java index 68ddd26178..cfba6ff90f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupGridDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupGridDailyServiceImpl.java @@ -20,6 +20,7 @@ package com.epmet.service.stats.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.group.result.GroupGridDailyResultDTO; import com.epmet.dto.stats.FactGroupGridDailyDTO; @@ -111,6 +112,9 @@ public class FactGroupGridDailyServiceImpl extends BaseServiceImpl formDto) { + if (formDto.size() == NumConstant.ZERO){ + return; + } baseDao.insertGroupGridDaily(formDto); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/group/GroupDataDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/group/GroupDataDao.xml index e0f4ee8be0..021a38a005 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/group/GroupDataDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/group/GroupDataDao.xml @@ -67,5 +67,95 @@ GROUP BY grid_id + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml index 54e81a8d69..e31a36a40a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml @@ -18,4 +18,20 @@ ORDER BY CREATED_TIME ASC; + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml index 370ea99cc5..ac14010373 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml @@ -222,4 +222,29 @@ agency.PID + + + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml index 3c12538580..783230dc55 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml @@ -11,18 +11,6 @@ LIMIT 1 - + + + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupAgencyDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupAgencyDailyDao.xml index 2e526090dc..283cd62e9b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupAgencyDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupAgencyDailyDao.xml @@ -30,5 +30,83 @@ + + INSERT INTO fact_group_agency_daily ( + ID, AGENCY_ID, PID, DATE_ID, WEEK_ID, MONTH_ID, QUARTER_ID, YEAR_ID, GRID_TOTAL, GROUP_TOTAL_COUNT, GROUP_MEMBER_TOTAL_COUNT, + GROUP_MEMBER_AVG_COUNT, GROUP_MEDIAN, GROUP_INCR, GROUP_MEMBER_MAX_COUNT, MAX_MEMBER_GROUP_ID, GROUP_MEMBER_MIN_COUNT, + MIN_MEMBER_GROUP_ID, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME) + values + + ( + REPLACE(UUID(),'-',''), + #{agency.agencyId}, + #{agency.pid}, + #{agency.dateId}, + #{agency.weekId}, + #{agency.monthId}, + #{agency.quarterId}, + #{agency.yearId}, + #{agency.gridTotal}, + #{agency.groupTotalCount}, + #{agency.groupMemberTotalCount}, + #{agency.groupMemberAvgCount}, + #{agency.groupMedian}, + #{agency.groupIncr}, + #{agency.groupMemberMaxCount}, + IFNULL(#{agency.maxMemberGroupId},NULL), + #{agency.groupMemberMinCount}, + IFNULL(#{agency.minMemberGroupId},NULL), + #{agency.delFlag}, + #{agency.revision}, + #{agency.createdBy}, + NOW(), + #{agency.updatedBy}, + NOW() + ) + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupAgencyMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupAgencyMonthlyDao.xml index 956e399ed0..73f80a1ce0 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupAgencyMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/FactGroupAgencyMonthlyDao.xml @@ -28,5 +28,40 @@ + + INSERT INTO fact_group_agency_monthly + (ID, AGENCY_ID, PID, MONTH_ID, QUARTER_ID, YEAR_ID, GRID_TOTAL, GROUP_TOTAL, GROUP_MEMBER_TOTAL, + GROUP_MEMBER_AVG_COUNT, GROUP_MEDIAN, GROUP_INCR, GROUP_MEMBER_MAX_COUNT, MAX_MEMBER_GROUP_ID, + GROUP_MEMBER_MIN_COUNT, MIN_MEMBER_GROUP_ID, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, + UPDATED_BY, UPDATED_TIME) + VALUES + + ( + REPLACE(UUID(),'-',''), + #{agency.agencyId}, + #{agency.pid}, + #{agency.monthId}, + #{agency.quarterId}, + #{agency.yearId}, + #{agency.gridTotal}, + #{agency.groupTotal}, + #{agency.groupMemberTotal}, + #{agency.groupMemberAvgCount}, + #{agency.groupMedian}, + #{agency.groupIncr}, + #{agency.groupMemberMaxCount}, + #{agency.maxMemberGroupId}, + #{agency.groupMemberMinCount}, + #{agency.minMemberGroupId}, + #{agency.delFlag}, + #{agency.revision}, + #{agency.createdBy}, + NOW(), + #{agency.updatedBy}, + NOW() + ) + + + \ No newline at end of file