Browse Source

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

dev_shibei_match
sunyuchao 5 years ago
parent
commit
91717f29e9
  1. 2
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/publicity/dto/result/FactTagAgencyDTO.java
  2. 7
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/topic/dto/result/TopicSubAgencyResultDTO.java
  3. 7
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/topic/dto/result/TopicSubGridResultDTO.java
  4. 6
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/topic/dto/result/TopicSummaryInfoResultDTO.java
  5. 10
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/topic/dto/result/TopicSummaryResultDTO.java
  6. 2
      epmet-module/data-report/data-report-server/deploy/docker-compose-dev.yml
  7. 4
      epmet-module/data-report/data-report-server/pom.xml
  8. 5
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/group/impl/GroupServiceImpl.java
  9. 62
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/topic/impl/TopicServiceImpl.java
  10. 42
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/user/impl/UserAnalysisServiceImpl.java
  11. 4
      epmet-module/data-report/data-report-server/src/main/resources/mapper/group/GroupDao.xml
  12. 21
      epmet-module/data-report/data-report-server/src/main/resources/mapper/publicity/PublicityDao.xml
  13. 15
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsIssueController.java
  14. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/issue/StatsIssueDao.java
  15. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/Issue/IssueService.java
  16. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/Issue/impl/IssueServiceImpl.java
  17. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsIssueService.java
  18. 55
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsIssueServiceImpl.java
  19. 102
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/issue/StatsIssueDao.xml

2
epmet-module/data-report/data-report-client/src/main/java/com/epmet/publicity/dto/result/FactTagAgencyDTO.java

@ -47,7 +47,7 @@ public class FactTagAgencyDTO implements Serializable {
/** /**
* 固定值文章数量 * 固定值文章数量
*/ */
private String type="文章数量"; private String type="阅读次数";
/** /**
* 机关Id * 机关Id

7
epmet-module/data-report/data-report-client/src/main/java/com/epmet/topic/dto/result/TopicSubAgencyResultDTO.java

@ -1,5 +1,6 @@
package com.epmet.topic.dto.result; package com.epmet.topic.dto.result;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
@ -32,4 +33,10 @@ public class TopicSubAgencyResultDTO implements Serializable {
* 机关Id * 机关Id
*/ */
private String agencyId; private String agencyId;
/**
* 排序
*/
@JsonIgnore
private Integer sort;
} }

7
epmet-module/data-report/data-report-client/src/main/java/com/epmet/topic/dto/result/TopicSubGridResultDTO.java

@ -1,5 +1,6 @@
package com.epmet.topic.dto.result; package com.epmet.topic.dto.result;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
@ -32,4 +33,10 @@ public class TopicSubGridResultDTO implements Serializable {
* 网格Id * 网格Id
*/ */
private String gridId; private String gridId;
/**
* 排序
*/
@JsonIgnore
private Integer sort;
} }

6
epmet-module/data-report/data-report-client/src/main/java/com/epmet/topic/dto/result/TopicSummaryInfoResultDTO.java

@ -16,15 +16,15 @@ public class TopicSummaryInfoResultDTO implements Serializable {
/** /**
* 名称 * 名称
*/ */
private String name; private String name = "";
/** /**
* *
*/ */
private Integer value; private Integer value = 0;
/** /**
* 百分比 * 百分比
*/ */
private String ratio; private String ratio = "0.0%";
} }

10
epmet-module/data-report/data-report-client/src/main/java/com/epmet/topic/dto/result/TopicSummaryResultDTO.java

@ -16,27 +16,27 @@ public class TopicSummaryResultDTO implements Serializable {
/** /**
* 话题总数 * 话题总数
*/ */
private Integer topicTotalCount; private Integer topicTotalCount = 0;
/** /**
* 讨论中话题数量 * 讨论中话题数量
*/ */
private Integer talkingTotalCount; private Integer talkingTotalCount = 0;
/** /**
* 已关闭话题数量 * 已关闭话题数量
*/ */
private Integer closedTotalCount; private Integer closedTotalCount = 0;
/** /**
* 已屏蔽话题数量 * 已屏蔽话题数量
*/ */
private Integer shieldedTotalCount; private Integer shieldedTotalCount = 0;
/** /**
* 话题已转议题数量 * 话题已转议题数量
*/ */
private Integer shiftedTotalCount; private Integer shiftedTotalCount = 0;
/** /**
* 数据更新至 时间 * 数据更新至 时间

2
epmet-module/data-report/data-report-server/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services: services:
data-report-server: data-report-server:
container_name: data-report-server-dev container_name: data-report-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/data-report-server:0.3.6 image: 192.168.1.130:10080/epmet-cloud-dev/data-report-server:0.3.7
ports: ports:
- "8109:8109" - "8109:8109"
network_mode: host # 使用现有网络 network_mode: host # 使用现有网络

4
epmet-module/data-report/data-report-server/pom.xml

@ -3,7 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<version>0.3.6</version> <version>0.3.7</version>
<artifactId>data-report-server</artifactId> <artifactId>data-report-server</artifactId>
<parent> <parent>
@ -112,7 +112,7 @@
<spring.redis.password>123456</spring.redis.password> <spring.redis.password>123456</spring.redis.password>
<!-- nacos --> <!-- nacos -->
<nacos.register-enabled>true</nacos.register-enabled> <nacos.register-enabled>false</nacos.register-enabled>
<nacos.server-addr>122.152.200.70:8848</nacos.server-addr> <nacos.server-addr>122.152.200.70:8848</nacos.server-addr>
<nacos.discovery.namespace>fcd6fc8f-ca3a-4b01-8026-2b05cdc5976b</nacos.discovery.namespace> <nacos.discovery.namespace>fcd6fc8f-ca3a-4b01-8026-2b05cdc5976b</nacos.discovery.namespace>
<nacos.config.namespace></nacos.config.namespace> <nacos.config.namespace></nacos.config.namespace>

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

@ -15,7 +15,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* @Author zxc * @Author zxc
@ -60,7 +62,8 @@ public class GroupServiceImpl implements GroupService {
} }
}); });
}); });
return result; //倒序
return result.stream().sorted(Comparator.comparing(GroupSubAgencyResultDTO::getValue).reversed()).collect(Collectors.toList());
} }
return new ArrayList<>(); return new ArrayList<>();
} }

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

@ -14,9 +14,9 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.text.DecimalFormat;
import java.util.Comparator; import java.time.LocalDate;
import java.util.List; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -41,6 +41,7 @@ public class TopicServiceImpl implements TopicService {
TopicSummaryResultDTO result = new TopicSummaryResultDTO(); TopicSummaryResultDTO result = new TopicSummaryResultDTO();
String agencyId = this.getLoginUserDetails(tokenDto); String agencyId = this.getLoginUserDetails(tokenDto);
List<TopicStatusResultDTO> topicStatus = topicDao.getTopicStatus(agencyId); List<TopicStatusResultDTO> topicStatus = topicDao.getTopicStatus(agencyId);
result.setDeadline(LocalDate.now().minusDays(NumConstant.ONE).toString());
if (topicStatus.size() != NumConstant.ZERO){ if (topicStatus.size() != NumConstant.ZERO){
topicStatus.forEach(topic -> { topicStatus.forEach(topic -> {
if (topic.getTopicStatus().equals(TopicConstant.DISCUSSING)){ if (topic.getTopicStatus().equals(TopicConstant.DISCUSSING)){
@ -52,11 +53,11 @@ public class TopicServiceImpl implements TopicService {
} }
}); });
result.setTopicTotalCount(topicStatus.stream().collect(Collectors.summingInt(TopicStatusResultDTO::getTopicCount))); result.setTopicTotalCount(topicStatus.stream().collect(Collectors.summingInt(TopicStatusResultDTO::getTopicCount)));
} TopicShiftedCountResultDTO shiftedCount = topicDao.getShiftedCount(agencyId);
TopicShiftedCountResultDTO shiftedCount = topicDao.getShiftedCount(agencyId); if (shiftedCount != null){
if (shiftedCount != null){ result.setShiftedTotalCount(shiftedCount.getShiftedIssueCount());
result.setShiftedTotalCount(shiftedCount.getShiftedIssueCount()); result.setDeadline(shiftedCount.getDeadline());
result.setDeadline(shiftedCount.getDeadline()); }
} }
return result; return result;
} }
@ -94,6 +95,7 @@ public class TopicServiceImpl implements TopicService {
public List<TopicSubGridResultDTO> topicSubGrid(TokenDto tokenDto) { public List<TopicSubGridResultDTO> topicSubGrid(TokenDto tokenDto) {
String agencyId = this.getLoginUserDetails(tokenDto); String agencyId = this.getLoginUserDetails(tokenDto);
List<TopicSubGridResultDTO> result = new ArrayList<>(); List<TopicSubGridResultDTO> result = new ArrayList<>();
List<TopicSubGridResultDTO> resultAll = new ArrayList<>();
List<String> subGridIdList = topicDao.getSubGridIdList(agencyId); List<String> subGridIdList = topicDao.getSubGridIdList(agencyId);
if (subGridIdList.size() != NumConstant.ZERO){ if (subGridIdList.size() != NumConstant.ZERO){
List<TopicSubGridResultDTO> gridAllTopicInfoLastDay = topicDao.getGridAllTopicInfoLastDay(); List<TopicSubGridResultDTO> gridAllTopicInfoLastDay = topicDao.getGridAllTopicInfoLastDay();
@ -110,7 +112,17 @@ public class TopicServiceImpl implements TopicService {
} }
}); });
}); });
return result; Map<String, List<TopicSubGridResultDTO>> collect = result.stream().collect(Collectors.groupingBy(TopicSubGridResultDTO::getGridId));
Set<Map.Entry<String, List<TopicSubGridResultDTO>>> entries = collect.entrySet();
entries.forEach(entry -> {
List<TopicSubGridResultDTO> value = entry.getValue();
Integer sort = value.stream().collect(Collectors.summingInt(TopicSubGridResultDTO::getValue));
value.forEach(v -> {
v.setSort(sort);
resultAll.add(v);
});
});
return resultAll.stream().sorted(Comparator.comparing(TopicSubGridResultDTO::getSort).reversed()).collect(Collectors.toList());
} }
return new ArrayList<>(); return new ArrayList<>();
} }
@ -124,6 +136,7 @@ public class TopicServiceImpl implements TopicService {
public List<TopicSubAgencyResultDTO> topicSubAgency(TokenDto tokenDto) { public List<TopicSubAgencyResultDTO> topicSubAgency(TokenDto tokenDto) {
String agencyId = this.getLoginUserDetails(tokenDto); String agencyId = this.getLoginUserDetails(tokenDto);
List<TopicSubAgencyResultDTO> result = new ArrayList<>(); List<TopicSubAgencyResultDTO> result = new ArrayList<>();
List<TopicSubAgencyResultDTO> resultAll = new ArrayList<>();
List<String> subAgencyIdList = topicDao.getSubAgencyIdList(agencyId); List<String> subAgencyIdList = topicDao.getSubAgencyIdList(agencyId);
//存在下级机关 //存在下级机关
if (subAgencyIdList.size() != NumConstant.ZERO){ if (subAgencyIdList.size() != NumConstant.ZERO){
@ -142,7 +155,17 @@ public class TopicServiceImpl implements TopicService {
} }
}); });
}); });
return result; Map<String, List<TopicSubAgencyResultDTO>> collect = result.stream().collect(Collectors.groupingBy(TopicSubAgencyResultDTO::getAgencyId));
Set<Map.Entry<String, List<TopicSubAgencyResultDTO>>> entries = collect.entrySet();
entries.forEach(entry -> {
List<TopicSubAgencyResultDTO> value = entry.getValue();
Integer sort = value.stream().collect(Collectors.summingInt(TopicSubAgencyResultDTO::getValue));
value.forEach(v -> {
v.setSort(sort);
resultAll.add(v);
});
});
return resultAll.stream().sorted(Comparator.comparing(TopicSubAgencyResultDTO::getSort).reversed()).collect(Collectors.toList());
} }
//不存在 //不存在
return new ArrayList<>(); return new ArrayList<>();
@ -158,14 +181,17 @@ public class TopicServiceImpl implements TopicService {
String agencyId = this.getLoginUserDetails(tokenDto); String agencyId = this.getLoginUserDetails(tokenDto);
List<TopicSummaryInfoResultDTO> topicSummaryInfo = topicDao.topicSummaryInfo(agencyId); List<TopicSummaryInfoResultDTO> topicSummaryInfo = topicDao.topicSummaryInfo(agencyId);
TopicShiftedCountResultDTO shiftedCount = topicDao.getShiftedCount(agencyId); TopicShiftedCountResultDTO shiftedCount = topicDao.getShiftedCount(agencyId);
Integer collect = topicSummaryInfo.stream().collect(Collectors.summingInt(TopicSummaryInfoResultDTO::getValue)); if (topicSummaryInfo.size() != NumConstant.ZERO && shiftedCount != null) {
String ratio; Integer collect = topicSummaryInfo.stream().collect(Collectors.summingInt(TopicSummaryInfoResultDTO::getValue));
ratio = collect == NumConstant.ZERO ? NumConstant.ZERO + TopicConstant.RATIO : ((float)shiftedCount.getShiftedIssueCount() / (float)collect) * NumConstant.ONE_HUNDRED + TopicConstant.RATIO; DecimalFormat decimalFormat = new DecimalFormat(".00");
TopicSummaryInfoResultDTO result = new TopicSummaryInfoResultDTO(); String ratio;
result.setName(TopicConstant.SHIFTED); ratio = collect == NumConstant.ZERO ? NumConstant.ZERO + TopicConstant.RATIO : decimalFormat.format(((float) shiftedCount.getShiftedIssueCount() / (float) collect) * NumConstant.ONE_HUNDRED) + TopicConstant.RATIO;
result.setRatio(ratio); TopicSummaryInfoResultDTO result = new TopicSummaryInfoResultDTO();
result.setValue(shiftedCount.getShiftedIssueCount()); result.setName(TopicConstant.SHIFTED);
topicSummaryInfo.add(result); result.setRatio(ratio);
result.setValue(shiftedCount.getShiftedIssueCount());
topicSummaryInfo.add(result);
}
return topicSummaryInfo; return topicSummaryInfo;
} }

42
epmet-module/data-report/data-report-server/src/main/java/com/epmet/service/user/impl/UserAnalysisServiceImpl.java

@ -28,9 +28,9 @@ import org.springframework.util.CollectionUtils;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 组织能力用户相关接口 * 组织能力用户相关接口
@ -169,10 +169,23 @@ public class UserAnalysisServiceImpl implements UserAnalysisService {
logger.error(String.format("各机关注册用户数缺少记录:date_id=%s,agencyId=%s",formDTO.getDateId(),dimInitResultDto.getAgencyId())); logger.error(String.format("各机关注册用户数缺少记录:date_id=%s,agencyId=%s",formDTO.getDateId(),dimInitResultDto.getAgencyId()));
} }
} }
logger.info("排序前");
for(UserSubAgencyResultDTO m:dimList){
logger.info("机关名:"+m.getName()+",总数="+m.getTotal());
}
//返回集合按照total降序排序 //返回集合按照total降序排序
List<UserSubAgencyResultDTO> returnList = dimList.stream().sorted(Comparator.comparing(UserSubAgencyResultDTO::getTotal)) Collections.sort(dimList, new Comparator<UserSubAgencyResultDTO>() {
.collect(Collectors.toList()); @Override
return returnList; public int compare(UserSubAgencyResultDTO o1, UserSubAgencyResultDTO o2) {
int i=o2.getTotal()-o1.getTotal();//降序
return i;
}
});
logger.info("排序后");
for(UserSubAgencyResultDTO m:dimList){
logger.info("机关名:"+m.getName()+",总数="+m.getTotal());
}
return dimList;
} }
private List<UserSubAgencyResultDTO> initUserSubAgencyResultDTO(String myAgencyId) { private List<UserSubAgencyResultDTO> initUserSubAgencyResultDTO(String myAgencyId) {
@ -273,10 +286,23 @@ public class UserAnalysisServiceImpl implements UserAnalysisService {
logger.error(String.format("直属网格注册用户数缺少记录:date_id=%s,gridId=%s",formDTO.getDateId(),dimInitResultDto.getGridId())); logger.error(String.format("直属网格注册用户数缺少记录:date_id=%s,gridId=%s",formDTO.getDateId(),dimInitResultDto.getGridId()));
} }
} }
logger.info("排序前");
for(UserSubGridResultDTO m:dimList){
logger.info("网格名:"+m.getName()+",总数="+m.getTotal());
}
//返回集合按照total降序排序 //返回集合按照total降序排序
List<UserSubGridResultDTO> returnList = dimList.stream().sorted(Comparator.comparing(UserSubGridResultDTO::getTotal)) Collections.sort(dimList, new Comparator<UserSubGridResultDTO>() {
.collect(Collectors.toList()); @Override
return returnList; public int compare(UserSubGridResultDTO o1, UserSubGridResultDTO o2) {
int i=o2.getTotal()-o1.getTotal();//降序
return i;
}
});
logger.info("排序后");
for(UserSubGridResultDTO m:dimList){
logger.info("网格名:"+m.getName()+",总数="+m.getTotal());
}
return dimList;
} }
private List<UserSubGridResultDTO> initUserSubGridResultDTO(String myAgencyId) { private List<UserSubGridResultDTO> initUserSubGridResultDTO(String myAgencyId) {
@ -399,7 +425,7 @@ public class UserAnalysisServiceImpl implements UserAnalysisService {
for(UserIncrTrendResDTO userIncrTrendResDTO:list){ for(UserIncrTrendResDTO userIncrTrendResDTO:list){
String date=""; String date="";
if(UserAnalysisConstant.DAY_TYPE.equals(formDTO.getType())){ if(UserAnalysisConstant.DAY_TYPE.equals(formDTO.getType())){
date=DateUtils.getxAxisDatePattern(userIncrTrendResDTO.getDateIdOrMonthId(),"."); date=DateUtils.getxAxisDatePattern(userIncrTrendResDTO.getDateIdOrMonthId(),"/");
}else if(UserAnalysisConstant.MONTH_TYPE.equals(formDTO.getType())){ }else if(UserAnalysisConstant.MONTH_TYPE.equals(formDTO.getType())){
date=DateUtils.getxAxisDatePattern(userIncrTrendResDTO.getDateIdOrMonthId(),"/"); date=DateUtils.getxAxisDatePattern(userIncrTrendResDTO.getDateIdOrMonthId(),"/");
} }

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

@ -28,6 +28,7 @@
WHERE WHERE
del_flag = '0' del_flag = '0'
AND pid = #{agencyId} AND pid = #{agencyId}
AND agency_dim_type = 'all'
</select> </select>
<!--获取下级机关的小组数--> <!--获取下级机关的小组数-->
@ -59,6 +60,7 @@
fggd.del_flag = '0' fggd.del_flag = '0'
AND fggd.agency_id = #{agencyId} AND fggd.agency_id = #{agencyId}
AND fggd.date_id = (SELECT MAX(date_id) FROM fact_group_grid_daily WHERE del_flag = '0') AND fggd.date_id = (SELECT MAX(date_id) FROM fact_group_grid_daily WHERE del_flag = '0')
ORDER BY value DESC
</select> </select>
<!--小组数量 日增长--> <!--小组数量 日增长-->
@ -89,7 +91,7 @@
del_flag = '0' del_flag = '0'
AND agency_id = #{agencyId} AND agency_id = #{agencyId}
ORDER BY ORDER BY
month_id DESC month_id DESC, value DESC
LIMIT 12 LIMIT 12
</select> </select>

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

@ -24,7 +24,7 @@
where agency_id = #{agencyId} where agency_id = #{agencyId}
AND month_id = #{monthId} AND month_id = #{monthId}
GROUP BY TAG_ID GROUP BY TAG_ID
ORDER BY value DESC ORDER BY value DESC ,tagId ASC
LIMIT #{pageSize} LIMIT #{pageSize}
</select> </select>
@ -39,7 +39,7 @@
where agency_id = #{agencyId} where agency_id = #{agencyId}
AND quarter_id = #{quarterId} AND quarter_id = #{quarterId}
GROUP BY TAG_ID GROUP BY TAG_ID
ORDER BY value DESC ORDER BY value DESC ,tagId ASC
LIMIT #{pageSize} LIMIT #{pageSize}
</select> </select>
@ -54,7 +54,7 @@
where agency_id = #{agencyId} where agency_id = #{agencyId}
AND year_id = #{yearId} AND year_id = #{yearId}
GROUP BY tag_id GROUP BY tag_id
ORDER BY value DESC ORDER BY value DESC ,tagId ASC
LIMIT #{pageSize} LIMIT #{pageSize}
</select> </select>
@ -69,7 +69,7 @@
where agency_id = #{agencyId} where agency_id = #{agencyId}
AND month_id = #{monthId} AND month_id = #{monthId}
GROUP BY TAG_ID GROUP BY TAG_ID
ORDER BY value DESC ORDER BY value DESC ,tagId ASC
LIMIT #{pageSize} LIMIT #{pageSize}
</select> </select>
@ -84,7 +84,7 @@
where agency_id = #{agencyId} where agency_id = #{agencyId}
AND quarter_id = #{quarterId} AND quarter_id = #{quarterId}
GROUP BY TAG_ID GROUP BY TAG_ID
ORDER BY value DESC ORDER BY value DESC ,tagId ASC
LIMIT #{pageSize} LIMIT #{pageSize}
</select> </select>
@ -99,7 +99,7 @@
where agency_id = #{agencyId} where agency_id = #{agencyId}
AND year_id = #{yearId} AND year_id = #{yearId}
GROUP BY tag_id GROUP BY tag_id
ORDER BY value DESC ORDER BY value DESC ,tagId ASC
LIMIT #{pageSize} LIMIT #{pageSize}
</select> </select>
@ -118,6 +118,7 @@
AND pub.PID =#{agencyId} AND pub.PID =#{agencyId}
AND pub.month_id=#{monthId} AND pub.month_id=#{monthId}
GROUP BY pub.agency_id GROUP BY pub.agency_id
ORDER BY value DESC,agencyId ASC
</select> </select>
@ -136,6 +137,7 @@
AND pub.PID =#{agencyId} AND pub.PID =#{agencyId}
AND pub.quarter_id=#{quarterId} AND pub.quarter_id=#{quarterId}
GROUP BY pub.agency_id GROUP BY pub.agency_id
ORDER BY value DESC,agencyId ASC
</select> </select>
<!-- 当年——下级机发文数:机关名称、机关id、发文数量、上级机关id --> <!-- 当年——下级机发文数:机关名称、机关id、发文数量、上级机关id -->
@ -153,6 +155,7 @@
AND pub.PID =#{agencyId} AND pub.PID =#{agencyId}
AND pub.year_id=#{yearId} AND pub.year_id=#{yearId}
GROUP BY pub.agency_id GROUP BY pub.agency_id
ORDER BY value DESC,agencyId ASC
</select> </select>
<!-- 当月——下级部门文数:部门名称、机关id、发文数量、部门id --> <!-- 当月——下级部门文数:部门名称、机关id、发文数量、部门id -->
@ -170,6 +173,7 @@
AND pub.agency_id =#{agencyId} AND pub.agency_id =#{agencyId}
AND pub.month_id=#{monthId} AND pub.month_id=#{monthId}
GROUP BY pub.department_id GROUP BY pub.department_id
ORDER BY value DESC,departmentId ASC
</select> </select>
@ -188,6 +192,7 @@
AND pub.agency_id =#{agencyId} AND pub.agency_id =#{agencyId}
AND pub.quarter_id=#{quarterId} AND pub.quarter_id=#{quarterId}
GROUP BY pub.department_id GROUP BY pub.department_id
ORDER BY value DESC,departmentId ASC
</select> </select>
<!-- 当年——下级部门文数:部门名称、机关id、发文数量、部门id --> <!-- 当年——下级部门文数:部门名称、机关id、发文数量、部门id -->
@ -205,6 +210,7 @@
AND pub.agency_id =#{agencyId} AND pub.agency_id =#{agencyId}
AND pub.year_id=#{yearId} AND pub.year_id=#{yearId}
GROUP BY pub.department_id GROUP BY pub.department_id
ORDER BY value DESC,departmentId ASC
</select> </select>
<!-- 当月——下级网格文数:网格名称、机关id、发文数量、网格id --> <!-- 当月——下级网格文数:网格名称、机关id、发文数量、网格id -->
@ -222,6 +228,7 @@
AND pub.agency_id = #{agencyId} AND pub.agency_id = #{agencyId}
AND pub.month_id=#{monthId} AND pub.month_id=#{monthId}
GROUP BY pub.grid_id GROUP BY pub.grid_id
ORDER BY value DESC,gridId ASC
</select> </select>
@ -240,6 +247,7 @@
AND pub.agency_id = #{agencyId} AND pub.agency_id = #{agencyId}
AND pub.quarter_id=#{quarterId} AND pub.quarter_id=#{quarterId}
GROUP BY pub.grid_id GROUP BY pub.grid_id
ORDER BY value DESC,gridId ASC
</select> </select>
<!-- 当年——下级网格文数:网格名称、机关id、发文数量、网格id --> <!-- 当年——下级网格文数:网格名称、机关id、发文数量、网格id -->
@ -257,6 +265,7 @@
AND pub.agency_id = #{agencyId} AND pub.agency_id = #{agencyId}
AND pub.year_id = #{yearId} AND pub.year_id = #{yearId}
GROUP BY pub.grid_id GROUP BY pub.grid_id
ORDER BY value DESC,gridId ASC
</select> </select>
</mapper> </mapper>

15
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsIssueController.java

@ -1,12 +1,17 @@
package com.epmet.controller; package com.epmet.controller;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.service.StatsIssueService; import com.epmet.service.StatsIssueService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.io.Serializable;
/** /**
* @author zhaoqifeng * @author zhaoqifeng
* @dscription * @dscription
@ -30,4 +35,14 @@ public class StatsIssueController {
statsIssueService.agencyGridIssueStats(); statsIssueService.agencyGridIssueStats();
return new Result(); return new Result();
} }
@Data
private static class StatsDate implements Serializable {
private static final long serialVersionUID = 149723067011918433L;
private String date;
}
@PostMapping("date")
public Result agencyGridIssueStatsOfDate(@RequestBody StatsDate statsDate) {
statsIssueService.agencyGridIssueStatsOfDate(DateUtils.parse(statsDate.getDate(), DateUtils.DATE_PATTERN));
return new Result();
}
} }

3
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/issue/StatsIssueDao.java

@ -18,11 +18,12 @@ public interface StatsIssueDao extends BaseDao<IssueEntity> {
* 获取当前日期组织下议题统计结果 * 获取当前日期组织下议题统计结果
* *
* @param customerId * @param customerId
* @param date
* @return java.util.List<com.epmet.dto.issue.IssueAgencyDTO> * @return java.util.List<com.epmet.dto.issue.IssueAgencyDTO>
* @author zhaoqifeng * @author zhaoqifeng
* @date 2020/6/17 14:13 * @date 2020/6/17 14:13
*/ */
List<IssueAgencyDTO> selectAgencyIssueTotal(@Param("customerId") String customerId); List<IssueAgencyDTO> selectAgencyIssueTotal(@Param("customerId") String customerId, @Param("date") String date);
/** /**
* 获取当前日期组织下议题增量 * 获取当前日期组织下议题增量

3
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/Issue/IssueService.java

@ -18,9 +18,10 @@ public interface IssueService {
* @author zhaoqifeng * @author zhaoqifeng
* @date 2020/6/17 16:04 * @date 2020/6/17 16:04
* @param customerId * @param customerId
* @param date
* @return java.util.List<com.epmet.dto.issue.IssueAgencyDTO> * @return java.util.List<com.epmet.dto.issue.IssueAgencyDTO>
*/ */
List<IssueAgencyDTO> getAgencyIssueTotal(String customerId); List<IssueAgencyDTO> getAgencyIssueTotal(String customerId, String date);
/** /**
* 获取当前日期组织下议题增量 * 获取当前日期组织下议题增量

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/Issue/impl/IssueServiceImpl.java

@ -26,8 +26,8 @@ public class IssueServiceImpl implements IssueService {
private StatsIssueDao statsIssueDao; private StatsIssueDao statsIssueDao;
@Override @Override
public List<IssueAgencyDTO> getAgencyIssueTotal(String customerId) { public List<IssueAgencyDTO> getAgencyIssueTotal(String customerId, String date) {
List<IssueAgencyDTO> list = statsIssueDao.selectAgencyIssueTotal(customerId); List<IssueAgencyDTO> list = statsIssueDao.selectAgencyIssueTotal(customerId, date);
list.forEach(dto -> { list.forEach(dto -> {
String[] pIds = dto.getPIds().split(":"); String[] pIds = dto.getPIds().split(":");
dto.setPId(pIds[pIds.length - 2]); dto.setPId(pIds[pIds.length - 2]);

9
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsIssueService.java

@ -17,6 +17,15 @@ public interface StatsIssueService {
*/ */
void agencyGridIssueStats(); void agencyGridIssueStats();
/**
* 指定日期议题统计
* @author zhaoqifeng
* @date 2020/6/28 11:01
* @param date
* @return void
*/
void agencyGridIssueStatsOfDate(Date date);
/** /**
* 机关下议题日统计 * 机关下议题日统计
* @author zhaoqifeng * @author zhaoqifeng

55
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsIssueServiceImpl.java

@ -20,6 +20,7 @@ import com.epmet.service.project.ProjectService;
import com.epmet.service.stats.*; import com.epmet.service.stats.*;
import com.epmet.util.DimIdGenerator; import com.epmet.util.DimIdGenerator;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import oracle.sql.DATE;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -66,6 +67,28 @@ public class StatsIssueServiceImpl implements StatsIssueService {
//获取当前日期前一天 //获取当前日期前一天
Date date = DateUtils.getBeforeDay(new Date()); Date date = DateUtils.getBeforeDay(new Date());
customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize);
if (!CollectionUtils.isEmpty(customerIdList)) {
for (String customerId : customerIdList) {
//遍历统计每一个客户数据
try {
customerStats(customerId, date);
} catch(Exception e) {
log.error(String.format(ProjectConstant.STATS_FAILED_PREFIX, "agencyGridIssueStats", customerId, DateUtils.format(date),
e.getMessage()));
}
}
}
} while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize);
}
@Override
public void agencyGridIssueStatsOfDate(Date date) {
int pageNo = 1;
int pageSize = 100;
List<String> customerIdList = null;
do {
//获取当前日期前一天
customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize);
if (!CollectionUtils.isEmpty(customerIdList)) { if (!CollectionUtils.isEmpty(customerIdList)) {
for (String customerId : customerIdList) { for (String customerId : customerIdList) {
//遍历统计每一个客户数据 //遍历统计每一个客户数据
@ -109,7 +132,7 @@ public class StatsIssueServiceImpl implements StatsIssueService {
//获取当前客户下所有机关 //获取当前客户下所有机关
List<DimAgencyDTO> agencyList = dimAgencyService.getDimAgencyList(dimAgencyDTO); List<DimAgencyDTO> agencyList = dimAgencyService.getDimAgencyList(dimAgencyDTO);
//获取机关下议题各种状态的数目统计 //获取机关下议题各种状态的数目统计
List<IssueAgencyDTO> issueAgencyTotalList = issueService.getAgencyIssueTotal(customerId); List<IssueAgencyDTO> issueAgencyTotalList = issueService.getAgencyIssueTotal(customerId, dateString);
//获取机关下议题各种状态的数目增量 //获取机关下议题各种状态的数目增量
List<IssueAgencyDTO> issueAgencyIncList = issueService.getAgencyIssueInc(customerId, dateString); List<IssueAgencyDTO> issueAgencyIncList = issueService.getAgencyIssueInc(customerId, dateString);
//获取机关下已关闭议题统计 //获取机关下已关闭议题统计
@ -129,10 +152,10 @@ public class StatsIssueServiceImpl implements StatsIssueService {
entity.setPid(agency.getPid()); entity.setPid(agency.getPid());
String pIds; String pIds;
if (null == agency.getPids() || agency.getPids().isEmpty()) { if (NumConstant.ZERO_STR.equals(agency.getPid())) {
pIds = agency.getPid().concat(":").concat(agency.getId()); pIds = agency.getPid();
} else { } else {
pIds = ("0").concat(":").concat(agency.getPids()).concat(":").concat(agency.getId()); pIds = agency.getPids().concat(":").concat(agency.getId());
} }
//总量统计 //总量统计
saveTotal(issueAgencyTotalList, agency, entity, pIds); saveTotal(issueAgencyTotalList, agency, entity, pIds);
@ -172,7 +195,7 @@ public class StatsIssueServiceImpl implements StatsIssueService {
//获取当前客户下所有机关 //获取当前客户下所有机关
List<DimAgencyDTO> agencyList = dimAgencyService.getDimAgencyList(dimAgencyDTO); List<DimAgencyDTO> agencyList = dimAgencyService.getDimAgencyList(dimAgencyDTO);
//获取机关下议题各种状态的数目统计 //获取机关下议题各种状态的数目统计
List<IssueAgencyDTO> issueAgencyTotalList = issueService.getAgencyIssueTotal(customerId); List<IssueAgencyDTO> issueAgencyTotalList = issueService.getAgencyIssueTotal(customerId, dateString);
//获取机关下已关闭议题统计 //获取机关下已关闭议题统计
List<IssueAgencyDTO> issueAgencyClosedTotalList = issueService.getAgencyClosedIssueTotal(customerId, dateString); List<IssueAgencyDTO> issueAgencyClosedTotalList = issueService.getAgencyClosedIssueTotal(customerId, dateString);
//已结案项目统计 //已结案项目统计
@ -185,10 +208,10 @@ public class StatsIssueServiceImpl implements StatsIssueService {
FactIssueAgencyMonthlyEntity monthly = initIssueAgencyMonthly(dimId); FactIssueAgencyMonthlyEntity monthly = initIssueAgencyMonthly(dimId);
String pIds; String pIds;
if (null == agency.getPids() || agency.getPids().isEmpty()) { if (NumConstant.ZERO_STR.equals(agency.getPid())) {
pIds = agency.getPid().concat(":").concat(agency.getId()); pIds = agency.getPid();
} else { } else {
pIds = ("0").concat(":").concat(agency.getPids()).concat(":").concat(agency.getId()); pIds = agency.getPids().concat(":").concat(agency.getId());
} }
//总量统计 //总量统计
saveTotal(issueAgencyTotalList, agency, daily, pIds); saveTotal(issueAgencyTotalList, agency, daily, pIds);
@ -550,6 +573,8 @@ public class StatsIssueServiceImpl implements StatsIssueService {
int shiftInc = NumConstant.ZERO; int shiftInc = NumConstant.ZERO;
//已关闭增量 //已关闭增量
int closedInc = NumConstant.ZERO; int closedInc = NumConstant.ZERO;
//议题增量
int issueInc = NumConstant.ZERO;
for (IssueGridDTO dto : list) { for (IssueGridDTO dto : list) {
if (grid.getId().equals(dto.getGridId())) { if (grid.getId().equals(dto.getGridId())) {
if (IssueConstant.VOTING.equals(dto.getStatus())) { if (IssueConstant.VOTING.equals(dto.getStatus())) {
@ -558,13 +583,15 @@ public class StatsIssueServiceImpl implements StatsIssueService {
} else if (IssueConstant.SHIFT_PROJECT.equals(dto.getStatus())) { } else if (IssueConstant.SHIFT_PROJECT.equals(dto.getStatus())) {
//已转项目议题数量 //已转项目议题数量
shiftInc = dto.getCount(); shiftInc = dto.getCount();
} else { } else if(IssueConstant.CLOSED.equals(dto.getStatus())) {
//已关闭议题数量 //已关闭议题数量
closedInc = dto.getCount(); closedInc = dto.getCount();
} else {
issueInc = dto.getCount();
} }
} }
} }
int issueInc = votingInc + shiftInc + closedInc;
entity.setVotingIncr(votingInc); entity.setVotingIncr(votingInc);
entity.setShiftProjectIncr(shiftInc); entity.setShiftProjectIncr(shiftInc);
entity.setClosedIncr(closedInc); entity.setClosedIncr(closedInc);
@ -712,6 +739,8 @@ public class StatsIssueServiceImpl implements StatsIssueService {
int shiftInc = NumConstant.ZERO; int shiftInc = NumConstant.ZERO;
//已关闭增量 //已关闭增量
int closedInc = NumConstant.ZERO; int closedInc = NumConstant.ZERO;
//议题增量
int issueInc = NumConstant.ZERO;
for (IssueAgencyDTO issueAgency : list) { for (IssueAgencyDTO issueAgency : list) {
if (agency.getId().equals(issueAgency.getAgencyId()) || issueAgency.getPIds().contains(pIds)) { if (agency.getId().equals(issueAgency.getAgencyId()) || issueAgency.getPIds().contains(pIds)) {
if (IssueConstant.VOTING.equals(issueAgency.getStatus())) { if (IssueConstant.VOTING.equals(issueAgency.getStatus())) {
@ -720,13 +749,15 @@ public class StatsIssueServiceImpl implements StatsIssueService {
} else if (IssueConstant.SHIFT_PROJECT.equals(issueAgency.getStatus())) { } else if (IssueConstant.SHIFT_PROJECT.equals(issueAgency.getStatus())) {
//已转项目议题数量 //已转项目议题数量
shiftInc = shiftInc + issueAgency.getCount(); shiftInc = shiftInc + issueAgency.getCount();
} else { } else if(IssueConstant.CLOSED.equals(issueAgency.getStatus())) {
//已关闭议题数量 //已关闭议题数量
closedInc = closedInc + issueAgency.getCount(); closedInc = closedInc + issueAgency.getCount();
} else {
//议题增量
issueInc = issueInc + issueAgency.getCount();
} }
} }
} }
int issueInc = votingInc + shiftInc + closedInc;
entity.setVotingIncr(votingInc); entity.setVotingIncr(votingInc);
entity.setShiftProjectIncr(shiftInc); entity.setShiftProjectIncr(shiftInc);
entity.setClosedIncr(closedInc); entity.setClosedIncr(closedInc);

102
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/issue/StatsIssueDao.xml

@ -12,26 +12,49 @@
WHERE WHERE
DEL_FLAG = '0' DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId} AND CUSTOMER_ID = #{customerId}
AND DATE(UPDATED_TIME) <![CDATA[ <= ]]> #{date}
GROUP BY GROUP BY
ORG_ID, ISSUE_STATUS ORG_ID, ISSUE_STATUS
</select> </select>
<select id="selectAgencyIssueInc" resultType="com.epmet.dto.issue.IssueAgencyDTO"> <select id="selectAgencyIssueInc" resultType="com.epmet.dto.issue.IssueAgencyDTO">
SELECT SELECT
i.ORG_ID AS "agencyId", *
i.ORG_ID_PATH AS "pIds",
ip.ISSUE_STATUS AS "status",
COUNT(ip.ID) AS "count"
FROM FROM
issue i (
INNER JOIN issue_process ip ON i.ID = ip.ISSUE_ID SELECT
AND ip.DEL_FLAG = '0' i.ORG_ID AS "agencyId",
WHERE i.ORG_ID_PATH AS "pIds",
i.DEL_FLAG = '0' ip.ISSUE_STATUS AS "status",
AND i.CUSTOMER_ID = #{customerId} COUNT( ip.ID ) AS "count"
AND DATE(ip.CREATED_TIME) = #{date} FROM
GROUP BY issue i
i.ORG_ID, INNER JOIN issue_process ip ON i.ID = ip.ISSUE_ID
ip.ISSUE_STATUS AND ip.DEL_FLAG = '0'
WHERE
i.DEL_FLAG = '0'
AND i.CUSTOMER_ID = #{customerId}
AND DATE(ip.CREATED_TIME) = #{date}
GROUP BY
i.ORG_ID,
ip.ISSUE_STATUS
UNION
SELECT
i.ORG_ID AS "agencyId",
i.ORG_ID_PATH AS "pIds",
"all" AS "status",
COUNT( ip.ISSUE_ID ) AS "count"
FROM
issue i
INNER JOIN ( SELECT DISTINCT ISSUE_ID FROM issue_process WHERE DEL_FLAG = '0' AND DATE( CREATED_TIME ) = #{date} ) ip ON i.ID = ip.ISSUE_ID
WHERE
i.DEL_FLAG = '0'
AND i.CUSTOMER_ID = #{customerId}
GROUP BY
i.ORG_ID
) a
ORDER BY
agencyId
</select> </select>
<select id="selectAgencyClosedIssueTotal" resultType="com.epmet.dto.issue.IssueAgencyDTO"> <select id="selectAgencyClosedIssueTotal" resultType="com.epmet.dto.issue.IssueAgencyDTO">
SELECT SELECT
@ -83,22 +106,43 @@
</select> </select>
<select id="selectGridIssueInc" resultType="com.epmet.dto.issue.IssueGridDTO"> <select id="selectGridIssueInc" resultType="com.epmet.dto.issue.IssueGridDTO">
SELECT SELECT
i.ORG_ID AS "agencyId", *
i.GRID_ID AS "gridId",
ip.ISSUE_STATUS AS "status",
COUNT(ip.ID) AS "count"
FROM FROM
issue i (
INNER JOIN issue_process ip ON i.ID = ip.ISSUE_ID SELECT
AND ip.DEL_FLAG = '0' i.ORG_ID AS "agencyId",
WHERE i.GRID_ID AS "gridId",
i.DEL_FLAG = '0' ip.ISSUE_STATUS AS "status",
AND i.CUSTOMER_ID = #{customerId} COUNT( ip.ID ) AS "count"
AND DATE(ip.CREATED_TIME) = #{date} FROM
GROUP BY issue i
i.ORG_ID, INNER JOIN issue_process ip ON i.ID = ip.ISSUE_ID
i.GRID_ID, AND ip.DEL_FLAG = '0'
ip.ISSUE_STATUS WHERE
i.DEL_FLAG = '0'
AND i.CUSTOMER_ID = #{customerId}
AND DATE(ip.CREATED_TIME) = #{date}
GROUP BY
i.ORG_ID,
i.GRID_ID,
ip.ISSUE_STATUS UNION
SELECT
i.ORG_ID AS "agencyId",
i.GRID_ID AS "gridId",
"all" AS "status",
COUNT( ip.ISSUE_ID ) AS "count"
FROM
issue i
INNER JOIN ( SELECT DISTINCT ISSUE_ID FROM issue_process WHERE DEL_FLAG = '0' AND DATE( CREATED_TIME ) = #{date} ) ip ON i.ID = ip.ISSUE_ID
WHERE
i.DEL_FLAG = '0'
AND i.CUSTOMER_ID = #{customerId}
GROUP BY
i.ORG_ID,
i.GRID_ID
) a
ORDER BY
agencyId
</select> </select>
<select id="selectGridClosedIssueTotal" resultType="com.epmet.dto.issue.IssueGridDTO"> <select id="selectGridClosedIssueTotal" resultType="com.epmet.dto.issue.IssueGridDTO">
SELECT SELECT

Loading…
Cancel
Save