Browse Source

Merge remote-tracking branch 'remotes/origin/dev_screen_data_2.0' into dev_difficulty_data

master
jianjun 5 years ago
parent
commit
3b5b3d21bb
  1. 2
      epmet-auth/deploy/docker-compose-prod.yml
  2. 2
      epmet-auth/pom.xml
  3. 2
      epmet-cloud-generator/src/main/resources/application.yml
  4. 7
      epmet-commons/epmet-commons-tools/pom.xml
  5. 56
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/RedissonConfig.java
  6. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java
  7. 10
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  8. 2
      epmet-gateway/deploy/docker-compose-prod.yml
  9. 2
      epmet-gateway/pom.xml
  10. 30
      epmet-gateway/src/main/java/com/epmet/auth/ExternalAuthProcessor.java
  11. 39
      epmet-gateway/src/main/java/com/epmet/auth/InternalAuthProcessor.java
  12. 8
      epmet-gateway/src/main/java/com/epmet/constant/AuthTypeConstant.java
  13. 6
      epmet-gateway/src/main/java/com/epmet/constant/TokenHeaderKeyConstant.java
  14. 81
      epmet-gateway/src/main/java/com/epmet/filter/CpAuthGatewayFilterFactory.java
  15. 4
      epmet-gateway/src/main/java/com/epmet/filter/CpProperty.java
  16. 3
      epmet-gateway/src/main/resources/bootstrap.yml
  17. 2
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/constant/ScreenConstant.java
  18. 4
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/AblityListFormDTO.java
  19. 4
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/MonthAblityListFormDTO.java
  20. 4
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/MonthScoreListFormDTO.java
  21. 9
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/PeerComparisonFormDTO.java
  22. 4
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/ScoreListFormDTO.java
  23. 2
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/PublicPartiProfileResultDTO.java
  24. 2
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/UserJoinIndicatorGrowthRateResultDTO.java
  25. 2
      epmet-module/data-report/data-report-server/deploy/docker-compose-prod.yml
  26. 2
      epmet-module/data-report/data-report-server/pom.xml
  27. 12
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/AgencyController.java
  28. 4
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java
  29. 9
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/AgencyService.java
  30. 71
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java
  31. 3
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/IndexServiceImpl.java
  32. 6
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/fact/impl/FactIndexServiceImpl.java
  33. 37
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml
  34. 13
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml
  35. 2
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenUserJoinDao.xml
  36. 2
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/ProjectParticipatedAgencyResultDTO.java
  37. 21
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/TransferRightRatioResultDTO.java
  38. 26
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcollect/form/CustomerBizOrgFormDTO.java
  39. 5
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/form/CustomerIdAndDateIdFormDTO.java
  40. 3
      epmet-module/data-statistical/data-statistical-server/Dockerfile
  41. 2
      epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-prod.yml
  42. 2
      epmet-module/data-statistical/data-statistical-server/pom.xml
  43. 13
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java
  44. 1
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java
  45. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java
  46. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexDictController.java
  47. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ShiBeiScreenCollController.java
  48. 72
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginProjectLogDailyDao.java
  49. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginProjectMainDailyDao.java
  50. 20
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginProjectOrgPeriodDailyDao.java
  51. 7
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java
  52. 40
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerBizOrgDao.java
  53. 15
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerAgencyEntity.java
  54. 52
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerBizOrgEntity.java
  55. 7
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/CalculateFlagModel.java
  56. 43
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalGridIndexServiceImpl.java
  57. 25
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollCommunityServiceImpl.java
  58. 50
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollDistrictDepartmentServiceImpl.java
  59. 23
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollDistrictServiceImpl.java
  60. 23
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollStreetServiceImpl.java
  61. 44
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginProjectLogDailyService.java
  62. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginProjectMainDailyService.java
  63. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginProjectOrgPeriodDailyService.java
  64. 21
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/ProjectPeriodExtractService.java
  65. 156
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java
  66. 149
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginProjectLogDailyServiceImpl.java
  67. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginProjectMainDailyServiceImpl.java
  68. 14
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginProjectOrgPeriodDailyServiceImpl.java
  69. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java
  70. 104
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectPeriodExtractServiceImpl.java
  71. 26
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/OrgRankExtractServiceImpl.java
  72. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java
  73. 11
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/DeptScoreServiceImpl.java
  74. 11
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/GridCorreLationServiceImpl.java
  75. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java
  76. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java
  77. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java
  78. 11
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/FactIndexGovrnAblityDeptMonthlyService.java
  79. 89
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java
  80. 15
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexGovrnAblityDeptMonthlyServiceImpl.java
  81. 13
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java
  82. 13
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ShiBeiScreenCollService.java
  83. 13
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java
  84. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java
  85. 88
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ShiBeiScreenCollServiceImpl.java
  86. 65
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerPartymemberServiceImpl.java
  87. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/ScoreConstants.java
  88. 48
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java
  89. 10
      epmet-module/data-statistical/data-statistical-server/src/main/resources/logback-spring.xml
  90. 214
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectLogDailyDao.xml
  91. 11
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectMainDailyDao.xml
  92. 21
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectOrgPeriodDailyDao.xml
  93. 1
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencySubScoreDao.xml
  94. 1
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunitySubScoreDao.xml
  95. 1
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/DeptSubScoreDao.xml
  96. 1
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridSubScoreDao.xml
  97. 1
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml
  98. 39
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerBizOrgDao.xml
  99. 1
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimDepartmentDao.xml
  100. 61
      epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/RedissonTest.java

2
epmet-auth/deploy/docker-compose-prod.yml

@ -2,7 +2,7 @@ version: "3.7"
services:
epmet-auth-server:
container_name: epmet-auth-server-prod
image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/epmet-auth:0.3.69
image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/epmet-auth:0.3.70
ports:
- "8081:8081"
network_mode: host # 使用现有网络

2
epmet-auth/pom.xml

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<version>0.3.69</version>
<version>0.3.70</version>
<parent>
<groupId>com.epmet</groupId>
<artifactId>epmet-cloud</artifactId>

2
epmet-cloud-generator/src/main/resources/application.yml

@ -9,7 +9,7 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource
#MySQL配置
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://192.168.1.130:3306/epmet_data_statistical?useUnicode=true&characterEncoding=UTF-8&useSSL=false
url: jdbc:mysql://192.168.1.130:3306/epmet_gov_project?useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: epmet_dba
password: EpmEt-dbA-UsEr
#oracle配置

7
epmet-commons/epmet-commons-tools/pom.xml

@ -49,6 +49,13 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.redisson/redisson -->
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
<version>3.12.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>

56
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/RedissonConfig.java

@ -0,0 +1,56 @@
package com.epmet.commons.tools.config;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.codec.JsonJacksonCodec;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* redisson 配置类
*/
@Slf4j
@Configuration
public class RedissonConfig {
@Value("${spring.redis.host}")
private String host;
@Value("${spring.redis.port}")
private String port;
@Value("${spring.redis.password}")
private String password;
@Bean
public RedissonClient getRedisson() {
if (StringUtils.isBlank(host)) {
log.warn("getRedisson redis param is null,don't need to init redissonClient");
return null;
}
try {
Config config = new Config();
config.setCodec(new JsonJacksonCodec());
config.setThreads(NumConstant.FOUR);
config.setNettyThreads(NumConstant.FOUR);
//redis://ip:port
//redis的部署方式有单节点部署、主从方式部署、哨兵方式部署、集群方式部署
config.useSingleServer().setAddress("redis://".concat(host).concat(StrConstant.COLON).concat(port));
config.useSingleServer().setPassword(password);
config.useSingleServer().setConnectTimeout(NumConstant.ONE_THOUSAND * NumConstant.FIVE);
config.useSingleServer().setDatabase(NumConstant.TEN);
return Redisson.create(config);
} catch (Exception e) {
log.error("初始化redisson失败", e);
return null;
}
}
}

1
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java

@ -39,6 +39,7 @@ public interface NumConstant {
int SIXTY = 60;
int ONE_HUNDRED = 100;
BigDecimal ONE_HUNDRED_DECIMAL = new BigDecimal(100);
BigDecimal ZERO_DECIMAL = new BigDecimal(0);
int ONE_THOUSAND = 1000;
int MAX = 99999999;
int EIGHTY_EIGHT = 88;

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

@ -313,7 +313,7 @@ public class RedisKeys {
* @return
*/
public static String getIndexCodeWeightKey(String customerId) {
return rootPrefix.concat("stats:indexcal:indexcode:weight").concat(customerId);
return rootPrefix.concat("stats:indexcal:indexcode:weight").concat(StrConstant.COLON).concat(customerId);
}
/**
@ -330,9 +330,17 @@ public class RedisKeys {
/**
* 获取计算标记的key前缀
*
* @return
*/
public static String getCustomerStatsCalKeyPrefix() {
return rootPrefix.concat("stats:calflag");
}
/**
* 插入大屏指标数据分布式锁 key
*/
public static String getScreenIndexDataLockKey() {
return rootPrefix.concat("stats:indexcal:lock");
}
}

2
epmet-gateway/deploy/docker-compose-prod.yml

@ -2,7 +2,7 @@ version: "3.7"
services:
epmet-gateway-server:
container_name: epmet-gateway-server-prod
image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/epmet-gateway:0.3.33
image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/epmet-gateway:0.3.39
ports:
- "8080:8080"
network_mode: host # 使用现有网络

2
epmet-gateway/pom.xml

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<version>0.3.35</version>
<version>0.3.39</version>
<parent>
<groupId>com.epmet</groupId>
<artifactId>epmet-cloud</artifactId>

30
epmet-gateway/src/main/java/com/epmet/auth/ExternalAuthProcessor.java

@ -4,13 +4,16 @@ 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.utils.Result;
import com.epmet.filter.CpProperty;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.http.HttpHeaders;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Component;
import org.springframework.util.AntPathMatcher;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
@ -41,9 +44,30 @@ public class ExternalAuthProcessor extends AuthProcessor {
@Autowired
private ExtAppMD5AuthProcessor md5AuthProcessor;
private final AntPathMatcher antPathMatcher = new AntPathMatcher();
@Autowired
private CpProperty cpProperty;
@Override
public Mono<Void> auth(ServerWebExchange exchange, GatewayFilterChain chain) {
HttpHeaders headers = exchange.getRequest().getHeaders();
ServerHttpRequest request = exchange.getRequest();
// 只有在外部应用urls中的url才会允许外部应用访问,否则不允许访问
String requestUri = request.getPath().pathWithinApplication().value();
boolean inPaths = false;
for (String url : cpProperty.getExternalOpenUrls()) {
if (antPathMatcher.match(url, requestUri)) {
inPaths = true;
}
}
if (!inPaths) {
throw new RenException(EpmetErrorCode.ERR401.getCode(), "所请求的url并未对外部应用开放");
}
HttpHeaders headers = request.getHeaders();
String token = headers.getFirst(ACCESS_TOKEN_HEADER_KEY);
String appId = headers.getFirst(APP_ID_HEADER_KEY);
@ -52,7 +76,7 @@ public class ExternalAuthProcessor extends AuthProcessor {
String authType = headers.getFirst(APP_ID_AUTY_TYPE_KEY);
if (StringUtils.isAnyBlank(token, appId)) {
throw new RenException("请求头中的AccessToken和AppId不能为空");
throw new RenException(EpmetErrorCode.ERR401.getCode(), "请求头中的AccessToken和AppId不能为空");
}
logger.info("外部应用请求认证拦截Aspect执行,appId:{}, token:{}, ts:{}, customerId:{}, authType:{}",
@ -65,7 +89,7 @@ public class ExternalAuthProcessor extends AuthProcessor {
} else if (APP_AUTH_TYPE_MD5.equals(authType)) {
md5AuthProcessor.auth(appId, token, StringUtils.isNotBlank(ts) ? new Long(ts) : null, exchange);
} else {
throw new RenException(EpmetErrorCode.OPER_EXTERNAL_APP_AUTH_ERROR.getCode(), "未知的认证类型");
throw new RenException(EpmetErrorCode.OPER_EXTERNAL_APP_AUTH_ERROR.getCode(), "未知的外部认证类型");
}
} catch (RenException e) {
return response(exchange, new Result<>().error(e.getCode(), e.getMsg()));

39
epmet-gateway/src/main/java/com/epmet/auth/InternalAuthProcessor.java

@ -9,6 +9,7 @@ import com.epmet.commons.tools.security.dto.GovTokenDto;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.CpUserDetailRedis;
import com.epmet.commons.tools.utils.Result;
import com.epmet.filter.CpProperty;
import com.epmet.jwt.JwtTokenUtils;
import io.jsonwebtoken.Claims;
import org.apache.commons.lang3.StringUtils;
@ -19,6 +20,7 @@ import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.http.HttpHeaders;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Component;
import org.springframework.util.AntPathMatcher;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
@ -36,6 +38,11 @@ public class InternalAuthProcessor extends AuthProcessor {
@Autowired
private CpUserDetailRedis cpUserDetailRedis;
private final AntPathMatcher antPathMatcher = new AntPathMatcher();
@Autowired
private CpProperty cpProperty;
@Override
public Mono<Void> auth(ServerWebExchange exchange, GatewayFilterChain chain) {
ServerHttpRequest request = exchange.getRequest();
@ -82,14 +89,16 @@ public class InternalAuthProcessor extends AuthProcessor {
}
}
// 校验token
if (StringUtils.isBlank(token)) {
return response(exchange,new Result<>().error(EpmetErrorCode.ERR10005.getCode(),EpmetErrorCode.ERR10005.getMsg()));
}
try {
validateTokenDto(baseTokenDto, token);
} catch (RenException e) {
return response(exchange,new Result<>().error(e.getCode(),e.getMsg()));
if (needAuth(requestUri)) {
// 校验token
if (StringUtils.isBlank(token)) {
return response(exchange, new Result<>().error(EpmetErrorCode.ERR10005.getCode(), EpmetErrorCode.ERR10005.getMsg()));
}
try {
validateTokenDto(baseTokenDto, token);
} catch (RenException e) {
return response(exchange, new Result<>().error(e.getCode(), e.getMsg()));
}
}
// 添加header
@ -116,6 +125,20 @@ public class InternalAuthProcessor extends AuthProcessor {
return chain.filter(exchange);
}
/**
* 是否需要认证
* @param requestUri
* @return
*/
private boolean needAuth(String requestUri) {
for (String url : cpProperty.getInternalAuthUrls()) {
if (antPathMatcher.match(url, requestUri)) {
return true;
}
}
return false;
}
/**
* 从请求中获取token
* @param request

8
epmet-gateway/src/main/java/com/epmet/constant/AuthTypeConstant.java

@ -0,0 +1,8 @@
package com.epmet.constant;
public class AuthTypeConstant {
public static final String AUTH_TYPE_INTERNAL = "internal";
public static final String AUTH_TYPE_EXTERNAL = "external";
public static final String AUTH_TYPE_NO_NEED = "no_need";
public static final String AUTH_TYPE_UNKNOW = "unknow";
}

6
epmet-gateway/src/main/java/com/epmet/constant/TokenHeaderKeyConstant.java

@ -0,0 +1,6 @@
package com.epmet.constant;
public class TokenHeaderKeyConstant {
public static final String ACCESS_TOKEN_HEADER_KEY = "AccessToken";
public static final String AUTHORIZATION_TOKEN_HEADER_KEY = "Authorization";
}

81
epmet-gateway/src/main/java/com/epmet/filter/CpAuthGatewayFilterFactory.java

@ -7,7 +7,10 @@ import com.epmet.auth.InternalAuthProcessor;
import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.constant.Constant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.AuthTypeConstant;
import com.epmet.constant.TokenHeaderKeyConstant;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -40,16 +43,6 @@ public class CpAuthGatewayFilterFactory extends AbstractGatewayFilterFactory<CpA
private Logger logger = LoggerFactory.getLogger(getClass());
private final AntPathMatcher antPathMatcher = new AntPathMatcher();
public static final String AUTH_TYPE_INTERNAL = "internal";
public static final String AUTH_TYPE_EXTERNAL = "external";
public static final String AUTH_TYPE_NO_NEED = "no_need";
public static final String AUTH_TYPE_UNKNOW = "unknow";
@Autowired
private CpProperty cpProperty;
@Autowired
private InternalAuthProcessor internalAuthProcessor;
@ -79,16 +72,17 @@ public class CpAuthGatewayFilterFactory extends AbstractGatewayFilterFactory<CpA
String authType = getAuthType(request);
switch (authType) {
case AUTH_TYPE_EXTERNAL:
return externalAuthProcessor.auth(exchange, chain);
case AUTH_TYPE_INTERNAL:
return internalAuthProcessor.auth(exchange, chain);
case AUTH_TYPE_NO_NEED:
break;
default:
return response(exchange, new Result<>().error(EpmetErrorCode.ERR401.getCode(),
EpmetErrorCode.ERR401.getMsg()));
try {
switch (authType) {
case AuthTypeConstant.AUTH_TYPE_EXTERNAL:
return externalAuthProcessor.auth(exchange, chain);
case AuthTypeConstant.AUTH_TYPE_INTERNAL:
return internalAuthProcessor.auth(exchange, chain);
}
} catch (RenException e) {
return response(exchange, new Result<>().error(e.getCode(), e.getMessage()));
} catch (Exception e) {
return response(exchange, new Result<>().error(e.getMessage()));
}
return chain.filter(exchange);
@ -100,40 +94,23 @@ public class CpAuthGatewayFilterFactory extends AbstractGatewayFilterFactory<CpA
* @return
*/
private String getAuthType(ServerHttpRequest request) {
String requestUri = request.getPath().pathWithinApplication().value();
boolean existsInInternal = false;
boolean existsInExternal = false;
for (String url : cpProperty.getInternalAuthUrls()) {
if (antPathMatcher.match(url, requestUri)) {
existsInInternal = true;
}
}
for (String url : cpProperty.getExternalAuthUrls()) {
if (antPathMatcher.match(url, requestUri)) {
existsInExternal = true;
}
}
if (!existsInInternal && !existsInExternal) {
// 既不再内部认证url,也不在外部认证url,那么不需要认证
return AUTH_TYPE_NO_NEED;
}
// 内部认证
if (StringUtils.isNotBlank(getHeader(request, Constant.AUTHORIZATION_HEADER))
&& existsInInternal) {
return AUTH_TYPE_INTERNAL;
}
if (StringUtils.isNotBlank(getHeader(request, Constant.ACCESS_TOKEN_HEADER))
&& existsInExternal) {
return AUTH_TYPE_EXTERNAL;
//String requestUri = request.getPath().pathWithinApplication().value();
// 是否在外部认证列表中(外部认证列表中的url,是对外部应用开放的,只有在这个列表中的url才对外部应用开放)
//boolean inExtAuthPaths = false;
//
//for (String url : cpProperty.getExternalAuthUrls()) {
// if (antPathMatcher.match(url, requestUri)) {
// inExtAuthPaths = true;
// }
//}
if (StringUtils.isNotBlank(request.getHeaders().getFirst(TokenHeaderKeyConstant.ACCESS_TOKEN_HEADER_KEY))) {
// url对外部应用开放,并且头里面有AccessToken,那么走外部应用认证
return AuthTypeConstant.AUTH_TYPE_EXTERNAL;
}
return AUTH_TYPE_UNKNOW;
return AuthTypeConstant.AUTH_TYPE_INTERNAL;
}
/**

4
epmet-gateway/src/main/java/com/epmet/filter/CpProperty.java

@ -23,9 +23,9 @@ public class CpProperty {
private List<String> internalAuthUrls;
/**
* 需要外部认证的url
* 对外部应用开放的url列表
*/
private List<String> externalAuthUrls;
private List<String> externalOpenUrls;
/**
* 不处理token直接通过

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

@ -439,9 +439,10 @@ epmet:
- /data/report/**
# 外部应用认证,使用AccessToken等头进行认证
externalAuthUrls:
externalOpenUrls:
- /data/report/**
- /data/stats/**
- /epmet/ext/**
- /epmetuser/customerstaff/customerlist
swaggerUrls:

2
epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/constant/ScreenConstant.java

@ -16,6 +16,8 @@ public interface ScreenConstant {
String COMMA = ",";
String COLON = ":";
String MONTH_ID = "month";
String YEAR_ID = "year";

4
epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/AblityListFormDTO.java

@ -21,12 +21,12 @@ public class AblityListFormDTO implements Serializable {
/**
* 组织或网格Id
*/
@NotBlank(message = "组织或网格ID不能为空",groups = {AblityIndexFormDTO.AddUserInternalGroup.class})
@NotBlank(message = "组织或网格ID不能为空",groups = {AblityListFormDTO.AddUserInternalGroup.class})
private String orgId;
/**
* 组织或网格类型
*/
@NotBlank(message = "组织或网格类型不能为空",groups = {AblityIndexFormDTO.AddUserInternalGroup.class})
@NotBlank(message = "组织或网格类型不能为空",groups = {AblityListFormDTO.AddUserInternalGroup.class})
private String orgType;
public interface AddUserInternalGroup {}
/**

4
epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/MonthAblityListFormDTO.java

@ -21,12 +21,12 @@ public class MonthAblityListFormDTO implements Serializable {
/**
* 组织或网格Id
*/
@NotBlank(message = "组织或网格ID不能为空",groups = {AblityIndexFormDTO.AddUserInternalGroup.class})
@NotBlank(message = "组织或网格ID不能为空",groups = {MonthAblityListFormDTO.AddUserInternalGroup.class})
private String orgId;
/**
* 组织或网格类型
*/
@NotBlank(message = "组织或网格类型不能为空",groups = {AblityIndexFormDTO.AddUserInternalGroup.class})
@NotBlank(message = "组织或网格类型不能为空",groups = {MonthAblityListFormDTO.AddUserInternalGroup.class})
private String orgType;
public interface AddUserInternalGroup {}
/**

4
epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/MonthScoreListFormDTO.java

@ -17,7 +17,7 @@ public class MonthScoreListFormDTO implements Serializable {
/**
* 组织或网格Id
*/
@NotBlank(message = "组织或网格ID不能为空",groups = {AblityIndexFormDTO.AddUserInternalGroup.class})
@NotBlank(message = "组织或网格ID不能为空",groups = {MonthScoreListFormDTO.AddUserInternalGroup.class})
private String orgId;
/**
* 组织Id
@ -27,7 +27,7 @@ public class MonthScoreListFormDTO implements Serializable {
/**
* 组织或网格类型
*/
@NotBlank(message = "组织或网格类型不能为空",groups = {AblityIndexFormDTO.AddUserInternalGroup.class})
@NotBlank(message = "组织或网格类型不能为空",groups = {MonthScoreListFormDTO.AddUserInternalGroup.class})
private String orgType;
/**
* 月份Id格式202009

9
epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/PeerComparisonFormDTO.java

@ -19,15 +19,20 @@ public class PeerComparisonFormDTO implements Serializable {
*/
@NotBlank(message = "客户ID不能为空",groups = {PeerComparisonFormDTO.AddUserInternalGroup.class})
private String customerId;
/**
* 月份Id格式202009
*/
//@NotBlank(message = "月份ID不能为空",groups = {PeerComparisonFormDTO.AddUserInternalGroup.class})
private String monthId;
/**
* 组织或网格Id
*/
@NotBlank(message = "组织或网格ID不能为空",groups = {AblityIndexFormDTO.AddUserInternalGroup.class})
@NotBlank(message = "组织或网格ID不能为空",groups = {PeerComparisonFormDTO.AddUserInternalGroup.class})
private String orgId;
/**
* 组织或网格类型
*/
@NotBlank(message = "组织或网格类型不能为空",groups = {AblityIndexFormDTO.AddUserInternalGroup.class})
@NotBlank(message = "组织或网格类型不能为空",groups = {PeerComparisonFormDTO.AddUserInternalGroup.class})
private String orgType;
public interface AddUserInternalGroup {}
/**

4
epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/ScoreListFormDTO.java

@ -17,7 +17,7 @@ public class ScoreListFormDTO implements Serializable {
/**
* 组织或网格Id
*/
@NotBlank(message = "组织或网格ID不能为空",groups = {AblityIndexFormDTO.AddUserInternalGroup.class})
@NotBlank(message = "组织或网格ID不能为空",groups = {ScoreListFormDTO.AddUserInternalGroup.class})
private String orgId;
/**
* 组织Id
@ -27,7 +27,7 @@ public class ScoreListFormDTO implements Serializable {
/**
* 组织或网格类型
*/
@NotBlank(message = "组织或网格类型不能为空",groups = {AblityIndexFormDTO.AddUserInternalGroup.class})
@NotBlank(message = "组织或网格类型不能为空",groups = {ScoreListFormDTO.AddUserInternalGroup.class})
private String orgType;
/**
* 月份Id格式202009

2
epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/PublicPartiProfileResultDTO.java

@ -25,7 +25,7 @@ public class PublicPartiProfileResultDTO implements Serializable {
* */
private String monthTrend = "";
private Integer averageIssue = NumConstant.ZERO;
private BigDecimal averageIssue = new BigDecimal(NumConstant.ZERO);
/**
* 较上月百分比

2
epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/UserJoinIndicatorGrowthRateResultDTO.java

@ -24,7 +24,7 @@ public class UserJoinIndicatorGrowthRateResultDTO implements Serializable {
* */
private String monthTrend;
private Integer averageIssue;
private BigDecimal averageIssue;
/**
* 较上月百分比

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

@ -2,7 +2,7 @@ version: "3.7"
services:
data-report-server:
container_name: data-report-server-prod
image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/data-report-server:0.3.37
image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/data-report-server:0.3.44
ports:
- "8108:8108"
network_mode: host # 使用现有网络

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

@ -3,7 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<version>0.3.37</version>
<version>0.3.44</version>
<artifactId>data-report-server</artifactId>
<parent>

12
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/AgencyController.java

@ -33,6 +33,18 @@ public class AgencyController {
return new Result<TreeResultDTO>().ok(agencyService.tree(customerId));
}
/**
* @Description 智慧社区的tree
* @Param customerId
* @Param bizType
* @author zxc
* @date 2020/10/21 2:49 下午
*/
@PostMapping("treebytype")
public Result<TreeResultDTO> treeByType(@RequestHeader("CustomerId") String customerId,@RequestParam("bizType")String bizType){
return new Result<TreeResultDTO>().ok(agencyService.treeByType(customerId,bizType));
}
/**
* @Description 2组织区域查询
* @param compartmentFormDTO

4
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java

@ -40,6 +40,8 @@ public interface ScreenCustomerAgencyDao {
*/
TreeResultDTO selectRootAgencyId(@Param("customerId")String customerId);
TreeResultDTO selectRootAgencyIdByBizType(@Param("customerId")String customerId,@Param("bizType")String bizType);
/**
* @Description 查询下级机关的 名称和id
* @param subAgencyPids
@ -48,6 +50,8 @@ public interface ScreenCustomerAgencyDao {
*/
List<TreeResultDTO> selectSubAgencyList(@Param("subAgencyPids") String subAgencyPids);
List<TreeResultDTO> selectSubAgencyListByBizType(@Param("subAgencyPids") String subAgencyPids);
/**
* @Description 查询当前机关的区域信息
* @param agencyId

9
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/AgencyService.java

@ -20,6 +20,15 @@ public interface AgencyService {
*/
TreeResultDTO tree(String customerId);
/**
* @Description 智慧社区的tree
* @Param customerId
* @Param bizType
* @author zxc
* @date 2020/10/21 2:49 下午
*/
TreeResultDTO treeByType(String customerId,String bizType);
/**
* @Description 2组织区域查询
* @param compartmentFormDTO

71
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java

@ -66,6 +66,37 @@ public class AgencyServiceImpl implements AgencyService {
return rootAgency;
}
/**
* @Description 智慧社区的tree
* @Param customerId
* @Param bizType
* @author zxc
* @date 2020/10/21 2:49 下午
*/
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
public TreeResultDTO treeByType(String customerId, String bizType) {
TreeResultDTO rootAgency = null;
try {
rootAgency = screenCustomerAgencyDao.selectRootAgencyIdByBizType(customerId,bizType);
if (null == rootAgency) {
return new TreeResultDTO();
}
} catch (TooManyResultsException e) {
throw new RenException("根组织结构数据有误");
}
List<Double> centerMark = this.getCenterMark(rootAgency.getCenterMarkA());
rootAgency.setCenterMark(centerMark.size() == NumConstant.ZERO ? new ArrayList<>() : centerMark);
if (rootAgency.getLevel().equals(ScreenConstant.COMMUNITY)) {
List<TreeResultDTO> treeResultDTOS = screenCustomerGridDao.selectGridInfo(rootAgency.getValue());
rootAgency.setChildren(treeResultDTOS);
} else {
List<TreeResultDTO> departmentList = this.getDepartmentListByBiz(("".equals(rootAgency.getPids()) || rootAgency.getPids().equals(NumConstant.ZERO_STR)) ? rootAgency.getValue() : rootAgency.getPids().concat(",").concat(rootAgency.getValue()));
rootAgency.setChildren(departmentList);
}
return rootAgency;
}
/**
* @Description 处理centerMark
* @param centerMark
@ -105,7 +136,45 @@ public class AgencyServiceImpl implements AgencyService {
});
sub.setChildren(treeResultDTOS);
}else {
List<TreeResultDTO> subAgency = getDepartmentList(sub.getPids() + "," + sub.getValue());
List<TreeResultDTO> subAgency = new ArrayList<>();
if (sub.getPids().contains(ScreenConstant.COMMA)){
subAgency = getDepartmentList(sub.getPids() + ScreenConstant.COMMA + sub.getValue());
}else {
subAgency = getDepartmentList(sub.getPids() + ScreenConstant.COLON + sub.getValue());
}
sub.setChildren(subAgency);
}
});
}
return subAgencyList;
}
/**
* @Description 智慧社区的tree
* @Param subAgencyPids
* @author zxc
* @date 2020/10/21 2:49 下午
*/
public List<TreeResultDTO> getDepartmentListByBiz(String subAgencyPids) {
List<TreeResultDTO> subAgencyList = screenCustomerAgencyDao.selectSubAgencyListByBizType(subAgencyPids);
if (subAgencyList.size() > NumConstant.ZERO) {
subAgencyList.forEach(sub -> {
List<Double> centerMark = this.getCenterMark(sub.getCenterMarkA());
sub.setCenterMark(centerMark.size() == NumConstant.ZERO ? new ArrayList<>() : centerMark);
if (sub.getLevel().equals(ScreenConstant.COMMUNITY)){
List<TreeResultDTO> treeResultDTOS = screenCustomerGridDao.selectGridInfo(sub.getValue());
treeResultDTOS.forEach(tree -> {
List<Double> centerMarkTree = this.getCenterMark(tree.getCenterMarkA());
tree.setCenterMark(centerMarkTree.size() == NumConstant.ZERO ? new ArrayList<>() : centerMarkTree);
});
sub.setChildren(treeResultDTOS);
}else {
List<TreeResultDTO> subAgency = new ArrayList<>();
if (sub.getPids().contains(ScreenConstant.COMMA)){
subAgency = getDepartmentListByBiz(sub.getPids() + ScreenConstant.COMMA + sub.getValue());
}else {
subAgency = getDepartmentListByBiz(sub.getPids() + ScreenConstant.COLON + sub.getValue());
}
sub.setChildren(subAgency);
}
});

3
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/IndexServiceImpl.java

@ -218,8 +218,7 @@ public class IndexServiceImpl implements IndexService {
} else if (ScreenConstant.MONTH_ID.equals(formDTO.getType())) {
// 月(上一个月) 指数排行
if (StringUtils.isBlank(formDTO.getMonthId())) {
String monthId = com.epmet.commons.tools.utils.DateUtils.format(com.epmet.commons.tools.utils.DateUtils.addDateMonths(new Date(), -1), "yyyyMMdd");
formDTO.setMonthId(monthId);
formDTO.setMonthId(DateUtils.getBeforeNMonth(1));
}
subAgencyIndexRankResultDTOS = screenIndexDataMonthlyDao.selectSubAgencyOrGridIndexMonthlyRank(formDTO);
subAgencyIndexRankResultDTOS.forEach(rank -> {

6
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/fact/impl/FactIndexServiceImpl.java

@ -3,6 +3,7 @@ package com.epmet.datareport.service.fact.impl;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.constant.DataSourceConstant;
import com.epmet.datareport.constant.FactConstant;
import com.epmet.datareport.dao.evaluationindex.screen.ScreenCustomerAgencyDao;
@ -456,7 +457,10 @@ public class FactIndexServiceImpl implements FactIndexService {
@Override
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
public List<PeerComparisonResultDTO> peerComparison(PeerComparisonFormDTO formDTO) {
//1.根据组织或网格Id的上级组织Id查询同级组织或网格对应类型的得分排名(查询最近一个月数据)
//1.根据组织或网格Id的上级组织Id查询同级组织或网格对应类型的得分排名(按月查询)
if (null == formDTO.getMonthId() || "".equals(formDTO.getMonthId())) {
formDTO.setMonthId(DateUtils.getBeforeNMonth(1));
}
List<PeerComparisonResultDTO> resultList = screenIndexDataMonthlyDao.selectScoreList(formDTO);
return resultList;
}

37
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml

@ -114,4 +114,41 @@
AND agency_id = #{agencyId}
</select>
<select id="selectRootAgencyIdByBizType" resultType="com.epmet.evaluationindex.screen.dto.result.TreeResultDTO">
SELECT
ca.agency_name AS label,
cbo.ORG_ID AS value,
ca.pids AS pids,
IFNULL(ca.center_mark,'') AS centerMarkA,
ca.level AS level
FROM
screen_customer_agency ca
LEFT JOIN screen_customer_biz_org cbo ON cbo.ORG_ID = ca.AGENCY_ID
WHERE
ca.del_flag = 0
AND cbo.DEL_FLAG = 0
AND ca.pid = '0'
AND cbo.customer_id = #{customerId}
AND cbo.BIZ_TYPE = #{bizType}
</select>
<select id="selectSubAgencyListByBizType" resultType="com.epmet.evaluationindex.screen.dto.result.TreeResultDTO">
SELECT
cbo.ORG_ID AS value,
ca.agency_name AS label,
ca.pids AS pids,
IFNULL(ca.center_mark,'') AS centerMarkA,
ca.level AS level
FROM
screen_customer_biz_org cbo
LEFT JOIN screen_customer_agency ca ON ca.AGENCY_ID = cbo.ORG_ID
WHERE
ca.del_flag = '0'
AND cbo.DEL_FLAG = 0
AND cbo.biz_type = "community"
AND ca.pids = #{subAgencyPids}
ORDER BY
ca.created_time DESC
</select>
</mapper>

13
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml

@ -148,18 +148,7 @@
created_time desc
limit 1
)
AND MONTH_ID = (
select
month_id
from
screen_index_data_monthly
where
del_flag = '0'
and customer_id = #{customerId}
order by
month_id desc
limit 1
)
AND month_id = #{monthId}
ORDER BY
<if test="indexCode != null and indexCode != '' and indexCode == 'dangjiannengli'">
(party_dev_ablity * party_dev_weight) DESC

2
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenUserJoinDao.xml

@ -10,7 +10,7 @@
ROUND( AVG_JOIN, 1 ) AS averageJoin,
JOIN_TOTAL_UP_RATE AS monthIncr,
JOIN_TOTAL_UP_FLAG AS monthTrend,
AVG_ISSUE AS averageIssue,
ROUND(AVG_ISSUE, 1) AS averageIssue,
AVG_ISSUE_UP_RATE AS issueCompareLatestMonth,
AVG_ISSUE_UP_FLAG AS issueCompareLatestTrend,
AGVG_JOIN_UP_RATE AS joinCompareLatestMonth,

2
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/ProjectParticipatedAgencyResultDTO.java

@ -17,4 +17,6 @@ public class ProjectParticipatedAgencyResultDTO implements Serializable {
private String agencyId;
private int count;
private String projectId;
}

21
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/TransferRightRatioResultDTO.java

@ -0,0 +1,21 @@
package com.epmet.dto.extract.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/10/19 2:00 下午
*/
@Data
public class TransferRightRatioResultDTO implements Serializable {
private String projectId;
private String gridId;
private Boolean status;
private Integer notReturnProject;
}

26
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcollect/form/CustomerBizOrgFormDTO.java

@ -0,0 +1,26 @@
package com.epmet.dto.indexcollect.form;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable;
/**
* 客户业务组织关系 入参
*/
@Data
public class CustomerBizOrgFormDTO implements Serializable {
/**
* 当为true时后台将删除本月数据
*/
@NotEmpty(message = "客户Id不能为空")
private String customerId;
/**
* 业务类型智慧社区 community
*/
@NotEmpty(message = "业务类型不能为空")
private String bizType;
}

5
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/form/CustomerIdAndDateIdFormDTO.java

@ -19,6 +19,9 @@ public class CustomerIdAndDateIdFormDTO implements Serializable {
private String customerId;
@NotBlank(message = "日期Id不能为空",groups = CustomerIdAndDateId.class)
private String dateId;
private String startDate;
private String endDate;
}

3
epmet-module/data-statistical/data-statistical-server/Dockerfile

@ -8,4 +8,5 @@ COPY ./target/*.jar ./data-stats.jar
EXPOSE 8108
ENTRYPOINT ["sh", "-c", "$RUN_INSTRUCT"]
#ENTRYPOINT ["sh", "-c", "$RUN_INSTRUCT"]
ENTRYPOINT ["sh","-c","exec $RUN_INSTRUCT"]

2
epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-prod.yml

@ -2,7 +2,7 @@ version: "3.7"
services:
data-statistical-server:
container_name: data-statistical-server-prod
image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/data-statistical-server:0.3.49
image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/data-statistical-server:0.3.62
ports:
- "8108:8108"
network_mode: host # 使用现有网络

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

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<version>0.3.49</version>
<version>0.3.62</version>
<parent>
<artifactId>data-statistical</artifactId>
<groupId>com.epmet</groupId>

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

@ -33,10 +33,7 @@ import com.epmet.entity.stats.DimCustomerEntity;
import com.epmet.entity.stats.DimDateEntity;
import com.epmet.entity.stats.DimMonthEntity;
import com.epmet.service.StatsDemoService;
import com.epmet.service.evaluationindex.extract.dataToIndex.CalCpcIndexService;
import com.epmet.service.evaluationindex.extract.dataToIndex.CalGridIndexService;
import com.epmet.service.evaluationindex.extract.dataToIndex.IndexCollCommunityService;
import com.epmet.service.evaluationindex.extract.dataToIndex.IndexCollStreetService;
import com.epmet.service.evaluationindex.extract.dataToIndex.*;
import com.epmet.service.evaluationindex.extract.todata.FactOriginProjectLogDailyService;
import com.epmet.service.evaluationindex.extract.todata.FactOriginTopicMainDailyService;
import com.epmet.service.evaluationindex.extract.toscreen.*;
@ -99,6 +96,8 @@ public class DemoController {
@Autowired
private IndexCollStreetService indexCollStreetService;
@Autowired
private IndexCollDistrictDepartmentService indexCollDistrictDepartmentService;
@Autowired
private GovernRankDataExtractService governRankDataExtractService;
@Autowired
private OrgRankExtractService orgRankExtractService;
@ -629,6 +628,12 @@ public class DemoController {
return new Result();
}
@PostMapping("indexCollDept")
public Result indexCollDept(@RequestBody CustomerIdAndDateIdFormDTO formDTO){
indexCollDistrictDepartmentService.saveDepartmentAbility(formDTO.getCustomerId(), formDTO.getDateId());
return new Result();
}
@Autowired
private PartyBaseInfoService partyBaseInfoService;

1
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java

@ -263,7 +263,6 @@ public class DimController {
*/
@PostMapping("statsparty")
public Result getPartyInfo(@RequestBody CustomerIdAndDateIdFormDTO customerIdAndDateIdFormDTO) {
ValidatorUtils.validateEntity(customerIdAndDateIdFormDTO, CustomerIdAndDateIdFormDTO.CustomerIdAndDateId.class);
return new Result().ok(partyMemberService.statsPartyMember(customerIdAndDateIdFormDTO));
}

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

@ -60,6 +60,7 @@ public class IndexCalculateController {
@PreDestroy
public void saveCalStatus() {
log.info("data-statical-server服务被关闭,执行保存计算状态的动作");
// 实例销毁之前,将正在本实例中执行计算的客户列表的计算状态修改为pendding,等待其他实例重新计算
futureMap.forEach((customerId, future) -> {
CalculateFlagModel flag = (CalculateFlagModel) redisUtils.get(RedisKeys.getCustomerStatsCalFlag(customerId));
@ -165,6 +166,7 @@ public class IndexCalculateController {
CalculateFlagModel flag = new CalculateFlagModel();
flag.setStatus(CalculateStatus.CALCULATING);
flag.setForm(formDTO);
flag.setStartTime(DateUtils.format(new Date(), DateUtils.DATE_TIME_PATTERN));
redisUtils.set(RedisKeys.getCustomerStatsCalFlag(formDTO.getCustomerId()), flag);
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexDictController.java

@ -44,7 +44,7 @@ public class IndexDictController {
* @return
*/
@PostMapping("initFromExcel")
public Result<String> testTx(@RequestPart("file") MultipartFile file,@RequestParam("customerId") String customerId) {
public Result<String> testTx(@RequestPart("file") MultipartFile file, @RequestParam(value = "customerId", required = false) String customerId) {
ExcelReader excelReader = null;
try {
InputStream inputStream = null;

9
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ShiBeiScreenCollController.java

@ -1,6 +1,7 @@
package com.epmet.controller;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO;
import com.epmet.dto.screencoll.form.*;
import com.epmet.service.evaluationindex.screen.ShiBeiScreenCollService;
import org.springframework.beans.factory.annotation.Autowired;
@ -261,4 +262,12 @@ public class ShiBeiScreenCollController {
shiBeiScreenCollService.insertPublicPartiTotalData(formDTO, customerId);
return new Result();
}
/**
* 初始化客户业务组织类型
**/
@PostMapping("initbizorg")
public Result initBizOrg(@RequestBody CustomerBizOrgFormDTO formDTO) {
return new Result().ok(shiBeiScreenCollService.initBizOrg(formDTO));
}
}

72
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginProjectLogDailyDao.java

@ -23,6 +23,7 @@ import com.epmet.entity.evaluationindex.extract.FactOriginProjectLogDailyEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
@ -54,6 +55,8 @@ public interface FactOriginProjectLogDailyDao extends BaseDao<FactOriginProjectL
*/
List<NotReturnProjectResultDTO> selectNotReturnProject(@Param("customerId") String customerId,@Param("monthId") String monthId,@Param("actionCode") String actionCode,@Param("orgType") String orgType);
List<TransferRightRatioResultDTO> selectNotReturn(@Param("customerId")String customerId,@Param("monthId")String monthId);
/**
* @Description 查询项目评价信息
* @param customerId
@ -114,6 +117,27 @@ public interface FactOriginProjectLogDailyDao extends BaseDao<FactOriginProjectL
* @date 2020.09.20 23:46
**/
List<ProjectParticipatedAgencyResultDTO> selectProjectParticipatedAgency(@Param("agencies") List<String> agencies, @Param("customerId") String customerId,@Param("dimId") String dimId);
/***
* @Description 评价周期内被吹哨项目数
* @param agencies
* @param customerId
* @param dimId
* @return java.util.List<com.epmet.dto.extract.result.ProjectParticipatedAgencyResultDTO>
* @author wangc
* @date 2020.10.15 11:20
*/
List<ProjectParticipatedAgencyResultDTO> selectAgencyWhistledCount(@Param("agencies") List<String> agencies, @Param("customerId") String customerId,@Param("dimId") String dimId);
/***
* @Description 评价周期内被吹哨且被办结(无论是哪一级办结)的项目数
* @param agencies
* @param customerId
* @param dimId
* @return java.util.List<com.epmet.dto.extract.result.ProjectParticipatedAgencyResultDTO>
* @author wangc
* @date 2020.10.16 10:43
*/
List<ProjectParticipatedAgencyResultDTO> selectWhistledAgencyClosedProjectCount(@Param("agencies") List<String> agencies, @Param("customerId") String customerId,@Param("dimId") String dimId);
/***
* @Description 查询机关办结次数
* @param agencies
@ -122,7 +146,24 @@ public interface FactOriginProjectLogDailyDao extends BaseDao<FactOriginProjectL
* @date 2020.10.14 10:27
*/
List<ProjectParticipatedAgencyResultDTO> selectAgencyHandledProjectCount(@Param("agencies") List<String> agencies,@Param("customerId") String customerId,@Param("dimId") String dimId);
/**
* @Description 查询评价周期内各级别机关办结的项目Id
* @param customerId
* @param dimId
* @return java.util.List<com.epmet.dto.extract.result.ProjectParticipatedAgencyResultDTO>
* @author wangc
* @date 2020.10.15 17:29
*/
List<ProjectParticipatedAgencyResultDTO> selectProjectIdHandledByAgency(@Param("customerId") String customerId,@Param("dimId") String dimId);
/**
* @Description 计算每个办结项目的总耗时
* @param projectIds
* @return java.util.List<com.epmet.dto.extract.result.ProjectParticipatedAgencyResultDTO>
* @author wangc
* @date 2020.10.15 17:32
*/
List<ProjectParticipatedAgencyResultDTO> selectProjectCostTime(@Param("projectIds") List<String> projectIds);
/**
* 网格项目响应度
* @author zhaoqifeng
@ -165,4 +206,35 @@ public interface FactOriginProjectLogDailyDao extends BaseDao<FactOriginProjectL
*/
List<OrgStatisticsResultDTO> selectOrgSatisfaction(@Param("customerId") String customerId, @Param("monthId") String monthId,
@Param("level")String level);
/**
* 获取部门办结项目数
* @author zhaoqifeng
* @date 2020/10/16 17:09
* @param customerId
* @param monthId
* @return java.util.List<com.epmet.dto.extract.result.OrgStatisticsResultDTO>
*/
List<OrgStatisticsResultDTO> selectDeptClosedProject(@Param("customerId") String customerId, @Param("monthId") String monthId);
/**
* 部门办结项目满意度
* @author zhaoqifeng
* @date 2020/9/20 16:44
* @param customerId
* @param monthId
* @return java.util.List<com.epmet.dto.extract.result.OrgStatisticsResultDTO>
*/
List<OrgStatisticsResultDTO> selectDeptSatisfaction(@Param("customerId") String customerId, @Param("monthId") String monthId);
/**
* 网格结案率统计
* @author zhaoqifeng
* @date 2020/9/20 16:44
* @param customerId
* @param monthId
* @return java.util.List<com.epmet.dto.extract.result.OrgStatisticsResultDTO>
*/
List<OrgStatisticsResultDTO> selectGridClosed(@Param("customerId") String customerId, @Param("monthId") String monthId);
}

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

@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.extract.FactOriginProjectMainDailyDTO;
import com.epmet.dto.extract.result.GridProjectClosedTotalResultDTO;
import com.epmet.dto.extract.result.OrgStatisticsResultDTO;
import com.epmet.dto.extract.result.TransferRightRatioResultDTO;
import com.epmet.dto.indexcollect.result.CpcIndexCommonDTO;
import com.epmet.dto.screen.form.ProjectSourceMapFormDTO;
import com.epmet.entity.evaluationindex.extract.FactOriginProjectMainDailyEntity;
@ -77,6 +78,8 @@ public interface FactOriginProjectMainDailyDao extends BaseDao<FactOriginProject
*/
List<GridProjectClosedTotalResultDTO> selectGridClosedProject(@Param("customerId") String customerId,@Param("monthId") String monthId,@Param("status") String status);
List<TransferRightRatioResultDTO> selectTransferRightRatio(@Param("customerId")String customerId, @Param("monthId")String monthId);
/**
* 根据日期删除数据
* @author zhaoqifeng

20
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginProjectOrgPeriodDailyDao.java

@ -67,8 +67,14 @@ public interface FactOriginProjectOrgPeriodDailyDao extends BaseDao<FactOriginPr
List<OrgStatisticsResultDTO> selectResponsiveness(@Param("customerId") String customerId, @Param("monthId") String monthId,
@Param("level")String level,
@Param("orgType")String orgType);
void deleteByProjectId(@Param("list") List<String> list);
/***
* @Description 在插入之前先删除所有与这个项目相关的历时信息
* @param list
* @return void
* @author wangc
* @date 2020.10.19 16:26
*/
void deleteByProjectIds(@Param("list") List<String> list);
/**
* @Description 批量插入
@ -96,4 +102,14 @@ public interface FactOriginProjectOrgPeriodDailyDao extends BaseDao<FactOriginPr
* @date 2020.09.21 02:13
**/
List<OrgResponseTimeResultDTO> selectAgencyResponseCoefficient(@Param("customerId") String customerId,@Param("dimId") String dimId, @Param("dateType") String dateType);
/**
* 部门处理效率统计
* @author zhaoqifeng
* @date 2020/10/19 9:31
* @param customerId
* @param monthId
* @return java.util.List<com.epmet.dto.extract.result.OrgStatisticsResultDTO>
*/
List<OrgStatisticsResultDTO> selectDeptHandle(@Param("customerId") String customerId, @Param("monthId") String monthId);
}

7
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java

@ -23,6 +23,7 @@ import com.epmet.dto.extract.form.ScreenPartyBranchDataFormDTO;
import com.epmet.dto.extract.form.ScreenPartyLinkMassesDataFormDTO;
import com.epmet.dto.extract.result.CustomerAgencyInfoResultDTO;
import com.epmet.dto.extract.result.OrgNameResultDTO;
import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO;
import com.epmet.dto.screen.result.TreeResultDTO;
import com.epmet.dto.screencoll.form.CustomerAgencyFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity;
@ -165,13 +166,15 @@ public interface ScreenCustomerAgencyDao extends BaseDao<ScreenCustomerAgencyEnt
*/
List<ScreenPartyLinkMassesDataFormDTO> selectAllAgencyIdToPartyLinkMessage(@Param("customerId") String customerId,@Param("monthId") String monthId);
List<ScreenPartyBranchDataFormDTO> selectAllAgencyIdToOrganize(@Param("customerId") String customerId,@Param("monthId") String monthId);
List<ScreenPartyBranchDataFormDTO> selectAllAgencyIdToOrganize(@Param("customerId") String customerId, @Param("monthId") String monthId);
/**
* @Description 查询org名称机关
* @param agencyIds
* @Description 查询org名称机关
* @author zxc
* @date 2020/9/24 1:27 下午
*/
List<OrgNameResultDTO> selectOrgNameAgency(@Param("agencyIds") List<String> agencyIds);
Boolean initBizOrg(CustomerBizOrgFormDTO formDTO);
}

40
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerBizOrgDao.java

@ -0,0 +1,40 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dao.evaluationindex.screen;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerBizOrgEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 组织机构信息
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-18
*/
@Mapper
public interface ScreenCustomerBizOrgDao extends BaseDao<ScreenCustomerBizOrgEntity> {
int deleteByBizType(CustomerBizOrgFormDTO formDTO);
int batchInsert(@Param("list") List<ScreenCustomerBizOrgEntity> list);
}

15
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerAgencyEntity.java

@ -89,15 +89,20 @@ public class ScreenCustomerAgencyEntity extends BaseEpmetEntity {
private String level;
/**
* 行政地区编码
*/
* 行政地区编码
*/
private String areaCode;
private String sourceType;
/**
* 数据更新至: yyyy|yyyyMM|yyyyMMdd(08-21新增)
*/
/**
* 数据更新至: yyyy|yyyyMM|yyyyMMdd(08-21新增)
*/
private String dataEndTime;
/**
* desc: 是否显示 1显示 0不显示
*/
private String isDisplay;
}

52
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerBizOrgEntity.java

@ -0,0 +1,52 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.entity.evaluationindex.screen;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 组织机构信息
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-21
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("screen_customer_biz_org")
public class ScreenCustomerBizOrgEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户id
*/
private String customerId;
/**
* 组织id
*/
private String orgId;
/**
* 业务类型 community:智慧社区
*/
private String bizType;
}

7
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/CalculateFlagModel.java

@ -17,4 +17,11 @@ public class CalculateFlagModel {
*/
private String status;
/**
* 开始时间
* CalculateStatus.java
*/
private String startTime;
}

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

@ -29,10 +29,7 @@ import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
@ -275,18 +272,32 @@ public class CalGridIndexServiceImpl implements CalGridIndexService {
});
}
//网格办结项目数
List<GridProjectClosedTotalResultDTO> gridProjectClosedTotalList = projectMainService.selectGridClosedProject(customerId, monthId, ExtractConstant.CLOSE);
List<GridProjectClosedTotalResultDTO> gridProjectClosedTotalList = projectMainService.selectGridClosedProject(customerId, monthId, ExtractConstant.CLOSED);
//网格吹哨部门准确率 【没被退回的项目数/项目总数 】
List<NotReturnProjectResultDTO> notReturnProjectList = projectLogService.selectNotReturnProject(customerId, monthId, ExtractConstant.RETURN_ACTION_CODE, ExtractConstant.GRID_ORG_TYPE);
if (!CollectionUtils.isEmpty(gridIssueShiftProjectRatio) && !CollectionUtils.isEmpty(notReturnProjectList)){
notReturnProjectList.forEach(not -> {
gridIssueShiftProjectRatio.forEach(total -> {
if (not.getGridId().equals(total.getGridId())){
not.setTransferRightRatio(getRound(new BigDecimal(not.getNotReturnProject()/total.getProjectTotal()).multiply(NumConstant.ONE_HUNDRED_DECIMAL)));
}
List<TransferRightRatioResultDTO> transferRightRatioResultDTOS = projectMainService.selectTransferRightRatio(customerId, monthId);
List<TransferRightRatioResultDTO> transferRightRatioResultDTOS1 = projectLogService.selectNotReturn(customerId, monthId);
if (!CollectionUtils.isEmpty(transferRightRatioResultDTOS1)){
transferRightRatioResultDTOS.forEach(r -> {
transferRightRatioResultDTOS1.forEach(t -> {
r.setStatus(r.getProjectId().equals(t.getProjectId()) ? true : false);
});
});
}else {
transferRightRatioResultDTOS.forEach(r -> {
r.setStatus(false);
});
}
Map<String, List<TransferRightRatioResultDTO>> groupByGridProject = transferRightRatioResultDTOS.stream().collect(Collectors.groupingBy(TransferRightRatioResultDTO::getGridId));
Map<String,BigDecimal> notReturnMap = new HashMap<>(16);
groupByGridProject.forEach((grid,project) -> {
AtomicReference<Integer> count = new AtomicReference<>(NumConstant.ZERO);
project.forEach(p -> {
if (p.getStatus().equals(false)){
count.getAndSet(count.get() + NumConstant.ONE);
}
});
notReturnMap.put(grid,getRound(new BigDecimal(count.get()/project.size()).multiply(NumConstant.ONE_HUNDRED_DECIMAL)));
});
//网格内解决的项目的满意度
//项目评价(分值定义下非常满意100,满意80,不满意(一般)60)的人数的平均分(每个项目的参加人数的分数和/评论人数=一个项目的平均分)+其他项目得分/已关闭项目总数
List<ProjectEvaluateResultDTO> projectEvaluateList = projectLogService.selectProjectEvaluate(customerId, monthId);
@ -355,10 +366,10 @@ public class CalGridIndexServiceImpl implements CalGridIndexService {
});
}
// 4. 网格吹哨部门准确率
if (!CollectionUtils.isEmpty(notReturnProjectList)) {
notReturnProjectList.forEach(not -> {
if (r.getGridId().equals(not.getGridId())) {
r.setTransferRightRatio(not.getTransferRightRatio());
if(notReturnMap != null){
notReturnMap.forEach((grid,transferRightRatio) -> {
if (r.getGridId().equals(grid)){
r.setTransferRightRatio(transferRightRatio);
}
});
}

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

@ -134,24 +134,19 @@ public class IndexCollCommunityServiceImpl implements IndexCollCommunityService
}));
}
//办结数
List<String> agencies = agencyList.stream().map(DimAgencyDTO :: getId).distinct().collect(Collectors.toList());
//办结数
Map<String, Integer> agencyHandleCount = factOriginProjectLogDailyService.getProjectHandledAgency(agencies,customerId,dimId.getMonthId(),"month");
Map<String,Integer> agencyParticipatedCount = factOriginProjectLogDailyService.getCountOfDealingAgency(agencies,customerId,dimId.getMonthId(),"month");
Map<String,BigDecimal> efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(agencies,customerId,dimId.getMonthId(),"month");
//办结率
Map<String, BigDecimal> handlingRatioMap = factOriginProjectLogDailyService.getHandlingRatio(agencies,customerId,dimId.getMonthId(),"month");
//处理效率
Map<String,BigDecimal> efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(customerId,dimId.getMonthId(),"month");
list.forEach(entity ->{
entity.setClosedProjectCount(agencyHandleCount.get(entity.getAgencyId()) == null? NumConstant.ZERO : agencyHandleCount.get(entity.getAgencyId()));
BigDecimal element = new BigDecimal(entity.getClosedProjectCount());
//分母,即机关参与过的项目数(去重)
Integer denominator = agencyParticipatedCount.get(entity.getAgencyId());
if (null != denominator && denominator != NumConstant.ZERO) {
//办结率
entity.setClosedProjectRatio(
element.divide(new BigDecimal(denominator), NumConstant.SIX, RoundingMode.HALF_UP)
);
}else{
entity.setClosedProjectRatio(BigDecimal.ZERO);
}
//办结数
entity.setClosedProjectCount(Optional.ofNullable(agencyHandleCount.get(entity.getAgencyId())).orElse(NumConstant.ZERO));
//办结率
entity.setClosedProjectRatio(Optional.ofNullable(handlingRatioMap.get(entity.getAgencyId())).orElse(BigDecimal.ZERO));
//办结效率
entity.setHandleProjectRatio(Optional.ofNullable(efficiencyMap.get(entity.getAgencyId())).orElse(BigDecimal.ZERO));

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

@ -9,13 +9,11 @@ import com.epmet.dto.stats.DimDepartmentDTO;
import com.epmet.entity.evaluationindex.indexcoll.FactIndexGovrnAblityDeptMonthlyEntity;
import com.epmet.service.evaluationindex.extract.dataToIndex.IndexCollDistrictDepartmentService;
import com.epmet.service.evaluationindex.extract.todata.FactOriginProjectLogDailyService;
import com.epmet.service.evaluationindex.extract.todata.FactOriginProjectMainDailyService;
import com.epmet.service.evaluationindex.indexcoll.FactIndexGovrnAblityDeptMonthlyService;
import com.epmet.service.evaluationindex.indexcoll.FactIndexPartyAblityOrgMonthlyService;
import com.epmet.service.stats.DimDepartmentService;
import com.epmet.service.stats.FactArticlePublishedDepartmentDailyService;
import com.epmet.util.DimIdGenerator;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -41,12 +39,6 @@ public class IndexCollDistrictDepartmentServiceImpl implements IndexCollDistrict
private FactOriginProjectLogDailyService factOriginProjectLogDailyService;
@Autowired
private FactOriginProjectOrgPeriodDailyDao factOriginProjectOrgPeriodDailyDao;
@Autowired
private FactOriginProjectMainDailyService factOriginProjectMainDailyService;
@Autowired
private FactArticlePublishedDepartmentDailyService factArticlePublishedDepartmentDailyService;
@Autowired
private FactIndexPartyAblityOrgMonthlyService factIndexPartyAblityOrgMonthlyService;
@Override
public void saveDepartmentAbility(String customerId, String dateId) {
@ -97,10 +89,46 @@ public class IndexCollDistrictDepartmentServiceImpl implements IndexCollDistrict
}));
}
//TODO 区直部门办结项目满意度 暂时无法统计
//办结项目数 办结率
List<OrgStatisticsResultDTO > closedList = factOriginProjectLogDailyService.getDeptClosedProject(customerId, dimId.getMonthId());
if (CollectionUtils.isNotEmpty(closedList)) {
list.forEach(entity -> closedList.stream().filter(dto -> dto.getOrgId().equals(entity.getDeptId())).forEach(item -> {
entity.setClosedProjectCount(item.getCount());
if (item.getSum() != NumConstant.ZERO) {
BigDecimal count = new BigDecimal(item.getCount());
BigDecimal sum = new BigDecimal(item.getSum());
entity.setClosedProjectRatio(count.divide(sum, NumConstant.SIX, RoundingMode.HALF_UP));
}
}));
}
//部门办结项目满意度
List<OrgStatisticsResultDTO > satisfactions = factOriginProjectLogDailyService.getDeptSatisfaction(customerId, dimId.getMonthId());
if (CollectionUtils.isNotEmpty(satisfactions)) {
list.forEach(entity -> satisfactions.stream().filter(dto -> dto.getOrgId().equals(entity.getDeptId())).forEach(item -> {
if (item.getCount() != NumConstant.ZERO) {
BigDecimal count = new BigDecimal(item.getCount());
entity.setClosedProjectRatio(item.getRatio().divide(count, NumConstant.SIX, RoundingMode.HALF_UP));
}
}));
}
//部门办结项目的处理效率
List<OrgStatisticsResultDTO > handle = factOriginProjectOrgPeriodDailyDao.selectDeptHandle(customerId, dimId.getMonthId());
if (CollectionUtils.isNotEmpty(handle)) {
list.forEach(entity -> handle.stream().filter(dto -> dto.getOrgId().equals(entity.getDeptId())).forEach(item -> {
if (item.getCount() != NumConstant.ZERO) {
BigDecimal count = new BigDecimal(item.getCount());
BigDecimal sum = new BigDecimal(item.getSum());
BigDecimal one = new BigDecimal(NumConstant.ONE);
entity.setClosedProjectRatio(one.divide(sum.divide(count), NumConstant.SIX, RoundingMode.HALF_UP));
}
}));
}
factIndexGovrnAblityDeptMonthlyService.deleteByCustomer(customerId, dimId.getMonthId());
factIndexGovrnAblityDeptMonthlyService.insertBatch(list);
factIndexGovrnAblityDeptMonthlyService.saveList(list);
}
}
}

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

@ -127,24 +127,19 @@ public class IndexCollDistrictServiceImpl implements IndexCollDistrictService {
}
}));
}
//办结数
List<String> agencies = agencyList.stream().map(DimAgencyDTO :: getId).distinct().collect(Collectors.toList());
//办结数
Map<String, Integer> agencyHandleCount = factOriginProjectLogDailyService.getProjectHandledAgency(agencies,customerId,dimId.getMonthId(),"month");
Map<String,Integer> agencyParticipatedCount = factOriginProjectLogDailyService.getCountOfDealingAgency(agencies,customerId,dimId.getMonthId(),"month");
Map<String,BigDecimal> efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(agencies,customerId,dimId.getMonthId(),"month");
//办结率
Map<String, BigDecimal> handlingRatioMap = factOriginProjectLogDailyService.getHandlingRatio(agencies,customerId,dimId.getMonthId(),"month");
//处理效率
Map<String,BigDecimal> efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(customerId,dimId.getMonthId(),"month");
list.forEach(entity ->{
//办结数
entity.setClosedProjectCount(agencyHandleCount.get(entity.getAgencyId()) == null? NumConstant.ZERO : agencyHandleCount.get(entity.getAgencyId()));
BigDecimal element = new BigDecimal(entity.getClosedProjectCount());
//分母,即机关参与过的项目数(去重)
Integer denominator = agencyParticipatedCount.get(entity.getAgencyId());
if (null != denominator && denominator != NumConstant.ZERO) {
//办结率
entity.setClosedProjectRatio(
element.divide(new BigDecimal(denominator), NumConstant.SIX, RoundingMode.HALF_UP)
);
}else{
entity.setClosedProjectRatio(BigDecimal.ZERO);
}
//办结率
entity.setClosedProjectRatio(Optional.ofNullable(handlingRatioMap.get(entity.getAgencyId())).orElse(BigDecimal.ZERO));
//办结效率
entity.setHandleProjectRatio(Optional.ofNullable(efficiencyMap.get(entity.getAgencyId())).orElse(BigDecimal.ZERO));
});

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

@ -125,24 +125,19 @@ public class IndexCollStreetServiceImpl implements IndexCollStreetService {
}
}));
}
//办结数
List<String> agencies = agencyList.stream().map(DimAgencyDTO :: getId).distinct().collect(Collectors.toList());
//办结数
Map<String, Integer> agencyHandleCount = factOriginProjectLogDailyService.getProjectHandledAgency(agencies,customerId,dimId.getMonthId(),"month");
Map<String,Integer> agencyParticipatedCount = factOriginProjectLogDailyService.getCountOfDealingAgency(agencies,customerId,dimId.getMonthId(),"month");
Map<String,BigDecimal> efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(agencies,customerId,dimId.getMonthId(),"month");
//办结率
Map<String, BigDecimal> handlingRatioMap = factOriginProjectLogDailyService.getHandlingRatio(agencies,customerId,dimId.getMonthId(),"month");
//处理效率
Map<String,BigDecimal> efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(customerId,dimId.getMonthId(),"month");
list.forEach(entity ->{
//办结数
entity.setClosedProjectCount(agencyHandleCount.get(entity.getAgencyId()) == null? NumConstant.ZERO : agencyHandleCount.get(entity.getAgencyId()));
BigDecimal element = new BigDecimal(entity.getClosedProjectCount());
//分母,即机关参与过的项目数(去重)
Integer denominator = agencyParticipatedCount.get(entity.getAgencyId());
if (null != denominator && denominator != NumConstant.ZERO) {
//办结率
entity.setClosedProjectRatio(
element.divide(new BigDecimal(denominator), NumConstant.SIX, RoundingMode.HALF_UP)
);
}else{
entity.setClosedProjectRatio(BigDecimal.ZERO);
}
//办结率
entity.setClosedProjectRatio(Optional.ofNullable(handlingRatioMap.get(entity.getAgencyId())).orElse(BigDecimal.ZERO));
//办结效率
entity.setHandleProjectRatio(Optional.ofNullable(efficiencyMap.get(entity.getAgencyId())).orElse(BigDecimal.ZERO));
});

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

@ -20,10 +20,7 @@ package com.epmet.service.evaluationindex.extract.todata;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.extract.FactOriginProjectLogDailyDTO;
import com.epmet.dto.extract.result.OrgStatisticsResultDTO;
import com.epmet.dto.extract.result.AutoNoMyResultDTO;
import com.epmet.dto.extract.result.NotReturnProjectResultDTO;
import com.epmet.dto.extract.result.ProjectEvaluateResultDTO;
import com.epmet.dto.extract.result.*;
import com.epmet.entity.evaluationindex.extract.FactOriginProjectLogDailyEntity;
import java.math.BigDecimal;
@ -118,6 +115,8 @@ public interface FactOriginProjectLogDailyService extends BaseService<FactOrigin
*/
List<NotReturnProjectResultDTO> selectNotReturnProject(String customerId,String monthId,String actionCode,String orgType);
List<TransferRightRatioResultDTO> selectNotReturn(String customerId,String monthId);
/**
* @Description 查询项目评价信息
* @param customerId
@ -178,7 +177,7 @@ public interface FactOriginProjectLogDailyService extends BaseService<FactOrigin
Map<String,Integer> getProjectHandledAgency(List<String> agencies, String customerId, String dimId,String dateType);
/**
* @Description 查询机关单位经手的项目数去重
* @Description 办结率
* @param agencies
* @param dimId
* @param dateType - 日期维度类型 month date week quarter year
@ -186,16 +185,16 @@ public interface FactOriginProjectLogDailyService extends BaseService<FactOrigin
* @author wangc
* @date 2020.09.23 10:06
**/
Map<String,Integer> getCountOfDealingAgency(List<String> agencies, String customerId,String dimId,String dateType);
Map<String,BigDecimal> getHandlingRatio(List<String> agencies, String customerId,String dimId,String dateType);
/**
* @Description 计算机关办结项目效率
* @param agencies
* @param customerId
* @return
* @author wangc
* @date 2020.09.21 02:16
**/
Map<String, BigDecimal> getAgencyWorkPieceRatio(List<String> agencies, String customerId,String dimId,String dateType);
Map<String, BigDecimal> getAgencyWorkPieceRatio( String customerId,String dimId,String dateType);
/**
* 网格项目响应度
@ -239,4 +238,33 @@ public interface FactOriginProjectLogDailyService extends BaseService<FactOrigin
*/
List<OrgStatisticsResultDTO> getOrgSatisfaction(String customerId, String monthId, String level);
/**
* 获取部门办结项目数
* @author zhaoqifeng
* @date 2020/10/16 17:08
* @param customerId
* @param monthId
* @return java.util.List<com.epmet.dto.extract.result.OrgStatisticsResultDTO>
*/
List<OrgStatisticsResultDTO> getDeptClosedProject(String customerId, String monthId);
/**
* 部门办结项目满意度
* @author zhaoqifeng
* @date 2020/10/16 17:50
* @param customerId
* @param monthId
* @return java.util.List<com.epmet.dto.extract.result.OrgStatisticsResultDTO>
*/
List<OrgStatisticsResultDTO> getDeptSatisfaction(String customerId, String monthId);
/**
* 网格结案率统计
* @author zhaoqifeng
* @date 2020/10/19 11:58
* @param customerId
* @param monthId
* @return java.util.List<com.epmet.dto.extract.result.OrgStatisticsResultDTO>
*/
List<OrgStatisticsResultDTO> getGridClosed(String customerId, String monthId);
}

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

@ -22,6 +22,7 @@ import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.extract.FactOriginProjectMainDailyDTO;
import com.epmet.dto.extract.result.GridProjectClosedTotalResultDTO;
import com.epmet.dto.extract.result.OrgStatisticsResultDTO;
import com.epmet.dto.extract.result.TransferRightRatioResultDTO;
import com.epmet.dto.indexcollect.result.CpcIndexCommonDTO;
import com.epmet.dto.screen.form.ProjectSourceMapFormDTO;
import com.epmet.entity.evaluationindex.extract.FactOriginProjectMainDailyEntity;
@ -126,6 +127,8 @@ public interface FactOriginProjectMainDailyService extends BaseService<FactOrigi
*/
List<GridProjectClosedTotalResultDTO> selectGridClosedProject(String customerId,String monthId,String status);
List<TransferRightRatioResultDTO> selectTransferRightRatio(String customerId,String monthId);
/**
* 项目超期数
* @author zhaoqifeng

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

@ -23,4 +23,14 @@ public interface FactOriginProjectOrgPeriodDailyService extends BaseService<Fact
* @return java.util.List<com.epmet.dto.extract.result.OrgStatisticsResultDTO>
*/
List<OrgStatisticsResultDTO> getResponsiveness(String customerId, String monthId, String level, String orgType);
/**
* 部门处理效率统计
* @author zhaoqifeng
* @date 2020/10/19 9:38
* @param customerId
* @param monthId
* @return java.util.List<com.epmet.dto.extract.result.OrgStatisticsResultDTO>
*/
List<OrgStatisticsResultDTO> getDeptHandle(String customerId, String monthId);
}

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

@ -1,21 +0,0 @@
package com.epmet.service.evaluationindex.extract.todata;
import com.epmet.dto.extract.form.ExtractOriginFormDTO;
/**
* @Desc 业务数据抽取 - 项目节点历时
* @Author wangc
* @DateTime 2020/9/14 5:07 下午
*/
public interface ProjectPeriodExtractService {
/**
* @param param
* @return
* @Description 抽取项目节点历时逻辑
* @author wangc
* @date 2020.09.17 14:05
**/
void extractProjectPeriodData(ExtractOriginFormDTO param);
}

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

@ -2,9 +2,12 @@ package com.epmet.service.evaluationindex.extract.todata.impl;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.constant.NumConstant;
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.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;
@ -27,7 +30,7 @@ import java.util.concurrent.*;
public class FactOriginExtractServiceImpl implements FactOriginExtractService {
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
.setNameFormat("factOriginExtract-pool-%d").build();
ExecutorService threadPool = new ThreadPoolExecutor(1, 1,
ExecutorService threadPool = new ThreadPoolExecutor(3, 6,
10L, TimeUnit.MINUTES,
new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy());
@ -41,12 +44,14 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService {
private DimCustomerService dimCustomerService;
@Autowired
private GroupExtractService groupExtractService;
@Autowired
private DimCustomerPartymemberService dimCustomerPartymemberService;
@Override
public void extractAll(ExtractOriginFormDTO extractOriginFormDTO) {
String customerId = extractOriginFormDTO.getCustomerId();
if (StringUtils.isBlank(extractOriginFormDTO.getStartDate())||StringUtils.isBlank(extractOriginFormDTO.getEndDate())) {
if (StringUtils.isBlank(extractOriginFormDTO.getDateId()) && (StringUtils.isBlank(extractOriginFormDTO.getStartDate()) && StringUtils.isBlank(extractOriginFormDTO.getEndDate()))) {
//如果没有设置开始日期、结束日期,默认查询昨天
extractOriginFormDTO.setDateId(DimIdGenerator.getDateDimId(DateUtils.addDateDays(new Date(), -1)));
}
@ -70,120 +75,149 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService {
param.setDateId(extractOriginFormDTO.getDateId());
param.setStartDate(extractOriginFormDTO.getStartDate());
param.setEndDate(extractOriginFormDTO.getEndDate());
log.debug("extractAll param:{}", JSON.toJSONString(param));
log.info("extractAll param:{}", JSON.toJSONString(param));
submitJob(param);
});
}
private void submitJob(ExtractOriginFormDTO param) {
boolean isRange = StringUtils.isBlank(param.getDateId()) ? true : false;
List<String> daysBetween = null;
if (isRange) {
daysBetween = DateUtils.getDaysBetween(param.getStartDate(), param.getEndDate());
}
List<String> finalDaysBetween = daysBetween;
threadPool.submit(() -> {
CustomerIdAndDateIdFormDTO formDTO = new CustomerIdAndDateIdFormDTO();
formDTO.setCustomerId(param.getCustomerId());
if (!isRange) {
try {
formDTO.setDateId(param.getDateId());
dimCustomerPartymemberService.statsPartyMember(formDTO);
} catch (Exception e) {
log.error("抽取【党员数据】发生异常,参数:" + JSON.toJSONString(formDTO), e);
}
} else {
try {
for (int i = 0; i < finalDaysBetween.size(); i++) {
String dateDimId = finalDaysBetween.get(i);
formDTO.setDateId(dateDimId);
dimCustomerPartymemberService.statsPartyMember(formDTO);
}
} catch (Exception e) {
log.error("抽取【党员数据】发生异常,参数:" + JSON.toJSONString(param), e);
}
}
});
threadPool.submit(() -> {
if(StringUtils.isNotBlank(param.getDateId())){
ExtractOriginFormDTO paramNew = ConvertUtils.sourceToTarget(param, ExtractOriginFormDTO.class);
if (!isRange) {
try {
groupExtractService.extractGroupData(param);
groupExtractService.extractGroupData(paramNew);
} catch (Exception e) {
log.error("抽取【小组数据】发生异常,参数:" + JSON.toJSONString(param), e);
log.error("抽取【小组数据】发生异常,参数:" + JSON.toJSONString(paramNew), e);
}
}else if(StringUtils.isNotBlank(param.getStartDate()) && StringUtils.isNotBlank(param.getEndDate())){
try{
List<String> daysBetween = DateUtils.getDaysBetween(param.getStartDate(), param.getEndDate());
for (int i = 0; i < daysBetween.size(); i++) {
String dateDimId = daysBetween.get(i);
param.setDateId(dateDimId);
groupExtractService.extractGroupData(param);
} else {
try {
for (int i = 0; i < finalDaysBetween.size(); i++) {
String dateDimId = finalDaysBetween.get(i);
paramNew.setDateId(dateDimId);
groupExtractService.extractGroupData(paramNew);
}
}catch(Exception e){
log.error("抽取【小组数据】发生异常,参数:" + JSON.toJSONString(param), e);
} catch (Exception e) {
log.error("抽取【小组数据】发生异常,参数:" + JSON.toJSONString(paramNew), e);
}
}
});
threadPool.submit(() -> {
if(StringUtils.isNotBlank(param.getDateId())){
log.debug("extractAll start param:{}", JSON.toJSONString(param));
ExtractOriginFormDTO paramNew = ConvertUtils.sourceToTarget(param, ExtractOriginFormDTO.class);
if (!isRange) {
try {
factOriginTopicMainDailyService.topicCleaning(param);
factOriginTopicMainDailyService.topicCleaning(paramNew);
} catch (Exception e) {
log.error("抽取【话题数据】发生异常,参数:" + JSON.toJSONString(param), e);
log.error("抽取【话题数据】发生异常,参数:" + JSON.toJSONString(paramNew), e);
}
}else if(StringUtils.isNotBlank(param.getStartDate()) && StringUtils.isNotBlank(param.getEndDate())){
} else {
try {
List<String> daysBetween = DateUtils.getDaysBetween(param.getStartDate(), param.getEndDate());
for (int i = 0; i < daysBetween.size(); i++) {
String dateDimId = daysBetween.get(i);
param.setDateId(dateDimId);
factOriginTopicMainDailyService.topicCleaning(param);
for (int i = 0; i < finalDaysBetween.size(); i++) {
String dateDimId = finalDaysBetween.get(i);
paramNew.setDateId(dateDimId);
log.info("extractAll cal param:{}", JSON.toJSONString(paramNew));
factOriginTopicMainDailyService.topicCleaning(paramNew);
}
} catch (Exception e) {
log.error("抽取【话题数据】发生异常,参数:" + JSON.toJSONString(param), e);
log.error("抽取【话题数据】发生异常,参数:" + JSON.toJSONString(paramNew), e);
}
}
log.debug("extractAll end param:{}", JSON.toJSONString(paramNew));
});
threadPool.submit(() -> {
if(StringUtils.isNotBlank(param.getDateId())){
ExtractOriginFormDTO paramNew = ConvertUtils.sourceToTarget(param, ExtractOriginFormDTO.class);
if (!isRange) {
try {
issueExtractService.issueExtractMain(param);
issueExtractService.issueExtractMain(paramNew);
} catch (Exception e) {
log.error("抽取【议题数据主表】发生异常,参数:" + JSON.toJSONString(param), e);
log.error("抽取【议题数据主表】发生异常,参数:" + JSON.toJSONString(paramNew), e);
}
try {
issueExtractService.issueExtractLog(param);
issueExtractService.issueExtractLog(paramNew);
} catch (Exception e) {
log.error("抽取【议题数据附表】发生异常,参数:" + JSON.toJSONString(param), e);
log.error("抽取【议题数据附表】发生异常,参数:" + JSON.toJSONString(paramNew), e);
}
}else if(StringUtils.isNotBlank(param.getStartDate()) && StringUtils.isNotBlank(param.getEndDate())){
} else {
try {
List<String> daysBetween = DateUtils.getDaysBetween(param.getStartDate(), param.getEndDate());
for (int i = 0; i < daysBetween.size(); i++) {
String dateDimId = daysBetween.get(i);
param.setDateId(dateDimId);
issueExtractService.issueExtractMain(param);
for (int i = 0; i < finalDaysBetween.size(); i++) {
String dateDimId = finalDaysBetween.get(i);
paramNew.setDateId(dateDimId);
issueExtractService.issueExtractMain(paramNew);
}
} catch (Exception e) {
log.error("抽取【议题数据主表】发生异常,参数:" + JSON.toJSONString(param), e);
log.error("抽取【议题数据主表】发生异常,参数:" + JSON.toJSONString(paramNew), e);
}
try {
List<String> daysBetween = DateUtils.getDaysBetween(param.getStartDate(), param.getEndDate());
for (int i = 0; i < daysBetween.size(); i++) {
String dateDimId = daysBetween.get(i);
param.setDateId(dateDimId);
issueExtractService.issueExtractLog(param);
for (int i = 0; i < finalDaysBetween.size(); i++) {
String dateDimId = finalDaysBetween.get(i);
paramNew.setDateId(dateDimId);
issueExtractService.issueExtractLog(paramNew);
}
} catch (Exception e) {
log.error("抽取【议题数据附表】发生异常,参数:" + JSON.toJSONString(param), e);
log.error("抽取【议题数据附表】发生异常,参数:" + JSON.toJSONString(paramNew), e);
}
}
});
threadPool.submit(() -> {
if(StringUtils.isNotBlank(param.getDateId())){
ExtractOriginFormDTO paramNew = ConvertUtils.sourceToTarget(param, ExtractOriginFormDTO.class);
if (!isRange) {
try {
projectExtractService.saveOriginProjectDaily(param);
projectExtractService.saveOriginProjectDaily(paramNew);
} catch (Exception e) {
log.error("抽取【项目数据】发生异常,参数:" + JSON.toJSONString(param), e);
log.error("抽取【项目数据】发生异常,参数:" + JSON.toJSONString(paramNew), e);
}
try {
projectExtractService.extractProjectPeriodData(param);
projectExtractService.extractProjectPeriodData(paramNew);
} catch (Exception e) {
log.error("抽取【项目数据】发生异常,参数:" + JSON.toJSONString(param), e);
log.error("抽取【项目数据】发生异常,参数:" + JSON.toJSONString(paramNew), e);
}
}else if(StringUtils.isNotBlank(param.getStartDate()) && StringUtils.isNotBlank(param.getEndDate())){
} else {
try {
List<String> daysBetween = DateUtils.getDaysBetween(param.getStartDate(), param.getEndDate());
for (int i = 0; i < daysBetween.size(); i++) {
String dateDimId = daysBetween.get(i);
param.setDateId(dateDimId);
projectExtractService.saveOriginProjectDaily(param);
for (int i = 0; i < finalDaysBetween.size(); i++) {
String dateDimId = finalDaysBetween.get(i);
paramNew.setDateId(dateDimId);
projectExtractService.saveOriginProjectDaily(paramNew);
}
} catch (Exception e) {
log.error("抽取【项目数据】发生异常,参数:" + JSON.toJSONString(param), e);
log.error("抽取【项目数据】发生异常,参数:" + JSON.toJSONString(paramNew), e);
}
try {
List<String> daysBetween = DateUtils.getDaysBetween(param.getStartDate(), param.getEndDate());
for (int i = 0; i < daysBetween.size(); i++) {
String dateDimId = daysBetween.get(i);
param.setDateId(dateDimId);
projectExtractService.extractProjectPeriodData(param);
for (int i = 0; i < finalDaysBetween.size(); i++) {
String dateDimId = finalDaysBetween.get(i);
paramNew.setDateId(dateDimId);
projectExtractService.extractProjectPeriodData(paramNew);
}
} catch (Exception e) {
log.error("抽取【项目数据】发生异常,参数:" + JSON.toJSONString(param), e);
log.error("抽取【项目数据】发生异常,参数:" + JSON.toJSONString(paramNew), e);
}
}
});

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

@ -38,6 +38,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.naming.LinkLoopException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
@ -125,6 +126,11 @@ public class FactOriginProjectLogDailyServiceImpl extends BaseServiceImpl<FactOr
return baseDao.selectNotReturnProject(customerId, monthId, actionCode, orgType);
}
@Override
public List<TransferRightRatioResultDTO> selectNotReturn(String customerId,String monthId){
return baseDao.selectNotReturn(customerId,monthId);
}
/**
* @Description 查询项目评价信息
* @param customerId
@ -183,7 +189,7 @@ public class FactOriginProjectLogDailyServiceImpl extends BaseServiceImpl<FactOr
/**
* @Description 查询机关单位经手的项目数去重
* @Description 办结率
* @param agencies
* @param dimId
* @param dateType - 日期维度类型 month date week quarter year
@ -192,59 +198,88 @@ public class FactOriginProjectLogDailyServiceImpl extends BaseServiceImpl<FactOr
* @date 2020.09.23 10:06
**/
@Override
public Map<String, Integer> getCountOfDealingAgency(List<String> agencies, String customerId,String dimId, String dateType) {
Map<String,Integer> result = new HashMap<>();
List<ProjectParticipatedAgencyResultDTO> projectAgencyCount = baseDao.selectProjectParticipatedAgency(agencies,customerId,dimId);
public Map<String, BigDecimal> getHandlingRatio(List<String> agencies, String customerId,String dimId, String dateType) {
//计算方式:“评价周期内被吹哨且办结(无论是哪一级办结)的项目数”/“评价周期内被吹哨的所有项目数”
Map<String,BigDecimal> result = new HashMap<>();
List<ProjectParticipatedAgencyResultDTO> projectAgencyCount = baseDao.selectWhistledAgencyClosedProjectCount(agencies,customerId,dimId);
if(!CollectionUtils.isEmpty(projectAgencyCount)){
result = projectAgencyCount.stream().collect(Collectors.toMap(ProjectParticipatedAgencyResultDTO::getAgencyId,ProjectParticipatedAgencyResultDTO::getCount));
Map<String,Integer> whistledAndHandledProjectTotalMap = projectAgencyCount.stream().collect(Collectors.toMap(ProjectParticipatedAgencyResultDTO::getAgencyId,ProjectParticipatedAgencyResultDTO::getCount));
List<ProjectParticipatedAgencyResultDTO> whistledProjectTotal = baseDao.selectAgencyWhistledCount(agencies,customerId,dimId);
Map<String,Integer> whistledProjectTotalMap = whistledProjectTotal.stream().collect(Collectors.toMap(ProjectParticipatedAgencyResultDTO::getAgencyId,ProjectParticipatedAgencyResultDTO::getCount));
whistledAndHandledProjectTotalMap.forEach((agencyId,count) -> {
//分母 被吹哨项目数
Integer denominator = whistledProjectTotalMap.get(agencyId);
if(null == denominator || NumConstant.ZERO == denominator){
result.put(agencyId,BigDecimal.ZERO);
}else{
result.put(agencyId,new BigDecimal(count).divide(new BigDecimal(denominator), NumConstant.SIX, RoundingMode.HALF_UP));
}
});
}
return result;
}
/**
* @Description 计算机关办结项目效率
* @param agencies
* @param
* @return
* @author wangc
* @date 2020.09.21 02:16
**/
@Override
public Map<String, BigDecimal> getAgencyWorkPieceRatio(List<String> agencies, String customerId,String dimId, String dateType) {
//网格、部门的办结系数
List<OrgResponseTimeResultDTO> gridDeptResponse = projectOrgPeriodDailyDao.selectSubOrgResponseCoefficient(customerId, dimId, dateType);
//机关的办结系数
List<OrgResponseTimeResultDTO> agencyResponse = projectOrgPeriodDailyDao.selectAgencyResponseCoefficient(customerId, dimId, dateType);
Map<String,BigDecimal> consumingMap = new HashMap<>();
Map<String,BigDecimal> timeMap = new HashMap<>();
if(!CollectionUtils.isEmpty(agencyResponse)){
agencyResponse.forEach(response -> {
consumingMap.put(response.getAgencyId(),response.getResponseTime());
//注意,这里取的是去重后的项目次数,例如一个部门被项目流转了多次,项目数只算一次
//如果需要改成不去重,只需response.getProjectTotal()
timeMap.put(response.getAgencyId(),response.getDistinctProjectTotal());
});
}
if(!CollectionUtils.isEmpty(gridDeptResponse)){
gridDeptResponse.forEach(response -> {
if(null != consumingMap.get(response.getAgencyId())){
consumingMap.put(response.getAgencyId(),consumingMap.get(response.getAgencyId()).add(response.getResponseTime()));
timeMap.put(response.getAgencyId(),timeMap.get(response.getAgencyId()).add(response.getDistinctProjectTotal()));
}else{
consumingMap.put(response.getAgencyId(),response.getResponseTime());
timeMap.put(response.getAgencyId(),response.getDistinctProjectTotal());
}
});
}
//效率map
public Map<String, BigDecimal> getAgencyWorkPieceRatio(String customerId,String dimId, String dateType) {
//计算方法 : 评价周期内办结项目的平均处理时长的倒数
//1.评价周期内结案了的项目
List<ProjectParticipatedAgencyResultDTO> projectsHandledByAgency = baseDao.selectProjectIdHandledByAgency(customerId,dimId);
Map<String,BigDecimal> efficiencyMap = new HashMap<>();
if(!CollectionUtils.isEmpty(consumingMap)) {
consumingMap.keySet().forEach(agencyId -> {
efficiencyMap.put(agencyId, consumingMap.get(agencyId).divide(timeMap.get(agencyId), NumConstant.SIX, RoundingMode.HALF_UP));
if(!CollectionUtils.isEmpty(projectsHandledByAgency)){
Map<String,List<String>> agencyProjectsMap = new HashMap<>();
projectsHandledByAgency.forEach(o -> {
String agencyId = o.getAgencyId();
String projectId = o.getProjectId();
if(CollectionUtils.isEmpty(agencyProjectsMap.get(agencyId))){
List<String> projectUnit = new LinkedList<>();
projectUnit.add(projectId);
agencyProjectsMap.put(agencyId,projectUnit);
}else{
agencyProjectsMap.get(agencyId).add(projectId);
}
});
List<String> projects = new LinkedList<>();
agencyProjectsMap.forEach((key,value) -> {projects.addAll(value);});
//2.结案项目的总耗时
List<ProjectParticipatedAgencyResultDTO> costTimes = baseDao.selectProjectCostTime(projects);
Map<String,Integer> projectCostTime = costTimes.stream().collect(Collectors.toMap(ProjectParticipatedAgencyResultDTO::getProjectId,ProjectParticipatedAgencyResultDTO::getCount));
agencyProjectsMap.forEach((k,v) -> {
//k -> agencyId v -> projects
int total = NumConstant.ZERO;
if(!CollectionUtils.isEmpty(v)){
for(String p : v){
Integer cost = projectCostTime.get(p);
total = total + (null == cost ? NumConstant.ZERO : cost);
}
//每个机关的项目平均耗时
BigDecimal avgCost = new BigDecimal(total).divide(new BigDecimal(v.size()),4, BigDecimal.ROUND_HALF_UP);
efficiencyMap.put(k,BigDecimal.ONE.divide(avgCost,4, BigDecimal.ROUND_HALF_UP));
}else{
efficiencyMap.put(k,BigDecimal.ZERO);
}
});
}
return efficiencyMap;
}
@Override
public List<OrgStatisticsResultDTO> getGridResponse(String customerId, String monthId) {
return baseDao.selectGridResponse(customerId, monthId);
@ -265,5 +300,47 @@ public class FactOriginProjectLogDailyServiceImpl extends BaseServiceImpl<FactOr
return baseDao.selectOrgSatisfaction(customerId, monthId, level);
}
/**
* 获取部门办结项目数
*
* @param customerId
* @param monthId
* @return java.util.List<com.epmet.dto.extract.result.OrgStatisticsResultDTO>
* @author zhaoqifeng
* @date 2020/10/16 17:08
*/
@Override
public List<OrgStatisticsResultDTO> getDeptClosedProject(String customerId, String monthId) {
return baseDao.selectDeptClosedProject(customerId, monthId);
}
/**
* 部门办结项目满意度
*
* @param customerId
* @param monthId
* @return java.util.List<com.epmet.dto.extract.result.OrgStatisticsResultDTO>
* @author zhaoqifeng
* @date 2020/10/16 17:50
*/
@Override
public List<OrgStatisticsResultDTO> getDeptSatisfaction(String customerId, String monthId) {
return baseDao.selectDeptSatisfaction(customerId, monthId);
}
/**
* 网格结案率统计
*
* @param customerId
* @param monthId
* @return java.util.List<com.epmet.dto.extract.result.OrgStatisticsResultDTO>
* @author zhaoqifeng
* @date 2020/10/19 11:58
*/
@Override
public List<OrgStatisticsResultDTO> getGridClosed(String customerId, String monthId) {
return baseDao.selectGridClosed(customerId, monthId);
}
}

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

@ -30,6 +30,7 @@ import com.epmet.dao.evaluationindex.extract.FactOriginProjectMainDailyDao;
import com.epmet.dto.extract.FactOriginProjectMainDailyDTO;
import com.epmet.dto.extract.result.GridProjectClosedTotalResultDTO;
import com.epmet.dto.extract.result.OrgStatisticsResultDTO;
import com.epmet.dto.extract.result.TransferRightRatioResultDTO;
import com.epmet.dto.indexcollect.result.CpcIndexCommonDTO;
import com.epmet.dto.screen.form.ProjectSourceMapFormDTO;
import com.epmet.entity.evaluationindex.extract.FactOriginProjectMainDailyEntity;
@ -134,6 +135,11 @@ public class FactOriginProjectMainDailyServiceImpl extends BaseServiceImpl<FactO
return baseDao.selectGridClosedProject(customerId, monthId,status);
}
@Override
public List<TransferRightRatioResultDTO> selectTransferRightRatio(String customerId, String monthId){
return baseDao.selectTransferRightRatio(customerId,monthId);
}
@Override
public void deleteByDate(String customerId, String date) {
baseDao.deleteByDate(customerId, date);

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

@ -23,4 +23,18 @@ public class FactOriginProjectOrgPeriodDailyServiceImpl extends BaseServiceImpl<
public List<OrgStatisticsResultDTO> getResponsiveness(String customerId, String monthId, String level, String orgType) {
return baseDao.selectResponsiveness(customerId, monthId, level, orgType);
}
/**
* 部门处理效率统计
*
* @param customerId
* @param monthId
* @return java.util.List<com.epmet.dto.extract.result.OrgStatisticsResultDTO>
* @author zhaoqifeng
* @date 2020/10/19 9:38
*/
@Override
public List<OrgStatisticsResultDTO> getDeptHandle(String customerId, String monthId) {
return baseDao.selectDeptHandle(customerId, monthId);
}
}

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

@ -438,7 +438,7 @@ public class ProjectExtractServiceImpl implements ProjectExtractService {
if(!CollectionUtils.isEmpty(formattingData)) {
List<String> projectIds = formattingData.stream().map(FactOriginProjectOrgPeriodDailyEntity::getProjectId).distinct().collect(Collectors.toList());
if (!CollectionUtils.isEmpty(projectIds)) {
factOriginProjectOrgPeriodDailyDao.deleteByProjectId(projectIds);
factOriginProjectOrgPeriodDailyDao.deleteByProjectIds(projectIds);
factOriginProjectOrgPeriodDailyDao.insertBatch(formattingData);
}
}

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

@ -1,104 +0,0 @@
package com.epmet.service.evaluationindex.extract.todata.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.dao.evaluationindex.extract.FactOriginProjectOrgPeriodDailyDao;
import com.epmet.dto.extract.form.ExtractOriginFormDTO;
import com.epmet.dto.project.result.ProjectOrgPeriodResultDTO;
import com.epmet.entity.evaluationindex.extract.FactOriginProjectOrgPeriodDailyEntity;
import com.epmet.service.evaluationindex.extract.todata.ProjectPeriodExtractService;
import com.epmet.service.project.ProjectProcessService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Description 业务数据抽取 - 项目节点历时
* @ClassName ProjectPeriodExtractServiceImpl
* @Auth wangc
* @Date 2020-09-17 13:52
*/
@Service
@Slf4j
public class ProjectPeriodExtractServiceImpl implements ProjectPeriodExtractService {
@Autowired
private FactOriginProjectOrgPeriodDailyDao factOriginProjectOrgPeriodDailyDao;
@Autowired
private ProjectProcessService projectProcessService;
/**
* @param param
* @return
* @Description 抽取项目节点历时逻辑
* @author wangc
* @date 2020.09.17 14:05
**/
@Override
public void extractProjectPeriodData(ExtractOriginFormDTO param) {
int trace = factOriginProjectOrgPeriodDailyDao.selectIfExisted(param.getCustomerId());
Boolean isFirst = trace <= NumConstant.ZERO ? true : false;
if (StringUtils.isBlank(param.getDateId())) {
Date yesterday = new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24);
SimpleDateFormat format = new SimpleDateFormat(DateUtils.DATE_PATTERN_YYYYMMDD);
param.setDateId(format.format(yesterday));
}
List<ProjectOrgPeriodResultDTO> extractData =
projectProcessService.getProjectPeriod(isFirst, param.getCustomerId(), param.getDateId());
List<FactOriginProjectOrgPeriodDailyEntity> formattingData = new LinkedList<>();
extractData.forEach(original -> {
FactOriginProjectOrgPeriodDailyEntity dest
= ConvertUtils.sourceToTarget(original,FactOriginProjectOrgPeriodDailyEntity.class);
if(StringUtils.isNotBlank(original.getDepartmentId())){
dest.setOrgType("dept");
dest.setPid(original.getOrgId());
dest.setPids(original.getOrgIdPath());
}else if(StringUtils.isNotBlank(original.getGridId())){
dest.setOrgType("grid");
dest.setPid(original.getOrgId());
dest.setPids(original.getOrgIdPath());
}else{
dest.setOrgType("agency");
dest.setPids("");
String[] array = original.getOrgIdPath().split(":");
if(null == array || array.length <= NumConstant.ZERO){
dest.setPid(NumConstant.ZERO_STR);
}
if(array[NumConstant.ZERO] == original.getOrgId() && array.length == NumConstant.ONE){
dest.setPid(NumConstant.ZERO_STR);
}
if(array.length > NumConstant.ONE && original.getOrgId() == array[array.length - NumConstant.ONE]){
dest.setPid(array[array.length - NumConstant.TWO]);
dest.setPids(original.getOrgIdPath().replace(original.getOrgId(),""));
}
if(StringUtils.isNotBlank(dest.getPids())){
while(dest.getPids().endsWith(":")){
dest.setPids(dest.getPids().substring(NumConstant.ZERO,dest.getPids().length() - NumConstant.ONE));
}
while(dest.getPids().startsWith(":")){
dest.setPids(dest.getPids().replaceFirst(":",""));
}
}
dest.setPids(dest.getPids().replaceAll(" ",""));
}
formattingData.add(dest);
});
if(!CollectionUtils.isEmpty(formattingData)) {
List<String> projectIds = formattingData.stream().map(FactOriginProjectOrgPeriodDailyEntity::getProjectId).distinct().collect(Collectors.toList());
if (!CollectionUtils.isEmpty(projectIds)) {
factOriginProjectOrgPeriodDailyDao.deleteByProjectId(projectIds);
factOriginProjectOrgPeriodDailyDao.insertBatch(formattingData);
}
}
}
}

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

@ -101,15 +101,25 @@ public class OrgRankExtractServiceImpl implements OrgRankExtractService {
));
}
//结案率 结案数/项目数
List<FactIndexGovrnAblityGridMonthlyEntity> abilityList = factIndexGovrnAblityGridMonthlyService.getGridByCustomer(customerId, monthId);
if (CollectionUtils.isNotEmpty(abilityList)) {
list.forEach(entity -> abilityList.stream().filter(item -> item.getGridId().equals(entity.getOrgId())).forEach(dto -> {
if (dto.getProjectTotal() != NumConstant.ZERO) {
BigDecimal total = new BigDecimal(dto.getProjectTotal());
BigDecimal closed = new BigDecimal(dto.getResolveProjectCount());
entity.setCloseProjectRatio(closed.multiply(hundred).divide(total, NumConstant.SIX, RoundingMode.HALF_UP));
// List<FactIndexGovrnAblityGridMonthlyEntity> abilityList = factIndexGovrnAblityGridMonthlyService.getGridByCustomer(customerId, monthId);
// if (CollectionUtils.isNotEmpty(abilityList)) {
// list.forEach(entity -> abilityList.stream().filter(item -> item.getGridId().equals(entity.getOrgId())).forEach(dto -> {
// if (dto.getProjectTotal() != NumConstant.ZERO) {
// BigDecimal total = new BigDecimal(dto.getProjectTotal());
// BigDecimal closed = new BigDecimal(dto.getResolveProjectCount());
// entity.setCloseProjectRatio(closed.multiply(hundred).divide(total, NumConstant.SIX, RoundingMode.HALF_UP));
// }
//
// }));
// }
List<OrgStatisticsResultDTO> closed = factOriginProjectLogDailyService.getGridClosed(customerId, monthId);
if (CollectionUtils.isNotEmpty(closed)) {
list.forEach(entity -> closed.stream().filter(item -> item.getOrgId().equals(entity.getOrgId())).forEach(dto -> {
if (dto.getSum() != NumConstant.ZERO) {
BigDecimal sum = new BigDecimal(dto.getSum());
BigDecimal count = new BigDecimal(dto.getCount());
entity.setCloseProjectRatio(count.multiply(hundred).divide(sum, NumConstant.SIX, RoundingMode.HALF_UP));
}
}));
}
//满意率 满意和非常满意占比

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

@ -2,7 +2,9 @@ package com.epmet.service.evaluationindex.extract.toscreen.impl;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.constant.NumConstant;
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.ExtractOriginFormDTO;
import com.epmet.dto.extract.form.ExtractScreenFormDTO;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
@ -167,6 +169,7 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
}catch (Exception e){
log.error("基层治理-难点赌点抽取到大屏失败,customerId为:"+customerId+"dateId为:"+dateId, e);
}
log.info("===== extractDaily method end ======");
}
/**
@ -245,14 +248,17 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
//此方法保持在最后即可 计算指标分数 todo 优化 手动创建线程池 控制任务数量
ExecutorService pool = Executors.newSingleThreadExecutor();
pool.submit(() -> {
long start = System.currentTimeMillis();
CalculateCommonFormDTO formDTO1 = new CalculateCommonFormDTO();
try {
formDTO1.setMonthId(monthId);
formDTO1.setCustomerId(customerId);
indexCalculateService.indexCalculate(formDTO1);
Boolean aBoolean = indexCalculateService.indexCalculate(formDTO1);
HttpClientManager.getInstance().sendAlarmMsg(EnvEnum.getCurrentEnv().getName() + "客户Id:" + formDTO.getCustomerId() + ",calculateAll全部指标计算完成,是否成功:" + aBoolean + ",总耗时:" + (System.currentTimeMillis() - start) / 1000 + "秒");
} catch (Exception e) {
log.error("extractMonthly 计算分数异常,参数:{}", JSON.toJSONString(formDTO1));
}
});
log.info("===== extractMonthly method end ======");
}
}

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

@ -140,12 +140,15 @@ public class DeptScoreServiceImpl extends BaseServiceImpl<DeptScoreDao, DeptScor
Map<String, Set<String>> selfSubParentMap = new HashMap<>();
selfSubParentMap.put(ProjectConstant.ZI_SHEN, new HashSet<>());
selfSubParentMap.put(ProjectConstant.XIA_JI, new HashSet<>());
Map<String, BigDecimal> weightMap = new HashMap<>();
selfSubIndexList.forEach(o -> {
//找出自身 和下级的指标
if (o.getAllIndexCodePath().indexOf(ProjectConstant.XIA_JI) > -1) {
selfSubParentMap.get(ProjectConstant.XIA_JI).add(o.getIndexCode());
weightMap.put(ProjectConstant.XIA_JI, weightMap.getOrDefault(ProjectConstant.XIA_JI, new BigDecimal(0)).add(o.getWeight()));
} else {
selfSubParentMap.get(ProjectConstant.ZI_SHEN).add(o.getIndexCode());
weightMap.put(ProjectConstant.ZI_SHEN, weightMap.getOrDefault(ProjectConstant.ZI_SHEN, new BigDecimal(0)).add(o.getWeight()));
}
});
Map<String, DeptSelfSubScoreEntity> insertMap = new HashMap<>();
@ -158,16 +161,16 @@ public class DeptScoreServiceImpl extends BaseServiceImpl<DeptScoreDao, DeptScor
scoreEntity.setSelfScore(new BigDecimal(0));
scoreEntity.setSubScore(new BigDecimal(0));
scoreEntity.setParentIndexCode(index.getIndexCode());
scoreEntity.setSelfWeight(new BigDecimal(0));
scoreEntity.setSubWeight(new BigDecimal(0));
scoreEntity.setSelfWeight(weightMap.getOrDefault(score.getIndexCode(), new BigDecimal(0)));
scoreEntity.setSubWeight(weightMap.getOrDefault(score.getIndexCode(), new BigDecimal(0)));
}
BigDecimal partScore = score.getScore().multiply(score.getWeight());
if (selfSubParentMap.get(ProjectConstant.XIA_JI).contains(score.getIndexCode())) {
scoreEntity.setSubScore(scoreEntity.getSubScore().add(partScore));
scoreEntity.setSubWeight(scoreEntity.getSubWeight().add(score.getWeight()));
scoreEntity.setSelfWeight(weightMap.get(ProjectConstant.XIA_JI));
} else {
scoreEntity.setSelfScore(scoreEntity.getSelfScore().add(partScore));
scoreEntity.setSelfWeight(scoreEntity.getSelfWeight().add(score.getWeight()));
scoreEntity.setSelfWeight(weightMap.get(ProjectConstant.ZI_SHEN));
}
log.debug("=====key" + key + ",grid:{},originScore:{},weight:{},finalScore:{},total", score.getAgencyId(), score.getScore(), score.getWeight(), partScore);
});

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

@ -129,12 +129,15 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
Map<String, Set<String>> selfSubParentMap = new HashMap<>();
selfSubParentMap.put(ProjectConstant.ZI_SHEN, new HashSet<>());
selfSubParentMap.put(ProjectConstant.XIA_JI, new HashSet<>());
Map<String, BigDecimal> weightMap = new HashMap<>();
selfSubIndexList.forEach(o -> {
//找出自身 和下级的指标
if (o.getAllIndexCodePath().indexOf(ProjectConstant.XIA_JI) > -1) {
selfSubParentMap.get(ProjectConstant.XIA_JI).add(o.getIndexCode());
weightMap.put(ProjectConstant.XIA_JI, weightMap.getOrDefault(ProjectConstant.XIA_JI, new BigDecimal(0)).add(o.getWeight()));
} else {
selfSubParentMap.get(ProjectConstant.ZI_SHEN).add(o.getIndexCode());
weightMap.put(ProjectConstant.ZI_SHEN, weightMap.getOrDefault(ProjectConstant.ZI_SHEN, new BigDecimal(0)).add(o.getWeight()));
}
});
Map<String, GridSelfSubScoreEntity> insertMap = new HashMap<>();
@ -148,16 +151,14 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
scoreEntity.setSelfScore(new BigDecimal(0));
scoreEntity.setSubScore(new BigDecimal(0));
scoreEntity.setParentIndexCode(index.getIndexCode());
scoreEntity.setSelfWeight(new BigDecimal(0));
scoreEntity.setSubWeight(new BigDecimal(0));
scoreEntity.setSubWeight(weightMap.getOrDefault(ProjectConstant.XIA_JI, new BigDecimal(0)));
scoreEntity.setSelfWeight(weightMap.getOrDefault(ProjectConstant.ZI_SHEN, new BigDecimal(0)));
}
BigDecimal partScore = score.getScore().multiply(score.getWeight());
if (selfSubParentMap.get(ProjectConstant.XIA_JI).contains(score.getIndexCode())) {
scoreEntity.setSubScore(scoreEntity.getSubScore().add(partScore));
scoreEntity.setSubWeight(scoreEntity.getSubWeight().add(score.getWeight()));
} else {
scoreEntity.setSelfScore(scoreEntity.getSelfScore().add(partScore));
scoreEntity.setSelfWeight(scoreEntity.getSelfWeight().add(score.getWeight()));
}
log.debug("=====key" + key + ",grid:{},originScore:{},weight:{},finalScore:{},total", score.getGridId(), score.getScore(), score.getWeight(), partScore);
});
@ -500,7 +501,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
log.info("计算的结果(List)"+JSON.toJSONString(listTemp));*/
HashMap<String, CalculateResult> resultMap = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
log.info("计算的结果{}", resultMap);
log.info("计算的结果{}", JSON.toJSONString(resultMap));
return resultMap;
}

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

@ -138,12 +138,15 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
Map<String, Set<String>> selfSubParentMap = new HashMap<>();
selfSubParentMap.put(ProjectConstant.ZI_SHEN, new HashSet<>());
selfSubParentMap.put(ProjectConstant.XIA_JI, new HashSet<>());
Map<String, BigDecimal> weightMap = new HashMap<>();
selfSubIndexList.forEach(o -> {
//找出自身 和下级的指标
if (o.getAllIndexCodePath().indexOf(ProjectConstant.XIA_JI) > -1) {
selfSubParentMap.get(ProjectConstant.XIA_JI).add(o.getIndexCode());
weightMap.put(ProjectConstant.XIA_JI, weightMap.getOrDefault(ProjectConstant.XIA_JI, new BigDecimal(0)).add(o.getWeight()));
} else {
selfSubParentMap.get(ProjectConstant.ZI_SHEN).add(o.getIndexCode());
weightMap.put(ProjectConstant.ZI_SHEN, weightMap.getOrDefault(ProjectConstant.ZI_SHEN, new BigDecimal(0)).add(o.getWeight()));
}
});
Map<String, CommunitySelfSubScoreEntity> insertMap = new HashMap<>();
@ -156,16 +159,15 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
scoreEntity.setSelfScore(new BigDecimal(0));
scoreEntity.setSubScore(new BigDecimal(0));
scoreEntity.setParentIndexCode(index.getIndexCode());
scoreEntity.setSelfWeight(new BigDecimal(0));
scoreEntity.setSubWeight(new BigDecimal(0));
scoreEntity.setSubWeight(weightMap.get(ProjectConstant.XIA_JI));
scoreEntity.setSelfWeight(weightMap.get(ProjectConstant.ZI_SHEN));
}
BigDecimal partScore = score.getScore().multiply(score.getWeight());
if (selfSubParentMap.get(ProjectConstant.XIA_JI).contains(score.getIndexCode())) {
scoreEntity.setSubScore(scoreEntity.getSubScore().add(partScore));
scoreEntity.setSubWeight(scoreEntity.getSubWeight().add(score.getWeight()));
} else {
scoreEntity.setSelfScore(scoreEntity.getSelfScore().add(partScore));
scoreEntity.setSelfWeight(scoreEntity.getSelfWeight().add(score.getWeight()));
}
log.debug("=====key" + key + ",grid:{},originScore:{},weight:{},finalScore:{},total", score.getAgencyId(), score.getScore(), score.getWeight(), partScore);
});

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

@ -136,12 +136,15 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
Map<String, Set<String>> selfSubParentMap = new HashMap<>();
selfSubParentMap.put(ProjectConstant.ZI_SHEN, new HashSet<>());
selfSubParentMap.put(ProjectConstant.XIA_JI, new HashSet<>());
Map<String, BigDecimal> weightMap = new HashMap<>();
selfSubIndexList.forEach(o -> {
//找出自身 和下级的指标
if (o.getAllIndexCodePath().indexOf(ProjectConstant.XIA_JI) > -1) {
selfSubParentMap.get(ProjectConstant.XIA_JI).add(o.getIndexCode());
weightMap.put(ProjectConstant.XIA_JI, weightMap.getOrDefault(ProjectConstant.XIA_JI, new BigDecimal(0)).add(o.getWeight()));
} else {
selfSubParentMap.get(ProjectConstant.ZI_SHEN).add(o.getIndexCode());
weightMap.put(ProjectConstant.ZI_SHEN, weightMap.getOrDefault(ProjectConstant.ZI_SHEN, new BigDecimal(0)).add(o.getWeight()));
}
});
Map<String, AgencySelfSubScoreEntity> insertMap = new HashMap<>();
@ -154,16 +157,14 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
scoreEntity.setSelfScore(new BigDecimal(0));
scoreEntity.setSubScore(new BigDecimal(0));
scoreEntity.setParentIndexCode(index.getIndexCode());
scoreEntity.setSelfWeight(new BigDecimal(0));
scoreEntity.setSubWeight(new BigDecimal(0));
scoreEntity.setSubWeight(weightMap.getOrDefault(ProjectConstant.XIA_JI, new BigDecimal(0)));
scoreEntity.setSelfWeight(weightMap.getOrDefault(ProjectConstant.ZI_SHEN, new BigDecimal(0)));
}
BigDecimal partScore = score.getScore().multiply(score.getWeight());
if (selfSubParentMap.get(ProjectConstant.XIA_JI).contains(score.getIndexCode())) {
scoreEntity.setSubScore(scoreEntity.getSubScore().add(partScore));
scoreEntity.setSubWeight(scoreEntity.getSubWeight().add(score.getWeight()));
} else {
scoreEntity.setSelfScore(scoreEntity.getSelfScore().add(partScore));
scoreEntity.setSelfWeight(scoreEntity.getSelfWeight().add(score.getWeight()));
}
log.debug("=====key" + key + ",grid:{},originScore:{},weight:{},finalScore:{},total", score.getAgencyId(), score.getScore(), score.getWeight(), partScore);
});

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

@ -139,13 +139,17 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
Map<String, Set<String>> selfSubParentMap = new HashMap<>();
selfSubParentMap.put(ProjectConstant.ZI_SHEN, new HashSet<>());
selfSubParentMap.put(ProjectConstant.XIA_JI, new HashSet<>());
Map<String, BigDecimal> weightMap = new HashMap<>();
selfSubIndexList.forEach(o -> {
//找出自身 和下级的指标
if (o.getAllIndexCodePath().indexOf(ProjectConstant.XIA_JI) > -1) {
selfSubParentMap.get(ProjectConstant.XIA_JI).add(o.getIndexCode());
weightMap.put(ProjectConstant.XIA_JI, weightMap.getOrDefault(ProjectConstant.XIA_JI, new BigDecimal(0)).add(o.getWeight()));
} else {
selfSubParentMap.get(ProjectConstant.ZI_SHEN).add(o.getIndexCode());
weightMap.put(ProjectConstant.ZI_SHEN, weightMap.getOrDefault(ProjectConstant.ZI_SHEN, new BigDecimal(0)).add(o.getWeight()));
}
});
Map<String, AgencySelfSubScoreEntity> insertMap = new HashMap<>();
subScore.forEach(score -> {
@ -157,16 +161,14 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
scoreEntity.setSelfScore(new BigDecimal(0));
scoreEntity.setSubScore(new BigDecimal(0));
scoreEntity.setParentIndexCode(index.getIndexCode());
scoreEntity.setSelfWeight(new BigDecimal(0));
scoreEntity.setSubWeight(new BigDecimal(0));
scoreEntity.setSubWeight(weightMap.getOrDefault(ProjectConstant.XIA_JI, new BigDecimal(0)));
scoreEntity.setSelfWeight(weightMap.getOrDefault(ProjectConstant.ZI_SHEN, new BigDecimal(0)));
}
BigDecimal partScore = score.getScore().multiply(score.getWeight());
if (selfSubParentMap.get(ProjectConstant.XIA_JI).contains(score.getIndexCode())) {
scoreEntity.setSubScore(scoreEntity.getSubScore().add(partScore));
scoreEntity.setSubWeight(scoreEntity.getSubWeight().add(score.getWeight()));
} else {
scoreEntity.setSelfScore(scoreEntity.getSelfScore().add(partScore));
scoreEntity.setSelfWeight(scoreEntity.getSelfWeight().add(score.getWeight()));
}
log.debug("=====key" + key + ",grid:{},originScore:{},weight:{},finalScore:{},total", score.getAgencyId(), score.getScore(), score.getWeight(), partScore);
});

11
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/FactIndexGovrnAblityDeptMonthlyService.java

@ -3,6 +3,8 @@ package com.epmet.service.evaluationindex.indexcoll;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.entity.evaluationindex.indexcoll.FactIndexGovrnAblityDeptMonthlyEntity;
import java.util.List;
/**
* @author zhaoqifeng
* @dscription
@ -18,4 +20,13 @@ public interface FactIndexGovrnAblityDeptMonthlyService extends BaseService<Fact
* @return void
*/
void deleteByCustomer(String customerId, String monthId);
/**
* 批量插入
* @author zhaoqifeng
* @date 2020/9/21 17:08
* @param list
* @return void
*/
void saveList(List<FactIndexGovrnAblityDeptMonthlyEntity> list);
}

89
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java

@ -3,6 +3,7 @@ package com.epmet.service.evaluationindex.indexcoll.impl;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.constant.DataSourceConstant;
import com.epmet.constant.OrgTypeConstant;
@ -27,6 +28,8 @@ import com.epmet.service.evaluationindex.indexcoll.FactIndexCollectService;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -38,6 +41,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
@ -84,6 +88,8 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
private ScreenCustomerDeptDao screenCustomerDeptDao;
@Autowired
private ScreenCustomerAgencyDao screenCustomerAgencyDao;
@Autowired
private RedissonClient redissonClient;
@Override
@Transactional(rollbackFor = Exception.class)
@ -198,35 +204,60 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
}
}
/**
* @Description 目前只支持到区县级别区县级以上的未实现
* @Param monthId
* @Param customerId
* @author zxc
* @date 2020/10/20 2:59 下午
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void insertScreenIndexDataMonthlyAndYearly(String monthId, String customerId) {
if (NumConstant.SIX != monthId.length()){
if (NumConstant.SIX != monthId.length()) {
throw new RuntimeException("入参monthId格式不正确:monthId =" + monthId);
}
allParentIds.cleanUp();
// 根据网格类型,删除 指数-指数数据(每月数值)表中 匹配的数据
this.batchDelIndexDataMonthly(customerId, monthId, OrgTypeConstant.GRID);
// 开始处理 网格相关分值表
this.startHandleIndexGridScore(monthId, customerId);
// 根据组织类型,删除 指数-指数数据(每月数值)表中 匹配的数据
this.batchDelIndexDataMonthly(customerId, monthId, OrgTypeConstant.AGENCY);
// 开始处理 社区相关分值表
this.startHandleIndexCommunityScore(monthId, customerId);
// 根据部门类型,删除 指数-指数数据(每月数值)表中 匹配的数据
this.batchDelIndexDataMonthly(customerId, monthId, OrgTypeConstant.DEPARTMENT);
// 开始处理 区直部门分值表
this.startHandleIndexDeptScore(monthId, customerId);
// 同样是 组织类型,所以不再重复删除了
// 开始处理 区/街道相关分数表
this.startHandleIndexAgencyScore(monthId, customerId);
// 根据年,汇总今年各项得到,计算平均值后 插入年表 screen_index_data_yearly
this.insertIndexDataYear(monthId, customerId);
allParentIds.invalidateAll();
RLock lock = redissonClient.getLock(RedisKeys.getScreenIndexDataLockKey());
try {
AtomicInteger tryTimes = new AtomicInteger(0);
boolean lockFlag = false;
do {
lockFlag = lock.tryLock(1, 10, TimeUnit.MINUTES);
} while (!lockFlag && tryTimes.addAndGet(1) < 3);
if (!lockFlag) {
log.error("插入大屏指数方法获取锁失败");
return;
}
allParentIds.cleanUp();
// 根据网格类型,删除 指数-指数数据(每月数值)表中 匹配的数据
this.batchDelIndexDataMonthly(customerId, monthId, OrgTypeConstant.GRID);
// 开始处理 网格相关分值表
this.startHandleIndexGridScore(monthId, customerId);
// 根据组织类型,删除 指数-指数数据(每月数值)表中 匹配的数据
this.batchDelIndexDataMonthly(customerId, monthId, OrgTypeConstant.AGENCY);
// 开始处理 社区相关分值表
this.startHandleIndexCommunityScore(monthId, customerId);
// 根据部门类型,删除 指数-指数数据(每月数值)表中 匹配的数据
this.batchDelIndexDataMonthly(customerId, monthId, OrgTypeConstant.DEPARTMENT);
// 开始处理 区直部门分值表
this.startHandleIndexDeptScore(monthId, customerId);
// 同样是 组织类型,所以不再重复删除了
// 开始处理 区/街道相关分数表
this.startHandleIndexAgencyScore(monthId, customerId);
// 根据年,汇总今年各项得到,计算平均值后 插入年表 screen_index_data_yearly
this.insertIndexDataYear(monthId, customerId);
allParentIds.invalidateAll();
} catch (InterruptedException inter) {
log.error("插入计算指标数据异常", inter);
} finally {
//判断是否是当前线程 持有锁
if (lock.isHeldByCurrentThread()) {
lock.unlock();
}
}
}
/**
@ -348,7 +379,8 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
}
}
if ("".equals(parentAgencyId)){
throw new RuntimeException("在screen_customer_grid表中未查询到该客户下的网格信息:customerId =" + customerId + ", gridId = " + gridScore.getKey());
log.error("在screen_customer_grid表中未查询到该客户下的网格信息:customerId =" + customerId + ", gridId = " + gridScore.getKey());
continue;
}
// 补充表中其他字段
monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.GRID, gridScore.getKey(),
@ -480,8 +512,9 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
agencyName = agencyScoreDTO.getAgencyName();
}
}
if ("".equals(agencyName)){
throw new RuntimeException("在screen_customer_agency表中未查询到该客户下的组织名称:customerId =" + customerId + ", agencyId = " + communityScore.getKey());
if ("".equals(agencyName)) {
log.error("在screen_customer_agency表中未查询到该客户下的组织名称:customerId =" + customerId + ", agencyId = " + communityScore.getKey());
continue;
}
// 补充表中其他字段
monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.AGENCY, communityScore.getKey(),

15
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexGovrnAblityDeptMonthlyServiceImpl.java

@ -8,6 +8,8 @@ import com.epmet.entity.evaluationindex.indexcoll.FactIndexGovrnAblityDeptMonthl
import com.epmet.service.evaluationindex.indexcoll.FactIndexGovrnAblityDeptMonthlyService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author zhaoqifeng
* @dscription
@ -21,4 +23,17 @@ public class FactIndexGovrnAblityDeptMonthlyServiceImpl extends BaseServiceImpl<
public void deleteByCustomer(String customerId, String monthId) {
baseDao.deleteFactIndexGovrnAblityDeptMonthly(customerId, monthId);
}
/**
* 批量插入
*
* @param list
* @return void
* @author zhaoqifeng
* @date 2020/9/21 17:08
*/
@Override
public void saveList(List<FactIndexGovrnAblityDeptMonthlyEntity> list) {
insertBatch(list);
}
}

13
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java

@ -21,6 +21,7 @@ package com.epmet.service.evaluationindex.screen;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.dto.extract.form.*;
import com.epmet.dto.extract.result.GridInfoResultDTO;
import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity;
import com.epmet.entity.org.CustomerGridEntity;
@ -75,10 +76,20 @@ public interface ScreenCustomerGridService extends BaseService<ScreenCustomerGri
List<PartyAbilityGridMonthlyFormDTO> selectAllGridInfoToParty(String customerId);
/**
* @Description 查询全部网格信息
* @param customerId
* @Description 查询全部网格信息
* @author zxc
* @date 2020/9/18 10:47 上午
*/
List<GovernAbilityGridMonthlyFormDTO> selectAllGridInfo(String customerId);
/**
* desc: 初始化客户的业务组织关系
*
* @param formDTO
* @return java.lang.Boolean
* @author LiuJanJun
* @date 2020/10/21 2:33 下午
*/
Boolean initBizOrg(CustomerBizOrgFormDTO formDTO);
}

13
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ShiBeiScreenCollService.java

@ -1,8 +1,7 @@
package com.epmet.service.evaluationindex.screen;
import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO;
import com.epmet.dto.screencoll.form.*;
import java.util.List;
/**
* 大屏数据采集api
*
@ -231,4 +230,14 @@ public interface ShiBeiScreenCollService {
* @Date 09:44 2020-08-25
**/
void insertPublicPartiTotalData(PublicPartiTotalDataListFormDTO formDTO, String customerId);
/**
* desc: 初始化客户业务组织关系表
*
* @param formDTO
* @return java.lang.Integer
* @author LiuJanJun
* @date 2020/10/21 2:38 下午
*/
Integer initBizOrg(CustomerBizOrgFormDTO formDTO);
}

13
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java

@ -39,6 +39,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.*;
import java.util.stream.Collectors;
@ -131,6 +132,12 @@ public class ScreenCustomerAgencyServiceImpl implements ScreenCustomerAgencyServ
exists.setLevel(e.getLevel());
exists.setDataEndTime(dateEndTime);
exists.setAreaCode(e.getAreaCode());
//如果没有区划 则默认暂时不显示
if (StringUtils.isEmpty(e.getAreaCode())) {
exists.setIsDisplay(NumConstant.ZERO_STR);
} else {
exists.setIsDisplay(NumConstant.ONE_STR);
}
exists.setAllParentNames(e.getAllParentName());
updateAgency(exists);
}
@ -221,6 +228,12 @@ public class ScreenCustomerAgencyServiceImpl implements ScreenCustomerAgencyServ
cae.setAllParentNames(e.getAllParentName());
cae.setAreaCode(e.getAreaCode());
//cae.setAreaMarks(e);
//如果没有区划 则默认暂时不显示
if (StringUtils.isEmpty(e.getAreaCode())) {
cae.setIsDisplay(NumConstant.ZERO_STR);
} else {
cae.setIsDisplay(NumConstant.ONE_STR);
}
cae.setCustomerId(e.getCustomerId());
cae.setDataEndTime(dateEndTime);
cae.setLevel(e.getLevel());

9
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java

@ -26,10 +26,10 @@ import com.epmet.constant.OrgSourceTypeConstant;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerGridDao;
import com.epmet.dto.extract.form.*;
import com.epmet.dto.extract.result.GridInfoResultDTO;
import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity;
import com.epmet.entity.org.CustomerGridEntity;
import com.epmet.service.evaluationindex.screen.ScreenCustomerGridService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -150,8 +150,8 @@ public class ScreenCustomerGridServiceImpl extends BaseServiceImpl<ScreenCustome
}
/**
* @Description 查询全部网格信息
* @param customerId
* @Description 查询全部网格信息
* @author zxc
* @date 2020/9/18 10:47 上午
*/
@ -159,4 +159,9 @@ public class ScreenCustomerGridServiceImpl extends BaseServiceImpl<ScreenCustome
public List<GovernAbilityGridMonthlyFormDTO> selectAllGridInfo(String customerId) {
return screenCustomerGridDao.selectAllGridInfo(customerId);
}
@Override
public Boolean initBizOrg(CustomerBizOrgFormDTO formDTO) {
return null;
}
}

88
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ShiBeiScreenCollServiceImpl.java

@ -17,20 +17,24 @@
package com.epmet.service.evaluationindex.screen.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.constant.CompareConstant;
import com.epmet.constant.DataSourceConstant;
import com.epmet.constant.IndexCalConstant;
import com.epmet.dao.evaluationindex.screen.*;
import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO;
import com.epmet.dto.screencoll.form.*;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerBizOrgEntity;
import com.epmet.entity.evaluationindex.screen.ScreenEventImgDataEntity;
import com.epmet.entity.evaluationindex.screen.ScreenUserJoinEntity;
import com.epmet.service.evaluationindex.screen.ShiBeiScreenCollService;
import org.apache.commons.collections4.ListUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -39,7 +43,6 @@ import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
@ -53,9 +56,9 @@ import java.util.stream.Collectors;
@DataSource(DataSourceConstant.EVALUATION_INDEX)
public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
@Autowired
private ScreenPartyUserRankDataDao screenPartyUserRankDataDao;
@Autowired
@Autowired
private ScreenPartyUserRankDataDao screenPartyUserRankDataDao;
@Autowired
private ScreenPartyLinkMassesDataDao screenPartyLinkMassesDataDao;
@Autowired
private ScreenPartyBranchDataDao screenPartyBranchDataDao;
@ -80,6 +83,8 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
@Autowired
private ScreenCustomerAgencyDao screenCustomerAgencyDao;
@Autowired
private ScreenCustomerBizOrgDao screenCustomerBizOrgDao;
@Autowired
private ScreenUserTotalDataDao screenUserTotalDataDao;
@Autowired
private ScreenUserJoinDao screenUserJoinDao;
@ -93,7 +98,7 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
@Transactional(rollbackFor = Exception.class)
public void insertPartyUserRankData(PartyUserRankDataListFormDTO formDTO,String customerId) {
public void insertPartyUserRankData(PartyUserRankDataListFormDTO formDTO, String customerId) {
if (formDTO.getIsFirst()) {
int deleteNum;
do {
@ -186,7 +191,7 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
if (null != formDTO.getDataList().get(i).getImgDataList() && formDTO.getDataList().get(i).getImgDataList().size() > NumConstant.ZERO) {
// 根据原始事件ID,物理删除 - 事件数据图片数据
events[i] = formDTO.getDataList().get(i).getEventId();
for (int j = NumConstant.ZERO; j < formDTO.getDataList().get(i).getImgDataList().size(); j++){
for (int j = NumConstant.ZERO; j < formDTO.getDataList().get(i).getImgDataList().size(); j++) {
// 新增 中央区-事件数据图片数据 表
ScreenEventImgDataEntity imgDataEntity = new ScreenEventImgDataEntity();
imgDataEntity.setEventId(formDTO.getDataList().get(i).getImgDataList().get(j).getEventId());
@ -197,7 +202,7 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
}
}
}
if (isImgUrl){
if (isImgUrl) {
screenEventImgDataDao.delEventImgDataByEvent(events);
screenEventImgDataDao.batchInsertEventImgData(eventImgDataList);
}
@ -209,11 +214,11 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
@Override
@Transactional(rollbackFor = Exception.class)
public void insertDifficultyData(DifficultyDataFormDTO formDTO, String customerId) {
if(formDTO.getIsFirst()){
if (formDTO.getIsFirst()) {
//直接删除当前客户下所有的数据
screenDifficultyDataDao.deleteDifficultyData(customerId);
}
if (null != formDTO && !CollectionUtils.isEmpty(formDTO.getDataList())){
if (null != formDTO && !CollectionUtils.isEmpty(formDTO.getDataList())) {
screenDifficultyDataDao.batchInsertDifficultyData(formDTO.getDataList(), customerId);
}
}
@ -229,7 +234,10 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
} while (deleteNum != NumConstant.ZERO);
}
if (!CollectionUtils.isEmpty(formDTO.getDataList())) {
screenCpcBaseDataDao.batchInsertCpcBaseData(formDTO.getDataList(), customerId);
List<List<CpcBaseDataFormDTO>> pageByOneHundred = ListUtils.partition(formDTO.getDataList(), NumConstant.ONE_HUNDRED);
pageByOneHundred.forEach(one -> {
screenCpcBaseDataDao.batchInsertCpcBaseData(one, customerId);
});
}
}
@ -305,9 +313,9 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
}
if (!CollectionUtils.isEmpty(formDTO.getDataList())) {
List<CustomerAgencyFormDTO> pidIsZeroList = formDTO.getDataList().stream().filter(d -> d.getPid().equals(NumConstant.ZERO_STR) || "".equals(d.getPid())).collect(Collectors.toList());
if (pidIsZeroList.size()>=NumConstant.ONE){
if (pidIsZeroList.size() > NumConstant.ONE) {
Object o = JSONObject.toJSON(pidIsZeroList);
throw new RenException("多个pid为【0】的数据:"+o.toString());
throw new RenException("多个pid为【0】的数据:" + o.toString());
}
screenCustomerAgencyDao.batchInsertCustomerAgency(formDTO.getDataList(), customerId);
}
@ -339,9 +347,9 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
} while (deleteNum != NumConstant.ZERO);
}
if (!CollectionUtils.isEmpty(formDTO.getDataList())) {
if (formDTO.getDataList().size() > NumConstant.ZERO){
if (formDTO.getDataList().size() > NumConstant.ZERO) {
String[] orgIds = new String[formDTO.getDataList().size()];
for (int i = NumConstant.ZERO; i < formDTO.getDataList().size(); i++){
for (int i = NumConstant.ZERO; i < formDTO.getDataList().size(); i++) {
orgIds[i] = formDTO.getDataList().get(i).getOrgId();
}
@ -356,11 +364,11 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
// 定义本月待添加数据的集合
List<ScreenUserJoinEntity> curMonthJoinEntityList = new ArrayList<>();
// 增加率计算
if (null != lastMonthJoinList && lastMonthJoinList.size() > NumConstant.ZERO){
if (null != lastMonthJoinList && lastMonthJoinList.size() > NumConstant.ZERO) {
// 存在上个月的数据 (本月-上月)/上月 *100
for (int i = NumConstant.ZERO; i < formDTO.getDataList().size(); i++){
for (int j = NumConstant.ZERO; j < lastMonthJoinList.size(); j++){
if (formDTO.getDataList().get(i).getOrgId().equals(lastMonthJoinList.get(j).getOrgId())){
for (int i = NumConstant.ZERO; i < formDTO.getDataList().size(); i++) {
for (int j = NumConstant.ZERO; j < lastMonthJoinList.size(); j++) {
if (formDTO.getDataList().get(i).getOrgId().equals(lastMonthJoinList.get(j).getOrgId())) {
ScreenUserJoinEntity entity = ConvertUtils.sourceToTarget(formDTO.getDataList().get(i), ScreenUserJoinEntity.class);
entity.setJoinTotalUpRate(this.calculateGrowthRateNumber(lastMonthJoinList.get(i).getJoinTotal(), formDTO.getDataList().get(j).getJoinTotal()));
entity.setJoinTotalUpFlag(this.calculateGrowthRateFlag(lastMonthJoinList.get(i).getJoinTotal(), formDTO.getDataList().get(j).getJoinTotal()));
@ -376,8 +384,8 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
// 计算增长率后的 待新增数据
BigDecimal zero = new BigDecimal(NumConstant.ZERO);
// 不存在上个月的数据
for (int i = NumConstant.ZERO; i < formDTO.getDataList().size(); i++){
ScreenUserJoinEntity entity = ConvertUtils.sourceToTarget(formDTO.getDataList().get(i), ScreenUserJoinEntity.class);
for (int i = NumConstant.ZERO; i < formDTO.getDataList().size(); i++) {
ScreenUserJoinEntity entity = ConvertUtils.sourceToTarget(formDTO.getDataList().get(i), ScreenUserJoinEntity.class);
entity.setJoinTotalUpRate(zero);
entity.setJoinTotalUpFlag("");
entity.setAvgIssueUpRate(zero);
@ -392,14 +400,37 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
}
}
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
@Transactional(rollbackFor = Exception.class)
public Integer initBizOrg(CustomerBizOrgFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
List<ScreenCustomerAgencyEntity> entityList = screenCustomerAgencyDao.selectListAgencyInfo(formDTO.getCustomerId());
List<ScreenCustomerBizOrgEntity> list = new ArrayList<>();
if (CollectionUtils.isEmpty(entityList)) {
return 0;
}
entityList.forEach(o -> {
ScreenCustomerBizOrgEntity entity = new ScreenCustomerBizOrgEntity();
entity.setCustomerId(o.getCustomerId());
entity.setOrgId(o.getAgencyId());
entity.setBizType(formDTO.getBizType());
list.add(entity);
});
screenCustomerBizOrgDao.deleteByBizType(formDTO);
return screenCustomerBizOrgDao.batchInsert(list);
}
/**
* 获取当前日期的前一个月的日期
*
* @param
* @return java.lang.String[]
* @Author zhangyong
* @Date 15:33 2020-08-21
**/
private String[] lastMonthDate(){
private String[] lastMonthDate() {
String[] date = new String[NumConstant.TWO];
//Java获取当前日期的前一个月的日期
Calendar calendar = Calendar.getInstance();
@ -407,8 +438,9 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + NumConstant.ONE;
date[NumConstant.ZERO] = String.valueOf(year);
date[NumConstant.ONE] = String.valueOf(month);;
if (NumConstant.TEN >= month){
date[NumConstant.ONE] = String.valueOf(month);
;
if (NumConstant.TEN >= month) {
date[NumConstant.ONE] = NumConstant.ZERO_STR + month;
}
return date;
@ -417,8 +449,8 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
/**
* 计算 本月数值 相较于 上月数值的增长率
*
* @param old 上月数值
* @param now 本月数值
* @param old 上月数值
* @param now 本月数值
* @return java.math.BigDecimal
* @Author zhangyong
* @Date 15:38 2020-08-21
@ -455,8 +487,8 @@ public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
/**
* 计算 本月数值 相较于 上月数值的增长率 得出标识
*
* @param old 上月数值
* @param now 本月数值
* @param old 上月数值
* @param now 本月数值
* @return java.util.String
* @Author zhangyong
* @Date 15:38 2020-08-21

65
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerPartymemberServiceImpl.java

@ -41,6 +41,7 @@ import com.epmet.service.partymember.PartyMemberService;
import com.epmet.service.stats.DimCustomerPartymemberService;
import com.epmet.service.stats.DimCustomerService;
import com.epmet.service.stats.DimGridService;
import com.epmet.util.DimIdGenerator;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
@ -49,10 +50,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -134,32 +132,49 @@ public class DimCustomerPartymemberServiceImpl extends BaseServiceImpl<DimCustom
*/
@Override
public Boolean statsPartyMember(CustomerIdAndDateIdFormDTO customerIdAndDateIdFormDTO) {
List<String> allCustomerId = dimCustomerService.getAllCustomerId();
if (CollectionUtils.isEmpty(allCustomerId)){
String customerIdOne = customerIdAndDateIdFormDTO.getCustomerId();
List<String> customerIds = new ArrayList<>();
List<String> dateIds = new ArrayList<>();
if (StringUtils.isNotBlank(customerIdOne)){
customerIds.add(customerIdOne);
}else {
customerIds = dimCustomerService.getAllCustomerId();
}
if (CollectionUtils.isEmpty(customerIds)){
throw new RenException(StatsConstant.CUSTOMER_INFO_NULL);
}
allCustomerId.forEach(customerId -> {
String dateId = customerIdAndDateIdFormDTO.getDateId();
List<DimCustomerPartyMemberFormDTO> partyMemberList = partyMemberService.selectPartyMemberInfo(customerId, dateId);
if (CollectionUtils.isEmpty(partyMemberList)){
log.warn(String.format(StatsConstant.PARTY_INFO_LIST,customerId));
return;
if ((StringUtils.isBlank(customerIdAndDateIdFormDTO.getStartDate()) && StringUtils.isBlank(customerIdAndDateIdFormDTO.getEndDate()))){
if (StringUtils.isNotBlank(customerIdAndDateIdFormDTO.getDateId())){
dateIds.add(customerIdAndDateIdFormDTO.getDateId());
}else {
dateIds.add(DimIdGenerator.getDateDimId(DateUtils.addDateDays(new Date(), -1)));
}
List<String> gridIds = partyMemberList.stream().map(party -> party.getGridId()).distinct().collect(Collectors.toList());
List<GridBelongAgencyResultDTO> agencyInfos = dimGridService.selectGridBelongAgencyInfo(gridIds);
TimeListResultDTO timeList = DateUtils.getTimeList(dateId);
partyMemberList.forEach(party -> {
BeanUtils.copyProperties(timeList,party);
agencyInfos.forEach(agency -> {
if (party.getGridId().equals(agency.getGridId())){
party.setAgencyId(agency.getAgencyId());
party.setParentId(agency.getParentId());
party.setPids(agency.getPids());
}
}else {
dateIds = DateUtils.getDaysBetween(customerIdAndDateIdFormDTO.getStartDate(), customerIdAndDateIdFormDTO.getEndDate());
}
List<String> finalDateIds = dateIds;
customerIds.forEach(customerId -> {
finalDateIds.forEach(dateId -> {
List<DimCustomerPartyMemberFormDTO> partyMemberList = partyMemberService.selectPartyMemberInfo(customerId, dateId);
if (CollectionUtils.isEmpty(partyMemberList)){
log.warn(String.format(StatsConstant.PARTY_INFO_LIST,customerId));
return;
}
List<String> gridIds = partyMemberList.stream().map(party -> party.getGridId()).distinct().collect(Collectors.toList());
List<GridBelongAgencyResultDTO> agencyInfos = dimGridService.selectGridBelongAgencyInfo(gridIds);
TimeListResultDTO timeList = DateUtils.getTimeList(dateId);
partyMemberList.forEach(party -> {
BeanUtils.copyProperties(timeList,party);
agencyInfos.forEach(agency -> {
if (party.getGridId().equals(agency.getGridId())){
party.setAgencyId(agency.getAgencyId());
party.setParentId(agency.getParentId());
party.setPids(agency.getPids());
}
});
});
delAndInsertParty(partyMemberList,customerId,dateId);
});
delAndInsertParty(partyMemberList,customerId,dateId);
});
return true;
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/ScoreConstants.java

@ -3,7 +3,7 @@ package com.epmet.support.normalizing;
import java.math.BigDecimal;
/**
* 分值常量
* 分值常量 归一区间
*/
public class ScoreConstants {

48
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java

@ -1,6 +1,11 @@
package com.epmet.support.normalizing.batch;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.support.normalizing.BigDecimalScoreCalculator;
import com.epmet.support.normalizing.Correlation;
import com.epmet.support.normalizing.ScoreCalculator;
import com.epmet.support.normalizing.ScoreConstants;
import java.math.BigDecimal;
import java.math.RoundingMode;
@ -58,15 +63,28 @@ public class BatchScoreCalculator {
String sampleId = vo.getSampleId();
//归一后的值
BigDecimal normalizeValue;// = scoreCalculator.normalize(getFinalSampleValue(vo.getSampleValue(), threshold));
//如果不需要归一 则 直接value*权重
if (idx.isScore()) {
normalizeValue = getFinalSampleValue(vo.getSampleValue(), threshold);
} else {
normalizeValue = scoreCalculator.normalize(getFinalSampleValue(vo.getSampleValue(), threshold));
}
//反正切函数 [-pi/2,pi/2]
BigDecimal minScoreValue = idx.getScoreCalculator().getMinScore();
BigDecimal maxScoreValue = idx.getScoreCalculator().getMaxScore();
if (idx.getScoreCalculator().getMaxValue().compareTo(idx.getScoreCalculator().getMinValue()) == 0) {
normalizeValue = new BigDecimal(Math.atan(new Double(vo.getSampleValue().toString())) / Math.PI * 100).setScale(6, RoundingMode.HALF_UP);
//*((max-min)/ (Math.PI/2))+min
//Math.atan(new Double(vo.getSampleValue().toString()))*
normalizeValue = new BigDecimal(Math.atan(new Double(getFinalSampleValue(vo.getSampleValue(), threshold).toString())))
.multiply(
(maxScoreValue.subtract(minScoreValue).divide(new BigDecimal(Math.PI / 2), 10, RoundingMode.HALF_UP)))
.add(minScoreValue).setScale(6, RoundingMode.HALF_UP);
//
if (scoreCalculator.getCorrelation().getCode().equals(Correlation.NEGATIVE)) {
normalizeValue = maxScoreValue.subtract(normalizeValue);
}
}else {
//如果不需要归一 则 直接value*权重
if (idx.isScore()) {
vo.setSampleValue(new BigDecimal(vo.getSampleValue().toString()).compareTo(NumConstant.ZERO_DECIMAL) == NumConstant.ZERO ? ScoreConstants.MIN_SCORE : new BigDecimal(vo.getSampleValue().toString()));
normalizeValue = getFinalSampleValue(vo.getSampleValue(), threshold);
} else {
normalizeValue = scoreCalculator.normalize(getFinalSampleValue(vo.getSampleValue(), threshold));
}
}
BigDecimal score = normalizeValue.multiply(weight).setScale(6, RoundingMode.HALF_UP);
CalculateResult result = scoreCountOfSamples.get(sampleId);
@ -81,7 +99,7 @@ public class BatchScoreCalculator {
}
IndexScoreVo sampleScore = new IndexScoreVo(idx.getIndexId(), idx.getAllParentIndexCode(), String.valueOf(vo.getSampleValue()), normalizeValue, idx.getWeight());
result.getDetails().add(sampleScore);
result.setTotalScore(result.getTotalScore().add(score).setScale(6, RoundingMode.HALF_UP));
result.setTotalScore(result.getTotalScore().add(score));
}
}
@ -105,4 +123,16 @@ public class BatchScoreCalculator {
? bdRealValue
: threshold;
}
public static void main(String[] args) {
List<IndexInputVO> indexInputVOS = new ArrayList<>();
String jsonStr = "{\"allParentIndexCode\":\"quanquxiangguan:zhilinengli\",\"indexId\":\"suoyoujiedaozlnlpjz\",\"indexValueVOs\":[{\"sampleId\":\"7b6f9a9f9f38d5f9fa7ce94a93d6eb28\",\"sampleValue\":69.830369}],\"score\":true,\"scoreCalculator\":{\"coefficient\":0,\"correlation\":\"POSITIVE\",\"maxScore\":100,\"maxValue\":69.830369,\"minScore\":60,\"minValue\":69.830369},\"threshold\":-1.0000,\"weight\":0.8000}";
IndexInputVO vo = JSON.parseObject(jsonStr, IndexInputVO.class);
BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(new BigDecimal("69.830369"), new BigDecimal("69.830369"), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(Correlation.POSITIVE.getCode()));
vo.setScoreCalculator(sc);
indexInputVOS.add(vo);
BatchScoreCalculator sc2 = new BatchScoreCalculator();
HashMap<String, CalculateResult> scoreTotalOfSampleId = sc2.getScoreTotalOfSampleId(indexInputVOS);
System.out.println(JSON.toJSONString(scoreTotalOfSampleId));
}
}

10
epmet-module/data-statistical/data-statistical-server/src/main/resources/logback-spring.xml

@ -149,6 +149,16 @@
<appender-ref ref="WARN_FILE"/>
<appender-ref ref="ERROR_FILE"/>
</root>
<!-- 屏蔽logger -->
<logger name="org.springframework" level="INFO"/>
<logger name="org.apache" level="WARN"/>
<logger name="org.mybatis.spring" level="WARN"/>
<logger name="io.netty" level="WARN"/>
<logger name="org.redisson.connection" level="WARN"/>
<logger name="org.hibernate.validator" level="WARN"/>
<!-- 屏蔽jdk日志 -->
<logger name="java" level="WARN"/>
<!-- 屏蔽logger 结束-->
</springProfile>
<!-- 生产环境 -->

214
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectLogDailyDao.xml

@ -23,7 +23,7 @@
AND da.`LEVEL` = #{level}
WHERE
fopld.IS_ACTIVE = 0
AND fopld.ACTION_CODE = 'transfer'
AND (fopld.ACTION_CODE = 'transfer' OR fopld.ACTION_CODE = 'created')
AND fopld.MONTH_ID = #{monthId}
AND fopld.CUSTOMER_ID = #{customerId}
GROUP BY
@ -125,7 +125,6 @@
FROM
fact_origin_project_log_daily fopld
INNER JOIN dim_agency da ON fopld.AGENCY_ID = da.ID
AND da.`LEVEL` = #{level}
WHERE
fopld.IS_ACTIVE = 0
AND fopld.ACTION_CODE = 'transfer'
@ -160,6 +159,61 @@
GROUP BY AGENCY_ID
</select>
<!-- 评价周期内被吹哨项目数-->
<select id="selectAgencyWhistledCount" resultType="com.epmet.dto.extract.result.ProjectParticipatedAgencyResultDTO">
SELECT
AGENCY_ID,
COUNT(DISTINCT PROJECT_ID) AS count
FROM
fact_origin_project_log_daily
WHERE DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND IS_ACTIVE = '0'
<if test='null != dimId and "" != dimId.trim()'>
AND MONTH_ID = #{dimId}
AND NOT EXISTS(
SELECT ID
FROM fact_origin_project_log_daily
WHERE DEL_FLAG = '0'
AND MONTH_ID <![CDATA[ < ]]> #{dimId}
AND IS_ACTIVE = '0'
<if test="agencies != null and agencies.size() > 0">
<foreach collection="agencies" item="agencyId" open="AND (" close=" )" separator=" OR ">
AGENCY_ID = #{agencyId}
</foreach>
</if>
)
</if>
<if test="agencies != null and agencies.size() > 0">
<foreach collection="agencies" item="agencyId" open="AND (" close=" )" separator=" OR ">
AGENCY_ID = #{agencyId}
</foreach>
</if>
GROUP BY AGENCY_ID
</select>
<!-- 评价周期内被吹哨且被办结(无论是哪一级办结)的项目数 -->
<select id="selectWhistledAgencyClosedProjectCount" resultType="com.epmet.dto.extract.result.ProjectParticipatedAgencyResultDTO">
SELECT
log.AGENCY_ID,
COUNT(DISTINCT log.PROJECT_ID) AS count
FROM
fact_origin_project_log_daily log
LEFT JOIN fact_origin_project_main_daily project ON log.PROJECT_ID = project.ID AND project.DEL_FLAG = '0' AND project.CUSTOMER_ID = #{customerId}
WHERE log.DEL_FLAG = '0'
AND project.PROJECT_STATUS LIKE 'close%'
AND log.CUSTOMER_ID = #{customerId}
AND log.IS_ACTIVE = '0'
<if test='null != dimId and "" != dimId.trim()'>
AND log.MONTH_ID = #{dimId}
</if>
<if test="agencies != null and agencies.size() > 0">
<foreach collection="agencies" item="agencyId" open="AND (" close=" )" separator=" OR ">
log.AGENCY_ID = #{agencyId}
</foreach>
</if>
GROUP BY log.AGENCY_ID
</select>
<!-- 查询机关办结次数 -->
<select id="selectAgencyHandledProjectCount" resultType="com.epmet.dto.extract.result.ProjectParticipatedAgencyResultDTO">
SELECT
@ -177,11 +231,64 @@
</if>
<if test='null != dimId and "" != dimId.trim()'>
AND ((log.ID IS NOT NULL AND log.MONTH_ID <![CDATA[>=]]> #{dimId}) OR log.ID IS NULL )
AND log.ID IS NOT NULL AND log.MONTH_ID = #{dimId}
</if>
GROUP BY SUBSTRING_INDEX(main.FINISH_ORG_IDS,':',1)
</select>
<!-- 查询评价周期内各级别机关办结的项目Id -->
<select id="selectProjectIdHandledByAgency" resultType="com.epmet.dto.extract.result.ProjectParticipatedAgencyResultDTO">
SELECT
ID AS projectId,
SUBSTRING_INDEX(FINISH_ORG_IDS,':',1) AS agencyId
FROM
fact_origin_project_main_daily
WHERE
DEL_FLAG = '0'
AND ID IN (
SELECT DISTINCT PROJECT_ID FROM fact_origin_project_log_daily
WHERE DEL_FLAG = '0' AND CUSTOMER_ID = #{customerId}
AND ACTION_CODE = 'close'
<if test='null != dimId and "" != dimId'>
AND MONTH_ID = #{dimId}
</if>
)
ORDER BY agencyId
</select>
<!-- 计算每个办结项目的总耗时 -->
<select id="selectProjectCostTime" resultType="com.epmet.dto.extract.result.ProjectParticipatedAgencyResultDTO">
SELECT
DISTINCT
log1.PROJECT_ID,
IF(
TIMESTAMPDIFF( DAY, log2.createdDate, DATE_FORMAT( log1.DATE_ID, '%Y-%m-%d' ) ) = 0,
1,
TIMESTAMPDIFF( DAY, log2.createdDate, DATE_FORMAT( log1.DATE_ID, '%Y-%m-%d' ) )
) * 8 * 60 AS count
FROM
fact_origin_project_log_daily log1
LEFT JOIN (
SELECT
ID ,
DATE_FORMAT( DATE_ID, '%Y-%m-%d' ) AS createdDate
FROM
fact_origin_project_main_daily
WHERE
DEL_FLAG = '0'
<foreach collection="projectIds" item="projectId" open="AND ( " separator=" OR " close=" ) ">
ID = #{projectId}
</foreach>
AND PROJECT_STATUS = 'closed'
) log2 ON log1.PROJECT_ID = log2.ID
WHERE
log1.DEL_FLAG = '0'
<foreach collection="projectIds" item="projectId" open="AND ( " separator=" OR " close=" ) ">
log1.PROJECT_ID = #{projectId}
</foreach>
AND log1.IS_ACTIVE = '1'
AND log1.ACTION_CODE = 'close'
</select>
<select id="selectGridResponse" resultType="com.epmet.dto.extract.result.OrgStatisticsResultDTO">
SELECT a.ORG_ID,
a.count AS "sum",
@ -317,4 +424,105 @@
GROUP BY
AGENCY_ID
</select>
<select id="selectDeptClosedProject" resultType="com.epmet.dto.extract.result.OrgStatisticsResultDTO">
SELECT
a.ORG_ID,
a.count AS "sum",
IFNULL(b.count,0) AS "count"
FROM
(SELECT
ORG_ID,
COUNT( ID ) AS "count"
FROM
fact_origin_project_log_daily
WHERE
ORG_TYPE = 'department'
AND IS_ACTIVE = '0'
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
GROUP BY
ORG_ID) a
LEFT JOIN
(SELECT
ORG_ID,
COUNT( ID ) AS "count"
FROM
fact_origin_project_log_daily
WHERE
ORG_TYPE = 'department'
AND ACTION_CODE = 'close'
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
GROUP BY
ORG_ID) b ON a.ORG_ID = b.ORG_ID
</select>
<select id="selectDeptSatisfaction" resultType="com.epmet.dto.extract.result.OrgStatisticsResultDTO">
SELECT
ORG_ID,
COUNT( a.PROJECT_ID ) AS "count",
SUM( IFNULL( b.score, 80 ) ) AS "ratio"
FROM
(SELECT
ORG_ID,
PROJECT_ID
FROM
fact_origin_project_log_daily
WHERE
ORG_TYPE = 'department'
AND ACTION_CODE = 'close'
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}) a
LEFT JOIN
(SELECT
PROJECT_ID,
AVG( CASE ACTION_CODE WHEN 'bad' THEN 60 WHEN 'perfect' THEN 100 ELSE 80 END ) AS score
FROM
fact_origin_project_log_daily
WHERE
( ACTION_CODE = 'bad' OR ACTION_CODE = 'good' OR ACTION_CODE = 'perfect' )
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
GROUP BY
PROJECT_ID) b ON a.PROJECT_ID = b.PROJECT_ID
GROUP BY ORG_ID
</select>
<select id="selectGridClosed" resultType="com.epmet.dto.extract.result.OrgStatisticsResultDTO">
SELECT
a.ORG_ID,
a.count AS "sum",
IFNULL(b.count,0)AS "count"
FROM
(SELECT ORG_ID,
COUNT(DISTINCT PROJECT_ID) AS "count"
FROM fact_origin_project_log_daily
WHERE( ACTION_CODE = 'created' OR ACTION_CODE = 'transfer')
AND IS_ACTIVE = 0
AND ORG_TYPE = 'grid'
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
GROUP BY ORG_ID) a
LEFT JOIN
(SELECT fl.ORG_ID,
COUNT(DISTINCT fl.PROJECT_ID) AS "count"
FROM fact_origin_project_log_daily fl
INNER JOIN fact_origin_project_main_daily fm ON fl.PROJECT_ID = fm.ID AND fm.PROJECT_STATUS = 'closed'
WHERE( fl.ACTION_CODE = 'created' OR fl.ACTION_CODE = 'transfer')
AND fl.IS_ACTIVE = 0
AND fl.ORG_TYPE = 'grid'
AND fl.CUSTOMER_ID = #{customerId}
AND fl.MONTH_ID = #{monthId}
GROUP BY fl.ORG_ID) b ON a.ORG_ID = b.ORG_ID
</select>
<select id="selectNotReturn" resultType="com.epmet.dto.extract.result.TransferRightRatioResultDTO">
SELECT
DISTINCT(PROJECT_ID) AS projectId
FROM
fact_origin_project_log_daily
WHERE
ORG_TYPE = 'grid'
AND ACTION_CODE != 'return'
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
</select>
</mapper>

11
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectMainDailyDao.xml

@ -427,4 +427,15 @@
</foreach>
</if>
</select>
<select id="selectTransferRightRatio" resultType="com.epmet.dto.extract.result.TransferRightRatioResultDTO">
SELECT
ID as projectId,
GRID_ID
FROM
fact_origin_project_main_daily
WHERE
CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
</select>
</mapper>

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

@ -34,7 +34,7 @@
</select>
<!-- 在插入之前,先删除所有与这个项目相关的历时信息 -->
<delete id="deleteByProjectId">
<delete id="deleteByProjectIds">
DELETE FROM
fact_origin_project_org_period_daily
WHERE
@ -54,7 +54,9 @@
FROM
fact_origin_project_org_period_daily f
INNER JOIN dim_agency da ON f.ORG_ID = da.ID
<if test='"dept" != orgType'>
AND da.`LEVEL` = #{level}
</if>
WHERE
f.ORG_TYPE = #{orgType}
AND DATE_FORMAT(INFORMED_DATE, '%Y%m') = #{monthId}
@ -180,4 +182,21 @@
GROUP BY ORG_ID
</select>
<select id="selectDeptHandle" resultType="com.epmet.dto.extract.result.OrgStatisticsResultDTO">
SELECT
fp.ORG_ID,
SUM( TIMESTAMPDIFF( MINUTE, ( DATE_FORMAT( fp.INFORMED_DATE, '%Y-%m-%d %H:%i' )),
( DATE_FORMAT( fp.PERIOD_TILL_REPLY_FIRSTLY, '%Y-%m-%d %H:%i' )) ) ) AS "sum",
COUNT( fp.ID ) AS "count"
FROM
fact_origin_project_org_period_daily fp
INNER JOIN fact_origin_project_main_daily fm ON fp.PROJECT_ID = fm.ID
AND fm.PROJECT_STATUS = 'closed'
WHERE
fp.ORG_TYPE = 'dept'
AND fp.CUSTOMER_ID = #{customerId}
AND fm.MONTH_ID = #{monthId}
GROUP BY
fp.ORG_ID
</select>
</mapper>

1
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencySubScoreDao.xml

@ -56,6 +56,7 @@
DEL_FLAG = '0'
AND data_type = #{dataType}
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId,jdbcType=VARCHAR}
AND ALL_PARENT_INDEX_CODE = #{allIndexCodePath,jdbcType=VARCHAR}
</select>
</mapper>

1
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunitySubScoreDao.xml

@ -54,6 +54,7 @@
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId,jdbcType=VARCHAR}
AND ALL_PARENT_INDEX_CODE = #{allIndexCodePath,jdbcType=VARCHAR}
</select>
</mapper>

1
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/DeptSubScoreDao.xml

@ -79,6 +79,7 @@
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId,jdbcType=VARCHAR}
AND ALL_PARENT_INDEX_CODE = #{allIndexCodePath,jdbcType=VARCHAR}
</select>
</mapper>

1
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridSubScoreDao.xml

@ -86,6 +86,7 @@
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId,jdbcType=VARCHAR}
AND ALL_PARENT_INDEX_CODE = #{allIndexCodePath,jdbcType=VARCHAR}
</select>
</mapper>

1
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml

@ -80,6 +80,7 @@
<select id="selectListAgencyInfo" parameterType="map" resultType="com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity">
SELECT
CUSTOMER_ID,
AGENCY_ID agencyId,
AGENCY_NAME agencyName,
PIDS pids

39
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerBizOrgDao.xml

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.evaluationindex.screen.ScreenCustomerBizOrgDao">
<delete id="deleteByBizType">
delete from screen_customer_biz_org
where CUSTOMER_ID = #{customerId}
and BIZ_TYPE = #{bizType,jdbcType=VARCHAR}
</delete>
<insert id="batchInsert">
insert into screen_customer_biz_org
(
ID,
CUSTOMER_ID,
ORG_ID,
BIZ_TYPE,
DEL_FLAG,
REVISION,
CREATED_BY,
CREATED_TIME,
UPDATED_BY,
UPDATED_TIME
) values
<foreach collection="list" item="item" separator=",">
(
(SELECT REPLACE(UUID(), '-', '') AS id),
#{item.customerId},
#{item.orgId},
#{item.bizType},
0,
0,
'APP_USER',
now(),
'APP_USER',
now()
)
</foreach>
</insert>
</mapper>

1
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimDepartmentDao.xml

@ -60,7 +60,6 @@
FROM
dim_department dd
INNER JOIN dim_agency da ON dd.AGENCY_ID = da.ID
AND da.`LEVEL` = 'district'
WHERE
dd.CUSTOMER_ID = #{customerId}
</select>

61
epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/RedissonTest.java

@ -0,0 +1,61 @@
package com.epmet.stats.test;
import com.epmet.DataStatsApplication;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.concurrent.TimeUnit;
/**
* descredisson测试类
*/
@Slf4j
@RunWith(value = SpringRunner.class)
@SpringBootTest(classes = {DataStatsApplication.class})
public class RedissonTest {
@Autowired
private RedissonClient redissonClient;
@Test
public void lockTest() {
//获取一个名为 lockName 的锁实例
RLock lock = redissonClient.getLock("lockName");
try {
// 尝试加锁(推荐使用)
// 参数1 等待时长 waitTime:5 等待时长是5秒 如果5秒内还获取不到锁 则返回false,
// 参数2 持有时长 leaseTime:5 持有锁时长超过5秒 就释放锁 此时如果继续lock.unlock()会抛出异常
// 参数3 时间单位
boolean bs = lock.tryLock(5, 6, TimeUnit.SECONDS);
//如果获取不到锁 会一直阻塞到着 直至获取到锁 不推荐使用
//lock.lock();
//异步方式
/* RFuture<Void> future = lock.lockAsync();
if (future.isSuccess()){
//todo something
}*/
if (bs) {
// 业务代码
System.out.println("进入业务代码: " + 123);
} else {
Thread.sleep(300);
}
} catch (Exception e) {
log.error("lockTest exception", e);
} finally {
//判断是否是当前线程 持有锁
if (lock.isHeldByCurrentThread()) {
lock.unlock();
}
}
}
}

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

Loading…
Cancel
Save