Browse Source

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

master
wangchao 5 years ago
parent
commit
caedc863fc
  1. 36
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java
  2. 11
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/ContactMassLineChartResultDTO.java
  3. 2
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/screen/impl/PartyMemberLeadServiceImpl.java
  4. 17
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/IndexCalConstant.java
  5. 52
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/GridScoreDTO.java
  6. 30
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/GridScoreDetailDTO.java
  7. 109
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityGovrnFiveScoreDTO.java
  8. 110
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityPartyFiveScoreDTO.java
  9. 55
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityScoreDTO.java
  10. 107
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityServiceFiveScoreDTO.java
  11. 59
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/CommunityActivityCountResultDTO.java
  12. 5
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/CommunityPublishArticleCountResultDTO.java
  13. 21
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/MaxAndMinBigDecimalResultDTO.java
  14. 46
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridGovernAvgResultDTO.java
  15. 5
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridPartyAvgResultDTO.java
  16. 51
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridServiceAvgResultDTO.java
  17. 20
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java
  18. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java
  19. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexGovrnAblityGridMonthlyDao.java
  20. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java
  21. 11
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexServiceAblityOrgMonthlyDao.java
  22. 55
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexscore/CpcScoreDao.java
  23. 38
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexscore/GridScoreDao.java
  24. 33
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityGovrnFiveScoreDao.java
  25. 45
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityPartyFiveScoreDao.java
  26. 35
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityScoreDao.java
  27. 33
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityServiceFiveScoreDao.java
  28. 20
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexGridScoreDao.java
  29. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/ScreenCustomerGridDao.java
  30. 38
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/indexscore/CpcScoreEntity.java
  31. 74
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/indexscore/GridScoreEntity.java
  32. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityFiveScoreEntity.java
  33. 77
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityGovrnFiveScoreEntity.java
  34. 34
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityScoreEntity.java
  35. 77
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityServiceFiveScoreEntity.java
  36. 1
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/eum/IndexCodeEnum.java
  37. 48
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java
  38. 253
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/CpcIndexCalculateServiceImpl.java
  39. 419
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/GridCorreLationServiceImpl.java
  40. 23
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexCalculateCommunityService.java
  41. 373
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateCommunityServiceImpl.java
  42. 27
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java
  43. 14
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexInputVO.java
  44. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/util/Pinyin4jUtil.java
  45. 11
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexGovrnAblityGridMonthlyDao.xml
  46. 24
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml
  47. 3
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml
  48. 3
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml
  49. 19
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexServiceAblityOrgMonthlyDao.xml
  50. 118
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/CpcScoreDao.xml
  51. 96
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/GridScoreDao.xml
  52. 6
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityGovrnFiveScoreDao.xml
  53. 27
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityPartyFiveScoreDao.xml
  54. 56
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityScoreDao.xml
  55. 6
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityServiceFiveScoreDao.xml
  56. 44
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexGridScoreDao.xml
  57. 6
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailDao.xml
  58. 13
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml
  59. 12
      epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/DemoScoreCal.java

36
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java

@ -9,6 +9,7 @@
package com.epmet.commons.tools.utils;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
@ -33,6 +34,11 @@ public class DateUtils {
public static final List<Integer> Q3Months = Arrays.asList(7, 8, 9);
public static final List<Integer> Q4Months = Arrays.asList(10, 11, 12);
public static final List<String> Q1MonthsStrList = Arrays.asList("1", "2", "3","01","02","03");
public static final List<String> Q2MonthsStrList = Arrays.asList("4", "5", "6","04", "05", "06");
public static final List<String> Q3MonthsStrList = Arrays.asList("7", "8", "9","07", "08", "09");
public static final List<String> Q4MonthsStrList = Arrays.asList("10", "11", "12");
/** 时间格式(yyyy-MM-dd) */
public final static String DATE_PATTERN = "yyyy-MM-dd";
/** 时间格式(yyyy-MM-dd HH:mm:ss) */
@ -298,6 +304,29 @@ public class DateUtils {
return 4;
}
/**
* 获取季度
* @param monthId yyyyMM
* @return yyyyQ1yyyyQ2yyyyQ3yyyyQ4
*/
public static String getQuarterId(String monthId) {
String year = monthId.substring(0, 4);
String month = monthId.substring(4, 6);
if (Q1MonthsStrList.contains(month)) {
return year.concat("Q1");
}
if (Q2MonthsStrList.contains(month)) {
return year.concat("Q2");
}
if (Q3MonthsStrList.contains(month)) {
return year.concat("Q3");
}
if(Q4MonthsStrList.contains(month)){
return year.concat("Q4");
}
return StrConstant.EPMETY_STR;
}
/**
* 根据季度查询季度的月份列表
* @param quarterIndex
@ -557,4 +586,11 @@ public class DateUtils {
System.out.println(comparteDate(yesterDay,today));
System.out.println(comparteDate(tomorrow,today));
}
public static String getYearId(String monthId) {
if (StringUtils.isNotBlank(monthId) && monthId.length() > 4) {
return monthId.substring(NumConstant.ZERO, NumConstant.FOUR);
}
return StrConstant.EPMETY_STR;
}
}

11
epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/ContactMassLineChartResultDTO.java

@ -1,5 +1,6 @@
package com.epmet.screen.dto.result;
import com.epmet.commons.tools.constant.NumConstant;
import lombok.Data;
import java.io.Serializable;
@ -28,4 +29,14 @@ public class ContactMassLineChartResultDTO implements Serializable {
* 群成员数
*/
private List<Integer> groupMemberData;
/**
* 党员建群数
**/
private Integer groupTotal = NumConstant.ZERO;
/**
* 党成员数
* */
private Integer groupMemberTotal = NumConstant.ZERO;
}

2
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/screen/impl/PartyMemberLeadServiceImpl.java

@ -110,6 +110,8 @@ public class PartyMemberLeadServiceImpl implements PartyMemberLeadService {
result.setXAxis(xAxis);
result.setGroupData(groupData);
result.setGroupMemberData(groupMemberData);
result.setGroupTotal(groupData.stream().mapToInt(Integer :: intValue).sum());
result.setGroupMemberTotal(groupMemberData.stream().mapToInt(Integer :: intValue).sum());
return result;
}

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

@ -12,9 +12,26 @@ public interface IndexCalConstant {
String GRID_ID="GRID_ID";
String AGENCY_ID="AGENCY_ID";
String CUSTOMER_ID="CUSTOMER_ID";
String MONTH_ID="MONTH_ID";
String USER_ID="USER_ID";
String YEAR_ID = "YEAR_ID";
String COMMUNITY_GOVERN = "zhilinengli";
String COMMUNITY_PARTY = "dangjiannengli";
String COMMUNITY_SERVICE = "fuwunengli";
String COMMUNITY_SERVICE_AVG = "shequxiajisywgfwnldfpjz";
String COMMUNITY_GOVERN_AVG = "shequxiashusywgzlnlhzpyz";
String COMMUNITY_PARTY_AVG = "xiazhusuoyouwgddjnlpjz";
String COMMUNITY_RELATE = "shequxiangguan";
}

52
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/GridScoreDTO.java

@ -0,0 +1,52 @@
package com.epmet.dto.indexcal;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 网格相关分值
*
* @author yinzuomei@elink-cn.com
* @date 2020/8/31 16:38
*/
@Data
public class GridScoreDTO implements Serializable {
/**
* 网格Id
*/
private String gridId;
/**
* 客户Id
*/
private String customerId;
/**
* 网格所属的机关Id
*/
private String agencyId;
/**
* 所有上级ID用英文逗号分开
*/
private String allParentIds;
/**
* 季度id: yyyyQ1yyyyQ2yyyyQ3yyyyQ4
*/
private String quarterId;
/**
* 年度ID: yyyy
*/
private String yearId;
/**
* 月维度Id: yyyyMM
*/
private String monthId;
private List<GridScoreDetailDTO> detailList;
}

30
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/GridScoreDetailDTO.java

@ -0,0 +1,30 @@
package com.epmet.dto.indexcal;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 网格相关分值
*
* @author yinzuomei@elink-cn.com
* @date 2020/8/31 16:39
*/
@Data
public class GridScoreDetailDTO implements Serializable {
/**
* 1总分0不是
*/
private String isTotal;
/**
* 分值
*/
private BigDecimal score;
/**
* 党建能力dangjiannengli治理能力zhilinengli服务能力fuwunengli网格相关wanggexiangguan
*/
private String indexCode;
}

109
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityGovrnFiveScoreDTO.java

@ -1,109 +0,0 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto.screen;
import java.io.Serializable;
import java.math.BigDecimal;
import lombok.Data;
/**
* 社区相关-治理能力五级权重分数表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-27
*/
@Data
public class FactIndexCommunityGovrnFiveScoreDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
private String id;
/**
* 机关iD
*/
private String agencyId;
/**
* 月份ID
*/
private String monthId;
/**
* 指标ID
*/
private String indexId;
/**
* 总指数分值
*/
private BigDecimal totalScore;
/**
* 党建能力分值
*/
private BigDecimal partyAbilityScore;
/**
* 治理能力分值
*/
private BigDecimal govrnAbilityScore;
/**
* 服务能力分值
*/
private BigDecimal serviceAbilityScore;
/**
* 删除状态0正常1删除
*/
private Integer delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 更新人
*/
private String updatedBy ;
public FactIndexCommunityGovrnFiveScoreDTO() {
this.agencyId = "";
this.monthId = "";
this.indexId = "";
this.totalScore = new BigDecimal(0);
this.partyAbilityScore = new BigDecimal(0);
this.govrnAbilityScore = new BigDecimal(0);
this.serviceAbilityScore = new BigDecimal(0);
this.delFlag = 0;
this.revision = 0;
this.createdBy = "APP_USER";
this.updatedBy = "APP_USER";
}
}

110
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityPartyFiveScoreDTO.java

@ -1,110 +0,0 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto.screen;
import java.io.Serializable;
import java.math.BigDecimal;
import lombok.Data;
/**
* 社区相关-党建能力五级权重分数表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-27
*/
@Data
public class FactIndexCommunityPartyFiveScoreDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
private String id;
/**
* 机关ID
*/
private String agencyId;
/**
* 月度ID
*/
private String monthId;
/**
* 指标ID
*/
private String indexId;
/**
* 总指数分值
*/
private BigDecimal totalScore;
/**
* 党建能力分值
*/
private BigDecimal partyAbilityScore;
/**
* 治理能力分值
*/
private BigDecimal govrnAbilityScore;
/**
* 服务能力分值
*/
private BigDecimal serviceAbilityScore;
/**
* 删除状态0正常1删除
*/
private Integer delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 更新人
*/
private String updatedBy;
public FactIndexCommunityPartyFiveScoreDTO() {
this.agencyId = "";
this.monthId = "";
this.indexId = "";
this.totalScore = new BigDecimal(0);
this.partyAbilityScore = new BigDecimal(0);
this.govrnAbilityScore = new BigDecimal(0);
this.serviceAbilityScore = new BigDecimal(0);
this.delFlag = 0;
this.revision = 0;
this.createdBy = "APP_USER";
this.updatedBy = "APP_USER";
}
}

55
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityScoreDTO.java

@ -27,7 +27,7 @@ import java.math.BigDecimal;
* 社区相关分数表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-27
* @since v1.0.0 2020-08-31
*/
@Data
public class FactIndexCommunityScoreDTO implements Serializable {
@ -35,49 +35,59 @@ public class FactIndexCommunityScoreDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
* ID 主键
*/
private String id;
/**
* 机关ID
* 客户Id
*/
private String customerId;
/**
* 组织id
*/
private String agencyId;
/**
* 月份ID
* 社区上一级组织id
*/
private String monthId;
private String parentAgencyId;
/**
* 年度ID: yyyy
*/
private String yearId;
/**
* 季度ID
* 季度id: yyyyQ1yyyyQ2yyyyQ3yyyyQ4
*/
private String quarterId;
/**
* 年度ID
* 月维度Id: yyyyMM
*/
private String yearId;
private String monthId;
/**
* 指标ID
* 1总分0不是默认0
*/
private String indexId;
private String isTotal;
/**
*
*
*/
private BigDecimal score;
/**
* 党建能力party治理能力govrn服务能力service
* 党建能力dangjiannengli治理能力zhilinengli服务能力fuwunengli社区相关shequxiangguan
*/
private String type;
private String indexCode;
/**
* 删除状态0正常1删除
* 删除状态
*/
private Integer delFlag;
private Integer delFlag;
/**
* 乐观锁
@ -104,4 +114,19 @@ public class FactIndexCommunityScoreDTO implements Serializable {
*/
private Date updatedTime;
public FactIndexCommunityScoreDTO() {
this.customerId = "";
this.agencyId = "";
this.parentAgencyId = "";
this.yearId = "";
this.quarterId = "";
this.monthId = "";
this.isTotal = "0";
this.score = new BigDecimal(0);
this.indexCode = "";
this.delFlag = 0;
this.revision = 0;
this.createdBy = "APP_USER";
this.updatedBy = "APP_USER";
}
}

107
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityServiceFiveScoreDTO.java

@ -1,107 +0,0 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto.screen;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import java.math.BigDecimal;
/**
* 社区相关-服务能力五级权重分数表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-27
*/
@Data
public class FactIndexCommunityServiceFiveScoreDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
private String id;
/**
* 机关ID
*/
private String agencyId;
/**
* 月度ID
*/
private String monthId;
/**
* 指标ID
*/
private String indexId;
/**
* 总指数分值
*/
private BigDecimal totalScore;
/**
* 党建能力分值
*/
private BigDecimal partyAbilityScore;
/**
* 治理能力分值
*/
private BigDecimal govrnAbilityScore;
/**
* 服务能力分值
*/
private BigDecimal serviceAbilityScore;
/**
* 删除状态0正常1删除
*/
private Integer delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

59
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/CommunityActivityCountResultDTO.java

@ -0,0 +1,59 @@
package com.epmet.dto.screen.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/8/31 2:12 下午
*/
@Data
public class CommunityActivityCountResultDTO implements Serializable {
private static final long serialVersionUID = -6623426101220283941L;
/**
* 客户ID
*/
private String customerId;
/**
* 机关ID
*/
private String agencyId;
/**
* 上级组织ID
*/
private String parentId;
/**
* 月度ID
*/
private String monthId;
/**
* 季度ID
*/
private String quarterId;
/**
* 年度ID
*/
private String yearId;
/**
* 发文数
*/
public Integer activityCount;
public CommunityActivityCountResultDTO() {
this.agencyId = "";
this.parentId = "";
this.monthId = "";
this.quarterId = "";
this.yearId = "";
this.activityCount = 0;
}
}

5
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/CommunityPublishArticleCountResultDTO.java

@ -13,6 +13,11 @@ public class CommunityPublishArticleCountResultDTO implements Serializable {
private static final long serialVersionUID = -8260746179353253237L;
/**
* 客户ID
*/
private String customerId;
/**
* 机关ID
*/

21
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/MaxAndMinBigDecimalResultDTO.java

@ -0,0 +1,21 @@
package com.epmet.dto.screen.result;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @Author zxc
* @DateTime 2020/8/30 8:11 下午
*/
@Data
public class MaxAndMinBigDecimalResultDTO implements Serializable {
private static final long serialVersionUID = 76227645470470839L;
private BigDecimal min;
private BigDecimal max;
}

46
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridGovernAvgResultDTO.java

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

5
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridPartyAvgResultDTO.java

@ -19,6 +19,11 @@ public class SubGridPartyAvgResultDTO implements Serializable {
*/
private String agencyId;
/**
* 客户ID
*/
private String customerId;
/**
* 上级组织ID
*/

51
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridServiceAvgResultDTO.java

@ -0,0 +1,51 @@
package com.epmet.dto.screen.result;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @Author zxc
* @DateTime 2020/8/31 1:53 下午
*/
@Data
public class SubGridServiceAvgResultDTO implements Serializable {
private static final long serialVersionUID = -405197363477213644L;
/**
*
*/
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;
}

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

@ -120,7 +120,25 @@ public class DemoController {
@PostMapping("zxc")
public Result getZxc(){
// indexCalculateCommunityService.communityPublishArticleCountCalculate("b09527201c4409e19d1dbc5e3c3429a1","202008");
indexCalculateCommunityService.communityPublishArticleCountCalculate("","202008");
indexCalculateCommunityService.communityGovernAbilityCalculate("b09527201c4409e19d1dbc5e3c3429a1","202008");
return new Result();
}
@PostMapping("zxc1")
public Result getZxc1(){
indexCalculateCommunityService.communityPartyCalculate("b09527201c4409e19d1dbc5e3c3429a1","202008");
return new Result();
}
@PostMapping("zxc2")
public Result getZxc2(){
indexCalculateCommunityService.communityServiceAbilityCalculate("b09527201c4409e19d1dbc5e3c3429a1","202008");
return new Result();
}
@PostMapping("zxcAll")
public Result getZxcAll(){
indexCalculateCommunityService.communityRelate("b09527201c4409e19d1dbc5e3c3429a1","202008");
return new Result();
}

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

@ -44,7 +44,7 @@ public class IndexCalculateController {
}
@PostMapping("getMax")
public Result getMax(){
CalculateCommonFormDTO calculateCommonFormDTO = new CalculateCommonFormDTO("c1","202008");
CalculateCommonFormDTO calculateCommonFormDTO = new CalculateCommonFormDTO("b09527201c4409e19d1dbc5e3c3429a1","202008");
cpcIndexCalculateService.cpcIndexCalculate(calculateCommonFormDTO);
return new Result();
}

10
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexGovrnAblityGridMonthlyDao.java

@ -18,6 +18,7 @@
package com.epmet.dao.indexcoll;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.indexcal.PageQueryGridFormDTO;
import com.epmet.dto.indexcollect.form.GridGovrnAbilityFormDTO;
import com.epmet.entity.indexcoll.FactIndexGovrnAblityGridMonthlyEntity;
@ -85,4 +86,13 @@ public interface FactIndexGovrnAblityGridMonthlyDao extends BaseDao<FactIndexGov
* @Date 2020/8/27 13:10
**/
Map<String, Object> selectGovrnAblityGridMinAndMax(@Param("customerId") String customerId, @Param("monthId") String monthId);
/**
* @return int
* @param formDTO
* @author yinzuomei
* @description 查询当前月共上传了多少条记录治理能力-网格相关事实表
* @Date 2020/8/31 14:31
**/
int selectCount(CalculateCommonFormDTO formDTO);
}

3
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java

@ -25,6 +25,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 治理能力-街道及社区相关数据
@ -70,5 +71,5 @@ public interface FactIndexGovrnAblityOrgMonthlyDao extends BaseDao<FactIndexGovr
* @author zxc
* @date 2020/8/26 1:40 下午
*/
List<CommunityGovernAbilityResultDTO> selectCommunityGovernAbility(@Param("customerId")String customerId, @Param("monthId")String monthId);
List<Map<String,Object>> selectCommunityGovernAbility(@Param("customerId")String customerId, @Param("monthId")String monthId);
}

11
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexServiceAblityOrgMonthlyDao.java

@ -19,6 +19,8 @@ package com.epmet.dao.indexcoll;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.indexcollect.form.OrgServiceAbilityFormDTO;
import com.epmet.dto.screen.result.CommunityActivityCountResultDTO;
import com.epmet.dto.screen.result.CommunityPublishArticleCountResultDTO;
import com.epmet.entity.indexcoll.FactIndexServiceAblityOrgMonthlyEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -62,4 +64,13 @@ public interface FactIndexServiceAblityOrgMonthlyDao extends BaseDao<FactIndexSe
* @Date 10:52 2020-08-20
**/
void batchInsertFactIndexServiceAblityOrgMonthly(@Param("list") List<OrgServiceAbilityFormDTO> list, @Param("customerId")String customerId);
/**
* @Description 社区活动组织次数
* @param customerId
* @param monthId
* @author zxc
* @date 2020/8/31 2:15 下午
*/
List<CommunityActivityCountResultDTO> selectActivityCount(@Param("customerId")String customerId, @Param("monthId")String monthId);
}

55
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexscore/CpcScoreDao.java

@ -18,8 +18,14 @@
package com.epmet.dao.indexscore;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.entity.indexscore.CpcScoreEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;
/**
* 党员相关分值
@ -29,5 +35,52 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface CpcScoreDao extends BaseDao<CpcScoreEntity> {
/**
* @param customerId
* @param monthId
* @param gridId
* @return java.math.BigDecimal
* @author yinzuomei
* @description 获取网格内党员的联系群众能力考评分平均值
* @Date 2020/8/31 10:56
**/
BigDecimal selectGridContactMassesAvgValue(@Param("customerId") String customerId,
@Param("monthId") String monthId,
@Param("gridId") String gridId);
/**
* @param formDTO
* @return java.util.List<java.math.BigDecimal>
* @author yinzuomei
* @description 获取网格内党员的联系群众能力考评分平均值的最大值最小值
* @Date 2020/8/31 12:10
**/
List<BigDecimal> selectListGridContactMassesAvgValue(CalculateCommonFormDTO formDTO);
/**
* @param calculateCommonFormDTO
* @return java.util.List<java.math.BigDecimal>
* @author yinzuomei
* @description 网格内党员的参与议事能力考评分平均值 最大值最小值
* @Date 2020/8/31 14:42
**/
List<BigDecimal> selectListJoinIssueAvgValue(CalculateCommonFormDTO calculateCommonFormDTO);
/**
* @param customerId
* @param monthId
* @param gridId
* @return java.math.BigDecimal
* @author yinzuomei
* @description 组织内党员的参与议事能力考评分平均值
* @Date 2020/8/31 15:51
**/
BigDecimal selectGridJoinIssueAvgValue(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("gridId") String gridId);
int deleteByMonthId(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("indexCode") String indexCode);
List<CpcScoreEntity> getPartScore(@Param("customerId") String customerId, @Param("monthId") String monthId);
int insertBatch(@Param("list") Collection<CpcScoreEntity> values);
}

38
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexscore/GridScoreDao.java

@ -18,8 +18,13 @@
package com.epmet.dao.indexscore;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.indexcal.GridScoreDTO;
import com.epmet.entity.indexscore.GridScoreEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 网格相关分值
@ -29,5 +34,36 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface GridScoreDao extends BaseDao<GridScoreEntity> {
/**
* @param customerId
* @param monthId
* @param indexCode
* @param isTotal 1总分0不是
* @return int
* @author yinzuomei
* @description
* @Date 2020/8/31 14:00
**/
int deleteByCusAndMonthId(@Param("customerId") String customerId,
@Param("monthId") String monthId,
@Param("indexCode") String indexCode,
@Param("isTotal") String isTotal);
/**
* @return int
* @param gridScoreEntityList
* @author yinzuomei
* @description
* @Date 2020/8/31 14:01
**/
int insertBatches(List<GridScoreEntity> gridScoreEntityList);
/**
* @return java.util.List<com.epmet.dto.indexcal.GridScoreDTO>
* @param formDTO
* @author yinzuomei
* @description
* @Date 2020/8/31 16:42
**/
List<GridScoreDTO> selectList(CalculateCommonFormDTO formDTO);
}

33
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityGovrnFiveScoreDao.java

@ -1,33 +0,0 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dao.screen;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.screen.FactIndexCommunityGovrnFiveScoreEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 社区相关-治理能力五级权重分数表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-27
*/
@Mapper
public interface FactIndexCommunityGovrnFiveScoreDao extends BaseDao<FactIndexCommunityGovrnFiveScoreEntity> {
}

45
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityPartyFiveScoreDao.java

@ -1,45 +0,0 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dao.screen;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.screen.FactIndexCommunityPartyFiveScoreDTO;
import com.epmet.entity.screen.FactIndexCommunityPartyFiveScoreEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 社区相关-党建能力五级权重分数表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-27
*/
@Mapper
public interface FactIndexCommunityPartyFiveScoreDao extends BaseDao<FactIndexCommunityPartyFiveScoreEntity> {
/**
* @Description 党建能力社区中间表插入
* @param lists
* @author zxc
* @date 2020/8/27 5:05 下午
*/
void insertCommunityPartyRecord(@Param("lists")List<FactIndexCommunityPartyFiveScoreDTO> lists);
}

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

@ -18,16 +18,47 @@
package com.epmet.dao.screen;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.screen.FactIndexCommunityScoreDTO;
import com.epmet.entity.screen.FactIndexCommunityScoreEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 社区相关分数表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-27
* @since v1.0.0 2020-08-31
*/
@Mapper
public interface FactIndexCommunityScoreDao extends BaseDao<FactIndexCommunityScoreEntity> {
/**
* @Description 党建能力社区中间表插入
* @param lists
* @author zxc
* @date 2020/8/27 5:05 下午
*/
void insertCommunityPartyRecord(@Param("lists") List<FactIndexCommunityScoreDTO> lists);
/**
* @Description 删除旧记录
* @param customerId
* @param monthId
* @param indexCode
* @author zxc
* @date 2020/9/1 9:03 上午
*/
void deleteOldRecord(@Param("customerId") String customerId,@Param("monthId")String monthId,@Param("indexCode")String indexCode);
/**
* @Description 查询社区相关信息
* @param customerId
* @param monthId
* @author zxc
* @date 2020/9/1 9:41 上午
*/
List<FactIndexCommunityScoreDTO> selectCommunityInfo(@Param("customerId") String customerId,@Param("monthId")String monthId);
}

33
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityServiceFiveScoreDao.java

@ -1,33 +0,0 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dao.screen;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.screen.FactIndexCommunityServiceFiveScoreEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 社区相关-服务能力五级权重分数表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-27
*/
@Mapper
public interface FactIndexCommunityServiceFiveScoreDao extends BaseDao<FactIndexCommunityServiceFiveScoreEntity> {
}

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

@ -18,7 +18,9 @@
package com.epmet.dao.screen;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.screen.result.SubGridGovernAvgResultDTO;
import com.epmet.dto.screen.result.SubGridPartyAvgResultDTO;
import com.epmet.dto.screen.result.SubGridServiceAvgResultDTO;
import com.epmet.entity.screen.FactIndexGridScoreEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -43,4 +45,22 @@ public interface FactIndexGridScoreDao extends BaseDao<FactIndexGridScoreEntity>
*/
List<SubGridPartyAvgResultDTO> selectSubGridPartyAvgScore(@Param("customerId")String customerId,@Param("monthId")String monthId);
/**
* @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);
}

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

@ -84,4 +84,14 @@ public interface ScreenCustomerGridDao extends BaseDao<ScreenCustomerGridEntity>
* @Date 2020/8/27 14:42
**/
List<ScreenCustomerGridDTO> pageListByCustomerId(PageQueryGridFormDTO formDTO);
/**
* @param customerId 客户id
* @param gridId 网格id
* @return java.lang.String
* @author yinzuomei
* @description 查询网格所属的组织id
* @Date 2020/8/31 12:35
**/
ScreenCustomerGridDTO selectParentAgencyId(@Param("customerId") String customerId, @Param("gridId") String gridId);
}

38
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/indexscore/CpcScoreEntity.java

@ -18,13 +18,11 @@
package com.epmet.entity.indexscore;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.Date;
/**
* 党员相关分值
@ -54,34 +52,34 @@ public class CpcScoreEntity extends BaseEpmetEntity {
*/
private String gridId;
/**
* 用户id
*/
private String userId;
/**
* 维度Id: yyyyMM
* 年维度Id: yyyy
*/
private String monthId;
private String yearId;
/**
* 党建能力分值
*/
private BigDecimal partyAblityScore;
/**
* 月维度Id: yyyyMM
*/
private String monthId;
/**
* 参与议事分值
*/
private BigDecimal joinIssueScore;
/**
* 用户id
*/
private String userId;
/**
* 党务活动分值
* 分值
*/
private BigDecimal partyWorkActScore;
private BigDecimal score;
/**
* 联系群众分值
* 指标code
*/
private BigDecimal contactMassesScore;
private String indexCode;
/**
* 是否是总分 1是0不是
*/
private String isTotal;
}

74
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/indexscore/GridScoreEntity.java

@ -39,54 +39,54 @@ public class GridScoreEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户Id
*/
/**
* 客户Id
*/
private String customerId;
/**
* 网格Id
*/
/**
* 网格Id
*/
private String gridId;
/**
* 网格所属的机关Id
*/
/**
* 网格所属的机关Id
*/
private String agencyId;
/**
* 季度ID
*/
/**
* 所有上级ID用英文逗号分开
*/
private String allParentIds;
/**
* 季度id: yyyyQ1yyyyQ2yyyyQ3yyyyQ4
*/
private String quarterId;
/**
* 年度ID
*/
/**
* 年度ID: yyyy
*/
private String yearId;
/**
* 月维度Id: yyyyMM
*/
/**
* 月维度Id: yyyyMM
*/
private String monthId;
/**
* 总指数分值
*/
private BigDecimal totalScore;
/**
* 党建能力分值
*/
private BigDecimal partyAblityScore;
/**
* 治理能力分值
*/
private BigDecimal govrnAblityScore;
/**
* 服务能力分值
*/
private BigDecimal serviceAblityScore;
/**
* 1总分0不是
*/
private String isTotal;
/**
* 分值
*/
private BigDecimal score;
/**
* 党建能力dangjiannengli治理能力zhilinengli服务能力fuwunengli网格相关wanggexiangguan
*/
private String indexCode;
}

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityPartyFiveScoreEntity.java → epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityFiveScoreEntity.java

@ -34,8 +34,8 @@ import java.util.Date;
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("fact_index_community_party_five_score")
public class FactIndexCommunityPartyFiveScoreEntity extends BaseEpmetEntity {
@TableName("fact_index_community_five_score")
public class FactIndexCommunityFiveScoreEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;

77
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityGovrnFiveScoreEntity.java

@ -1,77 +0,0 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.entity.screen;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.Date;
/**
* 社区相关-治理能力五级权重分数表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-27
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("fact_index_community_govrn_five_score")
public class FactIndexCommunityGovrnFiveScoreEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 机关iD
*/
private String agencyId;
/**
* 月份ID
*/
private String monthId;
/**
* 季度ID
*/
private String quarterId;
/**
* 年度ID
*/
private String yearId;
/**
* 指标ID
*/
private String indexId;
/**
* 分数
*/
private BigDecimal score;
/**
* 社区被吹哨次数transfered社区办结项目数closed_project社区项目响应度resp_project_ratio社区超期项目率overdue_project_ratio社区办结项目率closed_project_ratio社区办结项目满意度satisfaction_ratio
*/
private String type;
}

34
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityScoreEntity.java

@ -30,7 +30,7 @@ import java.util.Date;
* 社区相关分数表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-27
* @since v1.0.0 2020-08-31
*/
@Data
@EqualsAndHashCode(callSuper=false)
@ -40,38 +40,48 @@ public class FactIndexCommunityScoreEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 机关ID
* 客户Id
*/
private String customerId;
/**
* 组织id
*/
private String agencyId;
/**
* 月份ID
* 社区上一级组织id
*/
private String monthId;
private String parentAgencyId;
/**
* 年度ID: yyyy
*/
private String yearId;
/**
* 季度ID
* 季度id: yyyyQ1yyyyQ2yyyyQ3yyyyQ4
*/
private String quarterId;
/**
* 年度ID
* 月维度Id: yyyyMM
*/
private String yearId;
private String monthId;
/**
* 指标ID
* 1总分0不是默认0
*/
private String indexId;
private String isTotal;
/**
*
*
*/
private BigDecimal score;
/**
* 党建能力party治理能力govrn服务能力service
* 党建能力dangjiannengli治理能力zhilinengli服务能力fuwunengli社区相关shequxiangguan
*/
private String type;
private String indexCode;
}

77
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityServiceFiveScoreEntity.java

@ -1,77 +0,0 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.entity.screen;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.Date;
/**
* 社区相关-服务能力五级权重分数表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-27
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("fact_index_community_service_five_score")
public class FactIndexCommunityServiceFiveScoreEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 机关ID
*/
private String agencyId;
/**
* 月度ID
*/
private String monthId;
/**
* 季度ID
*/
private String quarterId;
/**
* 年度ID
*/
private String yearId;
/**
* 指标ID
*/
private String indexId;
/**
* 分数
*/
private BigDecimal score;
/**
* 社区活动组织次数activity
*/
private String type;
}

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

@ -24,6 +24,7 @@ public enum IndexCodeEnum {
DANG_WU_HUO_DONG("dangwuhuodong", "党务活动", 4),
LIAN_XI_QUN_ZHONG("lianxiqunzhong", "联系群众", 4),
ZUZHINEIDANGYDLXQZNLKPFPJZ("zuzhineidangydlxqznlkpfpjz","组织内党员的联系群众能力考评分(平均值)",5),
ZUZHINEIDANGYDSYYSNLKPFPJZ("zuzhineidangydsyysnlkpfpjz","组织内党员的参与议事能力考评分(平均值)",5),
;
private String code;

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

@ -123,49 +123,49 @@ public class IndexExcelDataListener extends AnalysisEventListener<IndexModel> {
group1.setIndexId(indexDictEntity.getId());
group1.setParentIndexGroupId("0");
group1.setId(UniqueIdGenerator.generate());
group1.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(),true,4));
group1.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(), true, 4));
indexGroupMap.put(index.getLevel1Index(), group1);
}
StringBuilder allIndexCodeSb = new StringBuilder(group1.getIndexCode());
String level4Index = index.getLevel4Index();
indexDictEntity = indexDicMap.get(level4Index);
IndexGroupTemplateEntity group2 = indexGroupMap.get(index.getLevel1Index()+level4Index);
IndexGroupTemplateEntity group2 = indexGroupMap.get(index.getLevel1Index() + level4Index);
IndexGroupDetailTemplateEntity templateEntity = null;
if (group2 == null) {
group2 = new IndexGroupTemplateEntity();
group2.setIndexId(indexDictEntity.getId());
group2.setParentIndexGroupId(group1.getId());
group2.setId(UniqueIdGenerator.generate());
group2.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(),false,4 ));
indexGroupMap.put(index.getLevel1Index()+level4Index, group2);
group2.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(), false, 4));
indexGroupMap.put(index.getLevel1Index() + level4Index, group2);
//构建 分组明细
templateEntity = indexGroupDetailMap.get(index.getLevel1Index()+level4Index);
templateEntity = indexGroupDetailMap.get(index.getLevel1Index() + level4Index);
if (templateEntity == null) {
templateEntity = new IndexGroupDetailTemplateEntity();
templateEntity = new IndexGroupDetailTemplateEntity();
templateEntity.setIndexGroupId(group1.getId());
templateEntity.setIndexId(indexDictEntity.getId());
templateEntity.setAllParentIndexCode(allIndexCodeSb.toString());
templateEntity.setId(UniqueIdGenerator.generate());
templateEntity.setCorrelation(index.getCorrelation());
buildIndexGroupDetail(templateEntity,indexDictEntity, index, group1, 2);
indexGroupDetailMap.put(index.getLevel1Index()+level4Index,templateEntity);
buildIndexGroupDetail(templateEntity, indexDictEntity, index, 2);
indexGroupDetailMap.put(index.getLevel1Index() + level4Index, templateEntity);
}
}
indexDictEntity = indexDicMap.get(index.getLevel5Index());
allIndexCodeSb.append(StrConstant.COLON);
allIndexCodeSb.append(group2.getIndexCode());
templateEntity = indexGroupDetailMap.get(index.getLevel1Index()+index.getLevel5Index());
templateEntity = indexGroupDetailMap.get(index.getLevel1Index() + index.getLevel5Index());
if (templateEntity == null) {
templateEntity = new IndexGroupDetailTemplateEntity();
templateEntity = new IndexGroupDetailTemplateEntity();
templateEntity.setIndexGroupId(group2.getId());
templateEntity.setIndexId(indexDictEntity.getId());
templateEntity.setAllParentIndexCode(allIndexCodeSb.toString());
templateEntity.setId(UniqueIdGenerator.generate());
templateEntity.setCorrelation(index.getCorrelation());
buildIndexGroupDetail(templateEntity,indexDictEntity, index, group2, 5);
indexGroupDetailMap.put(index.getLevel1Index()+index.getLevel5Index(),templateEntity);
buildIndexGroupDetail(templateEntity, indexDictEntity, index, 5);
indexGroupDetailMap.put(index.getLevel1Index() + index.getLevel5Index(), templateEntity);
}
} else {
//todo 测试完去掉
@ -177,7 +177,7 @@ public class IndexExcelDataListener extends AnalysisEventListener<IndexModel> {
group1.setIndexId(indexDictEntity.getId());
group1.setParentIndexGroupId("0");
group1.setId(UniqueIdGenerator.generate());
group1.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(),false,4 ));
group1.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(), false, 4));
indexGroupMap.put(index.getLevel1Index(), group1);
}
StringBuilder allIndexCodeSb = new StringBuilder(group1.getIndexCode());
@ -191,35 +191,35 @@ public class IndexExcelDataListener extends AnalysisEventListener<IndexModel> {
group2.setIndexId(indexDictEntity.getId());
group2.setParentIndexGroupId(group1.getId());
group2.setId(UniqueIdGenerator.generate());
group2.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(),false,4 ));
group2.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(), false, 4));
indexGroupMap.put(groupMapKey, group2);
//构建 分组明细
templateEntity = indexGroupDetailMap.get(level2Index);
if (templateEntity == null) {
templateEntity = new IndexGroupDetailTemplateEntity();
templateEntity = new IndexGroupDetailTemplateEntity();
templateEntity.setIndexGroupId(group2.getId());
templateEntity.setIndexId(indexDictEntity.getId());
templateEntity.setAllParentIndexCode(allIndexCodeSb.toString());
templateEntity.setId(UniqueIdGenerator.generate());
templateEntity.setCorrelation(index.getCorrelation());
buildIndexGroupDetail(templateEntity,indexDictEntity, index, group1, 2);
indexGroupDetailMap.put(level2Index,templateEntity);
buildIndexGroupDetail(templateEntity, indexDictEntity, index, 2);
indexGroupDetailMap.put(groupMapKey, templateEntity);
}
}
indexDictEntity = indexDicMap.get(index.getLevel5Index());
allIndexCodeSb.append(StrConstant.COLON);
allIndexCodeSb.append(group2.getIndexCode());
templateEntity = indexGroupDetailMap.get(index.getLevel1Index()+index.getLevel5Index());
templateEntity = indexGroupDetailMap.get(index.getLevel1Index() + index.getLevel5Index());
if (templateEntity == null) {
templateEntity = new IndexGroupDetailTemplateEntity();
templateEntity = new IndexGroupDetailTemplateEntity();
templateEntity.setIndexGroupId(group2.getId());
templateEntity.setIndexId(indexDictEntity.getId());
templateEntity.setAllParentIndexCode(allIndexCodeSb.toString());
templateEntity.setId(UniqueIdGenerator.generate());
templateEntity.setCorrelation(index.getCorrelation());
buildIndexGroupDetail(templateEntity, indexDictEntity, index, group2, 5);
indexGroupDetailMap.put(index.getLevel1Index()+index.getLevel5Index(),templateEntity);
buildIndexGroupDetail(templateEntity, indexDictEntity, index, 5);
indexGroupDetailMap.put(index.getLevel1Index() + index.getLevel5Index(), templateEntity);
}
}
//}
@ -228,13 +228,13 @@ public class IndexExcelDataListener extends AnalysisEventListener<IndexModel> {
LOGGER.info("所有指标分组明细数据解析完成:{}", JSON.toJSONString(indexGroupDetailMap.values()));
}
private void buildIndexGroupDetail( IndexGroupDetailTemplateEntity templateEntity,IndexDictEntity indexDictEntity, IndexModel index, IndexGroupTemplateEntity parentGroup, Integer level) {
private void buildIndexGroupDetail(IndexGroupDetailTemplateEntity templateEntity, IndexDictEntity indexDictEntity, IndexModel index, Integer level) {
if (level == 5) {
templateEntity.setIndexCode(Pinyin4jUtil.getSpellPinYin(index.getLevel5Index(),false,4 ));
templateEntity.setIndexCode(Pinyin4jUtil.getSpellPinYin(index.getLevel5Index(), false, 4));
String level5WeightStr = index.getLevel5Weight().replace("%", "");
templateEntity.setWeight(new BigDecimal(level5WeightStr).divide(new BigDecimal(100), 4, RoundingMode.HALF_UP));
} else {
templateEntity.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(),false,4 ));
templateEntity.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(), false, 4));
templateEntity.setWeight(new BigDecimal(index.getWeight()).divide(new BigDecimal(100), 4, RoundingMode.HALF_UP));
}

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

@ -1,11 +1,15 @@
package com.epmet.service.indexcal.impl;
import com.alibaba.fastjson.JSON;
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.ConvertUtils;
import com.epmet.constant.IndexCalConstant;
import com.epmet.dao.indexcoll.FactIndexPartyAblityCpcMonthlyDao;
import com.epmet.dao.indexscore.CpcScoreDao;
import com.epmet.dao.screen.IndexCodeFieldReDao;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.entity.indexscore.CpcScoreEntity;
import com.epmet.entity.screen.IndexGroupDetailEntity;
import com.epmet.eum.IndexCodeEnum;
import com.epmet.service.indexcal.CpcIndexCalculateService;
@ -26,10 +30,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@ -43,24 +44,63 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService {
private IndexGroupDetailService getDetailListByParentCode;
@Autowired
private IndexCodeFieldReService indexCodeFieldReService;
@Autowired
private CpcScoreDao cpcScoreDao;
@Override
public Boolean cpcIndexCalculate(CalculateCommonFormDTO formDTO) {
calculatePartScore(formDTO);
calculateTotalScore(formDTO);
return true;
}
//获取指标权重信息 -参与议事
List<IndexGroupDetailEntity> indexDetails = getDetailListByParentCode.getDetailListLikeParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode());
if (CollectionUtils.isEmpty(indexDetails)) {
/**
* desc: 计算总分
*
* @param formDTO
*/
private void calculateTotalScore(CalculateCommonFormDTO formDTO) {
//获取指标权重
List<IndexGroupDetailEntity> parentIndexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode());
if (CollectionUtils.isEmpty(parentIndexDetails)) {
log.warn("cpcIndexCalculate customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
return false;
throw new RenException("客户【党员相关】指标权重信息不存在");
}
Map<String, CpcScoreEntity> cpcScoreTotalMap = new HashMap<>();
Map<String, IndexGroupDetailEntity> indexWeightMap = parentIndexDetails.stream().collect(Collectors.toMap(IndexGroupDetailEntity::getIndexCode, o -> o));
canyuyishi(formDTO, indexDetails);
//获取数据
List<CpcScoreEntity> list = cpcScoreDao.getPartScore(formDTO.getCustomerId(), formDTO.getMonthId());
if (CollectionUtils.isEmpty(list)) {
log.error("calculateTotalScore cpcScoreDao.getPartScore return empty,customerId:{},monthId:{}", formDTO.getCustomerId(), formDTO.getMonthId());
throw new RenException("客户四级指标分值记录不存在");
}
Map<String, List<CpcScoreEntity>> userGroupMap = list.stream().collect(Collectors.groupingBy(CpcScoreEntity::getUserId));
userGroupMap.forEach((userId, partScoreList) -> {
CpcScoreEntity totalEntity = null;
for (CpcScoreEntity part : partScoreList) {
IndexGroupDetailEntity indexGroupDetailEntity = indexWeightMap.get(part.getIndexCode());
if (totalEntity == null) {
totalEntity = ConvertUtils.sourceToTarget(part, CpcScoreEntity.class);
totalEntity.setIsTotal(NumConstant.ONE_STR);
totalEntity.setIndexCode(indexGroupDetailEntity.getIndexCode());
totalEntity.setScore(new BigDecimal(0));
cpcScoreTotalMap.put(userId, totalEntity);
}
//todo 自建群活跃度——议题转项目率 有阈值 >60%按60%算
BigDecimal total = part.getScore().multiply(indexGroupDetailEntity.getWeight());
log.info("userId:{},分数:{},权重:{},total:{}", userId, part.getScore(), indexGroupDetailEntity.getWeight(), total);
totalEntity.setScore(totalEntity.getScore().add(total));
}
});
insertBatch(cpcScoreTotalMap.values().stream().collect(Collectors.toList()));
}
//log.info(JSON.toJSONString(minAndMaxList));
return null;
private void insertBatch(Collection<CpcScoreEntity> values) {
cpcScoreDao.insertBatch(values);
}
private void canyuyishi(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexDetails) {
private void calculatePartScore(CalculateCommonFormDTO formDTO) {
Map<String, String> indexCodeFieldReList = indexCodeFieldReService.getIndexCodeFieldReMap();
if (CollectionUtils.isEmpty(indexCodeFieldReList)) {
log.error("cpcIndexCalculate have any indexcodefieldre");
@ -69,77 +109,108 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService {
//计算最大最小值
Map<String, Object> minAndMaxMap = factIndexPartyAblityCpcMonthlyDao.getExtremeValue(formDTO.getCustomerId());
if (CollectionUtils.isEmpty(minAndMaxMap)) {
log.warn("cpcIndexCalculate getExtremeValue customerId:{} have not any fact record", formDTO.getCustomerId());
log.error("cpcIndexCalculate getExtremeValue customerId:{} have not any fact record", formDTO.getCustomerId());
return;
}
//指标集合
//对指标进行分组
Map<String, List<IndexGroupDetailEntity>> groupIndexDetailsMap = indexDetails.stream().collect(Collectors.groupingBy(IndexGroupDetailEntity::getAllParentIndexCode));
Map<String, List<IndexGroupDetailEntity>> groupIndexDetailsMap = getIndexDetailMap(formDTO);
if (groupIndexDetailsMap == null) {
return;
}
List<Map<String, Object>> list = null;
int pageNo = 1;
int pageSize = 10;
//分页查询 要计算的原始数据
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((parentIndex, indexDetailList)->{
Map<String, IndexInputVO<BigDecimal>> indexMap = getIndexInputVO(indexDetailList, minAndMaxMap);
//遍历指标 进行计算
for (Map.Entry<String, IndexInputVO<BigDecimal>> entry : indexMap.entrySet()) {
String indexCode = entry.getKey();
IndexInputVO<BigDecimal> value = entry.getValue();
String fieldName = indexCodeFieldReService.getFieldNameByIndexCode(indexCode);
if (StringUtils.isBlank(fieldName)) {
log.error("cpcIndexCalculate fieldName error");
continue;
}
for (Map<String, Object> cpcIndex : finalList) {
//对应的数值
String sampleValueStr = String.valueOf(cpcIndex.get(indexCodeFieldReService.getFieldNameByIndexCode(fieldName)));
//构造样本值对象
SampleValue<BigDecimal> currentGridIndexValue = new SampleValue((String) cpcIndex.get(IndexCalConstant.USER_ID), new BigDecimal(sampleValueStr));
value.getIndexValueVOs().add(currentGridIndexValue);
}
}
HashMap<String, BigDecimal> result = calculate(indexMap);
// TODO 处理结果
saveGridCorreLationDangJian(formDTO, indexDetails, result);
try {
System.out.println( JSON.toJSONString(result));
} catch (Exception e) {
}
groupIndexDetailsMap.forEach((parentIndexCode, details) -> {
calculateScore(formDTO, details, finalList, minAndMaxMap, parentIndexCode);
});
}
} while (!CollectionUtils.isEmpty(list) && pageNo++ > 0);
}
@Transactional(rollbackFor = Exception.class)
public void saveGridCorreLationDangJian(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexDetails, HashMap<String, BigDecimal> result) {
/**
* desc计算并保存中间结果
*
* @param formDTO
* @param indexDetailList
* @param finalList
* @param minAndMaxMap
* @param parentIndexCode remark1.遍历指标和原始数据2.构建指标归一算法计算器计算分值3.将分值保存到中间表
*/
private void calculateScore(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexDetailList, List<Map<String, Object>> finalList, Map<String, Object> minAndMaxMap, String parentIndexCode) {
Map<String, IndexInputVO<BigDecimal>> indexMap = buildIndexInputVO(indexDetailList, minAndMaxMap);
Map<String, CpcScoreEntity> scoreEntityMap = new HashMap<>();
//遍历指标 进行计算
for (Map.Entry<String, IndexInputVO<BigDecimal>> entry : indexMap.entrySet()) {
String indexCode = entry.getKey();
IndexInputVO<BigDecimal> value = entry.getValue();
String fieldName = indexCodeFieldReService.getFieldNameByIndexCode(indexCode);
if (StringUtils.isBlank(fieldName)) {
log.error("cpcIndexCalculate fieldName error");
continue;
}
for (Map<String, Object> cpcCount : finalList) {
//对应的数值
String userId = String.valueOf(cpcCount.get(IndexCalConstant.USER_ID));
BigDecimal sampleValue = new BigDecimal(String.valueOf(cpcCount.get(fieldName)));
CpcScoreEntity cpcScoreEntity = new CpcScoreEntity();
cpcScoreEntity.setYearId(String.valueOf(cpcCount.get(IndexCalConstant.YEAR_ID)));
cpcScoreEntity.setCustomerId(formDTO.getCustomerId());
cpcScoreEntity.setAgencyId(String.valueOf(cpcCount.get(IndexCalConstant.AGENCY_ID)));
cpcScoreEntity.setGridId(String.valueOf(cpcCount.get(IndexCalConstant.GRID_ID)));
cpcScoreEntity.setUserId(userId);
cpcScoreEntity.setIsTotal(NumConstant.ZERO_STR);
cpcScoreEntity.setMonthId(formDTO.getMonthId());
cpcScoreEntity.setScore(new BigDecimal(0));
cpcScoreEntity.setIndexCode(parentIndexCode);
scoreEntityMap.put(userId, cpcScoreEntity);
//构造样本值对象
SampleValue<BigDecimal> currentUserIndexValue = new SampleValue(userId, sampleValue);
value.getIndexValueVOs().add(currentUserIndexValue);
}
}
log.warn("计算的参数:{}", indexMap);
HashMap<String, BigDecimal> result = calculateScore(indexMap);
log.warn("计算的结果:{}", result);
//处理结果
saveCpcScore(formDTO, scoreEntityMap, parentIndexCode, result);
}
/**
* @param indexMap
* @return java.util.List<com.epmet.support.normalizing.batch.IndexOutputVO>
* @author yinzuomei
* @description
* @Date 2020/8/30 21:40
**/
private HashMap<String, BigDecimal> calculate(Map<String, IndexInputVO<BigDecimal>> indexMap) {
//构造入参
List<IndexInputVO> indexInputVOS = indexMap.values().stream().collect(Collectors.toList());
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
return batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
* desc:保存分值 到中间表
*
* @param formDTO
* @param indexDetails
* @param parentIndexCode
* @param result
*/
@Transactional(rollbackFor = Exception.class)
public void saveCpcScore(CalculateCommonFormDTO formDTO, Map<String, CpcScoreEntity> indexDetails, String parentIndexCode, HashMap<String, BigDecimal> result) {
cpcScoreDao.deleteByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), parentIndexCode);
List<CpcScoreEntity> list = new ArrayList<>();
result.forEach((userId, score) -> {
CpcScoreEntity cpcScoreEntity = indexDetails.get(userId);
cpcScoreEntity.setScore(score);
list.add(cpcScoreEntity);
});
this.insertBatch(list);
}
/**
* desc构建分值计算器
*
* @param indexList 指标集合
* @param minAndMaxMap 最大值最小值集合
* @return java.util.Map<java.lang.String, com.epmet.support.normalizing.batch.IndexInputVO>
@ -147,15 +218,9 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService {
* @description
* @Date 2020/8/30 15:56
**/
private Map<String, IndexInputVO<BigDecimal>> getIndexInputVO(List<IndexGroupDetailEntity> indexList, Map<String, Object> minAndMaxMap) {
private Map<String, IndexInputVO<BigDecimal>> buildIndexInputVO(List<IndexGroupDetailEntity> indexList, Map<String, Object> minAndMaxMap) {
Map<String, IndexInputVO<BigDecimal>> map = new HashMap<>();
for (int indexNum = 0; indexNum < indexList.size(); indexNum++) {
IndexGroupDetailEntity index = indexList.get(indexNum);
IndexInputVO indexInputVO = new IndexInputVO();
// 指标code
indexInputVO.setIndexId(index.getIndexCode());
//权重
indexInputVO.setWeight(index.getWeight());
for (IndexGroupDetailEntity index : indexList) {
BigDecimal minValue = null;
BigDecimal maxValue = null;
@ -175,12 +240,54 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService {
ScoreConstants.MAX_SCORE,
Correlation.getCorrelation(index.getCorrelation())
);
indexInputVO.setScoreCalculator(scoreCalculator);
List<SampleValue<BigDecimal>> sampleValueList = new ArrayList<>();
indexInputVO.setIndexValueVOs(sampleValueList);
IndexInputVO indexInputVO = new IndexInputVO(index.getIndexCode(),new ArrayList<>(),index.getThreshold(),index.getWeight(),scoreCalculator);
map.put(index.getIndexCode(), indexInputVO);
}
return map;
}
/**
* desc:调用计算器计算每个人的分数值
*
* @param indexMap
* @return
*/
private HashMap<String, BigDecimal> calculateScore(Map<String, IndexInputVO<BigDecimal>> indexMap) {
//构造入参
List<IndexInputVO> indexInputVOS = indexMap.values().stream().collect(Collectors.toList());
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
return batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
}
/**
* desc构建党员相关4级指标明细map
*
* @param formDTO
* @return
*/
private Map<String, List<IndexGroupDetailEntity>> getIndexDetailMap(CalculateCommonFormDTO formDTO) {
//获取指标权重信息 -参与议事
List<IndexGroupDetailEntity> canyuyishiIndexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(), IndexCodeEnum.CAN_YU_YI_SHI.getCode());
if (CollectionUtils.isEmpty(canyuyishiIndexDetails)) {
log.error("cpcIndexCalculate customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
return null;
}
List<IndexGroupDetailEntity> dangwuhongdongIndexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(), IndexCodeEnum.DANG_WU_HUO_DONG.getCode());
if (CollectionUtils.isEmpty(canyuyishiIndexDetails)) {
log.error("cpcIndexCalculate customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
return null;
}
List<IndexGroupDetailEntity> lianxiqunzhongIndexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(), IndexCodeEnum.LIAN_XI_QUN_ZHONG.getCode());
if (CollectionUtils.isEmpty(canyuyishiIndexDetails)) {
log.error("cpcIndexCalculate customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
return null;
}
Map<String, List<IndexGroupDetailEntity>> groupIndexDetailsMap = new HashMap<>();
groupIndexDetailsMap.put(IndexCodeEnum.CAN_YU_YI_SHI.getCode(), canyuyishiIndexDetails);
groupIndexDetailsMap.put(IndexCodeEnum.DANG_WU_HUO_DONG.getCode(), dangwuhongdongIndexDetails);
groupIndexDetailsMap.put(IndexCodeEnum.LIAN_XI_QUN_ZHONG.getCode(), lianxiqunzhongIndexDetails);
return groupIndexDetailsMap;
}
}

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

@ -2,15 +2,18 @@ package com.epmet.service.indexcal.impl;
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.IndexCalConstant;
import com.epmet.dao.indexcoll.FactIndexGovrnAblityGridMonthlyDao;
import com.epmet.dao.indexcoll.FactIndexPartyAblityGridMonthlyDao;
import com.epmet.dao.indexcoll.FactIndexServiceAblityGridMonthlyDao;
import com.epmet.dao.indexscore.CpcScoreDao;
import com.epmet.dao.indexscore.GridScoreDao;
import com.epmet.dao.screen.ScreenCustomerGridDao;
import com.epmet.dto.ScreenCustomerGridDTO;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.indexcal.CustomerGridInfoDTO;
import com.epmet.dto.indexcal.PageQueryGridFormDTO;
import com.epmet.dto.indexcal.*;
import com.epmet.entity.indexscore.GridScoreEntity;
import com.epmet.entity.screen.IndexGroupDetailEntity;
import com.epmet.eum.IndexCodeEnum;
import com.epmet.service.indexcal.GridCorreLationService;
@ -23,6 +26,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
@ -51,6 +55,11 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
private IndexGroupDetailService indexGroupDetailService;
@Autowired
private IndexCodeFieldReService indexCodeFieldReService;
@Autowired
private CpcScoreDao cpcScoreDao;
@Autowired
private GridScoreDao gridScoreDao;
/**
* @param formDTO
@ -62,33 +71,45 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
@Override
public Boolean calculateGridCorreLation(CalculateCommonFormDTO formDTO) {
boolean resultFlag = false;
//1、计算网格相关-党建能力
List<IndexGroupDetailEntity> dangJianNengLiList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(),
IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode(),
IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
if (!CollectionUtils.isEmpty(dangJianNengLiList)) {
//1、计算网格相关-党建能力
calculateGridCorreLationDangJian(formDTO, dangJianNengLiList);
if (CollectionUtils.isEmpty(dangJianNengLiList)) {
logger.warn("calculateGridDangJian customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
throw new RenException("客户【网格相关:党建能力】指标权重信息不存在");
}
/* List<IndexGroupDetailEntity> zhiLiNengLiList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(),
calculateGridDangJian(formDTO, dangJianNengLiList);
//2、计算网格相关-治理能力
List<IndexGroupDetailEntity> zhiLiNengLiList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(),
IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode(),
IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
if (!CollectionUtils.isEmpty(zhiLiNengLiList)) {
//2、计算网格相关-治理能力
calculateGridCorreLationZhiLi(formDTO, zhiLiNengLiList);
if (CollectionUtils.isEmpty(zhiLiNengLiList)) {
logger.warn("calculateGridZhiLi customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
throw new RenException("客户【网格相关:治理能力】指标权重信息不存在");
}
calculateGridZhiLi(formDTO, zhiLiNengLiList);
//3、计算网格相关-服务能力
List<IndexGroupDetailEntity> fuWuNengLiList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(),
IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode(),
IndexCodeEnum.FU_WU_NENG_LI.getCode());
if (!CollectionUtils.isEmpty(fuWuNengLiList)) {
//3、计算网格相关-服务能力
calculateGridCorreLationFuWu(formDTO, fuWuNengLiList);
if (CollectionUtils.isEmpty(fuWuNengLiList)) {
logger.warn("calculateGridFuWu customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
throw new RenException("客户【网格相关:服务能力】指标权重信息不存在");
}
//计算网格相关总分
calculateGridFuWu(formDTO, fuWuNengLiList);
//4、计算网格相关总分
List<IndexGroupDetailEntity> wgxgList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(),
IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode());
if (!CollectionUtils.isEmpty(wgxgList)) {
calculateGridCorreLationTotal(formDTO, wgxgList);
}*/
if (CollectionUtils.isEmpty(wgxgList)) {
logger.warn("calculateGridTotal customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
throw new RenException("客户【网格相关】指标权重信息不存在");
}
calculateGridTotal(formDTO, wgxgList, IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode());
resultFlag = true;
return resultFlag;
}
@ -101,7 +122,8 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
* @description 计算网格相关-党建能力
* @Date 2020/8/26 16:47
**/
private void calculateGridCorreLationDangJian(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexList) {
@Transactional(rollbackFor = Exception.class)
public void calculateGridDangJian(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexList) {
//查询总记录数
int total = factIndexPartyAblityGridMonthlyDao.selectCount(formDTO);
if (NumConstant.ZERO == total) {
@ -113,8 +135,13 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
logger.info(String.format("共%s条数据,分%s次计算", total, totalPage));
//每一组指标的最大值,key:code_MIN/MAX
Map<String, Object> minAndMaxMap = queryPartyAblityGridMinAndMax(formDTO.getCustomerId(), formDTO.getMonthId());
if (CollectionUtils.isEmpty(minAndMaxMap)) {
logger.error("calculateGridDangJian queryPartyAblityGridMinAndMax customerId:{} monthId:{} have not any fact record", formDTO.getCustomerId(),formDTO.getMonthId());
return;
}
//指标集合
Map<String, IndexInputVO<BigDecimal>> indexMap = getIndexInputVO(formDTO, indexList, minAndMaxMap);
Map<String, IndexInputVO<BigDecimal>> indexMap = buildGridCorrelationIndexInputVO(formDTO, indexList, minAndMaxMap);
List<HashMap<String, BigDecimal>> resultMapList = new ArrayList<>();
//分页查询采集记录
for (int pageNo = 1; pageNo <= totalPage; pageNo++) {
int pageIndex = (pageNo - NumConstant.ONE) * IndexCalConstant.PAGE_SIZE;
@ -139,89 +166,161 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
//组织内党员的联系群众能力考评分(平均值)
logger.info("组织内党员的联系群众能力考评分(平均值) 单独处理");
//网格内党员的联系群众能力考评分(平均值)
String gridId=(String) recordMap.get(IndexCalConstant.GRID_ID);
BigDecimal contactMassesAvgValue = getGridContactMassesAvgValue(gridId);
String gridId = (String) recordMap.get(IndexCalConstant.GRID_ID);
BigDecimal contactMassesAvgValue = getGridContactMassesAvgValue(formDTO, gridId);
SampleValue<BigDecimal> contactMassesAblityValue = new SampleValue((String) recordMap.get(IndexCalConstant.GRID_ID), contactMassesAvgValue);
value.getIndexValueVOs().add(contactMassesAblityValue);
}
});
});
List<IndexOutputVO> result = calculate(indexMap);
// TODO 处理结果
saveGridCorreLationDangJian(formDTO, indexList, result);
try {
for (IndexOutputVO m : result) {
logger.info("indexId=" + m.getIndexId());
for (SampleScore sampleScore : m.getIndexScoreVOs()) {
logger.info(String.format("网格id:%s,得分:%s", sampleScore.getSampleId(), sampleScore.getSampleScore()));
}
}
} catch (Exception e) {
}
HashMap<String, BigDecimal> resultMap = calculate(indexMap);
resultMapList.add(resultMap);
}
// 保存中间表
saveGridCorreLationResult(formDTO, resultMapList, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), NumConstant.ZERO_STR);
}
/**
* @return java.util.Map<java.lang.String,java.math.BigDecimal>
* @param formDTO
* @param calculateCommonFormDTO
* @return java.util.Map<java.lang.String, java.math.BigDecimal>
* @author yinzuomei
* @description TODO
* @description 获取网格内党员的联系群众能力考评分平均值的最大值最小值
* @Date 2020/8/31 9:51
**/
private Map<String, BigDecimal> contactMassesAblityMap(CalculateCommonFormDTO formDTO) {
return null;
private Map<String, BigDecimal> getContactMassesAblityMap(CalculateCommonFormDTO calculateCommonFormDTO) {
Map<String, BigDecimal> map = new HashMap<>();
List<BigDecimal> list = cpcScoreDao.selectListGridContactMassesAvgValue(calculateCommonFormDTO);
if (!CollectionUtils.isEmpty(list)) {
BigDecimal minValue = Collections.min(list);
BigDecimal maxValue = Collections.max(list);
map.put(StrConstant.MIN, minValue);
map.put(StrConstant.MAX, maxValue);
return map;
}
map.put(StrConstant.MIN, new BigDecimal(NumConstant.ZERO_STR));
map.put(StrConstant.MAX, new BigDecimal(NumConstant.ZERO_STR));
return map;
}
/**
* @param calculateCommonFormDTO
* @param gridId 网格id
* @return java.math.BigDecimal
* @param gridId 网格id
* @author yinzuomei TODO
* @author yinzuomei
* @description 获取网格组织内党员的联系群众能力考评分平均值
* @Date 2020/8/31 9:50
**/
private BigDecimal getGridContactMassesAvgValue(String gridId) {
return null;
private BigDecimal getGridContactMassesAvgValue(CalculateCommonFormDTO calculateCommonFormDTO, String gridId) {
BigDecimal result = cpcScoreDao.selectGridContactMassesAvgValue(calculateCommonFormDTO.getCustomerId(), calculateCommonFormDTO.getMonthId(), gridId);
if (null == result) {
return new BigDecimal(NumConstant.ZERO_STR);
}
return result;
}
/**
* @param formDTO 客户id 月份id: yyyyMM
* @param indexList 指标集合
* @param indexOutputVOList
* @return void
* @param formDTO
* @param gridId
* @return java.math.BigDecimal
* @author yinzuomei
* @description 保存网格相关五级指标分值
* @Date 2020/8/30 22:50
* @description 组织内党员的参与议事能力考评分平均值
* @Date 2020/8/31 15:51
**/
private void saveGridCorreLationDangJian(CalculateCommonFormDTO formDTO,
List<IndexGroupDetailEntity> indexList,
List<IndexOutputVO> indexOutputVOList) {
Map<String, IndexGroupDetailEntity> indexMap = indexList.stream().collect(Collectors.toMap(IndexGroupDetailEntity::getIndexCode, Function.identity()));
private BigDecimal getGridJoinIssueAvgValue(CalculateCommonFormDTO formDTO, String gridId) {
BigDecimal result = cpcScoreDao.selectGridJoinIssueAvgValue(formDTO.getCustomerId(), formDTO.getMonthId(), gridId);
if (null == result) {
return new BigDecimal(NumConstant.ZERO_STR);
}
return result;
}
/**
* @param calculateCommonFormDTO
* @return java.util.Map<java.lang.String, java.math.BigDecimal>
* @author yinzuomei
* @description 网格内党员的参与议事能力考评分平均值 最大值最小值
* @Date 2020/8/31 14:41
**/
private Map<String, BigDecimal> getJoinIssueAblityMap(CalculateCommonFormDTO calculateCommonFormDTO) {
Map<String, BigDecimal> map = new HashMap<>();
List<BigDecimal> list = cpcScoreDao.selectListJoinIssueAvgValue(calculateCommonFormDTO);
if (!CollectionUtils.isEmpty(list)) {
BigDecimal minValue = Collections.min(list);
BigDecimal maxValue = Collections.max(list);
map.put(StrConstant.MIN, minValue);
map.put(StrConstant.MAX, maxValue);
return map;
}
map.put(StrConstant.MIN, new BigDecimal(NumConstant.ZERO_STR));
map.put(StrConstant.MAX, new BigDecimal(NumConstant.ZERO_STR));
return map;
}
/**
* @param formDTO 客户id 月份id: yyyyMM
* @param resultMapList
* @param indexCode 指标编码: 党建能力dangjiannengli治理能力zhilinengli服务能力fuwunengli
* @param isTotal 1总分0不是
* @return void
* @author yinzuomei
* @description 保存网格相关三大能力值
* @Date 2020/8/30 22:50
**/
private void saveGridCorreLationResult(CalculateCommonFormDTO formDTO,
List<HashMap<String, BigDecimal>> resultMapList,
String indexCode,
String isTotal) {
List<GridScoreEntity> gridScoreEntityList = new ArrayList<>();
String quarterId = DateUtils.getQuarterId(formDTO.getMonthId());
String yearId = DateUtils.getYearId(formDTO.getMonthId());
for (HashMap<String, BigDecimal> resultMap : resultMapList) {
resultMap.forEach((gridId, partyAblityScore) -> {
logger.info("网格id:" + gridId + ";分值:" + partyAblityScore);
GridScoreEntity gridScoreEntity = new GridScoreEntity();
gridScoreEntity.setCustomerId(formDTO.getCustomerId());
gridScoreEntity.setGridId(gridId);
gridScoreEntity.setIsTotal(isTotal);
gridScoreEntity.setIndexCode(indexCode);
ScreenCustomerGridDTO screenCustomerGridDTO = screenCustomerGridDao.selectParentAgencyId(formDTO.getCustomerId(), gridId);
if (null != screenCustomerGridDTO) {
gridScoreEntity.setAgencyId(screenCustomerGridDTO.getParentAgencyId());
gridScoreEntity.setAllParentIds(screenCustomerGridDTO.getAllParentIds());
}
gridScoreEntity.setQuarterId(quarterId);
gridScoreEntity.setYearId(yearId);
gridScoreEntity.setMonthId(formDTO.getMonthId());
gridScoreEntity.setScore(partyAblityScore);
gridScoreEntityList.add(gridScoreEntity);
});
}
if (!CollectionUtils.isEmpty(gridScoreEntityList)) {
gridScoreDao.deleteByCusAndMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode, isTotal);
gridScoreDao.insertBatches(gridScoreEntityList);
}
}
/**
* @param indexMap
* @return java.util.List<com.epmet.support.normalizing.batch.IndexOutputVO>
* @author yinzuomei
* @description
* @description 调用计算器计算每个指标下各个网格的总分
* @Date 2020/8/30 21:40
**/
private List<IndexOutputVO> calculate(Map<String, IndexInputVO<BigDecimal>> indexMap) {
private HashMap<String, BigDecimal> calculate(Map<String, IndexInputVO<BigDecimal>> indexMap) {
//构造入参
List<IndexInputVO> indexInputVOS = this.getIndexInputVOList(indexMap);
logger.info("计算的参数:{}", indexInputVOS);
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
return batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS);
HashMap<String, BigDecimal> resultMap = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
logger.info("计算的结果:{}", resultMap);
return resultMap;
}
/**
* @param indexMap
* @return java.util.List<com.epmet.support.normalizing.batch.IndexInputVO>
* @author yinzuomei
* @description
* @description map遍历转为List
* @Date 2020/8/30 18:34
**/
private List<IndexInputVO> getIndexInputVOList(Map<String, IndexInputVO<BigDecimal>> indexMap) {
@ -239,50 +338,61 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
* @param minAndMaxMap 最大值最小值集合
* @return java.util.Map<java.lang.String, com.epmet.support.normalizing.batch.IndexInputVO>
* @author yinzuomei
* @description
* @description 构造网格相关 指标计算参数
* @Date 2020/8/30 15:56
**/
private Map<String, IndexInputVO<BigDecimal>> getIndexInputVO(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexList, Map<String, Object> minAndMaxMap) {
private Map<String, IndexInputVO<BigDecimal>> buildGridCorrelationIndexInputVO(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexList, Map<String, Object> minAndMaxMap) {
Map<String, IndexInputVO<BigDecimal>> map = new HashMap<>();
for (int indexNum = 0; indexNum < indexList.size(); indexNum++) {
IndexGroupDetailEntity index = indexList.get(indexNum);
IndexInputVO indexInputVO = new IndexInputVO();
for (IndexGroupDetailEntity index : indexList) {
// IndexInputVO indexInputVO = new IndexInputVO();
// 指标code
indexInputVO.setIndexId(index.getIndexCode());
// indexInputVO.setIndexId(index.getIndexCode());
//阈值
// indexInputVO.setThreshold(index.getThreshold());
//权重
indexInputVO.setWeight(index.getWeight());
// indexInputVO.setWeight(index.getWeight());
BigDecimal minValue = null;
BigDecimal maxValue = null;
if (IndexCodeEnum.ZUZHINEIDANGYDLXQZNLKPFPJZ.getCode().equals(index.getIndexCode())) {
//组织内党员的联系群众能力考评分(平均值) 获取最大值,最小值
logger.info("组织内党员的联系群众能力考评分(平均值) 单独处理");
Map<String,BigDecimal> contactMassesAblityMap= this.contactMassesAblityMap(formDTO);
minValue=contactMassesAblityMap.get(StrConstant.MIN);
maxValue=contactMassesAblityMap.get(StrConstant.MAX);
Map<String, BigDecimal> contactMassesAblityMap = this.getContactMassesAblityMap(formDTO);
minValue = contactMassesAblityMap.get(StrConstant.MIN);
maxValue = contactMassesAblityMap.get(StrConstant.MAX);
} else if (IndexCodeEnum.ZUZHINEIDANGYDSYYSNLKPFPJZ.getCode().equals(index.getIndexCode())) {
logger.info("组织内党员的参与议事能力考评分(平均值) 单独处理");
Map<String, BigDecimal> joinIssueAblityMap = this.getJoinIssueAblityMap(formDTO);
minValue = joinIssueAblityMap.get(StrConstant.MIN);
maxValue = joinIssueAblityMap.get(StrConstant.MAX);
} else {
//获取指标对应的列名
String fieldName = indexCodeFieldReService.getFieldNameByIndexCode(index.getIndexCode());
// logger.info("fieldName=" + fieldName + ";index.getIndexCode()=" + index.getIndexCode());
//最小值key
if (StringUtils.isBlank(fieldName)) {
logger.error("index_code:{} ",index.getIndexCode(),"not find field_name");
continue;
}
logger.info("index_code:{} ",index.getIndexCode(),"field_id :{} ",fieldName);
String minValueKey = fieldName.concat(StrConstant.UNDER_LINE).concat(StrConstant.MIN);
//最大值key
String maxValueKey = fieldName.concat(StrConstant.UNDER_LINE).concat(StrConstant.MAX);
minValue = new BigDecimal(String.valueOf(minAndMaxMap.get(minValueKey)));
maxValue = new BigDecimal(String.valueOf(minAndMaxMap.get(maxValueKey)));
}
// logger.info("minValue="+minValue+";maxValue="+maxValue);
//分值计算器
ScoreCalculator<Integer> scoreCalculator = new BigDecimalScoreCalculator(minValue,
ScoreCalculator scoreCalculator = new BigDecimalScoreCalculator(minValue,
maxValue,
ScoreConstants.MIN_SCORE,
ScoreConstants.MAX_SCORE,
Correlation.getCorrelation(index.getCorrelation())
);
indexInputVO.setScoreCalculator(scoreCalculator);
// indexInputVO.setScoreCalculator(scoreCalculator);
List<SampleValue<BigDecimal>> sampleValueList = new ArrayList<>();
indexInputVO.setIndexValueVOs(sampleValueList);
map.put(index.getIndexCode(), indexInputVO);
// indexInputVO.setIndexValueVOs(sampleValueList);
IndexInputVO indexInputVO1 = new IndexInputVO(index.getIndexCode(),
sampleValueList,
index.getThreshold(),
index.getWeight(),
scoreCalculator);
map.put(index.getIndexCode(), indexInputVO1);
}
return map;
}
@ -290,15 +400,67 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
/**
* @param formDTO
* @param indexList
* @return void TODO
* @return void
* @author yinzuomei
* @description 计算网格相关-治理能力
* @Date 2020/8/26 16:47
**/
private void calculateGridCorreLationZhiLi(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexList) {
private void calculateGridZhiLi(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexList) {
//查询总记录数
int total = factIndexGovrnAblityGridMonthlyDao.selectCount(formDTO);
if (NumConstant.ZERO == total) {
logger.info(String.format("customerId:%s,monthId:%s,没有上传网格相关-治理能力-五级指标数据"), formDTO.getCustomerId(), formDTO.getMonthId());
return;
}
//总页数,进行批量查询,批量计算
int totalPage = (int) Math.ceil((double) total / IndexCalConstant.PAGE_SIZE);
logger.info(String.format("共%s条数据,分%s次计算", total, totalPage));
//每一组指标的最大值,key:code_MIN/MAX
Map<String, Object> minAndMaxMap = queryGovrnAblityGridMinAndMax(formDTO.getCustomerId(), formDTO.getMonthId());
if (CollectionUtils.isEmpty(minAndMaxMap)) {
logger.error("calculateGridZhiLi queryGovrnAblityGridMinAndMax customerId:{} monthId:{} have not any fact record", formDTO.getCustomerId(),formDTO.getMonthId());
return;
}
//指标集合
Map<String, IndexInputVO<BigDecimal>> indexMap = buildGridCorrelationIndexInputVO(formDTO, indexList, minAndMaxMap);
List<HashMap<String, BigDecimal>> resultMapList = new ArrayList<>();
//分页查询采集记录
for (int pageNo = 1; pageNo <= totalPage; pageNo++) {
int pageIndex = (pageNo - NumConstant.ONE) * IndexCalConstant.PAGE_SIZE;
//前10条
List<Map<String, Object>> recordList = queryListGovrnAblityGrid(new PageQueryGridFormDTO(formDTO.getCustomerId(),
formDTO.getMonthId(),
pageIndex,
pageNo,
IndexCalConstant.PAGE_SIZE));
//遍历每一个网格的记录
recordList.forEach(recordMap -> {
//遍历所有的指标
indexMap.forEach((key, value) -> {
//列名不为空
if (StringUtils.isNotBlank(indexCodeFieldReService.getFieldNameByIndexCode(key))) {
//对应的数值
String sampleValueStr = String.valueOf(recordMap.get(indexCodeFieldReService.getFieldNameByIndexCode(key)));
//构造样本值对象
SampleValue<BigDecimal> currentGridIndexValue = new SampleValue((String) recordMap.get(IndexCalConstant.GRID_ID), new BigDecimal(sampleValueStr));
value.getIndexValueVOs().add(currentGridIndexValue);
} else if (IndexCodeEnum.ZUZHINEIDANGYDSYYSNLKPFPJZ.getCode().equals(key)) {
logger.info("组织内党员的参与议事能力考评分(平均值) 单独处理");
String gridId = (String) recordMap.get(IndexCalConstant.GRID_ID);
BigDecimal joinAvgValue = getGridJoinIssueAvgValue(formDTO, gridId);
SampleValue<BigDecimal> contactMassesAblityValue = new SampleValue((String) recordMap.get(IndexCalConstant.GRID_ID), joinAvgValue);
value.getIndexValueVOs().add(contactMassesAblityValue);
}
});
});
HashMap<String, BigDecimal> resultMap = calculate(indexMap);
resultMapList.add(resultMap);
}
// 保存中间表
saveGridCorreLationResult(formDTO, resultMapList, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), NumConstant.ZERO_STR);
}
/**
* @param formDTO
* @param indexList
@ -307,8 +469,55 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
* @description 计算网格相关-服务能力
* @Date 2020/8/26 16:48
**/
private void calculateGridCorreLationFuWu(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexList) {
private void calculateGridFuWu(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexList) {
//查询总记录数
int total = factIndexGovrnAblityGridMonthlyDao.selectCount(formDTO);
if (NumConstant.ZERO == total) {
logger.info(String.format("customerId:%s,monthId:%s,没有上传网格相关-服务能力-五级指标数据"), formDTO.getCustomerId(), formDTO.getMonthId());
return;
}
//总页数,进行批量查询,批量计算
int totalPage = (int) Math.ceil((double) total / IndexCalConstant.PAGE_SIZE);
logger.info(String.format("共%s条数据,分%s次计算", total, totalPage));
//每一组指标的最大值,key:code_MIN/MAX
Map<String, Object> minAndMaxMap = queryServiceAblityGridMinAndMax(formDTO.getCustomerId(), formDTO.getMonthId());
if (CollectionUtils.isEmpty(minAndMaxMap)) {
logger.error("calculateGridFuWu queryServiceAblityGridMinAndMax customerId:{} monthId:{} have not any fact record", formDTO.getCustomerId(),formDTO.getMonthId());
return;
}
//指标集合
Map<String, IndexInputVO<BigDecimal>> indexMap = buildGridCorrelationIndexInputVO(formDTO, indexList, minAndMaxMap);
List<HashMap<String, BigDecimal>> resultMapList = new ArrayList<>();
//分页查询采集记录
for (int pageNo = 1; pageNo <= totalPage; pageNo++) {
int pageIndex = (pageNo - NumConstant.ONE) * IndexCalConstant.PAGE_SIZE;
//前10条
List<Map<String, Object>> recordList = queryListServiceAblityGrid(new PageQueryGridFormDTO(formDTO.getCustomerId(),
formDTO.getMonthId(),
pageIndex,
pageNo,
IndexCalConstant.PAGE_SIZE));
//遍历每一个网格的记录
recordList.forEach(recordMap -> {
//遍历所有的指标
indexMap.forEach((key, value) -> {
//列名不为空
if (StringUtils.isNotBlank(indexCodeFieldReService.getFieldNameByIndexCode(key))) {
//对应的数值
String sampleValueStr = String.valueOf(recordMap.get(indexCodeFieldReService.getFieldNameByIndexCode(key)));
//构造样本值对象
SampleValue<BigDecimal> currentGridIndexValue = new SampleValue((String) recordMap.get(IndexCalConstant.GRID_ID), new BigDecimal(sampleValueStr));
value.getIndexValueVOs().add(currentGridIndexValue);
} else {
logger.error("index_code:" + key + " not find field_name");
}
});
});
HashMap<String, BigDecimal> resultMap = calculate(indexMap);
resultMapList.add(resultMap);
}
// 保存中间表
saveGridCorreLationResult(formDTO, resultMapList, IndexCodeEnum.FU_WU_NENG_LI.getCode(), NumConstant.ZERO_STR);
}
/**
@ -319,10 +528,50 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
* @description 计算网格相关总分
* @Date 2020/8/26 16:50
**/
private void calculateGridCorreLationTotal(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexList) {
private void calculateGridTotal(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexList, String indexCode) {
//查询总记录数
List<GridScoreDTO> gridScoreDTOList = gridScoreDao.selectList(formDTO);
if(CollectionUtils.isEmpty(gridScoreDTOList)){
logger.error("calculateGridTotal gridScoreDao.selectList return empty,customerId:{},monthId:{}", formDTO.getCustomerId(), formDTO.getMonthId());
throw new RenException("客户一级指标分值记录不存在");
}
Map<String, IndexGroupDetailEntity> indexMap = indexList.stream().collect(Collectors.toMap(IndexGroupDetailEntity::getIndexCode, Function.identity()));
List<GridScoreEntity> gridScoreEntityList = new ArrayList<>();
for (GridScoreDTO gridScoreDTO : gridScoreDTOList) {
GridScoreEntity gridScoreEntity = new GridScoreEntity();
gridScoreEntity.setCustomerId(gridScoreDTO.getCustomerId());
gridScoreEntity.setGridId(gridScoreDTO.getGridId());
gridScoreEntity.setIsTotal(NumConstant.ONE_STR);
gridScoreEntity.setIndexCode(indexCode);
gridScoreEntity.setAgencyId(gridScoreDTO.getAgencyId());
gridScoreEntity.setAllParentIds(gridScoreDTO.getAllParentIds());
gridScoreEntity.setQuarterId(gridScoreDTO.getQuarterId());
gridScoreEntity.setYearId(gridScoreDTO.getYearId());
gridScoreEntity.setMonthId(gridScoreDTO.getMonthId());
gridScoreEntity.setScore(BigDecimal.ZERO);
if (!CollectionUtils.isEmpty(gridScoreDTO.getDetailList()) && gridScoreDTO.getDetailList().size() != 3) {
logger.error("customerId:" + gridScoreDTO.getCustomerId() + ";gridId:" + gridScoreDTO.getGridId() + ";monthId:" + gridScoreDTO.getMonthId() + "能力值缺失,无法计算总值");
continue;
}
for (GridScoreDetailDTO gridScoreDetailDTO : gridScoreDTO.getDetailList()) {
BigDecimal indexScore = gridScoreDetailDTO.getScore().multiply(indexMap.get(gridScoreDetailDTO.getIndexCode()).getWeight());
gridScoreEntity.setScore(gridScoreEntity.getScore().add(indexScore));
}
gridScoreEntityList.add(gridScoreEntity);
}
if (!CollectionUtils.isEmpty(gridScoreEntityList)) {
gridScoreDao.deleteByCusAndMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode, NumConstant.ONE_STR);
gridScoreDao.insertBatches(gridScoreEntityList);
}
}
public static void main(String[] args) {
BigDecimal totalScore = BigDecimal.ZERO;
for (int i = 1; i < 5; i++) {
totalScore = totalScore.add(new BigDecimal("1.00"));
}
System.out.println(totalScore);
}
/**
* @param customerId

23
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexCalculateCommunityService.java

@ -12,13 +12,13 @@ import java.util.List;
public interface IndexCalculateCommunityService {
/**
* @Description 社区名义发文数量计算
* @Description 社区党建能力
* @param customerId
* @param monthId
* @author zxc
* @date 2020/8/26 10:46 上午
*/
void communityPublishArticleCountCalculate(String customerId, String monthId);
void communityPartyCalculate(String customerId, String monthId);
/**
* @Description 社区治理能力
@ -27,6 +27,23 @@ public interface IndexCalculateCommunityService {
* @author zxc
* @date 2020/8/26 1:40 下午
*/
void CommunityGovernAbilityCalculate(String customerId, String monthId);
void communityGovernAbilityCalculate(String customerId, String monthId);
/**
* @Description 社区服务能力
* @param customerId
* @param monthId
* @author zxc
* @date 2020/8/31 1:38 下午
*/
void communityServiceAbilityCalculate(String customerId, String monthId);
/**
* @Description 社区相关计算
* @param customerId
* @param monthId
* @author zxc
* @date 2020/9/1 9:21 上午
*/
void communityRelate(String customerId, String monthId);
}

373
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateCommunityServiceImpl.java

@ -1,30 +1,25 @@
package com.epmet.service.screen.impl;
import com.alibaba.druid.util.StringUtils;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.constant.IndexCalConstant;
import com.epmet.dao.indexcoll.FactIndexGovrnAblityOrgMonthlyDao;
import com.epmet.dao.indexcoll.FactIndexPartyAblityCpcMonthlyDao;
import com.epmet.dao.indexcoll.FactIndexPartyAblityOrgMonthlyDao;
import com.epmet.dao.indexcoll.FactIndexServiceAblityOrgMonthlyDao;
import com.epmet.dao.screen.*;
import com.epmet.dto.indexcal.ExtremeValueCommonDTO;
import com.epmet.dto.screen.FactIndexCommunityPartyFiveScoreDTO;
import com.epmet.dto.screen.FactIndexCommunityScoreDTO;
import com.epmet.dto.screen.result.*;
import com.epmet.entity.screen.IndexGroupDetailEntity;
import com.epmet.eum.IndexCodeEnum;
import com.epmet.service.indexcal.IndexCodeFieldReService;
import com.epmet.service.screen.IndexCalculateCommunityService;
import com.epmet.service.screen.IndexGroupDetailService;
import com.epmet.support.normalizing.Correlation;
import com.epmet.support.normalizing.IntegerScoreCalculator;
import com.epmet.support.normalizing.ScoreCalculator;
import com.epmet.support.normalizing.ScoreConstants;
import com.epmet.support.normalizing.*;
import com.epmet.support.normalizing.batch.BatchScoreCalculator;
import com.epmet.support.normalizing.batch.IndexInputVO;
import com.epmet.support.normalizing.batch.IndexOutputVO;
import com.epmet.support.normalizing.batch.SampleValue;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -48,19 +43,15 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
@Autowired
private FactIndexGovrnAblityOrgMonthlyDao factIndexGovrnAblityOrgMonthlyDao;
@Autowired
private FactIndexServiceAblityOrgMonthlyDao factIndexServiceAblityOrgMonthlyDao;
@Autowired
private IndexGroupDetailService indexGroupDetailService;
@Autowired
private IndexCodeFieldReService indexCodeFieldReService;
@Autowired
private FactIndexCommunityPartyFiveScoreDao factIndexCommunityPartyFiveScoreDao;
private FactIndexCommunityScoreDao factIndexCommunityScoreDao;
@Autowired
private FactIndexGridScoreDao factIndexGridScoreDao;
@Autowired
private FactIndexCommunityServiceFiveScoreDao factIndexCommunityServiceFiveScoreDao;
@Autowired
private FactIndexCommunityGovrnFiveScoreDao factIndexCommunityGovrnFiveScoreDao;
@Autowired
private FactIndexCommunityScoreDao factIndexCommunityScoreDao;
/**
* @Description 社区名义发文数量计算党建能力
@ -70,32 +61,48 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void communityPublishArticleCountCalculate(String customerId, String monthId) {
public void communityPartyCalculate(String customerId, String monthId) {
customerId = "b09527201c4409e19d1dbc5e3c3429a1";
// 党建能力
// 根据all_parent_index_code 获取指标明细
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(),IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
List<FactIndexCommunityPartyFiveScoreDTO> subAllGridList = new ArrayList<>();
List<FactIndexCommunityPartyFiveScoreDTO> communityPublishArticle = new ArrayList<>();
List<FactIndexCommunityScoreDTO> subAllGridList = new ArrayList<>();
List<FactIndexCommunityScoreDTO> communityPublishArticle = new ArrayList<>();
//下属所有网格的党建能力平均值
String finalCustomerId = customerId;
detailListByParentCode.forEach(indexGroup -> {
if (indexGroup.getIndexCode().equals("xiazhusuoyouwgddjnlpjz")){
if (indexGroup.getIndexCode().equals(IndexCalConstant.COMMUNITY_PARTY_AVG)){
List<SubGridPartyAvgResultDTO> subGridPartyAvgScore = factIndexGridScoreDao.selectSubGridPartyAvgScore(finalCustomerId, monthId);
if (subGridPartyAvgScore.size() != NumConstant.ZERO){
subGridPartyAvgScore.forEach(subGridParty -> {
BigDecimal multiply = subGridParty.getScore().multiply(indexGroup.getWeight());
subGridParty.setScore(multiply);
FactIndexCommunityPartyFiveScoreDTO dto = new FactIndexCommunityPartyFiveScoreDTO();
BeanUtils.copyProperties(subGridParty,dto);
dto.setIndexId(indexGroup.getIndexId());
dto.setTotalScore(dto.getPartyAbilityScore());
subAllGridList.add(dto);
});
factIndexCommunityPartyFiveScoreDao.insertCommunityPartyRecord(subAllGridList);
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridPartyAvgScore.stream().map(o -> o.getScore()).collect(Collectors.toList()));
Integer indexStart = NumConstant.ZERO;
Integer indexEnd = NumConstant.TEN;
List<SubGridPartyAvgResultDTO> collect;
do {
collect = subGridPartyAvgScore.stream().skip(indexEnd * indexStart).limit(indexEnd).collect(Collectors.toList());
BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
List<SampleValue> index1SampleValues = new ArrayList<>();
collect.forEach(c -> {
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
FactIndexCommunityScoreDTO dto = new FactIndexCommunityScoreDTO();
BeanUtils.copyProperties(c,dto);
subAllGridList.add(dto);
});
IndexInputVO index1VO = new IndexInputVO(indexGroup.getIndexId(), index1SampleValues,indexGroup.getThreshold(), indexGroup.getWeight(), sc1);
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO);
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
List<IndexOutputVO> result = batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS);
result.get(NumConstant.ZERO).getIndexScoreVOs().forEach(agency -> {
subAllGridList.forEach(grid -> {
if (grid.getAgencyId().equals(agency.getSampleId())){
grid.setScore(agency.getSampleScore());
}
});
});
indexStart++;
}while (collect.size() == NumConstant.TEN);
}
}
});
@ -105,13 +112,13 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
if (indexGroup.getIndexCode().equals("shequmingyifwsl")) {
if (publishArticleCounts.size() == NumConstant.ONE) {
//TODO 计算之后的分数
FactIndexCommunityPartyFiveScoreDTO dto = new FactIndexCommunityPartyFiveScoreDTO();
FactIndexCommunityScoreDTO dto = new FactIndexCommunityScoreDTO();
BeanUtils.copyProperties(detailListByParentCode.get(NumConstant.ZERO), dto);
dto.setPartyAbilityScore(BigDecimal.valueOf(50.00));
dto.setIndexId(detailListByParentCode.get(NumConstant.ZERO).getIndexId());
dto.setScore(BigDecimal.valueOf(50.00));
dto.setIndexCode(detailListByParentCode.get(NumConstant.ZERO).getIndexCode());
communityPublishArticle.add(dto);
factIndexCommunityPartyFiveScoreDao.insertCommunityPartyRecord(communityPublishArticle);
} else if (publishArticleCounts.size() != NumConstant.ZERO) {
factIndexCommunityScoreDao.insertCommunityPartyRecord(communityPublishArticle);
} else if (publishArticleCounts.size() > NumConstant.ONE) {
Integer indexStart = NumConstant.ZERO;
Integer indexEnd = NumConstant.TEN;
List<CommunityPublishArticleCountResultDTO> collect;
@ -123,32 +130,37 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
collect.forEach(c -> {
SampleValue s = new SampleValue(c.getAgencyId(), c.getPublishArticleCount());
ll.add(s);
FactIndexCommunityPartyFiveScoreDTO publishArticle = new FactIndexCommunityPartyFiveScoreDTO();
FactIndexCommunityScoreDTO publishArticle = new FactIndexCommunityScoreDTO();
BeanUtils.copyProperties(c,publishArticle);
communityPublishArticle.add(publishArticle);
});
IndexInputVO<Integer> index1VO = new IndexInputVO<>(indexGroup.getIndexId(), ll, indexGroup.getWeight(), sc1);
IndexInputVO<Integer> index1VO = new IndexInputVO<>(indexGroup.getIndexId(), ll,indexGroup.getThreshold(), indexGroup.getWeight(), sc1);
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO);
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
List<IndexOutputVO> result = batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS);
result.get(NumConstant.ZERO).getIndexScoreVOs().forEach(agency -> {
communityPublishArticle.forEach(publish -> {
if (publish.getAgencyId().equals(agency.getSampleId())){
publish.setIndexId(indexGroup.getIndexId());
publish.setPartyAbilityScore(agency.getSampleScore());
publish.setTotalScore(agency.getSampleScore());
publish.setIndexCode(indexGroup.getIndexCode());
publish.setScore(agency.getSampleScore());
}
});
});
indexStart++;
} while (collect.size() == 10);
factIndexCommunityPartyFiveScoreDao.insertCommunityPartyRecord(communityPublishArticle);
} while (collect.size() == NumConstant.TEN);
}
}
});
subAllGridList.forEach(grid -> {
communityPublishArticle.forEach(publish -> {
if (grid.getAgencyId().equals(publish.getAgencyId())){
grid.setScore(grid.getScore().add(publish.getScore()));
grid.setIndexCode(IndexCalConstant.COMMUNITY_PARTY);
}
});
});
factIndexCommunityScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.COMMUNITY_PARTY);
factIndexCommunityScoreDao.insertCommunityPartyRecord(subAllGridList);
}
/**
@ -160,21 +172,260 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void CommunityGovernAbilityCalculate(String customerId, String monthId) {
List<CommunityGovernAbilityResultDTO> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbility(customerId, monthId);
public void communityGovernAbilityCalculate(String customerId, String monthId) {
customerId = "b09527201c4409e19d1dbc5e3c3429a1";
List<FactIndexCommunityScoreDTO> subAllGridList = new ArrayList<>();
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
String finalCustomerId = customerId;
detailListByParentCode.forEach(detail -> {
if (detail.getIndexCode().equals(IndexCalConstant.COMMUNITY_GOVERN_AVG)){
List<SubGridGovernAvgResultDTO> subGridGovernAvg = factIndexGridScoreDao.selectSubGridGovernAvgScore(finalCustomerId, monthId);
if (subGridGovernAvg.size() == NumConstant.ONE){
// TODO
}else if (subGridGovernAvg.size() > NumConstant.ONE){
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridGovernAvg.stream().map(o -> o.getScore()).collect(Collectors.toList()));
Integer indexStart = NumConstant.ZERO;
Integer indexEnd = NumConstant.TEN;
List<SubGridGovernAvgResultDTO> collect;
do {
collect = subGridGovernAvg.stream().skip(indexEnd * indexStart).limit(indexEnd).collect(Collectors.toList());
BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
List<SampleValue> index1SampleValues = new ArrayList<>();
collect.forEach(c -> {
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
FactIndexCommunityScoreDTO dto = new FactIndexCommunityScoreDTO();
BeanUtils.copyProperties(c,dto);
subAllGridList.add(dto);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold() ,detail.getWeight(), sc1);
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO);
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
scoreCountOfSampleId.forEach((key,value) -> {
subAllGridList.forEach(grid -> {
if (grid.getAgencyId().equals(key)){
grid.setScore(value);
}
});
});
indexStart++;
}while (collect.size() == NumConstant.TEN);
}
}
else {
}
});
List<Map<String,Object>> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbility(finalCustomerId, monthId);
if (communityGovernAbility.size() == NumConstant.ONE){
List<CommunityGovernAbilityCalculateResultDTO> result = new ArrayList<>();
CommunityGovernAbilityCalculateResultDTO governAbility = new CommunityGovernAbilityCalculateResultDTO();
BeanUtils.copyProperties(communityGovernAbility.get(NumConstant.ZERO),governAbility);
// TODO 计算之后的分数
// TODO
result.add(governAbility);
}else if (communityGovernAbility.size() > NumConstant.ONE){
List<IndexInputVO> indexInputVOS = new ArrayList<>();
detailListByParentCode.forEach(detail -> {
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode());
if (!StringUtils.isEmpty(fieldNameByIndexCode)){
if (communityGovernAbility.get(NumConstant.ZERO).containsKey(fieldNameByIndexCode)) {
List<BigDecimal> decimalList = communityGovernAbility.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList());
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(decimalList);
Integer indexStart = NumConstant.ZERO;
Integer indexEnd = NumConstant.TEN;
List<Map<String, Object>> collect;
do {
collect = communityGovernAbility.stream().skip(indexEnd * indexStart).limit(indexEnd).collect(Collectors.toList());
ScoreCalculator<Integer> sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
List<SampleValue> index1SampleValues = new ArrayList<>();
collect.forEach(c -> {
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);
} while (collect.size() == NumConstant.TEN);
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
scoreCountOfSampleId.forEach((key,value) -> {
subAllGridList.forEach(grid -> {
if (key.equals(grid.getAgencyId())) {
grid.setCustomerId(finalCustomerId);
grid.setIndexCode(IndexCalConstant.COMMUNITY_GOVERN);
grid.setScore(grid.getScore().add(value));
}
});
});
}
}
});
}
factIndexCommunityScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.COMMUNITY_GOVERN);
factIndexCommunityScoreDao.insertCommunityPartyRecord(subAllGridList);
}
/**
* @Description 社区服务能力
* @param customerId
* @param monthId
* @author zxc
* @date 2020/8/31 1:38 下午
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void communityServiceAbilityCalculate(String customerId, String monthId) {
List<FactIndexCommunityScoreDTO> subAllGridList = new ArrayList<>();
List<FactIndexCommunityScoreDTO> communityPublishArticle = new ArrayList<>();
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), IndexCodeEnum.FU_WU_NENG_LI.getCode());
detailListByParentCode.forEach(detail -> {
switch (detail.getIndexCode()){
case IndexCalConstant.COMMUNITY_SERVICE_AVG:
List<SubGridServiceAvgResultDTO> subGridServiceAvg = factIndexGridScoreDao.selectSubGridServiceAvgScore(customerId, monthId);
if (subGridServiceAvg.size() == NumConstant.ONE){
// TODO 只有一条记录时
}else if (subGridServiceAvg.size() > NumConstant.ONE ){
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridServiceAvg.stream().map(o -> o.getScore()).collect(Collectors.toList()));
Integer indexStart = NumConstant.ZERO;
Integer indexEnd = NumConstant.TEN;
List<SubGridServiceAvgResultDTO> collect;
do {
collect = subGridServiceAvg.stream().skip(indexEnd * indexStart).limit(indexEnd).collect(Collectors.toList());
BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
List<SampleValue> index1SampleValues = new ArrayList<>();
collect.forEach(c -> {
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
FactIndexCommunityScoreDTO dto = new FactIndexCommunityScoreDTO();
BeanUtils.copyProperties(c,dto);
subAllGridList.add(dto);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues,detail.getThreshold(), detail.getWeight(), sc1);
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO);
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
List<IndexOutputVO> result = batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS);
result.get(NumConstant.ZERO).getIndexScoreVOs().forEach(agency -> {
subAllGridList.forEach(grid -> {
if (grid.getAgencyId().equals(agency.getSampleId())){
grid.setScore(agency.getSampleScore());
}
});
});
indexStart++;
}while (collect.size() == NumConstant.TEN);
}
break;
case "shequhuodongzzcs":
List<CommunityActivityCountResultDTO> communityActivityCount = factIndexServiceAblityOrgMonthlyDao.selectActivityCount(customerId, monthId);
if (communityActivityCount.size() == NumConstant.ONE){
// TODO
}else if (communityActivityCount.size() > NumConstant.ONE){
Integer indexStart = NumConstant.ZERO;
Integer indexEnd = NumConstant.TEN;
List<CommunityActivityCountResultDTO> collect;
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(communityActivityCount.stream().map(o -> new BigDecimal(o.getActivityCount())).collect(Collectors.toList()));
do {
collect = communityActivityCount.stream().skip(indexEnd * indexStart).limit(indexEnd).collect(Collectors.toList());
ScoreCalculator<Integer> sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
List<SampleValue<Integer>> ll = new ArrayList<>();
collect.forEach(c -> {
SampleValue s = new SampleValue(c.getAgencyId(), c.getActivityCount());
ll.add(s);
FactIndexCommunityScoreDTO publishArticle = new FactIndexCommunityScoreDTO();
BeanUtils.copyProperties(c,publishArticle);
communityPublishArticle.add(publishArticle);
});
IndexInputVO<Integer> index1VO = new IndexInputVO<>(detail.getIndexId(), ll, detail.getThreshold(),detail.getWeight(), sc1);
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO);
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
List<IndexOutputVO> result = batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS);
result.get(NumConstant.ZERO).getIndexScoreVOs().forEach(agency -> {
communityPublishArticle.forEach(publish -> {
if (publish.getAgencyId().equals(agency.getSampleId())){
publish.setScore(agency.getSampleScore());
}
});
});
indexStart++;
} while (collect.size() == NumConstant.TEN);
}
break;
default:
}
});
subAllGridList.forEach(grid -> {
grid.setIndexCode(IndexCalConstant.COMMUNITY_SERVICE);
communityPublishArticle.forEach(publish -> {
if (grid.getAgencyId().equals(publish.getAgencyId())){
grid.setScore(grid.getScore().add(publish.getScore()));
grid.setCustomerId(customerId);
}
});
});
factIndexCommunityScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.COMMUNITY_SERVICE);
factIndexCommunityScoreDao.insertCommunityPartyRecord(subAllGridList);
}
/**
* @Description 社区相关计算
* @param customerId
* @param monthId
* @author zxc
* @date 2020/9/1 9:21 上午
*/
@Override
public void communityRelate(String customerId, String monthId) {
this.communityPartyCalculate(customerId, monthId); //党建能力
this.communityGovernAbilityCalculate(customerId, monthId); // 治理能力
this.communityServiceAbilityCalculate(customerId, monthId); // 服务能力
List<FactIndexCommunityScoreDTO> communityPublishArticle = new ArrayList<>();
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode());
List<FactIndexCommunityScoreDTO> factIndexCommunityScoreEntities = factIndexCommunityScoreDao.selectCommunityInfo(customerId, monthId);
detailListByParentCode.forEach(detail -> {
factIndexCommunityScoreEntities.forEach(community -> {
if (detail.getIndexCode().equals(community.getIndexCode())){
community.setScore(community.getScore().multiply(detail.getWeight()));
}
});
});
Map<String, List<FactIndexCommunityScoreDTO>> collect = factIndexCommunityScoreEntities.stream().collect(Collectors.groupingBy(FactIndexCommunityScoreDTO::getAgencyId));
List<FactIndexCommunityScoreDTO> result = new ArrayList<>();
collect.forEach((key,value) -> {
FactIndexCommunityScoreDTO score = new FactIndexCommunityScoreDTO();
score.setIsTotal(NumConstant.ONE_STR);
score.setCustomerId(customerId);
score.setAgencyId(key);
score.setMonthId(monthId);
score.setYearId(DateUtils.getYearId(monthId));
score.setQuarterId(DateUtils.getQuarterId(monthId));
factIndexCommunityScoreEntities.forEach(community -> {
score.setScore(score.getScore().add(community.getScore()));
});
result.add(score);
});
factIndexCommunityScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.COMMUNITY_RELATE);
factIndexCommunityScoreDao.insertCommunityPartyRecord(result);
}
/**
* @Description Integer类型获取最大数和最小数
* @param list
@ -190,6 +441,16 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
return result;
}
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;
}
/**
* @Description Double类型获取最大数和最小数
* @param list

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

@ -3,6 +3,7 @@ package com.epmet.support.normalizing.batch;
import com.epmet.support.normalizing.ScoreCalculator;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
@ -21,10 +22,11 @@ public class BatchScoreCalculator {
List<SampleValue> indexValueVOs = i.getIndexValueVOs();
BigDecimal weight = i.getWeight();
ScoreCalculator scoreCalculator = i.getScoreCalculator();
BigDecimal threshold = i.getThreshold();
// 循环同一个指标内的多个样本值的SampleValue列表
List<SampleScore> scores4OneIndex = indexValueVOs.stream().map(vo -> {
BigDecimal score = scoreCalculator.normalize(vo.getSampleValue(), weight);
BigDecimal score = scoreCalculator.normalize(getFinalSampleValue(vo.getSampleValue(), threshold), weight).setScale(6, RoundingMode.HALF_UP);;
return new SampleScore(vo.getSampleId(), score);
}).collect(Collectors.toList());
@ -47,14 +49,16 @@ public class BatchScoreCalculator {
List<SampleValue> indexValueVOs = idx.getIndexValueVOs();
BigDecimal weight = idx.getWeight();
ScoreCalculator scoreCalculator = idx.getScoreCalculator();
BigDecimal threshold = idx.getThreshold();
for (SampleValue vo : indexValueVOs) {
String sampleId = vo.getSampleId();
BigDecimal score = scoreCalculator.normalize(vo.getSampleValue(), weight);
BigDecimal score = scoreCalculator.normalize(getFinalSampleValue(vo.getSampleValue(), threshold), weight);
if (scoreCountOfSamples.containsKey(sampleId)) {
BigDecimal newScore = scoreCountOfSamples.get(sampleId).add(score);
BigDecimal newScore = scoreCountOfSamples.get(sampleId).add(score).setScale(6, RoundingMode.HALF_UP);
scoreCountOfSamples.put(sampleId, newScore);
} else {
score.setScale(6, RoundingMode.HALF_UP);
scoreCountOfSamples.put(sampleId, score);
}
}
@ -62,4 +66,21 @@ public class BatchScoreCalculator {
return scoreCountOfSamples;
}
/**
* 获取最终样本值
* @param realValue
* @param threshold
* @return
*/
public BigDecimal getFinalSampleValue(Object realValue, BigDecimal threshold) {
BigDecimal bdRealValue = new BigDecimal(realValue.toString());
if (threshold.equals(-1)) {
// -1表示不使用阈值
return bdRealValue;
}
return (bdRealValue.compareTo(threshold) < 0) || (bdRealValue.equals(threshold))
? bdRealValue
: threshold ;
}
}

14
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexInputVO.java

@ -10,8 +10,7 @@ import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class IndexInputVO<T> {
public class IndexInputVO<T extends Number> {
/**
* 指标标记由使用者传入用以标记该条指标的独有特性一般用id或者code
@ -24,16 +23,15 @@ public class IndexInputVO<T> {
*/
private List<SampleValue<T>> indexValueVOs;
/**
* 样本阈值
*/
private BigDecimal threshold;
/**
* 权重
*/
private BigDecimal weight;
private ScoreCalculator<T> scoreCalculator;
public IndexInputVO(List<SampleValue<T>> indexValueVOs, BigDecimal weight, ScoreCalculator<T> scoreCalculator) {
this.indexValueVOs = indexValueVOs;
this.weight = weight;
this.scoreCalculator = scoreCalculator;
}
}

3
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/util/Pinyin4jUtil.java

@ -25,6 +25,8 @@ public class Pinyin4jUtil {
duoyinMap.put('率',new String[]{"lv"});
duoyinMap.put('员',new String[]{"yuan"});
duoyinMap.put('提',new String[]{"ti"});
duoyinMap.put('被',new String[]{"bei"});
duoyinMap.put('期',new String[]{"qi"});
}
/**
@ -192,5 +194,6 @@ public class Pinyin4jUtil {
public static void main(String[] args) {
System.out.println(getFirstSpellPinYin("区直部门",false));
System.out.println(getSpellPinYin("党员提出话题数",false,4));
System.out.println(getSpellPinYin("社区超期项目数",false,4));
}
}

11
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexGovrnAblityGridMonthlyDao.xml

@ -138,4 +138,15 @@
and m.CUSTOMER_ID=#{customerId}
and m.MONTH_ID=#{monthId}
</select>
<select id="selectCount" resultType="java.lang.Integer" parameterType="com.epmet.dto.indexcal.CalculateCommonFormDTO">
SELECT
count( 1 ) AS total
FROM
fact_index_govrn_ablity_grid_monthly m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID =#{customerId}
AND m.MONTH_ID=#{monthId}
</select>
</mapper>

24
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml

@ -87,19 +87,19 @@
</insert>
<!-- 社区治理能力各个参数查询 -->
<select id="selectCommunityGovernAbility" resultType="com.epmet.dto.screen.result.CommunityGovernAbilityResultDTO">
<select id="selectCommunityGovernAbility" resultType="java.util.Map">
SELECT
agency_id AS agencyId,
parent_id AS parentId,
month_id AS monthId,
quarter_id AS quarterId,
year_id AS yearId,
transfered_count AS transferedCount,
closed_project_count AS closedProjectCount,
resp_project_ratio AS respProjectRatio,
overdue_project_ratio AS overDueProjectRatio,
closed_project_ratio AS closedProjectRatio,
satisfaction_ratio AS satisfactionRatio
AGENCY_ID,
PARENT_ID,
MONTH_ID,
QUARTER_ID,
YEAR_ID,
TRANSFERED_COUNT,
CLOSED_PROJECT_COUNT,
RESP_PROJECT_RATIO,
OVERDUE_PROJECT_RATIO,
CLOSED_PROJECT_RATIO,
SATISFACTION_RATIO
FROM
fact_index_govrn_ablity_org_monthly
WHERE

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

@ -101,6 +101,9 @@
AGENCY_ID,
PARENT_ID,
GRID_ID,
MONTH_ID,
QUARTER_ID,
YEAR_ID,
USER_ID,
CREATE_TOPIC_COUNT,
JOIN_TOPIC_COUNT,

3
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml

@ -79,7 +79,8 @@
month_id,
quarter_id,
year_id,
publish_article_count
publish_article_count,
customer_id
FROM
fact_index_party_ablity_org_monthly
WHERE

19
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexServiceAblityOrgMonthlyDao.xml

@ -70,4 +70,23 @@
)
</foreach>
</insert>
<!-- 社区活动组织次数 -->
<select id="selectActivityCount" resultType="com.epmet.dto.screen.result.CommunityActivityCountResultDTO">
SELECT
agency_id,
parent_id,
month_id,
quarter_id,
year_id,
activity_count,
customer_id
FROM
fact_index_service_ablity_org_monthly
WHERE
del_flag = '0'
AND data_type = 'community'
AND customer_id = #{customerId}
AND month_id = #{monthId}
</select>
</mapper>

118
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/CpcScoreDao.xml

@ -10,10 +10,6 @@
<result property="gridId" column="GRID_ID"/>
<result property="userId" column="USER_ID"/>
<result property="monthId" column="MONTH_ID"/>
<result property="partyAblityScore" column="PARTY_ABLITY_SCORE"/>
<result property="joinIssueScore" column="JOIN_ISSUE_SCORE"/>
<result property="partyWorkActScore" column="PARTY_WORK_ACT_SCORE"/>
<result property="contactMassesScore" column="CONTACT_MASSES_SCORE"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
@ -22,5 +18,119 @@
<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.indexscore.CpcScoreEntity">
select
CUSTOMER_ID,AGENCY_ID,GRID_ID,YEAR_ID,MONTH_ID,USER_ID,SCORE,INDEX_CODE FROM fact_index_cpc_score
WHERE
CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} and MONTH_ID = #{monthId,jdbcType=VARCHAR} AND IS_TOTAL = '0'
</select>
<!-- 获取网格内党员的联系群众能力考评分(平均值) -->
<select id="selectGridContactMassesAvgValue" parameterType="map" resultType="java.math.BigDecimal">
SELECT
AVG( SCORE ) AS AVG_CONTACT_MASSES_SCORE
FROM
fact_index_cpc_score m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID =#{customerId}
AND m.MONTH_ID = #{monthId}
AND m.GRID_ID = #{gridId}
and m.INDEX_CODE='lianxiqunzhong'
GROUP BY
m.GRID_ID
</select>
<!-- 获取网格内党员的联系群众能力考评分(平均值)的最大值,最小值 -->
<select id="selectListGridContactMassesAvgValue" parameterType="com.epmet.dto.indexcal.CalculateCommonFormDTO" resultType="java.math.BigDecimal">
SELECT
AVG( SCORE ) AS AVG_CONTACT_MASSES_SCORE
FROM
fact_index_cpc_score m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID =#{customerId}
AND m.MONTH_ID = #{monthId}
and m.INDEX_CODE='lianxiqunzhong'
GROUP BY
m.GRID_ID
</select>
<!-- 网格内党员的参与议事能力考评分(平均值) 最大值最小值 -->
<select id="selectListJoinIssueAvgValue" parameterType="com.epmet.dto.indexcal.CalculateCommonFormDTO" resultType="java.math.BigDecimal">
SELECT
AVG( SCORE ) AS AVG_JOIN_ISSUE_SCORE
FROM
fact_index_cpc_score m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID =#{customerId}
AND m.MONTH_ID = #{monthId}
and m.INDEX_CODE='canyuyishi'
GROUP BY
m.GRID_ID
</select>
<!-- -->
<select id="selectGridJoinIssueAvgValue" parameterType="map" resultType="java.math.BigDecimal">
SELECT
AVG( SCORE ) AS AVG_CONTACT_MASSES_SCORE
FROM
fact_index_cpc_score m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID =#{customerId}
AND m.MONTH_ID = #{monthId}
AND m.GRID_ID = #{gridId}
and m.INDEX_CODE='canyuyishi'
GROUP BY
m.GRID_ID
</select>
<insert id="insertBatch">
INSERT INTO `fact_index_cpc_score` (
`ID`,
`CUSTOMER_ID`,
`GRID_ID`,
`AGENCY_ID`,
`YEAR_ID`,
`MONTH_ID`,
`USER_ID`,
`IS_TOTAL`,
`SCORE`,
`INDEX_CODE`,
`DEL_FLAG`,
`REVISION`,
`CREATED_BY`,
`CREATED_TIME`,
`UPDATED_BY`,
`UPDATED_TIME`
)
VALUES
<foreach collection="list" item="item" index="index" separator=",">
(
(SELECT REPLACE(UUID(), '-', '') AS id),
#{item.customerId},
#{item.gridId},
#{item.agencyId},
#{item.yearId},
#{item.monthId},
#{item.userId},
#{item.isTotal},
#{item.score},
#{item.indexCode},
0,
0,
'APP_USER',
now(),
'APP_USER',
now()
)
</foreach>
</insert>
</mapper>

96
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/GridScoreDao.xml

@ -8,13 +8,13 @@
<result property="customerId" column="CUSTOMER_ID"/>
<result property="gridId" column="GRID_ID"/>
<result property="agencyId" column="AGENCY_ID"/>
<result property="allParentIds" column="ALL_PARENT_IDS"/>
<result property="quarterId" column="QUARTER_ID"/>
<result property="yearId" column="YEAR_ID"/>
<result property="monthId" column="MONTH_ID"/>
<result property="totalScore" column="TOTAL_SCORE"/>
<result property="partyAblityScore" column="PARTY_ABLITY_SCORE"/>
<result property="govrnAblityScore" column="GOVRN_ABLITY_SCORE"/>
<result property="serviceAblityScore" column="SERVICE_ABLITY_SCORE"/>
<result property="isTotal" column="IS_TOTAL"/>
<result property="score" column="SCORE"/>
<result property="indexCode" column="INDEX_CODE"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
@ -23,5 +23,93 @@
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<delete id="deleteByCusAndMonthId" parameterType="map">
DELETE
FROM
fact_index_grid_score
WHERE
CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
AND INDEX_CODE = #{indexCode}
and IS_TOTAL=#{isTotal}
</delete>
<insert id="insertBatches">
INSERT INTO `fact_index_grid_score` (
`ID`,
`CUSTOMER_ID`,
`GRID_ID`,
`AGENCY_ID`,
`ALL_PARENT_IDS`,
`QUARTER_ID`,
`YEAR_ID`,
`MONTH_ID`,
`IS_TOTAL`,
`SCORE`,
`INDEX_CODE`,
`DEL_FLAG`,
`REVISION`,
`CREATED_BY`,
`CREATED_TIME`,
`UPDATED_BY`,
`UPDATED_TIME`
)
VALUES
<foreach collection="list" item="item" index="index" separator=",">
(
(SELECT REPLACE(UUID(), '-', '') AS id),
#{item.customerId},
#{item.gridId},
#{item.agencyId},
#{item.allParentIds},
#{item.quarterId},
#{item.yearId},
#{item.monthId},
#{item.isTotal},
#{item.score},
#{item.indexCode},
0,
0,
'APP_USER',
now(),
'APP_USER',
now()
)
</foreach>
</insert>
<resultMap id="GridScoreDTOMap" type="com.epmet.dto.indexcal.GridScoreDTO">
<result property="gridId" column="GRID_ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="agencyId" column="AGENCY_ID"/>
<result property="allParentIds" column="ALL_PARENT_IDS"/>
<result property="quarterId" column="QUARTER_ID"/>
<result property="yearId" column="YEAR_ID"/>
<result property="monthId" column="MONTH_ID"/>
<collection property="detailList" ofType="com.epmet.dto.indexcal.GridScoreDetailDTO" >
<result property="isTotal" column="IS_TOTAL"/>
<result property="score" column="SCORE"/>
<result property="indexCode" column="INDEX_CODE"/>
</collection>
</resultMap>
<select id="selectList" parameterType="com.epmet.dto.indexcal.CalculateCommonFormDTO" resultMap="GridScoreDTOMap">
SELECT
m.GRID_ID,
m.CUSTOMER_ID,
m.AGENCY_ID,
m.ALL_PARENT_IDS,
m.QUARTER_ID,
m.YEAR_ID,
m.MONTH_ID,
m.IS_TOTAL,
M.SCORE,
M.INDEX_CODE
FROM
fact_index_grid_score m
WHERE
m.DEL_FLAG = '0'
AND m.IS_TOTAL='0'
AND m.CUSTOMER_ID =#{customerId}
AND m.MONTH_ID =#{monthId}
</select>
</mapper>

6
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityGovrnFiveScoreDao.xml

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.screen.FactIndexCommunityGovrnFiveScoreDao">
</mapper>

27
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityPartyFiveScoreDao.xml

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.screen.FactIndexCommunityPartyFiveScoreDao">
<!-- 党建能力【社区】中间表插入 -->
<insert id="insertCommunityPartyRecord">
INSERT INTO fact_index_community_party_five_score ( ID, AGENCY_ID, MONTH_ID, INDEX_ID, TOTAL_SCORE, PARTY_ABILITY_SCORE, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME )
VALUES
<foreach collection="lists" item="item" separator=",">
(
REPLACE ( UUID(), '-', '' ),
#{item.agencyId},
#{item.monthId},
#{item.indexId},
#{item.totalScore},
#{item.partyAbilityScore},
#{item.delFlag},
#{item.revision},
#{item.createdBy},
NOW(),
#{item.updatedBy},
NOW()
)
</foreach>
</insert>
</mapper>

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

@ -3,4 +3,60 @@
<mapper namespace="com.epmet.dao.screen.FactIndexCommunityScoreDao">
<!-- 党建能力【社区】中间表插入 -->
<insert id="insertCommunityPartyRecord">
INSERT INTO fact_index_community_score ( ID, CUSTOMER_ID, AGENCY_ID, PARENT_AGENCY_ID, YEAR_ID, QUARTER_ID, MONTH_ID, IS_TOTAL, SCORE, INDEX_CODE, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME )
VALUES
<foreach collection="lists" item="item" separator=",">
(
REPLACE(UUID(),'-',''),
#{item.customerId},
#{item.agencyId},
#{item.parentAgencyId},
#{item.yearId},
#{item.quarterId},
#{item.monthId},
#{item.isTotal},
#{item.score},
#{item.indexCode},
#{item.delFlag},
#{item.revision},
#{item.createdBy},
NOW(),
#{item.updatedBy},
NOW()
)
</foreach>
</insert>
<!-- 删除旧记录 -->
<delete id="deleteOldRecord">
DELETE
FROM
fact_index_community_score
WHERE
del_flag = '0'
AND customer_id = #{customerId}
AND month_id = #{monthId}
AND index_code = #{indexCode}
</delete>
<!-- 查询社区相关信息 -->
<select id="selectCommunityInfo" resultType="com.epmet.dto.screen.FactIndexCommunityScoreDTO">
SELECT
CUSTOMER_ID,
AGENCY_ID,
MONTH_ID,
QUARTER_ID,
YEAR_ID,
SCORE,
INDEX_CODE
FROM
fact_index_community_score
WHERE
del_flag = 0
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
</select>
</mapper>

6
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityServiceFiveScoreDao.xml

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.screen.FactIndexCommunityServiceFiveScoreDao">
</mapper>

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

@ -8,13 +8,55 @@
SELECT
agency_id,
month_id,
AVG( party_ablity_score ) AS score
quarter_id,
year_id,
AVG( score ) AS score,
customer_id
FROM
fact_index_grid_score
WHERE
del_flag = '0'
AND customer_id = #{customerId}
AND month_id = #{monthId}
AND index_code = 'dangjiannengli'
GROUP BY agency_id
</select>
<!-- 社区下属所有网格治理能力汇总平均值 -->
<select id="selectSubGridGovernAvgScore" resultType="com.epmet.dto.screen.result.SubGridGovernAvgResultDTO">
SELECT
agency_id,
month_id,
quarter_id,
year_id,
AVG( score ) AS score,
customer_id
FROM
fact_index_grid_score
WHERE
del_flag = '0'
AND customer_id = #{customerId}
AND month_id = #{monthId}
AND index_code = 'zhilinengli'
GROUP BY agency_id
</select>
<!-- 社区下级所有网格服务能力得分平均值 -->
<select id="selectSubGridServiceAvgScore" resultType="com.epmet.dto.screen.result.SubGridServiceAvgResultDTO">
SELECT
agency_id,
month_id,
quarter_id,
year_id,
AVG( score ) AS score,
customer_id
FROM
fact_index_grid_score
WHERE
del_flag = '0'
AND customer_id = #{customerId}
AND month_id = #{monthId}
AND index_code = 'fuwunengli'
GROUP BY agency_id
</select>
</mapper>

6
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailDao.xml

@ -6,7 +6,7 @@
<select id="getDetailListByParentCode" resultType="com.epmet.entity.screen.IndexGroupDetailEntity">
select
ID, INDEX_GROUP_ID, INDEX_ID, INDEX_CODE, WEIGHT, THRESHOLD
ID,CUSTOMER_ID, INDEX_GROUP_ID, INDEX_ID, INDEX_CODE, WEIGHT, THRESHOLD, ALL_PARENT_INDEX_CODE
FROM index_group_detail
WHERE
CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} and STATUS = 'enable' and DEL_FLAG = '0'
@ -15,10 +15,10 @@
<select id="getDetailListLikeParentCode" resultType="com.epmet.entity.screen.IndexGroupDetailEntity">
select
ID, INDEX_GROUP_ID, INDEX_ID, INDEX_CODE, WEIGHT, THRESHOLD
ID, CUSTOMER_ID, INDEX_GROUP_ID, INDEX_ID, INDEX_CODE, WEIGHT, THRESHOLD, ALL_PARENT_INDEX_CODE
FROM index_group_detail
WHERE
CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} and STATUS = 'enable' and DEL_FLAG = '0'
and ALL_PARENT_INDEX_CODE like concat(#{indexCode,jdbcType=VARCHAR},'%')
and ALL_PARENT_INDEX_CODE like concat(#{parentIndexCode,jdbcType=VARCHAR},'%')
</select>
</mapper>

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

@ -92,4 +92,17 @@
order by m.GRID_ID asc
LIMIT #{pageIndex}, #{pageSize}
</select>
<!-- -->
<select id="selectParentAgencyId" parameterType="map" resultType="com.epmet.dto.ScreenCustomerGridDTO">
SELECT
PARENT_AGENCY_ID,
ALL_PARENT_IDS
FROM
screen_customer_grid m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID =#{customerId}
AND m.GRID_ID = #{gridId}
</select>
</mapper>

12
epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/DemoScoreCal.java

@ -78,8 +78,8 @@ public class DemoScoreCal {
List<SampleValue<Integer>> index2SampleValues = Arrays.asList(new SampleValue<>("id1", 1), new SampleValue<>("id2", 8), new SampleValue<>("id3", 3));
// 每个指标的信息,包括样本列表,权重,指标标记
IndexInputVO<Integer> index1VO = new IndexInputVO<>("aaa", index1SampleValues, new BigDecimal(1), sc1);
IndexInputVO<Integer> index2VO = new IndexInputVO<>("bbb", index2SampleValues, new BigDecimal(1), sc2);
IndexInputVO<Integer> index1VO = new IndexInputVO<>("aaa", index1SampleValues, new BigDecimal(10), new BigDecimal(1), sc1);
IndexInputVO<Integer> index2VO = new IndexInputVO<>("bbb", index2SampleValues, new BigDecimal(10), new BigDecimal(1), sc2);
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO, index2VO);
@ -104,8 +104,8 @@ public class DemoScoreCal {
List<SampleValue> index2SampleValues = Arrays.asList(new SampleValue<>("id1", new BigDecimal(1)), new SampleValue<>("id2", new BigDecimal(8)), new SampleValue<>("id3", new BigDecimal(3)));
// 每个指标的信息,包括样本列表,权重,指标标记
IndexInputVO index1VO = new IndexInputVO("aaa", index1SampleValues, new BigDecimal(1), sc1);
IndexInputVO index2VO = new IndexInputVO("bbb", index2SampleValues, new BigDecimal(1), sc2);
IndexInputVO index1VO = new IndexInputVO("aaa", index1SampleValues, new BigDecimal(6), new BigDecimal(1), sc1);
IndexInputVO index2VO = new IndexInputVO("bbb", index2SampleValues, new BigDecimal(6), new BigDecimal(1), sc2);
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO, index2VO);
@ -130,8 +130,8 @@ public class DemoScoreCal {
List<SampleValue> index2SampleValues = Arrays.asList(new SampleValue<>("id1", new BigDecimal(1)), new SampleValue<>("id2", new BigDecimal(8)), new SampleValue<>("id3", new BigDecimal(3)));
// 每个指标的信息,包括样本列表,权重,指标标记
IndexInputVO index1VO = new IndexInputVO("aaa", index1SampleValues, new BigDecimal(1), sc1);
IndexInputVO index2VO = new IndexInputVO("bbb", index2SampleValues, new BigDecimal(1), sc2);
IndexInputVO index1VO = new IndexInputVO("aaa", index1SampleValues, new BigDecimal(6), new BigDecimal(1), sc1);
IndexInputVO index2VO = new IndexInputVO("bbb", index2SampleValues, new BigDecimal(6), new BigDecimal(1), sc2);
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO, index2VO);

Loading…
Cancel
Save