From 251db3d7a2fd93344e2a898f62e25fedd878b66c Mon Sep 17 00:00:00 2001 From: jiangyuying Date: Mon, 29 Jun 2020 13:31:40 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=AE=A3=E4=BC=A0=E8=83=BD=E5=8A=9B--type?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=92=8C=E4=B8=8B=E7=BA=A7=E6=9C=BA=E5=85=B3?= =?UTF-8?q?=E5=8E=BB=E9=99=A4self?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/result/FactTagUsedAgencyDTO.java | 62 +++++++++++++++++++ ...cyDTO.java => FactTagViewedAgencyDTO.java} | 2 +- .../publicity/PublicityController.java | 8 +-- .../com/epmet/dao/publicity/PublicityDao.java | 12 ++-- .../service/publicity/PublicityService.java | 8 +-- .../publicity/impl/PublicityServiceImpl.java | 4 +- .../mapper/publicity/PublicityDao.xml | 15 +++-- 7 files changed, 86 insertions(+), 25 deletions(-) create mode 100644 epmet-module/data-report/data-report-client/src/main/java/com/epmet/publicity/dto/result/FactTagUsedAgencyDTO.java rename epmet-module/data-report/data-report-client/src/main/java/com/epmet/publicity/dto/result/{FactTagAgencyDTO.java => FactTagViewedAgencyDTO.java} (95%) diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/publicity/dto/result/FactTagUsedAgencyDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/publicity/dto/result/FactTagUsedAgencyDTO.java new file mode 100644 index 0000000000..9f0ddc7b3e --- /dev/null +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/publicity/dto/result/FactTagUsedAgencyDTO.java @@ -0,0 +1,62 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.publicity.dto.result; + +import lombok.Data; + +import java.io.Serializable; + + +/** + * 文章引用标签阅读数量【机关】统计表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-06-19 + */ +@Data +public class FactTagUsedAgencyDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 标签名称 标签名称 + */ + private String name; + + /** + * 使用改标签的数量 + */ + private Integer value; + + /** + * 固定值:文章数量 + */ + private String type="文章数量"; + + /** + * 机关Id + */ + private String agencyId; + + /** + * 标签Id + */ + private String tagId; + + +} \ No newline at end of file diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/publicity/dto/result/FactTagAgencyDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/publicity/dto/result/FactTagViewedAgencyDTO.java similarity index 95% rename from epmet-module/data-report/data-report-client/src/main/java/com/epmet/publicity/dto/result/FactTagAgencyDTO.java rename to epmet-module/data-report/data-report-client/src/main/java/com/epmet/publicity/dto/result/FactTagViewedAgencyDTO.java index 35cbbc0390..31b5334303 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/publicity/dto/result/FactTagAgencyDTO.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/publicity/dto/result/FactTagViewedAgencyDTO.java @@ -30,7 +30,7 @@ import java.util.Date; * @since v1.0.0 2020-06-19 */ @Data -public class FactTagAgencyDTO implements Serializable { +public class FactTagViewedAgencyDTO implements Serializable { private static final long serialVersionUID = 1L; diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/controller/publicity/PublicityController.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/controller/publicity/PublicityController.java index 56d31b9d17..8612d82002 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/controller/publicity/PublicityController.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/controller/publicity/PublicityController.java @@ -65,7 +65,7 @@ public class PublicityController { * @author jyy */ @PostMapping("tagviewed") - public Result> tagviewed(@LoginUser TokenDto tokenDto, @RequestBody TagFormDTO formDTO) { + public Result> tagviewed(@LoginUser TokenDto tokenDto, @RequestBody TagFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO, TagFormDTO.GroupJava.class); Integer pageSize = formDTO.getPageSize(); @@ -73,7 +73,7 @@ public class PublicityController { pageSize = NumConstant.TEN; } String type = formDTO.getType(); - return new Result>().ok(publicityService.tagviewed(tokenDto, pageSize, type)); + return new Result>().ok(publicityService.tagviewed(tokenDto, pageSize, type)); } /** @@ -82,7 +82,7 @@ public class PublicityController { * @author jyy */ @PostMapping("tagused") - public Result> tagused(@LoginUser TokenDto tokenDto, @RequestBody TagFormDTO formDTO) { + public Result> tagused(@LoginUser TokenDto tokenDto, @RequestBody TagFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO, TagFormDTO.GroupJava.class); Integer pageSize = formDTO.getPageSize(); @@ -90,7 +90,7 @@ public class PublicityController { pageSize = NumConstant.TEN; } String type = formDTO.getType(); - return new Result>().ok(publicityService.tagused(tokenDto, pageSize, type)); + return new Result>().ok(publicityService.tagused(tokenDto, pageSize, type)); } /** diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/dao/publicity/PublicityDao.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/dao/publicity/PublicityDao.java index 33801156b9..cf62356848 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/dao/publicity/PublicityDao.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/dao/publicity/PublicityDao.java @@ -44,42 +44,42 @@ public interface PublicityDao { * @param agencyId,monthId,pageSize 机关id,月,展示数量 * @author zxc */ - List getViewedMonthlyCountByTag(@Param("agencyId") String agencyId, @Param("monthId") String monthId, @Param("pageSize") Integer pageSize); + List getViewedMonthlyCountByTag(@Param("agencyId") String agencyId, @Param("monthId") String monthId, @Param("pageSize") Integer pageSize); /** * @Description 当季———获取机关下,获取每个标签阅读数量,按照数量降序,取前pagesize个 * @param agencyId,quarterId,pageSize 机关id,季,展示数量 * @author zxc */ - List getViewedQuarterlyCountByTag(@Param("agencyId") String agencyId, @Param("quarterId") String quarterId, @Param("pageSize") Integer pageSize); + List getViewedQuarterlyCountByTag(@Param("agencyId") String agencyId, @Param("quarterId") String quarterId, @Param("pageSize") Integer pageSize); /** * @Description 当年———获取机关下,获取每个标签阅读数量,按照数量降序,取前pagesize个 * @param agencyId,yearId,pageSize 机关id,年,展示数量 * @author zxc */ - List getViewedYearlyCountByTag(@Param("agencyId") String agencyId, @Param("yearId") String yearId, @Param("pageSize") Integer pageSize); + List getViewedYearlyCountByTag(@Param("agencyId") String agencyId, @Param("yearId") String yearId, @Param("pageSize") Integer pageSize); /** * @Description 当月———获取机关下,获取每个标签发文数量,按照数量降序,取前pagesize个 * @param agencyId,monthId,pageSize 机关id,月,展示数量 * @author zxc */ - List getUsedMonthlyCountByTag(@Param("agencyId") String agencyId, @Param("monthId") String monthId, @Param("pageSize") Integer pageSize); + List getUsedMonthlyCountByTag(@Param("agencyId") String agencyId, @Param("monthId") String monthId, @Param("pageSize") Integer pageSize); /** * @Description 当季———获取机关下,获取每个标签发文数量,按照数量降序,取前pagesize个 * @param agencyId,quarterId,pageSize 机关id,季,展示数量 * @author zxc */ - List getUsedQuarterlyCountByTag(@Param("agencyId") String agencyId, @Param("quarterId") String quarterId, @Param("pageSize") Integer pageSize); + List getUsedQuarterlyCountByTag(@Param("agencyId") String agencyId, @Param("quarterId") String quarterId, @Param("pageSize") Integer pageSize); /** * @Description 当年———获取机关下,每个标签发文数量,按照数量降序,取前pagesize个 * @param agencyId,yearId,pageSize 机关id,年,展示数量 * @author zxc */ - List getUsedYearlyCountByTag(@Param("agencyId") String agencyId, @Param("yearId") String yearId, @Param("pageSize") Integer pageSize); + List getUsedYearlyCountByTag(@Param("agencyId") String agencyId, @Param("yearId") String yearId, @Param("pageSize") Integer pageSize); /** * @Description 当月———下级机发文数 diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/publicity/PublicityService.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/publicity/PublicityService.java index 9eccb5b29f..bec823066c 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/publicity/PublicityService.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/publicity/PublicityService.java @@ -18,12 +18,8 @@ package com.epmet.service.publicity; import com.epmet.commons.tools.security.dto.TokenDto; -import com.epmet.commons.tools.utils.DateUtils; -import com.epmet.commons.tools.utils.Result; import com.epmet.publicity.dto.result.*; -import org.apache.commons.lang3.StringUtils; -import java.util.Date; import java.util.List; /** @@ -46,14 +42,14 @@ public interface PublicityService { * @param tokenDto,formDTO * @author jyy */ - public List tagviewed(TokenDto tokenDto, Integer pageSize, String type) ; + public List tagviewed(TokenDto tokenDto, Integer pageSize, String type) ; /** * @Description 宣传能力—工作端—宣传能力-获取发表最多的分类数据 * @param tokenDto,pageSize,type * @author jyy */ - public List tagused(TokenDto tokenDto, Integer pageSize, String type) ; + public List tagused(TokenDto tokenDto, Integer pageSize, String type) ; /** * @param tokenDto type diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/publicity/impl/PublicityServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/publicity/impl/PublicityServiceImpl.java index c5e94f7633..990cc97916 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/publicity/impl/PublicityServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/publicity/impl/PublicityServiceImpl.java @@ -64,7 +64,7 @@ public class PublicityServiceImpl implements PublicityService { * @author jyy */ @Override - public List tagviewed(TokenDto tokenDto, Integer pageSize, String type) { + public List tagviewed(TokenDto tokenDto, Integer pageSize, String type) { String agencyId = this.getLoginUserDetails(tokenDto); Date date = new Date(); String strDate = DateUtils.format(date, DateUtils.DATE_PATTERN); @@ -92,7 +92,7 @@ public class PublicityServiceImpl implements PublicityService { * @author jyy */ @Override - public List tagused(TokenDto tokenDto, Integer pageSize, String type) { + public List tagused(TokenDto tokenDto, Integer pageSize, String type) { String agencyId = this.getLoginUserDetails(tokenDto); Date date = new Date(); String strDate = DateUtils.format(date, DateUtils.DATE_PATTERN); diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/publicity/PublicityDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/publicity/PublicityDao.xml index c7d032eb43..bb4b53fd65 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/publicity/PublicityDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/publicity/PublicityDao.xml @@ -14,7 +14,7 @@ - SELECT tag_name AS name, agency_id AS agencyId, @@ -29,7 +29,7 @@ - SELECT tag_name AS name, agency_id AS agencyId, @@ -44,7 +44,7 @@ - SELECT tag_name AS name, agency_id AS agencyId, @@ -59,7 +59,7 @@ - SELECT tag_name AS name, agency_id AS agencyId, @@ -74,7 +74,7 @@ - SELECT tag_name AS name, agency_id AS agencyId, @@ -89,7 +89,7 @@ - SELECT tag_name AS name, agency_id AS agencyId, @@ -116,6 +116,7 @@ where pub.agency_id = agency.id AND pub.PID =#{agencyId} + AND pub.agency_id not LIKE '%self%' AND pub.month_id=#{monthId} GROUP BY pub.agency_id ORDER BY value DESC,agencyId ASC @@ -135,6 +136,7 @@ where pub.agency_id = agency.id AND pub.PID =#{agencyId} + AND pub.agency_id not LIKE '%self%' AND pub.quarter_id=#{quarterId} GROUP BY pub.agency_id ORDER BY value DESC,agencyId ASC @@ -153,6 +155,7 @@ where pub.agency_id = agency.id AND pub.PID =#{agencyId} + AND pub.agency_id not LIKE '%self%' AND pub.year_id=#{yearId} GROUP BY pub.agency_id ORDER BY value DESC,agencyId ASC From 1c4798d086a7e3fa2a85a68354fe7a21b3b44fe4 Mon Sep 17 00:00:00 2001 From: zxc <954985706@qq.com> Date: Mon, 29 Jun 2020 13:45:16 +0800 Subject: [PATCH 2/3] =?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 --- .../com/epmet/dao/group/GroupDataDao.java | 8 +- .../group/impl/GroupDataServiceImpl.java | 32 ++--- .../service/impl/StatsGroupServiceImpl.java | 130 +++++++++++------- .../resources/mapper/group/GroupDataDao.xml | 16 +-- 4 files changed, 106 insertions(+), 80 deletions(-) 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 28703e70e9..db1bc08318 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 @@ -50,21 +50,21 @@ public interface GroupDataDao { * @param * @author zxc */ - List getAgencyGroupTotalCount(@Param("allGrid") List allGrid,@Param("dateId")String dateId); + List getAgencyGroupTotalCount(@Param("customerId") String customerId,@Param("dateId")String dateId); /** * @Description 查询机关下网格内的小组人数 【待优化】 * @param * @author zxc */ - List selectAgencyGridGroupPeopleTotal(@Param("allGrid") List allGrid,@Param("dateId")String dateId); + List selectAgencyGridGroupPeopleTotal(@Param("customerId") String customerId,@Param("dateId")String dateId); /** * @Description 查询机关下每个小组的人数 【待优化】 * @param * @author zxc */ - List selectAgencyEveryGroupPeopleCount(@Param("allGrid") List allGrid,@Param("dateId")String dateId); + List selectAgencyEveryGroupPeopleCount(@Param("customerId") String customerId,@Param("dateId")String dateId); /** * @Description 查询机关下的小组日增数 【待优化】 @@ -72,7 +72,7 @@ public interface GroupDataDao { * @param dateId * @author zxc */ - List selectAgencyGroupIncr(@Param("allGrid") List allGrid,@Param("dateId")String dateId); + List selectAgencyGroupIncr(@Param("customerId") String customerId,@Param("dateId")String dateId); /** * @Description 查询机关下所有网格小组人数 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 1cdc3acdcf..cd4a68f97a 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 @@ -133,11 +133,11 @@ public class GroupDataServiceImpl implements GroupDataService { * @param * @author zxc */ - public List getAgencyGroupTotalCount(List allGrid,String dateId){ - if (allGrid.size() == NumConstant.ZERO){ + public List getAgencyGroupTotalCount(String customerId,String dateId){ + /*if (allGrid.size() == NumConstant.ZERO){ return new ArrayList<>(); - } - return groupDataDao.getAgencyGroupTotalCount(allGrid,dateId); + }*/ + return groupDataDao.getAgencyGroupTotalCount(customerId,dateId); } /** @@ -146,11 +146,11 @@ public class GroupDataServiceImpl implements GroupDataService { * @author zxc */ @Override - public List selectAgencyGridGroupPeopleTotal(List allGrid,String dateId) { - if (allGrid.size() == NumConstant.ZERO){ + public List selectAgencyGridGroupPeopleTotal(String customerId,String dateId) { + /*if (allGrid.size() == NumConstant.ZERO){ return new ArrayList<>(); - } - return groupDataDao.selectAgencyGridGroupPeopleTotal(allGrid,dateId); + }*/ + return groupDataDao.selectAgencyGridGroupPeopleTotal(customerId,dateId); } /** @@ -158,11 +158,11 @@ public class GroupDataServiceImpl implements GroupDataService { * @param * @author zxc */ - public List selectAgencyEveryGroupPeopleCount(List allGrid,String dateId){ - if (allGrid.size() == NumConstant.ZERO){ + public List selectAgencyEveryGroupPeopleCount(String customerId,String dateId){ + /*if (allGrid.size() == NumConstant.ZERO){ return new ArrayList<>(); - } - return groupDataDao.selectAgencyEveryGroupPeopleCount(allGrid,dateId); + }*/ + return groupDataDao.selectAgencyEveryGroupPeopleCount(customerId,dateId); } /** @@ -171,11 +171,11 @@ public class GroupDataServiceImpl implements GroupDataService { * @param dateId * @author zxc */ - public List selectAgencyGroupIncr(List allGrid,String dateId){ - if (allGrid.size() == NumConstant.ZERO){ + public List selectAgencyGroupIncr(String customerId,String dateId){ + /*if (allGrid.size() == NumConstant.ZERO){ return new ArrayList<>(); - } - return groupDataDao.selectAgencyGroupIncr(allGrid, dateId); + }*/ + return groupDataDao.selectAgencyGroupIncr(customerId, dateId); } /** 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 8fc87943da..5e86bc0bbb 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 @@ -151,58 +151,92 @@ public class StatsGroupServiceImpl implements StatsGroupService { BeanUtils.copyProperties(timeDim,agencyResult); //机关下的所有网格(包括直属网格) List allGrid = this.getAllGrid(agencyId,customerId); - String pidByAgencyId = dimAgencyService.getPidByAgencyId(agencyId); - agencyResult.setPid(StringUtils.isBlank(pidByAgencyId)?"0":pidByAgencyId); - // 1. 机关下有多少网格 - List customerGridIdList = customerGridService.getCustomerGridIdList(customerId, dateId); - AtomicReference gridSize = new AtomicReference<>(0); - if (customerGridIdList.size() != NumConstant.ZERO){ - customerGridIdList.forEach(gridId -> { - allGrid.forEach(allAgencyGrid -> { - if (gridId.getGridId().equals(allAgencyGrid)){ - gridSize.updateAndGet(v -> v + NumConstant.ONE); + if (allGrid.size() != NumConstant.ZERO) { + String pidByAgencyId = dimAgencyService.getPidByAgencyId(agencyId); + agencyResult.setPid(StringUtils.isBlank(pidByAgencyId) ? "0" : pidByAgencyId); + // 1. 机关下有多少网格 + List customerGridIdList = customerGridService.getCustomerGridIdList(customerId, dateId); + AtomicReference gridSize = new AtomicReference<>(0); + if (customerGridIdList.size() != NumConstant.ZERO) { + customerGridIdList.forEach(gridId -> { + allGrid.forEach(allAgencyGrid -> { + if (gridId.getGridId().equals(allAgencyGrid)) { + gridSize.updateAndGet(v -> v + NumConstant.ONE); + } + }); + }); + agencyResult.setGridTotal(gridSize.get()); + } else { + agencyResult.setGridTotal(NumConstant.ZERO); + } + // 2. 机关下有多少小组,只算 state = ‘approved’ + List approvedResult = new ArrayList<>(); + List agencyGroupTotalCount = groupDataService.getAgencyGroupTotalCount(customerId, dateId); + allGrid.forEach(grid -> { + agencyGroupTotalCount.forEach(groupTotal -> { + if (grid.equals(groupTotal.getGridId())) { + approvedResult.add(groupTotal); } }); }); - agencyResult.setGridTotal(gridSize.get()); - }else { - agencyResult.setGridTotal(NumConstant.ZERO); - } - // 2. 机关下有多少小组,只算 state = ‘approved’ - List agencyGroupTotalCount = groupDataService.getAgencyGroupTotalCount(allGrid,dateId); - Integer groupCount = agencyGroupTotalCount.stream().collect(Collectors.summingInt(AgencyGroupTotalCountResultDTO::getGridGroupCount)); - agencyResult.setGroupTotalCount(groupCount); - // 3. 机关下所有组内人数和(不需要去重) 人员状态 != "removed" - List agencyGridGroupPeopleTotal = groupDataService.selectAgencyGridGroupPeopleTotal(allGrid,dateId); - Integer groupPeopleCount = agencyGridGroupPeopleTotal.stream().collect(Collectors.summingInt(AgencyGridGroupPeopleTotalResultDTO::getGridGroupPeopleTotal)); - agencyResult.setGroupMemberTotalCount(groupPeopleCount); - // 4. 机关下小组平均人数 - agencyResult.setGroupMemberAvgCount( - agencyResult.getGroupTotalCount() == NumConstant.ZERO ? NumConstant.ZERO : - agencyResult.getGroupMemberTotalCount()/agencyResult.getGroupTotalCount()); - // 5. 机关下小组人数中位数 小组最大(小)成员数、最多(少)成员小组ID - List agencyGridGroupPeople = groupDataService.selectAgencyEveryGroupPeopleCount(allGrid,dateId); - 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() % NumConstant.TWO == NumConstant.ZERO ? - (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()); + Integer groupCount = approvedResult.stream().collect(Collectors.summingInt(AgencyGroupTotalCountResultDTO::getGridGroupCount)); + agencyResult.setGroupTotalCount(groupCount); + // 3. 机关下所有组内人数和(不需要去重) 人员状态 != "removed" + List peopleTotal = new ArrayList<>(); + List agencyGridGroupPeopleTotal = groupDataService.selectAgencyGridGroupPeopleTotal(customerId, dateId); + allGrid.forEach(grid -> { + agencyGridGroupPeopleTotal.forEach(people -> { + if (grid.equals(people.getGridId())) { + peopleTotal.add(people); + } + }); + }); + Integer groupPeopleCount = peopleTotal.stream().collect(Collectors.summingInt(AgencyGridGroupPeopleTotalResultDTO::getGridGroupPeopleTotal)); + agencyResult.setGroupMemberTotalCount(groupPeopleCount); + // 4. 机关下小组平均人数 + agencyResult.setGroupMemberAvgCount( + agencyResult.getGroupTotalCount() == NumConstant.ZERO ? NumConstant.ZERO : + agencyResult.getGroupMemberTotalCount() / agencyResult.getGroupTotalCount()); + // 5. 机关下小组人数中位数 小组最大(小)成员数、最多(少)成员小组ID + List groupPeople = new ArrayList<>(); + List agencyGridGroupPeople = groupDataService.selectAgencyEveryGroupPeopleCount(customerId, dateId); + allGrid.forEach(grid -> { + agencyGridGroupPeople.forEach(group -> { + if (grid.equals(group.getGridId())) { + groupPeople.add(group); + } + }); + }); + List sorted = groupPeople.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() % NumConstant.TWO == NumConstant.ZERO ? + (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()); + } + // 6. 机关下小组增量 + List groupIncr = new ArrayList<>(); + List agencyGroupIncr = groupDataService.selectAgencyGroupIncr(customerId, dateId); + allGrid.forEach(grid -> { + agencyGroupIncr.forEach(incr -> { + if (grid.equals(incr.getGridId())) { + groupIncr.add(incr); + } + }); + }); + Integer groupIncrCount = groupIncr.stream().collect(Collectors.summingInt(AgencyGroupIncrResultDTO::getGroupIncr)); + agencyResult.setGroupIncr(groupIncrCount); } - // 6. 机关下小组增量 - List agencyGroupIncr = groupDataService.selectAgencyGroupIncr(allGrid, dateId); - Integer groupIncr = agencyGroupIncr.stream().collect(Collectors.summingInt(AgencyGroupIncrResultDTO::getGroupIncr)); - agencyResult.setGroupIncr(groupIncr); result.add(agencyResult); }); return result; 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 968ca9d83d..0ed8f428fe 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 @@ -73,7 +73,6 @@ diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/topic/TopicDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/topic/TopicDao.xml index 00f845829a..29ddddc6c6 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/topic/TopicDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/topic/TopicDao.xml @@ -94,6 +94,7 @@ LEFT JOIN dim_agency da ON da.id = ftiad.agency_id AND da.del_flag = '0' WHERE ftiad.del_flag = '0' + AND ftiad.customer_id = #{customerId} AND ftiad.date_id = (SELECT MAX(date_id) AS dateId FROM fact_topic_issue_agency_daily WHERE del_flag = '0') @@ -138,6 +139,7 @@ LEFT JOIN dim_grid da ON da.id = ftiad.grid_id AND da.del_flag = '0' WHERE ftiad.del_flag = '0' + AND ftiad.customer_id = #{customerId} AND ftiad.date_id = (SELECT MAX(date_id) AS dateId FROM fact_topic_issue_grid_daily WHERE del_flag = '0') 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 a6d61a756e..82588801a7 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 @@ -21,24 +21,24 @@ public interface GroupDataService { /** * @Description 获取同级机关下网格下的小组数量 - * @param allGrid + * @param * @author zxc */ - List getAgencyGroupTotalCount(List allGrid,String dateId); + List getAgencyGroupTotalCount(String customerId,String dateId); /** * @Description 查询机关下网格内的小组人数 * @param * @author zxc */ - List selectAgencyGridGroupPeopleTotal(List allGrid,String dateId); + List selectAgencyGridGroupPeopleTotal(String customerId,String dateId); /** * @Description 查询机关下每个小组的人数 * @param * @author zxc */ - List selectAgencyEveryGroupPeopleCount(List allGrid,String dateId); + List selectAgencyEveryGroupPeopleCount(String customerId,String dateId); /** * @Description 查询机关下的小组日增数 @@ -46,7 +46,7 @@ public interface GroupDataService { * @param yesterday * @author zxc */ - List selectAgencyGroupIncr(List allGrid,String yesterday); + List selectAgencyGroupIncr(String customerId,String yesterday); /** * @Description 查询机关下所有网格小组人数