Browse Source

Merge remote-tracking branch 'origin/dev_screen_data' into dev_temp

# Conflicts:
#	epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
dev
yinzuomei 5 years ago
parent
commit
e117cfdc75
  1. 66
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/CustomerApplicationRunner.java
  2. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  3. 2
      epmet-gateway/pom.xml
  4. 4
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/IndexCalConstant.java
  5. 51
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubAgencyScoreAvgResultDTO.java
  6. 96
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcollect/form/GridPartyMemberDataDetailFormDTO.java
  7. 77
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcollect/form/GridPartyMemberDataFormDTO.java
  8. 18
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexGridScoreDTO.java
  9. 105
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screencoll/form/DifficultyDataDetailFormDTO.java
  10. 90
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screencoll/form/DifficultyDataFormDTO.java
  11. 33
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/constant/OrgTypeConstant.java
  12. 14
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java
  13. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactIndexCollectController.java
  14. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenCollController.java
  15. 29
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java
  16. 30
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/DeptScoreDao.java
  17. 1
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexGovrnAblityDeptMonthlyDao.java
  18. 17
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexPartyAblityCpcMonthlyDao.java
  19. 13
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexCommunityScoreDao.java
  20. 31
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexGridScoreDao.java
  21. 11
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java
  22. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerDeptDao.java
  23. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerGridDao.java
  24. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenDifficultyDataDao.java
  25. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/eum/IndexCodeEnum.java
  26. 28
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java
  27. 1
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexModel.java
  28. 18
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateDistrictService.java
  29. 77
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/CpcIndexCalculateServiceImpl.java
  30. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/DeptScoreServiceImpl.java
  31. 7
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java
  32. 406
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java
  33. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java
  34. 12
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/FactIndexCollectService.java
  35. 352
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java
  36. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCollService.java
  37. 15
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCollServiceImpl.java
  38. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java
  39. 42
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml
  40. 18
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CpcScoreDao.xml
  41. 42
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/DeptScoreDao.xml
  42. 7
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml
  43. 20
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexCommunityScoreDao.xml
  44. 21
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexGridScoreDao.xml
  45. 10
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml
  46. 11
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerDeptDao.xml
  47. 12
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerGridDao.xml
  48. 2
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenDifficultyDataDao.xml
  49. 3
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ExternalAppFormDTO.java
  50. 17
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalAppController.java
  51. 1
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalAppSecretDao.java
  52. 2
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalAppService.java
  53. 9
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppServiceImpl.java
  54. 7
      epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppSecretDao.xml

66
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/CustomerApplicationRunner.java

@ -0,0 +1,66 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
* <p>
* https://www.renren.io
* <p>
* 版权所有侵权必究
*/
package com.epmet.commons.tools.aspect;
import com.epmet.commons.tools.dto.form.DingTalkTextMsg;
import com.epmet.commons.tools.enums.EnvEnum;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.utils.SpringContextUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.cloud.commons.util.InetUtils;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
/**
* 应用 启动健康检查 通知类
* CustomerApplicationRunner
*
* @author Mark sunlightcs@gmail.com
* @since 1.0.0
*/
@Component
@Order(value = 99)
public class CustomerApplicationRunner implements ApplicationRunner {
private static Logger logger = LogManager.getLogger(CustomerApplicationRunner.class);
@Value("${spring.application.name}")
private String appName;
@Override
public void run(ApplicationArguments args) {
//发送启动成功消息
EnvEnum currentEnv = EnvEnum.getCurrentEnv();
if (!EnvEnum.DEV.getCode().equals(currentEnv.getCode())) {
InetUtils inetUtils = SpringContextUtils.getBean(InetUtils.class);
String serverIp = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
//开发小组 群机器人地址
String url = "https://oapi.dingtalk.com/robot/send?access_token=ffd7c972b0525e249283df1a16b65a8b9d0012601f3a458dfc588c2eac497bb5";
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(EnvEnum.getCurrentEnv().getName())
.append("【")
.append(appName)
.append("】")
.append("ip地址: ")
.append(serverIp)
.append("部署完毕!");
DingTalkTextMsg msg = new DingTalkTextMsg();
msg.setWebHook(url);
msg.setAtAll(true);
msg.setContent(stringBuilder.toString());
Result<String> stringResult = HttpClientManager.getInstance().sendPostByJSON(url, msg.getMsgContent());
logger.info(stringResult);
}
}
}

1
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java

@ -108,6 +108,7 @@ public enum EpmetErrorCode {
OPER_EXTERNAL_APP_EXISTS(8711, "应用已存在"),
OPER_CUSTOMER_FOOTBAR_EXISTS(8712, "footbar已存在"),
OPER_CUSTOMER_FOOTBAR_NOT_FOUND(8713, "footbar不存在"),
OPER_EXT_APP_SECRET_RESET_FAIL(8712, "秘钥更新失败"),
// 党建声音 前端提示 88段
DRAFT_CONTENT_IS_NULL(8801, "至少需要添加一个段落"),

2
epmet-gateway/pom.xml

@ -182,7 +182,7 @@
<!-- <gateway.routes.data-report-server.uri>http://localhost:8109</gateway.routes.data-report-server.uri>-->
<!-- 29、统计服务 -->
<gateway.routes.data-statistical-server.uri>lb://data-statistical-server</gateway.routes.data-statistical-server.uri>
<!-- <gateway.routes.data-statistical-server.uri>http://localhost:8108</gateway.routes.data-statistical-server.uri>-->
<!--<gateway.routes.data-statistical-server.uri>http://localhost:8108</gateway.routes.data-statistical-server.uri>-->
<!-- 30、内容审核服务 -->
<gateway.routes.epmet-openapi-scan.uri>lb://epmet-openapi-scan</gateway.routes.epmet-openapi-scan.uri>
<!-- <gateway.routes.epmet-openapi-scan.uri>http://localhost:8107</gateway.routes.epmet-openapi-scan.uri>-->

4
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/IndexCalConstant.java

@ -31,6 +31,8 @@ public interface IndexCalConstant {
String STREET_LEVEL = "street";
String DISTRICT_LEVEL = "district";
String COMMUNITY_RELATE = "shequxiangguan";
@ -55,7 +57,9 @@ public interface IndexCalConstant {
String INDEX_DETAIL_LIST_NULL = "指标明细查询集合为空";
String COMMUNITY_PARTY_AVG_NULL = "查询下属所有【社区】的党建能力平均值集合为空";
String GRID_PARTY_AVG_NULL = "查询下属所有【网格】的党建能力平均值集合为空";
String DISTRICT_PARTY_AVG_NULL = "查询【区县】的党建能力平均值集合为空";
String STREET_PUBLISH_ARTICLE_LIST_NULL = "查询【街道】名义发文数量集合为空";
String DISTRICT_PUBLISH_ARTICLE_LIST_NULL = "查询【区/县】名义发文数量集合为空";
String COMMUNITY_PUBLISH_ARTICLE_LIST_NULL = "查询【社区】名义发文数量集合为空";
String INDEX_CODE_NULL = "指标Code未查询出对应字段 【 %s 】";
String STREET_GOVERN_ABILITY_NULL = "查询【街道】治理能力的六个五级指标集合为空";

51
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubAgencyScoreAvgResultDTO.java

@ -0,0 +1,51 @@
package com.epmet.dto.indexcal;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @Author zxc
* @DateTime 2020/9/4 9:32 上午
*/
@Data
public class SubAgencyScoreAvgResultDTO implements Serializable {
private static final long serialVersionUID = 6913351504675726385L;
/**
*
*/
private String customerId;
/**
* 机关ID
*/
private String agencyId;
/**
* 上级组织ID
*/
private String parentId;
/**
* 月度ID
*/
private String monthId;
/**
* 季度ID
*/
private String quarterId;
/**
* 年度ID
*/
private String yearId;
/**
* 分数
*/
private BigDecimal score;
}

96
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcollect/form/GridPartyMemberDataDetailFormDTO.java

@ -0,0 +1,96 @@
package com.epmet.dto.indexcollect.form;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 1党建能力-党员相关指标上报(按照月份) 入参
*
* @author yinzuomei@elink-cn.com
* @date 2020/9/4 16:04
*/
@Data
public class GridPartyMemberDataDetailFormDTO implements Serializable {
private static final long serialVersionUID = 2923515319015973995L;
/**
* 机关id:网格所属的组织id
*/
private String agencyId;
/**
* 网格id
*/
private String gridId;
/**
* yyyyMM
*/
private String monthId;
/**
* yyyyQ1, yyyyQ2, yyyyQ3, yyyyQ4
*/
private String quarterId;
/**
* yyyy
*/
private String yearId;
/**
* 党员提出的话题数
*/
private Integer createTopicCount;
/**
* 党员参与话题数支持反对评论浏览
*/
private Integer joinTopicCount;
/**
* 话题转议题数
*/
private Integer shiftIssueCount;
/**
* 议题转项目数
*/
private Integer shiftProjectCount;
/**
* 参加三会一课次数
*/
private Integer joinThreeMeetsCount;
/**
* 自建群群众人数
*/
private Integer groupUserCount;
/**
* 自建群活跃度-话题数
*/
private Integer groupTopicCount;
/**
* 议题转项目率
*/
private BigDecimal topicToIssueRatio;
/**
* 上级组织Id
*/
private String parentId;
/**
* 党员自建群活跃群众人数(08-24)
*/
private Integer groupActiveUserCount;
/**
* 用户id
*/
private String userId;
}

77
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcollect/form/GridPartyMemberDataFormDTO.java

@ -3,8 +3,11 @@ package com.epmet.dto.indexcollect.form;
import lombok.Data;
import org.apache.poi.hpsf.Decimal;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
/**
* 1党建能力-党员相关指标上报(按照月份) 入参
@ -17,82 +20,14 @@ public class GridPartyMemberDataFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 机关id:网格所属的组织id
* 当为true时后台将删除本月数据
*/
private String agencyId;
/**
* 网格id
*/
private String gridId;
private Boolean isFirst;
/**
* yyyyMM
*/
private String monthId;
/**
* yyyyQ1, yyyyQ2, yyyyQ3, yyyyQ4
*/
private String quarterId;
/**
* yyyy
*/
private String yearId;
/**
* 党员提出的话题数
*/
private Integer createTopicCount;
/**
* 党员参与话题数支持反对评论浏览
*/
private Integer joinTopicCount;
/**
* 话题转议题数
*/
private Integer shiftIssueCount;
/**
* 议题转项目数
*/
private Integer shiftProjectCount;
/**
* 参加三会一课次数
*/
private Integer joinThreeMeetsCount;
/**
* 自建群群众人数
*/
private Integer groupUserCount;
/**
* 自建群活跃度-话题数
*/
private Integer groupTopicCount;
/**
* 议题转项目率
*/
private BigDecimal topicToIssueRatio;
/**
* 上级组织Id
*/
private String parentId;
/**
* 党员自建群活跃群众人数(08-24)
*/
private Integer groupActiveUserCount;
/**
* 用户id
*/
private String userId;
private List<GridPartyMemberDataDetailFormDTO> partyMemberDataList;
}

18
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexGridScoreDTO.java

@ -60,24 +60,24 @@ public class FactIndexGridScoreDTO implements Serializable {
private String monthId;
/**
* 总指数分值
* 年维度Id: yyyy
*/
private BigDecimal totalScore;
private String yearId;
/**
* 党建能力分值
* 1总分0不是默认0
*/
private BigDecimal partyAblityScore;
private String isTotal;
/**
* 治理能力分值
* 分值
*/
private BigDecimal govrnAblityScore;
private BigDecimal score;
/**
* 服务能力分值
* 党建能力dangjiannengli治理能力zhilinengli服务能力fuwunengli网格相关(前三者之和)wanggexiangguan
*/
private BigDecimal serviceAblityScore;
private String indexCode;
/**
* 删除标识 0未删除1已删除
@ -109,4 +109,4 @@ public class FactIndexGridScoreDTO implements Serializable {
*/
private Date updatedTime;
}
}

105
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screencoll/form/DifficultyDataDetailFormDTO.java

@ -0,0 +1,105 @@
package com.epmet.dto.screencoll.form;
import lombok.Data;
import java.io.Serializable;
/**
* 描述一下
*
* @author yinzuomei@elink-cn.com
* @date 2020/9/4 15:43
*/
@Data
public class DifficultyDataDetailFormDTO implements Serializable {
private static final long serialVersionUID = 4893795146396420078L;
/**
* 组织类别 agency组织部门department网格grid
*/
private String orgType;
/**
* 组织Id 可以为网格机关id
*/
private String orgId;
/**
* 上级组织Id
*/
private String parentId;
/**
* 组织名称
*/
private String orgName;
/**
* 事件原Id
*/
private String eventId;
/**
* 事件图片 URL
*/
private String eventImgUrl;
/**
* 事件来源 eg: XXX街道-xx社区-网格
*/
private String eventSource;
/**
* 事件内容
*/
private String eventContent;
/**
* 事件耗时单位分钟
*/
private Integer eventCostTime;
/**
* 事件设计部门数
*/
private Integer eventReOrg;
/**
* 事件类别编码
*/
private String eventCategoryCode;
/**
* 事件状态编码
*/
private String eventStatusCode;
/**
* 事件类别名称
*/
private String eventCategoryName;
/**
* 事件状态描述
*/
private String eventStatusDesc;
/**
* 最近一次操作说明 eg: 转项目结案流转
*/
private String latestOperateDesc;
/**
* 事件被处理次数08-21新增
*/
private Integer eventHandledCount;
/**
* 数据更新至: yyyy|yyyyMM|yyyyMMdd(08-21新增)
*/
private String dataEndTime;
/**
* 所有上级ID用英文逗号分开(8.26新增)
*/
private String allParentIds;
}

90
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screencoll/form/DifficultyDataFormDTO.java

@ -3,6 +3,7 @@ package com.epmet.dto.screencoll.form;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 3难点赌点 入参
@ -11,96 +12,15 @@ import java.io.Serializable;
*/
@Data
public class DifficultyDataFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 组织类别 agency组织部门department网格grid
* 当为true时后台将删除本月数据
*/
private String orgType;
private Boolean isFirst;
/**
* 组织Id 可以为网格机关id
* 难点堵点数据
*/
private String orgId;
private List<DifficultyDataDetailFormDTO> diffcultyDataList;
/**
* 上级组织Id
*/
private String parentId;
/**
* 组织名称
*/
private String orgName;
/**
* 事件原Id
*/
private String eventId;
/**
* 事件图片 URL
*/
private String eventImgUrl;
/**
* 事件来源 eg: XXX街道-xx社区-网格
*/
private String eventSource;
/**
* 事件内容
*/
private String eventContent;
/**
* 事件耗时单位分钟
*/
private Integer eventCostTime;
/**
* 事件设计部门数
*/
private Integer eventReOrg;
/**
* 事件类别编码
*/
private String eventCategoryCode;
/**
* 事件状态编码
*/
private String eventStatusCode;
/**
* 事件类别名称
*/
private String eventCategoryName;
/**
* 事件状态描述
*/
private String eventStatusDesc;
/**
* 最近一次操作说明 eg: 转项目结案流转
*/
private String latestOperateDesc;
/**
* 事件被处理次数08-21新增
*/
private Integer eventHandledCount;
/**
* 数据更新至: yyyy|yyyyMM|yyyyMMdd(08-21新增)
*/
private String dataEndTime;
/**
* 所有上级ID用英文逗号分开(8.26新增)
*/
private String allParentIds;
}

33
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/constant/OrgTypeConstant.java

@ -0,0 +1,33 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
* <p>
* https://www.renren.io
* <p>
* 版权所有侵权必究
*/
package com.epmet.constant;
/**
* 组织类别 常量
*
* @author sun
* @since 1.0.0
*/
public interface OrgTypeConstant {
/**
* 部门
*/
String DEPARTMENT = "department";
/**
* 网格
*/
String GRID = "grid";
/**
* 组织
*/
String AGENCY = "agency";
}

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

@ -17,10 +17,7 @@ import com.epmet.entity.evaluationindex.indexcoll.FactIndexServiceAblityGridMont
import com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity;
import com.epmet.entity.stats.DimAgencyEntity;
import com.epmet.service.StatsDemoService;
import com.epmet.service.evaluationindex.indexcal.DeptScoreService;
import com.epmet.service.evaluationindex.indexcal.GridCorreLationService;
import com.epmet.service.evaluationindex.indexcal.IndexCalculateCommunityService;
import com.epmet.service.evaluationindex.indexcal.IndexCalculateStreetService;
import com.epmet.service.evaluationindex.indexcal.*;
import com.epmet.service.stats.DimAgencyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -56,6 +53,8 @@ public class DemoController {
private IndexCalculateStreetService indexCalculateStreetService;
@Autowired
private DeptScoreService deptScoreService;
@Autowired
private IndexCalculateDistrictService indexCalculateDistrictService;
@GetMapping("testAlarm")
public void testAlarm() {
@ -456,4 +455,11 @@ public class DemoController {
String monthId = "202008";
indexCalculateStreetService.calStreetAll(customerId,monthId);
}
@PostMapping("districtZxc")
public void getDistrict(){
String customerId = "b09527201c4409e19d1dbc5e3c3429a1";
String monthId = "202008";
indexCalculateDistrictService.calDistrictAll(customerId,monthId);
}
}

10
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactIndexCollectController.java

@ -4,12 +4,10 @@ import com.epmet.commons.extappauth.annotation.ExternalAppRequestAuth;
import com.epmet.commons.extappauth.bean.ExternalAppRequestParam;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.indexcollect.form.*;
import com.epmet.dto.screencoll.form.IndexDataMonthlyFormDTO;
import com.epmet.service.evaluationindex.indexcoll.FactIndexCollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -37,8 +35,8 @@ public class FactIndexCollectController {
**/
@ExternalAppRequestAuth
@PostMapping("gridpartymemberdata")
public Result gridPartyMemberData(ExternalAppRequestParam externalAppRequestParam, @RequestBody List<GridPartyMemberDataFormDTO> formDTO) {
factIndexCollectService.insertGridPartyMemberData(formDTO, externalAppRequestParam.getCustomerId());
public Result gridPartyMemberData(ExternalAppRequestParam externalAppRequestParam, @RequestBody GridPartyMemberDataFormDTO formDTO) {
factIndexCollectService.insertGridPartyMemberData(formDTO,externalAppRequestParam.getCustomerId() );
return new Result();
}

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

@ -133,7 +133,7 @@ public class ScreenCollController {
**/
@ExternalAppRequestAuth
@PostMapping("difficultydata")
public Result difficultyData(ExternalAppRequestParam externalAppRequestParam, @RequestBody List<DifficultyDataFormDTO> formDTO) {
public Result difficultyData(ExternalAppRequestParam externalAppRequestParam, @RequestBody DifficultyDataFormDTO formDTO) {
screenCollService.insertDifficultyData(formDTO, externalAppRequestParam.getCustomerId());
return new Result();
}

29
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java

@ -19,7 +19,7 @@ package com.epmet.dao.evaluationindex.indexcal;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.indexcal.AgencyScoreDTO;
import com.epmet.dto.screen.FactIndexCommunityScoreDTO;
import com.epmet.dto.indexcal.SubAgencyScoreAvgResultDTO;
import com.epmet.entity.evaluationindex.indexcal.AgencyScoreEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -27,7 +27,7 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* /街道相关分数表
* /街道相关分数表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-09-02
@ -54,12 +54,31 @@ public interface AgencyScoreDao extends BaseDao<AgencyScoreEntity> {
void deleteOldRecord(@Param("customerId") String customerId, @Param("monthId")String monthId, @Param("indexCode")String indexCode,@Param("dataType")String dataType);
/**
* @Description 查询街道相关信息
* @Description 查询fact_index_agency_score相关信息
* @param customerId
* @param monthId
* @author zxc
* @date 2020/9/1 9:41 上午
*/
List<AgencyScoreDTO> selectStreetInfo(@Param("customerId") String customerId, @Param("monthId")String monthId,@Param("dataType")String dataType);
List<AgencyScoreDTO> selectAgencyScoreInfo(@Param("customerId") String customerId, @Param("monthId")String monthId, @Param("dataType")String dataType);
}
/**
* @Description 区下级街道得分平均值
* @param customerId
* @param monthId
* @author zxc
* @date 2020/8/31 1:51 下午
*/
List<SubAgencyScoreAvgResultDTO> selectAgencyScoreAvg(@Param("customerId")String customerId, @Param("monthId")String monthId, @Param("indexCode")String indexCode);
/**
* 根据入参查询 /街道相关分数表 记录
* @param customerId
* @param monthId
* @return java.util.List<com.epmet.dto.indexcal.AgencyScoreDTO>
* @Author zhangyong
* @Date 10:43 2020-09-03
**/
List<AgencyScoreDTO> selectListAgencyScore(@Param("customerId")String customerId, @Param("monthId")String monthId);
}

30
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/DeptScoreDao.java

@ -18,8 +18,13 @@
package com.epmet.dao.evaluationindex.indexcal;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.indexcal.DeptScoreDTO;
import com.epmet.dto.indexcal.SubAgencyScoreAvgResultDTO;
import com.epmet.entity.evaluationindex.indexcal.DeptScoreEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 区直部门分值表
@ -29,5 +34,26 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface DeptScoreDao extends BaseDao<DeptScoreEntity> {
}
/**
* 根据入参查询 区直部门分值表 记录
* @param customerId
* @param monthId
* @return java.util.List<com.epmet.dto.indexcal.DeptScoreDTO>
* @Author zhangyong
* @Date 10:43 2020-09-03
**/
List<DeptScoreDTO> selectListDeptScore(@Param("customerId")String customerId, @Param("monthId")String monthId);
/**
* @Description 所有直属部门治理能力平均值
* @param customerId
* @param monthId
* @param indexCode
* @author zxc
* @date 2020/9/4 10:53 上午
*/
List<SubAgencyScoreAvgResultDTO> selectGovernDeptScoreAvg(@Param("customerId")String customerId, @Param("monthId")String monthId, @Param("indexCode")String indexCode);
}

1
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexGovrnAblityDeptMonthlyDao.java

@ -18,6 +18,7 @@ package com.epmet.dao.evaluationindex.indexcoll; /**
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.indexcal.SubAgencyScoreAvgResultDTO;
import com.epmet.dto.indexcollect.form.DeptGovrnAbilityFormDTO;
import com.epmet.entity.evaluationindex.indexcoll.FactIndexGovrnAblityDeptMonthlyEntity;
import org.apache.ibatis.annotations.Mapper;

17
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexPartyAblityCpcMonthlyDao.java

@ -18,6 +18,7 @@
package com.epmet.dao.evaluationindex.indexcoll;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.indexcollect.form.GridPartyMemberDataDetailFormDTO;
import com.epmet.dto.indexcollect.form.GridPartyMemberDataFormDTO;
import com.epmet.entity.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyEntity;
import org.apache.ibatis.annotations.Mapper;
@ -40,22 +41,12 @@ public interface FactIndexPartyAblityCpcMonthlyDao extends BaseDao<FactIndexPart
* 1) 根据CUSTOMER_IDAGENCY_IDGRID_IDUSER_IDYEAR_IDMONTH_IDQUARTER_ID进行查询如果有数据则先进行物理删除
*
* @param customerId
* @param agencyId
* @param gridId
* @param userId
* @param yearId
* @param monthId
* @param quarterId
* @Author zhangyong
* @Date 10:52 2020-08-20
**/
void deleteFactIndexPartyAblityCpcMonthly(@Param("customerId") String customerId,
@Param("agencyId") String agencyId,
@Param("gridId") String gridId,
@Param("userId") String userId,
@Param("yearId") String yearId,
@Param("monthId") String monthId,
@Param("quarterId") String quarterId);
int deleteFactIndexPartyAblityCpcMonthly(@Param("customerId") String customerId,
@Param("monthId") String monthId);
/**
* 1党建能力-党员相关指标上报(按照月份)
@ -66,7 +57,7 @@ public interface FactIndexPartyAblityCpcMonthlyDao extends BaseDao<FactIndexPart
* @Author zhangyong
* @Date 10:52 2020-08-20
**/
void batchInsertFactIndexPartyAblityCpcMonthly(@Param("list") List<GridPartyMemberDataFormDTO> list,
int batchInsertFactIndexPartyAblityCpcMonthly(@Param("list") List<GridPartyMemberDataDetailFormDTO> list,
@Param("customerId") String customerId);
List<Map<String, Object>> getCountByMonthId(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("offset") Integer offset, @Param("pageSize") Integer pageSize);

13
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexCommunityScoreDao.java

@ -29,7 +29,7 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 社区相关分数表
* 社区相关分数表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-31
@ -64,6 +64,15 @@ public interface FactIndexCommunityScoreDao extends BaseDao<FactIndexCommunitySc
*/
List<FactIndexCommunityScoreDTO> selectCommunityInfo(@Param("customerId") String customerId,@Param("monthId")String monthId);
/**
* 根据入参查询 查询社区相关信息
* @param customerId
* @param monthId
* @return java.util.List<com.epmet.dto.screen.FactIndexCommunityScoreDTO>
* @Author zhangyong
* @Date 10:43 2020-09-03
**/
List<FactIndexCommunityScoreDTO> selectListCommunityScore(@Param("customerId")String customerId, @Param("monthId")String monthId);
/**
* @Description 街道下级所有社区得分平均值
* @param customerId
@ -73,4 +82,4 @@ public interface FactIndexCommunityScoreDao extends BaseDao<FactIndexCommunitySc
*/
List<SubCommunityAvgResultDTO> selectSubCommAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId, @Param("indexCode")String indexCode);
}
}

31
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexGridScoreDao.java

@ -18,6 +18,7 @@
package com.epmet.dao.evaluationindex.screen;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.screen.FactIndexGridScoreDTO;
import com.epmet.dto.screen.result.SubGridGovernAvgResultDTO;
import com.epmet.dto.screen.result.SubGridAvgResultDTO;
import com.epmet.dto.screen.result.SubGridServiceAvgResultDTO;
@ -44,4 +45,32 @@ public interface FactIndexGridScoreDao extends BaseDao<FactIndexGridScoreEntity>
* @date 2020/8/28 3:20 下午
*/
List<SubGridAvgResultDTO> selectSubGridAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId, @Param("indexCode")String indexCode);
}
/**
* @Description 社区下属所有网格治理能力汇总平均值
* @param customerId
* @param monthId
* @author zxc
* @date 2020/8/31 9:19 上午
*/
List<SubGridGovernAvgResultDTO> selectSubGridGovernAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId);
/**
* @Description 社区下级所有网格服务能力得分平均值
* @param customerId
* @param monthId
* @author zxc
* @date 2020/8/31 1:51 下午
*/
List<SubGridServiceAvgResultDTO> selectSubGridServiceAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId);
/**
* 根据入参查询 网格相关分值记录
* @param customerId
* @param monthId
* @return java.util.List<com.epmet.dto.screen.FactIndexGridScoreDTO>
* @Author zhangyong
* @Date 10:43 2020-09-03
**/
List<FactIndexGridScoreDTO> selectListGridScore(@Param("customerId")String customerId, @Param("monthId")String monthId);
}

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

@ -55,4 +55,15 @@ public interface ScreenCustomerAgencyDao extends BaseDao<ScreenCustomerAgencyEnt
* @Date 10:52 2020-08-18
**/
void batchInsertCustomerAgency(@Param("list") List<CustomerAgencyFormDTO> list, @Param("customerId")String customerId);
/**
* 根据客户id组织id查询区/街道 组织名称
*
* @param customerId 客户id
* @param agencyId 组织id
* @return java.util.String
* @Author zhangyong
* @Date 16:57 2020-09-03
**/
String selectParentAgencyInfo(@Param("customerId")String customerId, @Param("agencyId")String agencyId);
}

10
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerDeptDao.java

@ -58,6 +58,16 @@ public interface ScreenCustomerDeptDao extends BaseDao<ScreenCustomerDeptEntity>
**/
void batchInsertCustomerDept(@Param("list") List<CustomerDeptFormDTO> list, @Param("customerId")String customerId);
/**
* 根据客户id部门id查询部门父级 信息
* @param customerId 客户id
* @param deptId 部门id
* @return com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity
* @Author zhangyong
* @Date 16:57 2020-09-03
**/
ScreenCustomerDeptEntity selectParentDeptInfo(@Param("customerId")String customerId, @Param("deptId")String deptId);
/**
* @param customerId
* @param deptId

10
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerGridDao.java

@ -94,4 +94,14 @@ public interface ScreenCustomerGridDao extends BaseDao<ScreenCustomerGridEntity>
* @Date 2020/8/31 12:35
**/
ScreenCustomerGridDTO selectParentAgencyId(@Param("customerId") String customerId, @Param("gridId") String gridId);
/**
* 根据客户id网格id查询网格(党支部)父级信息
* @param customerId
* @param gridId
* @return com.epmet.dto.screen.FactIndexGridScoreDTO
* @Author zhangyong
* @Date 16:57 2020-09-03
**/
ScreenCustomerGridDTO selectParentGridInfo(@Param("customerId")String customerId, @Param("gridId")String gridId);
}

9
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenDifficultyDataDao.java

@ -18,6 +18,7 @@
package com.epmet.dao.evaluationindex.screen;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.screencoll.form.DifficultyDataDetailFormDTO;
import com.epmet.dto.screencoll.form.DifficultyDataFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenDifficultyDataEntity;
import org.apache.ibatis.annotations.Mapper;
@ -38,14 +39,10 @@ public interface ScreenDifficultyDataDao extends BaseDao<ScreenDifficultyDataEnt
* 1) 根据CUSTOMER_IDEVENT_IDORG_ID进行查询如果有数据则先进行物理删除
* @param customerId
* @param eventId
* @param orgId
* @Author zhangyong
* @Date 10:52 2020-08-18
**/
void deleteDifficultyData(@Param("customerId")String customerId,
@Param("eventId")String eventId,
@Param("orgId")String orgId);
void deleteDifficultyData(@Param("customerId")String customerId);
/**
* 3难点赌点
@ -56,5 +53,5 @@ public interface ScreenDifficultyDataDao extends BaseDao<ScreenDifficultyDataEnt
* @Author zhangyong
* @Date 10:52 2020-08-18
**/
void batchInsertDifficultyData(@Param("list") List<DifficultyDataFormDTO> list, @Param("customerId")String customerId);
void batchInsertDifficultyData(@Param("list") List<DifficultyDataDetailFormDTO> list, @Param("customerId")String customerId);
}

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/eum/IndexCodeEnum.java

@ -31,6 +31,10 @@ public enum IndexCodeEnum {
JIE_DAO_XIA_SHU_SYSQDJNLHZPJZ("jiedaoxiashusysqdjnlhzpjz","街道下属所有社区党建能力汇总(平均值)",5),
JIE_DAO_XIA_SHU_SYSQZLNLHZ("jiedaoxiashusysqzlnlhz","街道下属所有社区治理能力汇总 (平均值) ",5),
JIE_DAO_XIA_SHU_SQFWNLDFPYZ("jiedaoxiashusqfwnldfpjz","街道下属社区服务能力得分 (平均值) ",5),
QU_XIA_SHU_JIE_DFWNLHZPJZ("quxiashujiedfwnlhzpjz","区下属街道服务能力汇总(平均值)",5),
QU_XIA_JI_JIE_DDJNLHZPJZ("quxiajijieddjnlhzpjz","区下级街道党建能力汇总(平均值)",5),
SUO_YOU_JIE_DAO_ZLNLPJZ("suoyoujiedaozlnlpjz","所有街道治理能力(平均值)",5),
SUO_YOU_ZHI_SHU_BMZLNLPJZ("suoyouzhishubmzlnlpjz","所有直属部门治理能力(平均值)",5),
;
private String code;

28
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java

@ -11,6 +11,7 @@ import com.epmet.entity.evaluationindex.screen.IndexGroupTemplateEntity;
import com.epmet.service.evaluationindex.screen.IndexDictService;
import com.epmet.service.evaluationindex.screen.IndexGroupDetailTemplateService;
import com.epmet.service.evaluationindex.screen.IndexGroupTemplateService;
import com.epmet.support.normalizing.Correlation;
import com.epmet.util.Pinyin4jUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -29,7 +30,6 @@ import java.util.stream.Collectors;
*/
public class IndexExcelDataListener extends AnalysisEventListener<IndexModel> {
private static final Logger LOGGER = LoggerFactory.getLogger(IndexExcelDataListener.class);
private String POSITIVE = "positive";
/**
* 每隔5条存储数据库实际使用中可以3000条然后清理list 方便内存回收
*/
@ -86,8 +86,23 @@ public class IndexExcelDataListener extends AnalysisEventListener<IndexModel> {
data.setWeight(preWheight);
}
LOGGER.info("解析到一条数据:{}", JSON.toJSONString(data));
//TODO 默认正相关
data.setCorrelation(POSITIVE);
if (StringUtils.isNotBlank(data.getThreshold())) {
String threshold = data.getThreshold();
if ("无".equals(data.getThreshold())) {
threshold = "-1";
} else if (data.getThreshold().contains("%")) {
String thresholdStr = data.getThreshold().replace("%", "");
threshold = new BigDecimal(thresholdStr).divide(new BigDecimal(100), 4, RoundingMode.HALF_UP).toString();
}
data.setThreshold(threshold);
}
if (StringUtils.isNotBlank(data.getCorrelation())) {
if (Correlation.NEGATIVE.getDesc().equals(data.getCorrelation())) {
data.setCorrelation(Correlation.NEGATIVE.getCode());
} else {
data.setCorrelation(Correlation.POSITIVE.getCode());
}
}
IndexDictEntity entity = new IndexDictEntity();
IndexDictEntity entity2 = new IndexDictEntity();
@ -240,11 +255,8 @@ public class IndexExcelDataListener extends AnalysisEventListener<IndexModel> {
templateEntity.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(), false, 4));
templateEntity.setWeight(new BigDecimal(index.getWeight()).divide(new BigDecimal(100), 4, RoundingMode.HALF_UP));
}
if (StringUtils.isNotBlank(index.getThreshold())) {
String thresholdStr = index.getThreshold().replace("%", "");
templateEntity.setThreshold(new BigDecimal(thresholdStr).divide(new BigDecimal(100), 4, RoundingMode.HALF_UP));
}
templateEntity.setThreshold(new BigDecimal(index.getThreshold()));
templateEntity.setCorrelation(index.getCorrelation());
}
private void buildIndexDicEntity(IndexModel data, IndexDictEntity entity, IndexDictEntity entity2, IndexDictEntity entity3, IndexDictEntity entity4, IndexDictEntity entity5) {

1
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexModel.java

@ -21,6 +21,7 @@ public class IndexModel {
private String weight;
@ExcelProperty(value = "五级权重")
private String level5Weight;
//没有阈值:无,有就是百分数
@ExcelProperty(value = "阈值")
private String threshold;
/**

18
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateDistrictService.java

@ -0,0 +1,18 @@
package com.epmet.service.evaluationindex.indexcal;
/**
* @Author zxc
* @DateTime 2020/9/4 9:03 上午
*/
public interface IndexCalculateDistrictService {
/**
* @Description 计算全区相关总分
* @param customerId
* @param monthId
* @author zxc
* @date 2020/9/2 3:12 下午
*/
Boolean calDistrictAll(String customerId, String monthId);
}

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

@ -10,9 +10,9 @@ import com.epmet.constant.DataSourceConstant;
import com.epmet.constant.IndexCalConstant;
import com.epmet.dao.evaluationindex.indexcal.CpcScoreDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyDao;
import com.epmet.dao.evaluationindex.screen.IndexCodeFieldReDao;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.entity.evaluationindex.indexcal.CpcScoreEntity;
import com.epmet.entity.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyEntity;
import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity;
import com.epmet.eum.IndexCodeEnum;
import com.epmet.service.evaluationindex.indexcal.CpcIndexCalculateService;
@ -43,8 +43,6 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService {
@Autowired
private FactIndexPartyAblityCpcMonthlyDao factIndexPartyAblityCpcMonthlyDao;
@Autowired
private IndexCodeFieldReDao indexCodeFieldReDao;
@Autowired
private IndexGroupDetailService getDetailListByParentCode;
@Autowired
private IndexCodeFieldReService indexCodeFieldReService;
@ -97,11 +95,43 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService {
totalEntity.setScore(totalEntity.getScore().add(total));
}
});
deleteAndInsertBatch(formDTO.getCustomerId(),formDTO.getMonthId(),IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(),cpcScoreTotalMap.values().stream().collect(Collectors.toList()));
deleteAndInsertBatch(formDTO, cpcScoreTotalMap.values().stream().collect(Collectors.toList()), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode());
}
/**
* @param formDTO
* @param indexCode
* @param stringObjectMap
* @return void
* @author yinzuomei
* @description 只有一条事实记录时分值默认赋50
* @Date 2020/9/2 14:35
**/
private CpcScoreEntity handleOneGridScene(CalculateCommonFormDTO formDTO, String indexCode, Map<String, Object> stringObjectMap) {
FactIndexPartyAblityCpcMonthlyEntity factCpc = JSON.parseObject(JSON.toJSONString(stringObjectMap), FactIndexPartyAblityCpcMonthlyEntity.class);
// 保存中间表
CpcScoreEntity cpcScoreEntity = new CpcScoreEntity();
cpcScoreEntity.setCustomerId(factCpc.getCustomerId());
cpcScoreEntity.setAgencyId(factCpc.getAgencyId());
cpcScoreEntity.setGridId(factCpc.getGridId());
cpcScoreEntity.setYearId(factCpc.getYearId());
cpcScoreEntity.setMonthId(factCpc.getMonthId());
cpcScoreEntity.setUserId(factCpc.getUserId());
cpcScoreEntity.setScore(new BigDecimal(NumConstant.FIFTY_STR));
cpcScoreEntity.setIndexCode(indexCode);
cpcScoreEntity.setIsTotal(NumConstant.ZERO_STR);
return cpcScoreEntity;
}
private void deleteAndInsertBatch(String customerId, String monthId, String indexCode, Collection<CpcScoreEntity> values) {
cpcScoreDao.deleteByMonthId(customerId, monthId, indexCode);
/**
* desc:根据客户id和月份Id 指标code 非必填 删除数据
*
* @param formDTO
* @param indexCode 指标code 非必填
* @param values
*/
private void deleteAndInsertBatch(CalculateCommonFormDTO formDTO, Collection<CpcScoreEntity> values, String indexCode) {
cpcScoreDao.deleteByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode);
cpcScoreDao.insertBatch(values);
}
@ -119,20 +149,33 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService {
return;
}
int pageNo = 1;
int pageSize = 10;
int pageNo = NumConstant.ONE;
int pageSize = NumConstant.ONE_THOUSAND;
//分页查询 要计算的原始数据
List<Map<String, Object>> list = null;
do {
list = factIndexPartyAblityCpcMonthlyDao.getCountByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), (pageNo - 1) * pageSize, pageSize);
if (!CollectionUtils.isEmpty(list)) {
//遍历指标分组 计算分数
List<Map<String, Object>> finalList = list;
groupIndexDetailsMap.forEach((parentIndexCode, details) -> {
calculateScore(formDTO, details, finalList, minAndMaxMap, parentIndexCode);
});
//如果是第一页且仅有一条数据 则直接给50分
if (pageNo == NumConstant.ONE && list.size() == NumConstant.ONE) {
List<CpcScoreEntity> insertList = new ArrayList<>();
for (String parentIndexCode : groupIndexDetailsMap.keySet()) {
insertList.add(handleOneGridScene(formDTO, parentIndexCode, list.get(0)));
}
if (CollectionUtils.isEmpty(insertList)) {
deleteAndInsertBatch(formDTO, insertList, null);
}
} else {
//遍历指标分组 计算分数
for (Map.Entry<String, List<IndexGroupDetailEntity>> entry : groupIndexDetailsMap.entrySet()) {
String parentIndexCode = entry.getKey();
List<IndexGroupDetailEntity> details = entry.getValue();
calculateScore(formDTO, details, list, minAndMaxMap, parentIndexCode);
}
}
}
} while (!CollectionUtils.isEmpty(list) && pageNo++ > 0);
pageNo++;
} while (!CollectionUtils.isEmpty(list) && list.size() == pageSize);
}
/**
@ -185,7 +228,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService {
log.info("计算的结果:{}", result);
//处理结果
if (CollectionUtils.isEmpty(result)){
if (CollectionUtils.isEmpty(result)) {
log.error("calculateScore calculateScore return empty");
return;
}
@ -209,7 +252,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService {
cpcScoreEntity.setScore(score);
list.add(cpcScoreEntity);
});
this.deleteAndInsertBatch(formDTO.getCustomerId(),formDTO.getMonthId(),parentIndexCode,list);
this.deleteAndInsertBatch(formDTO, list, parentIndexCode);
}
@ -242,7 +285,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService {
minValue = new BigDecimal(String.valueOf(minAndMaxMap.get(minValueKey)));
//如果最大值超过阈值 则最大值为阈值
if (new BigDecimal(NumConstant.ONE_NEG).compareTo(index.getThreshold()) != NumConstant.ZERO
&& maxValue.compareTo(new BigDecimal(NumConstant.ONE_NEG)) == NumConstant.ONE){
&& maxValue.compareTo(new BigDecimal(NumConstant.ONE_NEG)) == NumConstant.ONE) {
maxValue = index.getThreshold();
}
//分值计算器

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

@ -18,11 +18,13 @@
package com.epmet.service.evaluationindex.indexcal.impl;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.constant.DataSourceConstant;
import com.epmet.constant.IndexCalConstant;
import com.epmet.dao.evaluationindex.indexcal.DeptScoreDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityDeptMonthlyDao;
@ -63,6 +65,7 @@ import java.util.Map;
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-09-02
*/
@DataSource(DataSourceConstant.EVALUATION_INDEX)
@Slf4j
@Service
public class DeptScoreServiceImpl extends BaseServiceImpl<DeptScoreDao, DeptScoreEntity> implements DeptScoreService {

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

@ -1,6 +1,7 @@
package com.epmet.service.evaluationindex.indexcal.impl;
import com.alibaba.druid.util.StringUtils;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException;
@ -139,7 +140,9 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
}
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
log.info("communityPartyCalculate getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
log.info("communityPartyCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreCountOfSampleId));
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid);
deleteAndInsert(customerId, monthId, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), result);
return true;
@ -216,7 +219,9 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
}
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
log.info("communityGovernAbilityCalculate getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
log.info("communityGovernAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreCountOfSampleId));
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid);
deleteAndInsert(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), result);
return true;
@ -293,7 +298,9 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
}
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
log.info("communityServiceAbilityCalculate getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
log.info("communityServiceAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreCountOfSampleId));
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid);
deleteAndInsert(customerId, monthId, IndexCodeEnum.FU_WU_NENG_LI.getCode(), result);
return true;

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

@ -0,0 +1,406 @@
package com.epmet.service.evaluationindex.indexcal.impl;
import com.alibaba.druid.util.StringUtils;
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.constant.IndexCalConstant;
import com.epmet.dao.evaluationindex.indexcal.AgencyScoreDao;
import com.epmet.dao.evaluationindex.indexcal.DeptScoreDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityDeptMonthlyDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityOrgMonthlyDao;
import com.epmet.dto.indexcal.AgencyScoreDTO;
import com.epmet.dto.indexcal.SubAgencyScoreAvgResultDTO;
import com.epmet.dto.screen.result.MaxAndMinBigDecimalResultDTO;
import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity;
import com.epmet.eum.IndexCodeEnum;
import com.epmet.service.evaluationindex.indexcal.IndexCalculateDistrictService;
import com.epmet.service.evaluationindex.indexcal.IndexCodeFieldReService;
import com.epmet.service.evaluationindex.screen.IndexGroupDetailService;
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 com.epmet.support.normalizing.batch.BatchScoreCalculator;
import com.epmet.support.normalizing.batch.IndexInputVO;
import com.epmet.support.normalizing.batch.SampleValue;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.ListUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author zxc
* @DateTime 2020/9/4 9:03 上午
*/
@Service
@Slf4j
@DataSource(DataSourceConstant.EVALUATION_INDEX)
public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrictService {
@Autowired
private FactIndexPartyAblityOrgMonthlyDao factIndexPartyAblityOrgMonthlyDao;
@Autowired
private IndexCodeFieldReService indexCodeFieldReService;
@Autowired
private IndexGroupDetailService indexGroupDetailService;
@Autowired
private AgencyScoreDao agencyScoreDao;
@Autowired
private DeptScoreDao deptScoreDao;
/**
* @Description 计算全区相关总分
* @param customerId
* @param monthId
* @author zxc
* @date 2020/9/2 3:12 下午
*/
@Override
public Boolean calDistrictAll(String customerId, String monthId) {
Boolean aBoolean = districtPartyCalculate(customerId, monthId);//党建能力
if (!aBoolean.equals(true)) {
throw new RenException("calculate district-party-ability failure ......");
}
Boolean bBoolean = districtGovernAbilityCalculate(customerId, monthId);// 治理能力
if (!bBoolean.equals(true)) {
throw new RenException("calculate district-govern-ability failure ......");
}
Boolean cBoolean = districtServiceAbilityCalculate(customerId, monthId);// 服务能力
if (!cBoolean.equals(true)) {
throw new RenException("calculate district-service-ability failure ......");
}
Boolean dBoolean = districtRelate(customerId, monthId);
if (!dBoolean.equals(true)) {
throw new RenException("calculate district-all insert failure ......");
}
return true;
}
/**
* @param customerId
* @Description 全区名义发文数量计算党建能力
* @author zxc
* @date 2020/8/26 10:46 上午
*/
public Boolean districtPartyCalculate(String customerId, String monthId) {
// 党建能力
// 根据all_parent_index_code 获取指标明细
List<IndexGroupDetailEntity> indexDetailList = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode(), IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
if (CollectionUtils.isEmpty(indexDetailList)) {
log.error(IndexCalConstant.INDEX_DETAIL_LIST_NULL);
return false;
}
List<IndexInputVO> indexInputVOS = new ArrayList<>();
Map<String,String> pid = new HashMap<>();
//党建能力平均值
indexDetailList.forEach(detail -> {
if (IndexCodeEnum.QU_XIA_JI_JIE_DDJNLHZPJZ.getCode().equals(detail.getIndexCode())) {
List<SubAgencyScoreAvgResultDTO> subGridPartyAvgScore = agencyScoreDao.selectAgencyScoreAvg(customerId, monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
if (CollectionUtils.isEmpty(subGridPartyAvgScore)) {
log.error(IndexCalConstant.DISTRICT_PARTY_AVG_NULL);
return;
}else if (subGridPartyAvgScore.size() == NumConstant.ONE){
pid.put(subGridPartyAvgScore.get(NumConstant.ZERO).getAgencyId(),subGridPartyAvgScore.get(NumConstant.ZERO).getParentId());
sizeOne(subGridPartyAvgScore.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid);
return;
}else if (subGridPartyAvgScore.size() > NumConstant.ONE) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridPartyAvgScore.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubAgencyScoreAvgResultDTO>> subPartyAvgList = ListUtils.partition(subGridPartyAvgScore, IndexCalConstant.PAGE_SIZE);
subPartyAvgList.forEach( party -> {
List<SampleValue> index1SampleValues = new ArrayList<>();
party.forEach(c -> {
pid.put(c.getAgencyId(),c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc);
indexInputVOS.add(index1VO);
});
}
} else {
// 区名义发文数量
List<Map<String, Object>> publishArticleCountList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMap(customerId, monthId,IndexCalConstant.DISTRICT_LEVEL);
if (CollectionUtils.isEmpty(publishArticleCountList)) {
log.error(IndexCalConstant.DISTRICT_PUBLISH_ARTICLE_LIST_NULL);
return;
}
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode());
if (StringUtils.isEmpty(fieldNameByIndexCode)) {
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL,detail.getIndexCode()));
return;
}else if (publishArticleCountList.size() == NumConstant.ONE){
pid.put(publishArticleCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),publishArticleCountList.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString());
sizeOne(publishArticleCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid);
return;
}else if (publishArticleCountList.size() > NumConstant.ONE) {
List<BigDecimal> decimalList = publishArticleCountList.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList());
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(decimalList);
List<List<Map<String, Object>>> publishArticleList = ListUtils.partition(publishArticleCountList, IndexCalConstant.PAGE_SIZE);
publishArticleList.forEach( publish -> {
ScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
List<SampleValue> index1SampleValues = new ArrayList<>();
publish.forEach(c -> {
pid.put(c.get(IndexCalConstant.AGENCY_ID).toString(),c.get(IndexCalConstant.PARENT_ID).toString());
SampleValue s = new SampleValue((String) c.get(IndexCalConstant.AGENCY_ID), new BigDecimal(String.valueOf(c.get(fieldNameByIndexCode))));
index1SampleValues.add(s);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
indexInputVOS.add(index1VO);
});
}
}
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), pid);
deleteAndInsert(customerId, monthId, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), result);
return true;
}
/**
* @param customerId
* @param monthId
* @Description 全区治理能力
* @author zxc
* @date 2020/8/26 1:40 下午
*/
public Boolean districtGovernAbilityCalculate(String customerId, String monthId) {
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode(), IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
if (CollectionUtils.isEmpty(detailListByParentCode)) {
log.error(IndexCalConstant.INDEX_DETAIL_LIST_NULL);
return false;
}
List<IndexInputVO> indexInputVOS = new ArrayList<>();
Map<String,String> pid = new HashMap<>();
detailListByParentCode.forEach(detail -> {
if (IndexCodeEnum.SUO_YOU_JIE_DAO_ZLNLPJZ.getCode().equals(detail.getIndexCode())) {
List<SubAgencyScoreAvgResultDTO> districtGovernAvgList = agencyScoreDao.selectAgencyScoreAvg(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
if (districtGovernAvgList.size() == NumConstant.ONE) {
pid.put(districtGovernAvgList.get(NumConstant.ZERO).getAgencyId(),districtGovernAvgList.get(NumConstant.ZERO).getParentId());
sizeOne(districtGovernAvgList.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid);
return;
} else if (districtGovernAvgList.size() > NumConstant.ONE) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(districtGovernAvgList.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubAgencyScoreAvgResultDTO>> governAvg = ListUtils.partition(districtGovernAvgList, IndexCalConstant.PAGE_SIZE);
governAvg.forEach(avg -> {
List<SampleValue> index1SampleValues = new ArrayList<>();
avg.forEach(c -> {
pid.put(c.getAgencyId(),c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc);
indexInputVOS.add(index1VO);
});
}
} else if (IndexCodeEnum.SUO_YOU_ZHI_SHU_BMZLNLPJZ.getCode().equals(detail.getIndexCode())){
List<SubAgencyScoreAvgResultDTO> deptScoreAvgList = deptScoreDao.selectGovernDeptScoreAvg(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
if (deptScoreAvgList.size() == NumConstant.ONE) {
pid.put(deptScoreAvgList.get(NumConstant.ZERO).getAgencyId(),deptScoreAvgList.get(NumConstant.ZERO).getParentId());
sizeOne(deptScoreAvgList.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid);
return;
} else if (deptScoreAvgList.size() > NumConstant.ONE) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(deptScoreAvgList.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubAgencyScoreAvgResultDTO>> governAvg = ListUtils.partition(deptScoreAvgList, IndexCalConstant.PAGE_SIZE);
governAvg.forEach(avg -> {
List<SampleValue> index1SampleValues = new ArrayList<>();
avg.forEach(c -> {
pid.put(c.getAgencyId(),c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc);
indexInputVOS.add(index1VO);
});
}
}else{
// TODO 治理能力暂无自身级别
}
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), pid);
deleteAndInsert(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), result);
return true;
}
/**
* @param customerId
* @param monthId
* @Description 全区服务能力
* @author zxc
* @date 2020/8/31 1:38 下午
*/
public Boolean districtServiceAbilityCalculate(String customerId, String monthId) {
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode(), IndexCodeEnum.FU_WU_NENG_LI.getCode());
if (CollectionUtils.isEmpty(detailListByParentCode)) {
log.error(IndexCalConstant.INDEX_DETAIL_LIST_NULL);
return false;
}
List<IndexInputVO> indexInputVOS = new ArrayList<>();
Map<String,String> pid = new HashMap<>();
detailListByParentCode.forEach(detail -> {
String indexCode = detail.getIndexCode();
if (IndexCodeEnum.QU_XIA_SHU_JIE_DFWNLHZPJZ.getCode().equals(indexCode)) {
List<SubAgencyScoreAvgResultDTO> subStreetAvgList = agencyScoreDao.selectAgencyScoreAvg(customerId, monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode());
if (subStreetAvgList.size() == NumConstant.ONE) {
pid.put(subStreetAvgList.get(NumConstant.ZERO).getAgencyId(),subStreetAvgList.get(NumConstant.ZERO).getParentId());
sizeOne(subStreetAvgList.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid);
return;
} else if (subStreetAvgList.size() > NumConstant.ONE) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subStreetAvgList.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubAgencyScoreAvgResultDTO>> serviceAvgList = ListUtils.partition(subStreetAvgList, IndexCalConstant.PAGE_SIZE);
serviceAvgList.forEach(serviceAvg -> {
BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
List<SampleValue> index1SampleValues = new ArrayList<>();
serviceAvg.forEach(c -> {
pid.put(c.getAgencyId(),c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
indexInputVOS.add(index1VO);
});
}
} else {
// todo 暂时没有自身级别
}
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid);
deleteAndInsert(customerId, monthId, IndexCodeEnum.FU_WU_NENG_LI.getCode(), result);
return true;
}
/**
* @param customerId
* @param monthId
* @Description 区相关计算
* @author zxc
* @date 2020/9/1 9:21 上午
*/
public Boolean districtRelate(String customerId, String monthId) {
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode());
List<AgencyScoreDTO> agencyScoreList = agencyScoreDao.selectAgencyScoreInfo(customerId, monthId, IndexCalConstant.DISTRICT_LEVEL);
detailListByParentCode.forEach(detail -> {
agencyScoreList.forEach(community -> {
if (detail.getIndexCode().equals(community.getIndexCode())) {
community.setScore(community.getScore().multiply(detail.getWeight()));
}
});
});
Map<String, List<AgencyScoreDTO>> collect = agencyScoreList.stream().collect(Collectors.groupingBy(AgencyScoreDTO::getAgencyId));
List<AgencyScoreDTO> result = new ArrayList<>();
collect.forEach((key, value) -> {
AgencyScoreDTO score = new AgencyScoreDTO();
score.setIsTotal(NumConstant.ONE_STR);
score.setCustomerId(customerId);
score.setAgencyId(key);
score.setMonthId(monthId);
score.setYearId(DateUtils.getYearId(monthId));
score.setQuarterId(DateUtils.getQuarterId(monthId));
score.setIndexCode(IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode());
value.forEach(community -> {
score.setScore(score.getScore().add(community.getScore()));
score.setParentAgencyId(community.getParentAgencyId());
});
result.add(score);
});
deleteAndInsert(customerId, monthId, IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode(), result);
return true;
}
/**
* @param list
* @Description BigDecimal类型获取最大数和最小数
* @author zxc
* @date 2020/8/27 1:30 下午
*/
public MaxAndMinBigDecimalResultDTO getMaxAndMinBigDecimal(List<BigDecimal> list) {
BigDecimal max = Collections.max(list);
BigDecimal min = Collections.min(list);
MaxAndMinBigDecimalResultDTO result = new MaxAndMinBigDecimalResultDTO();
result.setMax(max);
result.setMin(min);
return result;
}
/**
* @param customerId
* @param monthId
* @param indexCode
* @param subAllDistrict
* @Description 先删除记录在插入
* @author zxc
* @date 2020/9/1 4:24 下午
*/
@Transactional(rollbackFor = Exception.class)
public void deleteAndInsert(String customerId, String monthId, String indexCode, List<AgencyScoreDTO> subAllDistrict) {
if (!CollectionUtils.isEmpty(subAllDistrict)) {
agencyScoreDao.deleteOldRecord(customerId, monthId, indexCode,IndexCalConstant.DISTRICT_LEVEL);
System.err.println(subAllDistrict.size());
agencyScoreDao.insertStreetRecord(subAllDistrict);
}
}
/**
* @Description
* @param scoreCountOfSampleId 指标计算结果
* @param customerId 客户ID
* @param monthId 月份ID
* @param isTotal 是否 总分党建+治理+服务
* @param indexCode 党建能力dangjiannengli治理能力zhilinengli服务能力fuwunenglixx相关xx相关
* @author zxc
* @date 2020/9/2 2:37 下午
*/
public List<AgencyScoreDTO> getResult(HashMap<String, BigDecimal> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode,Map<String,String> pid) {
List<AgencyScoreDTO> result = new ArrayList<>();
scoreCountOfSampleId.forEach((k, v) -> {
AgencyScoreDTO score = new AgencyScoreDTO();
score.setCustomerId(customerId);
score.setAgencyId(k);
score.setMonthId(monthId);
score.setQuarterId(DateUtils.getQuarterId(monthId));
score.setYearId(DateUtils.getYearId(monthId));
score.setIsTotal(isTotal);
score.setIndexCode(indexCode);
score.setScore(v);
score.setDataType(IndexCalConstant.DISTRICT_LEVEL);
pid.forEach((agency,parentAgency) -> {
if (k.equals(agency)){
score.setParentAgencyId(parentAgency);
}
});
result.add(score);
});
return result;
}
/**
* @Description 当查询结果为一条时调用此方法
* @param agencyId
* @param customerId
* @param monthId
* @author zxc
* @date 2020/9/2 2:40 下午
*/
public void sizeOne(String agencyId,String customerId,String monthId,String indexCode,Map<String,String> pid){
HashMap<String, BigDecimal> scoreCountOfSampleId = new HashMap<>();
scoreCountOfSampleId.put(agencyId,new BigDecimal(NumConstant.FIFTY));
List<AgencyScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, indexCode,pid);
deleteAndInsert(customerId, monthId, indexCode, result);
}
}

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

@ -338,7 +338,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
*/
public Boolean streetRelate(String customerId, String monthId) {
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode());
List<AgencyScoreDTO> agencyScoreList = agencyScoreDao.selectStreetInfo(customerId, monthId, IndexCalConstant.STREET_LEVEL);
List<AgencyScoreDTO> agencyScoreList = agencyScoreDao.selectAgencyScoreInfo(customerId, monthId, IndexCalConstant.STREET_LEVEL);
detailListByParentCode.forEach(detail -> {
agencyScoreList.forEach(community -> {
if (detail.getIndexCode().equals(community.getIndexCode())) {

12
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/FactIndexCollectService.java

@ -22,7 +22,7 @@ public interface FactIndexCollectService {
* @Author zhangyong
* @Date 10:52 2020-08-20
**/
void insertGridPartyMemberData(List<GridPartyMemberDataFormDTO> formDTO, String customerId);
void insertGridPartyMemberData(GridPartyMemberDataFormDTO formDTO, String customerId);
/**
* 2党建能力-网格相关指标上报(按照月份)
@ -107,4 +107,14 @@ public interface FactIndexCollectService {
* @Date 10:52 2020-08-20
**/
void insertDeptGovrnAbility(List<DeptGovrnAbilityFormDTO> formDTO, String customerId);
/**
* 将网格社区区直部门/街道分支记录表中的数据抽取到 指数-指数数据(每月数值) 指数-指数数据(按年统计)
* @param monthId 2020-8
* @param customerId
* @return void
* @Author zhangyong
* @Date 10:29 2020-09-03
**/
void insertScreenIndexDataMonthlyAndYearly(String monthId, String customerId);
}

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

@ -3,19 +3,38 @@ 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.constant.DataSourceConstant;
import com.epmet.constant.OrgTypeConstant;
import com.epmet.dao.evaluationindex.indexcal.AgencyScoreDao;
import com.epmet.dao.evaluationindex.indexcal.DeptScoreDao;
import com.epmet.dao.evaluationindex.indexcoll.*;
import com.epmet.dao.evaluationindex.screen.*;
import com.epmet.dto.ScreenCustomerGridDTO;
import com.epmet.dto.indexcal.AgencyScoreDTO;
import com.epmet.dto.indexcal.DeptScoreDTO;
import com.epmet.dto.indexcollect.form.*;
import com.epmet.dto.screen.FactIndexCommunityScoreDTO;
import com.epmet.dto.screen.FactIndexGridScoreDTO;
import com.epmet.dto.screencoll.form.IndexDataMonthlyFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity;
import com.epmet.eum.IndexCodeEnum;
import com.epmet.service.evaluationindex.indexcoll.FactIndexCollectService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Auther: zhangyong
* @Date: 2020-08-20 10:05
*/
@Slf4j
@Service
@DataSource(DataSourceConstant.EVALUATION_INDEX)
public class FactIndexCollectServiceImpl implements FactIndexCollectService {
@ -36,18 +55,38 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
private FactIndexGovrnAblityOrgMonthlyDao factIndexGovrnAblityOrgMonthlyDao;
@Autowired
private FactIndexGovrnAblityDeptMonthlyDao factIndexGovrnAblityDeptMonthlyDao;
@Autowired
private FactIndexGridScoreDao factIndexGridScoreDao;
@Autowired
private FactIndexCommunityScoreDao factIndexCommunityScoreDao;
@Autowired
private DeptScoreDao deptScoreDao;
@Autowired
private AgencyScoreDao agencyScoreDaol;
@Autowired
private ScreenIndexDataMonthlyDao screenIndexDataMonthlyDao;
@Autowired
private ScreenIndexDataYearlyDao screenIndexDataYearlyDao;
@Autowired
private ScreenCustomerGridDao screenCustomerGridDao;
@Autowired
private ScreenCustomerDeptDao screenCustomerDeptDao;
@Autowired
private ScreenCustomerAgencyDao screenCustomerAgencyDao;
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
@Transactional(rollbackFor = Exception.class)
public void insertGridPartyMemberData(List<GridPartyMemberDataFormDTO> formDTO, String customerId) {
if (null != formDTO && formDTO.size() > NumConstant.ZERO){
for (int i = NumConstant.ZERO; i < formDTO.size(); i++){
factIndexPartyAblityCpcMonthlyDao.deleteFactIndexPartyAblityCpcMonthly(customerId,
formDTO.get(i).getAgencyId(), formDTO.get(i).getGridId(), formDTO.get(i).getUserId(),
formDTO.get(i).getYearId(), formDTO.get(i).getMonthId(), formDTO.get(i).getQuarterId());
}
factIndexPartyAblityCpcMonthlyDao.batchInsertFactIndexPartyAblityCpcMonthly(formDTO, customerId);
public void insertGridPartyMemberData(GridPartyMemberDataFormDTO formDTO, String customerId) {
if (formDTO.getIsFirst()) {
//删除这个客户这个月的数据
int deleteNum;
do {
deleteNum = factIndexPartyAblityCpcMonthlyDao.deleteFactIndexPartyAblityCpcMonthly(customerId, formDTO.getMonthId());
} while (deleteNum != NumConstant.ZERO);
}
if (null != formDTO && !CollectionUtils.isEmpty(formDTO.getPartyMemberDataList())) {
factIndexPartyAblityCpcMonthlyDao.batchInsertFactIndexPartyAblityCpcMonthly(formDTO.getPartyMemberDataList(), customerId);
}
}
@ -160,4 +199,301 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
factIndexGovrnAblityDeptMonthlyDao.batchInsertFactIndexGovrnAblityDeptMonthly(formDTO, customerId);
}
}
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
@Transactional(rollbackFor = Exception.class)
public void insertScreenIndexDataMonthlyAndYearly(String monthId, String customerId) {
if (NumConstant.SIX != monthId.length()){
throw new RuntimeException("入参monthId格式不正确:monthId =" + monthId);
}
String year = monthId.substring(NumConstant.ZERO, NumConstant.FOUR);
String month = monthId.substring(NumConstant.FOUR, NumConstant.SIX);
// fact_index_grid_score 网格相关分值记录表 grid
List<FactIndexGridScoreDTO> gridScoreDTOS = factIndexGridScoreDao.selectListGridScore(customerId, monthId);
if (null != gridScoreDTOS && gridScoreDTOS.size() > NumConstant.ZERO){
this.insertIndexDataMonthlyByGridScore(month, year, customerId, gridScoreDTOS);
}
// fact_index_community_score 社区相关分数表 agency
List<FactIndexCommunityScoreDTO> communityScoreDTOS = factIndexCommunityScoreDao.selectListCommunityScore(customerId, monthId);
if (null != communityScoreDTOS && communityScoreDTOS.size() > NumConstant.ZERO){
this.insertIndexDataMonthlyByCommunityScore(month, year, customerId, communityScoreDTOS);
}
// fact_index_dept_score 区直部门分值表 department
List<DeptScoreDTO> deptScoreDTOS = deptScoreDao.selectListDeptScore(customerId, monthId);
if (null != deptScoreDTOS && deptScoreDTOS.size() > NumConstant.ZERO){
this.insertIndexDataMonthlyByDeptScore(month, year, customerId, deptScoreDTOS);
}
// fact_index_agency_score 区/街道相关分数表 agency
List<AgencyScoreDTO> agencyScoreDTOS = agencyScoreDaol.selectListAgencyScore(customerId, monthId);
if (null != agencyScoreDTOS && agencyScoreDTOS.size() > NumConstant.ZERO) {
this.insertIndexDataMonthlyByAgencyScore(month, year, customerId, agencyScoreDTOS);
}
// 插入年表 screen_index_data_yearly
}
/**
* 将网格相关分值记录表 数据 插入月表 screenIndexDataMonthlyDao
*
* @param month 08
* @param year 2020
* @param customerId 客户id
* @param gridScoreDTOS 网格相关分值记录表 当前客户所属月份数据集
* @return void
* @Author zhangyong
* @Date 14:17 2020-09-03
**/
private void insertIndexDataMonthlyByGridScore(String month, String year, String customerId, List<FactIndexGridScoreDTO> gridScoreDTOS){
List<IndexDataMonthlyFormDTO> monthlyFormDTOList = new ArrayList<>();
// 根据网格id进行分组,最后组装一条数据 一个网格 对应 4条数据
Map<String, List<FactIndexGridScoreDTO>> collect = gridScoreDTOS.stream().collect(Collectors.groupingBy(FactIndexGridScoreDTO::getGridId));
String[] orgIds = new String[collect.size()];
int j = 0;
for(Map.Entry<String,List<FactIndexGridScoreDTO>> gridScore : collect.entrySet()){
IndexDataMonthlyFormDTO monthlyFormDTO = new IndexDataMonthlyFormDTO();
// 网格id
orgIds[j] = gridScore.getKey();
j++;
for ( int i = 0; i < gridScore.getValue().size(); i++){
if (NumConstant.ONE_STR.equals(gridScore.getValue().get(i).getIsTotal())){
// 是总分
if (IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode().equals(gridScore.getValue().get(i).getIndexCode())){
// 总指数 = 网格相关
monthlyFormDTO.setIndexTotal(gridScore.getValue().get(i).getScore());
}
} else {
// 赋值 党建能力、治理能力、服务能力
monthlyFormDTO = this.setValueAblityMonthlyFor(gridScore.getValue().get(i).getIndexCode(),
gridScore.getValue().get(i).getScore(),
monthlyFormDTO);
}
}
// 查询网格的 上级组织id 和 组织名称
ScreenCustomerGridDTO parentGridInfo = screenCustomerGridDao.selectParentGridInfo(customerId, gridScore.getKey());
if (null == parentGridInfo){
throw new RuntimeException("在screen_customer_grid表中未查询到该客户下的网格信息:customerId =" + customerId + ", gridId = " + gridScore.getKey());
}
// 补充表中其他字段
monthlyFormDTO = this.supplementIndexDataMonthlyTable(year, month, OrgTypeConstant.GRID, gridScore.getKey(),
parentGridInfo.getParentAgencyId(), parentGridInfo.getGridName(), monthlyFormDTO);
monthlyFormDTOList.add(monthlyFormDTO);
}
screenIndexDataMonthlyDao.deleteIndexDataMonthly(customerId, year, month, orgIds);
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId);
}
/**
* 社区相关分数表 数据 插入月表 screenIndexDataMonthlyDao
*
* @param month 08
* @param year 2020
* @param customerId 客户id
* @param communityScoreDTOS 社区相关分数表 当前客户所属月份数据集
* @return void
* @Author zhangyong
* @Date 14:17 2020-09-03
**/
private void insertIndexDataMonthlyByCommunityScore(String month, String year, String customerId, List<FactIndexCommunityScoreDTO> communityScoreDTOS){
List<IndexDataMonthlyFormDTO> monthlyFormDTOList = new ArrayList<>();
// 根据组织id 进行分组,最后组装一条数据 一个组织id 对应 4条数据
Map<String, List<FactIndexCommunityScoreDTO>> collect = communityScoreDTOS.stream().collect(Collectors.groupingBy(FactIndexCommunityScoreDTO::getAgencyId));
String[] orgIds = new String[collect.size()];
int j = 0;
for(Map.Entry<String,List<FactIndexCommunityScoreDTO>> communityScore : collect.entrySet()){
IndexDataMonthlyFormDTO monthlyFormDTO = new IndexDataMonthlyFormDTO();
// 组织id
orgIds[j] = communityScore.getKey();
j++;
for ( int i = 0; i < communityScore.getValue().size(); i++){
if (NumConstant.ONE_STR.equals(communityScore.getValue().get(i).getIsTotal())){
// 是总分
if (IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode().equals(communityScore.getValue().get(i).getIndexCode())){
// 总指数 = 社区相关
monthlyFormDTO.setIndexTotal(communityScore.getValue().get(i).getScore());
}
} else {
// 赋值 党建能力、治理能力、服务能力
monthlyFormDTO = this.setValueAblityMonthlyFor(communityScore.getValue().get(i).getIndexCode(),
communityScore.getValue().get(i).getScore(),
monthlyFormDTO);
}
}
// 当前组织 的上级组织id
String parentAgencyId = communityScore.getValue().get(NumConstant.ZERO).getParentAgencyId();
// 查询 组织名称
String agencyName = screenCustomerAgencyDao.selectParentAgencyInfo(customerId, communityScore.getKey());
if (null == agencyName){
throw new RuntimeException("在screen_customer_agency表中未查询到该客户下的组织名称:customerId =" + customerId + ", agencyId = " + communityScore.getKey());
}
// 补充表中其他字段
monthlyFormDTO = this.supplementIndexDataMonthlyTable(year, month, OrgTypeConstant.GRID, communityScore.getKey(),
parentAgencyId, agencyName, monthlyFormDTO);
// 补充表中其他字段
monthlyFormDTOList.add(monthlyFormDTO);
}
screenIndexDataMonthlyDao.deleteIndexDataMonthly(customerId, year, month, orgIds);
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId);
}
/**
* 将区直部门分值表 数据 插入月表 screenIndexDataMonthlyDao
*
* @param month 08
* @param year 2020
* @param customerId 客户id
* @param deptScoreDTOS 区直部门分值表 当前客户所属月份数据集
* @return void
* @Author zhangyong
* @Date 14:17 2020-09-03
**/
private void insertIndexDataMonthlyByDeptScore(String month, String year, String customerId, List<DeptScoreDTO> deptScoreDTOS){
List<IndexDataMonthlyFormDTO> monthlyFormDTOList = new ArrayList<>();
// 根据部门id 进行分组,最后组装一条数据 一个部门id 对应 4条数据
Map<String, List<DeptScoreDTO>> collect = deptScoreDTOS.stream().collect(Collectors.groupingBy(DeptScoreDTO::getDeptId));
String[] orgIds = new String[collect.size()];
int j = 0;
for(Map.Entry<String,List<DeptScoreDTO>> deptScore : collect.entrySet()){
IndexDataMonthlyFormDTO monthlyFormDTO = new IndexDataMonthlyFormDTO();
// 部门id
orgIds[j] = deptScore.getKey();
j++;
for ( int i = 0; i < deptScore.getValue().size(); i++){
if (NumConstant.ONE_STR.equals(deptScore.getValue().get(i).getIsTotal())){
// 是总分 总指数 = IS_TOTAL = 1
monthlyFormDTO.setIndexTotal(deptScore.getValue().get(i).getScore());
} else {
// 赋值 党建能力、治理能力、服务能力
monthlyFormDTO = this.setValueAblityMonthlyFor(deptScore.getValue().get(i).getIndexCode(),
deptScore.getValue().get(i).getScore(),
monthlyFormDTO);
}
}
// 查询网格的 上级组织id 和 组织名称
ScreenCustomerDeptEntity parentDeptInfo = screenCustomerDeptDao.selectParentDeptInfo(customerId, deptScore.getKey());
if (null == parentDeptInfo){
throw new RuntimeException("在screen_customer_dept表中未查询到该客户下的父级信息:customerId =" + customerId + ", deptId = " + deptScore.getKey());
}
// 补充表中其他字段
monthlyFormDTO = this.supplementIndexDataMonthlyTable(year, month, OrgTypeConstant.GRID, deptScore.getKey(),
parentDeptInfo.getParentAgencyId(), parentDeptInfo.getDeptName(), monthlyFormDTO);
monthlyFormDTOList.add(monthlyFormDTO);
}
screenIndexDataMonthlyDao.deleteIndexDataMonthly(customerId, year, month, orgIds);
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId);
}
/**
* 将区/街道相关分数表 数据 插入月表 screenIndexDataMonthlyDao
*
* @param month 08
* @param year 2020
* @param customerId 客户id
* @param agencyScoreDTOS /街道相关分数表 当前客户所属月份数据集
* @return void
* @Author zhangyong
* @Date 14:17 2020-09-03
**/
private void insertIndexDataMonthlyByAgencyScore(String month, String year, String customerId, List<AgencyScoreDTO> agencyScoreDTOS){
List<IndexDataMonthlyFormDTO> monthlyFormDTOList = new ArrayList<>();
// 根据组织id(eg:社区或者街道id) 进行分组,最后组装一条数据 一个组织id 对应 4条数据
Map<String, List<AgencyScoreDTO>> collect = agencyScoreDTOS.stream().collect(Collectors.groupingBy(AgencyScoreDTO::getAgencyId));
String[] orgIds = new String[collect.size()];
int j = 0;
for(Map.Entry<String,List<AgencyScoreDTO>> agencyScore : collect.entrySet()){
IndexDataMonthlyFormDTO monthlyFormDTO = new IndexDataMonthlyFormDTO();
// 组织id(eg:社区或者街道id)
orgIds[j] = agencyScore.getKey();
j++;
for ( int i = 0; i < agencyScore.getValue().size(); i++){
if (NumConstant.ONE_STR.equals(agencyScore.getValue().get(i).getIsTotal())){
// 是总分 总指数 = IS_TOTAL = 1
monthlyFormDTO.setIndexTotal(agencyScore.getValue().get(i).getScore());
} else {
// 赋值 党建能力、治理能力、服务能力
monthlyFormDTO = this.setValueAblityMonthlyFor(agencyScore.getValue().get(i).getIndexCode(),
agencyScore.getValue().get(i).getScore(),
monthlyFormDTO);
}
}
// 当前组织 的上级组织id
String parentAgencyId = agencyScore.getValue().get(NumConstant.ZERO).getParentAgencyId();
// 查询 组织名称
String agencyName = screenCustomerAgencyDao.selectParentAgencyInfo(customerId, agencyScore.getKey());
if (null == agencyName){
throw new RuntimeException("在screen_customer_agency表中未查询到该客户下的组织名称:customerId =" + customerId + ", agencyId = " + agencyScore.getKey());
}
// 补充表中其他字段
monthlyFormDTO = this.supplementIndexDataMonthlyTable(year, month, OrgTypeConstant.GRID, agencyScore.getKey(),
parentAgencyId, agencyName, monthlyFormDTO);
monthlyFormDTOList.add(monthlyFormDTO);
}
screenIndexDataMonthlyDao.deleteIndexDataMonthly(customerId, year, month, orgIds);
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId);
}
/**
* 指数-指数数据(每月数值) 字段补全待新增
* @param year 2020
* @param month 08
* @param orgType 组织类别 agency组织部门department网格grid
* @param orgId 组织Id 可以为网格机关id
* @param parentId 上级组织id
* @param orgName 组织名称
* @param monthlyFormDTO 待新增的DTO
* @return com.epmet.dto.screencoll.form.IndexDataMonthlyFormDTO
* @Author zhangyong
* @Date 15:29 2020-09-03
**/
private IndexDataMonthlyFormDTO supplementIndexDataMonthlyTable(String year, String month, String orgType, String orgId, String parentId,
String orgName, IndexDataMonthlyFormDTO monthlyFormDTO){
monthlyFormDTO.setYearId(year);
monthlyFormDTO.setMonthId(year + month);
monthlyFormDTO.setOrgType(orgType);
monthlyFormDTO.setOrgId(orgId);
// 根据网格id,查询其上级组织id、组织名称
monthlyFormDTO.setParentId(parentId);
monthlyFormDTO.setOrgName(orgName);
return monthlyFormDTO;
}
/**
* 赋值 党建能力治理能力服务能力
* (总指数 赋默认值)
* @param IndexCode 组织类别
* @param Score 分数
* @param monthlyFormDTO 待保存的数据
* @return com.epmet.dto.screencoll.form.IndexDataMonthlyFormDTO
* @Author zhangyong
* @Date 09:26 2020-09-04
**/
private IndexDataMonthlyFormDTO setValueAblityMonthlyFor(String IndexCode, BigDecimal Score,
IndexDataMonthlyFormDTO monthlyFormDTO){
// 赋默认值
if (null == monthlyFormDTO.getIndexTotal() && null == monthlyFormDTO.getPartyDevAblity()
&& null == monthlyFormDTO.getGovernAblity() && null == monthlyFormDTO.getServiceAblity()){
BigDecimal zero = new BigDecimal(NumConstant.ZERO);
monthlyFormDTO.setIndexTotal(zero);
monthlyFormDTO.setPartyDevAblity(zero);
monthlyFormDTO.setGovernAblity(zero);
monthlyFormDTO.setServiceAblity(zero);
}
// 赋实际值
if (IndexCodeEnum.DANG_JIAN_NENG_LI.getCode().equals(IndexCode)){
// 党建能力
monthlyFormDTO.setPartyDevAblity(Score);
} else if (IndexCodeEnum.ZHI_LI_NENG_LI.getCode().equals(IndexCode)){
// 治理能力
monthlyFormDTO.setGovernAblity(Score);
} else if (IndexCodeEnum.FU_WU_NENG_LI.getCode().equals(IndexCode)){
// 服务能力
monthlyFormDTO.setServiceAblity(Score);
}
return monthlyFormDTO;
}
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCollService.java

@ -100,7 +100,7 @@ public interface ScreenCollService {
* @Author zhangyong
* @Date 10:52 2020-08-18
**/
void insertDifficultyData(List<DifficultyDataFormDTO> formDTO, String customerId);
void insertDifficultyData(DifficultyDataFormDTO formDTO, String customerId);
/**
* 2党员基本情况

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

@ -30,6 +30,7 @@ import com.epmet.service.evaluationindex.screen.ScreenCollService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
@ -198,13 +199,13 @@ public class ScreenCollServiceImpl implements ScreenCollService {
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
@Transactional(rollbackFor = Exception.class)
public void insertDifficultyData(List<DifficultyDataFormDTO> formDTO, String customerId) {
if (null != formDTO && formDTO.size() > NumConstant.ZERO){
for (int i = NumConstant.ZERO; i < formDTO.size(); i++){
screenDifficultyDataDao.deleteDifficultyData(customerId, formDTO.get(i).getEventId(), formDTO.get(i).getOrgId());
}
screenDifficultyDataDao.batchInsertDifficultyData(formDTO, customerId);
public void insertDifficultyData(DifficultyDataFormDTO formDTO, String customerId) {
if(formDTO.getIsFirst()){
//直接删除当前客户下所有的数据
screenDifficultyDataDao.deleteDifficultyData(customerId);
}
if (null != formDTO && !CollectionUtils.isEmpty(formDTO.getDiffcultyDataList())){
screenDifficultyDataDao.batchInsertDifficultyData(formDTO.getDiffcultyDataList(), customerId);
}
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java

@ -210,7 +210,7 @@ public class DimAgencyServiceImpl extends BaseServiceImpl<DimAgencyDao, DimAgenc
return baseDao.selectTopAgency(customerId);
}
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@DataSource(value = DataSourceConstant.STATS, datasourceNameFromArg = true)
@Override
public List<DimAgencyEntity> getAgencyListByCustomerId(String customerId) {
if (StringUtils.isBlank(customerId)){

42
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml

@ -43,8 +43,27 @@
AND data_type = #{dataType}
</delete>
<select id="selectListAgencyScore" resultType="com.epmet.dto.indexcal.AgencyScoreDTO">
SELECT
CUSTOMER_ID customerId,
AGENCY_ID agencyId,
PARENT_AGENCY_ID parentAgencyId,
YEAR_ID yearId,
MONTH_ID monthId,
IS_TOTAL isTotal,
SCORE score,
INDEX_CODE indexCode
FROM
fact_index_agency_score
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
ORDER BY AGENCY_ID
</select>
<!-- 查询街道相关信息 -->
<select id="selectStreetInfo" resultType="com.epmet.dto.indexcal.AgencyScoreDTO">
<select id="selectAgencyScoreInfo" resultType="com.epmet.dto.indexcal.AgencyScoreDTO">
SELECT
CUSTOMER_ID,
AGENCY_ID,
@ -64,4 +83,23 @@
AND INDEX_CODE != "jiedaoxiangguan"
AND data_type = #{dataType}
</select>
</mapper>
<select id="selectAgencyScoreAvg" resultType="com.epmet.dto.indexcal.SubAgencyScoreAvgResultDTO">
SELECT
fics.agency_id,
fics.month_id,
fics.quarter_id,
fics.year_id,
AVG( fics.score ) AS score,
fics.customer_id,
PARENT_AGENCY_ID AS parentId
FROM
fact_index_agency_score fics
WHERE
fics.del_flag = '0'
AND fics.customer_id = #{customerId}
AND fics.month_id = #{monthId}
AND fics.index_code = #{indexCode}
GROUP BY fics.agency_id
</select>
</mapper>

18
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CpcScoreDao.xml

@ -3,6 +3,16 @@
<mapper namespace="com.epmet.dao.evaluationindex.indexcal.CpcScoreDao">
<delete id="deleteByMonthId">
delete from fact_index_cpc_score
where
CUSTOMER_ID = #{customerId,jdbcType=VARCHAR}
and MONTH_ID = #{monthId,jdbcType=VARCHAR}
<if test="indexCode != null and indexCode !=''">
and INDEX_CODE = #{indexCode,jdbcType=VARCHAR}
</if>
</delete>
<resultMap type="com.epmet.entity.evaluationindex.indexcal.CpcScoreEntity" id="cpcScoreMap">
<result property="id" column="ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
@ -18,14 +28,6 @@
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<delete id="deleteByMonthId">
delete from fact_index_cpc_score
where
CUSTOMER_ID = #{customerId,jdbcType=VARCHAR}
and MONTH_ID = #{monthId,jdbcType=VARCHAR}
and INDEX_CODE = #{indexCode,jdbcType=VARCHAR}
</delete>
<select id="getPartScore" resultType="com.epmet.entity.evaluationindex.indexcal.CpcScoreEntity">
select
CUSTOMER_ID,AGENCY_ID,GRID_ID,YEAR_ID,MONTH_ID,USER_ID,SCORE,INDEX_CODE FROM fact_index_cpc_score

42
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/DeptScoreDao.xml

@ -3,4 +3,44 @@
<mapper namespace="com.epmet.dao.evaluationindex.indexcal.DeptScoreDao">
</mapper>
<select id="selectListDeptScore" resultType="com.epmet.dto.indexcal.DeptScoreDTO">
SELECT
CUSTOMER_ID customerId,
DEPT_ID deptId,
YEAR_ID yearId,
MONTH_ID monthId,
IS_TOTAL isTotal,
SCORE score,
INDEX_CODE indexCode
FROM
fact_index_dept_score
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
ORDER BY DEPT_ID
</select>
<!-- 所有直属部门治理能力平均值 -->
<select id="selectGovernDeptScoreAvg" resultType="com.epmet.dto.indexcal.SubAgencyScoreAvgResultDTO">
SELECT
fidc.agency_id,
fidc.month_id,
fidc.quarter_id,
fidc.year_id,
AVG( fidc.score ) AS score,
fidc.customer_id,
sca.pid AS parentId
FROM
fact_index_dept_score fidc
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = fidc.AGENCY_ID
WHERE
fidc.del_flag = '0'
AND fidc.IS_TOTAL = '0'
AND fidc.customer_id = #{customerId}
AND fidc.month_id = #{monthId}
AND fidc.index_code = #{indexCode}
GROUP BY fidc.agency_id
</select>
</mapper>

7
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml

@ -3,10 +3,11 @@
<mapper namespace="com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyDao">
<delete id="deleteFactIndexPartyAblityCpcMonthly">
<delete id="deleteFactIndexPartyAblityCpcMonthly" parameterType="map">
delete from fact_index_party_ablity_cpc_monthly
where CUSTOMER_ID = #{customerId} AND AGENCY_ID = #{agencyId} AND GRID_ID = #{gridId} AND USER_ID = #{userId}
AND YEAR_ID = #{yearId} AND MONTH_ID = #{monthId} AND QUARTER_ID = #{quarterId}
where CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
limit 1000
</delete>
<insert id="batchInsertFactIndexPartyAblityCpcMonthly" parameterType="map">

20
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexCommunityScoreDao.xml

@ -84,4 +84,22 @@
GROUP BY fics.agency_id
</select>
</mapper>
<select id="selectListCommunityScore" resultType="com.epmet.dto.screen.FactIndexCommunityScoreDTO">
SELECT
CUSTOMER_ID customerId,
AGENCY_ID agencyId,
PARENT_AGENCY_ID parentAgencyId,
YEAR_ID yearId,
MONTH_ID monthId,
IS_TOTAL isTotal,
SCORE score,
INDEX_CODE indexCode
FROM
fact_index_community_score
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
ORDER BY AGENCY_ID
</select>
</mapper>

21
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexGridScoreDao.xml

@ -24,4 +24,23 @@
AND figc.index_code = #{indexCode}
GROUP BY figc.agency_id
</select>
</mapper>
<select id="selectListGridScore" resultType="com.epmet.dto.screen.FactIndexGridScoreDTO">
SELECT
CUSTOMER_ID customerId,
GRID_ID gridId,
AGENCY_ID agencyId,
YEAR_ID yearId,
MONTH_ID monthId,
IS_TOTAL isTotal,
SCORE score,
INDEX_CODE indexCode
FROM
fact_index_grid_score
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
ORDER BY GRID_ID
</select>
</mapper>

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

@ -60,4 +60,14 @@
</foreach>
</insert>
<select id="selectParentAgencyInfo" parameterType="map" resultType="String">
SELECT
AGENCY_NAME agencyName
FROM
screen_customer_agency
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID =#{customerId}
AND AGENCY_ID = #{agencyId}
</select>
</mapper>

11
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerDeptDao.xml

@ -64,4 +64,15 @@
AND m.CUSTOMER_ID =#{customerId}
AND m.DEPT_ID =#{deptId}
</select>
<select id="selectParentDeptInfo" parameterType="map" resultType="com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity">
SELECT
PARENT_AGENCY_ID parentAgencyId,
DEPT_NAME deptName
FROM
screen_customer_dept
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID =#{customerId}
AND DEPT_ID = #{deptId}
</select>
</mapper>

12
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerGridDao.xml

@ -105,4 +105,16 @@
AND m.CUSTOMER_ID =#{customerId}
AND m.GRID_ID = #{gridId}
</select>
<select id="selectParentGridInfo" parameterType="map" resultType="com.epmet.dto.ScreenCustomerGridDTO">
SELECT
GRID_NAME gridName,
PARENT_AGENCY_ID parentAgencyId
FROM
screen_customer_grid
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID =#{customerId}
AND GRID_ID = #{gridId}
</select>
</mapper>

2
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenDifficultyDataDao.xml

@ -5,7 +5,7 @@
<delete id="deleteDifficultyData">
delete from screen_difficulty_data
where CUSTOMER_ID = #{customerId} AND EVENT_ID = #{eventId} AND ORG_ID = #{orgId}
where CUSTOMER_ID = #{customerId}
</delete>
<insert id="batchInsertDifficultyData" parameterType="map">

3
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ExternalAppFormDTO.java

@ -9,8 +9,9 @@ public class ExternalAppFormDTO {
public interface AddExternalApp {}
public interface UpdateExternalApp {}
public interface UpdateAppSecret {}
@NotBlank(message = "缺少应用ID", groups = { UpdateExternalApp.class })
@NotBlank(message = "缺少应用ID", groups = { UpdateExternalApp.class, UpdateAppSecret.class })
private String appId;
@NotBlank(message = "缺少应用名称", groups = { AddExternalApp.class, UpdateExternalApp.class })

17
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalAppController.java

@ -1,5 +1,6 @@
package com.epmet.controller;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.Result;
@ -109,4 +110,20 @@ public class ExternalAppController {
return new Result<List<String>>().ok(customerIds);
}
/**
* 重置应用秘钥
* @param formDTO
* @return
*/
@PostMapping("/resetsecret")
public Result resetSecret(@RequestBody ExternalAppFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, ExternalAppFormDTO.UpdateAppSecret.class);
String newSecret = externalAppService.resetSecret(formDTO.getAppId());
if (StringUtils.isBlank(newSecret)) {
return new Result().error(EpmetErrorCode.OPER_EXT_APP_SECRET_RESET_FAIL.getCode(),
EpmetErrorCode.OPER_EXT_APP_SECRET_RESET_FAIL.getMsg());
}
return new Result().ok(newSecret);
}
}

1
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalAppSecretDao.java

@ -40,4 +40,5 @@ public interface ExternalAppSecretDao extends BaseDao<ExternalAppSecretEntity> {
*/
ExternalAppSecretEntity getSecretsByAppId(@Param("appId") String appId);
int updateSecret(@Param("appId") String appId, @Param("secret") String secret);
}

2
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalAppService.java

@ -36,4 +36,6 @@ public interface ExternalAppService {
PageData<ExternalAppResultDTO> listPage(Integer pageNo, Integer pageSize, String customerId);
List<String> getCustomerIds();
String resetSecret(String appId);
}

9
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppServiceImpl.java

@ -136,4 +136,13 @@ public class ExternalAppServiceImpl implements ExternalAppService {
return externalAppDao.getCustomerIds();
}
@Override
public String resetSecret(String appId) {
String secret = genSecret();
if (externalAppSecretDao.updateSecret(appId, secret) > 0) {
return secret;
}
return null;
}
}

7
epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppSecretDao.xml

@ -15,6 +15,13 @@
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<!--更新秘钥-->
<update id="updateSecret">
update external_app_secret
set SECRET=#{secret}
where ID = #{appId}
</update>
<select id="getSecretsByAppId" resultType="com.epmet.entity.ExternalAppSecretEntity">
SELECT
ID,

Loading…
Cancel
Save