From 54fb0b27f02b6d82fd7eb3c2bbf1f6cca99c9880 Mon Sep 17 00:00:00 2001 From: zxc <954985706@qq.com> Date: Mon, 29 Jun 2020 10:17:22 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/StatsGroupServiceImpl.java | 37 ++++++++----------- .../mapper/stats/FactGroupAgencyDailyDao.xml | 8 +--- 2 files changed, 18 insertions(+), 27 deletions(-) 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 7eba9840e7..8fc87943da 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 @@ -129,6 +129,13 @@ public class StatsGroupServiceImpl implements StatsGroupService { factGroupAgencyMonthlyService.insertAgencyGroupMonthly(lastDayAgency); } + /** + * @Description 网格小组 【机关-日】 数据统计处理 + * @param customerAgencyInfos + * @param timeDim + * @param customerId + * @author zxc + */ public List getAgencyGroupDaily(List customerAgencyInfos, DimIdGenerator.DimIdBean timeDim,String customerId){ if (customerAgencyInfos.size() == NumConstant.ZERO){ return new ArrayList<>(); @@ -143,10 +150,10 @@ public class StatsGroupServiceImpl implements StatsGroupService { agencyResult.setCustomerId(customerId); BeanUtils.copyProperties(timeDim,agencyResult); //机关下的所有网格(包括直属网格) - List allGrid = this.getAllGrid(agencyId); + List allGrid = this.getAllGrid(agencyId,customerId); String pidByAgencyId = dimAgencyService.getPidByAgencyId(agencyId); agencyResult.setPid(StringUtils.isBlank(pidByAgencyId)?"0":pidByAgencyId); - // TODO 1. 机关下有多少网格 + // 1. 机关下有多少网格 List customerGridIdList = customerGridService.getCustomerGridIdList(customerId, dateId); AtomicReference gridSize = new AtomicReference<>(0); if (customerGridIdList.size() != NumConstant.ZERO){ @@ -161,22 +168,19 @@ public class StatsGroupServiceImpl implements StatsGroupService { }else { agencyResult.setGridTotal(NumConstant.ZERO); } - - // TODO 2. 机关下有多少小组,只算 state = ‘approved’ + // 2. 机关下有多少小组,只算 state = ‘approved’ List agencyGroupTotalCount = groupDataService.getAgencyGroupTotalCount(allGrid,dateId); Integer groupCount = agencyGroupTotalCount.stream().collect(Collectors.summingInt(AgencyGroupTotalCountResultDTO::getGridGroupCount)); agencyResult.setGroupTotalCount(groupCount); - // TODO 3. 机关下所有组内人数和(不需要去重) 人员状态 != "removed" + // 3. 机关下所有组内人数和(不需要去重) 人员状态 != "removed" List agencyGridGroupPeopleTotal = groupDataService.selectAgencyGridGroupPeopleTotal(allGrid,dateId); Integer groupPeopleCount = agencyGridGroupPeopleTotal.stream().collect(Collectors.summingInt(AgencyGridGroupPeopleTotalResultDTO::getGridGroupPeopleTotal)); agencyResult.setGroupMemberTotalCount(groupPeopleCount); - - // TODO 4. 机关下小组平均人数 + // 4. 机关下小组平均人数 agencyResult.setGroupMemberAvgCount( agencyResult.getGroupTotalCount() == NumConstant.ZERO ? NumConstant.ZERO : agencyResult.getGroupMemberTotalCount()/agencyResult.getGroupTotalCount()); - - // TODO 5. 机关下小组人数中位数 小组最大(小)成员数、最多(少)成员小组ID + // 5. 机关下小组人数中位数 小组最大(小)成员数、最多(少)成员小组ID List agencyGridGroupPeople = groupDataService.selectAgencyEveryGroupPeopleCount(allGrid,dateId); List sorted = agencyGridGroupPeople.stream().sorted(Comparator.comparing(AgencyGridGroupPeopleResultDTO::getGroupCount).reversed()).collect(Collectors.toList()); Integer groupPeopleMedian; @@ -190,13 +194,12 @@ public class StatsGroupServiceImpl implements StatsGroupService { (sorted.get(sorted.size() / NumConstant.TWO - NumConstant.ONE).getGroupCount() + sorted.get(sorted.size() / 2).getGroupCount()) / 2 : sorted.get(sorted.size() / NumConstant.TWO).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. 机关下小组增量 + // 6. 机关下小组增量 List agencyGroupIncr = groupDataService.selectAgencyGroupIncr(allGrid, dateId); Integer groupIncr = agencyGroupIncr.stream().collect(Collectors.summingInt(AgencyGroupIncrResultDTO::getGroupIncr)); agencyResult.setGroupIncr(groupIncr); @@ -210,9 +213,9 @@ public class StatsGroupServiceImpl implements StatsGroupService { * @param agencyId * @author zxc */ - public List getAllGrid(String agencyId){ + public List getAllGrid(String agencyId,String customerId){ List result = new ArrayList<>(); - List allAgency = dimAgencyService.getAllAgency(null); + List allAgency = dimAgencyService.getAllAgency(customerId); Map> subGridOfAgency = new HashMap<>(); allAgency.forEach(agency -> { @@ -237,7 +240,6 @@ public class StatsGroupServiceImpl implements StatsGroupService { * @author zxc */ void initAgencyGridMap(String pid, AgencySubTreeDto agency, Map> subGridOfAgency){ - //向map中放入数据 if(subGridOfAgency.containsKey(pid)){ //包含key @@ -254,13 +256,10 @@ public class StatsGroupServiceImpl implements StatsGroupService { 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); @@ -285,8 +284,4 @@ public class StatsGroupServiceImpl implements StatsGroupService { return DimIdGenerator.getDimIdBean(result); } - public List getAgencyAllGrid(String customerId,String agencyId){ - - return null; - } } 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 d2ef1b2a30..ced5e75721 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 @@ -91,11 +91,7 @@ fact_group_agency_daily WHERE del_flag = '0' - AND DATE_FORMAT(date_id,'%Y%m') = #{monthId} - GROUP BY - AGENCY_ID - ORDER BY - DATE_ID DESC + AND date_id = (SELECT MAX(date_id) FROM fact_group_agency_daily WHERE del_flag = '0') @@ -107,7 +103,7 @@ fact_group_agency_daily WHERE del_flag = '0' - AND SUBSTRING( date_id, 1, 6 ) = #{monthId} + AND month_id = #{monthId} GROUP BY agency_id From 9627303f7726911e0cf92cafddd5a4c3ac7aa613 Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Mon, 29 Jun 2020 11:07:47 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=AE=AE=E9=A2=98=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/project/ProjectDao.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/project/ProjectDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/project/ProjectDao.xml index 7c20a18f4c..ed572b8f52 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/project/ProjectDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/project/ProjectDao.xml @@ -27,7 +27,7 @@ AND ORIGIN = 'issue' AND STATUS = 'closed' AND CUSTOMER_ID = #{customerId} - AND UPDATED_TIME #{date} + AND DATE_FORMAT(UPDATED_TIME, '%Y-%m-%d') #{date} GROUP BY AGENCY_ID, CLOSED_STATUS @@ -44,7 +44,7 @@ AND ORIGIN = 'issue' AND STATUS = 'closed' AND CUSTOMER_ID = #{customerId} - AND UPDATED_TIME = #{date} + AND DATE_FORMAT(UPDATED_TIME, '%Y-%m-%d') = #{date} GROUP BY AGENCY_ID, CLOSED_STATUS @@ -60,7 +60,7 @@ AND ORIGIN = 'issue' AND STATUS = 'closed' AND CUSTOMER_ID = #{customerId} - AND UPDATED_TIME #{date} + AND DATE_FORMAT(UPDATED_TIME, '%Y-%m-%d') #{date} \ No newline at end of file