diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java index 0a45a6b290..75174f4216 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java +++ b/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 Q3Months = Arrays.asList(7, 8, 9); public static final List Q4Months = Arrays.asList(10, 11, 12); + public static final List Q1MonthsStrList = Arrays.asList("1", "2", "3","01","02","03"); + public static final List Q2MonthsStrList = Arrays.asList("4", "5", "6","04", "05", "06"); + public static final List Q3MonthsStrList = Arrays.asList("7", "8", "9","07", "08", "09"); + public static final List 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 yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4 + */ + 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; + } } diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/ContactMassLineChartResultDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/ContactMassLineChartResultDTO.java index e57b0cc54f..5a2b93acd9 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/ContactMassLineChartResultDTO.java +++ b/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 groupMemberData; + + /** + * 党员建群数 + **/ + private Integer groupTotal = NumConstant.ZERO; + + /** + * 党成员数 + * */ + private Integer groupMemberTotal = NumConstant.ZERO; } diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/screen/impl/PartyMemberLeadServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/screen/impl/PartyMemberLeadServiceImpl.java index 902861f5e2..b895b49651 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/screen/impl/PartyMemberLeadServiceImpl.java +++ b/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; } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/IndexCalConstant.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/IndexCalConstant.java index aff436ff3d..12b5c2a136 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/IndexCalConstant.java +++ b/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"; } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/GridScoreDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/GridScoreDTO.java new file mode 100644 index 0000000000..5e3b4096f2 --- /dev/null +++ b/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: yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4 + */ + private String quarterId; + + /** + * 年度ID: yyyy + */ + private String yearId; + + /** + * 月维度Id: yyyyMM + */ + private String monthId; + + private List detailList; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/GridScoreDetailDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/GridScoreDetailDTO.java new file mode 100644 index 0000000000..e2573fbfd9 --- /dev/null +++ b/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; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityGovrnFiveScoreDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityGovrnFiveScoreDTO.java deleted file mode 100644 index 5f2fbf85b7..0000000000 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityGovrnFiveScoreDTO.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * Copyright 2018 人人开源 https://www.renren.io - *

- * 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. - *

- * 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. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -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"; - } -} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityPartyFiveScoreDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityPartyFiveScoreDTO.java deleted file mode 100644 index 79024c60ca..0000000000 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityPartyFiveScoreDTO.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * Copyright 2018 人人开源 https://www.renren.io - *

- * 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. - *

- * 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. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -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"; - } - -} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityScoreDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityScoreDTO.java index 805e28ef7f..8ad2ec6658 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityScoreDTO.java +++ b/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: yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4 */ 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"; + } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityServiceFiveScoreDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityServiceFiveScoreDTO.java deleted file mode 100644 index 1eb6386bcc..0000000000 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityServiceFiveScoreDTO.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * Copyright 2018 人人开源 https://www.renren.io - *

- * 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. - *

- * 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. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -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; - -} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/CommunityActivityCountResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/CommunityActivityCountResultDTO.java new file mode 100644 index 0000000000..ec3b17f615 --- /dev/null +++ b/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; + } +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/CommunityPublishArticleCountResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/CommunityPublishArticleCountResultDTO.java index fe50bbf597..cf29133001 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/CommunityPublishArticleCountResultDTO.java +++ b/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 */ diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/MaxAndMinBigDecimalResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/MaxAndMinBigDecimalResultDTO.java new file mode 100644 index 0000000000..aa9f471405 --- /dev/null +++ b/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; + +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridGovernAvgResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridGovernAvgResultDTO.java new file mode 100644 index 0000000000..64f3cc7319 --- /dev/null +++ b/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; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridPartyAvgResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridPartyAvgResultDTO.java index 38263c4dc1..48b4501606 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridPartyAvgResultDTO.java +++ b/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 */ diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridServiceAvgResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridServiceAvgResultDTO.java new file mode 100644 index 0000000000..ba6329aef1 --- /dev/null +++ b/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; +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java index 5f18b920f9..2b88f53f42 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java +++ b/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(); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java index c2211c0d80..9dab47c148 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java +++ b/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(); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexGovrnAblityGridMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexGovrnAblityGridMonthlyDao.java index 90c9a3ea6e..b3002609d1 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexGovrnAblityGridMonthlyDao.java +++ b/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 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); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java index fa9b8569b9..f28e6a2fd3 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java +++ b/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 selectCommunityGovernAbility(@Param("customerId")String customerId, @Param("monthId")String monthId); + List> selectCommunityGovernAbility(@Param("customerId")String customerId, @Param("monthId")String monthId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexServiceAblityOrgMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexServiceAblityOrgMonthlyDao.java index 31c268cd75..261fb8b945 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexServiceAblityOrgMonthlyDao.java +++ b/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 list, @Param("customerId")String customerId); + + /** + * @Description 社区活动组织次数 + * @param customerId + * @param monthId + * @author zxc + * @date 2020/8/31 2:15 下午 + */ + List selectActivityCount(@Param("customerId")String customerId, @Param("monthId")String monthId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexscore/CpcScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexscore/CpcScoreDao.java index 74628e78e8..2142128e3b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexscore/CpcScoreDao.java +++ b/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 { - + + /** + * @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 + * @author yinzuomei + * @description 获取网格内党员的联系群众能力考评分(平均值)的最大值,最小值 + * @Date 2020/8/31 12:10 + **/ + List selectListGridContactMassesAvgValue(CalculateCommonFormDTO formDTO); + + /** + * @param calculateCommonFormDTO + * @return java.util.List + * @author yinzuomei + * @description 网格内党员的参与议事能力考评分(平均值) 最大值最小值 + * @Date 2020/8/31 14:42 + **/ + List 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 getPartScore(@Param("customerId") String customerId, @Param("monthId") String monthId); + + int insertBatch(@Param("list") Collection values); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexscore/GridScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexscore/GridScoreDao.java index 77de72959f..71316cf4f4 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexscore/GridScoreDao.java +++ b/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 { - + /** + * @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 gridScoreEntityList); + + /** + * @return java.util.List + * @param formDTO + * @author yinzuomei + * @description + * @Date 2020/8/31 16:42 + **/ + List selectList(CalculateCommonFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityGovrnFiveScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityGovrnFiveScoreDao.java deleted file mode 100644 index 52cd149927..0000000000 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityGovrnFiveScoreDao.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright 2018 人人开源 https://www.renren.io - *

- * 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. - *

- * 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. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -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 { - -} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityPartyFiveScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityPartyFiveScoreDao.java deleted file mode 100644 index 4c628a1ec0..0000000000 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityPartyFiveScoreDao.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright 2018 人人开源 https://www.renren.io - *

- * 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. - *

- * 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. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -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 { - - /** - * @Description 党建能力【社区】中间表插入 - * @param lists - * @author zxc - * @date 2020/8/27 5:05 下午 - */ - void insertCommunityPartyRecord(@Param("lists")List lists); - -} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityScoreDao.java index 9ea796d24a..607132ea18 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityScoreDao.java +++ b/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 { - + + /** + * @Description 党建能力【社区】中间表插入 + * @param lists + * @author zxc + * @date 2020/8/27 5:05 下午 + */ + void insertCommunityPartyRecord(@Param("lists") List 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 selectCommunityInfo(@Param("customerId") String customerId,@Param("monthId")String monthId); + } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityServiceFiveScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityServiceFiveScoreDao.java deleted file mode 100644 index 97a03ad2c9..0000000000 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityServiceFiveScoreDao.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright 2018 人人开源 https://www.renren.io - *

- * 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. - *

- * 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. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -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 { - -} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexGridScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexGridScoreDao.java index b95b41ff55..223a297db4 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexGridScoreDao.java +++ b/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 */ List selectSubGridPartyAvgScore(@Param("customerId")String customerId,@Param("monthId")String monthId); + /** + * @Description 社区下属所有网格治理能力汇总平均值 + * @param customerId + * @param monthId + * @author zxc + * @date 2020/8/31 9:19 上午 + */ + List selectSubGridGovernAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId); + + /** + * @Description 社区下级所有网格服务能力得分平均值 + * @param customerId + * @param monthId + * @author zxc + * @date 2020/8/31 1:51 下午 + */ + List selectSubGridServiceAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId); + } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/ScreenCustomerGridDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/ScreenCustomerGridDao.java index dfb0d95a84..b826b7cbcc 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/ScreenCustomerGridDao.java +++ b/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 * @Date 2020/8/27 14:42 **/ List 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); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/indexscore/CpcScoreEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/indexscore/CpcScoreEntity.java index 59c4269a3b..cca1b90ff2 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/indexscore/CpcScoreEntity.java +++ b/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; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/indexscore/GridScoreEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/indexscore/GridScoreEntity.java index 3b4b4c44c9..9b1bdf2f73 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/indexscore/GridScoreEntity.java +++ b/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: yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4 + */ 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; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityPartyFiveScoreEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityFiveScoreEntity.java similarity index 92% rename from epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityPartyFiveScoreEntity.java rename to epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityFiveScoreEntity.java index c42849dd0b..b43e51ad7c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityPartyFiveScoreEntity.java +++ b/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; diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityGovrnFiveScoreEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityGovrnFiveScoreEntity.java deleted file mode 100644 index bf0bcbeac0..0000000000 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityGovrnFiveScoreEntity.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Copyright 2018 人人开源 https://www.renren.io - *

- * 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. - *

- * 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. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -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; - -} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityScoreEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityScoreEntity.java index 1c3899ef2d..01b0ff363f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityScoreEntity.java +++ b/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: yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4 */ 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; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityServiceFiveScoreEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityServiceFiveScoreEntity.java deleted file mode 100644 index 8d0fb8857f..0000000000 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityServiceFiveScoreEntity.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Copyright 2018 人人开源 https://www.renren.io - *

- * 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. - *

- * 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. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -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; - -} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/eum/IndexCodeEnum.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/eum/IndexCodeEnum.java index 71ef0303d4..620175e5c5 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/eum/IndexCodeEnum.java +++ b/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; diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java index 24770d1bd2..9267d562a8 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java @@ -123,49 +123,49 @@ public class IndexExcelDataListener extends AnalysisEventListener { 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 { 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 { 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 { 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)); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/CpcIndexCalculateServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/CpcIndexCalculateServiceImpl.java index 521c9dd631..c2d8a924cb 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/CpcIndexCalculateServiceImpl.java +++ b/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 indexDetails = getDetailListByParentCode.getDetailListLikeParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode()); - if (CollectionUtils.isEmpty(indexDetails)) { + /** + * desc: 计算总分 + * + * @param formDTO + */ + private void calculateTotalScore(CalculateCommonFormDTO formDTO) { + //获取指标权重 + List 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 cpcScoreTotalMap = new HashMap<>(); + Map indexWeightMap = parentIndexDetails.stream().collect(Collectors.toMap(IndexGroupDetailEntity::getIndexCode, o -> o)); - canyuyishi(formDTO, indexDetails); + //获取数据 + List 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> 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 values) { + cpcScoreDao.insertBatch(values); } - private void canyuyishi(CalculateCommonFormDTO formDTO, List indexDetails) { + private void calculatePartScore(CalculateCommonFormDTO formDTO) { Map indexCodeFieldReList = indexCodeFieldReService.getIndexCodeFieldReMap(); if (CollectionUtils.isEmpty(indexCodeFieldReList)) { log.error("cpcIndexCalculate have any indexcodefieldre"); @@ -69,77 +109,108 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { //计算最大最小值 Map 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> groupIndexDetailsMap = indexDetails.stream().collect(Collectors.groupingBy(IndexGroupDetailEntity::getAllParentIndexCode)); - - + Map> groupIndexDetailsMap = getIndexDetailMap(formDTO); + if (groupIndexDetailsMap == null) { + return; + } - List> list = null; int pageNo = 1; int pageSize = 10; + //分页查询 要计算的原始数据 + List> list = null; do { list = factIndexPartyAblityCpcMonthlyDao.getCountByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), (pageNo - 1) * pageSize, pageSize); if (!CollectionUtils.isEmpty(list)) { - //遍历指标分组 计算分数 List> finalList = list; - groupIndexDetailsMap.forEach((parentIndex, indexDetailList)->{ - Map> indexMap = getIndexInputVO(indexDetailList, minAndMaxMap); - //遍历指标 进行计算 - for (Map.Entry> entry : indexMap.entrySet()) { - String indexCode = entry.getKey(); - IndexInputVO value = entry.getValue(); - String fieldName = indexCodeFieldReService.getFieldNameByIndexCode(indexCode); - if (StringUtils.isBlank(fieldName)) { - log.error("cpcIndexCalculate fieldName error"); - continue; - } - for (Map cpcIndex : finalList) { - //对应的数值 - String sampleValueStr = String.valueOf(cpcIndex.get(indexCodeFieldReService.getFieldNameByIndexCode(fieldName))); - //构造样本值对象 - SampleValue currentGridIndexValue = new SampleValue((String) cpcIndex.get(IndexCalConstant.USER_ID), new BigDecimal(sampleValueStr)); - value.getIndexValueVOs().add(currentGridIndexValue); - } - } - HashMap 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 indexDetails, HashMap result) { + /** + * desc:计算并保存中间结果 + * + * @param formDTO + * @param indexDetailList + * @param finalList + * @param minAndMaxMap + * @param parentIndexCode remark:1.遍历指标和原始数据;2.构建指标归一算法计算器,计算分值;3.将分值保存到中间表 + */ + private void calculateScore(CalculateCommonFormDTO formDTO, List indexDetailList, List> finalList, Map minAndMaxMap, String parentIndexCode) { + Map> indexMap = buildIndexInputVO(indexDetailList, minAndMaxMap); + Map scoreEntityMap = new HashMap<>(); + //遍历指标 进行计算 + for (Map.Entry> entry : indexMap.entrySet()) { + String indexCode = entry.getKey(); + IndexInputVO value = entry.getValue(); + String fieldName = indexCodeFieldReService.getFieldNameByIndexCode(indexCode); + if (StringUtils.isBlank(fieldName)) { + log.error("cpcIndexCalculate fieldName error"); + continue; + } + + for (Map 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 currentUserIndexValue = new SampleValue(userId, sampleValue); + value.getIndexValueVOs().add(currentUserIndexValue); + } + } + log.warn("计算的参数:{}", indexMap); + HashMap result = calculateScore(indexMap); + log.warn("计算的结果:{}", result); + + //处理结果 + saveCpcScore(formDTO, scoreEntityMap, parentIndexCode, result); } /** - * @param indexMap - * @return java.util.List - * @author yinzuomei - * @description - * @Date 2020/8/30 21:40 - **/ - private HashMap calculate(Map> indexMap) { - //构造入参 - List 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 indexDetails, String parentIndexCode, HashMap result) { + cpcScoreDao.deleteByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), parentIndexCode); + List 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 @@ -147,15 +218,9 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { * @description * @Date 2020/8/30 15:56 **/ - private Map> getIndexInputVO(List indexList, Map minAndMaxMap) { + private Map> buildIndexInputVO(List indexList, Map minAndMaxMap) { Map> 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> 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 calculateScore(Map> indexMap) { + //构造入参 + List indexInputVOS = indexMap.values().stream().collect(Collectors.toList()); + BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); + return batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); + } + + + /** + * desc:构建党员相关4级指标明细map + * + * @param formDTO + * @return + */ + private Map> getIndexDetailMap(CalculateCommonFormDTO formDTO) { + //获取指标权重信息 -参与议事 + List 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 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 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> 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; + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/GridCorreLationServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/GridCorreLationServiceImpl.java index 556d31f85c..7fa8281f15 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/GridCorreLationServiceImpl.java +++ b/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 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 zhiLiNengLiList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(), + calculateGridDangJian(formDTO, dangJianNengLiList); + + //2、计算网格相关-治理能力 + List 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 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 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 indexList) { + @Transactional(rollbackFor = Exception.class) + public void calculateGridDangJian(CalculateCommonFormDTO formDTO, List 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 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> indexMap = getIndexInputVO(formDTO, indexList, minAndMaxMap); + Map> indexMap = buildGridCorrelationIndexInputVO(formDTO, indexList, minAndMaxMap); + List> 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 contactMassesAblityValue = new SampleValue((String) recordMap.get(IndexCalConstant.GRID_ID), contactMassesAvgValue); value.getIndexValueVOs().add(contactMassesAblityValue); } }); }); - List 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 resultMap = calculate(indexMap); + resultMapList.add(resultMap); } + // 保存中间表 + saveGridCorreLationResult(formDTO, resultMapList, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), NumConstant.ZERO_STR); } /** - * @return java.util.Map - * @param formDTO + * @param calculateCommonFormDTO + * @return java.util.Map * @author yinzuomei - * @description TODO + * @description 获取网格内党员的联系群众能力考评分(平均值)的最大值,最小值 * @Date 2020/8/31 9:51 **/ - private Map contactMassesAblityMap(CalculateCommonFormDTO formDTO) { - - return null; + private Map getContactMassesAblityMap(CalculateCommonFormDTO calculateCommonFormDTO) { + Map map = new HashMap<>(); + List 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 indexList, - List indexOutputVOList) { - Map 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 + * @author yinzuomei + * @description 网格内党员的参与议事能力考评分(平均值) 最大值最小值 + * @Date 2020/8/31 14:41 + **/ + private Map getJoinIssueAblityMap(CalculateCommonFormDTO calculateCommonFormDTO) { + Map map = new HashMap<>(); + List 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> resultMapList, + String indexCode, + String isTotal) { + List gridScoreEntityList = new ArrayList<>(); + String quarterId = DateUtils.getQuarterId(formDTO.getMonthId()); + String yearId = DateUtils.getYearId(formDTO.getMonthId()); + for (HashMap 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 * @author yinzuomei - * @description + * @description 调用计算器计算每个指标下,各个网格的总分 * @Date 2020/8/30 21:40 **/ - private List calculate(Map> indexMap) { + private HashMap calculate(Map> indexMap) { //构造入参 List indexInputVOS = this.getIndexInputVOList(indexMap); + logger.info("计算的参数:{}", indexInputVOS); BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); - return batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS); + HashMap resultMap = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); + logger.info("计算的结果:{}", resultMap); + return resultMap; } /** * @param indexMap * @return java.util.List * @author yinzuomei - * @description + * @description map遍历,转为List * @Date 2020/8/30 18:34 **/ private List getIndexInputVOList(Map> indexMap) { @@ -239,50 +338,61 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { * @param minAndMaxMap 最大值最小值集合 * @return java.util.Map * @author yinzuomei - * @description + * @description 构造网格相关 指标计算参数 * @Date 2020/8/30 15:56 **/ - private Map> getIndexInputVO(CalculateCommonFormDTO formDTO, List indexList, Map minAndMaxMap) { + private Map> buildGridCorrelationIndexInputVO(CalculateCommonFormDTO formDTO, List indexList, Map minAndMaxMap) { Map> 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 contactMassesAblityMap= this.contactMassesAblityMap(formDTO); - minValue=contactMassesAblityMap.get(StrConstant.MIN); - maxValue=contactMassesAblityMap.get(StrConstant.MAX); + Map 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 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 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> 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 indexList) { - + private void calculateGridZhiLi(CalculateCommonFormDTO formDTO, List 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 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> indexMap = buildGridCorrelationIndexInputVO(formDTO, indexList, minAndMaxMap); + List> resultMapList = new ArrayList<>(); + //分页查询采集记录 + for (int pageNo = 1; pageNo <= totalPage; pageNo++) { + int pageIndex = (pageNo - NumConstant.ONE) * IndexCalConstant.PAGE_SIZE; + //前10条 + List> 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 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 contactMassesAblityValue = new SampleValue((String) recordMap.get(IndexCalConstant.GRID_ID), joinAvgValue); + value.getIndexValueVOs().add(contactMassesAblityValue); + } + }); + }); + HashMap 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 indexList) { - + private void calculateGridFuWu(CalculateCommonFormDTO formDTO, List 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 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> indexMap = buildGridCorrelationIndexInputVO(formDTO, indexList, minAndMaxMap); + List> resultMapList = new ArrayList<>(); + //分页查询采集记录 + for (int pageNo = 1; pageNo <= totalPage; pageNo++) { + int pageIndex = (pageNo - NumConstant.ONE) * IndexCalConstant.PAGE_SIZE; + //前10条 + List> 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 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 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 indexList) { - + private void calculateGridTotal(CalculateCommonFormDTO formDTO, List indexList, String indexCode) { + //查询总记录数 + List 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 indexMap = indexList.stream().collect(Collectors.toMap(IndexGroupDetailEntity::getIndexCode, Function.identity())); + List 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 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexCalculateCommunityService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexCalculateCommunityService.java index daf11c1519..f597e3748f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexCalculateCommunityService.java +++ b/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); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateCommunityServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateCommunityServiceImpl.java index 15e0b36ff7..89554a0cf2 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateCommunityServiceImpl.java +++ b/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 detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(),IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); - - List subAllGridList = new ArrayList<>(); - List communityPublishArticle = new ArrayList<>(); - + List subAllGridList = new ArrayList<>(); + List communityPublishArticle = new ArrayList<>(); //下属所有网格的党建能力平均值 String finalCustomerId = customerId; detailListByParentCode.forEach(indexGroup -> { - if (indexGroup.getIndexCode().equals("xiazhusuoyouwgddjnlpjz")){ + if (indexGroup.getIndexCode().equals(IndexCalConstant.COMMUNITY_PARTY_AVG)){ List 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 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 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 indexInputVOS = Arrays.asList(index1VO); + BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); + List 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 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 index1VO = new IndexInputVO<>(indexGroup.getIndexId(), ll, indexGroup.getWeight(), sc1); + IndexInputVO index1VO = new IndexInputVO<>(indexGroup.getIndexId(), ll,indexGroup.getThreshold(), indexGroup.getWeight(), sc1); List indexInputVOS = Arrays.asList(index1VO); BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); List 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 communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbility(customerId, monthId); + public void communityGovernAbilityCalculate(String customerId, String monthId) { + customerId = "b09527201c4409e19d1dbc5e3c3429a1"; + + List subAllGridList = new ArrayList<>(); + + List 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 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 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 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 indexInputVOS = Arrays.asList(index1VO); + BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); + HashMap 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> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbility(finalCustomerId, monthId); if (communityGovernAbility.size() == NumConstant.ONE){ - List 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 indexInputVOS = new ArrayList<>(); + detailListByParentCode.forEach(detail -> { + String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode()); + if (!StringUtils.isEmpty(fieldNameByIndexCode)){ + if (communityGovernAbility.get(NumConstant.ZERO).containsKey(fieldNameByIndexCode)) { + List 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> collect; + do { + collect = communityGovernAbility.stream().skip(indexEnd * indexStart).limit(indexEnd).collect(Collectors.toList()); + ScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); + List 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 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 subAllGridList = new ArrayList<>(); + List communityPublishArticle = new ArrayList<>(); + + + List 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 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 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 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 indexInputVOS = Arrays.asList(index1VO); + BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); + List 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 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 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 sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); + List> 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 index1VO = new IndexInputVO<>(detail.getIndexId(), ll, detail.getThreshold(),detail.getWeight(), sc1); + List indexInputVOS = Arrays.asList(index1VO); + BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); + List 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 communityPublishArticle = new ArrayList<>(); + + List detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode()); + List 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> collect = factIndexCommunityScoreEntities.stream().collect(Collectors.groupingBy(FactIndexCommunityScoreDTO::getAgencyId)); + List 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 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 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java index d42ae98562..6c17298ad6 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java +++ b/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 indexValueVOs = i.getIndexValueVOs(); BigDecimal weight = i.getWeight(); ScoreCalculator scoreCalculator = i.getScoreCalculator(); + BigDecimal threshold = i.getThreshold(); // 循环同一个指标内的多个样本值的SampleValue列表 List 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 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 ; + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexInputVO.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexInputVO.java index 94ea1ef0ad..c67b1c494d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexInputVO.java +++ b/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 { +public class IndexInputVO { /** * 指标标记,由使用者传入,用以标记该条指标的独有特性,一般用id或者code @@ -24,16 +23,15 @@ public class IndexInputVO { */ private List> indexValueVOs; + /** + * 样本阈值 + */ + private BigDecimal threshold; + /** * 权重 */ private BigDecimal weight; private ScoreCalculator scoreCalculator; - - public IndexInputVO(List> indexValueVOs, BigDecimal weight, ScoreCalculator scoreCalculator) { - this.indexValueVOs = indexValueVOs; - this.weight = weight; - this.scoreCalculator = scoreCalculator; - } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/util/Pinyin4jUtil.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/util/Pinyin4jUtil.java index c6e61ffb01..bedaf09f1b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/util/Pinyin4jUtil.java +++ b/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)); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexGovrnAblityGridMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexGovrnAblityGridMonthlyDao.xml index e5780e24fa..11c10755fa 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexGovrnAblityGridMonthlyDao.xml +++ b/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} + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml index 11b87f6eb8..76d61d7b83 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml @@ -87,19 +87,19 @@ - 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 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml index beb5b42a4e..c9f807d881 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml +++ b/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, diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml index ff41b99bd4..4e6bd0cd6c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml +++ b/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 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexServiceAblityOrgMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexServiceAblityOrgMonthlyDao.xml index c475e2aca1..d223423e17 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexServiceAblityOrgMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexServiceAblityOrgMonthlyDao.xml @@ -70,4 +70,23 @@ ) + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/CpcScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/CpcScoreDao.xml index 3a17dcc82b..c3483cbc32 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/CpcScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/CpcScoreDao.xml @@ -10,10 +10,6 @@ - - - - @@ -22,5 +18,119 @@ + + delete from fact_index_cpc_score where CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} and MONTH_ID = #{monthId,jdbcType=VARCHAR} and INDEX_CODE = #{indexCode,jdbcType=VARCHAR} + + + + + + + + + + + + + + + + + + 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 + + ( + (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() + ) + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/GridScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/GridScoreDao.xml index 4b1d7f6fcc..35a12160ce 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/GridScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/GridScoreDao.xml @@ -8,13 +8,13 @@ + - - - - + + + @@ -23,5 +23,93 @@ + + DELETE + FROM + fact_index_grid_score + WHERE + CUSTOMER_ID = #{customerId} + AND MONTH_ID = #{monthId} + AND INDEX_CODE = #{indexCode} + and IS_TOTAL=#{isTotal} + + + 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 + + ( + (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() + ) + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityGovrnFiveScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityGovrnFiveScoreDao.xml deleted file mode 100644 index 721b8181ef..0000000000 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityGovrnFiveScoreDao.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityPartyFiveScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityPartyFiveScoreDao.xml deleted file mode 100644 index 7110ba2c04..0000000000 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityPartyFiveScoreDao.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - 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 - - ( - REPLACE ( UUID(), '-', '' ), - #{item.agencyId}, - #{item.monthId}, - #{item.indexId}, - #{item.totalScore}, - #{item.partyAbilityScore}, - #{item.delFlag}, - #{item.revision}, - #{item.createdBy}, - NOW(), - #{item.updatedBy}, - NOW() - ) - - - \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityScoreDao.xml index 54611e0f02..91bebf545b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityScoreDao.xml @@ -3,4 +3,60 @@ + + + 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 + + ( + 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() + ) + + + + + + DELETE + FROM + fact_index_community_score + WHERE + del_flag = '0' + AND customer_id = #{customerId} + AND month_id = #{monthId} + AND index_code = #{indexCode} + + + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityServiceFiveScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityServiceFiveScoreDao.xml deleted file mode 100644 index 509f723548..0000000000 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityServiceFiveScoreDao.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexGridScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexGridScoreDao.xml index 7e4ad04732..b38cf57c0a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexGridScoreDao.xml +++ b/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 + + + + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailDao.xml index bb4e5636ae..89eb47208f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailDao.xml @@ -6,7 +6,7 @@ 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},'%') \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml index a5bee6054f..a00e0e750a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml +++ b/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} + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/DemoScoreCal.java b/epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/DemoScoreCal.java index c080ffc296..6da70db9c8 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/DemoScoreCal.java +++ b/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> index2SampleValues = Arrays.asList(new SampleValue<>("id1", 1), new SampleValue<>("id2", 8), new SampleValue<>("id3", 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(10), new BigDecimal(1), sc1); + IndexInputVO index2VO = new IndexInputVO<>("bbb", index2SampleValues, new BigDecimal(10), new BigDecimal(1), sc2); List indexInputVOS = Arrays.asList(index1VO, index2VO); @@ -104,8 +104,8 @@ public class DemoScoreCal { List 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 indexInputVOS = Arrays.asList(index1VO, index2VO); @@ -130,8 +130,8 @@ public class DemoScoreCal { List 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 indexInputVOS = Arrays.asList(index1VO, index2VO);