From a27dbf979abb54735b388d72003a5c7d905b10bf Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Tue, 14 Sep 2021 09:39:03 +0800 Subject: [PATCH] mlgb --- .../result/CustomerDataManageResultDTO.java | 76 ++++++++------- .../controller/DataStatsController.java | 4 +- .../dataaggre/dao/datastats/DataStatsDao.java | 10 +- .../StatsStaffPatrolRecordDailyDao.java | 2 +- .../service/datastats/DataStatsService.java | 2 +- .../datastats/impl/DataStatsServiceImpl.java | 92 ++++++++++--------- .../StatsStaffPatrolRecordDailyService.java | 2 +- ...tatsStaffPatrolRecordDailyServiceImpl.java | 2 +- .../mapper/datastats/DatsStatsDao.xml | 25 +---- .../StatsStaffPatrolRecordDailyDao.xml | 2 +- 10 files changed, 110 insertions(+), 107 deletions(-) diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/result/CustomerDataManageResultDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/result/CustomerDataManageResultDTO.java index b5668643a1..2c7391672e 100644 --- a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/result/CustomerDataManageResultDTO.java +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/result/CustomerDataManageResultDTO.java @@ -3,6 +3,9 @@ package com.epmet.dataaggre.dto.datastats.result; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; +import java.util.ArrayList; +import java.util.List; + /** * @Description 运营情况数据导出-接口返参 * @Auth sun @@ -10,38 +13,45 @@ import lombok.Data; @Data public class CustomerDataManageResultDTO { - //组织、网格Id - private String orgId; - //组织、网格名称 - private String orgName; - //用户数 - private Integer userCount = 0; - //居民数 - private Integer residentCount = 0; - //党员数 - private Integer partyMemberCount = 0; - //小组数 - private Integer groupCount = 0; - //话题数 - private Integer topicCount = 0; - //议题数 - private Integer issueCount = 0; - //项目数 - private Integer projectCount = 0; - //结案项目数 - private Integer closedProjectCount = 0; - //巡查人数 - private Integer patrolPeopleCount = 0; - //巡查次数 - private Integer patrolCount = 0; - //巡查时长 - private String patrolDuration; - //未转换前的巡查时长 - private Integer patrolDurationInteger = 0; - //数据对应dateId - @JsonIgnore - private String dateId; - @JsonIgnore - private String staffId; + List dataManageList = new ArrayList<>(); + private Integer total; + + @Data + public static class CustomerDataManage { + //组织、网格Id + private String orgId; + //组织、网格名称 + private String orgName; + //用户数 + private Integer userCount = 0; + //居民数 + private Integer residentCount = 0; + //党员数 + private Integer partyMemberCount = 0; + //小组数 + private Integer groupCount = 0; + //话题数 + private Integer topicCount = 0; + //议题数 + private Integer issueCount = 0; + //项目数 + private Integer projectCount = 0; + //结案项目数 + private Integer closedProjectCount = 0; + //巡查人数 + private Integer patrolPeopleCount = 0; + //巡查次数 + private Integer patrolCount = 0; + //巡查时长 + private String patrolDuration; + //未转换前的巡查时长 + private Integer patrolDurationInteger = 0; + //数据对应dateId + @JsonIgnore + private String dateId; + @JsonIgnore + private String staffId; + } + } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DataStatsController.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DataStatsController.java index 9f84657fe1..9e1929056d 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DataStatsController.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/DataStatsController.java @@ -237,9 +237,9 @@ public class DataStatsController { * @author sun */ @PostMapping("operatedata") - public Result> operatedata(@RequestBody CustomerDataManageFormDTO formDTO) throws ParseException { + public Result operatedata(@RequestBody CustomerDataManageFormDTO formDTO) throws ParseException { ValidatorUtils.validateEntity(formDTO, CustomerDataManageFormDTO.CustomerDataManageForm.class); - return new Result>().ok(dataStatsService.operateExport(formDTO)); + return new Result().ok(dataStatsService.operateExport(formDTO)); } } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/datastats/DataStatsDao.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/datastats/DataStatsDao.java index 7172164e18..8db54dd03b 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/datastats/DataStatsDao.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/datastats/DataStatsDao.java @@ -314,25 +314,25 @@ public interface DataStatsDao { * @Description 直属组织或网格下注册用户数据 * @author sun */ - List regUserList(CustomerDataManageFormDTO formDTO); + List regUserList(CustomerDataManageFormDTO formDTO); /** * @Description 直属组织或网格下群组数据 * @author sun */ - List groupList(CustomerDataManageFormDTO formDTO); + List groupList(CustomerDataManageFormDTO formDTO); /** * @Description 直属组织或网格下话题数据 * @author sun */ - List topicList(CustomerDataManageFormDTO formDTO); + List topicList(CustomerDataManageFormDTO formDTO); /** * @Description 直属组织或网格下议题数据 * @author sun */ - List issueList(CustomerDataManageFormDTO formDTO); + List issueList(CustomerDataManageFormDTO formDTO); /** * @Description 直属组织或网格下项目数据 * @author sun */ - List projectList(CustomerDataManageFormDTO formDTO); + List projectList(CustomerDataManageFormDTO formDTO); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/StatsStaffPatrolRecordDailyDao.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/StatsStaffPatrolRecordDailyDao.java index 8f01bdda96..11ed072080 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/StatsStaffPatrolRecordDailyDao.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/StatsStaffPatrolRecordDailyDao.java @@ -50,5 +50,5 @@ public interface StatsStaffPatrolRecordDailyDao extends BaseDao patrolList(CustomerDataManageFormDTO formDTO); + List patrolList(CustomerDataManageFormDTO formDTO); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/DataStatsService.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/DataStatsService.java index 11fd673ceb..36fa24c7b2 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/DataStatsService.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/DataStatsService.java @@ -245,6 +245,6 @@ public interface DataStatsService { * @Description 运营情况数据查询 * @author sun */ - List operateExport(CustomerDataManageFormDTO formDTO) throws ParseException; + CustomerDataManageResultDTO operateExport(CustomerDataManageFormDTO formDTO) throws ParseException; } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java index 293ae7fc3d..73e191dec1 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java @@ -1933,16 +1933,13 @@ public class DataStatsServiceImpl implements DataStatsService { * @author sun */ @Override - public List operateExport(CustomerDataManageFormDTO formDTO) throws ParseException { - List resultList = new ArrayList<>(); + public CustomerDataManageResultDTO operateExport(CustomerDataManageFormDTO formDTO) throws ParseException { + CustomerDataManageResultDTO resultDTO = new CustomerDataManageResultDTO(); + List dataManageList = new ArrayList<>(); //1.必要参数校验及处理 if ("Interval".equals(formDTO.getType()) && StringUtils.isEmpty(formDTO.getStartTime())) { throw new RenException("请选择开始时间或查询累计值"); } - if (formDTO.getIsPage()) { - int pageIndex = (formDTO.getPageNo() - NumConstant.ONE) * formDTO.getPageSize(); - formDTO.setPageNo(pageIndex); - } //入参有开始时间的则需要减去一天 if (StringUtils.isNotBlank(formDTO.getStartTime())) { SimpleDateFormat format = new SimpleDateFormat(DateUtils.DATE_PATTERN_YYYYMMDD); @@ -1954,27 +1951,29 @@ public class DataStatsServiceImpl implements DataStatsService { //2.查询组织信息,判断查询下级组织还是网格数据 ScreenAgencyOrGridListDTO agencyGrid = indexService.getSubAgencyOrGridList(formDTO.getAgencyId()); if (null == agencyGrid) { - return new ArrayList<>(); + return new CustomerDataManageResultDTO(); } //组织或网格Id集合 List idList = agencyGrid.getAgencyGridList().stream().map(ScreenAgencyOrGridListDTO.AgencyGrid::getOrgId).collect(Collectors.toList()); formDTO.setDataType(!"community".equals(agencyGrid.getLevel()) ? "agency" : "grid"); formDTO.setIdList(idList); + resultDTO.setTotal(idList.size()); //3.查询截止日期用户、群组、话题、议题、项目、巡查数据 - List userEnd = dataStatsDao.regUserList(formDTO); - List groupEnd = dataStatsDao.groupList(formDTO); - List topicEnd = dataStatsDao.topicList(formDTO); - List issueEnd = dataStatsDao.issueList(formDTO); - List projectEnd = dataStatsDao.projectList(formDTO); - List patrolEnd = statsStaffPatrolRecordDailyService.patrolList(formDTO); + List userEnd = dataStatsDao.regUserList(formDTO); + List groupEnd = dataStatsDao.groupList(formDTO); + List topicEnd = dataStatsDao.topicList(formDTO); + List issueEnd = dataStatsDao.issueList(formDTO); + List projectEnd = dataStatsDao.projectList(formDTO); + //巡查数据不区分区间差值,只计算累计值,人员做去重处理且是有巡查记录的人员 + List patrolEnd = statsStaffPatrolRecordDailyService.patrolList(formDTO); //4.判断是否需要查询起始日期用户、群组、话题、议题、项目、巡查数据 - List userStart = new ArrayList<>(); - List groupStart = new ArrayList<>(); - List topicStart = new ArrayList<>(); - List issueStart = new ArrayList<>(); - List projectStart = new ArrayList<>(); + List userStart = new ArrayList<>(); + List groupStart = new ArrayList<>(); + List topicStart = new ArrayList<>(); + List issueStart = new ArrayList<>(); + List projectStart = new ArrayList<>(); if ("Interval".equals(formDTO.getType())) { userStart = dataStatsDao.regUserList(formDTO); groupStart = dataStatsDao.groupList(formDTO); @@ -1984,25 +1983,25 @@ public class DataStatsServiceImpl implements DataStatsService { } //5.封装数据 - List finalUserStart = userStart; - List finalGroupStart = groupStart; - List finalTopicStart = topicStart; - List finalIssueStart = issueStart; - List finalProjectStart = projectStart; + List finalUserStart = userStart; + List finalGroupStart = groupStart; + List finalTopicStart = topicStart; + List finalIssueStart = issueStart; + List finalProjectStart = projectStart; agencyGrid.getAgencyGridList().forEach(org -> { - CustomerDataManageResultDTO dto = new CustomerDataManageResultDTO(); + CustomerDataManageResultDTO.CustomerDataManage dto = new CustomerDataManageResultDTO.CustomerDataManage(); dto.setOrgId(org.getOrgId()); dto.setOrgName(org.getOrgName()); int user = 0; int resi = 0; int part = 0; - for (CustomerDataManageResultDTO u : userEnd) { + for (CustomerDataManageResultDTO.CustomerDataManage u : userEnd) { if (org.getOrgId().equals(u.getOrgId())) { user = u.getUserCount(); resi = u.getResidentCount(); part = u.getPartyMemberCount(); if ("Interval".equals(formDTO.getType())) { - for (CustomerDataManageResultDTO s : finalUserStart) { + for (CustomerDataManageResultDTO.CustomerDataManage s : finalUserStart) { if (u.getOrgId().equals(s.getOrgId())) { user = user - s.getUserCount(); resi = resi - s.getResidentCount(); @@ -2013,11 +2012,11 @@ public class DataStatsServiceImpl implements DataStatsService { } } int group = 0; - for (CustomerDataManageResultDTO u : groupEnd) { + for (CustomerDataManageResultDTO.CustomerDataManage u : groupEnd) { if (org.getOrgId().equals(u.getOrgId())) { group = u.getGroupCount(); if ("Interval".equals(formDTO.getType())) { - for (CustomerDataManageResultDTO s : finalGroupStart) { + for (CustomerDataManageResultDTO.CustomerDataManage s : finalGroupStart) { if (u.getOrgId().equals(s.getOrgId())) { group = group - s.getGroupCount(); } @@ -2026,11 +2025,11 @@ public class DataStatsServiceImpl implements DataStatsService { } } int topic = 0; - for (CustomerDataManageResultDTO u : topicEnd) { + for (CustomerDataManageResultDTO.CustomerDataManage u : topicEnd) { if (org.getOrgId().equals(u.getOrgId())) { topic = u.getTopicCount(); if ("Interval".equals(formDTO.getType())) { - for (CustomerDataManageResultDTO s : finalTopicStart) { + for (CustomerDataManageResultDTO.CustomerDataManage s : finalTopicStart) { if (u.getOrgId().equals(s.getOrgId())) { topic = topic - s.getTopicCount(); } @@ -2039,11 +2038,11 @@ public class DataStatsServiceImpl implements DataStatsService { } } int issue = 0; - for (CustomerDataManageResultDTO u : issueEnd) { + for (CustomerDataManageResultDTO.CustomerDataManage u : issueEnd) { if (org.getOrgId().equals(u.getOrgId())) { issue = u.getIssueCount(); if ("Interval".equals(formDTO.getType())) { - for (CustomerDataManageResultDTO s : finalIssueStart) { + for (CustomerDataManageResultDTO.CustomerDataManage s : finalIssueStart) { if (u.getOrgId().equals(s.getOrgId())) { issue = issue - s.getIssueCount(); } @@ -2053,12 +2052,12 @@ public class DataStatsServiceImpl implements DataStatsService { } int project = 0; int closed = 0; - for (CustomerDataManageResultDTO u : projectEnd) { + for (CustomerDataManageResultDTO.CustomerDataManage u : projectEnd) { if (org.getOrgId().equals(u.getOrgId())) { project = u.getProjectCount(); closed = u.getClosedProjectCount(); if ("Interval".equals(formDTO.getType())) { - for (CustomerDataManageResultDTO s : finalProjectStart) { + for (CustomerDataManageResultDTO.CustomerDataManage s : finalProjectStart) { if (u.getOrgId().equals(s.getOrgId())) { project = project - s.getProjectCount(); closed = closed - s.getClosedProjectCount(); @@ -2071,15 +2070,14 @@ public class DataStatsServiceImpl implements DataStatsService { int patroCount = 0; String patrolDuration = ""; int patrolDurationInteger = 0; - List list = new ArrayList<>(); - for (CustomerDataManageResultDTO u : patrolEnd) { + HashSet set = new HashSet(); + for (CustomerDataManageResultDTO.CustomerDataManage u : patrolEnd) { if (org.getOrgId().equals(u.getOrgId())) { patroCount += u.getPatrolCount(); patrolDurationInteger += u.getPatrolDurationInteger(); - list.add(u.getStaffId()); + set.add(u.getStaffId()); } } - HashSet set = new HashSet(list); patro = set.size(); Integer minutes = patrolDurationInteger / 60; patrolDuration = (minutes / 60 > 0 ? minutes / 60 + "小时" : "") + (minutes % 60 > 0 ? minutes % 60 + "分钟" : "0分钟"); @@ -2097,18 +2095,28 @@ public class DataStatsServiceImpl implements DataStatsService { dto.setPatrolDuration(patrolDuration); dto.setPatrolDurationInteger(patrolDurationInteger); - resultList.add(dto); + dataManageList.add(dto); }); //6.默认按用户总数降序 - Collections.sort(resultList, new Comparator() { + Collections.sort(dataManageList, new Comparator() { @Override - public int compare(CustomerDataManageResultDTO o1, CustomerDataManageResultDTO o2) { + public int compare(CustomerDataManageResultDTO.CustomerDataManage o1, CustomerDataManageResultDTO.CustomerDataManage o2) { return o2.getUserCount().compareTo(o1.getUserCount()); } }); - return resultList; + //7.物理分页并返回 + if (formDTO.getIsPage()) { + int firstIndex = (formDTO.getPageNo() - 1) * formDTO.getPageSize(); + int lastIndex = formDTO.getPageNo() * formDTO.getPageSize(); + List list = dataManageList.subList((firstIndex > dataManageList.size() ? dataManageList.size() : firstIndex), (lastIndex > dataManageList.size() ? dataManageList.size() : lastIndex)); + resultDTO.setDataManageList(list); + return resultDTO; + } + resultDTO.setDataManageList(dataManageList); + return resultDTO; } + } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StatsStaffPatrolRecordDailyService.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StatsStaffPatrolRecordDailyService.java index bd2e1ccf11..ce49c18f73 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StatsStaffPatrolRecordDailyService.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StatsStaffPatrolRecordDailyService.java @@ -46,5 +46,5 @@ public interface StatsStaffPatrolRecordDailyService extends BaseService patrolList(CustomerDataManageFormDTO formDTO); + List patrolList(CustomerDataManageFormDTO formDTO); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StatsStaffPatrolRecordDailyServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StatsStaffPatrolRecordDailyServiceImpl.java index 22a2496ffe..d24dcbe10c 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StatsStaffPatrolRecordDailyServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StatsStaffPatrolRecordDailyServiceImpl.java @@ -43,7 +43,7 @@ public class StatsStaffPatrolRecordDailyServiceImpl extends BaseServiceImpl patrolList(CustomerDataManageFormDTO formDTO) { + public List patrolList(CustomerDataManageFormDTO formDTO) { return baseDao.patrolList(formDTO); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/datastats/DatsStatsDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/datastats/DatsStatsDao.xml index 8df88699ac..dc6772b551 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/datastats/DatsStatsDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/datastats/DatsStatsDao.xml @@ -797,7 +797,7 @@ GROUP BY staff_id - SELECT t.orgId, t.dateId, t.userCount, t.partyMemberCount,t.residentCount FROM @@ -836,11 +836,8 @@ ) t GROUP BY t.orgId - - LIMIT #{pageNo}, #{pageSize} - - SELECT t.orgId, t.dateId, t.groupCount FROM @@ -879,11 +876,8 @@ ) t GROUP BY t.orgId - - LIMIT #{pageNo}, #{pageSize} - - SELECT t.orgId, t.dateId, t.topicCount FROM @@ -922,11 +916,8 @@ ) t GROUP BY t.orgId - - LIMIT #{pageNo}, #{pageSize} - - SELECT t.orgId, t.dateId, t.issueCount FROM @@ -965,11 +956,8 @@ ) t GROUP BY t.orgId - - LIMIT #{pageNo}, #{pageSize} - - SELECT t.orgId, t.dateId, t.projectCount, t.closedProjectCount FROM @@ -1008,9 +996,6 @@ ) t GROUP BY t.orgId - - LIMIT #{pageNo}, #{pageSize} - diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StatsStaffPatrolRecordDailyDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StatsStaffPatrolRecordDailyDao.xml index 1bcc9ef704..5c9bc40337 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StatsStaffPatrolRecordDailyDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StatsStaffPatrolRecordDailyDao.xml @@ -16,7 +16,7 @@ - SELECT t.dateId, t.orgId, t.staffId, sum(t.patrolCount),SUM(t.patrolDurationInteger) FROM (