diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/CustomerDataManageFormDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/CustomerDataManageFormDTO.java index d87beecab2..e707ef6d6c 100644 --- a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/CustomerDataManageFormDTO.java +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/form/CustomerDataManageFormDTO.java @@ -60,6 +60,8 @@ public class CustomerDataManageFormDTO implements Serializable { //组织或网格Id集合 private List idList; + //按起始时间还是结束时间查数据【start end】 + private String sourceType; //数据类型【组织agency 网格grid】 private String dataType; } 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 0948ea0f84..59be2dfd15 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 @@ -1960,34 +1960,46 @@ public class DataStatsServiceImpl implements DataStatsService { resultDTO.setTotal(idList.size()); //3.查询截止日期用户、群组、话题、议题、项目、巡查数据 + formDTO.setSourceType("end"); List userEnd = dataStatsDao.regUserList(formDTO); + HashMap uEndMap = new HashMap<>(); + userEnd.stream().forEach(u->uEndMap.put(u.getOrgId(),u)); List groupEnd = dataStatsDao.groupList(formDTO); + HashMap gEndMap = new HashMap<>(); + groupEnd.stream().forEach(u->gEndMap.put(u.getOrgId(),u)); List topicEnd = dataStatsDao.topicList(formDTO); + HashMap tEndMap = new HashMap<>(); + topicEnd.stream().forEach(u->tEndMap.put(u.getOrgId(),u)); List issueEnd = dataStatsDao.issueList(formDTO); + HashMap iEndMap = new HashMap<>(); + issueEnd.stream().forEach(u->iEndMap.put(u.getOrgId(),u)); List projectEnd = dataStatsDao.projectList(formDTO); + HashMap pEndMap = new HashMap<>(); + projectEnd.stream().forEach(u->pEndMap.put(u.getOrgId(),u)); //巡查数据不区分区间差值,只计算累计值,人员做去重处理且是有巡查记录的人员 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<>(); + HashMap uStartMap = new HashMap<>(); + HashMap gStartMap = new HashMap<>(); + HashMap tStartMap = new HashMap<>(); + HashMap iStartMap = new HashMap<>(); + HashMap pStartMap = new HashMap<>(); if ("Interval".equals(formDTO.getType())) { - userStart = dataStatsDao.regUserList(formDTO); - groupStart = dataStatsDao.groupList(formDTO); - topicStart = dataStatsDao.topicList(formDTO); - issueStart = dataStatsDao.issueList(formDTO); - projectStart = dataStatsDao.projectList(formDTO); + formDTO.setSourceType("start"); + List userStart = dataStatsDao.regUserList(formDTO); + userStart.stream().forEach(u->uStartMap.put(u.getOrgId(),u)); + List groupStart = dataStatsDao.groupList(formDTO); + groupStart.stream().forEach(u->gStartMap.put(u.getOrgId(),u)); + List topicStart = dataStatsDao.topicList(formDTO); + topicStart.stream().forEach(u->tStartMap.put(u.getOrgId(),u)); + List issueStart = dataStatsDao.issueList(formDTO); + issueStart.stream().forEach(u->iStartMap.put(u.getOrgId(),u)); + List projectStart = dataStatsDao.projectList(formDTO); + projectStart.stream().forEach(u->pStartMap.put(u.getOrgId(),u)); } //5.封装数据 - List finalUserStart = userStart; - List finalGroupStart = groupStart; - List finalTopicStart = topicStart; - List finalIssueStart = issueStart; - List finalProjectStart = projectStart; agencyGrid.getAgencyGridList().forEach(org -> { CustomerDataManageResultDTO.CustomerDataManage dto = new CustomerDataManageResultDTO.CustomerDataManage(); dto.setOrgId(org.getOrgId()); @@ -1995,75 +2007,45 @@ public class DataStatsServiceImpl implements DataStatsService { int user = 0; int resi = 0; int part = 0; - 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.CustomerDataManage s : finalUserStart) { - if (u.getOrgId().equals(s.getOrgId())) { - user = user - s.getUserCount(); - resi = resi - s.getResidentCount(); - part = part - s.getPartyMemberCount(); - } - } - } + if(uEndMap.containsKey(org.getOrgId())){ + user = uEndMap.get(org.getOrgId()).getUserCount(); + resi = uEndMap.get(org.getOrgId()).getResidentCount(); + part = uEndMap.get(org.getOrgId()).getPartyMemberCount(); + if ("Interval".equals(formDTO.getType())&&uStartMap.containsKey(org.getOrgId())) { + user = user - uStartMap.get(org.getOrgId()).getUserCount(); + resi = resi - uStartMap.get(org.getOrgId()).getResidentCount(); + part = part - uStartMap.get(org.getOrgId()).getPartyMemberCount(); } } int group = 0; - for (CustomerDataManageResultDTO.CustomerDataManage u : groupEnd) { - if (org.getOrgId().equals(u.getOrgId())) { - group = u.getGroupCount(); - if ("Interval".equals(formDTO.getType())) { - for (CustomerDataManageResultDTO.CustomerDataManage s : finalGroupStart) { - if (u.getOrgId().equals(s.getOrgId())) { - group = group - s.getGroupCount(); - } - } - } + if(gEndMap.containsKey(org.getOrgId())){ + group = gEndMap.get(org.getOrgId()).getGroupCount(); + if ("Interval".equals(formDTO.getType())&&gStartMap.containsKey(org.getOrgId())) { + group = group - gStartMap.get(org.getOrgId()).getGroupCount(); } } int topic = 0; - for (CustomerDataManageResultDTO.CustomerDataManage u : topicEnd) { - if (org.getOrgId().equals(u.getOrgId())) { - topic = u.getTopicCount(); - if ("Interval".equals(formDTO.getType())) { - for (CustomerDataManageResultDTO.CustomerDataManage s : finalTopicStart) { - if (u.getOrgId().equals(s.getOrgId())) { - topic = topic - s.getTopicCount(); - } - } - } + if(tEndMap.containsKey(org.getOrgId())){ + topic = tEndMap.get(org.getOrgId()).getTopicCount(); + if ("Interval".equals(formDTO.getType())&&tStartMap.containsKey(org.getOrgId())) { + topic = topic - tStartMap.get(org.getOrgId()).getTopicCount(); } } int issue = 0; - for (CustomerDataManageResultDTO.CustomerDataManage u : issueEnd) { - if (org.getOrgId().equals(u.getOrgId())) { - issue = u.getIssueCount(); - if ("Interval".equals(formDTO.getType())) { - for (CustomerDataManageResultDTO.CustomerDataManage s : finalIssueStart) { - if (u.getOrgId().equals(s.getOrgId())) { - issue = issue - s.getIssueCount(); - } - } - } + if(iEndMap.containsKey(org.getOrgId())){ + issue = iEndMap.get(org.getOrgId()).getIssueCount(); + if ("Interval".equals(formDTO.getType())&&iStartMap.containsKey(org.getOrgId())) { + issue = issue - iStartMap.get(org.getOrgId()).getIssueCount(); } } int project = 0; int closed = 0; - for (CustomerDataManageResultDTO.CustomerDataManage u : projectEnd) { - if (org.getOrgId().equals(u.getOrgId())) { - project = u.getProjectCount(); - closed = u.getClosedProjectCount(); - if ("Interval".equals(formDTO.getType())) { - for (CustomerDataManageResultDTO.CustomerDataManage s : finalProjectStart) { - if (u.getOrgId().equals(s.getOrgId())) { - project = project - s.getProjectCount(); - closed = closed - s.getClosedProjectCount(); - } - } - } + if(pEndMap.containsKey(org.getOrgId())){ + project = pEndMap.get(org.getOrgId()).getProjectCount(); + closed = pEndMap.get(org.getOrgId()).getClosedProjectCount(); + if ("Interval".equals(formDTO.getType())&&pStartMap.containsKey(org.getOrgId())) { + project = project - pStartMap.get(org.getOrgId()).getProjectCount(); + closed = closed - pStartMap.get(org.getOrgId()).getClosedProjectCount(); } } int patro = 0; 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 dc6772b551..0850b865c5 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 @@ -822,11 +822,11 @@ - + AND date_id =]]> #{startTime} ORDER BY date_id ASC - + AND date_id #{endTime} ORDER BY date_id DESC @@ -862,11 +862,11 @@ - + AND date_id =]]> #{startTime} ORDER BY date_id ASC - + AND date_id #{endTime} ORDER BY date_id DESC @@ -902,11 +902,11 @@ - + AND date_id =]]> #{startTime} ORDER BY date_id ASC - + AND date_id #{endTime} ORDER BY date_id DESC @@ -942,11 +942,11 @@ - + AND date_id =]]> #{startTime} ORDER BY date_id ASC - + AND date_id #{endTime} ORDER BY date_id DESC @@ -982,11 +982,11 @@ - + AND date_id =]]> #{startTime} ORDER BY date_id ASC - + AND date_id #{endTime} ORDER BY date_id DESC