Browse Source

Merge remote-tracking branch 'remotes/origin/dev_data_stats' into dev

dev_shibei_match
jianjun 5 years ago
parent
commit
de7436b07a
  1. 62
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/publicity/dto/result/FactTagUsedAgencyDTO.java
  2. 2
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/publicity/dto/result/FactTagViewedAgencyDTO.java
  3. 8
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/controller/publicity/PublicityController.java
  4. 2
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/dao/group/GroupDao.java
  5. 12
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/dao/publicity/PublicityDao.java
  6. 4
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/dao/topic/TopicDao.java
  7. 5
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/group/impl/GroupServiceImpl.java
  8. 8
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/publicity/PublicityService.java
  9. 4
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/publicity/impl/PublicityServiceImpl.java
  10. 6
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/topic/impl/TopicServiceImpl.java
  11. 1
      epmet-module/data-report/data-report-server/src/main/resources/mapper/group/GroupDao.xml
  12. 15
      epmet-module/data-report/data-report-server/src/main/resources/mapper/publicity/PublicityDao.xml
  13. 2
      epmet-module/data-report/data-report-server/src/main/resources/mapper/topic/TopicDao.xml
  14. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/group/GroupDataDao.java
  15. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/GroupDataService.java
  16. 32
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/group/impl/GroupDataServiceImpl.java
  17. 52
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java
  18. 16
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/group/GroupDataDao.xml

62
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}

2
epmet-module/data-report/data-report-client/src/main/java/com/epmet/publicity/dto/result/FactTagAgencyDTO.java → 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;

8
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<List<FactTagAgencyDTO>> tagviewed(@LoginUser TokenDto tokenDto, @RequestBody TagFormDTO formDTO) {
public Result<List<FactTagViewedAgencyDTO>> 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<List<FactTagAgencyDTO>>().ok(publicityService.tagviewed(tokenDto, pageSize, type));
return new Result<List<FactTagViewedAgencyDTO>>().ok(publicityService.tagviewed(tokenDto, pageSize, type));
}
/**
@ -82,7 +82,7 @@ public class PublicityController {
* @author jyy
*/
@PostMapping("tagused")
public Result<List<FactTagAgencyDTO>> tagused(@LoginUser TokenDto tokenDto, @RequestBody TagFormDTO formDTO) {
public Result<List<FactTagUsedAgencyDTO>> 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<List<FactTagAgencyDTO>>().ok(publicityService.tagused(tokenDto, pageSize, type));
return new Result<List<FactTagUsedAgencyDTO>>().ok(publicityService.tagused(tokenDto, pageSize, type));
}
/**

2
epmet-module/data-report/data-report-server/src/main/java/com/epmet/dao/group/GroupDao.java

@ -32,7 +32,7 @@ public interface GroupDao {
* @param
* @author zxc
*/
List<GroupSubAgencyResultDTO> getSubGroupCount();
List<GroupSubAgencyResultDTO> getSubGroupCount(@Param("customerId") String customerId);
/**
* @Description 获取直属网格下的小组数

12
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<FactTagAgencyDTO> getViewedMonthlyCountByTag(@Param("agencyId") String agencyId, @Param("monthId") String monthId, @Param("pageSize") Integer pageSize);
List<FactTagViewedAgencyDTO> getViewedMonthlyCountByTag(@Param("agencyId") String agencyId, @Param("monthId") String monthId, @Param("pageSize") Integer pageSize);
/**
* @Description 当季获取机关下获取每个标签阅读数量按照数量降序取前pagesize个
* @param agencyId,quarterId,pageSize 机关id展示数量
* @author zxc
*/
List<FactTagAgencyDTO> getViewedQuarterlyCountByTag(@Param("agencyId") String agencyId, @Param("quarterId") String quarterId, @Param("pageSize") Integer pageSize);
List<FactTagViewedAgencyDTO> getViewedQuarterlyCountByTag(@Param("agencyId") String agencyId, @Param("quarterId") String quarterId, @Param("pageSize") Integer pageSize);
/**
* @Description 当年获取机关下获取每个标签阅读数量按照数量降序取前pagesize个
* @param agencyId,yearId,pageSize 机关id展示数量
* @author zxc
*/
List<FactTagAgencyDTO> getViewedYearlyCountByTag(@Param("agencyId") String agencyId, @Param("yearId") String yearId, @Param("pageSize") Integer pageSize);
List<FactTagViewedAgencyDTO> getViewedYearlyCountByTag(@Param("agencyId") String agencyId, @Param("yearId") String yearId, @Param("pageSize") Integer pageSize);
/**
* @Description 当月获取机关下获取每个标签发文数量按照数量降序取前pagesize个
* @param agencyId,monthId,pageSize 机关id展示数量
* @author zxc
*/
List<FactTagAgencyDTO> getUsedMonthlyCountByTag(@Param("agencyId") String agencyId, @Param("monthId") String monthId, @Param("pageSize") Integer pageSize);
List<FactTagUsedAgencyDTO> getUsedMonthlyCountByTag(@Param("agencyId") String agencyId, @Param("monthId") String monthId, @Param("pageSize") Integer pageSize);
/**
* @Description 当季获取机关下获取每个标签发文数量按照数量降序取前pagesize个
* @param agencyId,quarterId,pageSize 机关id展示数量
* @author zxc
*/
List<FactTagAgencyDTO> getUsedQuarterlyCountByTag(@Param("agencyId") String agencyId, @Param("quarterId") String quarterId, @Param("pageSize") Integer pageSize);
List<FactTagUsedAgencyDTO> getUsedQuarterlyCountByTag(@Param("agencyId") String agencyId, @Param("quarterId") String quarterId, @Param("pageSize") Integer pageSize);
/**
* @Description 当年获取机关下每个标签发文数量按照数量降序取前pagesize个
* @param agencyId,yearId,pageSize 机关id展示数量
* @author zxc
*/
List<FactTagAgencyDTO> getUsedYearlyCountByTag(@Param("agencyId") String agencyId, @Param("yearId") String yearId, @Param("pageSize") Integer pageSize);
List<FactTagUsedAgencyDTO> getUsedYearlyCountByTag(@Param("agencyId") String agencyId, @Param("yearId") String yearId, @Param("pageSize") Integer pageSize);
/**
* @Description 当月下级机发文数

4
epmet-module/data-report/data-report-server/src/main/java/com/epmet/dao/topic/TopicDao.java

@ -54,7 +54,7 @@ public interface TopicDao {
* @param
* @author zxc
*/
List<TopicSubAgencyResultDTO> getAllTopicShiftedInfoLastDay();
List<TopicSubAgencyResultDTO> getAllTopicShiftedInfoLastDay(@Param("customerId") String customerId);
/**
* @Description 校验机关下是否存在直属网格
@ -75,7 +75,7 @@ public interface TopicDao {
* @param
* @author zxc
*/
List<TopicSubGridResultDTO> getGridAllTopicShiftedInfoLastDay();
List<TopicSubGridResultDTO> getGridAllTopicShiftedInfoLastDay(@Param("customerId")String customerId);
/**
* @Description 话题日增长

5
epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/group/impl/GroupServiceImpl.java

@ -50,9 +50,12 @@ public class GroupServiceImpl implements GroupService {
@Override
public List<GroupSubAgencyResultDTO> subAgency(TokenDto tokenDto) {
String agencyId = this.getLoginUserDetails(tokenDto);
String customerId = tokenDto.getCustomerId();
List<GroupSubAgencyResultDTO> result = new ArrayList<>();
//获取下级机关
List<SubAgencyResultDTO> subAgencyList = groupDao.getSubAgencyList(agencyId);
List<GroupSubAgencyResultDTO> subGroupCount = groupDao.getSubGroupCount();
//查询客户下
List<GroupSubAgencyResultDTO> subGroupCount = groupDao.getSubGroupCount(customerId);
if (subAgencyList.size()!= NumConstant.ZERO){
subGroupCount.forEach(group -> {
subAgencyList.forEach(subAgency -> {

8
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<FactTagAgencyDTO> tagviewed(TokenDto tokenDto, Integer pageSize, String type) ;
public List<FactTagViewedAgencyDTO> tagviewed(TokenDto tokenDto, Integer pageSize, String type) ;
/**
* @Description 宣传能力工作端宣传能力-获取发表最多的分类数据
* @param tokenDto,pageSize,type
* @author jyy
*/
public List<FactTagAgencyDTO> tagused(TokenDto tokenDto, Integer pageSize, String type) ;
public List<FactTagUsedAgencyDTO> tagused(TokenDto tokenDto, Integer pageSize, String type) ;
/**
* @param tokenDto type

4
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<FactTagAgencyDTO> tagviewed(TokenDto tokenDto, Integer pageSize, String type) {
public List<FactTagViewedAgencyDTO> 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<FactTagAgencyDTO> tagused(TokenDto tokenDto, Integer pageSize, String type) {
public List<FactTagUsedAgencyDTO> tagused(TokenDto tokenDto, Integer pageSize, String type) {
String agencyId = this.getLoginUserDetails(tokenDto);
Date date = new Date();
String strDate = DateUtils.format(date, DateUtils.DATE_PATTERN);

6
epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/topic/impl/TopicServiceImpl.java

@ -94,12 +94,13 @@ public class TopicServiceImpl implements TopicService {
@Override
public List<TopicSubGridResultDTO> topicSubGrid(TokenDto tokenDto) {
String agencyId = this.getLoginUserDetails(tokenDto);
String customerId = tokenDto.getCustomerId();
List<TopicSubGridResultDTO> result = new ArrayList<>();
List<TopicSubGridResultDTO> resultAll = new ArrayList<>();
List<String> subGridIdList = topicDao.getSubGridIdList(agencyId);
if (subGridIdList.size() != NumConstant.ZERO){
List<TopicSubGridResultDTO> gridAllTopicInfoLastDay = topicDao.getGridAllTopicInfoLastDay();
List<TopicSubGridResultDTO> gridAllTopicShiftedInfoLastDay = topicDao.getGridAllTopicShiftedInfoLastDay();
List<TopicSubGridResultDTO> gridAllTopicShiftedInfoLastDay = topicDao.getGridAllTopicShiftedInfoLastDay(customerId);
subGridIdList.forEach(gridId -> {
gridAllTopicInfoLastDay.forEach(gridTopic -> {
if (gridId.equals(gridTopic.getGridId())){
@ -135,13 +136,14 @@ public class TopicServiceImpl implements TopicService {
@Override
public List<TopicSubAgencyResultDTO> topicSubAgency(TokenDto tokenDto) {
String agencyId = this.getLoginUserDetails(tokenDto);
String customerId = tokenDto.getCustomerId();
List<TopicSubAgencyResultDTO> result = new ArrayList<>();
List<TopicSubAgencyResultDTO> resultAll = new ArrayList<>();
List<String> subAgencyIdList = topicDao.getSubAgencyIdList(agencyId);
//存在下级机关
if (subAgencyIdList.size() != NumConstant.ZERO){
List<TopicSubAgencyResultDTO> allTopicInfoLastDay = topicDao.getAllTopicInfoLastDay();
List<TopicSubAgencyResultDTO> allTopicShiftedInfoLastDay = topicDao.getAllTopicShiftedInfoLastDay();
List<TopicSubAgencyResultDTO> allTopicShiftedInfoLastDay = topicDao.getAllTopicShiftedInfoLastDay(customerId);
//话题状态为 已关闭、讨论中、已屏蔽
subAgencyIdList.forEach(agencyIdOne -> {
allTopicInfoLastDay.forEach(agency -> {

1
epmet-module/data-report/data-report-server/src/main/resources/mapper/group/GroupDao.xml

@ -43,6 +43,7 @@
AND da.del_flag = '0'
WHERE
fgad.del_flag = '0'
AND fgad.customer_id = #{customerId}
AND fgad.date_id = (SELECT MAX(date_id) FROM fact_group_agency_daily WHERE del_flag = '0')
</select>

15
epmet-module/data-report/data-report-server/src/main/resources/mapper/publicity/PublicityDao.xml

@ -14,7 +14,7 @@
</select>
<!-- 机关当月—每个标签阅读数量—前pageSize -->
<select id="getViewedMonthlyCountByTag" resultType="com.epmet.publicity.dto.result.FactTagAgencyDTO">
<select id="getViewedMonthlyCountByTag" resultType="com.epmet.publicity.dto.result.FactTagViewedAgencyDTO">
SELECT
tag_name AS name,
agency_id AS agencyId,
@ -29,7 +29,7 @@
</select>
<!-- 机关当季—每个标签阅读数量—前pageSize -->
<select id="getViewedQuarterlyCountByTag" resultType="com.epmet.publicity.dto.result.FactTagAgencyDTO">
<select id="getViewedQuarterlyCountByTag" resultType="com.epmet.publicity.dto.result.FactTagViewedAgencyDTO">
SELECT
tag_name AS name,
agency_id AS agencyId,
@ -44,7 +44,7 @@
</select>
<!-- 机关当年—每个标签阅读数量—前pageSize -->
<select id="getViewedYearlyCountByTag" resultType="com.epmet.publicity.dto.result.FactTagAgencyDTO">
<select id="getViewedYearlyCountByTag" resultType="com.epmet.publicity.dto.result.FactTagViewedAgencyDTO">
SELECT
tag_name AS name,
agency_id AS agencyId,
@ -59,7 +59,7 @@
</select>
<!-- 机关当月—每个标签发文数量—前pageSize -->
<select id="getUsedMonthlyCountByTag" resultType="com.epmet.publicity.dto.result.FactTagAgencyDTO">
<select id="getUsedMonthlyCountByTag" resultType="com.epmet.publicity.dto.result.FactTagUsedAgencyDTO">
SELECT
tag_name AS name,
agency_id AS agencyId,
@ -74,7 +74,7 @@
</select>
<!-- 机关当季—每个标签发文数量—前pageSize -->
<select id="getUsedQuarterlyCountByTag" resultType="com.epmet.publicity.dto.result.FactTagAgencyDTO">
<select id="getUsedQuarterlyCountByTag" resultType="com.epmet.publicity.dto.result.FactTagUsedAgencyDTO">
SELECT
tag_name AS name,
agency_id AS agencyId,
@ -89,7 +89,7 @@
</select>
<!-- 机关当年—每个标签发文数量—前pageSize -->
<select id="getUsedYearlyCountByTag" resultType="com.epmet.publicity.dto.result.FactTagAgencyDTO">
<select id="getUsedYearlyCountByTag" resultType="com.epmet.publicity.dto.result.FactTagUsedAgencyDTO">
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

2
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')
</select>
@ -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')
</select>

8
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<AgencyGroupTotalCountResultDTO> getAgencyGroupTotalCount(@Param("allGrid") List<String> allGrid,@Param("dateId")String dateId);
List<AgencyGroupTotalCountResultDTO> getAgencyGroupTotalCount(@Param("customerId") String customerId,@Param("dateId")String dateId);
/**
* @Description 查询机关下网格内的小组人数 待优化
* @param
* @author zxc
*/
List<AgencyGridGroupPeopleTotalResultDTO> selectAgencyGridGroupPeopleTotal(@Param("allGrid") List<String> allGrid,@Param("dateId")String dateId);
List<AgencyGridGroupPeopleTotalResultDTO> selectAgencyGridGroupPeopleTotal(@Param("customerId") String customerId,@Param("dateId")String dateId);
/**
* @Description 查询机关下每个小组的人数 待优化
* @param
* @author zxc
*/
List<AgencyGridGroupPeopleResultDTO> selectAgencyEveryGroupPeopleCount(@Param("allGrid") List<String> allGrid,@Param("dateId")String dateId);
List<AgencyGridGroupPeopleResultDTO> selectAgencyEveryGroupPeopleCount(@Param("customerId") String customerId,@Param("dateId")String dateId);
/**
* @Description 查询机关下的小组日增数 待优化
@ -72,7 +72,7 @@ public interface GroupDataDao {
* @param dateId
* @author zxc
*/
List<AgencyGroupIncrResultDTO> selectAgencyGroupIncr(@Param("allGrid") List<String> allGrid,@Param("dateId")String dateId);
List<AgencyGroupIncrResultDTO> selectAgencyGroupIncr(@Param("customerId") String customerId,@Param("dateId")String dateId);
/**
* @Description 查询机关下所有网格小组人数

10
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<AgencyGroupTotalCountResultDTO> getAgencyGroupTotalCount(List<String> allGrid,String dateId);
List<AgencyGroupTotalCountResultDTO> getAgencyGroupTotalCount(String customerId,String dateId);
/**
* @Description 查询机关下网格内的小组人数
* @param
* @author zxc
*/
List<AgencyGridGroupPeopleTotalResultDTO> selectAgencyGridGroupPeopleTotal(List<String> allGrid,String dateId);
List<AgencyGridGroupPeopleTotalResultDTO> selectAgencyGridGroupPeopleTotal(String customerId,String dateId);
/**
* @Description 查询机关下每个小组的人数
* @param
* @author zxc
*/
List<AgencyGridGroupPeopleResultDTO> selectAgencyEveryGroupPeopleCount(List<String> allGrid,String dateId);
List<AgencyGridGroupPeopleResultDTO> selectAgencyEveryGroupPeopleCount(String customerId,String dateId);
/**
* @Description 查询机关下的小组日增数
@ -46,7 +46,7 @@ public interface GroupDataService {
* @param yesterday
* @author zxc
*/
List<AgencyGroupIncrResultDTO> selectAgencyGroupIncr(List<String> allGrid,String yesterday);
List<AgencyGroupIncrResultDTO> selectAgencyGroupIncr(String customerId,String yesterday);
/**
* @Description 查询机关下所有网格小组人数

32
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<AgencyGroupTotalCountResultDTO> getAgencyGroupTotalCount(List<String> allGrid,String dateId){
if (allGrid.size() == NumConstant.ZERO){
public List<AgencyGroupTotalCountResultDTO> 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<AgencyGridGroupPeopleTotalResultDTO> selectAgencyGridGroupPeopleTotal(List<String> allGrid,String dateId) {
if (allGrid.size() == NumConstant.ZERO){
public List<AgencyGridGroupPeopleTotalResultDTO> 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<AgencyGridGroupPeopleResultDTO> selectAgencyEveryGroupPeopleCount(List<String> allGrid,String dateId){
if (allGrid.size() == NumConstant.ZERO){
public List<AgencyGridGroupPeopleResultDTO> 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<AgencyGroupIncrResultDTO> selectAgencyGroupIncr(List<String> allGrid,String dateId){
if (allGrid.size() == NumConstant.ZERO){
public List<AgencyGroupIncrResultDTO> selectAgencyGroupIncr(String customerId,String dateId){
/*if (allGrid.size() == NumConstant.ZERO){
return new ArrayList<>();
}
return groupDataDao.selectAgencyGroupIncr(allGrid, dateId);
}*/
return groupDataDao.selectAgencyGroupIncr(customerId, dateId);
}
/**

52
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java

@ -151,6 +151,7 @@ public class StatsGroupServiceImpl implements StatsGroupService {
BeanUtils.copyProperties(timeDim,agencyResult);
//机关下的所有网格(包括直属网格)
List<String> allGrid = this.getAllGrid(agencyId,customerId);
if (allGrid.size() != NumConstant.ZERO) {
String pidByAgencyId = dimAgencyService.getPidByAgencyId(agencyId);
agencyResult.setPid(StringUtils.isBlank(pidByAgencyId) ? "0" : pidByAgencyId);
// 1. 机关下有多少网格
@ -169,20 +170,44 @@ public class StatsGroupServiceImpl implements StatsGroupService {
agencyResult.setGridTotal(NumConstant.ZERO);
}
// 2. 机关下有多少小组,只算 state = ‘approved’
List<AgencyGroupTotalCountResultDTO> agencyGroupTotalCount = groupDataService.getAgencyGroupTotalCount(allGrid,dateId);
Integer groupCount = agencyGroupTotalCount.stream().collect(Collectors.summingInt(AgencyGroupTotalCountResultDTO::getGridGroupCount));
List<AgencyGroupTotalCountResultDTO> approvedResult = new ArrayList<>();
List<AgencyGroupTotalCountResultDTO> agencyGroupTotalCount = groupDataService.getAgencyGroupTotalCount(customerId, dateId);
allGrid.forEach(grid -> {
agencyGroupTotalCount.forEach(groupTotal -> {
if (grid.equals(groupTotal.getGridId())) {
approvedResult.add(groupTotal);
}
});
});
Integer groupCount = approvedResult.stream().collect(Collectors.summingInt(AgencyGroupTotalCountResultDTO::getGridGroupCount));
agencyResult.setGroupTotalCount(groupCount);
// 3. 机关下所有组内人数和(不需要去重) 人员状态 != "removed"
List<AgencyGridGroupPeopleTotalResultDTO> agencyGridGroupPeopleTotal = groupDataService.selectAgencyGridGroupPeopleTotal(allGrid,dateId);
Integer groupPeopleCount = agencyGridGroupPeopleTotal.stream().collect(Collectors.summingInt(AgencyGridGroupPeopleTotalResultDTO::getGridGroupPeopleTotal));
List<AgencyGridGroupPeopleTotalResultDTO> peopleTotal = new ArrayList<>();
List<AgencyGridGroupPeopleTotalResultDTO> 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<AgencyGridGroupPeopleResultDTO> agencyGridGroupPeople = groupDataService.selectAgencyEveryGroupPeopleCount(allGrid,dateId);
List<AgencyGridGroupPeopleResultDTO> sorted = agencyGridGroupPeople.stream().sorted(Comparator.comparing(AgencyGridGroupPeopleResultDTO::getGroupCount).reversed()).collect(Collectors.toList());
List<AgencyGridGroupPeopleResultDTO> groupPeople = new ArrayList<>();
List<AgencyGridGroupPeopleResultDTO> agencyGridGroupPeople = groupDataService.selectAgencyEveryGroupPeopleCount(customerId, dateId);
allGrid.forEach(grid -> {
agencyGridGroupPeople.forEach(group -> {
if (grid.equals(group.getGridId())) {
groupPeople.add(group);
}
});
});
List<AgencyGridGroupPeopleResultDTO> 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());
@ -200,9 +225,18 @@ public class StatsGroupServiceImpl implements StatsGroupService {
agencyResult.setMinMemberGroupId(sorted.get(sorted.size() - NumConstant.ONE).getGroupId());
}
// 6. 机关下小组增量
List<AgencyGroupIncrResultDTO> agencyGroupIncr = groupDataService.selectAgencyGroupIncr(allGrid, dateId);
Integer groupIncr = agencyGroupIncr.stream().collect(Collectors.summingInt(AgencyGroupIncrResultDTO::getGroupIncr));
agencyResult.setGroupIncr(groupIncr);
List<AgencyGroupIncrResultDTO> groupIncr = new ArrayList<>();
List<AgencyGroupIncrResultDTO> 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);
}
result.add(agencyResult);
});
return result;

16
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/group/GroupDataDao.xml

@ -73,7 +73,6 @@
<!-- 机关下——所有网格内的小组数量 -->
<select id="getAgencyGroupTotalCount" resultType="com.epmet.dto.group.result.AgencyGroupTotalCountResultDTO">
<foreach collection="allGrid" item="grid" separator=" UNION ALL ">
SELECT
grid_id AS gridId,
COUNT(*) AS gridGroupCount
@ -82,16 +81,14 @@
WHERE
DEL_FLAG = 0
AND state = 'approved'
AND grid_id = #{grid}
AND customer_id = #{customerId}
AND DATE_FORMAT(created_time,'%Y%m%d') <![CDATA[ <= ]]> #{dateId}
GROUP BY
grid_id
</foreach>
</select>
<!-- 查询机关下的网格内小组成员总数 , 人员状态不为 “removed” -->
<select id="selectAgencyGridGroupPeopleTotal" resultType="com.epmet.dto.group.result.AgencyGridGroupPeopleTotalResultDTO">
<foreach collection="allGrid" item="grid" separator=" UNION ALL ">
SELECT
rg.grid_id AS gridId,
COUNT(rgm.id) AS gridGroupPeopleTotal
@ -101,16 +98,14 @@
WHERE
rg.DEL_FLAG = 0
AND rg.state = 'approved'
AND rg.grid_id = #{grid}
AND rg.customer_id = #{customerId}
AND rgm.status != 'removed'
AND DATE_FORMAT(rgm.created_time,'%Y%m%d') <![CDATA[ <= ]]> #{dateId}
GROUP BY rg.grid_id
</foreach>
</select>
<!-- 查询机关下每个小组的人数 -->
<select id="selectAgencyEveryGroupPeopleCount" resultType="com.epmet.dto.group.result.AgencyGridGroupPeopleResultDTO">
<foreach collection="allGrid" item="grid" separator=" UNION ALL ">
SELECT
rg.grid_id AS gridId,
rg.id AS groupId,
@ -121,17 +116,15 @@
WHERE
rg.DEL_FLAG = 0
AND rg.state = 'approved'
AND rg.grid_id = #{grid}
AND rg.customer_id = #{customerId}
AND rgm.STATUS != 'removed'
AND DATE_FORMAT(rgm.created_time,'%Y%m%d') <![CDATA[ <= ]]> #{dateId}
GROUP BY
rgm.resi_group_id
</foreach>
</select>
<!-- 查询机关下的小组日增数 -->
<select id="selectAgencyGroupIncr" resultType="com.epmet.dto.group.result.AgencyGroupIncrResultDTO">
<foreach collection="allGrid" item="grid" separator=" UNION ALL ">
SELECT
COUNT(*) AS groupIncr,
grid_id AS gridId
@ -139,11 +132,10 @@
resi_group
WHERE
state = 'approved'
AND grid_id = #{grid}
AND customer_id = #{customerId}
AND DATE_FORMAT( CREATED_TIME, '%Y%m%d' ) = #{dateId}
GROUP BY
grid_id
</foreach>
</select>
<select id="getAgencyGrid" resultType="com.epmet.dto.group.result.GroupPeopleCountResultDTO">

Loading…
Cancel
Save