wangxianzhang 4 years ago
parent
commit
4fa3113d8c
  1. 36
      epmet-admin/epmet-admin-server/pom.xml
  2. 13
      epmet-admin/epmet-admin-server/src/main/resources/bootstrap.yml
  3. 7
      epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.11__del_social_org.sql
  4. 8
      epmet-admin/epmet-admin-server/src/main/resources/mapper/SysDictDataDao.xml
  5. 36
      epmet-auth/pom.xml
  6. 32
      epmet-auth/src/main/java/com/epmet/StringRandomUtils.java
  7. 24
      epmet-auth/src/main/java/com/epmet/controller/LoginController.java
  8. 10
      epmet-auth/src/main/java/com/epmet/service/CaptchaService.java
  9. 20
      epmet-auth/src/main/java/com/epmet/service/impl/CaptchaServiceImpl.java
  10. 12
      epmet-auth/src/main/resources/bootstrap.yml
  11. 93
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/AsyncConfig.java
  12. 47
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/EpmetThreadPoolProperties.java
  13. 39
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/ThreadDispatcherConfig.java
  14. 3
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java
  15. 15
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/DingDingRobotConstant.java
  16. 36
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/SpecialCustomerOrgConstant.java
  17. 3
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java
  18. 27
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/DingTextBriefNessFormDTO.java
  19. 29
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/UpdateUserPointsFormDTO.java
  20. 43
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/BehaviorTypeYuShanEnum.java
  21. 35
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ExternalApiEnum.java
  22. 55
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ExternalServerEnum.java
  23. 55
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java
  24. 2
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java
  25. 63
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  26. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java
  27. 82
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YuShanSysApiService.java
  28. 19
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/validator/group/QueryGroup.java
  29. 3
      epmet-gateway/src/main/java/com/epmet/GatewayApplication.java
  30. 1
      epmet-gateway/src/main/resources/bootstrap.yml
  31. 4
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/result/CustomerDataManageResultDTO.java
  32. 24
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/feign/DataAggregatorOpenFeignClient.java
  33. 19
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/feign/impl/DataAggregatorOpenFeignClientFallback.java
  34. 17
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/feign/impl/DataAggregatorOpenFeignClientFallbackFactory.java
  35. 42
      epmet-module/data-aggregator/data-aggregator-server/pom.xml
  36. 12
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/GovOrgController.java
  37. 9
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/StatsStaffPatrolRecordDailyDao.java
  38. 3
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/CustomerDataManageExcel.java
  39. 19
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyExcel.java
  40. 505
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java
  41. 22
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StatsStaffPatrolRecordDailyService.java
  42. 5
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StatsStaffPatrolRecordDailyServiceImpl.java
  43. 6
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java
  44. 97
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java
  45. 11
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/bootstrap.yml
  46. 29
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/datastats/DatsStatsDao.xml
  47. 37
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StatsStaffPatrolRecordDailyDao.xml
  48. 36
      epmet-module/data-report/data-report-server/pom.xml
  49. 3
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/ScreenProjectController.java
  50. 11
      epmet-module/data-report/data-report-server/src/main/resources/bootstrap.yml
  51. 13
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/UserGroupIdDTO.java
  52. 53
      epmet-module/data-statistical/data-statistical-server/pom.xml
  53. 49
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/config/AsyncConfig.java
  54. 35
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java
  55. 12
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java
  56. 71
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/external/IndexCalculateController.java
  57. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginGroupMainDailyDao.java
  58. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginIssueLogDailyDao.java
  59. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginTopicLogDailyDao.java
  60. 7
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java
  61. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/StatsStaffPatrolRecordDailyDao.java
  62. 58
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/mq/ProjectChangedCustomListener.java
  63. 22
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/biz/impl/BizDataStatsServiceImpl.java
  64. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/CalCpcIndexService.java
  65. 290
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalCpcIndexServiceImpl.java
  66. 105
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java
  67. 7
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginGroupMainDailyService.java
  68. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginTopicLogDailyService.java
  69. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/IssueExtractService.java
  70. 29
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java
  71. 13
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginGroupMainDailyServiceImpl.java
  72. 12
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginTopicLogDailyServiceImpl.java
  73. 13
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/IssueExtractServiceImpl.java
  74. 84
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java
  75. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateService.java
  76. 33
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java
  77. 35
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsProjectServiceImpl.java
  78. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java
  79. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java
  80. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/StatsStaffPatrolService.java
  81. 7
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/StatsStaffPatrolServiceImpl.java
  82. 11
      epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml
  83. 5
      epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.29__addindex_forcpcability.sql
  84. 18
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginGroupMainDailyDao.xml
  85. 22
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginIssueLogDailyDao.xml
  86. 10
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectOrgPeriodDailyDao.xml
  87. 23
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginTopicLogDailyDao.xml
  88. 13
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml
  89. 7
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/StatsStaffPatrolRecordDailyDao.xml
  90. 36
      epmet-module/epmet-activiti/epmet-activiti-server/pom.xml
  91. 11
      epmet-module/epmet-activiti/epmet-activiti-server/src/main/resources/bootstrap.yml
  92. 11
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java
  93. 55
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ImportTaskCommonFormDTO.java
  94. 43
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/ImportTaskCommonResultDTO.java
  95. 18
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java
  96. 10
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java
  97. 36
      epmet-module/epmet-common-service/common-service-server/pom.xml
  98. 82
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ImportTaskController.java
  99. 0
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ImportTaskDao.java
  100. 11
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ImportTaskEntity.java

36
epmet-admin/epmet-admin-server/pom.xml

@ -141,6 +141,15 @@
<rocketmq.enable>true</rocketmq.enable>
<rocketmq.nameserver>192.168.1.140:9876;192.168.1.141:9876</rocketmq.nameserver>
<rocketmq.producer.group>epmet_message</rocketmq.producer.group>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>epmet-admin</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
</properties>
</profile>
<profile>
@ -181,6 +190,15 @@
<rocketmq.enable>false</rocketmq.enable>
<rocketmq.nameserver>192.168.1.140:9876;192.168.1.141:9876</rocketmq.nameserver>
<rocketmq.producer.group>epmet_message</rocketmq.producer.group>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>epmet-admin</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
</properties>
</profile>
<profile>
@ -217,6 +235,15 @@
<rocketmq.enable>true</rocketmq.enable>
<rocketmq.nameserver>192.168.10.161:9876</rocketmq.nameserver>
<rocketmq.producer.group>epmet_message</rocketmq.producer.group>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>epmet-admin</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
</properties>
</profile>
<profile>
@ -254,6 +281,15 @@
<rocketmq.enable>true</rocketmq.enable>
<rocketmq.nameserver>192.168.11.187:9876;192.168.11.184:9876</rocketmq.nameserver>
<rocketmq.producer.group>epmet_message</rocketmq.producer.group>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>epmet-admin</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
</properties>
</profile>
</profiles>

13
epmet-admin/epmet-admin-server/src/main/resources/bootstrap.yml

@ -139,4 +139,15 @@ shutdown:
rocketmq:
enable: @rocketmq.enable@
name-server: @rocketmq.nameserver@
name-server: @rocketmq.nameserver@
thread:
# 线程池配置
threadPool:
enableCustomize: @thread.threadPool.enable-customize@
corePoolSize: @thread.threadPool.core-pool-size@
maxPoolSize: @thread.threadPool.max-pool-size@
queueCapacity: @thread.threadPool.queue-capacity@
keepAliveSeconds: @thread.threadPool.keep-alive-seconds@
threadNamePrefix: @thread.threadPool.thread-name-prefix@
rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@

7
epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.11__del_social_org.sql

@ -0,0 +1,7 @@
UPDATE sys_dict_data
SET DEL_FLAG = '1',
UPDATED_BY = 'yinzuomei',
UPDATED_TIME = NOW(),
remark = '2022.02.21删除社会组织功能,改用联建单位两新组织'
WHERE
dict_value = 'social_org';

8
epmet-admin/epmet-admin-server/src/main/resources/mapper/SysDictDataDao.xml

@ -14,8 +14,8 @@
FROM
sys_dict_data a
INNER JOIN sys_dict_type b ON a.dict_type_id = b.id
WHERE
b.dict_type = #{dictType}
WHERE a.del_flag='0'
and b.dict_type = #{dictType}
ORDER BY
a.sort ASC
</select>
@ -27,8 +27,8 @@
FROM
sys_dict_data a
INNER JOIN sys_dict_type b ON a.dict_type_id = b.id
WHERE
b.dict_type = #{dictType}
WHERE a.del_flag='0'
and b.dict_type = #{dictType}
ORDER BY
a.sort asc
</select>

36
epmet-auth/pom.xml

@ -216,6 +216,15 @@
<thirdplat.jcet.g.appsecret>UUCnxLyXiB4eBF4p</thirdplat.jcet.g.appsecret>
<epmet.third.urlprefix>https://epmet-cloud.elinkservice.cn</epmet.third.urlprefix>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>epmet-auth</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
</properties>
</profile>
<profile>
@ -273,6 +282,15 @@
<thirdplat.jcet.g.appsecret>UUCnxLyXiB4eBF4p</thirdplat.jcet.g.appsecret>
<epmet.third.urlprefix>https://epmet-cloud.elinkservice.cn</epmet.third.urlprefix>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>epmet-auth</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
</properties>
</profile>
<profile>
@ -325,6 +343,15 @@
<thirdplat.jcet.g.appsecret>UUCnxLyXiB4eBF4p</thirdplat.jcet.g.appsecret>
<epmet.third.urlprefix>https://epmet-cloud.elinkservice.cn</epmet.third.urlprefix>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>epmet-auth</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
</properties>
</profile>
@ -382,6 +409,15 @@
<thirdplat.jcet.g.appsecret>UUCnxLyXiB4eBF4p</thirdplat.jcet.g.appsecret>
<epmet.third.urlprefix>https://epmet-cloud.elinkservice.cn</epmet.third.urlprefix>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>epmet-auth</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
</properties>
</profile>
</profiles>

32
epmet-auth/src/main/java/com/epmet/StringRandomUtils.java

@ -0,0 +1,32 @@
package com.epmet;
import com.epmet.commons.tools.constant.StrConstant;
/**
* desc:随机生成字母
*
* @author: LiuJanJun
* @date: 2022/3/1 5:16 下午
* @version: 1.0
*/
public class StringRandomUtils {
public static String getRandomStr(int length){
String result = StrConstant.EPMETY_STR;
//小写字母范围: 97~122
for (int i = 0; i < length; i++) {
int randomNumber = 97 + (int) (Math.random()* (122+1-97));
result += (char)randomNumber;
}
return result;
}
public static void main(String[] args) {
StringRandomUtils test = new StringRandomUtils();
//测试
for (int i = 0; i < 1000000; i++) {
System.out.println(getRandomStr(5));
}
}
}

24
epmet-auth/src/main/java/com/epmet/controller/LoginController.java

@ -68,30 +68,6 @@ public class LoginController {
}
}
/**
* @description 基层治理平台登录验证码
*
* @param response
* @return
* @author wxz
* @date 2021.10.25 14:19:40
*/
@GetMapping("ic-login-captcha")
public void icLoginCaptcha(HttpServletResponse response, String uuid) throws IOException {
try {
//生成图片验证码
BufferedImage image = captchaService.createIcLoginCaptcha(uuid);
response.reset();
response.setHeader("Cache-Control", "no-store, no-cache");
response.setContentType("image/jpeg");
ServletOutputStream out = response.getOutputStream();
ImageIO.write(image, "jpg", out);
out.close();
} catch (IOException e) {
log.error("获取登陆验证码异常", e);
}
}
/**
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<java.lang.String>

10
epmet-auth/src/main/java/com/epmet/service/CaptchaService.java

@ -23,16 +23,6 @@ public interface CaptchaService {
*/
BufferedImage create(String uuid);
/**
* @description 基层治理平台登录验证码
*
* @param
* @return
* @author wxz
* @date 2021.10.25 14:15:30
*/
BufferedImage createIcLoginCaptcha(String uuid);
/**
* 验证码效验
* @param uuid uuid

20
epmet-auth/src/main/java/com/epmet/service/impl/CaptchaServiceImpl.java

@ -8,16 +8,17 @@
package com.epmet.service.impl;
import com.google.code.kaptcha.Producer;
import com.epmet.StringRandomUtils;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.redis.CaptchaRedis;
import com.epmet.service.CaptchaService;
import com.google.code.kaptcha.Producer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.awt.image.BufferedImage;
import java.util.UUID;
/**
* 验证码
@ -35,8 +36,8 @@ public class CaptchaServiceImpl implements CaptchaService {
@Override
public BufferedImage create(String uuid) {
//生成验证码
String captcha = producer.createText();
//生成验证码 //producer.createText();
String captcha = StringRandomUtils.getRandomStr(NumConstant.FIVE);
//logger.info("uuid:"+uuid+",生成的验证码:"+captcha);
//保存验证码
captchaRedis.set(uuid, captcha);
@ -44,17 +45,6 @@ public class CaptchaServiceImpl implements CaptchaService {
return producer.createImage(captcha);
}
@Override
public BufferedImage createIcLoginCaptcha(String uuid) {
//生成验证码
String captchaText = producer.createText();
//logger.info("uuid:"+uuid+",生成的验证码:"+captcha);
//保存验证码
captchaRedis.setIcLoginCaptcha(uuid, captchaText);
return producer.createImage(captchaText);
}
@Override
public boolean validate(String uuid, String code) {
String captcha = captchaRedis.get(uuid);

12
epmet-auth/src/main/resources/bootstrap.yml

@ -159,3 +159,15 @@ epmet:
# third服务的相关配置
third:
urlPrefix: @epmet.third.urlprefix@
thread:
# 线程池配置
threadPool:
enableCustomize: @thread.threadPool.enable-customize@
corePoolSize: @thread.threadPool.core-pool-size@
maxPoolSize: @thread.threadPool.max-pool-size@
queueCapacity: @thread.threadPool.queue-capacity@
keepAliveSeconds: @thread.threadPool.keep-alive-seconds@
threadNamePrefix: @thread.threadPool.thread-name-prefix@
rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@

93
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/AsyncConfig.java

@ -0,0 +1,93 @@
package com.epmet.commons.tools.config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
/**
* 线程池配置类
* thread:
* # 线程池配置
* threadPool:
* enableCustomize: true [true会使用自定义线程池false则使用springboot自动配置的线程池推荐使用自定义线程池]
* 可以只配置此参数其他参会会使用默认值但还是建议把参数配置全
* corePoolSize: 2
* maxPoolSize: 4
* queueCapacity: 2
* keepAliveSeconds: 60
* threadNamePrefix: [线程池名字]
* rejectedExecutionHandler: [拒绝策略]
*
* 顺序核心线程->放入队列->未达到maxPoolSize则继续增加线程直到达到maxPoolSize->拒绝策略
* 开启自定义线程池thread.threadPool.enableCustomize=true不配置或者配置为false自定义线程池都不会开启
* rejectedExecutionHandler拒绝策略abortPolicy/discardPolicy/discardOldestPolicy/callerRunsPolicy(默认)
*/
@EnableConfigurationProperties(EpmetThreadPoolProperties.class)
@Configuration
@ConditionalOnProperty(prefix = "thread.threadPool", name = "enableCustomize", havingValue = "true", matchIfMissing = false)
public class AsyncConfig {
/**
* 默认值
*/
private int corePoolSize = 5;
private int maxPoolSize = 8;
private int queueCapacity = 20;
private String threadNamePrefix = "epmet-default-";
private int keepAliveSeconds = 60;
private String rejectedExecutionHandler = "callerRunsPolicy";
public AsyncConfig(EpmetThreadPoolProperties properties) {
if (properties.getCorePoolSize() != null) corePoolSize = properties.getCorePoolSize();
if (properties.getMaxPoolSize() != null) maxPoolSize = properties.getMaxPoolSize();
if (properties.getQueueCapacity() != null) queueCapacity = properties.getQueueCapacity();
if (properties.getThreadNamePrefix() != null) threadNamePrefix = properties.getThreadNamePrefix();
if (properties.getKeepAliveSeconds() != null) keepAliveSeconds = properties.getKeepAliveSeconds();
if (properties.getRejectedExecutionHandler() != null) rejectedExecutionHandler = properties.getRejectedExecutionHandler();
}
@Bean
public Executor executor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(corePoolSize);
executor.setMaxPoolSize(maxPoolSize);
executor.setQueueCapacity(queueCapacity);
executor.setThreadNamePrefix(threadNamePrefix);
executor.setRejectedExecutionHandler(getRejectedExecutionHandler(rejectedExecutionHandler)); //对拒绝task的处理策略
executor.setKeepAliveSeconds(keepAliveSeconds);
executor.initialize();
return executor;
}
@Bean
public ExecutorService executorService() {
ThreadPoolTaskExecutor executor = (ThreadPoolTaskExecutor) executor();
return executor.getThreadPoolExecutor();
}
/**
* 获取拒绝策略handler
* @param policy
* @return
*/
private RejectedExecutionHandler getRejectedExecutionHandler(String policy) {
switch (policy) {
case "abortPolicy":
return new ThreadPoolExecutor.AbortPolicy();
case "discardPolicy":
return new ThreadPoolExecutor.DiscardPolicy();
case "discardOldestPolicy":
return new ThreadPoolExecutor.DiscardOldestPolicy();
default:
// 默认情况下,使用主线程执行
return new ThreadPoolExecutor.CallerRunsPolicy();
}
}
}

47
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/EpmetThreadPoolProperties.java

@ -0,0 +1,47 @@
package com.epmet.commons.tools.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* 线程池配置参数
* thread-pool会自动对应到threadPool
*/
@ConfigurationProperties(prefix = "thread.thread-pool")
@Data
public class EpmetThreadPoolProperties {
/**
* 是否允许自定义线程池
*/
private Boolean enableCustomize;
/**
* 核心线程数
*/
private Integer corePoolSize;
/**
* 最大线程数
*/
private Integer maxPoolSize;
/**
* 队列容量
*/
private Integer queueCapacity;
/**
* 线程名前缀
*/
private String threadNamePrefix;
/**
* 线程存活时长
*/
private Integer keepAliveSeconds;
/**
* 拒绝策略
*/
private String rejectedExecutionHandler;
}

39
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/ThreadDispatcherConfig.java

@ -0,0 +1,39 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
* <p>
* https://www.renren.io
* <p>
* 版权所有侵权必究
*/
package com.epmet.commons.tools.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.RequestContextFilter;
import org.springframework.web.servlet.DispatcherServlet;
import javax.annotation.PostConstruct;
/**
* DESC:设置线程继承属性为true便于子线程获取到父线程的request,两个都设置为了保险
*
* @author Mark sunlightcs@gmail.com
* @since 1.0.0
*/
@Configuration
public class ThreadDispatcherConfig {
@Autowired
RequestContextFilter requestContextFilter;
@Autowired
DispatcherServlet dispatcherServlet;
@PostConstruct
public void init() {
// 设置线程继承属性为true,便于子线程获取到父线程的request,两个都设置为了保险。
requestContextFilter.setThreadContextInheritable(true);
dispatcherServlet.setThreadContextInheritable(true);
}
}

3
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java

@ -171,4 +171,7 @@ public interface Constant {
* 被禁用标识
* */
String DISABLE = "disable";
String OPITON_SOURCE_REMOTE = "remote";
String OPITON_SOURCE_LOCAL = "local";
}

15
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/DingDingRobotConstant.java

@ -0,0 +1,15 @@
package com.epmet.commons.tools.constant;
public interface DingDingRobotConstant {
/**
* 尹作梅测试用
*/
String YZM_TEST_URL="https://oapi.dingtalk.com/robot/send?access_token=249c5f49006cf14b37f9c3bc502ede34c16926a5ac5a0deeb9c9b4be735c0daf";
String YZM_TEST_SECRET="SECa03f447d67c62d924b5ae52dd9a7ddd9147d32c1d43f8cb43449f505444bdc6b";
/**
* EPMET V3 产品研发群
*/
String V3_ROBOT_URL="https://oapi.dingtalk.com/robot/send?access_token=75e9ab857536f3018baa09009646876edbd263d07521a1a22eedfc3852623614";
String V3_ROBOT_SECRET="SECdc8d3fb6780faa919f38fd43783f76d111255036c3b5bdcbc086dff023ee84d5";
}

36
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/SpecialCustomerOrgConstant.java

@ -0,0 +1,36 @@
package com.epmet.commons.tools.constant;
/**
* 需要特殊处理的客户id
*
* @author Mark sunlightcs@gmail.com
* @since 1.0.0
*/
public interface SpecialCustomerOrgConstant {
/**
* 榆山街道组织id
*/
String YUSHAN_AGENCY_ID_PROD="1258587398679126017";
/**
* 南宁社区-开发测试用的
*/
String test="6e511da6816e53af4cda952365a26eb9";
/**
* 榆山生产客户id
*/
String YUSHAN_PROD_CUSTOMER_ID = "46c55cb862d6d5e6d05d2ab61a1cc07e";
/**
* 榆山测试客户id
*/
String YUSHAN_TEST_CUSTOMER_ID = "a4bbf298d8e427844038cee466f022ef";
/**
* 生产平阴客户id
*/
String PING_YIN_CUSTOMER_ID="6f203e30de1a65aab7e69c058826cd80";
}

3
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java

@ -107,4 +107,7 @@ public interface StrConstant {
* 积分规则修改的头
*/
String POINT_CHANGE_HEAD = "修改了%s规则,";
String YES = "是";
String NO = "否";
}

27
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/DingTextBriefNessFormDTO.java

@ -0,0 +1,27 @@
package com.epmet.commons.tools.dto.form;
import com.dingtalk.api.request.OapiRobotSendRequest;
import lombok.Data;
/**
* 钉钉机器人发送文本通知@手机号简参
*/
@Data
public class DingTextBriefNessFormDTO {
/* {
"msgtype":"text",
"text":{
"content":"我就是我, @15764229697 是不同的烟火"
},
"at":{
"atMobiles": [
"15764229697"
],
"isAtAll":false
}
}*/
private String msgtype;
private OapiRobotSendRequest.Text text;
private OapiRobotSendRequest.At at;
}

29
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/UpdateUserPointsFormDTO.java

@ -0,0 +1,29 @@
package com.epmet.commons.tools.dto.form;
import lombok.Data;
import java.io.Serializable;
@Data
public class UpdateUserPointsFormDTO implements Serializable {
/**
* 行为类型
* 双十信息更新-double_info_update
* 网格巡查-grid_patrol
* 网格上报事件-grid_report_event
* 网格工作上传-grid_work_upload
*/
private String behaviorType;
/**
* 手机号
*/
private String mobile;
/**
* 工作端用户id
*/
private String staffId;
private String customerId;
}

43
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/BehaviorTypeYuShanEnum.java

@ -0,0 +1,43 @@
package com.epmet.commons.tools.enums;
/**
* 更新用户积分(双实信息更新 网格巡查)
* 行为类型枚举类
*/
public enum BehaviorTypeYuShanEnum {
DOUBLE_INFO_UPDATE("double_info_update", "双十信息更新"),
GRID_PATROL("grid_patrol", "网格巡查"),
GRID_REPORT_EVENT("grid_report_event", "网格上报事件"),
GRID_WORK_UPLOAD("grid_work_upload", "网格工作上传"),
;
private String code;
private String name;
BehaviorTypeYuShanEnum(String code, String name) {
this.code = code;
this.name = name;
}
public static BehaviorTypeYuShanEnum getEnum(String code) {
BehaviorTypeYuShanEnum[] values = BehaviorTypeYuShanEnum.values();
for (BehaviorTypeYuShanEnum value : values) {
if (value.getCode().equals(code)) {
return value;
}
}
return null;
}
public String getCode() {
return code;
}
public String getName() {
return name;
}
}

35
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ExternalApiEnum.java

@ -0,0 +1,35 @@
package com.epmet.commons.tools.enums;
/**
* 外部api
*/
public enum ExternalApiEnum {
/**
* 榆山-测试服务器地址
*/
UPDATE_USER_POINTS("/api/points/behavior/updateUserPoints","更新用户积分(双实信息更新 网格巡查)","http://yapi.elinkservice.cn/project/57/interface/api/7466");
private String apiPath;
private String desc;
private String descUrl;
ExternalApiEnum(String apiPath, String desc,String descUrl) {
this.apiPath = apiPath;
this.desc = desc;
this.descUrl=descUrl;
}
public String getApiPath() {
return apiPath;
}
public String getDesc() {
return desc;
}
public String getDescUrl() {
return descUrl;
}
}

55
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ExternalServerEnum.java

@ -0,0 +1,55 @@
package com.epmet.commons.tools.enums;
import com.epmet.commons.tools.constant.StrConstant;
/**
* 外部客户的服务器地址
*/
public enum ExternalServerEnum {
DEV_TEST("45687aa479955f9d06204d415238f7cc", "https://epdc-api-test.elinkservice.cn/epdc-api"),
/**
* 榆山-测试服务器地址
*/
YUSHAN_TEST("a4bbf298d8e427844038cee466f022ef", "https://epdc-api-test.elinkservice.cn/epdc-api"),
/**
* 榆山-生产服务器地址
*/
YUSHAN_PROD("46c55cb862d6d5e6d05d2ab61a1cc07e", "https://epdc-yushan.elinkservice.cn/epdc-api");
private String customerId;
private String url;
ExternalServerEnum(String customerId, String url) {
this.customerId = customerId;
this.url = url;
}
public static String getUrl(String customerId) {
ExternalServerEnum[] array = values();
for (ExternalServerEnum enumValue : array) {
if (enumValue.getCustomerId().equals(customerId)) {
return enumValue.getUrl();
}
}
return StrConstant.EPMETY_STR;
}
public String getCustomerId() {
return customerId;
}
public void setCustomerId(String customerId) {
this.customerId = customerId;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}

55
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java

@ -1,9 +1,12 @@
package com.epmet.commons.tools.feign;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.Result;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Feign请求结果解析器
@ -12,30 +15,30 @@ public interface ResultDataResolver {
/**
* @Description 获取Result种的data如果失败(返回result为null或者result.success为false)那么返回null
* @return
* @return data数据
* @author wxz
* @date 2021.06.07 22:45
*/
//default <R> R tryGetResultData(Result<R> result, String targetServiceName) {
// Logger logger = LoggerFactory.getLogger(ResultDataResolver.class);
// if (result == null) {
// logger.error("调用{}服务发生错误,返回Result为null", targetServiceName);
// return null;
// }
// if (!result.success()) {
// logger.error("调用{}服务发生错误,错误信息:{}", targetServiceName, result.getInternalMsg());
// return null;
// }
// return result.getData();
//}
default <R> R getResultDataOrReturnNull(Result<R> result, String targetServiceName) {
Logger logger = LoggerFactory.getLogger(ResultDataResolver.class);
if (result == null) {
logger.error("调用{}服务发生错误,返回Result为null", targetServiceName);
return null;
}
if (!result.success()) {
logger.error("调用{}服务发生错误,内部信息:{},错误信息:{}", targetServiceName, result.getInternalMsg(), result.getMsg());
return null;
}
return result.getData();
}
/**
* @Description
* @return
* @Description 解析Result中的结果如果请求上游服务返回的结果不成功则抛出异常
* @return data数据
* @param targetServiceName 目标service名称
* @param errorCode 错误码可以为空为空则使用上游服务抛出的错误码
* @param errorInternalMsg 内部错误信息可以为空为空则使用上游服务抛出的异常信息
* @param showMsg 展示给前端程序的错误信息可以为空为空则根据errorCode给定错误msg信息
* @param errorCode 错误码可以为空为空则使用8000
* @param errorInternalMsg 内部错误信息可以为空为空则internalMsg=""
* @param showMsg 展示给前端程序的错误信息可以为空为空则showMsg=""
* @author wxz
* @date 2021.06.07 22:45
*/
@ -43,11 +46,25 @@ public interface ResultDataResolver {
if (result == null) {
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), "调用{}服务发生错误,返回Result为null", targetServiceName);
}
if (!result.success()) {
// 考虑到:上游服务抛出的异常代码和错误消息并不一定适用于当前服务,并且上有服务的错误消息弹出之后可能给用户造成困扰,
// 因此,当前服务抛出异常的时候,不再继承上游服务返回的错误码和错误消息
/*if (!result.success()) {
Integer finalErrorCode = errorCode == null ? result.getCode() : errorCode;
String finalErrorInternalMsg = StringUtils.isBlank(errorInternalMsg) ? result.getInternalMsg() : errorInternalMsg;
throw new RenException(finalErrorCode, finalErrorInternalMsg, showMsg, RenException.MessageMode.CODE_INTERNAL_EXTERNAL);
}*/
if (!result.success()) {
// 如果不通过参数指定code,则默认使用8000服务器开小差
Integer finalErrorCode = errorCode == null ? EpmetErrorCode.SERVER_ERROR.getCode() : errorCode;
String finalErrorInternalMsg = StringUtils.isBlank(errorInternalMsg) ? "" : errorInternalMsg;
String finalShowMsg = StringUtils.isBlank(showMsg) ? "" : showMsg;
throw new EpmetException(finalErrorCode, finalErrorInternalMsg, finalShowMsg);
}
return result.getData();
}

2
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java

@ -66,6 +66,7 @@ public class LogMsgSendFilter extends LevelFilter {
}
if (StringUtils.isNotBlank(activeEnv)) {
stringBuilder.append("告警环境:").append(activeEnv);
stringBuilder.append("\n");
}
@ -112,7 +113,6 @@ public class LogMsgSendFilter extends LevelFilter {
if (!flag) {
logger.warn("msgSender.sendMsg fail,param:{}", stringBuilder.toString());
}
stringBuilder.append("告警环境:").append(activeEnv);
} catch (Exception e) {
logger.warn("decide exception", e);
}

63
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java

@ -673,4 +673,67 @@ public class RedisKeys {
public static String icResiImportResiCategoryKey(String importTag, String type, String resiId) {
return icResiImportTypeKey(importTag, type).concat(":").concat(resiId);
}
/**
* @Description 临时房屋缓存key
* @param customerId
* @param userId
* @author zxc
* @date 2022/2/14 9:38 上午
*/
public static String getTemporaryHouseInfoCacheKey(String customerId,String userId){
return rootPrefix.concat("temporary:").concat("temporaryHouse:").concat(customerId).concat(":").concat(userId);
}
/**
* @Description 临时网格缓存key
* @param customerId
* @param userId
* @author zxc
* @date 2022/2/14 9:38 上午
*/
public static String getTemporaryGridInfoCacheKey(String customerId,String userId){
return rootPrefix.concat("temporary:").concat("temporaryGrid:").concat(customerId).concat(":").concat(userId);
}
/**
* @Description 临时小区缓存key
* @param customerId
* @param userId
* @author zxc
* @date 2022/2/14 9:39 上午
*/
public static String getTemporaryNeighborHoodInfoCacheKey(String customerId,String userId){
return rootPrefix.concat("temporary:").concat("temporaryNeighborHood:").concat(customerId).concat(":").concat(userId);
}
/**
* @Description 临时楼栋缓存key
* @param customerId
* @param userId
* @author zxc
* @date 2022/2/14 9:39 上午
*/
public static String getTemporaryBuildingInfoCacheKey(String customerId,String userId){
return rootPrefix.concat("temporary:").concat("temporaryBuilding:").concat(customerId).concat(":").concat(userId);
}
/**
* @Description 临时楼栋单元缓存key
* @param customerId
* @param userId
* @author zxc
* @date 2022/2/14 1:54 下午
*/
public static String getTemporaryBuildingUnitInfoCacheKey(String customerId,String userId){
return rootPrefix.concat("temporary:").concat("temporaryBuildingUnit:").concat(customerId).concat(":").concat(userId);
}
public static String getTemporaryImportResultCacheKey(String customerId,String userId){
return rootPrefix.concat("temporary:").concat("temporaryResult:").concat(customerId).concat(":").concat(userId);
}
public static String getCustomerMenuList(String customerId, Integer type) {
return rootPrefix.concat("oper:access:nav:customerId:").concat(customerId).concat(":type:")+type;
}
}

1
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java

@ -305,6 +305,7 @@ public class HttpClientManager {
*/
public Result<String> sendAlarmMsg(String content) {
Long timestamp = System.currentTimeMillis();
//生产环境报警群:重要消息通知
String url = "https://oapi.dingtalk.com/robot/send?access_token=c40055ed85e45fdaafea00f3218928794262ff15163e09ad5c89764433b69806";
String secret = "SEC220eafdcb39ab5dd6cffa9f11b0e5de7178ddac9812d40fdceb6b1dda2963186";

82
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YuShanSysApiService.java

@ -0,0 +1,82 @@
package com.epmet.commons.tools.utils;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.constant.SpecialCustomerOrgConstant;
import com.epmet.commons.tools.dto.form.UpdateUserPointsFormDTO;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.enums.EnvEnum;
import com.epmet.commons.tools.enums.ExternalApiEnum;
import com.epmet.commons.tools.enums.ExternalServerEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
/**
* e事通调用榆山api
*
* @author yinzuomei
* @date 2022-02-16
**/
@Service
@Slf4j
public class YuShanSysApiService {
/**
* 更新用户积分(双实信息更新 网格巡查)
*
* @return
*/
@Async
public void updateUserPoints(String customerId, List<UpdateUserPointsFormDTO> paramList) {
if (StringUtils.isBlank(customerId) || CollectionUtils.isEmpty(paramList)) {
throw new RenException("参数错误");
}
if (!SpecialCustomerOrgConstant.PING_YIN_CUSTOMER_ID.equals(customerId)) {
return;
}
String serverUrl = null;
EnvEnum currentEnv = EnvEnum.getCurrentEnv();
if (EnvEnum.PROD.getCode().equals(currentEnv.getCode())) {
serverUrl = ExternalServerEnum.getUrl(SpecialCustomerOrgConstant.YUSHAN_PROD_CUSTOMER_ID);
} else if (EnvEnum.TEST.getCode().equals(currentEnv.getCode()) || EnvEnum.LOCAL.getCode().equals(currentEnv.getCode())) {
serverUrl = ExternalServerEnum.getUrl(SpecialCustomerOrgConstant.YUSHAN_TEST_CUSTOMER_ID);
}
if (StringUtils.isBlank(serverUrl)) {
log.warn(String.format("当前客户:%s,未配置服务器地址", customerId));
return;
}
String apiPath = serverUrl.concat(ExternalApiEnum.UPDATE_USER_POINTS.getApiPath());
log.info(String.format("updateUserPoints 接口路径:%s", apiPath));
for (UpdateUserPointsFormDTO formDTO : paramList) {
try {
CustomerStaffInfoCacheResult staff = CustomerStaffRedis.getStaffInfo(customerId, formDTO.getStaffId());
//只有榆山街道的工作人员才调用
if (null != staff && (staff.getAgencyId().equals(SpecialCustomerOrgConstant.YUSHAN_AGENCY_ID_PROD) || staff.getAgencyPIds().contains(SpecialCustomerOrgConstant.YUSHAN_AGENCY_ID_PROD))) {
formDTO.setMobile(staff.getMobile());
//测试用手机号
// formDTO.setMobile("13205302682");
Result<String> res = HttpClientManager.getInstance().sendPostByJSON(apiPath, JSON.toJSONString(formDTO));
Result result = JSON.parseObject(res.getData(), Result.class);
log.info(String.format("updateUserPoints 入参:%s;返参:%s", JSON.toJSONString(formDTO),JSON.toJSONString(result)));
if (!result.success()) {
log.warn("updateUserPoints failed:{}", JSON.toJSONString(result));
}
}
} catch (Exception e) {
log.warn("updateUserPoints exception 入参:{}", JSON.toJSONString(formDTO));
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), e.getMessage());
}
}
}
}

19
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/validator/group/QueryGroup.java

@ -0,0 +1,19 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.commons.tools.validator.group;
/**
* 查询 Group
*
* @author Mark sunlightcs@gmail.com
* @since 1.0.0
*/
public interface QueryGroup {
}

3
epmet-gateway/src/main/java/com/epmet/GatewayApplication.java

@ -10,6 +10,7 @@ package com.epmet;
import com.epmet.commons.tools.aspect.ServletExceptionHandler;
import com.epmet.commons.tools.config.RedissonConfig;
import com.epmet.commons.tools.config.ThreadDispatcherConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@ -27,7 +28,7 @@ import org.springframework.context.annotation.FilterType;
@EnableDiscoveryClient
@EnableFeignClients
//@ServletComponentScan
@ComponentScan(basePackages = {"com.epmet.*"}, excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {RedissonConfig.class, ServletExceptionHandler.class}))
@ComponentScan(basePackages = {"com.epmet.*"}, excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {RedissonConfig.class, ThreadDispatcherConfig.class, ServletExceptionHandler.class}))
public class GatewayApplication {
public static void main(String[] args) {

1
epmet-gateway/src/main/resources/bootstrap.yml

@ -234,6 +234,7 @@ spring:
- Path=${server.servlet.context-path}/commonservice/**
filters:
- StripPrefix=1
- CpAuth=true
#党建园地
- id: resi-home-server
uri: @gateway.routes.resi-home-server.uri@

4
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/datastats/result/CustomerDataManageResultDTO.java

@ -44,6 +44,10 @@ public class CustomerDataManageResultDTO {
private Integer patrolCount = 0;
//巡查时长
private String patrolDuration;
/**
* 例行工作次数
*/
private Integer patrolRoutineWorkTimes = 0;
//未转换前的巡查时长
private Integer patrolDurationInteger = 0;
//数据对应dateId

24
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/feign/DataAggregatorOpenFeignClient.java

@ -0,0 +1,24 @@
package com.epmet.dataaggre.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO;
import com.epmet.dataaggre.feign.impl.DataAggregatorOpenFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@FeignClient(name = ServiceConstant.DATA_AGGREGATOR_SERVER, fallbackFactory = DataAggregatorOpenFeignClientFallbackFactory.class)
// @FeignClient(name = ServiceConstant.DATA_AGGREGATOR_SERVER, fallbackFactory= DataAggregatorOpenFeignClientFallbackFactory.class,url = "localhost:8114")
public interface DataAggregatorOpenFeignClient {
/**
* 定时任务导出网格活跃统计表
* @param form
* @return
*/
@PostMapping(value = "data/aggregator/org/export-send-msg")
Result exportGridLiveRes(@RequestBody GridLivelyFormDTO form);
}

19
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/feign/impl/DataAggregatorOpenFeignClientFallback.java

@ -0,0 +1,19 @@
package com.epmet.dataaggre.feign.impl;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO;
import com.epmet.dataaggre.feign.DataAggregatorOpenFeignClient;
public class DataAggregatorOpenFeignClientFallback implements DataAggregatorOpenFeignClient {
/**
* 定时任务导出网格活跃统计表
* @param form
* @return
*/
@Override
public Result exportGridLiveRes(GridLivelyFormDTO form) {
return ModuleUtils.feignConError(ServiceConstant.DATA_AGGREGATOR_SERVER, "pcworkRecordListExportSendMsg",form);
}
}

17
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/feign/impl/DataAggregatorOpenFeignClientFallbackFactory.java

@ -0,0 +1,17 @@
package com.epmet.dataaggre.feign.impl;
import com.epmet.dataaggre.feign.DataAggregatorOpenFeignClient;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DataAggregatorOpenFeignClientFallbackFactory implements FallbackFactory<DataAggregatorOpenFeignClient> {
private DataAggregatorOpenFeignClientFallback fallback = new DataAggregatorOpenFeignClientFallback();
@Override
public DataAggregatorOpenFeignClient create(Throwable throwable) {
return null;
}
}

42
epmet-module/data-aggregator/data-aggregator-server/pom.xml

@ -110,6 +110,12 @@
</exclusion>-->
</exclusions>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-oss-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
@ -259,6 +265,15 @@
<!--钉钉 机器人地址-->
<dingTalk.robot.webHook>https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4</dingTalk.robot.webHook>
<dingTalk.robot.secret>SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd</dingTalk.robot.secret>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>data-aggregator</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
</properties>
</profile>
<profile>
@ -375,6 +390,15 @@
<!--钉钉 机器人地址-->
<dingTalk.robot.webHook>https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4</dingTalk.robot.webHook>
<dingTalk.robot.secret>SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd</dingTalk.robot.secret>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>data-aggregator</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
</properties>
</profile>
<profile>
@ -491,6 +515,15 @@
<!--测试钉钉 机器人地址-->
<dingTalk.robot.webHook>https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4</dingTalk.robot.webHook>
<dingTalk.robot.secret>SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd</dingTalk.robot.secret>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>data-aggregator</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
</properties>
</profile>
<profile>
@ -608,6 +641,15 @@
<!--生产钉钉 机器人地址-->
<dingTalk.robot.webHook>https://oapi.dingtalk.com/robot/send?access_token=a5f66c3374b1642fe2142dbf56d5997e280172d4e8f2b546c9423a68c82ece6c</dingTalk.robot.webHook>
<dingTalk.robot.secret>SEC95f4f40b533ad379ea6a6d1af6dd37029383cfe1b7cd96dfac2678be2c1c3ed1</dingTalk.robot.secret>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>data-aggregator</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
</properties>
</profile>
</profiles>

12
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/GovOrgController.java

@ -27,7 +27,6 @@ import com.epmet.dataaggre.entity.govorg.CustomerAgencyEntity;
import com.epmet.dataaggre.enums.GridMemberDataAnalysisEnums;
import com.epmet.dataaggre.service.AggreGridService;
import com.epmet.dataaggre.service.govorg.GovOrgService;
import com.epmet.dto.form.patrol.PcworkRecordListFormDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
@ -402,4 +401,15 @@ public class GovOrgController {
govOrgService.grdiLivelyExport(response, formDTO);
}
/**
* 定时任务调用本方法查询网格活跃度统计结果生成excel,上传oss.发送钉钉excel.
* @param formDTO
* @return
*/
@PostMapping("export-send-msg")
public Result pcworkRecordListExportSendMsg(@RequestBody GridLivelyFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, GridLivelyFormDTO.Grid.class);
govOrgService.pcworkRecordListExportSendMsg(formDTO);
return new Result();
}
}

9
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/StatsStaffPatrolRecordDailyDao.java

@ -40,6 +40,7 @@ public interface StatsStaffPatrolRecordDailyDao extends BaseDao<StatsStaffPatrol
/**
* desc:获取巡查次数和时间
*
* @param orgIdList
* @param startDateId
* @param endDateId
@ -55,6 +56,7 @@ public interface StatsStaffPatrolRecordDailyDao extends BaseDao<StatsStaffPatrol
/**
* 工作人员巡查记录按日统计查询
*
* @param userIds
* @param startDateID
* @param endDateID
@ -65,4 +67,11 @@ public interface StatsStaffPatrolRecordDailyDao extends BaseDao<StatsStaffPatrol
@Param("userIds") List<String> userIds,
@Param("startDateId") String startDateID,
@Param("endDateID") String endDateID);
/**
* desc: 获取例行工作次数
* @param patrolForm
* @return
*/
List<CustomerDataManageResultDTO.CustomerDataManage> getRoutineWorkCount(CustomerDataManageFormDTO patrolForm);
}

3
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/CustomerDataManageExcel.java

@ -47,6 +47,9 @@ public class CustomerDataManageExcel {
@Excel(name = "巡查时长")
private String patrolDuration;
@Excel(name = "例行工作次数")
private Integer patrolRoutineWorkTimes;
/**
* 未转换前的巡查时长
*/

19
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyExcel.java

@ -29,40 +29,57 @@ import lombok.Data;
*/
@Data
public class GridLivelyExcel {
@ExcelProperty("组织ID")
@ExcelIgnore
private String agencyId;
//组织名称
@Excel(name = "组织名称",width = 15)
@ExcelProperty("组织名称")
@ColumnWidth(15)
private String agencyName;
//组织下所有网格总数
@Excel(name = "网格总数",width = 15)
@ExcelProperty("网格总数")
@ColumnWidth(15)
private Integer gridSumNum;
//活跃网格数
@Excel(name = "活跃网格数",width = 15)
@ExcelProperty("活跃网格数")
@ColumnWidth(15)
private Integer gridLivelyNum;
//活跃网格数占比
@Excel(name = "活跃网格数占比",width = 15)
@ExcelProperty("活跃网格数占比")
@ColumnWidth(15)
private String gridLivelyRatio;
//正常运行网格数
@Excel(name = "正常运行网格数",width = 15)
@ExcelProperty("正常运行网格数")
@ColumnWidth(15)
private Integer gridOrdinaryNum;
//正常运行网格数占比
@Excel(name = "正常运行网格数占比",width = 15)
@ExcelProperty("正常运行网格数占比")
@ColumnWidth(15)
private String gridOrdinaryRatio;
//僵尸网格数
@Excel(name = "僵尸网格数",width = 15)
@ExcelProperty("僵尸网格数")
@ColumnWidth(15)
private Integer gridLazyNum;
//僵尸网格数占比
@Excel(name = "僵尸网格数占比",width = 15)
@ExcelProperty("僵尸网格数占比")
@ColumnWidth(15)
private String gridLazyRatio;

505
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java

@ -1,60 +1,61 @@
package com.epmet.dataaggre.service.datastats.impl;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.enums.OrgLevelEnum;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.feign.ResultDataResolver;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.dataaggre.constant.DataSourceConstant;
import com.epmet.dataaggre.constant.OrgConstant;
import com.epmet.dataaggre.dao.datastats.DataStatsDao;
import com.epmet.dataaggre.dao.datastats.FactGridMemberStatisticsDailyDao;
import com.epmet.dataaggre.dto.datastats.FactGroupActDailyDTO;
import com.epmet.dataaggre.dto.datastats.form.*;
import com.epmet.dataaggre.dto.datastats.result.*;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.enums.OrgLevelEnum;
import com.epmet.commons.tools.enums.OrgTypeEnum;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.feign.ResultDataResolver;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.dataaggre.constant.DataSourceConstant;
import com.epmet.dataaggre.constant.OrgConstant;
import com.epmet.dataaggre.dao.datastats.DataStatsDao;
import com.epmet.dataaggre.dao.datastats.FactGridMemberStatisticsDailyDao;
import com.epmet.dataaggre.dto.datastats.FactGroupActDailyDTO;
import com.epmet.dataaggre.dto.datastats.form.*;
import com.epmet.dataaggre.dto.datastats.result.*;
import com.epmet.dataaggre.dto.epmetuser.FactIcuserCategoryAnalysisDailyDTO;
import com.epmet.dataaggre.dto.epmetuser.form.GridMemberPatrolListFormDTO;
import com.epmet.dataaggre.dto.epmetuser.result.GridMemberPatrolListResultDTO;
import com.epmet.dataaggre.dto.epmetuser.result.PatrolDailySumResult;
import com.epmet.dataaggre.dto.evaluationindex.ScreenAgencyOrGridListDTO;
import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO;
import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerGridDTO;
import com.epmet.dataaggre.dto.evaluationindex.ScreenGovernRankDataDailyDTO;
import com.epmet.dataaggre.dto.epmetuser.result.GridMemberPatrolListResultDTO;
import com.epmet.dataaggre.dto.epmetuser.result.PatrolDailySumResult;
import com.epmet.dataaggre.dto.evaluationindex.ScreenAgencyOrGridListDTO;
import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerAgencyDTO;
import com.epmet.dataaggre.dto.evaluationindex.ScreenCustomerGridDTO;
import com.epmet.dataaggre.dto.evaluationindex.ScreenGovernRankDataDailyDTO;
import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO;
import com.epmet.dataaggre.dto.govorg.result.GridDateIdResultDTO;
import com.epmet.dataaggre.dto.govorg.result.GridMemberDataAnalysisResultDTO;
import com.epmet.dataaggre.dto.govproject.form.ProjectTotalFormDTO;
import com.epmet.dataaggre.dto.resigroup.ActCategoryDictDTO;
import com.epmet.dataaggre.dto.resigroup.result.GroupActRankDetailDTO;
import com.epmet.dataaggre.entity.datastats.DimAgencyEntity;
import com.epmet.dataaggre.entity.datastats.FactAgencyGovernDailyEntity;
import com.epmet.dataaggre.excel.CustomerDataManageExcel;
import com.epmet.dataaggre.service.datastats.DataStatsService;
import com.epmet.dataaggre.service.epmetuser.StatsStaffPatrolRecordDailyService;
import com.epmet.dataaggre.service.evaluationindex.EvaluationIndexService;
import com.epmet.dataaggre.service.govorg.GovOrgService;
import com.epmet.dataaggre.service.opercrm.CustomerRelation;
import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import com.epmet.dataaggre.dto.govproject.form.ProjectTotalFormDTO;
import com.epmet.dataaggre.dto.resigroup.ActCategoryDictDTO;
import com.epmet.dataaggre.dto.resigroup.result.GroupActRankDetailDTO;
import com.epmet.dataaggre.entity.datastats.DimAgencyEntity;
import com.epmet.dataaggre.entity.datastats.FactAgencyGovernDailyEntity;
import com.epmet.dataaggre.excel.CustomerDataManageExcel;
import com.epmet.dataaggre.service.datastats.DataStatsService;
import com.epmet.dataaggre.service.epmetuser.StatsStaffPatrolRecordDailyService;
import com.epmet.dataaggre.service.evaluationindex.EvaluationIndexService;
import com.epmet.dataaggre.service.govorg.GovOrgService;
import com.epmet.dataaggre.service.opercrm.CustomerRelation;
import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
/**
* @Author sun
@ -98,15 +99,15 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
formDTO.setDateId(format.format(yesterday));
}
//0.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表
//NumConstant.ZERO.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表
agencyList = indexService.getAgencyIdsByAgencyId(formDTO.getAgencyId());
agencyList.add(formDTO.getAgencyId());
//1.查询组织下注册用户最新日统计数据【只查询注册用户的统计数据,不涉及参与用户的】
List<AgencyBasicDataResultDTO> userList = dataStatsDao.getAgnecyRegUser(agencyList, formDTO.getDateId());
int userTotal = 0;
int resiTotal = 0;
int partyMemberTotal = 0;
int userTotal = NumConstant.ZERO;
int resiTotal = NumConstant.ZERO;
int partyMemberTotal = NumConstant.ZERO;
for (AgencyBasicDataResultDTO u : userList){
userTotal+=u.getUserTotal();
resiTotal+=u.getResiTotal();
@ -114,15 +115,15 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
}
resultDTO.setUserTotal(userTotal);
resultDTO.setResiTotal(resiTotal);
resultDTO.setResiRatio(resultDTO.getResiTotal() == 0 || resultDTO.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getResiTotal() / (float) resultDTO.getUserTotal())));
resultDTO.setResiRatio(resultDTO.getResiTotal() == NumConstant.ZERO || resultDTO.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getResiTotal() / (float) resultDTO.getUserTotal())));
resultDTO.setPartyMemberTotal(partyMemberTotal);
resultDTO.setPartyMemberRatio(resultDTO.getPartyMemberTotal() == 0 || resultDTO.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPartyMemberTotal() / (float) resultDTO.getUserTotal())));
resultDTO.setPartyMemberRatio(resultDTO.getPartyMemberTotal() == NumConstant.ZERO || resultDTO.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPartyMemberTotal() / (float) resultDTO.getUserTotal())));
//2.查询组织下最新群组日统计数据
List<AgencyBasicDataResultDTO> groupList = dataStatsDao.getAgnecyGroup(agencyList, formDTO.getDateId());
int groupTotal = 0;
int ordinaryTotal = 0;
int branchTotal = 0;
int groupTotal = NumConstant.ZERO;
int ordinaryTotal = NumConstant.ZERO;
int branchTotal = NumConstant.ZERO;
for (AgencyBasicDataResultDTO g : groupList){
groupTotal+=g.getGroupTotal();
ordinaryTotal+=g.getOrdinaryTotal();
@ -130,9 +131,9 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
}
resultDTO.setGroupTotal(groupTotal);
resultDTO.setOrdinaryTotal(ordinaryTotal);
resultDTO.setOrdinaryRatio(resultDTO.getOrdinaryTotal() == 0 || resultDTO.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getOrdinaryTotal() / (float) resultDTO.getGroupTotal())));
resultDTO.setOrdinaryRatio(resultDTO.getOrdinaryTotal() == NumConstant.ZERO || resultDTO.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getOrdinaryTotal() / (float) resultDTO.getGroupTotal())));
resultDTO.setBranchTotal(branchTotal);
resultDTO.setBranchRatio(resultDTO.getBranchTotal() == 0 || resultDTO.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getBranchTotal() / (float) resultDTO.getGroupTotal())));
resultDTO.setBranchRatio(resultDTO.getBranchTotal() == NumConstant.ZERO || resultDTO.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getBranchTotal() / (float) resultDTO.getGroupTotal())));
//3.查询组织下最新话题日统计数据
//状态话题-机关日统计数据表最新日期三种状态数据
@ -148,21 +149,21 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
//转议题
int shiftIssueTotal = topicSHiftIssue.stream().mapToInt(AgencyBasicDataResultDTO.Topic::getShiftedIssueTotal).sum();
resultDTO.setShiftIssueTotal(shiftIssueTotal);
resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal())));
resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal())));
//热议中
int discussingTotal = hotdiscuss.stream().mapToInt(AgencyBasicDataResultDTO.Topic::getTopicCount).sum();
resultDTO.setDiscussingTotal(discussingTotal);
resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal())));
resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal())));
//已处理
resultDTO.setClosedTopicTotal(closedTotal);
resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal())));
resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal())));
//4.查询组织下最新议题日统计数据
//NumConstant.FOUR.查询组织下最新议题日统计数据
List<AgencyBasicDataResultDTO> issueList = dataStatsDao.getAgencyIssue(agencyList, formDTO.getDateId());
int issueTotal = 0;
int votingTotal = 0;
int closedIssueTotal = 0;
int shiftProjectTotal = 0;
int issueTotal = NumConstant.ZERO;
int votingTotal = NumConstant.ZERO;
int closedIssueTotal = NumConstant.ZERO;
int shiftProjectTotal = NumConstant.ZERO;
for (AgencyBasicDataResultDTO i : issueList){
issueTotal+=i.getIssueTotal();
votingTotal+=i.getVotingTotal();
@ -171,17 +172,17 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
}
resultDTO.setIssueTotal(issueTotal);
resultDTO.setVotingTotal(votingTotal);
resultDTO.setVotingRatio(resultDTO.getVotingTotal() == 0 || resultDTO.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getVotingTotal() / (float) resultDTO.getIssueTotal())));
resultDTO.setVotingRatio(resultDTO.getVotingTotal() == NumConstant.ZERO || resultDTO.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getVotingTotal() / (float) resultDTO.getIssueTotal())));
resultDTO.setClosedIssueTotal(closedIssueTotal);
resultDTO.setClosedIssueRatio(resultDTO.getClosedIssueTotal() == 0 || resultDTO.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedIssueTotal() / (float) resultDTO.getIssueTotal())));
resultDTO.setClosedIssueRatio(resultDTO.getClosedIssueTotal() == NumConstant.ZERO || resultDTO.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedIssueTotal() / (float) resultDTO.getIssueTotal())));
resultDTO.setShiftProjectTotal(shiftProjectTotal);
resultDTO.setShiftProjectRatio(resultDTO.getShiftProjectTotal() == 0 || resultDTO.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftProjectTotal() / (float) resultDTO.getIssueTotal())));
resultDTO.setShiftProjectRatio(resultDTO.getShiftProjectTotal() == NumConstant.ZERO || resultDTO.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftProjectTotal() / (float) resultDTO.getIssueTotal())));
//5.查询组织下最新项目日统计数据
List<AgencyBasicDataResultDTO> projectList = dataStatsDao.getAgencyProject(agencyList, formDTO.getDateId());
int projectTotal = 0;
int pendingTotal = 0;
int closedProjectTotal = 0;
int projectTotal = NumConstant.ZERO;
int pendingTotal = NumConstant.ZERO;
int closedProjectTotal = NumConstant.ZERO;
for (AgencyBasicDataResultDTO p : projectList){
projectTotal+=p.getProjectTotal();
pendingTotal+=p.getPendingTotal();
@ -189,9 +190,9 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
}
resultDTO.setProjectTotal(projectTotal);
resultDTO.setPendingTotal(pendingTotal);
resultDTO.setPendingRatio(resultDTO.getPendingTotal() == 0 || resultDTO.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPendingTotal() / (float) resultDTO.getProjectTotal())));
resultDTO.setPendingRatio(resultDTO.getPendingTotal() == NumConstant.ZERO || resultDTO.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPendingTotal() / (float) resultDTO.getProjectTotal())));
resultDTO.setClosedProjectTotal(closedProjectTotal);
resultDTO.setClosedProjectRatio(resultDTO.getClosedProjectTotal() == 0 || resultDTO.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedProjectTotal() / (float) resultDTO.getProjectTotal())));
resultDTO.setClosedProjectRatio(resultDTO.getClosedProjectTotal() == NumConstant.ZERO || resultDTO.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedProjectTotal() / (float) resultDTO.getProjectTotal())));
return resultDTO;
}
@ -220,21 +221,21 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
gridIds.add(formDTO.getGridId());
List<SubGridUserResultDTO> userList = dataStatsDao.getSubGridUser(gridIds, formDTO.getDateId());
if (userList.size() > NumConstant.ZERO) {
resultDTO.setUserTotal(userList.get(0).getUserTotal());
resultDTO.setResiTotal(userList.get(0).getResiTotal());
resultDTO.setResiRatio(resultDTO.getResiTotal() == 0 || resultDTO.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getResiTotal() / (float) resultDTO.getUserTotal())));
resultDTO.setPartyMemberTotal(userList.get(0).getPartyMemberTotal());
resultDTO.setPartyMemberRatio(resultDTO.getPartyMemberTotal() == 0 || resultDTO.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPartyMemberTotal() / (float) resultDTO.getUserTotal())));
resultDTO.setUserTotal(userList.get(NumConstant.ZERO).getUserTotal());
resultDTO.setResiTotal(userList.get(NumConstant.ZERO).getResiTotal());
resultDTO.setResiRatio(resultDTO.getResiTotal() == NumConstant.ZERO || resultDTO.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getResiTotal() / (float) resultDTO.getUserTotal())));
resultDTO.setPartyMemberTotal(userList.get(NumConstant.ZERO).getPartyMemberTotal());
resultDTO.setPartyMemberRatio(resultDTO.getPartyMemberTotal() == NumConstant.ZERO || resultDTO.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPartyMemberTotal() / (float) resultDTO.getUserTotal())));
}
//2.查询网格下最新群组日统计数据
List<SubGridGroupResultDTO> groupList = dataStatsDao.getSubGridGroup(gridIds, formDTO.getDateId());
if (groupList.size() > NumConstant.ZERO) {
resultDTO.setGroupTotal(groupList.get(0).getGroupTotal());
resultDTO.setOrdinaryTotal(groupList.get(0).getOrdinaryTotal());
resultDTO.setOrdinaryRatio(resultDTO.getOrdinaryTotal() == 0 || resultDTO.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getOrdinaryTotal() / (float) resultDTO.getGroupTotal())));
resultDTO.setBranchTotal(groupList.get(0).getBranchTotal());
resultDTO.setBranchRatio(resultDTO.getBranchTotal() == 0 || resultDTO.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getBranchTotal() / (float) resultDTO.getGroupTotal())));
resultDTO.setGroupTotal(groupList.get(NumConstant.ZERO).getGroupTotal());
resultDTO.setOrdinaryTotal(groupList.get(NumConstant.ZERO).getOrdinaryTotal());
resultDTO.setOrdinaryRatio(resultDTO.getOrdinaryTotal() == NumConstant.ZERO || resultDTO.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getOrdinaryTotal() / (float) resultDTO.getGroupTotal())));
resultDTO.setBranchTotal(groupList.get(NumConstant.ZERO).getBranchTotal());
resultDTO.setBranchRatio(resultDTO.getBranchTotal() == NumConstant.ZERO || resultDTO.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getBranchTotal() / (float) resultDTO.getGroupTotal())));
}
//3.查询网格下最新话题日统计数据
@ -245,7 +246,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
List<SubGridFormDTO.Topic> topicShiftIssueList = dataStatsDao.getSubGridTopicShiftIssue(gridIds, formDTO.getDateId());
//热议中话题-网格日统计数据
List<SubGridFormDTO.Topic> hotdiscussList = dataStatsDao.getSubGridTopicHotDiscuss(gridIds, formDTO.getDateId());
AtomicReference<Integer> closedTotal = new AtomicReference<>(0);
AtomicReference<Integer> closedTotal = new AtomicReference<>(NumConstant.ZERO);
if (topicList.size() > NumConstant.ZERO) {
resultDTO.setTopicTotal(topicList.stream().collect(Collectors.summingInt(SubGridFormDTO.Topic::getTopicCount)));
topicList.forEach(t -> {
@ -256,38 +257,38 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
}
//转议题
if (topicShiftIssueList.size() > NumConstant.ZERO) {
resultDTO.setShiftIssueTotal(topicShiftIssueList.get(0).getShiftedIssueTotal());
resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal())));
resultDTO.setShiftIssueTotal(topicShiftIssueList.get(NumConstant.ZERO).getShiftedIssueTotal());
resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal())));
}
//热议中
if (hotdiscussList.size() > NumConstant.ZERO) {
resultDTO.setDiscussingTotal(hotdiscussList.get(0).getTopicCount());
resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal())));
resultDTO.setDiscussingTotal(hotdiscussList.get(NumConstant.ZERO).getTopicCount());
resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal())));
}
//已处理
resultDTO.setClosedTopicTotal(closedTotal.get());
resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal())));
resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal())));
//4.查询网格下最新议题日统计数据
//NumConstant.FOUR.查询网格下最新议题日统计数据
List<SubGridIssueResultDTO> issueList = dataStatsDao.getSubGridIssue(gridIds, formDTO.getDateId());
if (issueList.size() > NumConstant.ZERO) {
resultDTO.setIssueTotal(issueList.get(0).getIssueTotal());
resultDTO.setVotingTotal(issueList.get(0).getVotingTotal());
resultDTO.setVotingRatio(resultDTO.getVotingTotal() == 0 || resultDTO.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getVotingTotal() / (float) resultDTO.getIssueTotal())));
resultDTO.setClosedIssueTotal(issueList.get(0).getClosedIssueTotal());
resultDTO.setClosedIssueRatio(resultDTO.getClosedIssueTotal() == 0 || resultDTO.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedIssueTotal() / (float) resultDTO.getIssueTotal())));
resultDTO.setShiftProjectTotal(issueList.get(0).getShiftProjectTotal());
resultDTO.setShiftProjectRatio(resultDTO.getShiftProjectTotal() == 0 || resultDTO.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftProjectTotal() / (float) resultDTO.getIssueTotal())));
resultDTO.setIssueTotal(issueList.get(NumConstant.ZERO).getIssueTotal());
resultDTO.setVotingTotal(issueList.get(NumConstant.ZERO).getVotingTotal());
resultDTO.setVotingRatio(resultDTO.getVotingTotal() == NumConstant.ZERO || resultDTO.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getVotingTotal() / (float) resultDTO.getIssueTotal())));
resultDTO.setClosedIssueTotal(issueList.get(NumConstant.ZERO).getClosedIssueTotal());
resultDTO.setClosedIssueRatio(resultDTO.getClosedIssueTotal() == NumConstant.ZERO || resultDTO.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedIssueTotal() / (float) resultDTO.getIssueTotal())));
resultDTO.setShiftProjectTotal(issueList.get(NumConstant.ZERO).getShiftProjectTotal());
resultDTO.setShiftProjectRatio(resultDTO.getShiftProjectTotal() == NumConstant.ZERO || resultDTO.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftProjectTotal() / (float) resultDTO.getIssueTotal())));
}
//5.查询网格下最新项目日统计数据
List<SubGridProjectResultDTO> projectList = dataStatsDao.getSubGridProject(gridIds, formDTO.getDateId());
if (projectList.size() > NumConstant.ZERO) {
resultDTO.setProjectTotal(projectList.get(0).getProjectTotal());
resultDTO.setPendingTotal(projectList.get(0).getPendingTotal());
resultDTO.setPendingRatio(resultDTO.getPendingTotal() == 0 || resultDTO.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPendingTotal() / (float) resultDTO.getProjectTotal())));
resultDTO.setClosedProjectTotal(projectList.get(0).getClosedProjectTotal());
resultDTO.setClosedProjectRatio(resultDTO.getClosedProjectTotal() == 0 || resultDTO.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedProjectTotal() / (float) resultDTO.getProjectTotal())));
resultDTO.setProjectTotal(projectList.get(NumConstant.ZERO).getProjectTotal());
resultDTO.setPendingTotal(projectList.get(NumConstant.ZERO).getPendingTotal());
resultDTO.setPendingRatio(resultDTO.getPendingTotal() == NumConstant.ZERO || resultDTO.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getPendingTotal() / (float) resultDTO.getProjectTotal())));
resultDTO.setClosedProjectTotal(projectList.get(NumConstant.ZERO).getClosedProjectTotal());
resultDTO.setClosedProjectRatio(resultDTO.getClosedProjectTotal() == NumConstant.ZERO || resultDTO.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedProjectTotal() / (float) resultDTO.getProjectTotal())));
}
return resultDTO;
@ -339,12 +340,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dto.setResiTotal(u.getResiTotal());
}
}
dto.setPartyMemberRatio(dto.getPartyMemberTotal() == 0 || dto.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPartyMemberTotal() / (float) dto.getUserTotal())));
dto.setResiRatio(dto.getResiTotal() == 0 || dto.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getResiTotal() / (float) dto.getUserTotal())));
dto.setPartyMemberRatio(dto.getPartyMemberTotal() == NumConstant.ZERO || dto.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPartyMemberTotal() / (float) dto.getUserTotal())));
dto.setResiRatio(dto.getResiTotal() == NumConstant.ZERO || dto.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getResiTotal() / (float) dto.getUserTotal())));
resultList.add(dto);
}
//4.按要求排序并返回
//NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator<SubAgencyUserResultDTO>() {
@Override
public int compare(SubAgencyUserResultDTO o1, SubAgencyUserResultDTO o2) {
@ -408,12 +409,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dto.setResiTotal(re.getResiTotal());
}
}
dto.setPartyMemberRatio(dto.getPartyMemberTotal() == 0 || dto.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPartyMemberTotal() / (float) dto.getUserTotal())));
dto.setResiRatio(dto.getResiTotal() == 0 || dto.getUserTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getResiTotal() / (float) dto.getUserTotal())));
dto.setPartyMemberRatio(dto.getPartyMemberTotal() == NumConstant.ZERO || dto.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPartyMemberTotal() / (float) dto.getUserTotal())));
dto.setResiRatio(dto.getResiTotal() == NumConstant.ZERO || dto.getUserTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getResiTotal() / (float) dto.getUserTotal())));
resultList.add(dto);
}
//4.按要求排序并返回
//NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator<SubGridUserResultDTO>() {
@Override
public int compare(SubGridUserResultDTO o1, SubGridUserResultDTO o2) {
@ -477,12 +478,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dto.setBranchTotal(u.getBranchTotal());
}
}
dto.setOrdinaryRatio(dto.getOrdinaryTotal() == 0 || dto.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getOrdinaryTotal() / (float) dto.getGroupTotal())));
dto.setBranchRatio(dto.getBranchTotal() == 0 || dto.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getBranchTotal() / (float) dto.getGroupTotal())));
dto.setOrdinaryRatio(dto.getOrdinaryTotal() == NumConstant.ZERO || dto.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getOrdinaryTotal() / (float) dto.getGroupTotal())));
dto.setBranchRatio(dto.getBranchTotal() == NumConstant.ZERO || dto.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getBranchTotal() / (float) dto.getGroupTotal())));
resultList.add(dto);
}
//4.按要求排序并返回
//NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator<SubAgencyGroupResultDTO>() {
@Override
public int compare(SubAgencyGroupResultDTO o1, SubAgencyGroupResultDTO o2) {
@ -543,12 +544,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dto.setBranchTotal(re.getBranchTotal());
}
}
dto.setOrdinaryRatio(dto.getOrdinaryTotal() == 0 || dto.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getOrdinaryTotal() / (float) dto.getGroupTotal())));
dto.setBranchRatio(dto.getBranchTotal() == 0 || dto.getGroupTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getBranchTotal() / (float) dto.getGroupTotal())));
dto.setOrdinaryRatio(dto.getOrdinaryTotal() == NumConstant.ZERO || dto.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getOrdinaryTotal() / (float) dto.getGroupTotal())));
dto.setBranchRatio(dto.getBranchTotal() == NumConstant.ZERO || dto.getGroupTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getBranchTotal() / (float) dto.getGroupTotal())));
resultList.add(dto);
}
//4.按要求排序并返回
//NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator<SubGridGroupResultDTO>() {
@Override
public int compare(SubGridGroupResultDTO o1, SubGridGroupResultDTO o2) {
@ -604,10 +605,10 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
List<SubAgencyFormDTO.Topic> hotdiscuss = dataStatsDao.getSubAgencyTopicHotDiscuss(agencyIds, formDTO.getDateId());
subAgencyList.forEach(sub -> {
SubAgencyTopicResultDTO resultDTO = new SubAgencyTopicResultDTO();
AtomicInteger topicTotal = new AtomicInteger(0);
AtomicInteger closedTotal = new AtomicInteger(0);
AtomicInteger shiftIssueTotal = new AtomicInteger(0);
AtomicInteger hotdiscussTotal = new AtomicInteger(0);
AtomicInteger topicTotal = new AtomicInteger(NumConstant.ZERO);
AtomicInteger closedTotal = new AtomicInteger(NumConstant.ZERO);
AtomicInteger shiftIssueTotal = new AtomicInteger(NumConstant.ZERO);
AtomicInteger hotdiscussTotal = new AtomicInteger(NumConstant.ZERO);
topic.forEach(t -> {
if (t.getAgencyId().equals(sub.getAgencyId())) {
topicTotal.addAndGet(t.getTopicCount());
@ -633,28 +634,25 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
resultDTO.setAreaCode(null == sub.getAreaCode() ? "" : sub.getAreaCode());
resultDTO.setTopicTotal(topicTotal.get());
resultDTO.setDiscussingTotal(hotdiscussTotal.get());
resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal())));
resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal())));
resultDTO.setClosedTopicTotal(closedTotal.get());
resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal())));
resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal())));
resultDTO.setShiftIssueTotal(shiftIssueTotal.get());
resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal())));
resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal())));
resultList.add(resultDTO);
});
//3.按要求排序并返回
Collections.sort(resultList, new Comparator<SubAgencyTopicResultDTO>() {
@Override
public int compare(SubAgencyTopicResultDTO o1, SubAgencyTopicResultDTO o2) {
if ("discussing".equals(formDTO.getType())) {
return o2.getDiscussingTotal().compareTo(o1.getDiscussingTotal());
} else if ("closed".equals(formDTO.getType())) {
return o2.getClosedTopicTotal().compareTo(o1.getClosedTopicTotal());
} else if ("shiftIssue".equals(formDTO.getType())) {
return o2.getShiftIssueTotal().compareTo(o1.getShiftIssueTotal());
} else {
return o2.getTopicTotal().compareTo(o1.getTopicTotal());
}
resultList.sort((o1, o2) -> {
if ("discussing".equals(formDTO.getType())) {
return o2.getDiscussingTotal().compareTo(o1.getDiscussingTotal());
} else if ("closed".equals(formDTO.getType())) {
return o2.getClosedTopicTotal().compareTo(o1.getClosedTopicTotal());
} else if ("shiftIssue".equals(formDTO.getType())) {
return o2.getShiftIssueTotal().compareTo(o1.getShiftIssueTotal());
} else {
return o2.getTopicTotal().compareTo(o1.getTopicTotal());
}
});
@ -700,10 +698,10 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
List<SubGridFormDTO.Topic> hotdiscuss = dataStatsDao.getSubGridTopicHotDiscuss(gridIds, formDTO.getDateId());
gridList.forEach(gr -> {
SubGridTopicResultDTO resultDTO = new SubGridTopicResultDTO();
AtomicInteger topicTotal = new AtomicInteger(0);
AtomicInteger closedTotal = new AtomicInteger(0);
AtomicInteger shiftIssueTotal = new AtomicInteger(0);
AtomicInteger hotdiscussTotal = new AtomicInteger(0);
AtomicInteger topicTotal = new AtomicInteger(NumConstant.ZERO);
AtomicInteger closedTotal = new AtomicInteger(NumConstant.ZERO);
AtomicInteger shiftIssueTotal = new AtomicInteger(NumConstant.ZERO);
AtomicInteger hotdiscussTotal = new AtomicInteger(NumConstant.ZERO);
topic.forEach(t -> {
if (t.getGridId().equals(gr.getGridId())) {
topicTotal.addAndGet(t.getTopicCount());
@ -727,11 +725,11 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
resultDTO.setGridName(gr.getGridName());
resultDTO.setTopicTotal(topicTotal.get());
resultDTO.setDiscussingTotal(hotdiscussTotal.get());
resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal())));
resultDTO.setDiscussingRatio(resultDTO.getDiscussingTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getDiscussingTotal() / (float) resultDTO.getTopicTotal())));
resultDTO.setClosedTopicTotal(closedTotal.get());
resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal())));
resultDTO.setClosedTopicRatio(resultDTO.getClosedTopicTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getClosedTopicTotal() / (float) resultDTO.getTopicTotal())));
resultDTO.setShiftIssueTotal(shiftIssueTotal.get());
resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == 0 || resultDTO.getTopicTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal())));
resultDTO.setShiftIssueRatio(resultDTO.getShiftIssueTotal() == NumConstant.ZERO || resultDTO.getTopicTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) resultDTO.getShiftIssueTotal() / (float) resultDTO.getTopicTotal())));
resultList.add(resultDTO);
});
@ -802,13 +800,13 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dto.setShiftProjectTotal(u.getShiftProjectTotal());
}
}
dto.setVotingRatio(dto.getVotingTotal() == 0 || dto.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getVotingTotal() / (float) dto.getIssueTotal())));
dto.setClosedIssueRatio(dto.getClosedIssueTotal() == 0 || dto.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedIssueTotal() / (float) dto.getIssueTotal())));
dto.setShiftProjectRatio(dto.getShiftProjectTotal() == 0 || dto.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getShiftProjectTotal() / (float) dto.getIssueTotal())));
dto.setVotingRatio(dto.getVotingTotal() == NumConstant.ZERO || dto.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getVotingTotal() / (float) dto.getIssueTotal())));
dto.setClosedIssueRatio(dto.getClosedIssueTotal() == NumConstant.ZERO || dto.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedIssueTotal() / (float) dto.getIssueTotal())));
dto.setShiftProjectRatio(dto.getShiftProjectTotal() == NumConstant.ZERO || dto.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getShiftProjectTotal() / (float) dto.getIssueTotal())));
resultList.add(dto);
}
//4.按要求排序并返回
//NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator<SubAgencyIssueResultDTO>() {
@Override
public int compare(SubAgencyIssueResultDTO o1, SubAgencyIssueResultDTO o2) {
@ -872,13 +870,13 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dto.setShiftProjectTotal(re.getShiftProjectTotal());
}
}
dto.setVotingRatio(dto.getVotingTotal() == 0 || dto.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getVotingTotal() / (float) dto.getIssueTotal())));
dto.setClosedIssueRatio(dto.getClosedIssueTotal() == 0 || dto.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedIssueTotal() / (float) dto.getIssueTotal())));
dto.setShiftProjectRatio(dto.getShiftProjectTotal() == 0 || dto.getIssueTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getShiftProjectTotal() / (float) dto.getIssueTotal())));
dto.setVotingRatio(dto.getVotingTotal() == NumConstant.ZERO || dto.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getVotingTotal() / (float) dto.getIssueTotal())));
dto.setClosedIssueRatio(dto.getClosedIssueTotal() == NumConstant.ZERO || dto.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedIssueTotal() / (float) dto.getIssueTotal())));
dto.setShiftProjectRatio(dto.getShiftProjectTotal() == NumConstant.ZERO || dto.getIssueTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getShiftProjectTotal() / (float) dto.getIssueTotal())));
resultList.add(dto);
}
//4.按要求排序并返回
//NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator<SubGridIssueResultDTO>() {
@Override
public int compare(SubGridIssueResultDTO o1, SubGridIssueResultDTO o2) {
@ -943,12 +941,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dto.setClosedProjectTotal(u.getClosedProjectTotal());
}
}
dto.setPendingRatio(dto.getPendingTotal() == 0 || dto.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPendingTotal() / (float) dto.getProjectTotal())));
dto.setClosedProjectRatio(dto.getClosedProjectTotal() == 0 || dto.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedProjectTotal() / (float) dto.getProjectTotal())));
dto.setPendingRatio(dto.getPendingTotal() == NumConstant.ZERO || dto.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPendingTotal() / (float) dto.getProjectTotal())));
dto.setClosedProjectRatio(dto.getClosedProjectTotal() == NumConstant.ZERO || dto.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedProjectTotal() / (float) dto.getProjectTotal())));
resultList.add(dto);
}
//4.按要求排序并返回
//NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator<SubAgencyProjectResultDTO>() {
@Override
public int compare(SubAgencyProjectResultDTO o1, SubAgencyProjectResultDTO o2) {
@ -1009,12 +1007,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dto.setClosedProjectTotal(re.getClosedProjectTotal());
}
}
dto.setPendingRatio(dto.getPendingTotal() == 0 || dto.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPendingTotal() / (float) dto.getProjectTotal())));
dto.setClosedProjectRatio(dto.getClosedProjectTotal() == 0 || dto.getProjectTotal() == 0 ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedProjectTotal() / (float) dto.getProjectTotal())));
dto.setPendingRatio(dto.getPendingTotal() == NumConstant.ZERO || dto.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getPendingTotal() / (float) dto.getProjectTotal())));
dto.setClosedProjectRatio(dto.getClosedProjectTotal() == NumConstant.ZERO || dto.getProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(numberFormat.format((float) dto.getClosedProjectTotal() / (float) dto.getProjectTotal())));
resultList.add(dto);
}
//4.按要求排序并返回
//NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator<SubGridProjectResultDTO>() {
@Override
public int compare(SubGridProjectResultDTO o1, SubGridProjectResultDTO o2) {
@ -1278,7 +1276,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
resultList.add(dto);
}
//4.按要求排序并返回
//NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator<AgencyGovrnResultDTO>() {
@Override
public int compare(AgencyGovrnResultDTO o1, AgencyGovrnResultDTO o2) {
@ -1380,7 +1378,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
resultList.add(dto);
}
//4.按要求排序并返回
//NumConstant.FOUR.按要求排序并返回
Collections.sort(resultList, new Comparator<GridGovrnResultDTO>() {
@Override
public int compare(GridGovrnResultDTO o1, GridGovrnResultDTO o2) {
@ -1388,7 +1386,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
return o2.getGroupSelfGovernRatio().compareTo(o1.getGroupSelfGovernRatio());
} else if ("grid".equals(formDTO.getType())) {
return o2.getGridSelfGovernRatio().compareTo(o1.getGridSelfGovernRatio());
} else if ("community".equals(formDTO.getType())) {
} else if (OrgLevelEnum.COMMUNITY.getCode().equals(formDTO.getType())) {
return o2.getCommunityResolvedRatio().compareTo(o1.getCommunityResolvedRatio());
} else if ("department".equals(formDTO.getType())) {
return o2.getDistrictDeptResolvedRatio().compareTo(o1.getDistrictDeptResolvedRatio());
@ -1471,18 +1469,18 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
formDTO.setDateId(format.format(yesterday));
}
BaseStatsDataResultDTO result = new BaseStatsDataResultDTO();
result.setTopicTotal(0);
result.setTopicIncr(0);
result.setTopicTotal(NumConstant.ZERO);
result.setTopicIncr(NumConstant.ZERO);
result.setIssueTotal(0);
result.setIssueIncr(0);
result.setProjectTotal(0);
result.setProjectIncr(0);
result.setClosedProjectTotal(0);
result.setClosedProjectIncr(0);
result.setIssueTotal(NumConstant.ZERO);
result.setIssueIncr(NumConstant.ZERO);
result.setProjectTotal(NumConstant.ZERO);
result.setProjectIncr(NumConstant.ZERO);
result.setClosedProjectTotal(NumConstant.ZERO);
result.setClosedProjectIncr(NumConstant.ZERO);
//0.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表
//NumConstant.ZERO.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表
List<String> agencyList = indexService.getAgencyIdsByAgencyId(formDTO.getAgencyId());
agencyList.add(formDTO.getAgencyId());
TotalAndIncrResultDTO sum = dataStatsDao.getAgencySumTopic(agencyList, formDTO.getDateId());
@ -1546,7 +1544,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
List<WorkFactResultDTO> result = new ArrayList<>();
//如果是社区 则下级是网格 查询网格的数据
if (OrgLevelEnum.COMMUNITY.getCode().equals(formDTO.getAgencyLevel())){
//0.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表
//NumConstant.ZERO.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表
List<ScreenCustomerGridDTO> subAgencyList = indexService.getSubGridList(formDTO.getAgencyId());
if (subAgencyList.size() < NumConstant.ONE) {
return null;
@ -1585,7 +1583,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
result.add(resultDTO);
});
}else {
//0.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表
//NumConstant.ZERO.根据组织Id查询是否存在子客户,存在的按areaCode查询当前客户之外的客户组织列表
List<ScreenCustomerAgencyDTO> subAgencyList = indexService.getSubAgencyListByAgency(formDTO.getAgencyId());
if (subAgencyList.size() < NumConstant.ONE) {
return null;
@ -1636,9 +1634,9 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
resultDTO.setRoutineWorkCount(patrolRecordDTO.getRoutineWorkCount());
resultDTO.setPatrolTotal(patrolRecordDTO.getPatrolTotal());
Integer totalTime = patrolRecordDTO.getTotalTime();
if (totalTime != null || totalTime > 0){
if (totalTime != null || totalTime > NumConstant.ZERO){
int minutes = totalTime / 60;
if (minutes >0){
if (minutes >NumConstant.ZERO){
String totalTimeDesc = minutes / 60 + "小时"+ minutes % 60 + "分";
resultDTO.setPatrolTotalTime(totalTimeDesc);
}
@ -1649,12 +1647,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
private Integer getTotal(Map<String,Integer> startMap, Map<String,Integer> endMap,String agencyId){
Integer total1 = startMap.getOrDefault(agencyId,NumConstant.ZERO);
Integer total2 = endMap.getOrDefault(agencyId,NumConstant.ZERO);
return Math.max(total2-total1,0);
return Math.max(total2-total1,NumConstant.ZERO);
}
private String getPercentage(Integer countInt, Integer totalInt) {
if (NumConstant.ZERO == totalInt) {
return "0%";
return "NumConstant.ZERO%";
}
BigDecimal count = new BigDecimal(countInt);
BigDecimal total = new BigDecimal(totalInt);
@ -1681,7 +1679,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
//根据组织级别判断查询直属下级组织或网格数据
//2.直属网格
if ("community".equals(formDTO.getAgencyLevel())) {
if (OrgLevelEnum.COMMUNITY.getCode().equals(formDTO.getAgencyLevel())) {
//2-1.查询组织直属网格列表【网格维度】
List<ScreenCustomerGridDTO> gridList = indexService.getSubGridList(formDTO.getAgencyId());
if (gridList.size() < NumConstant.ONE) {
@ -1729,8 +1727,8 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
});
}
//4.按用户数降序排序并返回
Collections.sort(resultList, (o1, o2) -> {
//NumConstant.FOUR.按用户数降序排序并返回
resultList.sort((o1, o2) -> {
//降序
return o2.getUserTotal().compareTo(o1.getUserTotal());
});
@ -1757,7 +1755,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
//根据组织级别判断查询直属下级组织或网格数据
//2.直属网格
if ("community".equals(formDTO.getAgencyLevel())) {
if (OrgLevelEnum.COMMUNITY.getCode().equals(formDTO.getAgencyLevel())) {
//2-1.查询组织直属网格列表【网格维度】
List<ScreenCustomerGridDTO> gridList = indexService.getSubGridList(formDTO.getAgencyId());
if (gridList.size() < NumConstant.ONE) {
@ -1798,7 +1796,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
List<SubAgencyFormDTO.Topic> hotdiscuss = dataStatsDao.getSubAgencyTopicHotDiscuss(agencyIds, formDTO.getDateId());
//3-3.查询直属下级组织小组日统计数据
List<SubAgencyGroupResultDTO> list = dataStatsDao.getSubAgencyGroup(agencyIds, formDTO.getDateId());
//3-4.封装数据
//3-NumConstant.FOUR.封装数据
subAgencyList.forEach(sub -> {
SubTopicAndGroupResultDTO resultDTO = new SubTopicAndGroupResultDTO();
resultDTO.setOrgId(sub.getAgencyId());
@ -1817,12 +1815,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
});
}
//4.按用户数降序排序并返回
Collections.sort(resultList, (o1, o2) -> {
//NumConstant.FOUR.按用户数降序排序并返回
resultList.sort((o1, o2) -> {
//降序
return o2.getTopicTotal().compareTo(o1.getTopicTotal());
});
AtomicInteger i = new AtomicInteger(1);
AtomicInteger i = new AtomicInteger(NumConstant.ONE);
resultList.forEach(e->e.setSort(i.getAndIncrement()));
return resultList;
}
@ -1876,24 +1874,27 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
*/
@Override
public void CustomerDataManage(CustomerDataManageFormDTO formDTO, HttpServletResponse response) throws Exception {
String openTime = formDTO.getStartTime();
List<CustomerDataManageResultDTO.CustomerDataManage> result = operateExport(formDTO).getList();
if (!CollectionUtils.isEmpty(result)){
CustomerDataManageResultDTO.CustomerDataManage c = new CustomerDataManageResultDTO.CustomerDataManage();
c.setOrgName("合计");
c.setUserCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getUserCount)));
c.setResidentCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getResidentCount)));
c.setPartyMemberCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getPartyMemberCount)));
c.setGroupCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getGroupCount)));
c.setTopicCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getTopicCount)));
c.setIssueCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getIssueCount)));
c.setProjectCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getProjectCount)));
c.setClosedProjectCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getClosedProjectCount)));
c.setPatrolPeopleCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolPeopleCount)));
c.setPatrolCount(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolCount)));
c.setPatrolDurationInteger(result.stream().collect(Collectors.summingInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolDurationInteger)));
c.setUserCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getUserCount).sum());
c.setResidentCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getResidentCount).sum());
c.setPartyMemberCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getPartyMemberCount).sum());
c.setGroupCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getGroupCount).sum());
c.setTopicCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getTopicCount).sum());
c.setIssueCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getIssueCount).sum());
c.setProjectCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getProjectCount).sum());
c.setClosedProjectCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getClosedProjectCount).sum());
c.setPatrolPeopleCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolPeopleCount).sum());
c.setPatrolRoutineWorkTimes(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolRoutineWorkTimes).sum());
c.setPatrolCount(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolCount).sum());
c.setPatrolDurationInteger(result.stream().mapToInt(CustomerDataManageResultDTO.CustomerDataManage::getPatrolDurationInteger).sum());
c.setPatrolDuration(getHm(c.getPatrolDurationInteger()));
result.add(c);
}
formDTO.setStartTime(openTime);
String fileName = excelName(formDTO);
ExcelUtils.exportExcelToTargetDisposeAll(response,fileName,result, CustomerDataManageExcel.class);
}
@ -1908,7 +1909,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
String result = "0分钟";
if (seconds >= NumConstant.SIXTY) {
Integer hours = seconds / 3600;
Integer minutes = seconds % 3600 / 60;
Integer minutes = seconds % 3600 / NumConstant.SIXTY;
result = (hours < NumConstant.ONE ? "" : hours + "小时") + (minutes < NumConstant.ONE ? "" : minutes + "分钟");
}else if (seconds < NumConstant.SIXTY && seconds > NumConstant.ZERO){
result = "1分钟";
@ -1928,20 +1929,20 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
s.append(agencyName);
if (StringUtils.isNotBlank(formDTO.getStartTime())){
String startTime = formDTO.getStartTime();
String sYear = startTime.substring(0, 4);
String sMonth = startTime.substring(4, 6);
String sDay = startTime.substring(6, 8);
String sYear = startTime.substring(NumConstant.ZERO, NumConstant.FOUR);
String sMonth = startTime.substring(NumConstant.FOUR, NumConstant.SIX);
String sDay = startTime.substring(NumConstant.SIX, NumConstant.EIGHT);
String endTime = formDTO.getEndTime();
String eYear = endTime.substring(0, 4);
String eMonth = endTime.substring(4, 6);
String eDay = endTime.substring(6, 8);
String eYear = endTime.substring(NumConstant.ZERO, NumConstant.FOUR);
String eMonth = endTime.substring(NumConstant.FOUR, NumConstant.SIX);
String eDay = endTime.substring(NumConstant.SIX, NumConstant.EIGHT);
s.append(sYear).append("年").append(sMonth).append("月").append(sDay).append("日-")
.append(eYear).append("年").append(eMonth).append("月").append(eDay).append("日区间新增值");
}else {
String endTime = formDTO.getEndTime();
String eYear = endTime.substring(0, 4);
String eMonth = endTime.substring(4, 6);
String eDay = endTime.substring(6, 8);
String eYear = endTime.substring(NumConstant.ZERO, NumConstant.FOUR);
String eMonth = endTime.substring(NumConstant.FOUR, NumConstant.SIX);
String eDay = endTime.substring(NumConstant.SIX, NumConstant.EIGHT);
s.append(eYear).append("年").append(eMonth).append("月").append(eDay).append("日截止累计值");
}
return s.toString();
@ -1976,7 +1977,7 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
}
//组织或网格Id集合
List<String> idList = agencyGrid.getAgencyGridList().stream().map(ScreenAgencyOrGridListDTO.AgencyGrid::getOrgId).collect(Collectors.toList());
formDTO.setDataType(!"community".equals(agencyGrid.getLevel()) ? "agency" : "grid");
formDTO.setDataType(!OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) ? OrgTypeEnum.AGENCY.getCode() : OrgTypeEnum.GRID.getCode());
formDTO.setIdList(idList);
resultDTO.setTotal(idList.size());
@ -1984,25 +1985,27 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
formDTO.setSourceType("end");
List<CustomerDataManageResultDTO.CustomerDataManage> userEnd = dataStatsDao.regUserList(formDTO);
HashMap<String, CustomerDataManageResultDTO.CustomerDataManage> uEndMap = new HashMap<>();
userEnd.stream().forEach(u->uEndMap.put(u.getOrgId(),u));
userEnd.forEach(u->uEndMap.put(u.getOrgId(),u));
List<CustomerDataManageResultDTO.CustomerDataManage> groupEnd = dataStatsDao.groupList(formDTO);
HashMap<String, CustomerDataManageResultDTO.CustomerDataManage> gEndMap = new HashMap<>();
groupEnd.stream().forEach(u->gEndMap.put(u.getOrgId(),u));
groupEnd.forEach(u->gEndMap.put(u.getOrgId(),u));
List<CustomerDataManageResultDTO.CustomerDataManage> topicEnd = dataStatsDao.topicList(formDTO);
HashMap<String, CustomerDataManageResultDTO.CustomerDataManage> tEndMap = new HashMap<>();
topicEnd.stream().forEach(u->tEndMap.put(u.getOrgId(),u));
topicEnd.forEach(u->tEndMap.put(u.getOrgId(),u));
List<CustomerDataManageResultDTO.CustomerDataManage> issueEnd = dataStatsDao.issueList(formDTO);
HashMap<String, CustomerDataManageResultDTO.CustomerDataManage> iEndMap = new HashMap<>();
issueEnd.stream().forEach(u->iEndMap.put(u.getOrgId(),u));
issueEnd.forEach(u->iEndMap.put(u.getOrgId(),u));
List<CustomerDataManageResultDTO.CustomerDataManage> projectEnd = dataStatsDao.projectList(formDTO);
HashMap<String, CustomerDataManageResultDTO.CustomerDataManage> pEndMap = new HashMap<>();
projectEnd.stream().forEach(u->pEndMap.put(u.getOrgId(),u));
projectEnd.forEach(u->pEndMap.put(u.getOrgId(),u));
//巡查数据不区分区间差值,只计算累计值,人员做去重处理且是有巡查记录的人员 ==
CustomerDataManageFormDTO patrolForm = ConvertUtils.sourceToTarget(formDTO,CustomerDataManageFormDTO.class);
patrolForm.setStartTime(startTimeForm);
List<CustomerDataManageResultDTO.CustomerDataManage> patrolEnd = statsStaffPatrolRecordDailyService.patrolList(patrolForm);
//4.判断是否需要查询起始日期用户、群组、话题、议题、项目、巡查数据
//获取例行工作次数
List<CustomerDataManageResultDTO.CustomerDataManage> workCountList = statsStaffPatrolRecordDailyService.getPatrolRecordCount(patrolForm);
//NumConstant.FOUR.判断是否需要查询起始日期用户、群组、话题、议题、项目、巡查数据
HashMap<String, CustomerDataManageResultDTO.CustomerDataManage> uStartMap = new HashMap<>();
HashMap<String, CustomerDataManageResultDTO.CustomerDataManage> gStartMap = new HashMap<>();
HashMap<String, CustomerDataManageResultDTO.CustomerDataManage> tStartMap = new HashMap<>();
@ -2011,87 +2014,101 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
if ("Interval".equals(formDTO.getType())) {
formDTO.setSourceType("start");
List<CustomerDataManageResultDTO.CustomerDataManage> userStart = dataStatsDao.regUserList(formDTO);
userStart.stream().forEach(u->uStartMap.put(u.getOrgId(),u));
userStart.forEach(u->uStartMap.put(u.getOrgId(),u));
List<CustomerDataManageResultDTO.CustomerDataManage> groupStart = dataStatsDao.groupList(formDTO);
groupStart.stream().forEach(u->gStartMap.put(u.getOrgId(),u));
groupStart.forEach(u->gStartMap.put(u.getOrgId(),u));
List<CustomerDataManageResultDTO.CustomerDataManage> topicStart = dataStatsDao.topicList(formDTO);
topicStart.stream().forEach(u->tStartMap.put(u.getOrgId(),u));
topicStart.forEach(u->tStartMap.put(u.getOrgId(),u));
List<CustomerDataManageResultDTO.CustomerDataManage> issueStart = dataStatsDao.issueList(formDTO);
issueStart.stream().forEach(u->iStartMap.put(u.getOrgId(),u));
issueStart.forEach(u->iStartMap.put(u.getOrgId(),u));
List<CustomerDataManageResultDTO.CustomerDataManage> projectStart = dataStatsDao.projectList(formDTO);
projectStart.stream().forEach(u->pStartMap.put(u.getOrgId(),u));
projectStart.forEach(u->pStartMap.put(u.getOrgId(),u));
}
//5.封装数据
agencyGrid.getAgencyGridList().forEach(org -> {
for (ScreenAgencyOrGridListDTO.AgencyGrid org : agencyGrid.getAgencyGridList()) {
CustomerDataManageResultDTO.CustomerDataManage dto = new CustomerDataManageResultDTO.CustomerDataManage();
dto.setOrgId(org.getOrgId());
dto.setOrgName(org.getOrgName());
int user = 0;
int resi = 0;
int part = 0;
if(uEndMap.containsKey(org.getOrgId())){
int user = NumConstant.ZERO;
int resi = NumConstant.ZERO;
int part = NumConstant.ZERO;
if (uEndMap.containsKey(org.getOrgId())) {
user = uEndMap.get(org.getOrgId()).getUserCount();
resi = uEndMap.get(org.getOrgId()).getResidentCount();
part = uEndMap.get(org.getOrgId()).getPartyMemberCount();
if ("Interval".equals(formDTO.getType())&&uStartMap.containsKey(org.getOrgId())) {
if ("Interval".equals(formDTO.getType()) && uStartMap.containsKey(org.getOrgId())) {
user = user - uStartMap.get(org.getOrgId()).getUserCount();
resi = resi - uStartMap.get(org.getOrgId()).getResidentCount();
part = part - uStartMap.get(org.getOrgId()).getPartyMemberCount();
}
}
int group = 0;
if(gEndMap.containsKey(org.getOrgId())){
int group = NumConstant.ZERO;
if (gEndMap.containsKey(org.getOrgId())) {
group = gEndMap.get(org.getOrgId()).getGroupCount();
if ("Interval".equals(formDTO.getType())&&gStartMap.containsKey(org.getOrgId())) {
if ("Interval".equals(formDTO.getType()) && gStartMap.containsKey(org.getOrgId())) {
group = group - gStartMap.get(org.getOrgId()).getGroupCount();
}
}
int topic = 0;
if(tEndMap.containsKey(org.getOrgId())){
int topic = NumConstant.ZERO;
if (tEndMap.containsKey(org.getOrgId())) {
topic = tEndMap.get(org.getOrgId()).getTopicCount();
if ("Interval".equals(formDTO.getType())&&tStartMap.containsKey(org.getOrgId())) {
if ("Interval".equals(formDTO.getType()) && tStartMap.containsKey(org.getOrgId())) {
topic = topic - tStartMap.get(org.getOrgId()).getTopicCount();
}
}
int issue = 0;
if(iEndMap.containsKey(org.getOrgId())){
int issue = NumConstant.ZERO;
if (iEndMap.containsKey(org.getOrgId())) {
issue = iEndMap.get(org.getOrgId()).getIssueCount();
if ("Interval".equals(formDTO.getType())&&iStartMap.containsKey(org.getOrgId())) {
if ("Interval".equals(formDTO.getType()) && iStartMap.containsKey(org.getOrgId())) {
issue = issue - iStartMap.get(org.getOrgId()).getIssueCount();
}
}
int project = 0;
int closed = 0;
if(pEndMap.containsKey(org.getOrgId())){
int project = NumConstant.ZERO;
int closed = NumConstant.ZERO;
if (pEndMap.containsKey(org.getOrgId())) {
project = pEndMap.get(org.getOrgId()).getProjectCount();
closed = pEndMap.get(org.getOrgId()).getClosedProjectCount();
if ("Interval".equals(formDTO.getType())&&pStartMap.containsKey(org.getOrgId())) {
if ("Interval".equals(formDTO.getType()) && pStartMap.containsKey(org.getOrgId())) {
project = project - pStartMap.get(org.getOrgId()).getProjectCount();
closed = closed - pStartMap.get(org.getOrgId()).getClosedProjectCount();
}
}
int patro = 0;
int patroCount = 0;
int patro = NumConstant.ZERO;
int patroCount = NumConstant.ZERO;
String patrolDuration = "";
int patrolDurationInteger = 0;
int patrolDurationInteger = NumConstant.ZERO;
HashSet set = new HashSet();
for (CustomerDataManageResultDTO.CustomerDataManage u : patrolEnd) {
if ("community".equals(agencyGrid.getLevel()) && org.getOrgId().equals(u.getOrgId())) {
if (OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) && org.getOrgId().equals(u.getOrgId())) {
patroCount += u.getPatrolCount();
patrolDurationInteger += u.getPatrolDurationInteger();
set.add(u.getStaffId());
}
if (!"community".equals(agencyGrid.getLevel()) && u.getOrgId().contains(org.getOrgId())) {
if (!OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) && u.getOrgId().contains(org.getOrgId())) {
patroCount += u.getPatrolCount();
patrolDurationInteger += u.getPatrolDurationInteger();
set.add(u.getStaffId());
}
}
//例行工作次数累加
int patrolRoutineWorkTimes = NumConstant.ZERO;
if (CollectionUtils.isNotEmpty(workCountList) && workCountList.get(NumConstant.ZERO) != null) {
for (CustomerDataManageResultDTO.CustomerDataManage work : workCountList) {
if (OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) && org.getOrgId().equals(work.getOrgId())) {
patrolRoutineWorkTimes += work.getPatrolRoutineWorkTimes();
set.add(work.getStaffId());
} else if (!OrgLevelEnum.COMMUNITY.getCode().equals(agencyGrid.getLevel()) && work.getOrgId().contains(org.getOrgId())) {
patrolRoutineWorkTimes += work.getPatrolRoutineWorkTimes();
set.add(work.getStaffId());
}
}
}
patro = set.size();
Integer minutes = patrolDurationInteger / 60;
patrolDuration = (minutes / 60 > 0 ? minutes / 60 + "小时" : "") + (minutes % 60 > 0 ? minutes % 60 + "分钟" : "0分钟");
patrolDuration = (minutes / 60 > NumConstant.ZERO ? minutes / 60 + "小时" : "") + (minutes % 60 > NumConstant.ZERO ? minutes % 60 + "分钟" : "0分钟");
dto.setUserCount(user);
dto.setResidentCount(resi);
@ -2106,10 +2123,12 @@ public class DataStatsServiceImpl implements DataStatsService, ResultDataResolve
dto.setPatrolDuration(patrolDuration);
dto.setPatrolDurationInteger(patrolDurationInteger);
dto.setPatrolRoutineWorkTimes(patrolRoutineWorkTimes);
dataManageList.add(dto);
});
}
//6.默认按用户总数降序
//NumConstant.SIX.默认按用户总数降序
Collections.sort(dataManageList, new Comparator<CustomerDataManageResultDTO.CustomerDataManage>() {
@Override
public int compare(CustomerDataManageResultDTO.CustomerDataManage o1, CustomerDataManageResultDTO.CustomerDataManage o2) {

22
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/StatsStaffPatrolRecordDailyService.java

@ -35,12 +35,13 @@ import java.util.List;
public interface StatsStaffPatrolRecordDailyService extends BaseService<StatsStaffPatrolRecordDailyEntity> {
/**
* desc:获取组织或网格的 时间段内的总次数等
* desc:获取组织或网格的 时间段内的总次数等
*
* @param orgIdList
* @param startDateId
* @param endDateId
* @return
*/
* @param startDateId
* @param endDateId
* @return
*/
List<PatrolDailySumResult> getPatrolSumList(List<String> orgIdList, String startDateId, String endDateId);
/**
@ -51,11 +52,20 @@ public interface StatsStaffPatrolRecordDailyService extends BaseService<StatsSta
/**
* 查询工作人员巡查记录按日统计
* @param gridPids 记录所属的网格的pids
*
* @param gridPids 记录所属的网格的pids
* @param userIds
* @param startDateID
* @param endDateID
* @return
*/
List<StaffPatrolRecordDailyResultDTO> listStaffPatrolRecordDailyAnalysis(String gridPids, String gridId, List<String> userIds, String startDateID, String endDateID);
/**
* desc:获取巡查日统计的相关次数
*
* @param patrolForm
* @return
*/
List<CustomerDataManageResultDTO.CustomerDataManage> getPatrolRecordCount(CustomerDataManageFormDTO patrolForm);
}

5
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/StatsStaffPatrolRecordDailyServiceImpl.java

@ -52,4 +52,9 @@ public class StatsStaffPatrolRecordDailyServiceImpl extends BaseServiceImpl<Stat
public List<StaffPatrolRecordDailyResultDTO> listStaffPatrolRecordDailyAnalysis(String gridPids, String gridId, List<String> userIds, String startDateID, String endDateID) {
return baseDao.listStaffPatrolRecordDailyAnalysis(gridPids, gridId, userIds, startDateID, endDateID);
}
@Override
public List<CustomerDataManageResultDTO.CustomerDataManage> getPatrolRecordCount(CustomerDataManageFormDTO patrolForm) {
return baseDao.getRoutineWorkCount(patrolForm);
}
}

6
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java

@ -182,4 +182,10 @@ public interface GovOrgService {
* @Description 查询组织的直属下级组织下网格活跃度统计--文件导出
**/
void grdiLivelyExport(HttpServletResponse response, GridLivelyFormDTO formDTO);
/**
* @Author sun
* @Description 查询组织的直属下级组织下网格活跃度统计--文件导出
**/
void pcworkRecordListExportSendMsg(GridLivelyFormDTO formDTO);
}

97
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java

@ -1,18 +1,27 @@
package com.epmet.dataaggre.service.govorg.impl;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.fastjson.JSON;
import com.dingtalk.api.request.OapiRobotSendRequest;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.DingDingRobotConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.dto.form.DingTextBriefNessFormDTO;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dataaggre.constant.DataSourceConstant;
import com.epmet.dataaggre.dao.govorg.*;
import com.epmet.dataaggre.dto.epmetuser.result.ListStaffResultDTO;
@ -28,13 +37,23 @@ import com.epmet.dataaggre.service.datastats.DataStatsService;
import com.epmet.dataaggre.service.epmetuser.EpmetUserService;
import com.epmet.dataaggre.service.govorg.GovOrgService;
import com.epmet.dataaggre.service.opercrm.CustomerRelation;
import com.epmet.dto.result.UploadImgResultDTO;
import com.epmet.feign.OssFeignClient;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.entity.ContentType;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.*;
@ -67,6 +86,8 @@ public class GovOrgServiceImpl implements GovOrgService {
private EpmetUserService epmetUserService;
@Autowired
private DataStatsService dataStatsService;
@Autowired
private OssFeignClient ossFeignClient;
/**
* @param staffId
@ -690,4 +711,80 @@ public class GovOrgServiceImpl implements GovOrgService {
return name.toString();
}
/**
* @Author sun
* @Description 查询组织的直属下级组织下网格活跃度统计--文件导出
**/
@Override
public void pcworkRecordListExportSendMsg(GridLivelyFormDTO formDTO) {
List<GridLivelyExcel> data = ConvertUtils.sourceToTarget(grdiLively(formDTO), GridLivelyExcel.class);
if(CollectionUtils.isEmpty(data)){
log.warn(String.format("网格员活跃度统计数据查询为空,入参【%s】", JSON.toJSONString(formDTO)));
return;
}
ExportParams exportParams = new ExportParams();
String sheetName = excelSheetName(formDTO);
exportParams.setSheetName(sheetName);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams,
GridLivelyExcel.class, data);
// 文件名
String resultDescFileName = sheetName.concat(".xls");
FileItemFactory factory = new DiskFileItemFactory(16, null);
FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, resultDescFileName);
OutputStream os = null;
Result<UploadImgResultDTO> uploadResult = null;
try {
os = fileItem.getOutputStream();
workbook.write(os);
uploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem));
} catch (Exception e) {
String errormsg = ExceptionUtils.getErrorStackTrace(e);
log.warn("【网格活跃度统计】上传错误描述文件异常:{}", errormsg);
} finally {
try {
os.close();
} catch (IOException e) {
String errormsg = ExceptionUtils.getErrorStackTrace(e);
log.warn("【网格活跃度统计】上传错误描述文件关闭输出流:{}", errormsg);
}
try {
fileItem.delete();
} catch (Exception e) {
String errormsg = ExceptionUtils.getErrorStackTrace(e);
log.warn("【网格活跃度统计】上传错误描述文件删除临时文件:{}", errormsg);
}
}
log.warn(String.format("网格员活跃度统计数据查询为空,返参【%s】", JSON.toJSONString(uploadResult)));
if (uploadResult == null || !uploadResult.success()) {
log.warn("【网格活跃度统计】调用OSS上传结果描述文件失败");
} else {
//EPMETV3群机器人
String secret = DingDingRobotConstant.V3_ROBOT_SECRET;
String url = DingDingRobotConstant.V3_ROBOT_URL;
// String secret = DingDingRobotConstant.YZM_TEST_SECRET;
// String url = DingDingRobotConstant.YZM_TEST_URL;
DingTextBriefNessFormDTO dingTalkTextMsg=new DingTextBriefNessFormDTO();
dingTalkTextMsg.setMsgtype("text");
//小雷哥手机号:18660295251,
OapiRobotSendRequest.At at = new OapiRobotSendRequest.At();
at.setAtMobiles(Arrays.asList("18660295251"));
at.setIsAtAll(false);
dingTalkTextMsg.setAt(at);
//文本方式发送
OapiRobotSendRequest.Text text = new OapiRobotSendRequest.Text();
text.setContent("网格活跃度统计: \n" +
"起止时间: " + formDTO.getStartTime().concat(StrConstant.UNDER_LINE).concat(formDTO.getEndTime()) + "\n" +
"文件下载地址: " + uploadResult.getData().getUrl() + "\n"+
"请查收@18660295251");
dingTalkTextMsg.setText(text);
HttpClientManager.getInstance().sendDingMsg(JSON.toJSONString(dingTalkTextMsg), url, secret);
}
}
}

11
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/bootstrap.yml

@ -191,3 +191,14 @@ dingTalk:
logging:
level:
com.epmet.dataaggre: debug
thread:
# 线程池配置
threadPool:
enableCustomize: @thread.threadPool.enable-customize@
corePoolSize: @thread.threadPool.core-pool-size@
maxPoolSize: @thread.threadPool.max-pool-size@
queueCapacity: @thread.threadPool.queue-capacity@
keepAliveSeconds: @thread.threadPool.keep-alive-seconds@
threadNamePrefix: @thread.threadPool.thread-name-prefix@
rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@

29
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/datastats/DatsStatsDao.xml

@ -331,17 +331,19 @@
<select id="getSubAgencyProject" resultType="com.epmet.dataaggre.dto.datastats.result.SubAgencyProjectResultDTO">
SELECT
agency_id AS agencyId,
IFNULL(project_total, 0) AS "projectTotal",
IFNULL(pending_total, 0) AS "pendingTotal",
IFNULL(closed_total, 0) AS "closedProjectTotal"
<!-- 平阴三个街道的统计数据同一组织同一天会存在两条数据,一条是上报的一条是小程序统计的,所以查询的时候需要按组织分组sum -->
SUM(IFNULL(project_total, 0)) AS "projectTotal",
SUM(IFNULL(pending_total, 0)) AS "pendingTotal",
SUM(IFNULL(closed_total, 0)) AS "closedProjectTotal"
FROM
fact_agency_project_daily
WHERE
del_flag = '0'
AND date_id = #{dateId}
<foreach item="agencyId" collection="agencyIds" open="AND (" separator="or" close=")" index="">
agency_id = #{agencyId}
<foreach collection="agencyIds" item="agencyId" open="AND agency_id IN (" separator="," close=")">
#{agencyId}
</foreach>
GROUP BY agency_id
ORDER BY
project_total DESC
</select>
@ -349,17 +351,19 @@
<select id="getSubGridProject" resultType="com.epmet.dataaggre.dto.datastats.result.SubGridProjectResultDTO">
SELECT
grid_id AS gridId,
IFNULL(project_total, 0) AS "projectTotal",
IFNULL(pending_total, 0) AS "pendingTotal",
IFNULL(closed_total, 0) AS "closedProjectTotal"
<!-- 平阴三个街道的统计数据同一网格同一天会存在两条数据,一条是上报的一条是小程序统计的,所以查询的时候需要按网格分组sum -->
SUM(IFNULL(project_total, 0)) AS "projectTotal",
SUM(IFNULL(pending_total, 0)) AS "pendingTotal",
SUM(IFNULL(closed_total, 0)) AS "closedProjectTotal"
FROM
fact_grid_project_daily
WHERE
del_flag = '0'
AND date_id = #{dateId}
<foreach item="gridId" collection="gridIds" open="AND (" separator="or" close=")" index="">
grid_id = #{gridId}
<foreach collection="gridIds" item="gridId" open="AND grid_id IN (" separator="," close=")">
#{gridId}
</foreach>
GROUP BY grid_id
ORDER BY
project_total DESC
</select>
@ -1004,7 +1008,8 @@
FROM
(
SELECT DISTINCT
date_id dateId, project_total projectCount, closed_total closedProjectCount
<!-- 平阴的三个街道的数据在表里同一天会存在两条,一条是上报的一条是小程序统计的,所以查询时需要sum -->
date_id dateId, SUM(project_total) projectCount, SUM(closed_total) closedProjectCount
<choose>
<when test='dataType == "agency"'>
, agency_id orgId
@ -1028,6 +1033,7 @@
<if test='endTime != "" and endTime != null '>
AND date_id <![CDATA[<=]]> #{endTime}
</if>
GROUP BY date_id, agency_id
ORDER BY date_id ASC
</if>
<if test='sourceType != "" and sourceType == "end" and endTime != "" and endTime != null '>
@ -1035,6 +1041,7 @@
AND date_id <![CDATA[>=]]> #{startTime}
</if>
AND date_id <![CDATA[<=]]> #{endTime}
GROUP BY date_id, agency_id
ORDER BY date_id DESC
</if>
<choose>

37
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StatsStaffPatrolRecordDailyDao.xml

@ -86,5 +86,42 @@
sprd.STAFF_ID,
sprd.GRID_ID
</select>
<select id="getRoutineWorkCount" resultType="com.epmet.dataaggre.dto.datastats.result.CustomerDataManageResultDTO$CustomerDataManage">
SELECT
grid_id, staff_id staffId, sum(ROUTINE_WORK_COUNT) patrolRoutineWorkTimes
<choose>
<when test='dataType == "agency"'>
, grid_pids orgId
</when>
<otherwise>
, grid_id orgId
</otherwise>
</choose>
FROM
stats_staff_patrol_record_daily
WHERE del_flag = '0'
AND ROUTINE_WORK_COUNT > 0
<if test='type != "" and type == "Interval" and startTime != "" and startTime != null '>
AND date_id <![CDATA[>=]]> #{startTime}
</if>
<if test='endTime != "" and endTime != null '>
AND date_id <![CDATA[<=]]> #{endTime}
</if>
<choose>
<when test='dataType == "agency"'>
<foreach collection="idList" item="id" open="AND (" close=")" separator=" OR ">
grid_pids like concat('%', #{id}, '%')
</foreach>
</when>
<otherwise>
<foreach collection="idList" item="id" open="AND grid_id IN (" separator="," close=")">
#{id}
</foreach>
</otherwise>
</choose>
group by
STAFF_ID,
GRID_ID
</select>
</mapper>

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

@ -192,6 +192,15 @@
<!--钉钉 机器人地址-->
<dingTalk.robot.webHook>https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4</dingTalk.robot.webHook>
<dingTalk.robot.secret>SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd</dingTalk.robot.secret>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>data-report</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
</properties>
</profile>
<profile>
@ -246,6 +255,15 @@
<!--钉钉 机器人地址-->
<dingTalk.robot.webHook>https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4</dingTalk.robot.webHook>
<dingTalk.robot.secret>SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd</dingTalk.robot.secret>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>data-report</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
</properties>
</profile>
<profile>
@ -300,6 +318,15 @@
<!--测试钉钉 机器人地址-->
<dingTalk.robot.webHook>https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4</dingTalk.robot.webHook>
<dingTalk.robot.secret>SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd</dingTalk.robot.secret>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>data-report</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
</properties>
</profile>
<profile>
@ -354,6 +381,15 @@
<!--生产钉钉 机器人地址-->
<dingTalk.robot.webHook>https://oapi.dingtalk.com/robot/send?access_token=a5f66c3374b1642fe2142dbf56d5997e280172d4e8f2b546c9423a68c82ece6c</dingTalk.robot.webHook>
<dingTalk.robot.secret>SEC95f4f40b533ad379ea6a6d1af6dd37029383cfe1b7cd96dfac2678be2c1c3ed1</dingTalk.robot.secret>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>data-report</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
</properties>
</profile>
</profiles>

3
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/ScreenProjectController.java

@ -204,6 +204,7 @@ public class ScreenProjectController {
//tokenDto.setUserId("36bc0fb38565ecdebf8ab9b476b44548");
//tokenDto.setCustomerId("45687aa479955f9d06204d415238f7cc");
ValidatorUtils.validateEntity(formDTO, ProjectCategoryFormDTO.CategoryProjectExportForm.class);
String openTime = formDTO.getStartTime();
List<ProjectCategoryResultDTO> data = screenProjectService.selectProjectCategory(formDTO, tokenDto);
String templatePath = "excel/project_category_temp.xlsx";
@ -216,7 +217,7 @@ public class ScreenProjectController {
Map<String,Object> mapData = new HashMap<>();
mapData.put("list",resultDTOList);
mapData.put("orgName", formDTO.getOrgName());
mapData.put("exportDate",getExportDateStr(formDTO.getStartTime(),formDTO.getEndTime()));
mapData.put("exportDate", getExportDateStr(openTime, formDTO.getEndTime()));
Workbook workbook = ExcelExportUtil.exportExcel(new TemplateExportParams(templatePath), mapData);
response.setHeader("content-Type", "application/vnd.ms-excel");
response.addHeader("Content-Disposition", "attachment;fileName=" + URLEncoder.encode("项目分类统计.xls", "UTF-8"));

11
epmet-module/data-report/data-report-server/src/main/resources/bootstrap.yml

@ -158,3 +158,14 @@ shutdown:
graceful:
enable: true #是否开启优雅停机
waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警
thread:
# 线程池配置
threadPool:
enableCustomize: @thread.threadPool.enable-customize@
corePoolSize: @thread.threadPool.core-pool-size@
maxPoolSize: @thread.threadPool.max-pool-size@
queueCapacity: @thread.threadPool.queue-capacity@
keepAliveSeconds: @thread.threadPool.keep-alive-seconds@
threadNamePrefix: @thread.threadPool.thread-name-prefix@
rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@

13
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/UserGroupIdDTO.java

@ -0,0 +1,13 @@
package com.epmet.dto.extract;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class UserGroupIdDTO implements Serializable {
private String userId;
private List<String> groupIdList;
}

53
epmet-module/data-statistical/data-statistical-server/pom.xml

@ -286,11 +286,14 @@
<!--flyway migration 数据库迁移工具-->
<spring.flyway.enabled>false</spring.flyway.enabled>
<!--线程池配置-->
<thread.pool.core-pool-size>5</thread.pool.core-pool-size>
<thread.pool.max-pool-size>8</thread.pool.max-pool-size>
<thread.pool.queue-capacity>10</thread.pool.queue-capacity>
<thread.pool.keep-alive>30</thread.pool.keep-alive>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>data-statistical</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
<!--钉钉 机器人地址-->
<dingTalk.robot.webHook>https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4</dingTalk.robot.webHook>
@ -415,11 +418,14 @@
<!--flyway migration 数据库迁移工具-->
<spring.flyway.enabled>false</spring.flyway.enabled>
<!--线程池配置-->
<thread.pool.core-pool-size>5</thread.pool.core-pool-size>
<thread.pool.max-pool-size>8</thread.pool.max-pool-size>
<thread.pool.queue-capacity>10</thread.pool.queue-capacity>
<thread.pool.keep-alive>30</thread.pool.keep-alive>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>data-statistical</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
<!--钉钉 机器人地址-->
<dingTalk.robot.webHook>https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4</dingTalk.robot.webHook>
@ -543,11 +549,15 @@
<!--flyway migration 数据库迁移工具-->
<spring.flyway.enabled>false</spring.flyway.enabled>
<!--线程池配置-->
<thread.pool.core-pool-size>5</thread.pool.core-pool-size>
<thread.pool.max-pool-size>8</thread.pool.max-pool-size>
<thread.pool.queue-capacity>10</thread.pool.queue-capacity>
<thread.pool.keep-alive>30</thread.pool.keep-alive>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>data-statistical</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
<!--测试钉钉 机器人地址-->
<dingTalk.robot.webHook>https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4</dingTalk.robot.webHook>
<dingTalk.robot.secret>SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd</dingTalk.robot.secret>
@ -667,11 +677,14 @@
<!--flyway migration 数据库迁移工具-->
<spring.flyway.enabled>false</spring.flyway.enabled>
<!--线程池配置-->
<thread.pool.core-pool-size>5</thread.pool.core-pool-size>
<thread.pool.max-pool-size>8</thread.pool.max-pool-size>
<thread.pool.queue-capacity>10</thread.pool.queue-capacity>
<thread.pool.keep-alive>30</thread.pool.keep-alive>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>data-statistical</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
<!--生产钉钉 机器人地址-->
<dingTalk.robot.webHook>https://oapi.dingtalk.com/robot/send?access_token=a5f66c3374b1642fe2142dbf56d5997e280172d4e8f2b546c9423a68c82ece6c</dingTalk.robot.webHook>

49
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/config/AsyncConfig.java

@ -1,49 +0,0 @@
package com.epmet.config;
import com.epmet.properties.ThreadProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
/**
* 线程池配置类
*/
@Configuration
@EnableConfigurationProperties(ThreadProperties.class)
@EnableAsync
public class AsyncConfig {
@Autowired
private ThreadProperties threadProperties;
@Bean
public Executor executor() {
ThreadProperties.ThreadPoolProperties threadPoolProps = threadProperties.getThreadPool();
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(threadPoolProps.getCorePoolSize());
executor.setMaxPoolSize(threadPoolProps.getMaxPoolSize());
executor.setQueueCapacity(threadPoolProps.getQueueCapacity());
executor.setThreadNamePrefix("data-stats-");
// rejection-policy:当pool已经达到max size的时候,如何处理新任务
// CALLER_RUNS:不在新线程中执行任务,而是由调用者所在的线程来执行
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); //对拒绝task的处理策略
executor.setKeepAliveSeconds(threadPoolProps.getKeepAlive());
executor.initialize();
return executor;
}
@Bean
public ExecutorService executorService() {
ThreadPoolTaskExecutor executor = (ThreadPoolTaskExecutor) executor();
return executor.getThreadPoolExecutor();
}
}

35
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java

@ -621,20 +621,23 @@ public class DemoController {
private CalCpcIndexService calCpcIndexService;
@PostMapping("calCpcPartyAbility")
public Result calCpcPartyAbility(@RequestParam("customerId") String customerId, @RequestParam("monthId")String monthId) {
public Result calCpcPartyAbility(@RequestParam("customerId") String customerId, @RequestParam("monthId") String monthId) {
long startCpc = System.currentTimeMillis();
if (StringUtils.isNotBlank(customerId) && StringUtils.isNotBlank(monthId)) {
calCpcIndexService.calCpcPartyAbility(customerId,monthId);
}else{
calCpcIndexService.calCpcPartyAbilityV2(customerId, monthId);
// calCpcIndexService.calCpcPartyAbility(customerId, monthId);
} else {
QueryWrapper<DimCustomerEntity> customerEntityQueryWrapper = new QueryWrapper<>();
List<DimCustomerEntity> customerEntityList=dimCustomerDao.selectList(customerEntityQueryWrapper);
List<DimCustomerEntity> customerEntityList = dimCustomerDao.selectList(customerEntityQueryWrapper);
QueryWrapper<DimMonthEntity> wrapper = new QueryWrapper<>();
List<DimMonthEntity> dimMonthEntityList= dimMonthDao.selectList(wrapper);
for(DimCustomerEntity customerEntity:customerEntityList){
for(DimMonthEntity monthEntity:dimMonthEntityList) {
calCpcIndexService.calCpcPartyAbility(customerEntity.getId(),monthEntity.getId());
List<DimMonthEntity> dimMonthEntityList = dimMonthDao.selectList(wrapper);
for (DimCustomerEntity customerEntity : customerEntityList) {
for (DimMonthEntity monthEntity : dimMonthEntityList) {
calCpcIndexService.calCpcPartyAbilityV2(customerEntity.getId(), monthEntity.getId());
}
}
}
log.error("手动调用党员相关-党建能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCpc, customerId);
return new Result();
}
@ -1113,14 +1116,22 @@ public class DemoController {
if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)){
List<String> daysBetween = DateUtils.getDaysBetween(startDate, endDate);
daysBetween.forEach(d -> {
screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId,d);
screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId,d);
executorService.submit(() -> {
screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId,d);
});
executorService.submit(() -> {
screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId,d);
});
result.add(d);
redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("gridandorgdailynew"),customerId,result,3*24*60*60L);
});
}else {
screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId,dateId);
screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId,dateId);
executorService.submit(() -> {
screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId,dateId);
});
executorService.submit(() -> {
screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId,dateId);
});
result.add(dateId);
redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("gridandorgdailynew"),customerId,result,3*24*60*60L);
}

12
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java

@ -5,7 +5,6 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.extract.form.ExtractOriginFormDTO;
import com.epmet.dto.extract.form.ExtractScreenFormDTO;
import com.epmet.service.evaluationindex.extract.toscreen.ScreenExtractService;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
@ -13,7 +12,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.concurrent.*;
import java.util.concurrent.ExecutorService;
/**
* @Author zxc
@ -23,13 +22,10 @@ import java.util.concurrent.*;
@RestController
@RequestMapping("screenextract")
public class ScreenExtractDailyController {
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
.setNameFormat("ScreenExtractDailyController-pool-%d").build();
ExecutorService threadPool = new ThreadPoolExecutor(1, 1,
10L, TimeUnit.MINUTES,
new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy());
@Autowired
private ScreenExtractService screenExtractService;
@Autowired
private ExecutorService executorService;
/**
* @param extractOriginFormDTO
@ -39,7 +35,7 @@ public class ScreenExtractDailyController {
*/
@PostMapping("extractdailyall")
public Result screenExtractDaily(@RequestBody ExtractOriginFormDTO extractOriginFormDTO) {
threadPool.submit(() -> {
executorService.submit(() -> {
log.info("screenExtractDaily start,param:{}", JSON.toJSONString(extractOriginFormDTO));
try {
screenExtractService.extractDailyAll(extractOriginFormDTO);

71
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/external/IndexCalculateController.java

@ -1,5 +1,6 @@
package com.epmet.controller.external;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.enums.EnvEnum;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.RedisKeys;
@ -16,7 +17,6 @@ import com.epmet.model.CalculateFlagModel;
import com.epmet.service.evaluationindex.indexcal.CpcIndexCalculateService;
import com.epmet.service.evaluationindex.indexcal.IndexCalculateService;
import com.epmet.util.DimIdGenerator;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -27,7 +27,8 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
/**
* 指标计算controller
@ -39,13 +40,6 @@ import java.util.concurrent.*;
@RestController
@RequestMapping("indexcalculate")
public class IndexCalculateController {
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
.setNameFormat("indexcalculate-pool-%d").build();
ExecutorService singleThreadPool = new ThreadPoolExecutor(1, 1,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
@Autowired
private IndexCalculateService indexCalculateService;
@ -54,6 +48,9 @@ public class IndexCalculateController {
@Autowired
private RedisUtils redisUtils;
@Autowired
private ExecutorService executorService;
// 计算同步锁
private Object statsCalLock = new Object();
@ -68,7 +65,7 @@ public class IndexCalculateController {
CalculateFlagModel flag = (CalculateFlagModel) redisUtils.get(RedisKeys.getCustomerStatsCalFlag(customerId));
flag.setStatus(CalculateStatus.PENDDING);
redisUtils.set(RedisKeys.getCustomerStatsCalFlag(customerId), flag);
log.info("客户【%s】正在执行计算,实例发生重启,修改计算状态为:calculation->pendding", customerId);
log.error("客户【%s】正在执行计算,实例发生重启,修改计算状态为:calculation->pendding", customerId);
});
}
@ -97,7 +94,7 @@ public class IndexCalculateController {
}
/**
* 按照客户计算所有指标(按照月份)
* 这个是外部客户主动调用的方法入口 按照客户计算所有指标(按照月份)
*
* @param formDTO
* @return com.epmet.commons.tools.utils.Result
@ -112,6 +109,35 @@ public class IndexCalculateController {
return new Result<Boolean>().ok(true);
}
@PostMapping("calSingle")
public Result<Boolean> calculateSingle(@RequestBody CalculateCommonFormDTO formDTO) {
long start = System.currentTimeMillis();
try {
ValidatorUtils.validateEntity(formDTO);
Boolean aBoolean = indexCalculateService.indexCalculate(formDTO);
HttpClientManager.getInstance().sendAlarmMsg(EnvEnum.getCurrentEnv().getName() + "客户Id:" + formDTO.getCustomerId() + ";monthId:" + formDTO.getMonthId() + ",calculateAll全部指标计算完成,是否成功:" + aBoolean + ",总耗时:" + (System.currentTimeMillis() - start) / 1000 + "秒");
if (aBoolean) {
return new Result<Boolean>().ok(true);
}
} catch (Exception e) {
return new Result<Boolean>().error(e.getMessage());
}
return new Result<Boolean>().error("指标计算失败");
}
/**
* desc:异步 连续计算[指定或所有内部客户][多个月份]的指标得分入口 适用于公式调整后或之前计算错误 统一计算
* @param formDTO
* @return
* @remark:不要轻易调用 因为异步 怕有冲突
*/
@PostMapping("warn/moreStats")
public Result indexStatistics(@RequestBody IndexStatisticsFormDTO formDTO){
log.error("moreStats 不要轻易调用 因为异步 怕有冲突,参数:{}", JSON.toJSONString(formDTO));
indexCalculateService.indexStatistics(formDTO);
return new Result();
}
/**
* 指标计算
*
@ -142,7 +168,7 @@ public class IndexCalculateController {
* @return
*/
private void submitCalculate(CalculateCommonFormDTO formDTO) {
Future<?> future = singleThreadPool.submit(() -> {
Future<?> future = executorService.submit(() -> {
try {
long start = System.currentTimeMillis();
Boolean aBoolean = indexCalculateService.indexCalculate(formDTO);
@ -202,21 +228,6 @@ public class IndexCalculateController {
return new Result();
}
@PostMapping("reAll")
public Result<Boolean> calculateAll(@RequestBody CalculateCommonFormDTO formDTO) {
long start = System.currentTimeMillis();
try {
Boolean aBoolean = indexCalculateService.indexCalculate(formDTO);
HttpClientManager.getInstance().sendAlarmMsg(EnvEnum.getCurrentEnv().getName() + "客户Id:" + formDTO.getCustomerId() + ";monthId:" + formDTO.getMonthId() + ",calculateAll全部指标计算完成,是否成功:" + aBoolean + ",总耗时:" + (System.currentTimeMillis() - start) / 1000 + "秒");
if (aBoolean) {
return new Result<Boolean>().ok(true);
}
} catch (Exception e) {
return new Result<Boolean>().error(e.getMessage());
}
return new Result<Boolean>().error("指标计算失败");
}
/**
* desc计算党员指标分数
*
@ -343,12 +354,6 @@ public class IndexCalculateController {
return new Result();
}*/
@PostMapping("indexstatistics")
public Result indexStatistics(@RequestBody IndexStatisticsFormDTO formDTO){
indexCalculateService.indexStatistics(formDTO);
return new Result();
}
/**
* @return com.epmet.commons.tools.utils.Result
* @param formDTO

3
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginGroupMainDailyDao.java

@ -19,6 +19,7 @@ package com.epmet.dao.evaluationindex.extract;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.extract.FactOriginGroupMainDailyDTO;
import com.epmet.dto.extract.UserGroupIdDTO;
import com.epmet.dto.extract.form.GridHeartedFormDTO;
import com.epmet.dto.extract.form.ScreenPartyLinkMassesDataFormDTO;
import com.epmet.dto.extract.result.GridGroupUserCountResultDTO;
@ -225,4 +226,6 @@ public interface FactOriginGroupMainDailyDao extends BaseDao<FactOriginGroupMain
* @return java.util.List<com.epmet.dto.extract.result.OrgStatisticsResultDTO>
*/
List<OrgStatisticsResultDTO> selectPartyMemberGroupStaticByGrid(@Param("customerId") String customerId, @Param("dateId") String dateId);
List<UserGroupIdDTO> selectGroupAndLeader(String customerId);
}

8
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginIssueLogDailyDao.java

@ -170,4 +170,12 @@ public interface FactOriginIssueLogDailyDao extends BaseDao<FactOriginIssueLogDa
* @return java.util.List<com.epmet.dto.extract.result.OrgStatisticsResultDTO>
*/
List<OrgStatisticsResultDTO> getClosedIssueIncr(@Param("customerId") String customerId, @Param("dateId") String dateId);
/**
* 查询出本月内做过议题表决的用户id
* @param customerId
* @param monthId
* @return
*/
List<String> queryVoteUserIds(@Param("customerId")String customerId, @Param("monthId")String monthId);
}

8
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginTopicLogDailyDao.java

@ -103,4 +103,12 @@ public interface FactOriginTopicLogDailyDao extends BaseDao<FactOriginTopicLogDa
* @date 2020/9/21 9:37 上午
*/
List<PartyActiveResultDTO> selectPartyActiveTopic(@Param("customerId")String customerId,@Param("monthId") String monthId,@Param("isParty") Integer isParty);
/**
* 查询出本月内评论过话题的用户id
* @param customerId
* @param monthId
* @return
*/
List<String> queryCommentTopicUserIds(@Param("customerId") String customerId, @Param("monthId")String monthId);
}

7
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java

@ -25,6 +25,7 @@ import com.epmet.dto.org.CustomerStaffGridDTO;
import com.epmet.dto.org.GridInfoDTO;
import com.epmet.dto.org.form.GridBaseInfoFormDTO;
import com.epmet.dto.org.result.CustomerGridDTO;
import com.epmet.dto.stats.DimGridDTO;
import com.epmet.dto.user.form.StaffBaseInfoFormDTO;
import com.epmet.dto.user.result.GridUserInfoDTO;
import com.epmet.entity.org.CustomerGridEntity;
@ -118,4 +119,10 @@ public interface CustomerGridDao extends BaseDao<CustomerGridEntity> {
* @Description 查询工作人员所属网格信息
**/
List<GridUserInfoDTO> getStaffGrid(StaffBaseInfoFormDTO formDTO);
/**
* @Author sun
* @Description 查询客户下有效网格列表
**/
List<DimGridDTO> gridListByCustomerId(@Param("customerId") String customerId);
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/user/StatsStaffPatrolRecordDailyDao.java

@ -43,7 +43,7 @@ public interface StatsStaffPatrolRecordDailyDao extends BaseDao<StatsStaffPatrol
* @author LiuJanJun
* @date 2021/7/9 1:57 下午
*/
Integer insertBatch(@Param("list") List<StatsStaffPatrolRecordDailyDTO> insertList);
Integer insertBatchOrUpdate(@Param("list") List<StatsStaffPatrolRecordDailyDTO> insertList);
/**
* desc: 删除内部数据

58
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/mq/ProjectChangedCustomListener.java

@ -4,12 +4,14 @@ import com.alibaba.fastjson.JSON;
import com.epmet.commons.rocketmq.constants.MQUserPropertys;
import com.epmet.commons.rocketmq.messages.DisputeProcessMQMsg;
import com.epmet.commons.rocketmq.messages.ProjectChangedMQMsg;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.distributedlock.DistributedLock;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.SpringContextUtils;
import com.epmet.constant.PingYinConstant;
import com.epmet.constant.SystemMessageType;
import com.epmet.dto.extract.form.ExtractOriginFormDTO;
import com.epmet.service.evaluationindex.extract.todata.FactOriginExtractService;
@ -66,7 +68,7 @@ public class ProjectChangedCustomListener implements MessageListenerConcurrently
} catch (Exception e) {
//失败不重发
logger.error("consumeMessage fail,msg:{}",e.getMessage());
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
return ConsumeConcurrentlyStatus.RECONSUME_LATER;
}
log.info("consumeMessage success, cost:{} ms",System.currentTimeMillis() - start);
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
@ -94,7 +96,7 @@ public class ProjectChangedCustomListener implements MessageListenerConcurrently
}
log.info("消费了项目变动消息,customer id:{}", msgObj.getCustomerId());
if (org.apache.commons.lang.StringUtils.isNotBlank(pendingMsgLabel)) {
if (StringUtils.isNotBlank(pendingMsgLabel)) {
try {
removePendingMqMsgCache(pendingMsgLabel);
} catch (Exception e) {
@ -109,19 +111,21 @@ public class ProjectChangedCustomListener implements MessageListenerConcurrently
try {
String customerId = msgObj.getCustomerId();
distributedLock = SpringContextUtils.getBean(DistributedLock.class);
lock = distributedLock.getLock(String.format("lock:project_changed:%s", customerId)
,30L, 30L, TimeUnit.SECONDS);
lock = distributedLock.getLock(String.format("lock:project_changed:%s:%s", customerId, msgObj.getProjectId())
,60L, 60L, TimeUnit.SECONDS);
if (StringUtils.isBlank(customerId)){
logger.error("consumer project_changed fail,msg:{}",customerId);
return;
}
//消息被消费太快 业务数据还没有完成 歇一会先
//睡一秒 要不然那边执行不完
try {
Thread.sleep(60L);
Thread.sleep(NumConstant.ONE_THOUSAND);
} catch (InterruptedException e) {
logger.error("consumeMessage sleep exception",e);
log.error("consumeMessage exception",e);
}
ExtractOriginFormDTO extractOriginFormDTO = new ExtractOriginFormDTO();
extractOriginFormDTO.setCustomerId(customerId);
@ -146,21 +150,8 @@ public class ProjectChangedCustomListener implements MessageListenerConcurrently
}
logger.info("consumer projectChanged msg success,{}",aBoolean);
//发送项目数据上报的mq消息
if ("6f203e30de1a65aab7e69c058826cd80".equals(customerId)) {
if ("issue_shift_project".equals(msgObj.getOperation()) || "created".equals(msgObj.getOperation()) || "close".equals(msgObj.getOperation())) {
String type;
if ("issue_shift_project".equals(msgObj.getOperation()) || "created".equals(msgObj.getOperation())) {
type = SystemMessageType.PROJECT_ADD;
} else {
type = SystemMessageType.PROJECT_EDIT;
}
List<String> projectList = new ArrayList<>();
projectList.add(msgObj.getProjectId());
DisputeProcessMQMsg msg = new DisputeProcessMQMsg(customerId, projectList, type);
SpringContextUtils.getBean(ScreenProjectDataService.class).sendProjectChangeMq(msg);
}
}
sendProject2OpenData(msgObj, customerId);
} catch (RenException e) {
// 如果是我们手动抛出的异常,说明在业务可控范围内。目前不需要MQ重试
logger.error("【RocketMQ】消费项目变动消息失败:",e);
@ -175,6 +166,29 @@ public class ProjectChangedCustomListener implements MessageListenerConcurrently
}
}
/**
* desc:发型项目数据到 opendata
* @param msgObj
* @param customerId
*/
private void sendProject2OpenData(ProjectChangedMQMsg msgObj, String customerId) {
//发送项目数据上报的mq消息
if (PingYinConstant.PROD_PING_YIN_CUSTOMER_ID.equals(customerId)) {
if ("issue_shift_project".equals(msgObj.getOperation()) || "created".equals(msgObj.getOperation()) || "close".equals(msgObj.getOperation())) {
String type;
if ("issue_shift_project".equals(msgObj.getOperation()) || "created".equals(msgObj.getOperation())) {
type = SystemMessageType.PROJECT_ADD;
} else {
type = SystemMessageType.PROJECT_EDIT;
}
List<String> projectList = new ArrayList<>();
projectList.add(msgObj.getProjectId());
DisputeProcessMQMsg msg = new DisputeProcessMQMsg(customerId, projectList, type);
SpringContextUtils.getBean(ScreenProjectDataService.class).sendProjectChangeMq(msg);
}
}
}
@PreDestroy
public void saveCalStatus() {
//todo

22
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/biz/impl/BizDataStatsServiceImpl.java

@ -21,7 +21,6 @@ import com.epmet.service.stats.DimCustomerService;
import com.epmet.service.user.StatsStaffPatrolService;
import com.epmet.service.user.UserService;
import com.epmet.util.DimIdGenerator;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -34,7 +33,6 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.*;
import java.util.stream.Collectors;
/**
@ -47,11 +45,6 @@ import java.util.stream.Collectors;
@Slf4j
@Service
public class BizDataStatsServiceImpl implements BizDataStatsService {
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
.setNameFormat("bizDataStats-pool-%d").build();
ExecutorService threadPool = new ThreadPoolExecutor(3, 6,
10L, TimeUnit.MINUTES,
new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy());
@Autowired
private CustomerStaffService customerStaffService;
@Autowired
@ -130,6 +123,7 @@ public class BizDataStatsServiceImpl implements BizDataStatsService {
List<StatsStaffPatrolRecordDailyDTO> insertList = buildInitPatrolStatsData(formDTO, allGridMembers);
Map<String, StatsStaffPatrolRecordDailyDTO> yesterdayStatsMap = insertList.stream().collect(Collectors.toMap(o -> o.getGridId() + o.getStaffId(), o -> o, (o1, o2) -> o1));
log.debug("reloadStaffPatrolStatsData 所有网格员数据{}",JSON.toJSONString(yesterdayStatsMap));
//获取昨日的巡查记录
List<StaffPatrolRecordResult> yesterdayPatrolList = userService.selectStaffPatrolListByDateId(formDTO.getCustomerId(), formDTO.getDateId());
@ -138,7 +132,7 @@ public class BizDataStatsServiceImpl implements BizDataStatsService {
//获取昨日的例行工作数据
List<PatrolRoutineWorkResult> yesterdayWorkList = userService.selectRoutineWorkListByDateId(formDTO.getCustomerId(), formDTO.getDateId());
log.debug("reloadStaffPatrolStatsData 例行工作数据数据{}",JSON.toJSONString(yesterdayWorkList));
//遍历网格员 设置其 巡查次数 巡查时常 上报项目数
yesterdayPatrolList.forEach(patrolRecord -> {
String key = patrolRecord.getGrid().concat(patrolRecord.getStaffId());
@ -172,7 +166,7 @@ public class BizDataStatsServiceImpl implements BizDataStatsService {
String unqPatrolKey = getUnqPatrolKey(patrol.getGrid(), patrol.getStaffId());
StatsStaffPatrolRecordDailyDTO recordDailyDTO = yesterdayStatsMap.get(unqPatrolKey);
if (recordDailyDTO == null) {
log.error("have project data but have any patrolRecordDaily,gridId:{},staffId:{}", patrol.getGrid(), patrol.getStaffId());
log.error("reloadStaffPatrolStatsData have project data but have any patrolRecordDaily,gridId:{},staffId:{}", patrol.getGrid(), patrol.getStaffId());
return;
}
@ -181,17 +175,17 @@ public class BizDataStatsServiceImpl implements BizDataStatsService {
});
});
yesterdayWorkList.forEach(work->{
String key = work.getGridId().concat(work.getUserId());
String key = getUnqPatrolKey(work.getGridId(),work.getUserId());
StatsStaffPatrolRecordDailyDTO patrolRecordDailyDTO = yesterdayStatsMap.get(key);
if (patrolRecordDailyDTO == null){
log.warn("reloadStaffPatrolStatsData getRoutineWorkCount key{} not exist in gridMembers",key);
return;
}
patrolRecordDailyDTO.setRoutineWorkCount(patrolRecordDailyDTO.getRoutineWorkCount() + NumConstant.ONE);
});
Integer effectRow = statsStaffPatrolService.delAndInsertBatch(formDTO, insertList);
log.debug("initStaffPatrolStats insert rows:{}", effectRow);
Integer effectRow = statsStaffPatrolService.insertBatchOrUpdate(formDTO, insertList);
log.info("initStaffPatrolStats insert rows:{}", effectRow);
}
/**
@ -218,7 +212,7 @@ public class BizDataStatsServiceImpl implements BizDataStatsService {
private void initStaffPatrolTodayData(StaffPatrolStatsFormDTO formDTO, List<CustomerGridStaffDTO> allGridMembers) {
log.info("initStaffPatrolTodayData param:{}", JSON.toJSONString(formDTO));
List<StatsStaffPatrolRecordDailyDTO> insertList = buildInitPatrolStatsData(formDTO, allGridMembers);
Integer effectRow = statsStaffPatrolService.delAndInsertBatch(formDTO, insertList);
Integer effectRow = statsStaffPatrolService.insertBatchOrUpdate(formDTO, insertList);
log.debug("initStaffPatrolStats insert rows:{}", effectRow);
}

5
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/CalCpcIndexService.java

@ -1,7 +1,5 @@
package com.epmet.service.evaluationindex.extract.dataToIndex;
import java.util.Map;
/**
* 党员相关
*
@ -18,4 +16,7 @@ public interface CalCpcIndexService {
* @Date 2020/9/17 14:08
**/
void calCpcPartyAbility(String customerId, String monthId);
void calCpcPartyAbilityV2(String customerId, String monthId);
}

290
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalCpcIndexServiceImpl.java

@ -1,7 +1,10 @@
package com.epmet.service.evaluationindex.extract.dataToIndex.impl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.dto.extract.UserGroupIdDTO;
import com.epmet.dto.indexcollect.result.CpcIndexCommonDTO;
import com.epmet.entity.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyEntity;
import com.epmet.service.evaluationindex.extract.dataToIndex.CalCpcIndexService;
@ -9,8 +12,10 @@ import com.epmet.service.evaluationindex.extract.todata.*;
import com.epmet.service.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyService;
import com.epmet.service.group.GroupDataService;
import com.epmet.service.stats.DimCustomerPartymemberService;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -20,6 +25,8 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
/**
* 党员相关
@ -134,6 +141,237 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService {
factIndexPartyAblityCpcMonthlyService.delAndSavePartyAblityCpcMonthly(customerId,monthId,indexPartyAblityCpcList);
}
@Override
public void calCpcPartyAbilityV2(String customerId, String monthId) {
//1、构造初始值 当前客户下所有的党员
List<FactIndexPartyAblityCpcMonthlyEntity> indexPartyAblityCpcList = dimCustomerPartymemberService.selectPartyMemberList(customerId);
if (CollectionUtils.isEmpty(indexPartyAblityCpcList)) {
log.info("dim_customer_partymember do not any records customerId=" + customerId);
return;
}
//可以先查询出每个党员的 自建群
Map<String, List<String>> userCreatedGroups = queryUserCreatedGroups(customerId, indexPartyAblityCpcList);
CompletableFuture<Map<String, Integer>> createTopicCountFuture = CompletableFuture.supplyAsync(() -> {
return calCreateTopicCount(customerId, monthId);
});
CompletableFuture<Map<String, Integer>> joinTopicCountFuture = CompletableFuture.supplyAsync(() -> {
return calJoinTopicCount(customerId, monthId);
});
CompletableFuture<Map<String, Integer>> shiftIssueCountFuture = CompletableFuture.supplyAsync(() -> {
return calShiftIssueCount(customerId, monthId);
});
CompletableFuture<Map<String, Integer>> shiftProjectCountFuture = CompletableFuture.supplyAsync(() -> {
return calShiftProjectCount(customerId, monthId);
});
CompletableFuture<Map<String, Integer>> joinThreeMeetsCountFuture = CompletableFuture.supplyAsync(() -> {
return calJoinThreeMeetsCount(customerId, monthId);
});
CompletableFuture<Map<String, Integer>> groupUserCountFuture = CompletableFuture.supplyAsync(() -> {
return calgroupUserCount(customerId, monthId, indexPartyAblityCpcList, userCreatedGroups);
});
CompletableFuture<Map<String, Integer>> groupActiveUserCountFuture = CompletableFuture.supplyAsync(() -> {
return calGroupActiveUserCount(customerId, monthId, indexPartyAblityCpcList, userCreatedGroups);
});
CompletableFuture<Map<String, Integer>> groupTopicCountFuture = CompletableFuture.supplyAsync(() -> {
return calGroupTopicCount(customerId, monthId);
});
CompletableFuture<Map<String, BigDecimal>> topicToIssueRatioFuture = CompletableFuture.supplyAsync(() -> {
return caltopicToIssueRatio(customerId, monthId, indexPartyAblityCpcList, userCreatedGroups);
});
Map<String, Integer> createTopicCountMap = new HashMap<>();
Map<String, Integer> joinTopicCountMap = new HashMap<>();
Map<String, Integer> shiftIssueCountMap = new HashMap<>();
Map<String, Integer> shiftProjectCountMap = new HashMap<>();
Map<String, Integer> joinThreeMeetsCountMap = new HashMap<>();
Map<String, Integer> groupUserCountMap = new HashMap<>();
Map<String, Integer> groupActiveUserCountMap = new HashMap<>();
Map<String, Integer> groupTopicCountMap = new HashMap<>();
Map<String, BigDecimal> topicToIssueRatioMap = new HashMap<>();
try {
//1、党员提出话题数
createTopicCountMap = createTopicCountFuture.get();
} catch (Exception e) {
log.error("党员相关-党建能力原始指标值【党员提出话题数】计算异常:{}", ExceptionUtils.getErrorStackTrace(e));
}
try{
//2、党员参与话题数(支持、反对、评论、浏览)---目前只统计 党员评论话题次数之和
joinTopicCountMap = joinTopicCountFuture.get();
} catch (Exception e) {
log.error("党员相关-党建能力原始指标值【党员参与话题数】计算异常:{}", ExceptionUtils.getErrorStackTrace(e));
}
try{
//3、党员提出的话题转议题数
shiftIssueCountMap = shiftIssueCountFuture.get();
} catch (Exception e) {
log.error("党员相关-党建能力原始指标值【党员提出的话题转议题数】计算异常:{}", ExceptionUtils.getErrorStackTrace(e));
}
try{
//4、党员提出的议题转项目数
shiftProjectCountMap = shiftProjectCountFuture.get();
} catch (Exception e) {
log.error("党员相关-党建能力原始指标值【党员提出的议题转项目数】计算异常:{}", ExceptionUtils.getErrorStackTrace(e));
}
try{
//5、参加“三会一课”次数 默认0 :当前用户在本月内活动签到次数 限制活动分类编码100001 三会一课
joinThreeMeetsCountMap = joinThreeMeetsCountFuture.get();
} catch (Exception e) {
log.error("党员相关-党建能力原始指标值【参加“三会一课”次数】计算异常:{}", ExceptionUtils.getErrorStackTrace(e));
}
try{
//6、党员自建群群众人数 :和评价周期无关
groupUserCountMap = groupUserCountFuture.get();
} catch (Exception e) {
log.error("党员相关-党建能力原始指标值【党员自建群群众人数】计算异常:{}", ExceptionUtils.getErrorStackTrace(e));
}
try{
//7、党员自建群活跃群众人数
groupActiveUserCountMap = groupActiveUserCountFuture.get();
} catch (Exception e) {
log.error("党员相关-党建能力原始指标值【党员自建群活跃群众人数】计算异常:{}", ExceptionUtils.getErrorStackTrace(e));
}
try{
//8、党员自建群活跃度——话题数:从话题表中统计党员自建群i的话题总数;对所有自建群话题数累加。
groupTopicCountMap = groupTopicCountFuture.get();
} catch (Exception e) {
log.error("党员相关-党建能力原始指标值【党员自建群活跃度】计算异常:{}", ExceptionUtils.getErrorStackTrace(e));
}
try{
//9、自建群活跃度——议题转项目率
topicToIssueRatioMap = topicToIssueRatioFuture.get();
} catch (Exception e) {
log.error("党员相关-党建能力原始指标值【自建群活跃度】计算异常:{}", ExceptionUtils.getErrorStackTrace(e));
}
List<FactIndexPartyAblityCpcMonthlyEntity> list = new ArrayList<>();
List<List<FactIndexPartyAblityCpcMonthlyEntity>> partionList = Lists.partition(indexPartyAblityCpcList, 500);
List<CompletableFuture<List<FactIndexPartyAblityCpcMonthlyEntity>>> entityFutures = new ArrayList<>();
//2、计算实际值,更新
for (List<FactIndexPartyAblityCpcMonthlyEntity> partList : partionList) {
String quarterId = DateUtils.getQuarterId(monthId);
String yearId = DateUtils.getYearId(monthId);
Map<String, Integer> finalCreateTopicCountMap = createTopicCountMap;
Map<String, Integer> finalJoinTopicCountMap = joinTopicCountMap;
Map<String, Integer> finalShiftIssueCountMap = shiftIssueCountMap;
Map<String, Integer> finalShiftProjectCountMap = shiftProjectCountMap;
Map<String, Integer> finalJoinThreeMeetsCountMap = joinThreeMeetsCountMap;
Map<String, Integer> finalGroupUserCountMap = groupUserCountMap;
Map<String, Integer> finalGroupActiveUserCountMap = groupActiveUserCountMap;
Map<String, Integer> finalGroupTopicCountMap = groupTopicCountMap;
Map<String, BigDecimal> finalTopicToIssueRatioMap = topicToIssueRatioMap;
//目前平阴2100多个党员,200个一组,开一个线程
CompletableFuture<List<FactIndexPartyAblityCpcMonthlyEntity>> future = CompletableFuture.supplyAsync(() -> {
return constructEntity(monthId,
quarterId,
yearId,
partList,
finalCreateTopicCountMap,
finalJoinTopicCountMap,
finalShiftIssueCountMap,
finalShiftProjectCountMap,
finalJoinThreeMeetsCountMap,
finalGroupUserCountMap,
finalGroupActiveUserCountMap,
finalGroupTopicCountMap,
finalTopicToIssueRatioMap);
});
entityFutures.add(future);
}
for (CompletableFuture<List<FactIndexPartyAblityCpcMonthlyEntity>> entityFuture : entityFutures) {
try {
List<FactIndexPartyAblityCpcMonthlyEntity> partList = entityFuture.get();
list.addAll(partList);
} catch (InterruptedException e) {
log.error("党员相关-党建能力原始指标构造异常:{}", ExceptionUtils.getErrorStackTrace(e));
} catch (Exception e) {
log.error("党员相关-党建能力原始指标构造异常:{}", ExceptionUtils.getErrorStackTrace(e));
}
}
//3、删除之前统计过的、批插入批量插入
factIndexPartyAblityCpcMonthlyService.delAndSavePartyAblityCpcMonthly(customerId, monthId, list);
}
private List<FactIndexPartyAblityCpcMonthlyEntity> constructEntity(String monthId,
String quarterId,
String yearId,
List<FactIndexPartyAblityCpcMonthlyEntity> partList,
Map<String, Integer> createTopicCountMap,
Map<String, Integer> joinTopicCountMap,
Map<String, Integer> shiftIssueCountMap,
Map<String, Integer> shiftProjectCountMap,
Map<String, Integer> joinThreeMeetsCountMap,
Map<String, Integer> groupUserCountMap,
Map<String, Integer> groupActiveUserCountMap,
Map<String, Integer> groupTopicCountMap,
Map<String, BigDecimal> topicToIssueRatioMap) {
List<FactIndexPartyAblityCpcMonthlyEntity> resultList = new ArrayList<>();
for (FactIndexPartyAblityCpcMonthlyEntity temp : partList) {
FactIndexPartyAblityCpcMonthlyEntity indexPartyAblityCpcEntity = ConvertUtils.sourceToTarget(temp, FactIndexPartyAblityCpcMonthlyEntity.class);
indexPartyAblityCpcEntity.setMonthId(monthId);
indexPartyAblityCpcEntity.setQuarterId(quarterId);
indexPartyAblityCpcEntity.setYearId(yearId);
//1、党员提出话题数
if (MapUtils.isNotEmpty(createTopicCountMap) && createTopicCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())) {
indexPartyAblityCpcEntity.setCreateTopicCount(createTopicCountMap.get(indexPartyAblityCpcEntity.getUserId()));
}
//2、党员参与话题数(支持、反对、评论、浏览)---目前只统计 党员评论话题次数之和
if (MapUtils.isNotEmpty(joinTopicCountMap) && joinTopicCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())) {
indexPartyAblityCpcEntity.setJoinTopicCount(joinTopicCountMap.get(indexPartyAblityCpcEntity.getUserId()));
}
//3、党员提出的话题转议题数
if (MapUtils.isNotEmpty(shiftIssueCountMap) && shiftIssueCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())) {
indexPartyAblityCpcEntity.setShiftIssueCount(shiftIssueCountMap.get(indexPartyAblityCpcEntity.getUserId()));
}
//4、党员提出的议题转项目数
if (MapUtils.isNotEmpty(shiftProjectCountMap) && shiftProjectCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())) {
indexPartyAblityCpcEntity.setShiftProjectCount(shiftProjectCountMap.get(indexPartyAblityCpcEntity.getUserId()));
}
//5、参加“三会一课”次数 目前没有此业务,默认0 : 当前用户在本月内活动签到次数 限制活动分类编码100001 三会一课
if (MapUtils.isNotEmpty(joinThreeMeetsCountMap) && joinThreeMeetsCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())) {
indexPartyAblityCpcEntity.setJoinThreeMeetsCount(joinThreeMeetsCountMap.get(indexPartyAblityCpcEntity.getUserId()));
}
//6、党员自建群群众人数
if (MapUtils.isNotEmpty(groupUserCountMap) && groupUserCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())) {
indexPartyAblityCpcEntity.setGroupUserCount(groupUserCountMap.get(indexPartyAblityCpcEntity.getUserId()));
}
//7、党员自建群活跃群众人数
if (MapUtils.isNotEmpty(groupActiveUserCountMap) && groupActiveUserCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())) {
indexPartyAblityCpcEntity.setGroupActiveUserCount(groupActiveUserCountMap.get(indexPartyAblityCpcEntity.getUserId()));
}
//8、党员自建群活跃度——话题数
if (MapUtils.isNotEmpty(groupTopicCountMap) && groupTopicCountMap.containsKey(indexPartyAblityCpcEntity.getUserId())) {
indexPartyAblityCpcEntity.setGroupTopicCount(groupTopicCountMap.get(indexPartyAblityCpcEntity.getUserId()));
}
//9、自建群活跃度——议题转项目率
if (MapUtils.isNotEmpty(topicToIssueRatioMap) && topicToIssueRatioMap.containsKey(indexPartyAblityCpcEntity.getUserId())) {
indexPartyAblityCpcEntity.setTopicToIssueRatio(topicToIssueRatioMap.get(indexPartyAblityCpcEntity.getUserId()));
}
resultList.add(indexPartyAblityCpcEntity);
}
return resultList;
}
/**
* @param customerId
* @param partyMemberList
@ -144,7 +382,7 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService {
**/
private Map<String, List<String>> queryUserCreatedGroups(String customerId, List<FactIndexPartyAblityCpcMonthlyEntity> partyMemberList) {
Map<String, List<String>> map = new HashMap<>();
for (FactIndexPartyAblityCpcMonthlyEntity partyMember : partyMemberList) {
/*for (FactIndexPartyAblityCpcMonthlyEntity partyMember : partyMemberList) {
//查询当前党员建了多少个组
List<String> groupIdList=factOriginGroupMainDailyService.selectGroupIds(customerId,partyMember.getUserId());
if (CollectionUtils.isEmpty(groupIdList)) {
@ -153,6 +391,17 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService {
} else {
map.put(partyMember.getUserId(), groupIdList);
}
}*/
//查询出所有的小组,按照组长
List<UserGroupIdDTO> list = factOriginGroupMainDailyService.selectGroupAndLeader(customerId);
Map<String, List<String>> userGroupIdMap = list.stream().collect(Collectors.toMap(UserGroupIdDTO::getUserId, UserGroupIdDTO::getGroupIdList));
for (FactIndexPartyAblityCpcMonthlyEntity partyMember : partyMemberList) {
if (MapUtils.isEmpty(userGroupIdMap) || !userGroupIdMap.containsKey(partyMember.getUserId())) {
map.put(partyMember.getUserId(), new ArrayList<>());
continue;
} else {
map.put(partyMember.getUserId(), userGroupIdMap.get(partyMember.getUserId()));
}
}
return map;
}
@ -166,11 +415,13 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService {
* @Date 2020/9/18 10:59
**/
private Map<String, Integer> calCreateTopicCount(String customerId, String monthId) {
long startCpc = System.currentTimeMillis();
List<CpcIndexCommonDTO> list = factOriginTopicMainDailyService.selectPartyCreateTopicCount(customerId, monthId);
Map<String, Integer> resultMap = new HashMap<>();
for (CpcIndexCommonDTO cpcIndexCommonDTO: list) {
resultMap.put(cpcIndexCommonDTO.getUserId(), cpcIndexCommonDTO.getIndexValue());
}
log.warn("1、党员相关-党建能力【党员提出话题数】执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCpc, customerId);
return resultMap;
}
@ -183,11 +434,13 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService {
* @Date 2020/9/18 13:33
**/
private Map<String, Integer> calJoinTopicCount(String customerId, String monthId) {
long startCpc = System.currentTimeMillis();
List<CpcIndexCommonDTO> list = factOriginTopicLogDailyService.selectJoinTopicCount(customerId, monthId);
Map<String, Integer> resultMap = new HashMap<>();
for (CpcIndexCommonDTO cpcIndexCommonDTO : list) {
resultMap.put(cpcIndexCommonDTO.getUserId(), cpcIndexCommonDTO.getIndexValue());
}
log.warn("2、党员相关-党建能力【党员参与话题数】执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCpc, customerId);
return resultMap;
}
@ -201,11 +454,13 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService {
* @Date 2020/9/18 13:53
**/
private Map<String, Integer> calShiftIssueCount(String customerId, String monthId) {
long startCpc = System.currentTimeMillis();
List<CpcIndexCommonDTO> list = issueExtractService.selectShiftIssueCount(customerId, monthId);
Map<String, Integer> resultMap = new HashMap<>();
for (CpcIndexCommonDTO cpcIndexCommonDTO : list) {
resultMap.put(cpcIndexCommonDTO.getUserId(), cpcIndexCommonDTO.getIndexValue());
}
log.warn("3、党员相关-党建能力【党员提出的话题转议题数】执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCpc, customerId);
return resultMap;
}
@ -218,12 +473,14 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService {
* @Date 2020/9/18 14:10
**/
private Map<String, Integer> calShiftProjectCount(String customerId, String monthId) {
long startCpc = System.currentTimeMillis();
//查询fact_origin_project_main_daily 表 中议题的议题的状态为 shift_
List<CpcIndexCommonDTO> list = factOriginProjectMainDailyService.selectShiftProjectCount(customerId, monthId);
Map<String, Integer> resultMap = new HashMap<>();
for (CpcIndexCommonDTO cpcIndexCommonDTO : list) {
resultMap.put(cpcIndexCommonDTO.getUserId(), cpcIndexCommonDTO.getIndexValue());
}
log.warn("4、党员相关-党建能力【党员提出的议题转项目数】执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCpc, customerId);
return resultMap;
}
@ -236,12 +493,14 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService {
* @Date 2021/5/12 13:38
**/
private Map<String, Integer> calJoinThreeMeetsCount(String customerId, String monthId) {
long startCpc = System.currentTimeMillis();
//查询小组活动签到表,计算用户在本月内签到的活动次数
List<CpcIndexCommonDTO> list=groupDataService.selectJoinThreeMeetsCount(customerId,monthId);
Map<String, Integer> resultMap = new HashMap<>();
for (CpcIndexCommonDTO cpcIndexCommonDTO : list) {
resultMap.put(cpcIndexCommonDTO.getUserId(), cpcIndexCommonDTO.getIndexValue());
}
log.warn("5、党员相关-党建能力【参加“三会一课”次数】执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCpc, customerId);
return resultMap;
}
@ -256,6 +515,7 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService {
private Map<String, Integer> calgroupUserCount(String customerId, String monthId,
List<FactIndexPartyAblityCpcMonthlyEntity> partyMemberList,
Map<String, List<String>> userCreatedGroups) {
long startCpc = System.currentTimeMillis();
/*含义评价周期内党员自建群中群众成员数
数据来源用户社群关系表
计算方法对党员i的所有j个自建群从用户社群关系表中统计属于每个自建群的群众用户总人数并对j个群众用户总数进行不重复累加
@ -265,7 +525,7 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService {
//查询当前党员建了多少个组
List<String> groupIdList = userCreatedGroups.get(partyMember.getUserId());
if (CollectionUtils.isEmpty(groupIdList)) {
log.info("当前党员userId="+partyMember.getUserId()+"没有创建过小组, 【党员相关-党员自建群群众人数】赋值0");
// log.info("当前党员userId="+partyMember.getUserId()+"没有创建过小组, 【党员相关-党员自建群群众人数】赋值0");
map.put(partyMember.getUserId(), NumConstant.ZERO);
continue;
}
@ -279,6 +539,7 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService {
map.put(partyMember.getUserId(), memberIdList.size());
}
}
log.warn("6、党员相关-党建能力【党员自建群群众人数】执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCpc, customerId);
return map;
}
@ -294,6 +555,7 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService {
private Map<String, Integer> calGroupActiveUserCount(String customerId, String monthId,
List<FactIndexPartyAblityCpcMonthlyEntity> partyMemberList,
Map<String, List<String>> userCreatedGroups) {
long startCpc = System.currentTimeMillis();
/*含义评价周期内党员自建群中活跃群众成员数所谓活跃群成员即评价周期内参与话题事件评论点赞点踩总次数大于给定阈值的群众用户
数据来源话题用户阅读表话题评论用户表态表话题评论表事件点赞点踩表事件评论点赞点踩表事件评论表用户信息表
计算方法
@ -311,7 +573,7 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService {
//1、查询当前党员建了多少个组
List<String> groupIdList = userCreatedGroups.get(partyMember.getUserId());
if (CollectionUtils.isEmpty(groupIdList)) {
log.info("当前党员userId="+partyMember.getUserId()+"没有创建过小组, 【党员相关-党员自建群活跃群众人数】赋值0");
// log.warn("当前党员userId="+partyMember.getUserId()+"没有创建过小组, 【党员相关-党员自建群活跃群众人数】赋值0");
map.put(partyMember.getUserId(), NumConstant.ZERO);
continue;
}
@ -321,23 +583,35 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService {
map.put(partyMember.getUserId(), NumConstant.ZERO);
continue;
}
//可以先把本月内评论的用户+本月内表决过的用户 集合查询出来。避免循环查询
List<String> commentTopicUserIds=factOriginTopicLogDailyService.queryCommentTopicUserIds(customerId,monthId);
List<String> voteUserIds=issueExtractService.queryVoteUserIds(customerId,monthId);
//3、判断每个成员是否 “活跃”
for (String memberId : memberIdList) {
//注释2022.03.02
//1、判断成员在本月内是否评论过
Integer topicCommentCount = factOriginTopicLogDailyService.selectUserCommentCount(memberId, customerId, monthId);
/*Integer topicCommentCount = factOriginTopicLogDailyService.selectUserCommentCount(memberId, customerId, monthId);
if (topicCommentCount > 0) {
groupActiveUserCount++;
continue;
}
}*/
//2、判断成员在本月内是否表决过(支持or反对)议题
Integer voteCount = issueExtractService.selectCountUserVote(memberId, customerId, monthId);
/*Integer voteCount = issueExtractService.selectCountUserVote(memberId, customerId, monthId);
if (voteCount > 0) {
groupActiveUserCount++;
}*/
if (CollectionUtils.isNotEmpty(commentTopicUserIds) && commentTopicUserIds.contains(memberId)) {
groupActiveUserCount++;
continue;
}
if (CollectionUtils.isNotEmpty(voteUserIds) && voteUserIds.contains(memberId)) {
groupActiveUserCount++;
}
}
//赋值每个党员的 -- 党员自建群活跃群众人数
map.put(partyMember.getUserId(), groupActiveUserCount);
}
log.warn("7、党员相关-党建能力【党员自建群活跃群众人数】执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCpc, customerId);
return map;
}
@ -351,6 +625,7 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService {
* @Date 2020/9/18 14:31
**/
private Map<String, Integer> calGroupTopicCount(String customerId, String monthId) {
long startCpc = System.currentTimeMillis();
/*含义评价周期内党员自建群中话题发布数
数据来源话题表
计算方法从话题表中统计党员自建群i的话题总数对所有自建群话题数累加
@ -360,6 +635,7 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService {
for (CpcIndexCommonDTO dto : list) {
resultMap.put(dto.getUserId(), dto.getIndexValue());
}
log.warn("8、党员相关-党建能力【党员自建群活跃度——话题数】执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCpc, customerId);
return resultMap;
}
@ -374,6 +650,7 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService {
String monthId,
List<FactIndexPartyAblityCpcMonthlyEntity> partyMemberList,
Map<String, List<String>> userCreatedGroups) {
long startCpc = System.currentTimeMillis();
Map<String, BigDecimal> map = new HashMap<>();
for (FactIndexPartyAblityCpcMonthlyEntity partyMember : partyMemberList) {
//如果党员自建群为空,直接赋值0
@ -408,6 +685,7 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService {
BigDecimal topicToIssueRatio = new BigDecimal(topicToIssueRatioStr).multiply(new BigDecimal(NumConstant.ONE_HUNDRED));
map.put(partyMember.getUserId(), topicToIssueRatio);
}
log.warn("9、党员相关-党建能力【自建群活跃度——议题转项目率】执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCpc, customerId);
return map;
}

105
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java

@ -4,11 +4,14 @@ import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.constant.CustomerIdConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.enums.EnvEnum;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.extract.form.ExtractIndexFormDTO;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.service.evaluationindex.extract.dataToIndex.*;
import com.epmet.service.evaluationindex.indexcal.IndexCalculateService;
import com.epmet.service.stats.DimCustomerService;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -18,7 +21,8 @@ import org.springframework.util.CollectionUtils;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
/**
* desc指标原始数据抽取服务实现类
@ -26,12 +30,8 @@ import java.util.concurrent.*;
@Slf4j
@Service
public class IndexOriginExtractServiceImpl implements IndexOriginExtractService {
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
.setNameFormat("indexOriginExtract-pool-%d").build();
ExecutorService threadPool = new ThreadPoolExecutor(1, 1,
10L, TimeUnit.MINUTES,
new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy());
@Autowired
private ExecutorService executorService;
@Autowired
private CalCpcIndexService calCpcIndexService;
@Autowired
@ -45,7 +45,10 @@ public class IndexOriginExtractServiceImpl implements IndexOriginExtractService
@Autowired
private IndexCollDistrictService indexCollDistrictService;
@Autowired
private IndexCollDistrictDepartmentService indexCollDistrictDepartmentService;
private IndexCollDistrictDepartmentService indexCollDistrictDepartmentService;
@Autowired
private IndexCalculateService indexCalculateService;
/**
* desc从统计库对象抽取指标数据
*
@ -56,7 +59,7 @@ public class IndexOriginExtractServiceImpl implements IndexOriginExtractService
String monthId = formDTO.getMonthId();
String customerId = formDTO.getCustomerId();
if (StringUtils.isBlank(monthId)) {
monthId = LocalDate.now().minusMonths(NumConstant.ONE).toString().replace("-","").substring(NumConstant.ZERO,NumConstant.SIX);
monthId = LocalDate.now().minusMonths(NumConstant.ONE).toString().replace("-", "").substring(NumConstant.ZERO, NumConstant.SIX);
}
List<String> customerIds = new ArrayList<>();
if (StringUtils.isNotBlank(customerId)) {
@ -67,7 +70,7 @@ public class IndexOriginExtractServiceImpl implements IndexOriginExtractService
List<String> customerIdList = null;
do {
customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize);
if (!CollectionUtils.isEmpty(customerIdList)){
if (!CollectionUtils.isEmpty(customerIdList)) {
customerIds.addAll(customerIdList);
}
} while (!CollectionUtil.isEmpty(customerIdList) && customerIdList.size() == pageSize);
@ -91,88 +94,104 @@ public class IndexOriginExtractServiceImpl implements IndexOriginExtractService
private void submitJob(ExtractIndexFormDTO param) {
CountDownLatch countDownLatch = new CountDownLatch(2);
CountDownLatch countDownLatch = new CountDownLatch(NumConstant.SIX);
long start = System.currentTimeMillis();
final String customerId = param.getCustomerId();
final String monthId = param.getMonthId();
threadPool.submit(() -> {
executorService.submit(() -> {
try {
long startCpc = System.currentTimeMillis();
calCpcIndexService.calCpcPartyAbility(customerId, monthId);
log.error("党员相关-党建能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startCpc, param.getCustomerId());
// calCpcIndexService.calCpcPartyAbility(customerId, monthId);
calCpcIndexService.calCpcPartyAbilityV2(customerId, monthId);
log.info("党员相关-党建能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCpc, param.getCustomerId());
} catch (Exception e) {
log.error("抽取【党员相关数据】发生异常,参数:" + JSON.toJSONString(param), e);
}finally {
} finally {
countDownLatch.countDown();
}
});
threadPool.submit(() -> {
executorService.submit(() -> {
try {
long startGridGovern = System.currentTimeMillis();
calGridIndexService.calGridIndexGovernAbility(customerId, monthId);
log.error("网格相关-治理能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startGridGovern, param.getCustomerId());
log.info("网格相关-治理能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startGridGovern, param.getCustomerId());
} catch (Exception e) {
log.error("抽取【网格治理能力数据】发生异常,参数:" + JSON.toJSONString(param), e);
}
try {
long startGridParty = System.currentTimeMillis();
calGridIndexService.calGridIndexPartyAbility(customerId, monthId);
log.error("网格相关-党建能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startGridParty, param.getCustomerId());
log.info("网格相关-党建能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startGridParty, param.getCustomerId());
} catch (Exception e) {
log.error("抽取【网格党建能力数据】发生异常,参数:" + JSON.toJSONString(param), e);
}
try {
long startGridService = System.currentTimeMillis();
calGridIndexService.calGridIndexServiceAbility(customerId, monthId);
log.error("网格相关-服务能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startGridService, param.getCustomerId());
log.info("网格相关-服务能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startGridService, param.getCustomerId());
} catch (Exception e) {
log.error("抽取【网格服务能力数据】发生异常,参数:" + JSON.toJSONString(param), e);
}
try{
//dimAgency
countDownLatch.countDown();
});
executorService.submit(() -> {
try {
long startCommunity = System.currentTimeMillis();
indexCollCommunityService.saveCommunityAbility(customerId, monthId);
log.error("社区相关-三大能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startCommunity, param.getCustomerId());
}catch (Exception e){
log.info("社区相关-三大能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCommunity, param.getCustomerId());
} catch (Exception e) {
log.error("抽取【社区治理能力-社区党建能力-服务能力】发生异常,参数:" + JSON.toJSONString(param), e);
}
try{
//dimAgency
countDownLatch.countDown();
});
executorService.submit(() -> {
try {
long startStreet = System.currentTimeMillis();
indexCollStreetService.saveStreetAbility(customerId, monthId);
log.error("街道相关-三大能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startStreet, param.getCustomerId());
}catch (Exception e){
log.info("街道相关-三大能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startStreet, param.getCustomerId());
} catch (Exception e) {
log.error("抽取【街道治理能力-街道党建能力-服务能力】发生异常,参数:" + JSON.toJSONString(param), e);
}
try{
//dimAgency
countDownLatch.countDown();
});
executorService.submit(() -> {
try {
long startDept = System.currentTimeMillis();
indexCollDistrictDepartmentService.saveDepartmentAbility(customerId, monthId);
log.error("区直部门相关-治理能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startDept, param.getCustomerId());
}catch (Exception e){
log.info("区直部门相关-治理能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startDept, param.getCustomerId());
} catch (Exception e) {
log.error("抽取【区直部门治理能力】发生异常,参数:" + JSON.toJSONString(param), e);
}
try{
//dimAgency
countDownLatch.countDown();
});
executorService.submit(() -> {
try {
long startDistrict = System.currentTimeMillis();
indexCollDistrictService.saveDistrictAbility(customerId, monthId);
log.error("全区相关-三大能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startDistrict, param.getCustomerId());
}catch (Exception e){
log.info("全区相关-三大能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startDistrict, param.getCustomerId());
} catch (Exception e) {
log.error("抽取【全区治理能力-全区党建能力-服务能力】发生异常,参数:" + JSON.toJSONString(param), e);
}
countDownLatch.countDown();
});
log.info("indexOriginExtractAll======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - start, param.getCustomerId());
try {
//等前面都执行完 再执行计算指标得分
countDownLatch.await();
executorService.submit(() -> {
long startT = System.currentTimeMillis();
CalculateCommonFormDTO formDTO1 = new CalculateCommonFormDTO();
try {
formDTO1.setMonthId(monthId);
formDTO1.setCustomerId(customerId);
Boolean aBoolean = indexCalculateService.indexCalculate(formDTO1);
HttpClientManager.getInstance().sendAlarmMsg(EnvEnum.getCurrentEnv().getName() + "客户Id:" + customerId + ";monthId:" + monthId + ",calculateAll全部指标计算完成,是否成功:" + aBoolean + ",总耗时:" + (System.currentTimeMillis() - startT) / 1000 + "秒");
} catch (Exception e) {
log.error("extractMonthly 计算分数异常,参数:{}", JSON.toJSONString(formDTO1));
}
});
} catch (InterruptedException e) {
log.error("indexOriginExtractAll countDownLatch exception", e);
}
log.error("indexOriginExtractAll执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-start, param.getCustomerId());
}
}

7
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginGroupMainDailyService.java

@ -19,6 +19,7 @@ package com.epmet.service.evaluationindex.extract.todata;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.dto.extract.FactOriginGroupMainDailyDTO;
import com.epmet.dto.extract.UserGroupIdDTO;
import com.epmet.dto.extract.form.ScreenPartyLinkMassesDataFormDTO;
import com.epmet.dto.extract.result.GridGroupUserCountResultDTO;
import com.epmet.dto.extract.result.OrgStatisticsResultDTO;
@ -125,4 +126,10 @@ public interface FactOriginGroupMainDailyService extends BaseService<FactOriginG
*/
Map<String, OrgStatisticsResultDTO> getPartyMemberGroupStatic(String customerId, String dateId, String type);
/**
* 查询出小组id ,组长userId
* @param customerId
* @return
*/
List<UserGroupIdDTO> selectGroupAndLeader(String customerId);
}

8
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginTopicLogDailyService.java

@ -79,4 +79,12 @@ public interface FactOriginTopicLogDailyService extends BaseService<FactOriginTo
* @date 2020/9/21 9:37 上午
*/
List<PartyActiveResultDTO> selectPartyActiveTopic(String customerId, String monthId,Integer isParty);
/**
* 查询出本月内评论过话题的用户id
* @param customerId
* @param monthId
* @return
*/
List<String> queryCommentTopicUserIds(String customerId, String monthId);
}

8
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/IssueExtractService.java

@ -107,4 +107,12 @@ public interface IssueExtractService {
* @date 2020/9/21 9:37 上午
*/
List<PartyActiveResultDTO> selectPartyActiveIssueVote(String customerId, String monthId, Integer isParty);
/**
* 查询出本月内做过议题表决的用户id
* @param customerId
* @param monthId
* @return
*/
List<String> queryVoteUserIds(String customerId, String monthId);
}

29
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java

@ -7,13 +7,10 @@ import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.dto.extract.form.ExtractOriginFormDTO;
import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO;
import com.epmet.service.StatsGroupService;
import com.epmet.service.StatsTopicService;
import com.epmet.service.evaluationindex.extract.todata.*;
import com.epmet.service.stats.DimCustomerPartymemberService;
import com.epmet.service.stats.DimCustomerService;
import com.epmet.util.DimIdGenerator;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -23,7 +20,9 @@ import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
/**
* desc抽取业务数据 统计库 汇聚类
@ -31,12 +30,6 @@ import java.util.concurrent.*;
@Slf4j
@Service
public class FactOriginExtractServiceImpl implements FactOriginExtractService {
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
.setNameFormat("factOriginExtract-pool-%d").build();
ExecutorService threadPool = new ThreadPoolExecutor(3, 6,
10L, TimeUnit.MINUTES,
new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy());
@Autowired
private IssueExtractService issueExtractService;
@Autowired
@ -54,9 +47,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService {
@Autowired
private FactGroupActDailyService factGroupActDailyService;
@Autowired
private StatsGroupService statsGroupService;
@Autowired
private StatsTopicService statsTopicService;
private ExecutorService executorService;
@Override
@ -106,7 +97,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService {
daysBetween = DateUtils.getDaysBetween(param.getStartDate(), param.getEndDate());
}
List<String> finalDaysBetween = daysBetween;
threadPool.submit(() -> {
executorService.submit(() -> {
try {
CustomerIdAndDateIdFormDTO formDTO = new CustomerIdAndDateIdFormDTO();
formDTO.setCustomerId(param.getCustomerId());
@ -132,7 +123,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService {
countDownLatch.countDown();
}
});
threadPool.submit(() -> {
executorService.submit(() -> {
try {
ExtractOriginFormDTO paramNew = ConvertUtils.sourceToTarget(param, ExtractOriginFormDTO.class);
if (!isRange) {
@ -156,7 +147,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService {
countDownLatch.countDown();
}
});
threadPool.submit(() -> {
executorService.submit(() -> {
try {
log.debug("extractAll start param:{}", JSON.toJSONString(param));
ExtractOriginFormDTO paramNew = ConvertUtils.sourceToTarget(param, ExtractOriginFormDTO.class);
@ -183,7 +174,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService {
countDownLatch.countDown();
}
});
threadPool.submit(() -> {
executorService.submit(() -> {
try {
ExtractOriginFormDTO paramNew = ConvertUtils.sourceToTarget(param, ExtractOriginFormDTO.class);
if (!isRange) {
@ -222,7 +213,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService {
}
});
//小组活动
threadPool.submit(() -> {
executorService.submit(() -> {
try {
ExtractOriginFormDTO extractOriginFormDTO = ConvertUtils.sourceToTarget(param, ExtractOriginFormDTO.class);
if (!isRange) {
@ -339,7 +330,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService {
@Override
public Future<?> submitProjectRelationData(ExtractOriginFormDTO param, List<String> finalDaysBetween) {
Future<?> submit = threadPool.submit(() -> {
Future<?> submit = executorService.submit(() -> {
ExtractOriginFormDTO paramNew = ConvertUtils.sourceToTarget(param, ExtractOriginFormDTO.class);
if (CollectionUtils.isEmpty(finalDaysBetween)) {
try {

13
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginGroupMainDailyServiceImpl.java

@ -22,8 +22,8 @@ import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.constant.OrgTypeConstant;
import com.epmet.dao.evaluationindex.extract.FactOriginGroupMainDailyDao;
import com.epmet.dao.evaluationindex.extract.FactOriginGroupMemberDailyDao;
import com.epmet.dto.extract.FactOriginGroupMainDailyDTO;
import com.epmet.dto.extract.UserGroupIdDTO;
import com.epmet.dto.extract.form.ScreenPartyLinkMassesDataFormDTO;
import com.epmet.dto.extract.result.GridGroupUserCountResultDTO;
import com.epmet.dto.extract.result.OrgStatisticsResultDTO;
@ -198,4 +198,15 @@ public class FactOriginGroupMainDailyServiceImpl extends BaseServiceImpl<FactOri
}
}
/**
* 查询出小组id ,组长userId
*
* @param customerId
* @return
*/
@Override
public List<UserGroupIdDTO> selectGroupAndLeader(String customerId) {
return baseDao.selectGroupAndLeader(customerId);
}
}

12
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginTopicLogDailyServiceImpl.java

@ -108,4 +108,16 @@ public class FactOriginTopicLogDailyServiceImpl extends BaseServiceImpl<FactOrig
public List<PartyActiveResultDTO> selectPartyActiveTopic(String customerId, String monthId, Integer isParty) {
return baseDao.selectPartyActiveTopic(customerId, monthId, isParty);
}
/**
* 查询出本月内评论过话题的用户id
*
* @param customerId
* @param monthId
* @return
*/
@Override
public List<String> queryCommentTopicUserIds(String customerId, String monthId) {
return baseDao.queryCommentTopicUserIds(customerId,monthId);
}
}

13
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/IssueExtractServiceImpl.java

@ -374,4 +374,17 @@ public class IssueExtractServiceImpl implements IssueExtractService {
public List<PartyActiveResultDTO> selectPartyActiveIssueVote(String customerId, String monthId, Integer isParty) {
return issueLogDailyDao.selectPartyActiveIssueVote(customerId, monthId, isParty);
}
/**
* 查询出本月内做过议题表决的用户id
*
* @param customerId
* @param monthId
* @return
*/
@Override
public List<String> queryVoteUserIds(String customerId, String monthId) {
return issueLogDailyDao.queryVoteUserIds(customerId,monthId);
}
}

84
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java

@ -7,22 +7,17 @@ import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.distributedlock.DistributedLock;
import com.epmet.commons.tools.distributedlock.LockConstants;
import com.epmet.commons.tools.enums.EnvEnum;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.dto.extract.form.ExtractFactGridGovernDailyFromDTO;
import com.epmet.dto.extract.form.ExtractOriginFormDTO;
import com.epmet.dto.extract.form.ExtractScreenFormDTO;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.screen.form.ScreenCentralZoneDataFormDTO;
import com.epmet.service.evaluationindex.extract.todata.FactAgencyGovernDailyService;
import com.epmet.service.evaluationindex.extract.todata.FactGridGovernDailyService;
import com.epmet.service.evaluationindex.extract.todata.FactGridMemberStatisticsDailyService;
import com.epmet.service.evaluationindex.extract.toscreen.*;
import com.epmet.service.evaluationindex.indexcal.IndexCalculateService;
import com.epmet.service.evaluationindex.screen.*;
import com.epmet.service.stats.DimCustomerService;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.redisson.api.RLock;
@ -33,7 +28,9 @@ import org.springframework.util.CollectionUtils;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
/**
* @Author zxc
@ -42,12 +39,6 @@ import java.util.concurrent.*;
@Service
@Slf4j
public class ScreenExtractServiceImpl implements ScreenExtractService {
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
.setNameFormat("ScreenExtractServiceImpl-pool-%d").build();
ExecutorService threadPool = new ThreadPoolExecutor(3, 6,
10L, TimeUnit.MINUTES,
new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy());
@Autowired
private DimCustomerService dimCustomerService;
@Autowired
@ -65,8 +56,6 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
@Autowired
private PublicPartiTotalDataExtractService publicPartiTotalDataExtractService;
@Autowired
private IndexCalculateService indexCalculateService;
@Autowired
private ScreenCentralZoneDataAbsorptionService screenCentralZoneDataAbsorptionService;
@Autowired
private ScreenGrassrootsGovernDataAbsorptionService screenGrassrootsGovernDataAbsorptionService;
@ -81,10 +70,6 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
@Autowired
private ScreenProjectSettleService screenProjectSettleService;
@Autowired
private ScreenProjectCategoryGridDailyService projectCategoryGridDailyService;
@Autowired
private ScreenProjectCategoryOrgDailyService projectCategoryOrgDailyService;
@Autowired
private FactGridGovernDailyService factGridGovernDailyService;
@Autowired
private FactAgencyGovernDailyService factAgencyGovernDailyService;
@ -94,6 +79,9 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
private ScreenProjectCategoryGridAndOrgDailyService screenProjectCategoryGridAndOrgDailyService;
@Autowired
private DistributedLock distributedLock;
@Autowired
private ExecutorService executorService;
/**
* @param extractOriginFormDTO
@ -183,7 +171,7 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
lock = distributedLock.getLock(LockConstants.SCREEN_DAILY, NumConstant.SIX_HUNDRED_L, NumConstant.TEN_L, TimeUnit.SECONDS);
//等待3个线程执行完毕后再 继续执行下一个客户的 避免死锁
final CountDownLatch latch = new CountDownLatch(NumConstant.FOUR);
threadPool.submit(() -> {
executorService.submit(() -> {
//党员基本情况screen_cpc_base_data
try {
try {
@ -215,7 +203,7 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
}
});
threadPool.submit(() -> {
executorService.submit(() -> {
//公众参与排行(注册人数、参与人数、话题数、议题数、项目数)screen_public_party_total_data
try {
@ -263,7 +251,7 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
log.info("extractDaily 2 thread run end ========= dateId:{},customerId:{}", dateId, customerId);
}
});
threadPool.submit(() -> {
executorService.submit(() -> {
try {
try {
@ -278,26 +266,12 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
} catch (Exception e) {
log.error("项目(事件)分析按组织_按天统计失败,customerId为:" + customerId + "dateId为:" + dateId, e);
}
//按天统计:网格内各个分类下的项目总数
try {
screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId, dateId);
} catch (Exception e) {
log.error("按天统计:网格内各个分类下的项目总数,customerId为:" + customerId + "dateId为:" + dateId, e);
}
// 按天统计:组织内各个分类下的项目总数
try {
screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId, dateId);
} catch (Exception e) {
log.error("按天统计:组织内各个分类下的项目总数,customerId为:" + customerId + "dateId为:" + dateId, e);
}
} finally {
latch.countDown();
log.info("extractDaily 3 thread run end ========= dateId:{},customerId:{}", dateId, customerId);
}
});
threadPool.submit(() -> {
executorService.submit(() -> {
//治理能力排行screen_govern_rank_data
try {
try {
@ -342,6 +316,20 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
log.error("网格员数据统计fact_grid_member_statistics_daily抽取失败,customerId为:" + customerId + "dateId为:" + dateId, e);
}
extractPartData(customerId, dateId, null);
// 挪到这的原因是因为,要等 screen_project_data表跑完,下面两个方法抽取数据来源于screen_project_data和screen_project_category
//按天统计:网格内各个分类下的项目总数
try {
screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId, dateId);
} catch (Exception e) {
log.error("按天统计:网格内各个分类下的项目总数,customerId为:" + customerId + "dateId为:" + dateId, e);
}
// 按天统计:组织内各个分类下的项目总数
try {
screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId, dateId);
} catch (Exception e) {
log.error("按天统计:组织内各个分类下的项目总数,customerId为:" + customerId + "dateId为:" + dateId, e);
}
} finally {
latch.countDown();
log.info("extractDaily 4 thread run end ========= dateId:{},customerId:{}", dateId, customerId);
@ -447,16 +435,6 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
} catch (Exception e) {
log.error("党建引领抽取到大屏失败,参数为:" + JSON.toJSONString(formDTO), e);
}
//已经挪到天抽取的抽取里了
/* try {
//基层治理 - 热心市民 screen_party_user_rank_data
ScreenCentralZoneDataFormDTO param = new ScreenCentralZoneDataFormDTO();
param.setCustomerId(customerId);
param.setDateId(monthId);
screenGrassrootsGovernDataAbsorptionService.userScoreDataHub(param);
} catch (Exception e) {
log.error("大屏热心市民/党员得分数据写入失败,参数为:{}" + JSON.toJSONString(formDTO), e);
}*/
try {
// 项目(事件)数量分析按网格_按月统计
screenProjectQuantityGridMonthlyService.extractionProjectGridMonthly(customerId, monthId);
@ -474,20 +452,6 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
log.info("===== extractMonthly method end not contains shi bei:{}======", customerId);
return;
}
//此方法保持在最后即可 计算指标分数 todo 优化 手动创建线程池 控制任务数量
ExecutorService pool = Executors.newSingleThreadExecutor();
pool.submit(() -> {
long start = System.currentTimeMillis();
CalculateCommonFormDTO formDTO1 = new CalculateCommonFormDTO();
try {
formDTO1.setMonthId(monthId);
formDTO1.setCustomerId(customerId);
Boolean aBoolean = indexCalculateService.indexCalculate(formDTO1);
HttpClientManager.getInstance().sendAlarmMsg(EnvEnum.getCurrentEnv().getName() + "客户Id:" + formDTO.getCustomerId() + ";monthId:" + formDTO1.getMonthId() + ",calculateAll全部指标计算完成,是否成功:" + aBoolean + ",总耗时:" + (System.currentTimeMillis() - start) / 1000 + "秒");
} catch (Exception e) {
log.error("extractMonthly 计算分数异常,参数:{}", JSON.toJSONString(formDTO1));
}
});
log.info("===== extractMonthly method end ======");
}
}

5
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateService.java

@ -19,6 +19,11 @@ public interface IndexCalculateService {
*/
Boolean indexCalculate(CalculateCommonFormDTO formDTO);
/**
* desc:异步 连续计算[指定或所有内部客户][多个月份]的指标得分入口
* @param formDTO
* @return
*/
Boolean indexStatistics(IndexStatisticsFormDTO formDTO);
/**

33
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java

@ -1,7 +1,9 @@
package com.epmet.service.evaluationindex.indexcal.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.enums.EnvEnum;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.DateUtils;
@ -17,16 +19,16 @@ import com.epmet.redis.IndexCalRedis;
import com.epmet.service.crm.CustomerRelationService;
import com.epmet.service.evaluationindex.indexcal.*;
import com.epmet.service.evaluationindex.indexcoll.FactIndexCollectService;
import com.epmet.service.stats.DimCustomerService;
import com.epmet.util.DimIdGenerator;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
/**
* @author liujianjun
@ -58,6 +60,8 @@ public class IndexCalculateServiceImpl implements IndexCalculateService {
private ScreenCustomerAgencyDao screenCustomerAgencyDao;
@Autowired
private CustomerRelationService customerRelationService;
@Autowired
private DimCustomerService dimCustomerService;
@Override
public Boolean indexCalculate(CalculateCommonFormDTO formDTO) {
@ -67,14 +71,15 @@ public class IndexCalculateServiceImpl implements IndexCalculateService {
formDTO.setMonthId(DimIdGenerator.getMonthDimId(DateUtils.addDateMonths(new Date(), -1)));
}
//按照客户分组
List<String> customerIds = new ArrayList<>();
Set<String> customerIds = new HashSet<>();
if (StringUtils.isBlank(formDTO.getCustomerId())) {
log.error("什么情况下走的这个方法,应该干掉他,因为...=====param:{}",JSON.toJSONString(formDTO));
Result<List<String>> externalCustomerIdsResult = epmetCommonServiceOpenFeignClient.getExternalCustomerIds();
if (!externalCustomerIdsResult.success()) {
log.error("indexCalculate epmetCommonServiceOpenFeignClient.getExternalCustomerIds return fail");
return false;
}
customerIds = externalCustomerIdsResult.getData();
customerIds.addAll(externalCustomerIdsResult.getData());
} else {
customerIds.add(formDTO.getCustomerId());
}
@ -95,8 +100,7 @@ public class IndexCalculateServiceImpl implements IndexCalculateService {
}
return flag;
} catch (Exception e) {
e.printStackTrace();
log.warn("indexCalculate exception:{}",e);
log.warn("indexCalculate late exception",e);
log.error("indexCalculate exception,param:{}", JSON.toJSONString(formDTO));
} finally {
//清除缓存
@ -212,12 +216,15 @@ public class IndexCalculateServiceImpl implements IndexCalculateService {
public Boolean indexStatistics(IndexStatisticsFormDTO formDTO) {
List<String> customerIds = new ArrayList<>();
if (StringUtils.isEmpty(formDTO.getCustomerId())){
Result<List<String>> externalCustomerIds = epmetCommonServiceOpenFeignClient.getExternalCustomerIds();
if (!externalCustomerIds.success()){
log.error("indexCalculate epmetCommonServiceOpenFeignClient.getExternalCustomerIds return fail");
return false;
}
customerIds = externalCustomerIds.getData();
int pageNo = NumConstant.ONE;
int pageSize = NumConstant.ONE_HUNDRED;
List<String> customerIdList = null;
do {
customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize);
if (!CollectionUtils.isEmpty(customerIdList)){
customerIds.addAll(customerIdList);
}
} while (!CollectionUtil.isEmpty(customerIdList) && customerIdList.size() == pageSize);
}else {
customerIds.add(formDTO.getCustomerId());
}

35
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsProjectServiceImpl.java

@ -1,17 +1,23 @@
package com.epmet.service.impl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.constant.PingYinConstant;
import com.epmet.constant.ProjectConstant;
import com.epmet.dto.ProjectDTO;
import com.epmet.dto.StatsFormDTO;
import com.epmet.dto.project.form.MonthProjectListFormDTO;
import com.epmet.dto.stats.DimAgencyDTO;
import com.epmet.dto.stats.DimGridDTO;
import com.epmet.entity.issue.IssueEntity;
import com.epmet.entity.org.CustomerAgencyEntity;
import com.epmet.entity.project.ProjectEntity;
import com.epmet.entity.project.ProjectProcessEntity;
import com.epmet.entity.stats.*;
import com.epmet.service.Issue.IssueService;
import com.epmet.service.StatsProjectService;
import com.epmet.service.org.CustomerAgencyService;
import com.epmet.service.org.CustomerGridService;
import com.epmet.service.project.ProjectProcessService;
import com.epmet.service.project.ProjectService;
@ -63,6 +69,8 @@ public class StatsProjectServiceImpl implements StatsProjectService {
private FactGridProjectMonthlyService factGridProjectMonthlyService;
@Autowired
private CustomerGridService customerGridService;
@Autowired
private CustomerAgencyService customerAgencyService;
/**
* @Author sun
@ -108,10 +116,18 @@ public class StatsProjectServiceImpl implements StatsProjectService {
DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(date);
//2:根据客户Id查询机关维度表数据
DimAgencyDTO dimAgencyDTO = new DimAgencyDTO();
dimAgencyDTO.setCustomerId(customerId);
List<DimAgencyDTO> dimAgencyList = dimAgencyService.getDimAgencyList(dimAgencyDTO);
//2022.3.3 平阴数据统计时只统计了五个街道的 其他三个街道是上报的,现在这三个街道在小程序也产生了项目(例行工作)数据,
//但是dim维度表不能有这三个街道的组织,因此改查业务库组织列表数据 start sun
List<DimAgencyDTO> dimAgencyList = new ArrayList<>();
if (customerId.equals(PingYinConstant.PROD_PING_YIN_CUSTOMER_ID)) {
List<CustomerAgencyEntity> agencyList = customerAgencyService.queryAgencyListByCustomerId(customerId);
dimAgencyList = ConvertUtils.sourceToTarget(agencyList, DimAgencyDTO.class);
} else {
DimAgencyDTO dimAgencyDTO = new DimAgencyDTO();
dimAgencyDTO.setCustomerId(customerId);
dimAgencyList = dimAgencyService.getDimAgencyList(dimAgencyDTO);
}
//2022.3.3 end sun
/*
//2022.1.12 客户数据量大 调整计算逻辑,一千条已查询,封装数据,将这部分业务数据查询拿到子方法分页查询处理 sun
//3:根据客户Id查询项目业务表已结案数据(查询传入日期及之前的数据)
@ -650,7 +666,16 @@ public class StatsProjectServiceImpl implements StatsProjectService {
DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(date);
//2:根据客户Id查询网格维度表数据
List<DimGridEntity> dimGridList = dimGridService.getGridListByCustomerId(customerId);
//2022.3.3 平阴数据统计时只统计了五个街道的 其他三个街道是上报的,现在这三个街道在小程序也产生了项目(例行工作)数据,
//但是dim维度表不能有这三个街道的组织,因此改查业务库网格列表数据 start sun
List<DimGridEntity> dimGridList = new ArrayList<>();
if (customerId.equals(PingYinConstant.PROD_PING_YIN_CUSTOMER_ID)) {
List<DimGridDTO> gridList = customerGridService.gridListByCustomerId(customerId);
dimGridList = ConvertUtils.sourceToTarget(gridList, DimGridEntity.class);
} else {
dimGridList = dimGridService.getGridListByCustomerId(customerId);
}
//2022.3.3 end sun
//3:根据客户Id查询项目业务表已结案数据(查询传入日期及之前的数据)
ProjectEntity projectEntity = new ProjectEntity();

8
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java

@ -8,9 +8,11 @@ import com.epmet.dto.org.CustomerStaffGridDTO;
import com.epmet.dto.org.GridInfoDTO;
import com.epmet.dto.org.form.GridBaseInfoFormDTO;
import com.epmet.dto.org.result.CustomerGridDTO;
import com.epmet.dto.stats.DimGridDTO;
import com.epmet.dto.user.form.StaffBaseInfoFormDTO;
import com.epmet.dto.user.result.GridUserInfoDTO;
import com.epmet.entity.org.CustomerGridEntity;
import com.epmet.entity.stats.DimGridEntity;
import java.util.Date;
import java.util.List;
@ -99,4 +101,10 @@ public interface CustomerGridService extends BaseService<CustomerGridEntity> {
* @Description 查询工作人员所属网格信息
**/
List<GridUserInfoDTO> getStaffGrid(StaffBaseInfoFormDTO formDTO);
/**
* @Author sun
* @Description 查询客户下有效网格列表
**/
List<DimGridDTO> gridListByCustomerId(String customerId);
}

10
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java

@ -12,6 +12,7 @@ import com.epmet.dto.org.CustomerStaffGridDTO;
import com.epmet.dto.org.GridInfoDTO;
import com.epmet.dto.org.form.GridBaseInfoFormDTO;
import com.epmet.dto.org.result.CustomerGridDTO;
import com.epmet.dto.stats.DimGridDTO;
import com.epmet.dto.user.form.StaffBaseInfoFormDTO;
import com.epmet.dto.user.result.GridUserInfoDTO;
import com.epmet.entity.org.CustomerGridEntity;
@ -147,4 +148,13 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu
return customerGridDao.getStaffGrid(formDTO);
}
/**
* @Author sun
* @Description 查询客户下有效网格列表
**/
@Override
public List<DimGridDTO> gridListByCustomerId(String customerId) {
return customerGridDao.gridListByCustomerId(customerId);
}
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/StatsStaffPatrolService.java

@ -10,7 +10,7 @@ import java.util.List;
*/
public interface StatsStaffPatrolService {
Integer delAndInsertBatch(StaffPatrolStatsFormDTO formDTO, List<StatsStaffPatrolRecordDailyDTO> insertList);
Integer insertBatchOrUpdate(StaffPatrolStatsFormDTO formDTO, List<StatsStaffPatrolRecordDailyDTO> insertList);
List<StatsStaffPatrolRecordDailyDTO> selectData(String customerId, String yesterdayStr);
}

7
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/user/impl/StatsStaffPatrolServiceImpl.java

@ -1,6 +1,5 @@
package com.epmet.service.user.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.utils.ConvertUtils;
@ -33,10 +32,8 @@ public class StatsStaffPatrolServiceImpl implements StatsStaffPatrolService {
@Transactional(rollbackFor = Exception.class)
@Override
public Integer delAndInsertBatch(StaffPatrolStatsFormDTO formDTO, List<StatsStaffPatrolRecordDailyDTO> insertList) {
int delete = statsStaffPatrolRecordDailyDao.deleteInternal(formDTO);
log.debug("delAndInsertBatch delete:{},param:{}", delete, JSON.toJSONString(formDTO));
return statsStaffPatrolRecordDailyDao.insertBatch(insertList);
public Integer insertBatchOrUpdate(StaffPatrolStatsFormDTO formDTO, List<StatsStaffPatrolRecordDailyDTO> insertList) {
return statsStaffPatrolRecordDailyDao.insertBatchOrUpdate(insertList);
}
@Override

11
epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml

@ -197,10 +197,13 @@ dynamic:
thread:
# 线程池配置
threadPool:
corePoolSize: @thread.pool.core-pool-size@
maxPoolSize: @thread.pool.max-pool-size@
queueCapacity: @thread.pool.queue-capacity@
keepAlive: @thread.pool.keep-alive@
enableCustomize: @thread.threadPool.enable-customize@
corePoolSize: @thread.threadPool.core-pool-size@
maxPoolSize: @thread.threadPool.max-pool-size@
queueCapacity: @thread.threadPool.queue-capacity@
keepAliveSeconds: @thread.threadPool.keep-alive-seconds@
threadNamePrefix: @thread.threadPool.thread-name-prefix@
rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@
dingTalk:
robot:

5
epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.29__addindex_forcpcability.sql

@ -0,0 +1,5 @@
-- stat库执行
alter table fact_origin_topic_main_daily add index `IDX_TOPIC_MAIN_GROUP_ID` (`GROUP_ID`);
alter table fact_origin_project_main_daily add index `IDX_P_MAIN_TOPIC_ID` (`TOPIC_ID`);
alter table fact_origin_issue_main_daily add index `IDX_ISSUE_MAIN_TOPIC_ID` (`TOPIC_ID`);
alter table fact_origin_group_member_daily add index `IDX_GM_GROUP_ID` (`GROUP_ID`);

18
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginGroupMainDailyDao.xml

@ -382,4 +382,22 @@
GRID_ID
</select>
<resultMap id="UserGroupIdDTOMap" type="com.epmet.dto.extract.UserGroupIdDTO">
<id property="userId" column="GROUP_OWNER_ID"/>
<collection property="groupIdList" ofType="java.lang.String">
<constructor>
<arg column="ID"/>
</constructor>
</collection>
</resultMap>
<select id="selectGroupAndLeader" parameterType="java.lang.String" resultMap="UserGroupIdDTOMap">
SELECT
t1.GROUP_OWNER_ID,
t1.ID
FROM
fact_origin_group_main_daily t1
WHERE t1.DEL_FLAG='0'
and t1.CUSTOMER_ID = #{customerId}
</select>
</mapper>

22
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginIssueLogDailyDao.xml

@ -237,4 +237,26 @@
GRID_ID,
OPERATION_USER_ID
</select>
<select id="queryVoteUserIds" parameterType="map" resultType="java.lang.String">
SELECT
*
FROM
(
SELECT
T1.OPERATION_USER_ID AS userId,
COUNT( 1 ) AS TOTAL
FROM
fact_origin_issue_log_daily T1
WHERE
T1.DEL_FLAG = '0'
AND T1.CUSTOMER_ID = #{customerId}
AND T1.MONTH_ID = #{monthId}
AND ( T1.ACTION_CODE = 'vote_support' OR T1.ACTION_CODE = 'vote_opposition' )
GROUP BY
T1.OPERATION_USER_ID
) temp
WHERE
total >0
</select>
</mapper>

10
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectOrgPeriodDailyDao.xml

@ -40,12 +40,12 @@
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND (DATE_FORMAT(INFORMED_DATE,"%Y%m%d") &gt;= #{dateId} OR DATE_FORMAT(HANDLED_DATE,"%Y%m%d") &gt;= #{dateId} OR DATE_FORMAT(PERIOD_TILL_REPLY_FIRSTLY,"%Y%m%d") &gt;= #{dateId})
<if test="null != list and list.size() > 0">
<foreach collection="list" open="AND ( " close=" )" separator=" OR " item="item">
PROJECT_ID = #{item}
</foreach>
</if>
AND (DATE_FORMAT(INFORMED_DATE,"%Y%m%d") &gt;= #{dateId} OR DATE_FORMAT(HANDLED_DATE,"%Y%m%d") &gt;= #{dateId} OR DATE_FORMAT(PERIOD_TILL_REPLY_FIRSTLY,"%Y%m%d") &gt;= #{dateId})
</delete>
<select id="selectResponsiveness" resultType="com.epmet.dto.extract.result.OrgStatisticsResultDTO">
@ -122,7 +122,7 @@
)
</foreach>
</insert>
<select id="selectDeptHandle" resultType="com.epmet.dto.extract.result.OrgStatisticsResultDTO">
SELECT
@ -141,8 +141,8 @@
GROUP BY
fp.ORG_ID
</select>
<select id="selectProjectNodeStartStopTime" resultType="com.epmet.dto.form.CostDayFormDTO">
SELECT
period.PROJECT_ID AS id,
@ -161,4 +161,4 @@
period.PROJECT_ID = #{projectId}
</foreach>
</select>
</mapper>
</mapper>

23
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginTopicLogDailyDao.xml

@ -143,4 +143,27 @@
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
</select>
<!-- 查询出本月内,评论过话题的用户id -->
<select id="queryCommentTopicUserIds" parameterType="map" resultType="java.lang.String">
SELECT
userId
FROM
(
SELECT
t1.OPERATE_USER_ID AS userId,
COUNT( 1 ) AS total
FROM
fact_origin_topic_log_daily T1
WHERE
T1.DEL_FLAG = '0'
AND T1.CUSTOMER_ID = #{customerId}
AND T1.MONTH_ID = #{monthId}
AND t1.ACTION_CODE = 'comment'
GROUP BY
t1.OPERATE_USER_ID
) temp
WHERE
total >0
</select>
</mapper>

13
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml

@ -185,4 +185,17 @@
</if>
</select>
<select id="gridListByCustomerId" resultType="com.epmet.dto.stats.DimGridDTO">
SELECT
id id,
customer_id customerId,
pid agencyId,
grid_name gridName
FROM
customer_grid
WHERE
del_flag = 0
AND customer_id = #{customerId}
</select>
</mapper>

7
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/user/StatsStaffPatrolRecordDailyDao.xml

@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.user.StatsStaffPatrolRecordDailyDao">
<insert id="insertBatch">
<insert id="insertBatchOrUpdate">
insert into stats_staff_patrol_record_daily
(
ID,
@ -63,6 +63,11 @@
ON DUPLICATE KEY UPDATE
PATROL_TOTAL = values(PATROL_TOTAL),
TOTAL_TIME = values(TOTAL_TIME),
LATEST_PATROL_STATUS = values(LATEST_PATROL_STATUS),
LATEST_PATROL_TIME = values(LATEST_PATROL_TIME),
REPORT_PROJECT_COUNT = values(REPORT_PROJECT_COUNT),
ROUTINE_WORK_COUNT = values(ROUTINE_WORK_COUNT),
UPDATED_TIME = now(),
UPDATED_BY = VALUES(UPDATED_BY)
</insert>
<delete id="deleteInternal">

36
epmet-module/epmet-activiti/epmet-activiti-server/pom.xml

@ -185,6 +185,15 @@
<nacos.service-list-changed-listening.enable>true</nacos.service-list-changed-listening.enable>
<spring.flyway.enabled>false</spring.flyway.enabled>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>epmet-activiti</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
</properties>
</profile>
<profile>
@ -219,6 +228,15 @@
<nacos.service-list-changed-listening.enable>false</nacos.service-list-changed-listening.enable>
<spring.flyway.enabled>false</spring.flyway.enabled>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>epmet-activiti</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
</properties>
</profile>
<profile>
@ -250,6 +268,15 @@
<nacos.service-list-changed-listening.enable>true</nacos.service-list-changed-listening.enable>
<spring.flyway.enabled>true</spring.flyway.enabled>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>epmet-activiti</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
</properties>
</profile>
<profile>
@ -281,6 +308,15 @@
<nacos.service-list-changed-listening.enable>true</nacos.service-list-changed-listening.enable>
<spring.flyway.enabled>true</spring.flyway.enabled>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>epmet-activiti</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
</properties>
</profile>
</profiles>

11
epmet-module/epmet-activiti/epmet-activiti-server/src/main/resources/bootstrap.yml

@ -109,3 +109,14 @@ hystrix:
ribbon:
ReadTimeout: 300000
ConnectTimeout: 300000
thread:
# 线程池配置
threadPool:
enableCustomize: @thread.threadPool.enable-customize@
corePoolSize: @thread.threadPool.core-pool-size@
maxPoolSize: @thread.threadPool.max-pool-size@
queueCapacity: @thread.threadPool.queue-capacity@
keepAliveSeconds: @thread.threadPool.keep-alive-seconds@
threadNamePrefix: @thread.threadPool.thread-name-prefix@
rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@

11
epmet-user/epmet-user-client/src/main/java/com/epmet/constant/ImportTaskConstants.java → epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java

@ -1,13 +1,20 @@
package com.epmet.constant;
package com.epmet.constants;
/**
* 导入任务的业务类型常量
*/
public interface ImportTaskConstants {
/**
* 居民
* 业务类型居民
*/
String BIZ_TYPE_RESI = "resi";
String BIZ_TYPE_NEIGHBOR_HOOD = "neighborHood";
String BIZ_TYPE_BUILDING = "building";
String BIZ_TYPE_HOUSE = "house";
String BIZ_TYPE_PARTY_MEMBER = "party_member";
String BIZ_TYPE_COMMUNITY_SELF_ORG = "community_self_org";
String BIZ_TYPE_PARTY_UNIT = "party_unit";
String BIZ_TYPE_PARTY_ACTIVITY = "party_activity";
/**
* 处理状态处理中

55
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ImportTaskCommonFormDTO.java

@ -0,0 +1,55 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.dto.form.PageFormDTO;
import com.epmet.commons.tools.validator.group.QueryGroup;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class ImportTaskCommonFormDTO extends PageFormDTO {
public interface Create {}
public interface Finish {}
/**
* 原始文件名
*/
@NotBlank(message = "原始文件名必填", groups = { Create.class })
private String originFileName;
/**
* 操作者ID
*/
@NotBlank(message = "操作者ID必填", groups = { Create.class, Finish.class, QueryGroup.class})
private String operatorId;
/**
* 业务类型
*/
@NotBlank(message = "业务类型必填", groups = { Create.class })
private String bizType;
/**
* 任务ID
*/
@NotBlank(message = "任务ID必填", groups = { Finish.class })
private String taskId;
/**
* 处理状态
*/
@NotBlank(message = "处理状态必填", groups = { Finish.class })
private String processStatus;
/**
* 结果文件 url
*/
private String resultDescFilePath;
/**
* 结果描述文本
*/
private String resultDesc;
}

43
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/ImportTaskCommonResultDTO.java

@ -0,0 +1,43 @@
package com.epmet.dto.result;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
@Data
@NoArgsConstructor
public class ImportTaskCommonResultDTO implements Serializable {
public ImportTaskCommonResultDTO(String taskId) {
this.taskId = taskId;
}
private String taskId;
/**
* 原始文件名
*/
private String originFileName;
/**
* 业务类型resi:居民楼栋:building房屋:house依次补充
*/
private String bizType;
/**
* 处理状态processing:处理中finished:完成导入失败finished_fail
*/
private String processStatus;
/**
* 开始导入的时间
*/
private Date startTime;
/**
* 失败文件地址
*/
private String resultDescFile;
}

18
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java

@ -4,12 +4,12 @@ import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.feign.fallback.EpmetCommonServiceOpenFeignClientFallback;
import com.epmet.feign.fallback.EpmetCommonServiceOpenFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;
import java.util.Map;
@ -124,4 +124,20 @@ public interface EpmetCommonServiceOpenFeignClient {
**/
@PostMapping(value = "commonservice/areacode/addareacode", consumes = MediaType.APPLICATION_JSON_VALUE)
Result<String> addAreaCode(AddAreaCodeFormDTO formDTO);
/**
* 创建导入任务
* @param input
* @return
*/
@RequestMapping("/commonservice/import-task/create")
Result<ImportTaskCommonResultDTO> createImportTask(@RequestBody ImportTaskCommonFormDTO input);
/**
* 结束导入任务
* @param input
* @return
*/
@RequestMapping("/commonservice/import-task/finish")
Result finishImportTask(@RequestBody ImportTaskCommonFormDTO input);
}

10
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java

@ -111,4 +111,14 @@ public class EpmetCommonServiceOpenFeignClientFallback implements EpmetCommonSer
public Result<String> addAreaCode(AddAreaCodeFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "addAreaCode", formDTO);
}
@Override
public Result createImportTask(ImportTaskCommonFormDTO input) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "createImportTask", input);
}
@Override
public Result finishImportTask(ImportTaskCommonFormDTO input) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "finishImportTask", input);
}
}

36
epmet-module/epmet-common-service/common-service-server/pom.xml

@ -139,6 +139,15 @@
</dingTalk.robot.webHook>
<dingTalk.robot.secret>SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd
</dingTalk.robot.secret>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>common-service</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
</properties>
</profile>
<profile>
@ -187,6 +196,15 @@
</dingTalk.robot.webHook>
<dingTalk.robot.secret>SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd
</dingTalk.robot.secret>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>common-service</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
</properties>
</profile>
<profile>
@ -233,6 +251,15 @@
</dingTalk.robot.webHook>
<dingTalk.robot.secret>SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd
</dingTalk.robot.secret>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>common-service</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
</properties>
</profile>
<profile>
@ -276,6 +303,15 @@
</dingTalk.robot.webHook>
<dingTalk.robot.secret>SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd
</dingTalk.robot.secret>
<!--线程池-->
<thread.threadPool.enable-customize>true</thread.threadPool.enable-customize>
<thread.threadPool.core-pool-size>5</thread.threadPool.core-pool-size>
<thread.threadPool.max-pool-size>8</thread.threadPool.max-pool-size>
<thread.threadPool.queue-capacity>20</thread.threadPool.queue-capacity>
<thread.threadPool.keep-alive-seconds>60</thread.threadPool.keep-alive-seconds>
<thread.threadPool.thread-name-prefix>common-service</thread.threadPool.thread-name-prefix>
<thread.threadPool.rejected-execution-handler>callerRunsPolicy</thread.threadPool.rejected-execution-handler>
</properties>
</profile>
</profiles>

82
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ImportTaskController.java

@ -0,0 +1,82 @@
package com.epmet.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.QueryGroup;
import com.epmet.dto.form.ImportTaskCommonFormDTO;
import com.epmet.dto.result.ImportTaskCommonResultDTO;
import com.epmet.service.ImportTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("import-task")
public class ImportTaskController {
@Autowired
private ImportTaskService importTaskService;
/**
* desc:分页获取个人导入记录
* @param tokenDto
* @return
*/
@RequestMapping("page")
public Result<PageData<ImportTaskCommonResultDTO>> list(@LoginUser TokenDto tokenDto, @RequestBody ImportTaskCommonFormDTO param) {
//tokenDto.setUserId("d8dfc6c1fa2538976059f3900036d419");
param.setOperatorId(tokenDto.getUserId());
ValidatorUtils.validateEntity(param, QueryGroup.class);
return new Result().ok(importTaskService.page(param));
}
/**
* 创建导入任务
* @param input
* @return
*/
@RequestMapping("create")
public Result<ImportTaskCommonResultDTO> createTask(@RequestBody ImportTaskCommonFormDTO input) {
ValidatorUtils.validateEntity(input, ImportTaskCommonFormDTO.Create.class);
String operatorId = input.getOperatorId();
String bizType = input.getBizType();
String originFileName = input.getOriginFileName();
String taskId = importTaskService.createProcessTask(operatorId, bizType, originFileName);
ImportTaskCommonResultDTO ro = new ImportTaskCommonResultDTO(taskId);
return new Result().ok(ro);
}
/**
* 结束任务
* @param input
* @return
*/
@RequestMapping("finish")
public Result finishTask(@RequestBody ImportTaskCommonFormDTO input) {
ValidatorUtils.validateEntity(input, ImportTaskCommonFormDTO.Finish.class);
Boolean finished = importTaskService.finish(input.getTaskId(), input.getProcessStatus(), input.getOperatorId(), input.getResultDescFilePath(), input.getResultDesc());
if (!finished) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),
"失败,请确认任务是否存在,以及是否已完成",
"失败,请确认任务是否存在,以及是否已完成");
}
return new Result();
}
/**
* 检查是否有正在执行的任务
* @param bizType 业务类型非必填不传则任意一种导入正在执行都会返回true
* @return
*/
@GetMapping("processing-check")
public Result processingTaskCheck(@RequestParam(value = "biz_type", required = false) String bizType) {
Boolean r = importTaskService.processingTaskCheck(bizType);
return new Result().ok(r);
}
}

0
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/ImportTaskDao.java → epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ImportTaskDao.java

11
epmet-user/epmet-user-server/src/main/java/com/epmet/entity/ImportTaskEntity.java → epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ImportTaskEntity.java

@ -1,7 +1,6 @@
package com.epmet.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -21,6 +20,16 @@ public class ImportTaskEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户ID
*/
private String customerId;
/**
* 原始文件名
*/
private String originFileName;
/**
* 业务类型resi:居民楼栋:building房屋:house依次补充
*/

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save