From 8ebe8b6b731bf7393f10f26ee8512432d3b0b40b Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Mon, 31 Aug 2020 10:08:53 +0800 Subject: [PATCH 01/14] =?UTF-8?q?=E7=94=9F=E6=88=90fact=5Findex=5Fcpc=5Fsc?= =?UTF-8?q?ore=E3=80=81fact=5Findex=5Fgrid=5Fscore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/dao/indexscore/CpcScoreDao.java | 33 +++++++ .../epmet/dao/indexscore/GridScoreDao.java | 33 +++++++ .../entity/indexscore/CpcScoreEntity.java | 87 ++++++++++++++++++ .../entity/indexscore/GridScoreEntity.java | 92 +++++++++++++++++++ .../impl/GridCorreLationServiceImpl.java | 47 +++++++--- .../mapper/indexscore/CpcScoreDao.xml | 26 ++++++ .../mapper/indexscore/GridScoreDao.xml | 27 ++++++ 7 files changed, 333 insertions(+), 12 deletions(-) create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexscore/CpcScoreDao.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexscore/GridScoreDao.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/indexscore/CpcScoreEntity.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/indexscore/GridScoreEntity.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/CpcScoreDao.xml create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/GridScoreDao.xml 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 new file mode 100644 index 0000000000..74628e78e8 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexscore/CpcScoreDao.java @@ -0,0 +1,33 @@ +/** + * 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.indexscore; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.indexscore.CpcScoreEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 党员相关分值 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-08-31 + */ +@Mapper +public interface CpcScoreDao extends BaseDao { + +} \ 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 new file mode 100644 index 0000000000..77de72959f --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexscore/GridScoreDao.java @@ -0,0 +1,33 @@ +/** + * 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.indexscore; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.indexscore.GridScoreEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 网格相关分值 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-08-31 + */ +@Mapper +public interface GridScoreDao extends BaseDao { + +} \ No newline at end of file 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 new file mode 100644 index 0000000000..59c4269a3b --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/indexscore/CpcScoreEntity.java @@ -0,0 +1,87 @@ +/** + * 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.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; + +/** + * 党员相关分值 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-08-31 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("fact_index_cpc_score") +public class CpcScoreEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户Id + */ + private String customerId; + + /** + * 网格所属的机关Id + */ + private String agencyId; + + /** + * 网格Id + */ + private String gridId; + + /** + * 用户id + */ + private String userId; + + /** + * 月维度Id: yyyyMM + */ + private String monthId; + + /** + * 党建能力分值 + */ + private BigDecimal partyAblityScore; + + /** + * 参与议事分值 + */ + private BigDecimal joinIssueScore; + + /** + * 党务活动分值 + */ + private BigDecimal partyWorkActScore; + + /** + * 联系群众分值 + */ + private BigDecimal contactMassesScore; + +} 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 new file mode 100644 index 0000000000..3b4b4c44c9 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/indexscore/GridScoreEntity.java @@ -0,0 +1,92 @@ +/** + * 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.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; + +/** + * 网格相关分值 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-08-31 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("fact_index_grid_score") +public class GridScoreEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户Id + */ + private String customerId; + + /** + * 网格Id + */ + private String gridId; + + /** + * 网格所属的机关Id + */ + private String agencyId; + + /** + * 季度ID + */ + private String quarterId; + + /** + * 年度ID + */ + private String yearId; + + /** + * 月维度Id: yyyyMM + */ + private String monthId; + + /** + * 总指数分值 + */ + private BigDecimal totalScore; + + /** + * 党建能力分值 + */ + private BigDecimal partyAblityScore; + + /** + * 治理能力分值 + */ + private BigDecimal govrnAblityScore; + + /** + * 服务能力分值 + */ + private BigDecimal serviceAblityScore; + +} 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 8b052d2638..d06d57ee21 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 @@ -136,12 +136,13 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { SampleValue currentGridIndexValue = new SampleValue((String) recordMap.get(IndexCalConstant.GRID_ID), new BigDecimal(sampleValueStr)); value.getIndexValueVOs().add(currentGridIndexValue); } else if (IndexCodeEnum.ZUZHINEIDANGYDLXQZNLKPFPJZ.getCode().equals(key)) { - //组织内党员的联系群众能力考评分(平均值) TODO - logger.info("组织内党员的联系群众能力考评分(平均值) TODO"); + //组织内党员的联系群众能力考评分(平均值) + logger.info("组织内党员的联系群众能力考评分(平均值) 单独处理"); //网格内党员的联系群众能力考评分(平均值) - /* BigDecimal contactResiAblity = null; - SampleValue contactResiAblityValue = new SampleValue((String) recordMap.get(IndexCalConstant.GRID_ID), contactResiAblity); - value.getIndexValueVOs().add(contactResiAblityValue);*/ + String gridId=(String) recordMap.get(IndexCalConstant.GRID_ID); + BigDecimal contactMassesAvgValue = getGridContactMassesAvgValue(gridId); + SampleValue contactMassesAblityValue = new SampleValue((String) recordMap.get(IndexCalConstant.GRID_ID), contactMassesAvgValue); + value.getIndexValueVOs().add(contactMassesAblityValue); } }); }); @@ -162,6 +163,29 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { } } + /** + * @return java.util.Map + * @param formDTO + * @author yinzuomei + * @description TODO + * @Date 2020/8/31 9:51 + **/ + private Map contactMassesAblityMap(CalculateCommonFormDTO formDTO) { + + return null; + } + + /** + * @return java.math.BigDecimal + * @param gridId 网格id + * @author yinzuomei TODO + * @description 获取网格(组织)内党员的联系群众能力考评分(平均值) + * @Date 2020/8/31 9:50 + **/ + private BigDecimal getGridContactMassesAvgValue(String gridId) { + return null; + } + /** * @param formDTO 客户id 月份id: yyyyMM * @param indexList 指标集合 @@ -230,12 +254,11 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { BigDecimal minValue = null; BigDecimal maxValue = null; if (IndexCodeEnum.ZUZHINEIDANGYDLXQZNLKPFPJZ.getCode().equals(index.getIndexCode())) { - //组织内党员的联系群众能力考评分(平均值) TODO 获取最大值,最小值 - logger.info("组织内党员的联系群众能力考评分(平均值) TODO"); - /*Map contactResiAblityMap=; - minValue=contactResiAblityMap.get(StrConstant.MIN); - maxValue=contactResiAblityMap.get(StrConstant.MAX);*/ - continue; + //组织内党员的联系群众能力考评分(平均值) 获取最大值,最小值 + logger.info("组织内党员的联系群众能力考评分(平均值) 单独处理"); + Map contactMassesAblityMap= this.contactMassesAblityMap(formDTO); + minValue=contactMassesAblityMap.get(StrConstant.MIN); + maxValue=contactMassesAblityMap.get(StrConstant.MAX); } else { //获取指标对应的列名 String fieldName = indexCodeFieldReService.getFieldNameByIndexCode(index.getIndexCode()); @@ -267,7 +290,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { /** * @param formDTO * @param indexList - * @return void + * @return void TODO * @author yinzuomei * @description 计算网格相关-治理能力 * @Date 2020/8/26 16:47 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 new file mode 100644 index 0000000000..3a17dcc82b --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/CpcScoreDao.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 new file mode 100644 index 0000000000..4b1d7f6fcc --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/GridScoreDao.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 2c354ad1af543b451b6985856672618a97d2de5e Mon Sep 17 00:00:00 2001 From: wangchao Date: Mon, 31 Aug 2020 10:28:52 +0800 Subject: [PATCH 02/14] =?UTF-8?q?=E6=94=AF=E9=83=A8=E5=BB=BA=E8=AE=BE?= =?UTF-8?q?=E6=83=85=E5=86=B5|=E8=81=94=E5=BB=BA=E5=85=B1=E5=BB=BA?= =?UTF-8?q?=E6=83=85=E5=86=B5-=E6=8A=98=E7=BA=BF=E5=9B=BE=20=E5=85=9A?= =?UTF-8?q?=E5=91=98=E5=BF=97=E6=84=BF=E6=9C=8D=E5=8A=A1=20=E4=B8=A4?= =?UTF-8?q?=E4=B8=AA=E6=8E=A5=E5=8F=A3=E8=BF=94=E5=8F=82=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E4=B8=A4=E4=B8=AA=E5=B1=9E=E6=80=A7=EF=BC=8C=E6=80=BB=E5=8F=82?= =?UTF-8?q?=E4=B8=8E=E6=95=B0=E5=92=8C=E6=80=BB=E7=BB=84=E7=BB=87=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/result/BranchBuildTrendResultDTO.java | 11 +++++++++++ .../dto/result/VolunteerServiceResultDTO.java | 10 ++++++++++ .../dao/screen/ScreenPartyBranchDataDao.java | 12 ++++++++++++ .../impl/GrassrootsPartyDevServiceImpl.java | 7 ++++++- .../screen/impl/PartyMemberLeadServiceImpl.java | 7 +++++++ .../epmet/datareport/utils/ModuleConstant.java | 10 ++++++++++ .../mapper/screen/ScreenPartyBranchDataDao.xml | 16 +++++++++++++++- 7 files changed, 71 insertions(+), 2 deletions(-) diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/BranchBuildTrendResultDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/BranchBuildTrendResultDTO.java index 58a277322f..ee30981a68 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/BranchBuildTrendResultDTO.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/BranchBuildTrendResultDTO.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 BranchBuildTrendResultDTO implements Serializable { private List seriesData; + /** + * 总组织次数 + * */ + private Integer totalOrganizationCount = NumConstant.ZERO; + + /** + * 总参与人数 + * */ + private Integer totalJoinUserCount = NumConstant.ZERO; + } diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/VolunteerServiceResultDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/VolunteerServiceResultDTO.java index 18331f9ca7..d856e5081c 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/VolunteerServiceResultDTO.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/VolunteerServiceResultDTO.java @@ -33,4 +33,14 @@ public class VolunteerServiceResultDTO implements Serializable { * 平均参与人次 */ private List averageJoinUserData; + + /** + * 总组织次数 + * */ + private Integer totalOrganizationCount; + + /** + * 总参与人数 + * */ + private Integer totalJoinUserCount; } diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/screen/ScreenPartyBranchDataDao.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/screen/ScreenPartyBranchDataDao.java index 0117eec4a7..f28a23354b 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/screen/ScreenPartyBranchDataDao.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/screen/ScreenPartyBranchDataDao.java @@ -68,4 +68,16 @@ public interface ScreenPartyBranchDataDao { * @date 2020.08.20 09:46 **/ List selectBranchDataByTypeOrder(@Param("agencyId")String agencyId,@Param("category")String category,@Param("monthId")String monthId,@Param("bottomMonthId")String bottomMonthId); + + /** + * @Description 查询组织总数或者总参与人数 + * @param category + * @param type + * @param agencyId + * @param monthId + * @return + * @author wangc + * @date 2020.08.28 17:56 + **/ + Integer selectTotalOrganizationCount(@Param("category") String category,@Param("type") String type, @Param("agencyId") String agencyId,@Param("monthId") String monthId); } \ No newline at end of file diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/screen/impl/GrassrootsPartyDevServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/screen/impl/GrassrootsPartyDevServiceImpl.java index aa1b23a448..4fa8a23c20 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/screen/impl/GrassrootsPartyDevServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/screen/impl/GrassrootsPartyDevServiceImpl.java @@ -155,7 +155,12 @@ public class GrassrootsPartyDevServiceImpl implements GrassrootsPartyDevService result.setSeriesData(dataArray); result.setLegend(null == result.getLegend() ? new ArrayList<>() : result.getLegend()); - + //总组织次数 + Integer totalOrganizationCount = screenPartyBranchDataDao.selectTotalOrganizationCount(param.getCategory(),ModuleConstant.PARAM_BRANCH_DATA_TYPE_ORGAN,param.getAgencyId(),monthMap.keySet().iterator().next()); + //总参与人数 + Integer totalJoinUserCount = screenPartyBranchDataDao.selectTotalOrganizationCount(param.getCategory(),ModuleConstant.PARAM_BRANCH_DATA_TYPE_JOIN,param.getAgencyId(),monthMap.keySet().iterator().next()); + result.setTotalOrganizationCount(null == totalOrganizationCount ? NumConstant.ZERO : totalOrganizationCount); + result.setTotalJoinUserCount(null == totalJoinUserCount ? NumConstant.ZERO : totalJoinUserCount); return result; } 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 a1031a9494..8af422652a 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 @@ -147,6 +147,13 @@ public class PartyMemberLeadServiceImpl implements PartyMemberLeadService { result.setOrganizeData(organizeData); result.setJoinData(joinData); result.setAverageJoinUserData(averageJoinUserData); + String bottomMonthId = collect.get(collect.size() - NumConstant.ONE).getMonthId(); + //总组织次数 + Integer totalOrganizationCount = screenPartyBranchDataDao.selectTotalOrganizationCount(ModuleConstant.KEY_BRANCH_CATEGORY_VOLUNTARY_SERVICE,ModuleConstant.PARAM_BRANCH_DATA_TYPE_ORGAN,volunteerServiceFormDTO.getAgencyId(),bottomMonthId); + //总参与人数 + Integer totalJoinUserCount = screenPartyBranchDataDao.selectTotalOrganizationCount(ModuleConstant.KEY_BRANCH_CATEGORY_VOLUNTARY_SERVICE,ModuleConstant.PARAM_BRANCH_DATA_TYPE_JOIN,volunteerServiceFormDTO.getAgencyId(),bottomMonthId); + result.setTotalOrganizationCount(totalOrganizationCount); + result.setTotalJoinUserCount(totalJoinUserCount); return result; } diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/utils/ModuleConstant.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/utils/ModuleConstant.java index 9314d3ba3b..7e3af9f112 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/utils/ModuleConstant.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/utils/ModuleConstant.java @@ -21,4 +21,14 @@ public interface ModuleConstant { String PARAM_DIFFICULTY_TYPE_MOST_DEPTS = "mostdepts"; String PARAM_DIFFICULTY_TYPE_MOST_HANDLED = "mosthandled"; + + /** + * 支部建设情况折线图 查询数据类型 组织次数 + * */ + String PARAM_BRANCH_DATA_TYPE_ORGAN = "organize"; + + /** + * 支部建设情况折线图 查询数据类型 参与人数 + * */ + String PARAM_BRANCH_DATA_TYPE_JOIN = "joinuser"; } diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPartyBranchDataDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPartyBranchDataDao.xml index 165b383a81..013f43c74b 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPartyBranchDataDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPartyBranchDataDao.xml @@ -29,7 +29,6 @@ screen_party_branch_data WHERE DEL_FLAG = '0' - AND ORG_TYPE = 'agency' AND ORG_ID = #{agencyId} AND TYPE = #{category} AND MONTH_ID = ]]> #{bottomMonthId} @@ -85,4 +84,19 @@ LIMIT 12 + + \ No newline at end of file From 239520b4f5944e62ebe9bd9afff0a941cddd54af Mon Sep 17 00:00:00 2001 From: wangchao Date: Mon, 31 Aug 2020 10:29:30 +0800 Subject: [PATCH 03/14] =?UTF-8?q?=E5=8F=96=E6=9C=88=E4=BB=BD=E5=8C=BA?= =?UTF-8?q?=E9=97=B4=E7=9A=84=E5=B7=A6=E5=8C=BA=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/screen/impl/PartyMemberLeadServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 8af422652a..2cf28aca5a 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 @@ -147,7 +147,7 @@ public class PartyMemberLeadServiceImpl implements PartyMemberLeadService { result.setOrganizeData(organizeData); result.setJoinData(joinData); result.setAverageJoinUserData(averageJoinUserData); - String bottomMonthId = collect.get(collect.size() - NumConstant.ONE).getMonthId(); + String bottomMonthId = collect.get(NumConstant.ZERO).getMonthId(); //总组织次数 Integer totalOrganizationCount = screenPartyBranchDataDao.selectTotalOrganizationCount(ModuleConstant.KEY_BRANCH_CATEGORY_VOLUNTARY_SERVICE,ModuleConstant.PARAM_BRANCH_DATA_TYPE_ORGAN,volunteerServiceFormDTO.getAgencyId(),bottomMonthId); //总参与人数 From be6217395d0be4c1f25fae4a56c40d6aeeebf08d Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 31 Aug 2020 10:37:13 +0800 Subject: [PATCH 04/14] =?UTF-8?q?=E8=AE=A1=E7=AE=97=E5=85=9A=E5=91=98?= =?UTF-8?q?=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/constant/IndexCalConstant.java | 2 + .../FactIndexPartyAblityCpcMonthlyDao.java | 5 +- .../impl/CpcIndexCalculateServiceImpl.java | 166 +++++++++++++++--- .../impl/IndexCalculateServiceImpl.java | 2 +- .../FactIndexPartyAblityCpcMonthlyDao.xml | 74 +++----- 5 files changed, 174 insertions(+), 75 deletions(-) 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 0cfcdcc2a7..aff436ff3d 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 @@ -15,4 +15,6 @@ public interface IndexCalConstant { String CUSTOMER_ID="CUSTOMER_ID"; String MONTH_ID="MONTH_ID"; + + String USER_ID="USER_ID"; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexPartyAblityCpcMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexPartyAblityCpcMonthlyDao.java index f9c0ad1af2..cdecd48f51 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexPartyAblityCpcMonthlyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexPartyAblityCpcMonthlyDao.java @@ -23,7 +23,6 @@ import com.epmet.entity.indexcoll.FactIndexPartyAblityCpcMonthlyEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; -import java.math.BigDecimal; import java.util.List; import java.util.Map; @@ -70,7 +69,7 @@ public interface FactIndexPartyAblityCpcMonthlyDao extends BaseDao list, @Param("customerId") String customerId); - Map getCountByMonthId(@Param("customerId") String customerId, @Param("monthId") String monthId); + List> getCountByMonthId(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("offset") Integer offset, @Param("pageSize") Integer pageSize); - Map getExtremeValue(@Param("customerId") String customerId); + Map getExtremeValue(@Param("customerId") String customerId); } 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 0367e90137..c427a81eb9 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,6 +1,7 @@ package com.epmet.service.indexcal.impl; -import com.alibaba.fastjson.JSON; +import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.constant.IndexCalConstant; import com.epmet.dao.indexcoll.FactIndexPartyAblityCpcMonthlyDao; import com.epmet.dao.screen.IndexCodeFieldReDao; import com.epmet.dto.indexcal.CalculateCommonFormDTO; @@ -9,14 +10,24 @@ import com.epmet.eum.IndexCodeEnum; import com.epmet.service.indexcal.CpcIndexCalculateService; import com.epmet.service.indexcal.IndexCodeFieldReService; import com.epmet.service.screen.IndexGroupDetailService; +import com.epmet.support.normalizing.BigDecimalScoreCalculator; +import com.epmet.support.normalizing.Correlation; +import com.epmet.support.normalizing.ScoreCalculator; +import com.epmet.support.normalizing.ScoreConstants; +import com.epmet.support.normalizing.batch.*; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.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.stream.Collectors; @Slf4j @Service @@ -29,35 +40,144 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { private IndexGroupDetailService getDetailListByParentCode; @Autowired private IndexCodeFieldReService indexCodeFieldReService; + @Override public Boolean cpcIndexCalculate(CalculateCommonFormDTO formDTO) { - //计算最大最小值 - Map minAndMaxList = factIndexPartyAblityCpcMonthlyDao.getExtremeValue(formDTO.getCustomerId()); - if (CollectionUtils.isEmpty(minAndMaxList)){ - log.warn("cpcIndexCalculate customerId:{} have not any fact record",formDTO.getCustomerId()); - return false; - } - //获取指标权重信息 - List indexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(),IndexCodeEnum.CAN_YU_YI_SHI.getCode()); - if (CollectionUtils.isEmpty(indexDetails)){ - log.warn("cpcIndexCalculate customerId:{} have not any indexGroupDetail",formDTO.getCustomerId()); + + //获取指标权重信息 -参与议事 + List indexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(), IndexCodeEnum.CAN_YU_YI_SHI.getCode()); + if (CollectionUtils.isEmpty(indexDetails)) { + log.warn("cpcIndexCalculate customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); return false; } + + canyuyishi(formDTO, indexDetails); + + + //log.info(JSON.toJSONString(minAndMaxList)); + return null; + } + + private void canyuyishi(CalculateCommonFormDTO formDTO, List indexDetails) { Map indexCodeFieldReList = indexCodeFieldReService.getIndexCodeFieldReMap(); - if (CollectionUtils.isEmpty(indexCodeFieldReList)){ - log.warn("cpcIndexCalculate have any indexcodefieldre"); - return false; + if (CollectionUtils.isEmpty(indexCodeFieldReList)) { + log.error("cpcIndexCalculate have any indexcodefieldre"); + return; } - String indexCode = null; - String fieldName = null; - for (IndexGroupDetailEntity indexDetail : indexDetails) { - indexCode = indexDetail.getIndexCode(); - fieldName = indexCodeFieldReService.getFieldNameByIndexCode(indexCode); - + //计算最大最小值 + Map minAndMaxMap = factIndexPartyAblityCpcMonthlyDao.getExtremeValue(formDTO.getCustomerId()); + if (CollectionUtils.isEmpty(minAndMaxMap)) { + log.warn("cpcIndexCalculate getExtremeValue customerId:{} have not any fact record", formDTO.getCustomerId()); + return; } + //指标集合 + Map> indexMap = getIndexInputVO(indexDetails, minAndMaxMap); + List> list = null; + int pageNo = 1; + int pageSize = 10; + do { + String fieldName = null; + list = factIndexPartyAblityCpcMonthlyDao.getCountByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), (pageNo - 1) * pageSize, pageSize); + if (!CollectionUtils.isEmpty(list)) { + //遍历指标 进行计算 + for (Map.Entry> entry : indexMap.entrySet()) { + String indexCode = entry.getKey(); + IndexInputVO value = entry.getValue(); + fieldName = indexCodeFieldReService.getFieldNameByIndexCode(indexCode); + if (StringUtils.isBlank(fieldName)) { + log.error("cpcIndexCalculate fieldName error"); + continue; + } + for (Map cpcIndex : list) { + //对应的数值 + 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); + } - log.info(JSON.toJSONString(minAndMaxList)); - Map list = factIndexPartyAblityCpcMonthlyDao.getCountByMonthId(formDTO.getCustomerId(), formDTO.getMonthId()); - return null; + } + } + + List result = calculate(indexMap); + // TODO 处理结果 + saveGridCorreLationDangJian(formDTO, indexDetails, result); + + try { + for (IndexOutputVO m : result) { + log.info("indexId=" + m.getIndexId()); + for (SampleScore sampleScore : m.getIndexScoreVOs()) { + log.info(String.format("网格id:%s,得分:%s", sampleScore.getSampleId(), sampleScore.getSampleScore())); + } + } + } catch (Exception e) { + } + + } while (!CollectionUtils.isEmpty(list) && pageNo++ > 0); + + } + + @Transactional(rollbackFor = Exception.class) + public void saveGridCorreLationDangJian(CalculateCommonFormDTO formDTO, List indexDetails, List result) { + + } + + /** + * @param indexMap + * @return java.util.List + * @author yinzuomei + * @description + * @Date 2020/8/30 21:40 + **/ + private List calculate(Map> indexMap) { + //构造入参 + List indexInputVOS = indexMap.values().stream().collect(Collectors.toList()); + BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); + return batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS); + } + + /** + * @param indexList 指标集合 + * @param minAndMaxMap 最大值最小值集合 + * @return java.util.Map + * @author yinzuomei + * @description + * @Date 2020/8/30 15:56 + **/ + private Map> getIndexInputVO(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()); + BigDecimal minValue = null; + BigDecimal maxValue = null; + + //获取指标对应的列名 + String fieldName = indexCodeFieldReService.getFieldNameByIndexCode(index.getIndexCode()); + //最小值key + 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))); + + //分值计算器 + ScoreCalculator scoreCalculator = new BigDecimalScoreCalculator(minValue, + maxValue, + ScoreConstants.MIN_SCORE, + ScoreConstants.MAX_SCORE, + Correlation.getCorrelation(index.getCorrelation()) + ); + indexInputVO.setScoreCalculator(scoreCalculator); + List> sampleValueList = new ArrayList<>(); + indexInputVO.setIndexValueVOs(sampleValueList); + + map.put(index.getIndexCode(), indexInputVO); + } + return map; } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java index 4163ea074c..fa6c520c96 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java @@ -58,7 +58,7 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { CalculateCommonFormDTO calculateCommonFormDTO=new CalculateCommonFormDTO(customerId, formDTO.getMonthId()); //计算党员 try { - Map list = factIndexPartyAblityCpcMonthlyDao.getCountByMonthId(customerId, formDTO.getMonthId()); + Map list = factIndexPartyAblityCpcMonthlyDao.getCountByMonthId(customerId, formDTO.getMonthId(), (pageNo - 1) * pageSize, pageSize); } catch (Exception e) { } 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 41946192dd..beb5b42a4e 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 @@ -3,33 +3,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from fact_index_party_ablity_cpc_monthly where CUSTOMER_ID = #{customerId} AND AGENCY_ID = #{agencyId} AND GRID_ID = #{gridId} AND USER_ID = #{userId} @@ -94,27 +67,7 @@ - + + + + From 00324ad1c760545e702120b5cc170539fde9a423 Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 31 Aug 2020 13:33:56 +0800 Subject: [PATCH 05/14] =?UTF-8?q?=E9=94=99=E8=AF=AF=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/dao/screen/IndexGroupDetailDao.java | 2 + .../impl/CpcIndexCalculateServiceImpl.java | 79 ++++++++++--------- .../screen/IndexGroupDetailService.java | 8 ++ .../impl/IndexCalculateServiceImpl.java | 4 +- .../impl/IndexGroupDetailServiceImpl.java | 5 ++ .../mapper/screen/IndexGroupDetailDao.xml | 9 +++ 6 files changed, 66 insertions(+), 41 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDetailDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDetailDao.java index 8c7a4e82fb..8982bc5f29 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDetailDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDetailDao.java @@ -34,4 +34,6 @@ import java.util.List; public interface IndexGroupDetailDao extends BaseDao { List getDetailListByParentCode(@Param("customerId") String customerId, @Param("indexCode") String indexCode); + + List getDetailListLikeParentCode(@Param("customerId") String customerId, @Param("parentIndexCode") String parentIndexCode); } \ No newline at end of file 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 c427a81eb9..521c9dd631 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,5 +1,6 @@ package com.epmet.service.indexcal.impl; +import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.constant.IndexCalConstant; import com.epmet.dao.indexcoll.FactIndexPartyAblityCpcMonthlyDao; @@ -14,7 +15,9 @@ import com.epmet.support.normalizing.BigDecimalScoreCalculator; import com.epmet.support.normalizing.Correlation; import com.epmet.support.normalizing.ScoreCalculator; import com.epmet.support.normalizing.ScoreConstants; -import com.epmet.support.normalizing.batch.*; +import com.epmet.support.normalizing.batch.BatchScoreCalculator; +import com.epmet.support.normalizing.batch.IndexInputVO; +import com.epmet.support.normalizing.batch.SampleValue; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -45,7 +48,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { public Boolean cpcIndexCalculate(CalculateCommonFormDTO formDTO) { //获取指标权重信息 -参与议事 - List indexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(), IndexCodeEnum.CAN_YU_YI_SHI.getCode()); + List indexDetails = getDetailListByParentCode.getDetailListLikeParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode()); if (CollectionUtils.isEmpty(indexDetails)) { log.warn("cpcIndexCalculate customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); return false; @@ -53,7 +56,6 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { canyuyishi(formDTO, indexDetails); - //log.info(JSON.toJSONString(minAndMaxList)); return null; } @@ -71,54 +73,55 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { return; } //指标集合 - Map> indexMap = getIndexInputVO(indexDetails, minAndMaxMap); + //对指标进行分组 + Map> groupIndexDetailsMap = indexDetails.stream().collect(Collectors.groupingBy(IndexGroupDetailEntity::getAllParentIndexCode)); + + + List> list = null; int pageNo = 1; int pageSize = 10; do { - String fieldName = null; list = factIndexPartyAblityCpcMonthlyDao.getCountByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), (pageNo - 1) * pageSize, pageSize); if (!CollectionUtils.isEmpty(list)) { - //遍历指标 进行计算 - for (Map.Entry> entry : indexMap.entrySet()) { - String indexCode = entry.getKey(); - IndexInputVO value = entry.getValue(); - fieldName = indexCodeFieldReService.getFieldNameByIndexCode(indexCode); - if (StringUtils.isBlank(fieldName)) { - log.error("cpcIndexCalculate fieldName error"); - continue; - } - for (Map cpcIndex : list) { - //对应的数值 - 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); - } - - } - } - List result = calculate(indexMap); - // TODO 处理结果 - saveGridCorreLationDangJian(formDTO, indexDetails, result); + //遍历指标分组 计算分数 + 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 { - for (IndexOutputVO m : result) { - log.info("indexId=" + m.getIndexId()); - for (SampleScore sampleScore : m.getIndexScoreVOs()) { - log.info(String.format("网格id:%s,得分:%s", sampleScore.getSampleId(), sampleScore.getSampleScore())); + try { + System.out.println( JSON.toJSONString(result)); + } catch (Exception e) { } - } - } catch (Exception e) { + }); } - } while (!CollectionUtils.isEmpty(list) && pageNo++ > 0); } @Transactional(rollbackFor = Exception.class) - public void saveGridCorreLationDangJian(CalculateCommonFormDTO formDTO, List indexDetails, List result) { + public void saveGridCorreLationDangJian(CalculateCommonFormDTO formDTO, List indexDetails, HashMap result) { } @@ -129,11 +132,11 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { * @description * @Date 2020/8/30 21:40 **/ - private List calculate(Map> indexMap) { + private HashMap calculate(Map> indexMap) { //构造入参 List indexInputVOS = indexMap.values().stream().collect(Collectors.toList()); BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); - return batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS); + return batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); } /** diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexGroupDetailService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexGroupDetailService.java index aa69cba8e7..888b36725d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexGroupDetailService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexGroupDetailService.java @@ -35,4 +35,12 @@ public interface IndexGroupDetailService extends BaseService getDetailListByParentCode(String customerId,String... indexCode); + + /** + * desc:获取所有 包含该指标code的 + * @param customerId + * @param parentIndexCode + * @return + */ + List getDetailListLikeParentCode(String customerId, String parentIndexCode); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java index fa6c520c96..611ad18f4e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java @@ -17,10 +17,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; -import java.math.BigDecimal; import java.util.Date; import java.util.List; -import java.util.Map; /** * @author liujianjun @@ -58,7 +56,7 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { CalculateCommonFormDTO calculateCommonFormDTO=new CalculateCommonFormDTO(customerId, formDTO.getMonthId()); //计算党员 try { - Map list = factIndexPartyAblityCpcMonthlyDao.getCountByMonthId(customerId, formDTO.getMonthId(), (pageNo - 1) * pageSize, pageSize); + //Map list = factIndexPartyAblityCpcMonthlyDao.getCountByMonthId(customerId, formDTO.getMonthId(), (pageNo - 1) * pageSize, pageSize); } catch (Exception e) { } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexGroupDetailServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexGroupDetailServiceImpl.java index 0225c956c5..1135b023c8 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexGroupDetailServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexGroupDetailServiceImpl.java @@ -48,4 +48,9 @@ public class IndexGroupDetailServiceImpl extends BaseServiceImpl getDetailListLikeParentCode(String customerId, String parentIndexCode) { + return baseDao.getDetailListLikeParentCode(customerId,parentIndexCode); + } } \ 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 6038ecbfeb..bb4e5636ae 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 @@ -12,4 +12,13 @@ CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} and STATUS = 'enable' and DEL_FLAG = '0' and ALL_PARENT_INDEX_CODE = #{indexCode,jdbcType=VARCHAR} + + \ No newline at end of file From ac1b8df349d28010118e2f88f607f18cea84f258 Mon Sep 17 00:00:00 2001 From: wangchao Date: Mon, 31 Aug 2020 15:38:51 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=85=9A=E5=91=98?= =?UTF-8?q?=E5=BF=97=E6=84=BF=E8=80=85=E6=9C=8D=E5=8A=A1=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/PartyMemberLeadServiceImpl.java | 27 ++++++++++++++++++- .../screen/ScreenPartyBranchDataDao.xml | 8 +++--- 2 files changed, 31 insertions(+), 4 deletions(-) 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 2cf28aca5a..1ed8a24261 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 @@ -19,6 +19,7 @@ import com.epmet.screen.dto.form.VolunteerServiceFormDTO; import com.epmet.screen.dto.result.*; import com.epmet.screen.constant.*; import com.github.pagehelper.PageHelper; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -126,6 +127,13 @@ public class PartyMemberLeadServiceImpl implements PartyMemberLeadService { List joinData = new ArrayList<>(); List averageJoinUserData = new ArrayList<>(); result.setXAxis(this.getXPro()); + //创建缺省值对象 + VolunteerServiceResult defaultObj = new VolunteerServiceResult(); + defaultObj.setAverageJoinUserData(NumConstant.ZERO); + defaultObj.setJoinData(NumConstant.ZERO); + defaultObj.setOrganizeData(NumConstant.ZERO); + + //倒叙取十二个月的数据,从本月开始,有可能取不到十二条,要对X轴空白的缺口进行填补 List volunteerServiceResults = screenPartyBranchDataDao.selectVolunteerServiceResult(volunteerServiceFormDTO.getAgencyId()); if (volunteerServiceResults.size() == NumConstant.ZERO){ for (int i = NumConstant.ZERO; i <= NumConstant.TWELVE; i++) { @@ -138,16 +146,33 @@ public class PartyMemberLeadServiceImpl implements PartyMemberLeadService { result.setAverageJoinUserData(averageJoinUserData); return result; } + + Set yyyyMMList = dateUtils.getXpro().keySet(); + yyyyMMList.forEach(mm -> { + Optional opt = volunteerServiceResults.stream() + .filter(obj -> StringUtils.equals(mm,obj.getMonthId())).findAny(); + VolunteerServiceResult find = opt.isPresent() ? opt.get() : defaultObj; + //VolunteerServiceResult find = Optional.ofNullable(opt.isPresent() ? opt.get() : null).orElse(defaultObj); + organizeData.add(find.getOrganizeData()); + joinData.add(find.getJoinData()); + averageJoinUserData.add(find.getAverageJoinUserData()); + }); + + + /* List collect = volunteerServiceResults.stream().sorted(Comparator.comparing(VolunteerServiceResult::getMonthId)).collect(Collectors.toList()); collect.forEach(volunteer -> { organizeData.add(volunteer.getOrganizeData()); joinData.add(volunteer.getJoinData()); averageJoinUserData.add(volunteer.getAverageJoinUserData()); }); + */ + + result.setOrganizeData(organizeData); result.setJoinData(joinData); result.setAverageJoinUserData(averageJoinUserData); - String bottomMonthId = collect.get(NumConstant.ZERO).getMonthId(); + String bottomMonthId = yyyyMMList.iterator().next(); //总组织次数 Integer totalOrganizationCount = screenPartyBranchDataDao.selectTotalOrganizationCount(ModuleConstant.KEY_BRANCH_CATEGORY_VOLUNTARY_SERVICE,ModuleConstant.PARAM_BRANCH_DATA_TYPE_ORGAN,volunteerServiceFormDTO.getAgencyId(),bottomMonthId); //总参与人数 diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPartyBranchDataDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPartyBranchDataDao.xml index 013f43c74b..2b20c44880 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPartyBranchDataDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPartyBranchDataDao.xml @@ -72,14 +72,16 @@ From 28f20e7c1c6cc5c1c1dbe3cc9d969df20caf0da4 Mon Sep 17 00:00:00 2001 From: wangchao Date: Mon, 31 Aug 2020 15:55:38 +0800 Subject: [PATCH 07/14] =?UTF-8?q?=E5=85=9A=E5=91=98=E5=BF=97=E6=84=BF?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=20=E6=8E=A5=E5=8F=A3=20=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E8=AE=BE=E7=BD=AE=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/screen/impl/PartyMemberLeadServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 1ed8a24261..902861f5e2 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 @@ -177,8 +177,8 @@ public class PartyMemberLeadServiceImpl implements PartyMemberLeadService { Integer totalOrganizationCount = screenPartyBranchDataDao.selectTotalOrganizationCount(ModuleConstant.KEY_BRANCH_CATEGORY_VOLUNTARY_SERVICE,ModuleConstant.PARAM_BRANCH_DATA_TYPE_ORGAN,volunteerServiceFormDTO.getAgencyId(),bottomMonthId); //总参与人数 Integer totalJoinUserCount = screenPartyBranchDataDao.selectTotalOrganizationCount(ModuleConstant.KEY_BRANCH_CATEGORY_VOLUNTARY_SERVICE,ModuleConstant.PARAM_BRANCH_DATA_TYPE_JOIN,volunteerServiceFormDTO.getAgencyId(),bottomMonthId); - result.setTotalOrganizationCount(totalOrganizationCount); - result.setTotalJoinUserCount(totalJoinUserCount); + result.setTotalOrganizationCount(null == totalOrganizationCount ? NumConstant.ZERO : totalOrganizationCount); + result.setTotalJoinUserCount(null == totalJoinUserCount ? NumConstant.ZERO : totalJoinUserCount); return result; } From a89a053552bc4494656cf32ae0d717c86b597d9f Mon Sep 17 00:00:00 2001 From: wangchao Date: Mon, 31 Aug 2020 16:11:37 +0800 Subject: [PATCH 08/14] =?UTF-8?q?=E5=85=9A=E5=91=98=E5=BF=97=E6=84=BF?= =?UTF-8?q?=E8=80=85=E6=9C=8D=E5=8A=A1=E8=BF=94=E5=8F=82DTO=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/screen/dto/result/VolunteerServiceResultDTO.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/VolunteerServiceResultDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/VolunteerServiceResultDTO.java index d856e5081c..e255f61124 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/VolunteerServiceResultDTO.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/VolunteerServiceResultDTO.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; @@ -37,10 +38,10 @@ public class VolunteerServiceResultDTO implements Serializable { /** * 总组织次数 * */ - private Integer totalOrganizationCount; + private Integer totalOrganizationCount = NumConstant.ZERO; /** * 总参与人数 * */ - private Integer totalJoinUserCount; + private Integer totalJoinUserCount = NumConstant.ZERO; } From 4d7a82b68038d5078d4d8ef2b62cdf1870f46a6e Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Mon, 31 Aug 2020 16:47:26 +0800 Subject: [PATCH 09/14] =?UTF-8?q?=E7=BD=91=E6=A0=BC=E7=9B=B8=E5=85=B3-?= =?UTF-8?q?=E6=9A=82=E5=AD=98V2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/dto/indexcal/GridScoreDTO.java | 52 ++++ .../dto/indexcal/GridScoreDetailDTO.java | 30 ++ .../FactIndexGovrnAblityGridMonthlyDao.java | 10 + .../com/epmet/dao/indexscore/CpcScoreDao.java | 48 ++- .../epmet/dao/indexscore/GridScoreDao.java | 38 ++- .../dao/screen/ScreenCustomerGridDao.java | 10 + .../entity/indexscore/GridScoreEntity.java | 74 ++--- .../java/com/epmet/eum/IndexCodeEnum.java | 1 + .../impl/GridCorreLationServiceImpl.java | 292 ++++++++++++++---- .../FactIndexGovrnAblityGridMonthlyDao.xml | 11 + .../mapper/indexscore/CpcScoreDao.xml | 61 ++++ .../mapper/indexscore/GridScoreDao.xml | 65 +++- .../mapper/screen/ScreenCustomerGridDao.xml | 13 + 13 files changed, 606 insertions(+), 99 deletions(-) create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/GridScoreDTO.java create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/GridScoreDetailDTO.java 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-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/indexscore/CpcScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexscore/CpcScoreDao.java index 74628e78e8..f93338307f 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,13 @@ 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.List; /** * 党员相关分值 @@ -29,5 +34,46 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface CpcScoreDao extends BaseDao { - + + /** + * @return java.math.BigDecimal + * @param customerId + * @param monthId + * @param gridId + * @author yinzuomei + * @description 获取网格内党员的联系群众能力考评分(平均值) + * @Date 2020/8/31 10:56 + **/ + BigDecimal selectGridContactMassesAvgValue(@Param("customerId") String customerId, + @Param("monthId") String monthId, + @Param("gridId") String gridId); + + /** + * @return java.util.List + * @param formDTO + * @author yinzuomei + * @description 获取网格内党员的联系群众能力考评分(平均值)的最大值,最小值 + * @Date 2020/8/31 12:10 + **/ + List selectListGridContactMassesAvgValue(CalculateCommonFormDTO formDTO); + + /** + * @return java.util.List + * @param calculateCommonFormDTO + * @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); } \ 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..30196d21f9 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 + * @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/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/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/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/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..0700e33f7b 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,20 @@ 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.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.GridScoreDTO; import com.epmet.dto.indexcal.PageQueryGridFormDTO; +import com.epmet.entity.indexscore.GridScoreEntity; import com.epmet.entity.screen.IndexGroupDetailEntity; import com.epmet.eum.IndexCodeEnum; import com.epmet.service.indexcal.GridCorreLationService; @@ -23,12 +28,11 @@ 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; import java.util.*; -import java.util.function.Function; -import java.util.stream.Collectors; /** * 网格相关service @@ -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 @@ -67,28 +76,28 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); if (!CollectionUtils.isEmpty(dangJianNengLiList)) { //1、计算网格相关-党建能力 - calculateGridCorreLationDangJian(formDTO, dangJianNengLiList); + calculateGridDangJian(formDTO, dangJianNengLiList); } - /* List zhiLiNengLiList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(), + 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); + calculateGridZhiLi(formDTO, zhiLiNengLiList); } 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); + calculateGridFuWu(formDTO, fuWuNengLiList); } //计算网格相关总分 List wgxgList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode()); if (!CollectionUtils.isEmpty(wgxgList)) { - calculateGridCorreLationTotal(formDTO, wgxgList); - }*/ + calculateGridTotal(formDTO, wgxgList); + } resultFlag = true; return resultFlag; } @@ -101,7 +110,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) { @@ -115,6 +125,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { Map minAndMaxMap = queryPartyAblityGridMinAndMax(formDTO.getCustomerId(), formDTO.getMonthId()); //指标集合 Map> indexMap = getIndexInputVO(formDTO, indexList, minAndMaxMap); + List> resultMapList=new ArrayList<>(); //分页查询采集记录 for (int pageNo = 1; pageNo <= totalPage; pageNo++) { int pageIndex = (pageNo - NumConstant.ONE) * IndexCalConstant.PAGE_SIZE; @@ -140,67 +151,136 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { logger.info("组织内党员的联系群众能力考评分(平均值) 单独处理"); //网格内党员的联系群众能力考评分(平均值) String gridId=(String) recordMap.get(IndexCalConstant.GRID_ID); - BigDecimal contactMassesAvgValue = getGridContactMassesAvgValue(gridId); + 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); } + // 保存中间表 + saveGridCorreLationDangJian(formDTO, resultMapList,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),NumConstant.ZERO_STR); } /** * @return java.util.Map - * @param formDTO + * @param calculateCommonFormDTO * @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; } /** * @return java.math.BigDecimal + * @param calculateCommonFormDTO * @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 java.math.BigDecimal + * @param formDTO + * @param gridId + * @author yinzuomei + * @description 组织内党员的参与议事能力考评分(平均值) + * @Date 2020/8/31 15:51 + **/ + 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; + } + + /** + * @return java.util.Map + * @param calculateCommonFormDTO + * @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 指标编码 + * @param isTotal 1:总分;0不是 * @return void * @author yinzuomei - * @description 保存网格相关五级指标分值 + * @description 保存网格相关三大能力值 * @Date 2020/8/30 22:50 **/ private void saveGridCorreLationDangJian(CalculateCommonFormDTO formDTO, - List indexList, - List indexOutputVOList) { - Map indexMap = indexList.stream().collect(Collectors.toMap(IndexGroupDetailEntity::getIndexCode, Function.identity())); - - + 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); + } } /** @@ -210,11 +290,11 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { * @description * @Date 2020/8/30 21:40 **/ - private List calculate(Map> indexMap) { + private HashMap calculate(Map> indexMap) { //构造入参 List indexInputVOS = this.getIndexInputVOList(indexMap); BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); - return batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS); + return batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); } /** @@ -256,23 +336,29 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { if (IndexCodeEnum.ZUZHINEIDANGYDLXQZNLKPFPJZ.getCode().equals(index.getIndexCode())) { //组织内党员的联系群众能力考评分(平均值) 获取最大值,最小值 logger.info("组织内党员的联系群众能力考评分(平均值) 单独处理"); - Map contactMassesAblityMap= this.contactMassesAblityMap(formDTO); + 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, @@ -290,15 +376,63 @@ 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()); + //指标集合 + Map> indexMap = getIndexInputVO(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); + } + // 保存中间表 + saveGridCorreLationDangJian(formDTO, resultMapList,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),NumConstant.ZERO_STR); } + /** * @param formDTO * @param indexList @@ -307,8 +441,51 @@ 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()); + //指标集合 + Map> indexMap = getIndexInputVO(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); + } + // 保存中间表 + saveGridCorreLationDangJian(formDTO, resultMapList,IndexCodeEnum.FU_WU_NENG_LI.getCode(),NumConstant.ZERO_STR); } /** @@ -319,8 +496,11 @@ 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) { + //查询总记录数 + List gridScoreDTOList=gridScoreDao.selectList(formDTO); + // 保存中间表 TODO +// saveGridCorreLationDangJian(formDTO, resultMapList,IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode(),NumConstant.ONE_STR); } 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/indexscore/CpcScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/CpcScoreDao.xml index 3a17dcc82b..f4866aaffd 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 @@ -23,4 +23,65 @@ + + + + + + + + + + + \ 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..6f739c3e36 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,62 @@ + + 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/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} + + + From 13a5e793404576377d5b4e9342dee779cbbd42ce Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Mon, 31 Aug 2020 16:49:07 +0800 Subject: [PATCH 10/14] =?UTF-8?q?=E6=BC=8F=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/commons/tools/utils/DateUtils.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) 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; + } } From 180053a363fb787ed2af83ee55e028ec8afc6244 Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 31 Aug 2020 17:11:27 +0800 Subject: [PATCH 11/14] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/constant/IndexCalConstant.java | 2 + .../data-statistical-server/pom.xml | 2 +- .../controller/IndexCalculateController.java | 2 +- .../com/epmet/dao/indexscore/CpcScoreDao.java | 5 + .../entity/indexscore/CpcScoreEntity.java | 35 ++-- .../impl/CpcIndexCalculateServiceImpl.java | 158 +++++++++++++----- .../java/com/epmet/util/Pinyin4jUtil.java | 3 + .../mapper/indexscore/CpcScoreDao.xml | 15 +- .../mapper/screen/IndexGroupDetailDao.xml | 6 +- 9 files changed, 155 insertions(+), 73 deletions(-) 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..79321c6026 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,6 +12,8 @@ public interface IndexCalConstant { String GRID_ID="GRID_ID"; + String AGENCY_ID="AGENCY_ID"; + String CUSTOMER_ID="CUSTOMER_ID"; String MONTH_ID="MONTH_ID"; diff --git a/epmet-module/data-statistical/data-statistical-server/pom.xml b/epmet-module/data-statistical/data-statistical-server/pom.xml index 8d0e953c05..a805e4a53c 100644 --- a/epmet-module/data-statistical/data-statistical-server/pom.xml +++ b/epmet-module/data-statistical/data-statistical-server/pom.xml @@ -195,7 +195,7 @@ 6379 123456 - true + false 192.168.1.130:8848 6ceab336-d004-4acf-89c6-e121d06f4988 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/indexscore/CpcScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexscore/CpcScoreDao.java index f93338307f..2bab7efa56 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 @@ -25,6 +25,7 @@ import org.apache.ibatis.annotations.Param; import java.math.BigDecimal; import java.util.List; +import java.util.Map; /** * 党员相关分值 @@ -76,4 +77,8 @@ public interface CpcScoreDao extends BaseDao { * @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> getPartScoreByPage(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("offset") int offset, @Param("pageSize") int pageSize); } \ No newline at end of file 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..a9781ea496 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,29 @@ 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; } 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..ee7d161ecb 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,13 @@ package com.epmet.service.indexcal.impl; -import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.utils.DateUtils; 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; @@ -18,6 +20,7 @@ import com.epmet.support.normalizing.ScoreConstants; import com.epmet.support.normalizing.batch.BatchScoreCalculator; import com.epmet.support.normalizing.batch.IndexInputVO; import com.epmet.support.normalizing.batch.SampleValue; +import com.epmet.util.DimIdGenerator; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -26,10 +29,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 +43,53 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { private IndexGroupDetailService getDetailListByParentCode; @Autowired private IndexCodeFieldReService indexCodeFieldReService; + @Autowired + private CpcScoreDao cpcScoreDao; @Override public Boolean cpcIndexCalculate(CalculateCommonFormDTO formDTO) { - //获取指标权重信息 -参与议事 - List indexDetails = getDetailListByParentCode.getDetailListLikeParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode()); - if (CollectionUtils.isEmpty(indexDetails)) { + + calculatePartScore(formDTO); + calculateTotalScore(formDTO); + + + return null; + } + + /** + * 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; + return; } + //获取数据 + List> list = null; + int pageNo = 1; + int pageSize = 10; + do { - canyuyishi(formDTO, indexDetails); + list = cpcScoreDao.getPartScoreByPage(formDTO.getCustomerId(), formDTO.getMonthId(), (pageNo - 1) * pageSize, pageSize); + if (!CollectionUtils.isEmpty(list)) { + list.forEach(partScore->{ + partScore.get(IndexCalConstant.USER_ID) + }); + //遍历指标分组 计算分数 + List> finalList = list; + groupIndexDetailsMap.forEach((parentIndexCode, details) -> { + calculate(formDTO, details, finalList, minAndMaxMap, parentIndexCode); + }); + } + } while (!CollectionUtils.isEmpty(list) && pageNo++ > 0); - //log.info(JSON.toJSONString(minAndMaxList)); - return null; } - 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"); @@ -74,9 +103,29 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { } //指标集合 //对指标进行分组 - Map> groupIndexDetailsMap = indexDetails.stream().collect(Collectors.groupingBy(IndexGroupDetailEntity::getAllParentIndexCode)); + //Map> groupIndexDetailsMap = indexDetails.stream().collect(Collectors.groupingBy(IndexGroupDetailEntity::getAllParentIndexCode)); + //获取指标权重信息 -参与议事 + List canyuyishiIndexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(), IndexCodeEnum.CAN_YU_YI_SHI.getCode()); + if (CollectionUtils.isEmpty(canyuyishiIndexDetails)) { + log.warn("cpcIndexCalculate customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); + return; + } + List dangwuhongdongIndexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(), IndexCodeEnum.DANG_WU_HUO_DONG.getCode()); + if (CollectionUtils.isEmpty(canyuyishiIndexDetails)) { + log.warn("cpcIndexCalculate customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); + return; + } + List lianxiqunzhongIndexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(), IndexCodeEnum.LIAN_XI_QUN_ZHONG.getCode()); + if (CollectionUtils.isEmpty(canyuyishiIndexDetails)) { + log.warn("cpcIndexCalculate customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); + return; + } + 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); List> list = null; int pageNo = 1; @@ -87,42 +136,65 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { //遍历指标分组 计算分数 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) -> { + calculate(formDTO, details, finalList, minAndMaxMap, parentIndexCode); }); } } while (!CollectionUtils.isEmpty(list) && pageNo++ > 0); } - @Transactional(rollbackFor = Exception.class) - public void saveGridCorreLationDangJian(CalculateCommonFormDTO formDTO, List indexDetails, HashMap result) { + private void calculate(CalculateCommonFormDTO formDTO, List indexDetailList, List> finalList, Map minAndMaxMap, String parentIndexCode) { + Map> indexMap = getIndexInputVO(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)); + String sampleValueStr = String.valueOf(cpcCount.get(fieldName)); + + CpcScoreEntity cpcScoreEntity = new CpcScoreEntity(); + cpcScoreEntity.setYearId(DimIdGenerator.getYearDimId(DateUtils.addDateMonths(new Date(), -1))); + 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.setMonthId(formDTO.getMonthId()); + cpcScoreEntity.setScore(new BigDecimal(0)); + cpcScoreEntity.setIndexCode(parentIndexCode); + scoreEntityMap.put(userId, cpcScoreEntity); + + //构造样本值对象 + SampleValue currentGridIndexValue = new SampleValue((String) cpcCount.get(IndexCalConstant.USER_ID), new BigDecimal(sampleValueStr)); + value.getIndexValueVOs().add(currentGridIndexValue); + } + } + log.warn("计算的参数:{}", indexMap); + HashMap result = calculate(indexMap); + + //处理结果 + saveCpcScore(formDTO, scoreEntityMap, parentIndexCode, result); + } + + + @Transactional(rollbackFor = Exception.class) + public void saveCpcScore(CalculateCommonFormDTO formDTO, Map indexDetails, String parentIndexCode, HashMap result) { + cpcScoreDao.deleteByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), parentIndexCode); + result.forEach((userId, score) -> { + CpcScoreEntity cpcScoreEntity = indexDetails.get(userId); + cpcScoreEntity.setScore(score); + cpcScoreDao.insert(cpcScoreEntity); + }); } /** 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/indexscore/CpcScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/CpcScoreDao.xml index f4866aaffd..9696bf3702 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,6 +18,17 @@ + + delete from fact_index_cpc_score where CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} and MONTH_ID = #{monthId,jdbcType=VARCHAR} and INDEX_CODE = #{indexCode,jdbcType=VARCHAR} + + + + select - ID, INDEX_GROUP_ID, INDEX_ID, INDEX_CODE, WEIGHT, THRESHOLD + ID,CUSTOMER_ID, INDEX_GROUP_ID, INDEX_ID, INDEX_CODE, WEIGHT, THRESHOLD, ALL_PARENT_INDEX_CODE FROM index_group_detail WHERE CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} and STATUS = 'enable' and DEL_FLAG = '0' @@ -15,10 +15,10 @@ \ No newline at end of file From e5df941b4b7d2762c67f68d3c067dd5278e61625 Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 31 Aug 2020 17:13:23 +0800 Subject: [PATCH 12/14] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/dao/indexscore/CpcScoreDao.java | 3 +-- .../indexcal/impl/CpcIndexCalculateServiceImpl.java | 10 +++------- .../main/resources/mapper/indexscore/CpcScoreDao.xml | 2 +- 3 files changed, 5 insertions(+), 10 deletions(-) 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 2bab7efa56..99303193bf 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 @@ -25,7 +25,6 @@ import org.apache.ibatis.annotations.Param; import java.math.BigDecimal; import java.util.List; -import java.util.Map; /** * 党员相关分值 @@ -80,5 +79,5 @@ public interface CpcScoreDao extends BaseDao { int deleteByMonthId(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("indexCode") String indexCode); - List> getPartScoreByPage(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("offset") int offset, @Param("pageSize") int pageSize); + List getPartScoreByPage(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("offset") int offset, @Param("pageSize") int pageSize); } \ No newline at end of file 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 ee7d161ecb..b9338e4d32 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 @@ -69,7 +69,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { return; } //获取数据 - List> list = null; + List list = null; int pageNo = 1; int pageSize = 10; do { @@ -77,13 +77,9 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { list = cpcScoreDao.getPartScoreByPage(formDTO.getCustomerId(), formDTO.getMonthId(), (pageNo - 1) * pageSize, pageSize); if (!CollectionUtils.isEmpty(list)) { list.forEach(partScore->{ - partScore.get(IndexCalConstant.USER_ID) - }); - //遍历指标分组 计算分数 - List> finalList = list; - groupIndexDetailsMap.forEach((parentIndexCode, details) -> { - calculate(formDTO, details, finalList, minAndMaxMap, parentIndexCode); + }); + } } while (!CollectionUtils.isEmpty(list) && pageNo++ > 0); 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 9696bf3702..3694e52024 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 @@ -22,7 +22,7 @@ delete from fact_index_cpc_score where CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} and MONTH_ID = #{monthId,jdbcType=VARCHAR} and INDEX_CODE = #{indexCode,jdbcType=VARCHAR} - select CUSTOMER_ID,AGENCY_ID,GRID_ID,USER_ID,SCORE,INDEX_CODE FROM fact_index_cpc_score WHERE From 4ef2e4a0bdf64127d62f57229c7f17cec070098d Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 31 Aug 2020 17:59:49 +0800 Subject: [PATCH 13/14] =?UTF-8?q?=E8=AE=A1=E7=AE=97=E5=85=9A=E5=91=98?= =?UTF-8?q?=E6=80=BB=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/dao/indexscore/CpcScoreDao.java | 13 ++++-- .../entity/indexscore/CpcScoreEntity.java | 5 ++ .../impl/CpcIndexCalculateServiceImpl.java | 45 +++++++++++++----- .../mapper/indexscore/CpcScoreDao.xml | 46 ++++++++++++++++++- 4 files changed, 90 insertions(+), 19 deletions(-) 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 99303193bf..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 @@ -24,6 +24,7 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.math.BigDecimal; +import java.util.Collection; import java.util.List; /** @@ -36,10 +37,10 @@ import java.util.List; public interface CpcScoreDao extends BaseDao { /** - * @return java.math.BigDecimal * @param customerId * @param monthId * @param gridId + * @return java.math.BigDecimal * @author yinzuomei * @description 获取网格内党员的联系群众能力考评分(平均值) * @Date 2020/8/31 10:56 @@ -49,17 +50,17 @@ public interface CpcScoreDao extends BaseDao { @Param("gridId") String gridId); /** - * @return java.util.List * @param formDTO + * @return java.util.List * @author yinzuomei - * @description 获取网格内党员的联系群众能力考评分(平均值)的最大值,最小值 + * @description 获取网格内党员的联系群众能力考评分(平均值)的最大值,最小值 * @Date 2020/8/31 12:10 **/ List selectListGridContactMassesAvgValue(CalculateCommonFormDTO formDTO); /** - * @return java.util.List * @param calculateCommonFormDTO + * @return java.util.List * @author yinzuomei * @description 网格内党员的参与议事能力考评分(平均值) 最大值最小值 * @Date 2020/8/31 14:42 @@ -79,5 +80,7 @@ public interface CpcScoreDao extends BaseDao { int deleteByMonthId(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("indexCode") String indexCode); - List getPartScoreByPage(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("offset") int offset, @Param("pageSize") int pageSize); + 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/entity/indexscore/CpcScoreEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/indexscore/CpcScoreEntity.java index a9781ea496..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 @@ -77,4 +77,9 @@ public class CpcScoreEntity extends BaseEpmetEntity { * 指标code */ private String indexCode; + + /** + * 是否是总分 1是0不是 + */ + private String isTotal; } 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 b9338e4d32..1293e23dc9 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,6 +1,8 @@ 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.utils.ConvertUtils; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.constant.IndexCalConstant; import com.epmet.dao.indexcoll.FactIndexPartyAblityCpcMonthlyDao; @@ -53,12 +55,12 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { calculatePartScore(formDTO); calculateTotalScore(formDTO); - - return null; + return true; } /** * desc: 计算总分 + * * @param formDTO */ private void calculateTotalScore(CalculateCommonFormDTO formDTO) { @@ -70,19 +72,35 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { } //获取数据 List list = null; - int pageNo = 1; - int pageSize = 10; - do { + Map cpcScoreTotalMap = new HashMap<>(); + Map indexWeightMap = parentIndexDetails.stream().collect(Collectors.toMap(IndexGroupDetailEntity::getIndexCode, o -> o)); + + list = cpcScoreDao.getPartScore(formDTO.getCustomerId(), formDTO.getMonthId()); + if (!CollectionUtils.isEmpty(list)) { + 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()); + cpcScoreTotalMap.put(userId, totalEntity); + } + BigDecimal total = part.getScore().multiply(indexGroupDetailEntity.getWeight()); + totalEntity.setScore(totalEntity.getScore().add(total)); + } + }); + } - list = cpcScoreDao.getPartScoreByPage(formDTO.getCustomerId(), formDTO.getMonthId(), (pageNo - 1) * pageSize, pageSize); - if (!CollectionUtils.isEmpty(list)) { - list.forEach(partScore->{ + insertBatch(cpcScoreTotalMap.values().stream().collect(Collectors.toList())); - }); - } - } while (!CollectionUtils.isEmpty(list) && pageNo++ > 0); + } + private void insertBatch(Collection values) { + cpcScoreDao.insertBatch(values); } private void calculatePartScore(CalculateCommonFormDTO formDTO) { @@ -165,6 +183,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { 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); @@ -186,11 +205,13 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { @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); - cpcScoreDao.insert(cpcScoreEntity); + list.add(cpcScoreEntity); }); + this.insertBatch(list); } /** 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 3694e52024..c3b2529e0c 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 @@ -22,9 +22,9 @@ delete from fact_index_cpc_score where CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} and MONTH_ID = #{monthId,jdbcType=VARCHAR} and INDEX_CODE = #{indexCode,jdbcType=VARCHAR} - select - CUSTOMER_ID,AGENCY_ID,GRID_ID,USER_ID,SCORE,INDEX_CODE FROM fact_index_cpc_score + CUSTOMER_ID,AGENCY_ID,GRID_ID,YEAR_ID,MONTH_ID,USER_ID,SCORE,INDEX_CODE FROM fact_index_cpc_score WHERE CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} and MONTH_ID = #{monthId,jdbcType=VARCHAR} AND IS_TOTAL = '0' @@ -91,4 +91,46 @@ GROUP BY m.GRID_ID + + + 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 From 4d6adb90b30943ce7c55580d14b152ff4f8ea251 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Mon, 31 Aug 2020 18:10:07 +0800 Subject: [PATCH 14/14] =?UTF-8?q?=E7=BD=91=E6=A0=BC=E7=9B=B8=E5=85=B3-?= =?UTF-8?q?=E6=9A=82=E5=AD=98V3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/dao/indexscore/GridScoreDao.java | 2 +- .../impl/GridCorreLationServiceImpl.java | 47 +++++++++++++++---- .../mapper/indexscore/GridScoreDao.xml | 35 +++++++++++++- 3 files changed, 71 insertions(+), 13 deletions(-) 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 30196d21f9..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 @@ -38,7 +38,7 @@ public interface GridScoreDao extends BaseDao { * @param customerId * @param monthId * @param indexCode - * @param isTotal + * @param isTotal 1:总分;0不是 * @return int * @author yinzuomei * @description 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 0700e33f7b..74afb589f3 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 @@ -11,10 +11,7 @@ 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.GridScoreDTO; -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; @@ -33,6 +30,8 @@ import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; /** * 网格相关service @@ -96,7 +95,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { List wgxgList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode()); if (!CollectionUtils.isEmpty(wgxgList)) { - calculateGridTotal(formDTO, wgxgList); + calculateGridTotal(formDTO, wgxgList,IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode()); } resultFlag = true; return resultFlag; @@ -496,14 +495,42 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { * @description 计算网格相关总分 * @Date 2020/8/26 16:50 **/ - private void calculateGridTotal(CalculateCommonFormDTO formDTO, List indexList) { + private void calculateGridTotal(CalculateCommonFormDTO formDTO, List indexList, String indexCode) { //查询总记录数 - List gridScoreDTOList=gridScoreDao.selectList(formDTO); - // 保存中间表 TODO -// saveGridCorreLationDangJian(formDTO, resultMapList,IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode(),NumConstant.ONE_STR); + List gridScoreDTOList = gridScoreDao.selectList(formDTO); + Map indexMap = indexList.stream().collect(Collectors.toMap(IndexGroupDetailEntity::getIndexCode, Function.identity())); + List gridScoreEntityList = new ArrayList<>(); + gridScoreDTOList.forEach(gridScoreDTO -> { + 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); + 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 * @return com.epmet.dto.indexcal.CustomerGridInfoDTO 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 6f739c3e36..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 @@ -78,7 +78,38 @@ - + SELECT + m.GRID_ID, + m.CUSTOMER_ID, + m.AGENCY_ID, + m.ALL_PARENT_IDS, + m.QUARTER_ID, + m.YEAR_ID, + m.MONTH_ID, + m.IS_TOTAL, + M.SCORE, + M.INDEX_CODE + FROM + fact_index_grid_score m + WHERE + m.DEL_FLAG = '0' + AND m.IS_TOTAL='0' + AND m.CUSTOMER_ID =#{customerId} + AND m.MONTH_ID =#{monthId} \ No newline at end of file