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 01/22] =?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 02/22] =?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 03/22] =?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 04/22] =?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 05/22] =?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 06/22] =?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 From 255971ad11aa3d5556f6e711d11dc96a3060da27 Mon Sep 17 00:00:00 2001 From: wxz Date: Mon, 31 Aug 2020 18:19:48 +0800 Subject: [PATCH 07/22] =?UTF-8?q?=E5=88=86=E5=80=BC=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E5=99=A8=E4=BF=9D=E7=95=996=E4=BD=8D=E5=B0=8F=E6=95=B0?= =?UTF-8?q?=EF=BC=8C=E5=9B=9B=E8=88=8D=E4=BA=94=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../support/normalizing/batch/BatchScoreCalculator.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java index d42ae98562..361d81f95f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java @@ -3,6 +3,7 @@ package com.epmet.support.normalizing.batch; import com.epmet.support.normalizing.ScoreCalculator; import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.HashMap; import java.util.List; import java.util.stream.Collectors; @@ -24,7 +25,7 @@ public class BatchScoreCalculator { // 循环同一个指标内的多个样本值的SampleValue列表 List scores4OneIndex = indexValueVOs.stream().map(vo -> { - BigDecimal score = scoreCalculator.normalize(vo.getSampleValue(), weight); + BigDecimal score = scoreCalculator.normalize(vo.getSampleValue(), weight).setScale(6, RoundingMode.HALF_UP);; return new SampleScore(vo.getSampleId(), score); }).collect(Collectors.toList()); @@ -52,9 +53,10 @@ public class BatchScoreCalculator { String sampleId = vo.getSampleId(); BigDecimal score = scoreCalculator.normalize(vo.getSampleValue(), weight); if (scoreCountOfSamples.containsKey(sampleId)) { - BigDecimal newScore = scoreCountOfSamples.get(sampleId).add(score); + BigDecimal newScore = scoreCountOfSamples.get(sampleId).add(score).setScale(6, RoundingMode.HALF_UP); scoreCountOfSamples.put(sampleId, newScore); } else { + score.setScale(6, RoundingMode.HALF_UP); scoreCountOfSamples.put(sampleId, score); } } From 93fdcc50e97815fb9af9e516569884133d7d765d Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Mon, 31 Aug 2020 18:46:31 +0800 Subject: [PATCH 08/22] =?UTF-8?q?=E7=BD=91=E6=A0=BC=E7=9B=B8=E5=85=B3-?= =?UTF-8?q?=E6=9A=82=E5=AD=98V3.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/GridCorreLationServiceImpl.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) 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 74afb589f3..7897c2560b 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 @@ -123,7 +123,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { //每一组指标的最大值,key:code_MIN/MAX Map minAndMaxMap = queryPartyAblityGridMinAndMax(formDTO.getCustomerId(), formDTO.getMonthId()); //指标集合 - Map> indexMap = getIndexInputVO(formDTO, indexList, minAndMaxMap); + Map> indexMap = getGridCorrelationIndexInputVO(formDTO, indexList, minAndMaxMap); List> resultMapList=new ArrayList<>(); //分页查询采集记录 for (int pageNo = 1; pageNo <= totalPage; pageNo++) { @@ -318,10 +318,10 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { * @param minAndMaxMap 最大值最小值集合 * @return java.util.Map * @author yinzuomei - * @description + * @description 构造网格相关 指标计算参数 * @Date 2020/8/30 15:56 **/ - private Map> getIndexInputVO(CalculateCommonFormDTO formDTO, List indexList, Map minAndMaxMap) { + private Map> getGridCorrelationIndexInputVO(CalculateCommonFormDTO formDTO, List indexList, Map minAndMaxMap) { Map> map = new HashMap<>(); for (int indexNum = 0; indexNum < indexList.size(); indexNum++) { IndexGroupDetailEntity index = indexList.get(indexNum); @@ -347,7 +347,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { //获取指标对应的列名 String fieldName = indexCodeFieldReService.getFieldNameByIndexCode(index.getIndexCode()); if(StringUtils.isBlank(fieldName)){ - logger.error("index_code:"+index.getIndexCode()+"not find field_name"); + logger.error("index_code:"+index.getIndexCode()+" not find field_name"); continue; } logger.info("INDEX_CODE=" + index.getIndexCode()+";FIELD_ID=" + fieldName ); @@ -393,7 +393,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { //每一组指标的最大值,key:code_MIN/MAX Map minAndMaxMap = queryGovrnAblityGridMinAndMax(formDTO.getCustomerId(), formDTO.getMonthId()); //指标集合 - Map> indexMap = getIndexInputVO(formDTO, indexList, minAndMaxMap); + Map> indexMap = getGridCorrelationIndexInputVO(formDTO, indexList, minAndMaxMap); List> resultMapList=new ArrayList<>(); //分页查询采集记录 for (int pageNo = 1; pageNo <= totalPage; pageNo++) { @@ -453,7 +453,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { //每一组指标的最大值,key:code_MIN/MAX Map minAndMaxMap = queryServiceAblityGridMinAndMax(formDTO.getCustomerId(), formDTO.getMonthId()); //指标集合 - Map> indexMap = getIndexInputVO(formDTO, indexList, minAndMaxMap); + Map> indexMap = getGridCorrelationIndexInputVO(formDTO, indexList, minAndMaxMap); List> resultMapList=new ArrayList<>(); //分页查询采集记录 for (int pageNo = 1; pageNo <= totalPage; pageNo++) { @@ -500,7 +500,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { List gridScoreDTOList = gridScoreDao.selectList(formDTO); Map indexMap = indexList.stream().collect(Collectors.toMap(IndexGroupDetailEntity::getIndexCode, Function.identity())); List gridScoreEntityList = new ArrayList<>(); - gridScoreDTOList.forEach(gridScoreDTO -> { + for(GridScoreDTO gridScoreDTO:gridScoreDTOList){ GridScoreEntity gridScoreEntity = new GridScoreEntity(); gridScoreEntity.setCustomerId(gridScoreDTO.getCustomerId()); gridScoreEntity.setGridId(gridScoreDTO.getGridId()); @@ -512,12 +512,16 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { gridScoreEntity.setYearId(gridScoreDTO.getYearId()); gridScoreEntity.setMonthId(gridScoreDTO.getMonthId()); gridScoreEntity.setScore(BigDecimal.ZERO); + if(!CollectionUtils.isEmpty(gridScoreDTO.getDetailList())&&gridScoreDTO.getDetailList().size()!=3){ + logger.error("customerId:"+gridScoreDTO.getCustomerId()+";gridId:"+gridScoreDTO.getGridId()+";monthId:"+gridScoreDTO.getMonthId()+"能力值缺失,无法计算总值"); + continue; + } for(GridScoreDetailDTO gridScoreDetailDTO:gridScoreDTO.getDetailList()){ BigDecimal indexScore=gridScoreDetailDTO.getScore().multiply(indexMap.get(gridScoreDetailDTO.getIndexCode()).getWeight()); gridScoreEntity.setScore(gridScoreEntity.getScore().add(indexScore)); } gridScoreEntityList.add(gridScoreEntity); - }); + } if (!CollectionUtils.isEmpty(gridScoreEntityList)) { gridScoreDao.deleteByCusAndMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode, NumConstant.ONE_STR); gridScoreDao.insertBatches(gridScoreEntityList); From 19634b110b9ede3a5548162e6e65e0218e082c42 Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 31 Aug 2020 21:19:33 +0800 Subject: [PATCH 09/22] =?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 --- .../service/indexcal/impl/CpcIndexCalculateServiceImpl.java | 3 ++- .../src/main/resources/mapper/indexscore/CpcScoreDao.xml | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) 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 1293e23dc9..214076fc6a 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 @@ -89,6 +89,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { cpcScoreTotalMap.put(userId, totalEntity); } BigDecimal total = part.getScore().multiply(indexGroupDetailEntity.getWeight()); + log.warn("userId:{},分数:{},权重:{},total:{}", userId, part.getScore(), indexGroupDetailEntity.getWeight(), total); totalEntity.setScore(totalEntity.getScore().add(total)); } }); @@ -147,7 +148,6 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { do { list = factIndexPartyAblityCpcMonthlyDao.getCountByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), (pageNo - 1) * pageSize, pageSize); if (!CollectionUtils.isEmpty(list)) { - //遍历指标分组 计算分数 List> finalList = list; groupIndexDetailsMap.forEach((parentIndexCode, details) -> { @@ -196,6 +196,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { } log.warn("计算的参数:{}", indexMap); HashMap result = calculate(indexMap); + log.warn("计算的结果:{}", result); //处理结果 saveCpcScore(formDTO, scoreEntityMap, parentIndexCode, result); 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 c3b2529e0c..c3483cbc32 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/CpcScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/CpcScoreDao.xml @@ -124,8 +124,8 @@ #{item.isTotal}, #{item.score}, #{item.indexCode}, - '0', - 0, + 0, + 0, 'APP_USER', now(), 'APP_USER', From cbf7212c686f0f1bc2acc03462abaa8d1b6de4bc Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 31 Aug 2020 22:09:06 +0800 Subject: [PATCH 10/22] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/constant/IndexCalConstant.java | 1 + .../impl/CpcIndexCalculateServiceImpl.java | 184 ++++++++++-------- .../FactIndexPartyAblityCpcMonthlyDao.xml | 3 + 3 files changed, 108 insertions(+), 80 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 79321c6026..13b27760a5 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 @@ -19,4 +19,5 @@ public interface IndexCalConstant { String MONTH_ID="MONTH_ID"; String USER_ID="USER_ID"; + String YEAR_ID = "YEAR_ID"; } 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 214076fc6a..c15620850d 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 @@ -2,8 +2,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.exception.RenException; 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; import com.epmet.dao.indexscore.CpcScoreDao; @@ -22,7 +22,6 @@ 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; @@ -50,11 +49,8 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { @Override public Boolean cpcIndexCalculate(CalculateCommonFormDTO formDTO) { - - calculatePartScore(formDTO); calculateTotalScore(formDTO); - return true; } @@ -68,36 +64,35 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { 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; + throw new RenException("客户【党员相关】指标权重信息不存在"); } - //获取数据 - List list = null; 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()); - log.warn("userId:{},分数:{},权重:{},total:{}", userId, part.getScore(), indexGroupDetailEntity.getWeight(), total); - totalEntity.setScore(totalEntity.getScore().add(total)); - } - }); + //获取数据 + List list = cpcScoreDao.getPartScore(formDTO.getCustomerId(), formDTO.getMonthId()); + if (CollectionUtils.isEmpty(list)) { + log.error("calculateTotalScore cpcScoreDao.getPartScore return empty,customerId:{},monthId:{}", formDTO.getCustomerId(), formDTO.getMonthId()); + throw new RenException("客户四级指标分值记录不存在"); } - + Map> userGroupMap = list.stream().collect(Collectors.groupingBy(CpcScoreEntity::getUserId)); + userGroupMap.forEach((userId, partScoreList) -> { + CpcScoreEntity totalEntity = null; + for (CpcScoreEntity part : partScoreList) { + IndexGroupDetailEntity indexGroupDetailEntity = indexWeightMap.get(part.getIndexCode()); + if (totalEntity == null) { + totalEntity = ConvertUtils.sourceToTarget(part, CpcScoreEntity.class); + totalEntity.setIsTotal(NumConstant.ONE_STR); + totalEntity.setIndexCode(indexGroupDetailEntity.getIndexCode()); + cpcScoreTotalMap.put(userId, totalEntity); + } + //todo 自建群活跃度——议题转项目率 有阈值 >60%按60%算 + BigDecimal total = part.getScore().multiply(indexGroupDetailEntity.getWeight()); + log.debug("userId:{},分数:{},权重:{},total:{}", userId, part.getScore(), indexGroupDetailEntity.getWeight(), total); + totalEntity.setScore(totalEntity.getScore().add(total)); + } + }); insertBatch(cpcScoreTotalMap.values().stream().collect(Collectors.toList())); - - } private void insertBatch(Collection values) { @@ -113,56 +108,44 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { //计算最大最小值 Map minAndMaxMap = factIndexPartyAblityCpcMonthlyDao.getExtremeValue(formDTO.getCustomerId()); if (CollectionUtils.isEmpty(minAndMaxMap)) { - log.warn("cpcIndexCalculate getExtremeValue customerId:{} have not any fact record", formDTO.getCustomerId()); + log.error("cpcIndexCalculate getExtremeValue customerId:{} have not any fact record", formDTO.getCustomerId()); return; } //指标集合 - //对指标进行分组 - //Map> groupIndexDetailsMap = indexDetails.stream().collect(Collectors.groupingBy(IndexGroupDetailEntity::getAllParentIndexCode)); - - //获取指标权重信息 -参与议事 - 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()); + Map> groupIndexDetailsMap = getIndexDetailMap(formDTO); + if (groupIndexDetailsMap == null) { 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; int pageSize = 10; + //分页查询 要计算的原始数据 + List> list = null; do { list = factIndexPartyAblityCpcMonthlyDao.getCountByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), (pageNo - 1) * pageSize, pageSize); if (!CollectionUtils.isEmpty(list)) { //遍历指标分组 计算分数 List> finalList = list; groupIndexDetailsMap.forEach((parentIndexCode, details) -> { - calculate(formDTO, details, finalList, minAndMaxMap, parentIndexCode); + calculateScore(formDTO, details, finalList, minAndMaxMap, parentIndexCode); }); } } while (!CollectionUtils.isEmpty(list) && pageNo++ > 0); - } - private void calculate(CalculateCommonFormDTO formDTO, List indexDetailList, List> finalList, Map minAndMaxMap, String parentIndexCode) { - Map> indexMap = getIndexInputVO(indexDetailList, minAndMaxMap); + /** + * desc:计算并保存中间结果 + * + * @param formDTO + * @param indexDetailList + * @param finalList + * @param minAndMaxMap + * @param parentIndexCode remark:1.遍历指标和原始数据;2.构建指标归一算法计算器,计算分值;3.将分值保存到中间表 + */ + private void calculateScore(CalculateCommonFormDTO formDTO, List indexDetailList, List> finalList, Map minAndMaxMap, String parentIndexCode) { + Map> indexMap = buildIndexInputVO(indexDetailList, minAndMaxMap); Map scoreEntityMap = new HashMap<>(); //遍历指标 进行计算 - for (Map.Entry> entry : indexMap.entrySet()) { String indexCode = entry.getKey(); IndexInputVO value = entry.getValue(); @@ -175,10 +158,10 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { for (Map cpcCount : finalList) { //对应的数值 String userId = String.valueOf(cpcCount.get(IndexCalConstant.USER_ID)); - String sampleValueStr = String.valueOf(cpcCount.get(fieldName)); + BigDecimal sampleValue = new BigDecimal(String.valueOf(cpcCount.get(fieldName))); CpcScoreEntity cpcScoreEntity = new CpcScoreEntity(); - cpcScoreEntity.setYearId(DimIdGenerator.getYearDimId(DateUtils.addDateMonths(new Date(), -1))); + cpcScoreEntity.setYearId(String.valueOf(cpcCount.get(IndexCalConstant.YEAR_ID))); cpcScoreEntity.setCustomerId(formDTO.getCustomerId()); cpcScoreEntity.setAgencyId(String.valueOf(cpcCount.get(IndexCalConstant.AGENCY_ID))); cpcScoreEntity.setGridId(String.valueOf(cpcCount.get(IndexCalConstant.GRID_ID))); @@ -187,22 +170,30 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { 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); + SampleValue currentUserIndexValue = new SampleValue(userId, sampleValue); + value.getIndexValueVOs().add(currentUserIndexValue); } } log.warn("计算的参数:{}", indexMap); - HashMap result = calculate(indexMap); + HashMap result = calculateScore(indexMap); log.warn("计算的结果:{}", result); //处理结果 saveCpcScore(formDTO, scoreEntityMap, parentIndexCode, result); } - + /** + * desc:保存分值 到中间表 + * + * @param formDTO + * @param indexDetails + * @param parentIndexCode + * @param result + */ @Transactional(rollbackFor = Exception.class) public void saveCpcScore(CalculateCommonFormDTO formDTO, Map indexDetails, String parentIndexCode, HashMap result) { cpcScoreDao.deleteByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), parentIndexCode); @@ -215,21 +206,10 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { this.insertBatch(list); } - /** - * @param indexMap - * @return java.util.List - * @author yinzuomei - * @description - * @Date 2020/8/30 21:40 - **/ - private HashMap calculate(Map> indexMap) { - //构造入参 - List indexInputVOS = indexMap.values().stream().collect(Collectors.toList()); - BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); - return batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); - } /** + * desc:构建分值计算器 + * * @param indexList 指标集合 * @param minAndMaxMap 最大值最小值集合 * @return java.util.Map @@ -237,10 +217,9 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { * @description * @Date 2020/8/30 15:56 **/ - private Map> getIndexInputVO(List indexList, Map minAndMaxMap) { + private Map> buildIndexInputVO(List indexList, Map minAndMaxMap) { Map> map = new HashMap<>(); - for (int indexNum = 0; indexNum < indexList.size(); indexNum++) { - IndexGroupDetailEntity index = indexList.get(indexNum); + for (IndexGroupDetailEntity index : indexList) { IndexInputVO indexInputVO = new IndexInputVO(); // 指标code indexInputVO.setIndexId(index.getIndexCode()); @@ -273,4 +252,49 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { } return map; } + + /** + * desc:调用计算器计算每个人的分数值 + * + * @param indexMap + * @return + */ + private HashMap calculateScore(Map> indexMap) { + //构造入参 + List indexInputVOS = indexMap.values().stream().collect(Collectors.toList()); + BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); + return batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); + } + + + /** + * desc:构建党员相关4级指标明细map + * + * @param formDTO + * @return + */ + private Map> getIndexDetailMap(CalculateCommonFormDTO formDTO) { + //获取指标权重信息 -参与议事 + List canyuyishiIndexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(), IndexCodeEnum.CAN_YU_YI_SHI.getCode()); + if (CollectionUtils.isEmpty(canyuyishiIndexDetails)) { + log.error("cpcIndexCalculate customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); + return null; + } + List dangwuhongdongIndexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(), IndexCodeEnum.DANG_WU_HUO_DONG.getCode()); + if (CollectionUtils.isEmpty(canyuyishiIndexDetails)) { + log.error("cpcIndexCalculate customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); + return null; + } + List lianxiqunzhongIndexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(), IndexCodeEnum.LIAN_XI_QUN_ZHONG.getCode()); + if (CollectionUtils.isEmpty(canyuyishiIndexDetails)) { + log.error("cpcIndexCalculate customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); + return null; + } + + Map> groupIndexDetailsMap = new HashMap<>(); + groupIndexDetailsMap.put(IndexCodeEnum.CAN_YU_YI_SHI.getCode(), canyuyishiIndexDetails); + groupIndexDetailsMap.put(IndexCodeEnum.DANG_WU_HUO_DONG.getCode(), dangwuhongdongIndexDetails); + groupIndexDetailsMap.put(IndexCodeEnum.LIAN_XI_QUN_ZHONG.getCode(), lianxiqunzhongIndexDetails); + return groupIndexDetailsMap; + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml index beb5b42a4e..c9f807d881 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml @@ -101,6 +101,9 @@ AGENCY_ID, PARENT_ID, GRID_ID, + MONTH_ID, + QUARTER_ID, + YEAR_ID, USER_ID, CREATE_TOPIC_COUNT, JOIN_TOPIC_COUNT, From 82b959325b6d243dcdfe8192b488d3f57ff8a82f Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Tue, 1 Sep 2020 09:09:21 +0800 Subject: [PATCH 11/22] =?UTF-8?q?=E6=89=93=E5=BC=80nacos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- epmet-module/data-statistical/data-statistical-server/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-module/data-statistical/data-statistical-server/pom.xml b/epmet-module/data-statistical/data-statistical-server/pom.xml index a805e4a53c..8d0e953c05 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 - false + true 192.168.1.130:8848 6ceab336-d004-4acf-89c6-e121d06f4988 From 9f9a3903cebbbf4acbc9e5fedc762ac5a689fe5f Mon Sep 17 00:00:00 2001 From: wxz Date: Tue, 1 Sep 2020 09:57:01 +0800 Subject: [PATCH 12/22] =?UTF-8?q?=E5=88=86=E6=94=AF=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=EF=BC=8C=E5=A2=9E=E5=8A=A0=E9=98=88=E5=80=BC?= =?UTF-8?q?=E7=9A=84=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../batch/BatchScoreCalculator.java | 23 +++++++++++++++++-- .../normalizing/batch/IndexInputVO.java | 7 +++++- .../stats/test/normalizing/DemoScoreCal.java | 12 +++++----- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java index 361d81f95f..6c17298ad6 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java @@ -22,10 +22,11 @@ public class BatchScoreCalculator { List indexValueVOs = i.getIndexValueVOs(); BigDecimal weight = i.getWeight(); ScoreCalculator scoreCalculator = i.getScoreCalculator(); + BigDecimal threshold = i.getThreshold(); // 循环同一个指标内的多个样本值的SampleValue列表 List scores4OneIndex = indexValueVOs.stream().map(vo -> { - BigDecimal score = scoreCalculator.normalize(vo.getSampleValue(), weight).setScale(6, RoundingMode.HALF_UP);; + BigDecimal score = scoreCalculator.normalize(getFinalSampleValue(vo.getSampleValue(), threshold), weight).setScale(6, RoundingMode.HALF_UP);; return new SampleScore(vo.getSampleId(), score); }).collect(Collectors.toList()); @@ -48,10 +49,11 @@ public class BatchScoreCalculator { List indexValueVOs = idx.getIndexValueVOs(); BigDecimal weight = idx.getWeight(); ScoreCalculator scoreCalculator = idx.getScoreCalculator(); + BigDecimal threshold = idx.getThreshold(); for (SampleValue vo : indexValueVOs) { String sampleId = vo.getSampleId(); - BigDecimal score = scoreCalculator.normalize(vo.getSampleValue(), weight); + BigDecimal score = scoreCalculator.normalize(getFinalSampleValue(vo.getSampleValue(), threshold), weight); if (scoreCountOfSamples.containsKey(sampleId)) { BigDecimal newScore = scoreCountOfSamples.get(sampleId).add(score).setScale(6, RoundingMode.HALF_UP); scoreCountOfSamples.put(sampleId, newScore); @@ -64,4 +66,21 @@ public class BatchScoreCalculator { return scoreCountOfSamples; } + + /** + * 获取最终样本值 + * @param realValue + * @param threshold + * @return + */ + public BigDecimal getFinalSampleValue(Object realValue, BigDecimal threshold) { + BigDecimal bdRealValue = new BigDecimal(realValue.toString()); + if (threshold.equals(-1)) { + // -1表示不使用阈值 + return bdRealValue; + } + return (bdRealValue.compareTo(threshold) < 0) || (bdRealValue.equals(threshold)) + ? bdRealValue + : threshold ; + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexInputVO.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexInputVO.java index 94ea1ef0ad..47ca728d5a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexInputVO.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexInputVO.java @@ -11,7 +11,7 @@ import java.util.List; @Data @AllArgsConstructor @NoArgsConstructor -public class IndexInputVO { +public class IndexInputVO { /** * 指标标记,由使用者传入,用以标记该条指标的独有特性,一般用id或者code @@ -24,6 +24,11 @@ public class IndexInputVO { */ private List> indexValueVOs; + /** + * 样本阈值 + */ + private BigDecimal threshold; + /** * 权重 */ diff --git a/epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/DemoScoreCal.java b/epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/DemoScoreCal.java index c080ffc296..6da70db9c8 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/DemoScoreCal.java +++ b/epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/DemoScoreCal.java @@ -78,8 +78,8 @@ public class DemoScoreCal { List> index2SampleValues = Arrays.asList(new SampleValue<>("id1", 1), new SampleValue<>("id2", 8), new SampleValue<>("id3", 3)); // 每个指标的信息,包括样本列表,权重,指标标记 - IndexInputVO index1VO = new IndexInputVO<>("aaa", index1SampleValues, new BigDecimal(1), sc1); - IndexInputVO index2VO = new IndexInputVO<>("bbb", index2SampleValues, new BigDecimal(1), sc2); + IndexInputVO index1VO = new IndexInputVO<>("aaa", index1SampleValues, new BigDecimal(10), new BigDecimal(1), sc1); + IndexInputVO index2VO = new IndexInputVO<>("bbb", index2SampleValues, new BigDecimal(10), new BigDecimal(1), sc2); List indexInputVOS = Arrays.asList(index1VO, index2VO); @@ -104,8 +104,8 @@ public class DemoScoreCal { List index2SampleValues = Arrays.asList(new SampleValue<>("id1", new BigDecimal(1)), new SampleValue<>("id2", new BigDecimal(8)), new SampleValue<>("id3", new BigDecimal(3))); // 每个指标的信息,包括样本列表,权重,指标标记 - IndexInputVO index1VO = new IndexInputVO("aaa", index1SampleValues, new BigDecimal(1), sc1); - IndexInputVO index2VO = new IndexInputVO("bbb", index2SampleValues, new BigDecimal(1), sc2); + IndexInputVO index1VO = new IndexInputVO("aaa", index1SampleValues, new BigDecimal(6), new BigDecimal(1), sc1); + IndexInputVO index2VO = new IndexInputVO("bbb", index2SampleValues, new BigDecimal(6), new BigDecimal(1), sc2); List indexInputVOS = Arrays.asList(index1VO, index2VO); @@ -130,8 +130,8 @@ public class DemoScoreCal { List index2SampleValues = Arrays.asList(new SampleValue<>("id1", new BigDecimal(1)), new SampleValue<>("id2", new BigDecimal(8)), new SampleValue<>("id3", new BigDecimal(3))); // 每个指标的信息,包括样本列表,权重,指标标记 - IndexInputVO index1VO = new IndexInputVO("aaa", index1SampleValues, new BigDecimal(1), sc1); - IndexInputVO index2VO = new IndexInputVO("bbb", index2SampleValues, new BigDecimal(1), sc2); + IndexInputVO index1VO = new IndexInputVO("aaa", index1SampleValues, new BigDecimal(6), new BigDecimal(1), sc1); + IndexInputVO index2VO = new IndexInputVO("bbb", index2SampleValues, new BigDecimal(6), new BigDecimal(1), sc2); List indexInputVOS = Arrays.asList(index1VO, index2VO); From e8c33cf1fe306abd3bdcf84cfd00b5eab5ba0be8 Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 1 Sep 2020 10:10:02 +0800 Subject: [PATCH 13/22] =?UTF-8?q?=E6=80=BB=E5=88=86=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/model/IndexExcelDataListener.java | 48 +++++++++---------- .../impl/CpcIndexCalculateServiceImpl.java | 5 +- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java index 24770d1bd2..9267d562a8 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java @@ -123,49 +123,49 @@ public class IndexExcelDataListener extends AnalysisEventListener { group1.setIndexId(indexDictEntity.getId()); group1.setParentIndexGroupId("0"); group1.setId(UniqueIdGenerator.generate()); - group1.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(),true,4)); + group1.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(), true, 4)); indexGroupMap.put(index.getLevel1Index(), group1); } StringBuilder allIndexCodeSb = new StringBuilder(group1.getIndexCode()); String level4Index = index.getLevel4Index(); indexDictEntity = indexDicMap.get(level4Index); - IndexGroupTemplateEntity group2 = indexGroupMap.get(index.getLevel1Index()+level4Index); + IndexGroupTemplateEntity group2 = indexGroupMap.get(index.getLevel1Index() + level4Index); IndexGroupDetailTemplateEntity templateEntity = null; if (group2 == null) { group2 = new IndexGroupTemplateEntity(); group2.setIndexId(indexDictEntity.getId()); group2.setParentIndexGroupId(group1.getId()); group2.setId(UniqueIdGenerator.generate()); - group2.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(),false,4 )); - indexGroupMap.put(index.getLevel1Index()+level4Index, group2); + group2.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(), false, 4)); + indexGroupMap.put(index.getLevel1Index() + level4Index, group2); //构建 分组明细 - templateEntity = indexGroupDetailMap.get(index.getLevel1Index()+level4Index); + templateEntity = indexGroupDetailMap.get(index.getLevel1Index() + level4Index); if (templateEntity == null) { - templateEntity = new IndexGroupDetailTemplateEntity(); + templateEntity = new IndexGroupDetailTemplateEntity(); templateEntity.setIndexGroupId(group1.getId()); templateEntity.setIndexId(indexDictEntity.getId()); templateEntity.setAllParentIndexCode(allIndexCodeSb.toString()); templateEntity.setId(UniqueIdGenerator.generate()); templateEntity.setCorrelation(index.getCorrelation()); - buildIndexGroupDetail(templateEntity,indexDictEntity, index, group1, 2); - indexGroupDetailMap.put(index.getLevel1Index()+level4Index,templateEntity); + buildIndexGroupDetail(templateEntity, indexDictEntity, index, 2); + indexGroupDetailMap.put(index.getLevel1Index() + level4Index, templateEntity); } } indexDictEntity = indexDicMap.get(index.getLevel5Index()); allIndexCodeSb.append(StrConstant.COLON); allIndexCodeSb.append(group2.getIndexCode()); - templateEntity = indexGroupDetailMap.get(index.getLevel1Index()+index.getLevel5Index()); + templateEntity = indexGroupDetailMap.get(index.getLevel1Index() + index.getLevel5Index()); if (templateEntity == null) { - templateEntity = new IndexGroupDetailTemplateEntity(); + templateEntity = new IndexGroupDetailTemplateEntity(); templateEntity.setIndexGroupId(group2.getId()); templateEntity.setIndexId(indexDictEntity.getId()); templateEntity.setAllParentIndexCode(allIndexCodeSb.toString()); templateEntity.setId(UniqueIdGenerator.generate()); templateEntity.setCorrelation(index.getCorrelation()); - buildIndexGroupDetail(templateEntity,indexDictEntity, index, group2, 5); - indexGroupDetailMap.put(index.getLevel1Index()+index.getLevel5Index(),templateEntity); + buildIndexGroupDetail(templateEntity, indexDictEntity, index, 5); + indexGroupDetailMap.put(index.getLevel1Index() + index.getLevel5Index(), templateEntity); } } else { //todo 测试完去掉 @@ -177,7 +177,7 @@ public class IndexExcelDataListener extends AnalysisEventListener { group1.setIndexId(indexDictEntity.getId()); group1.setParentIndexGroupId("0"); group1.setId(UniqueIdGenerator.generate()); - group1.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(),false,4 )); + group1.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(), false, 4)); indexGroupMap.put(index.getLevel1Index(), group1); } StringBuilder allIndexCodeSb = new StringBuilder(group1.getIndexCode()); @@ -191,35 +191,35 @@ public class IndexExcelDataListener extends AnalysisEventListener { group2.setIndexId(indexDictEntity.getId()); group2.setParentIndexGroupId(group1.getId()); group2.setId(UniqueIdGenerator.generate()); - group2.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(),false,4 )); + group2.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(), false, 4)); indexGroupMap.put(groupMapKey, group2); //构建 分组明细 templateEntity = indexGroupDetailMap.get(level2Index); if (templateEntity == null) { - templateEntity = new IndexGroupDetailTemplateEntity(); + templateEntity = new IndexGroupDetailTemplateEntity(); templateEntity.setIndexGroupId(group2.getId()); templateEntity.setIndexId(indexDictEntity.getId()); templateEntity.setAllParentIndexCode(allIndexCodeSb.toString()); templateEntity.setId(UniqueIdGenerator.generate()); templateEntity.setCorrelation(index.getCorrelation()); - buildIndexGroupDetail(templateEntity,indexDictEntity, index, group1, 2); - indexGroupDetailMap.put(level2Index,templateEntity); + buildIndexGroupDetail(templateEntity, indexDictEntity, index, 2); + indexGroupDetailMap.put(groupMapKey, templateEntity); } } indexDictEntity = indexDicMap.get(index.getLevel5Index()); allIndexCodeSb.append(StrConstant.COLON); allIndexCodeSb.append(group2.getIndexCode()); - templateEntity = indexGroupDetailMap.get(index.getLevel1Index()+index.getLevel5Index()); + templateEntity = indexGroupDetailMap.get(index.getLevel1Index() + index.getLevel5Index()); if (templateEntity == null) { - templateEntity = new IndexGroupDetailTemplateEntity(); + templateEntity = new IndexGroupDetailTemplateEntity(); templateEntity.setIndexGroupId(group2.getId()); templateEntity.setIndexId(indexDictEntity.getId()); templateEntity.setAllParentIndexCode(allIndexCodeSb.toString()); templateEntity.setId(UniqueIdGenerator.generate()); templateEntity.setCorrelation(index.getCorrelation()); - buildIndexGroupDetail(templateEntity, indexDictEntity, index, group2, 5); - indexGroupDetailMap.put(index.getLevel1Index()+index.getLevel5Index(),templateEntity); + buildIndexGroupDetail(templateEntity, indexDictEntity, index, 5); + indexGroupDetailMap.put(index.getLevel1Index() + index.getLevel5Index(), templateEntity); } } //} @@ -228,13 +228,13 @@ public class IndexExcelDataListener extends AnalysisEventListener { LOGGER.info("所有指标分组明细数据解析完成:{}", JSON.toJSONString(indexGroupDetailMap.values())); } - private void buildIndexGroupDetail( IndexGroupDetailTemplateEntity templateEntity,IndexDictEntity indexDictEntity, IndexModel index, IndexGroupTemplateEntity parentGroup, Integer level) { + private void buildIndexGroupDetail(IndexGroupDetailTemplateEntity templateEntity, IndexDictEntity indexDictEntity, IndexModel index, Integer level) { if (level == 5) { - templateEntity.setIndexCode(Pinyin4jUtil.getSpellPinYin(index.getLevel5Index(),false,4 )); + templateEntity.setIndexCode(Pinyin4jUtil.getSpellPinYin(index.getLevel5Index(), false, 4)); String level5WeightStr = index.getLevel5Weight().replace("%", ""); templateEntity.setWeight(new BigDecimal(level5WeightStr).divide(new BigDecimal(100), 4, RoundingMode.HALF_UP)); } else { - templateEntity.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(),false,4 )); + templateEntity.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(), false, 4)); templateEntity.setWeight(new BigDecimal(index.getWeight()).divide(new BigDecimal(100), 4, RoundingMode.HALF_UP)); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/CpcIndexCalculateServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/CpcIndexCalculateServiceImpl.java index c15620850d..aa937dc3d6 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 @@ -84,11 +84,12 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { totalEntity = ConvertUtils.sourceToTarget(part, CpcScoreEntity.class); totalEntity.setIsTotal(NumConstant.ONE_STR); totalEntity.setIndexCode(indexGroupDetailEntity.getIndexCode()); + totalEntity.setScore(new BigDecimal(0)); cpcScoreTotalMap.put(userId, totalEntity); } //todo 自建群活跃度——议题转项目率 有阈值 >60%按60%算 BigDecimal total = part.getScore().multiply(indexGroupDetailEntity.getWeight()); - log.debug("userId:{},分数:{},权重:{},total:{}", userId, part.getScore(), indexGroupDetailEntity.getWeight(), total); + log.info("userId:{},分数:{},权重:{},total:{}", userId, part.getScore(), indexGroupDetailEntity.getWeight(), total); totalEntity.setScore(totalEntity.getScore().add(total)); } }); @@ -225,6 +226,8 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { indexInputVO.setIndexId(index.getIndexCode()); //权重 indexInputVO.setWeight(index.getWeight()); + //阈值 + indexInputVO.setThreshold(index.getThreshold()); BigDecimal minValue = null; BigDecimal maxValue = null; From 73012448d1869eab543f0bae61b7dd5e34529540 Mon Sep 17 00:00:00 2001 From: wxz Date: Tue, 1 Sep 2020 10:17:02 +0800 Subject: [PATCH 14/22] =?UTF-8?q?=E5=88=86=E5=80=BC=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=EF=BC=8C=E5=8E=BB=E6=8E=89=E6=97=A0=E5=8F=82?= =?UTF-8?q?=E6=9E=84=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/support/normalizing/batch/IndexInputVO.java | 1 - 1 file changed, 1 deletion(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexInputVO.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexInputVO.java index 47ca728d5a..abf62aef2b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexInputVO.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexInputVO.java @@ -10,7 +10,6 @@ import java.util.List; @Data @AllArgsConstructor -@NoArgsConstructor public class IndexInputVO { /** From 358ced173b7f1851514f797be1a96aa402a11ce7 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Tue, 1 Sep 2020 10:20:39 +0800 Subject: [PATCH 15/22] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=98=88=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/GridCorreLationServiceImpl.java | 208 ++++++++++-------- 1 file changed, 121 insertions(+), 87 deletions(-) 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 7897c2560b..98a35e93fe 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,6 +2,7 @@ package com.epmet.service.indexcal.impl; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.constant.IndexCalConstant; import com.epmet.dao.indexcoll.FactIndexGovrnAblityGridMonthlyDao; @@ -70,33 +71,45 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { @Override public Boolean calculateGridCorreLation(CalculateCommonFormDTO formDTO) { boolean resultFlag = false; + //1、计算网格相关-党建能力 List dangJianNengLiList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode(), IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); - if (!CollectionUtils.isEmpty(dangJianNengLiList)) { - //1、计算网格相关-党建能力 - calculateGridDangJian(formDTO, dangJianNengLiList); + if (CollectionUtils.isEmpty(dangJianNengLiList)) { + logger.warn("calculateGridDangJian customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); + throw new RenException("客户【网格相关:党建能力】指标权重信息不存在"); } + calculateGridDangJian(formDTO, dangJianNengLiList); + + //2、计算网格相关-治理能力 List zhiLiNengLiList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode(), IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); - if (!CollectionUtils.isEmpty(zhiLiNengLiList)) { - //2、计算网格相关-治理能力 - calculateGridZhiLi(formDTO, zhiLiNengLiList); + if (CollectionUtils.isEmpty(zhiLiNengLiList)) { + logger.warn("calculateGridZhiLi customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); + throw new RenException("客户【网格相关:治理能力】指标权重信息不存在"); } + calculateGridZhiLi(formDTO, zhiLiNengLiList); + + //3、计算网格相关-服务能力 List fuWuNengLiList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode(), IndexCodeEnum.FU_WU_NENG_LI.getCode()); - if (!CollectionUtils.isEmpty(fuWuNengLiList)) { - //3、计算网格相关-服务能力 - calculateGridFuWu(formDTO, fuWuNengLiList); + if (CollectionUtils.isEmpty(fuWuNengLiList)) { + logger.warn("calculateGridFuWu customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); + throw new RenException("客户【网格相关:服务能力】指标权重信息不存在"); } - //计算网格相关总分 + calculateGridFuWu(formDTO, fuWuNengLiList); + + //4、计算网格相关总分 List wgxgList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode()); - if (!CollectionUtils.isEmpty(wgxgList)) { - calculateGridTotal(formDTO, wgxgList,IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode()); + if (CollectionUtils.isEmpty(wgxgList)) { + logger.warn("calculateGridTotal customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); + throw new RenException("客户【网格相关】指标权重信息不存在"); } + calculateGridTotal(formDTO, wgxgList, IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode()); + resultFlag = true; return resultFlag; } @@ -122,9 +135,13 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { logger.info(String.format("共%s条数据,分%s次计算", total, totalPage)); //每一组指标的最大值,key:code_MIN/MAX Map minAndMaxMap = queryPartyAblityGridMinAndMax(formDTO.getCustomerId(), formDTO.getMonthId()); + if (CollectionUtils.isEmpty(minAndMaxMap)) { + logger.error("calculateGridDangJian queryPartyAblityGridMinAndMax customerId:{} monthId:{} have not any fact record", formDTO.getCustomerId(),formDTO.getMonthId()); + return; + } //指标集合 - Map> indexMap = getGridCorrelationIndexInputVO(formDTO, indexList, minAndMaxMap); - List> resultMapList=new ArrayList<>(); + Map> indexMap = buildGridCorrelationIndexInputVO(formDTO, indexList, minAndMaxMap); + List> resultMapList = new ArrayList<>(); //分页查询采集记录 for (int pageNo = 1; pageNo <= totalPage; pageNo++) { int pageIndex = (pageNo - NumConstant.ONE) * IndexCalConstant.PAGE_SIZE; @@ -149,8 +166,8 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { //组织内党员的联系群众能力考评分(平均值) logger.info("组织内党员的联系群众能力考评分(平均值) 单独处理"); //网格内党员的联系群众能力考评分(平均值) - String gridId=(String) recordMap.get(IndexCalConstant.GRID_ID); - BigDecimal contactMassesAvgValue = getGridContactMassesAvgValue(formDTO,gridId); + String gridId = (String) recordMap.get(IndexCalConstant.GRID_ID); + BigDecimal contactMassesAvgValue = getGridContactMassesAvgValue(formDTO, gridId); SampleValue contactMassesAblityValue = new SampleValue((String) recordMap.get(IndexCalConstant.GRID_ID), contactMassesAvgValue); value.getIndexValueVOs().add(contactMassesAblityValue); } @@ -160,96 +177,96 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { resultMapList.add(resultMap); } // 保存中间表 - saveGridCorreLationDangJian(formDTO, resultMapList,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),NumConstant.ZERO_STR); + saveGridCorreLationResult(formDTO, resultMapList, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), NumConstant.ZERO_STR); } /** - * @return java.util.Map * @param calculateCommonFormDTO + * @return java.util.Map * @author yinzuomei * @description 获取网格内党员的联系群众能力考评分(平均值)的最大值,最小值 * @Date 2020/8/31 9:51 **/ 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); + 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)); + 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 + * @param gridId 网格id + * @return java.math.BigDecimal * @author yinzuomei * @description 获取网格(组织)内党员的联系群众能力考评分(平均值) * @Date 2020/8/31 9:50 **/ - private BigDecimal getGridContactMassesAvgValue(CalculateCommonFormDTO calculateCommonFormDTO,String gridId) { - BigDecimal result=cpcScoreDao.selectGridContactMassesAvgValue(calculateCommonFormDTO.getCustomerId(),calculateCommonFormDTO.getMonthId(),gridId); - if(null==result){ + 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; } /** - * @return java.math.BigDecimal * @param formDTO * @param gridId + * @return java.math.BigDecimal * @author yinzuomei - * @description 组织内党员的参与议事能力考评分(平均值) + * @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){ + 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 + * @return java.util.Map * @author yinzuomei * @description 网格内党员的参与议事能力考评分(平均值) 最大值最小值 * @Date 2020/8/31 14:41 **/ - private Map getJoinIssueAblityMap(CalculateCommonFormDTO calculateCommonFormDTO){ - Map map=new HashMap<>(); - List list=cpcScoreDao.selectListJoinIssueAvgValue(calculateCommonFormDTO); - if(!CollectionUtils.isEmpty(list)){ - BigDecimal minValue=Collections.min(list); - BigDecimal maxValue=Collections.max(list); - map.put(StrConstant.MIN,minValue); - map.put(StrConstant.MAX,maxValue); + 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)); + 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 formDTO 客户id 月份id: yyyyMM * @param resultMapList - * @param indexCode 指标编码 - * @param isTotal 1:总分;0不是 + * @param indexCode 指标编码: 党建能力:dangjiannengli;治理能力:zhilinengli;服务能力:fuwunengli; + * @param isTotal 1:总分;0不是 * @return void * @author yinzuomei * @description 保存网格相关三大能力值 * @Date 2020/8/30 22:50 **/ - private void saveGridCorreLationDangJian(CalculateCommonFormDTO formDTO, + private void saveGridCorreLationResult(CalculateCommonFormDTO formDTO, List> resultMapList, String indexCode, String isTotal) { @@ -277,7 +294,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { }); } if (!CollectionUtils.isEmpty(gridScoreEntityList)) { - gridScoreDao.deleteByCusAndMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode,isTotal); + gridScoreDao.deleteByCusAndMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode, isTotal); gridScoreDao.insertBatches(gridScoreEntityList); } } @@ -286,21 +303,24 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { * @param indexMap * @return java.util.List * @author yinzuomei - * @description + * @description 调用计算器计算每个指标下,各个网格的总分 * @Date 2020/8/30 21:40 **/ private HashMap calculate(Map> indexMap) { //构造入参 List indexInputVOS = this.getIndexInputVOList(indexMap); + logger.info("计算的参数:{}", indexInputVOS); BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); - return batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); + HashMap resultMap = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); + logger.info("计算的结果:{}", resultMap); + return resultMap; } /** * @param indexMap * @return java.util.List * @author yinzuomei - * @description + * @description map遍历,转为List * @Date 2020/8/30 18:34 **/ private List getIndexInputVOList(Map> indexMap) { @@ -321,13 +341,14 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { * @description 构造网格相关 指标计算参数 * @Date 2020/8/30 15:56 **/ - private Map> getGridCorrelationIndexInputVO(CalculateCommonFormDTO formDTO, List indexList, Map minAndMaxMap) { + private Map> buildGridCorrelationIndexInputVO(CalculateCommonFormDTO formDTO, List indexList, Map minAndMaxMap) { Map> map = new HashMap<>(); - for (int indexNum = 0; indexNum < indexList.size(); indexNum++) { - IndexGroupDetailEntity index = indexList.get(indexNum); + for (IndexGroupDetailEntity index : indexList) { IndexInputVO indexInputVO = new IndexInputVO(); // 指标code indexInputVO.setIndexId(index.getIndexCode()); + //阈值 + indexInputVO.setThreshold(index.getThreshold()); //权重 indexInputVO.setWeight(index.getWeight()); BigDecimal minValue = null; @@ -335,22 +356,22 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { if (IndexCodeEnum.ZUZHINEIDANGYDLXQZNLKPFPJZ.getCode().equals(index.getIndexCode())) { //组织内党员的联系群众能力考评分(平均值) 获取最大值,最小值 logger.info("组织内党员的联系群众能力考评分(平均值) 单独处理"); - Map contactMassesAblityMap= this.getContactMassesAblityMap(formDTO); - minValue=contactMassesAblityMap.get(StrConstant.MIN); - maxValue=contactMassesAblityMap.get(StrConstant.MAX); - }else if(IndexCodeEnum.ZUZHINEIDANGYDSYYSNLKPFPJZ.getCode().equals(index.getIndexCode())){ + 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); + Map joinIssueAblityMap = this.getJoinIssueAblityMap(formDTO); + minValue = joinIssueAblityMap.get(StrConstant.MIN); + maxValue = joinIssueAblityMap.get(StrConstant.MAX); } else { //获取指标对应的列名 String fieldName = indexCodeFieldReService.getFieldNameByIndexCode(index.getIndexCode()); - if(StringUtils.isBlank(fieldName)){ - logger.error("index_code:"+index.getIndexCode()+" not find field_name"); + if (StringUtils.isBlank(fieldName)) { + logger.error("index_code:{} ",index.getIndexCode(),"not find field_name"); continue; } - logger.info("INDEX_CODE=" + index.getIndexCode()+";FIELD_ID=" + fieldName ); + logger.info("index_code:{} ",index.getIndexCode(),"field_id :{} ",fieldName); String minValueKey = fieldName.concat(StrConstant.UNDER_LINE).concat(StrConstant.MIN); String maxValueKey = fieldName.concat(StrConstant.UNDER_LINE).concat(StrConstant.MAX); minValue = new BigDecimal(String.valueOf(minAndMaxMap.get(minValueKey))); @@ -392,9 +413,13 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { logger.info(String.format("共%s条数据,分%s次计算", total, totalPage)); //每一组指标的最大值,key:code_MIN/MAX Map minAndMaxMap = queryGovrnAblityGridMinAndMax(formDTO.getCustomerId(), formDTO.getMonthId()); + if (CollectionUtils.isEmpty(minAndMaxMap)) { + logger.error("calculateGridZhiLi queryGovrnAblityGridMinAndMax customerId:{} monthId:{} have not any fact record", formDTO.getCustomerId(),formDTO.getMonthId()); + return; + } //指标集合 - Map> indexMap = getGridCorrelationIndexInputVO(formDTO, indexList, minAndMaxMap); - List> resultMapList=new ArrayList<>(); + Map> indexMap = buildGridCorrelationIndexInputVO(formDTO, indexList, minAndMaxMap); + List> resultMapList = new ArrayList<>(); //分页查询采集记录 for (int pageNo = 1; pageNo <= totalPage; pageNo++) { int pageIndex = (pageNo - NumConstant.ONE) * IndexCalConstant.PAGE_SIZE; @@ -417,8 +442,8 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { 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); + 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); } @@ -428,7 +453,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { resultMapList.add(resultMap); } // 保存中间表 - saveGridCorreLationDangJian(formDTO, resultMapList,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),NumConstant.ZERO_STR); + saveGridCorreLationResult(formDTO, resultMapList, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), NumConstant.ZERO_STR); } @@ -452,9 +477,13 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { logger.info(String.format("共%s条数据,分%s次计算", total, totalPage)); //每一组指标的最大值,key:code_MIN/MAX Map minAndMaxMap = queryServiceAblityGridMinAndMax(formDTO.getCustomerId(), formDTO.getMonthId()); + if (CollectionUtils.isEmpty(minAndMaxMap)) { + logger.error("calculateGridFuWu queryServiceAblityGridMinAndMax customerId:{} monthId:{} have not any fact record", formDTO.getCustomerId(),formDTO.getMonthId()); + return; + } //指标集合 - Map> indexMap = getGridCorrelationIndexInputVO(formDTO, indexList, minAndMaxMap); - List> resultMapList=new ArrayList<>(); + Map> indexMap = buildGridCorrelationIndexInputVO(formDTO, indexList, minAndMaxMap); + List> resultMapList = new ArrayList<>(); //分页查询采集记录 for (int pageNo = 1; pageNo <= totalPage; pageNo++) { int pageIndex = (pageNo - NumConstant.ONE) * IndexCalConstant.PAGE_SIZE; @@ -475,8 +504,8 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { //构造样本值对象 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"); + } else { + logger.error("index_code:" + key + " not find field_name"); } }); }); @@ -484,7 +513,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { resultMapList.add(resultMap); } // 保存中间表 - saveGridCorreLationDangJian(formDTO, resultMapList,IndexCodeEnum.FU_WU_NENG_LI.getCode(),NumConstant.ZERO_STR); + saveGridCorreLationResult(formDTO, resultMapList, IndexCodeEnum.FU_WU_NENG_LI.getCode(), NumConstant.ZERO_STR); } /** @@ -498,9 +527,13 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { private void calculateGridTotal(CalculateCommonFormDTO formDTO, List indexList, String indexCode) { //查询总记录数 List gridScoreDTOList = gridScoreDao.selectList(formDTO); + if(CollectionUtils.isEmpty(gridScoreDTOList)){ + logger.error("calculateGridTotal gridScoreDao.selectList return empty,customerId:{},monthId:{}", formDTO.getCustomerId(), formDTO.getMonthId()); + throw new RenException("客户一级指标分值记录不存在"); + } Map indexMap = indexList.stream().collect(Collectors.toMap(IndexGroupDetailEntity::getIndexCode, Function.identity())); List gridScoreEntityList = new ArrayList<>(); - for(GridScoreDTO gridScoreDTO:gridScoreDTOList){ + for (GridScoreDTO gridScoreDTO : gridScoreDTOList) { GridScoreEntity gridScoreEntity = new GridScoreEntity(); gridScoreEntity.setCustomerId(gridScoreDTO.getCustomerId()); gridScoreEntity.setGridId(gridScoreDTO.getGridId()); @@ -512,12 +545,12 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { gridScoreEntity.setYearId(gridScoreDTO.getYearId()); gridScoreEntity.setMonthId(gridScoreDTO.getMonthId()); gridScoreEntity.setScore(BigDecimal.ZERO); - if(!CollectionUtils.isEmpty(gridScoreDTO.getDetailList())&&gridScoreDTO.getDetailList().size()!=3){ - logger.error("customerId:"+gridScoreDTO.getCustomerId()+";gridId:"+gridScoreDTO.getGridId()+";monthId:"+gridScoreDTO.getMonthId()+"能力值缺失,无法计算总值"); + if (!CollectionUtils.isEmpty(gridScoreDTO.getDetailList()) && gridScoreDTO.getDetailList().size() != 3) { + logger.error("customerId:" + gridScoreDTO.getCustomerId() + ";gridId:" + gridScoreDTO.getGridId() + ";monthId:" + gridScoreDTO.getMonthId() + "能力值缺失,无法计算总值"); continue; } - for(GridScoreDetailDTO gridScoreDetailDTO:gridScoreDTO.getDetailList()){ - BigDecimal indexScore=gridScoreDetailDTO.getScore().multiply(indexMap.get(gridScoreDetailDTO.getIndexCode()).getWeight()); + for (GridScoreDetailDTO gridScoreDetailDTO : gridScoreDTO.getDetailList()) { + BigDecimal indexScore = gridScoreDetailDTO.getScore().multiply(indexMap.get(gridScoreDetailDTO.getIndexCode()).getWeight()); gridScoreEntity.setScore(gridScoreEntity.getScore().add(indexScore)); } gridScoreEntityList.add(gridScoreEntity); @@ -529,12 +562,13 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { } public static void main(String[] args) { - BigDecimal totalScore=BigDecimal.ZERO; - for(int i=1;i<5;i++){ - totalScore=totalScore.add(new BigDecimal("1.00")); + 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 From 1f62005bcb953122426798719abbec0f3b3b3a1b Mon Sep 17 00:00:00 2001 From: wxz Date: Tue, 1 Sep 2020 10:21:34 +0800 Subject: [PATCH 16/22] =?UTF-8?q?=E5=88=86=E5=80=BC=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=EF=BC=8C=E5=8E=BB=E6=8E=89=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E6=9E=84=E9=80=A0=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/support/normalizing/batch/IndexInputVO.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexInputVO.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexInputVO.java index abf62aef2b..c67b1c494d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexInputVO.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexInputVO.java @@ -34,10 +34,4 @@ public class IndexInputVO { private BigDecimal weight; private ScoreCalculator scoreCalculator; - - public IndexInputVO(List> indexValueVOs, BigDecimal weight, ScoreCalculator scoreCalculator) { - this.indexValueVOs = indexValueVOs; - this.weight = weight; - this.scoreCalculator = scoreCalculator; - } } From 10fa49c2b23c86fdc80f5d2afdd4743fb3ca861e Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 1 Sep 2020 10:27:37 +0800 Subject: [PATCH 17/22] =?UTF-8?q?=E7=A4=BE=E5=8C=BA=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/constant/IndexCalConstant.java | 14 + .../FactIndexCommunityGovrnFiveScoreDTO.java | 109 ----- .../FactIndexCommunityPartyFiveScoreDTO.java | 110 ------ .../screen/FactIndexCommunityScoreDTO.java | 55 ++- ...FactIndexCommunityServiceFiveScoreDTO.java | 107 ----- .../CommunityActivityCountResultDTO.java | 59 +++ ...CommunityPublishArticleCountResultDTO.java | 5 + .../result/MaxAndMinBigDecimalResultDTO.java | 21 + .../result/SubGridGovernAvgResultDTO.java | 46 +++ .../result/SubGridPartyAvgResultDTO.java | 5 + .../result/SubGridServiceAvgResultDTO.java | 51 +++ .../com/epmet/controller/DemoController.java | 20 +- .../FactIndexGovrnAblityOrgMonthlyDao.java | 3 +- .../FactIndexServiceAblityOrgMonthlyDao.java | 11 + .../FactIndexCommunityGovrnFiveScoreDao.java | 33 -- .../FactIndexCommunityPartyFiveScoreDao.java | 45 --- .../screen/FactIndexCommunityScoreDao.java | 35 +- ...FactIndexCommunityServiceFiveScoreDao.java | 33 -- .../dao/screen/FactIndexGridScoreDao.java | 20 + ...=> FactIndexCommunityFiveScoreEntity.java} | 4 +- ...actIndexCommunityGovrnFiveScoreEntity.java | 77 ---- .../screen/FactIndexCommunityScoreEntity.java | 34 +- ...tIndexCommunityServiceFiveScoreEntity.java | 77 ---- .../IndexCalculateCommunityService.java | 23 +- .../IndexCalculateCommunityServiceImpl.java | 373 +++++++++++++++--- .../FactIndexGovrnAblityOrgMonthlyDao.xml | 24 +- .../FactIndexPartyAblityOrgMonthlyDao.xml | 3 +- .../FactIndexServiceAblityOrgMonthlyDao.xml | 19 + .../FactIndexCommunityGovrnFiveScoreDao.xml | 6 - .../FactIndexCommunityPartyFiveScoreDao.xml | 27 -- .../screen/FactIndexCommunityScoreDao.xml | 56 +++ .../FactIndexCommunityServiceFiveScoreDao.xml | 6 - .../mapper/screen/FactIndexGridScoreDao.xml | 44 ++- 33 files changed, 819 insertions(+), 736 deletions(-) delete mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityGovrnFiveScoreDTO.java delete mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityPartyFiveScoreDTO.java delete mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityServiceFiveScoreDTO.java create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/CommunityActivityCountResultDTO.java create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/MaxAndMinBigDecimalResultDTO.java create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridGovernAvgResultDTO.java create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridServiceAvgResultDTO.java delete mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityGovrnFiveScoreDao.java delete mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityPartyFiveScoreDao.java delete mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityServiceFiveScoreDao.java rename epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/{FactIndexCommunityPartyFiveScoreEntity.java => FactIndexCommunityFiveScoreEntity.java} (92%) delete mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityGovrnFiveScoreEntity.java delete mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityServiceFiveScoreEntity.java delete mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityGovrnFiveScoreDao.xml delete mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityPartyFiveScoreDao.xml delete mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityServiceFiveScoreDao.xml 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 13b27760a5..12b5c2a136 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/IndexCalConstant.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/IndexCalConstant.java @@ -20,4 +20,18 @@ public interface IndexCalConstant { String USER_ID="USER_ID"; String YEAR_ID = "YEAR_ID"; + + String COMMUNITY_GOVERN = "zhilinengli"; + + String COMMUNITY_PARTY = "dangjiannengli"; + + String COMMUNITY_SERVICE = "fuwunengli"; + + String COMMUNITY_SERVICE_AVG = "shequxiajisywgfwnldfpjz"; + + String COMMUNITY_GOVERN_AVG = "shequxiashusywgzlnlhzpyz"; + + String COMMUNITY_PARTY_AVG = "xiazhusuoyouwgddjnlpjz"; + + String COMMUNITY_RELATE = "shequxiangguan"; } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityGovrnFiveScoreDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityGovrnFiveScoreDTO.java deleted file mode 100644 index 5f2fbf85b7..0000000000 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityGovrnFiveScoreDTO.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * Copyright 2018 人人开源 https://www.renren.io - *

- * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - *

- * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.epmet.dto.screen; - -import java.io.Serializable; -import java.math.BigDecimal; - -import lombok.Data; - -/** - * 社区相关-治理能力【五级权重】分数表 - * - * @author generator generator@elink-cn.com - * @since v1.0.0 2020-08-27 - */ -@Data -public class FactIndexCommunityGovrnFiveScoreDTO implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * - */ - private String id; - - /** - * 机关iD - */ - private String agencyId; - - /** - * 月份ID - */ - private String monthId; - - /** - * 指标ID - */ - private String indexId; - - /** - * 总指数分值 - */ - private BigDecimal totalScore; - - /** - * 党建能力分值 - */ - private BigDecimal partyAbilityScore; - - /** - * 治理能力分值 - */ - private BigDecimal govrnAbilityScore; - - /** - * 服务能力分值 - */ - private BigDecimal serviceAbilityScore; - - /** - * 删除状态,0正常,1删除 - */ - private Integer delFlag; - - /** - * 乐观锁 - */ - private Integer revision; - - /** - * 创建人 - */ - private String createdBy; - - /** - * 更新人 - */ - private String updatedBy ; - - public FactIndexCommunityGovrnFiveScoreDTO() { - this.agencyId = ""; - this.monthId = ""; - this.indexId = ""; - this.totalScore = new BigDecimal(0); - this.partyAbilityScore = new BigDecimal(0); - this.govrnAbilityScore = new BigDecimal(0); - this.serviceAbilityScore = new BigDecimal(0); - this.delFlag = 0; - this.revision = 0; - this.createdBy = "APP_USER"; - this.updatedBy = "APP_USER"; - } -} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityPartyFiveScoreDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityPartyFiveScoreDTO.java deleted file mode 100644 index 79024c60ca..0000000000 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityPartyFiveScoreDTO.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * Copyright 2018 人人开源 https://www.renren.io - *

- * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - *

- * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.epmet.dto.screen; - -import java.io.Serializable; -import java.math.BigDecimal; - -import lombok.Data; - -/** - * 社区相关-党建能力【五级权重】分数表 - * - * @author generator generator@elink-cn.com - * @since v1.0.0 2020-08-27 - */ -@Data -public class FactIndexCommunityPartyFiveScoreDTO implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * id - */ - private String id; - - /** - * 机关ID - */ - private String agencyId; - - /** - * 月度ID - */ - private String monthId; - - /** - * 指标ID - */ - private String indexId; - - /** - * 总指数分值 - */ - private BigDecimal totalScore; - - /** - * 党建能力分值 - */ - private BigDecimal partyAbilityScore; - - /** - * 治理能力分值 - */ - private BigDecimal govrnAbilityScore; - - /** - * 服务能力分值 - */ - private BigDecimal serviceAbilityScore; - - /** - * 删除状态,0正常,1删除 - */ - private Integer delFlag; - - /** - * 乐观锁 - */ - private Integer revision; - - /** - * 创建人 - */ - private String createdBy; - - /** - * 更新人 - */ - private String updatedBy; - - public FactIndexCommunityPartyFiveScoreDTO() { - this.agencyId = ""; - this.monthId = ""; - this.indexId = ""; - this.totalScore = new BigDecimal(0); - this.partyAbilityScore = new BigDecimal(0); - this.govrnAbilityScore = new BigDecimal(0); - this.serviceAbilityScore = new BigDecimal(0); - this.delFlag = 0; - this.revision = 0; - this.createdBy = "APP_USER"; - this.updatedBy = "APP_USER"; - } - -} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityScoreDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityScoreDTO.java index 805e28ef7f..8ad2ec6658 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityScoreDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityScoreDTO.java @@ -27,7 +27,7 @@ import java.math.BigDecimal; * 社区相关分数表 * * @author generator generator@elink-cn.com - * @since v1.0.0 2020-08-27 + * @since v1.0.0 2020-08-31 */ @Data public class FactIndexCommunityScoreDTO implements Serializable { @@ -35,49 +35,59 @@ public class FactIndexCommunityScoreDTO implements Serializable { private static final long serialVersionUID = 1L; /** - * + * ID 主键 */ private String id; /** - * 机关ID + * 客户Id + */ + private String customerId; + + /** + * 组织id */ private String agencyId; /** - * 月份ID + * 社区上一级组织id */ - private String monthId; + private String parentAgencyId; + + /** + * 年度ID: yyyy + */ + private String yearId; /** - * 季度ID + * 季度id: yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4 */ private String quarterId; /** - * 年度ID + * 月维度Id: yyyyMM */ - private String yearId; + private String monthId; /** - * 指标ID + * 1:总分;0不是;默认0 */ - private String indexId; + private String isTotal; /** - * 分数 + * 分值 */ private BigDecimal score; /** - * 党建能力:party,治理能力:govrn,服务能力:service + * 党建能力:dangjiannengli;治理能力:zhilinengli;服务能力:fuwunengli;社区相关:shequxiangguan */ - private String type; + private String indexCode; /** - * 删除状态,0正常,1删除 + * 删除状态 */ - private Integer delFlag; + private Integer delFlag; /** * 乐观锁 @@ -104,4 +114,19 @@ public class FactIndexCommunityScoreDTO implements Serializable { */ private Date updatedTime; + public FactIndexCommunityScoreDTO() { + this.customerId = ""; + this.agencyId = ""; + this.parentAgencyId = ""; + this.yearId = ""; + this.quarterId = ""; + this.monthId = ""; + this.isTotal = "0"; + this.score = new BigDecimal(0); + this.indexCode = ""; + this.delFlag = 0; + this.revision = 0; + this.createdBy = "APP_USER"; + this.updatedBy = "APP_USER"; + } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityServiceFiveScoreDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityServiceFiveScoreDTO.java deleted file mode 100644 index 1eb6386bcc..0000000000 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityServiceFiveScoreDTO.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * Copyright 2018 人人开源 https://www.renren.io - *

- * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - *

- * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.epmet.dto.screen; - -import java.io.Serializable; -import java.util.Date; -import lombok.Data; - -import java.math.BigDecimal; - -/** - * 社区相关-服务能力【五级权重】分数表 - * - * @author generator generator@elink-cn.com - * @since v1.0.0 2020-08-27 - */ -@Data -public class FactIndexCommunityServiceFiveScoreDTO implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * - */ - private String id; - - /** - * 机关ID - */ - private String agencyId; - - /** - * 月度ID - */ - private String monthId; - - /** - * 指标ID - */ - private String indexId; - - /** - * 总指数分值 - */ - private BigDecimal totalScore; - - /** - * 党建能力分值 - */ - private BigDecimal partyAbilityScore; - - /** - * 治理能力分值 - */ - private BigDecimal govrnAbilityScore; - - /** - * 服务能力分值 - */ - private BigDecimal serviceAbilityScore; - - /** - * 删除状态,0正常,1删除 - */ - private Integer delFlag; - - /** - * 乐观锁 - */ - private Integer revision; - - /** - * 创建人 - */ - private String createdBy; - - /** - * 创建时间 - */ - private Date createdTime; - - /** - * 更新人 - */ - private String updatedBy; - - /** - * 更新时间 - */ - private Date updatedTime; - -} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/CommunityActivityCountResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/CommunityActivityCountResultDTO.java new file mode 100644 index 0000000000..ec3b17f615 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/CommunityActivityCountResultDTO.java @@ -0,0 +1,59 @@ +package com.epmet.dto.screen.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2020/8/31 2:12 下午 + */ +@Data +public class CommunityActivityCountResultDTO implements Serializable { + + private static final long serialVersionUID = -6623426101220283941L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 机关ID + */ + private String agencyId; + + /** + * 上级组织ID + */ + private String parentId; + + /** + * 月度ID + */ + private String monthId; + + /** + * 季度ID + */ + private String quarterId; + + /** + * 年度ID + */ + private String yearId; + + /** + * 发文数 + */ + public Integer activityCount; + + public CommunityActivityCountResultDTO() { + this.agencyId = ""; + this.parentId = ""; + this.monthId = ""; + this.quarterId = ""; + this.yearId = ""; + this.activityCount = 0; + } +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/CommunityPublishArticleCountResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/CommunityPublishArticleCountResultDTO.java index fe50bbf597..cf29133001 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/CommunityPublishArticleCountResultDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/CommunityPublishArticleCountResultDTO.java @@ -13,6 +13,11 @@ public class CommunityPublishArticleCountResultDTO implements Serializable { private static final long serialVersionUID = -8260746179353253237L; + /** + * 客户ID + */ + private String customerId; + /** * 机关ID */ diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/MaxAndMinBigDecimalResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/MaxAndMinBigDecimalResultDTO.java new file mode 100644 index 0000000000..aa9f471405 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/MaxAndMinBigDecimalResultDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dto.screen.result; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @Author zxc + * @DateTime 2020/8/30 8:11 下午 + */ +@Data +public class MaxAndMinBigDecimalResultDTO implements Serializable { + + private static final long serialVersionUID = 76227645470470839L; + + private BigDecimal min; + + private BigDecimal max; + +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridGovernAvgResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridGovernAvgResultDTO.java new file mode 100644 index 0000000000..64f3cc7319 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridGovernAvgResultDTO.java @@ -0,0 +1,46 @@ +package com.epmet.dto.screen.result; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @Author zxc + * @DateTime 2020/8/31 9:11 上午 + */ +@Data +public class SubGridGovernAvgResultDTO implements Serializable { + + private static final long serialVersionUID = -1354963771895272899L; + + /** + * 机关ID + */ + private String agencyId; + + /** + * 上级组织ID + */ + private String parentId; + + /** + * 月度ID + */ + private String monthId; + + /** + * 季度ID + */ + private String quarterId; + + /** + * 年度ID + */ + private String yearId; + + /** + * 分数 + */ + private BigDecimal score; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridPartyAvgResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridPartyAvgResultDTO.java index 38263c4dc1..48b4501606 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridPartyAvgResultDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridPartyAvgResultDTO.java @@ -19,6 +19,11 @@ public class SubGridPartyAvgResultDTO implements Serializable { */ private String agencyId; + /** + * 客户ID + */ + private String customerId; + /** * 上级组织ID */ diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridServiceAvgResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridServiceAvgResultDTO.java new file mode 100644 index 0000000000..ba6329aef1 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridServiceAvgResultDTO.java @@ -0,0 +1,51 @@ +package com.epmet.dto.screen.result; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @Author zxc + * @DateTime 2020/8/31 1:53 下午 + */ +@Data +public class SubGridServiceAvgResultDTO implements Serializable { + + private static final long serialVersionUID = -405197363477213644L; + + /** + * + */ + private String customerId; + + /** + * 机关ID + */ + private String agencyId; + + /** + * 上级组织ID + */ + private String parentId; + + /** + * 月度ID + */ + private String monthId; + + /** + * 季度ID + */ + private String quarterId; + + /** + * 年度ID + */ + private String yearId; + + /** + * 分数 + */ + private BigDecimal score; +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java index 5f18b920f9..2b88f53f42 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java @@ -120,7 +120,25 @@ public class DemoController { @PostMapping("zxc") public Result getZxc(){ // indexCalculateCommunityService.communityPublishArticleCountCalculate("b09527201c4409e19d1dbc5e3c3429a1","202008"); - indexCalculateCommunityService.communityPublishArticleCountCalculate("","202008"); + indexCalculateCommunityService.communityGovernAbilityCalculate("b09527201c4409e19d1dbc5e3c3429a1","202008"); + return new Result(); + } + + @PostMapping("zxc1") + public Result getZxc1(){ + indexCalculateCommunityService.communityPartyCalculate("b09527201c4409e19d1dbc5e3c3429a1","202008"); + return new Result(); + } + + @PostMapping("zxc2") + public Result getZxc2(){ + indexCalculateCommunityService.communityServiceAbilityCalculate("b09527201c4409e19d1dbc5e3c3429a1","202008"); + return new Result(); + } + + @PostMapping("zxcAll") + public Result getZxcAll(){ + indexCalculateCommunityService.communityRelate("b09527201c4409e19d1dbc5e3c3429a1","202008"); return new Result(); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java index fa9b8569b9..f28e6a2fd3 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java @@ -25,6 +25,7 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; +import java.util.Map; /** * 治理能力-街道及社区相关数据 @@ -70,5 +71,5 @@ public interface FactIndexGovrnAblityOrgMonthlyDao extends BaseDao selectCommunityGovernAbility(@Param("customerId")String customerId, @Param("monthId")String monthId); + List> selectCommunityGovernAbility(@Param("customerId")String customerId, @Param("monthId")String monthId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexServiceAblityOrgMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexServiceAblityOrgMonthlyDao.java index 31c268cd75..261fb8b945 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexServiceAblityOrgMonthlyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexServiceAblityOrgMonthlyDao.java @@ -19,6 +19,8 @@ package com.epmet.dao.indexcoll; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.indexcollect.form.OrgServiceAbilityFormDTO; +import com.epmet.dto.screen.result.CommunityActivityCountResultDTO; +import com.epmet.dto.screen.result.CommunityPublishArticleCountResultDTO; import com.epmet.entity.indexcoll.FactIndexServiceAblityOrgMonthlyEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -62,4 +64,13 @@ public interface FactIndexServiceAblityOrgMonthlyDao extends BaseDao list, @Param("customerId")String customerId); + + /** + * @Description 社区活动组织次数 + * @param customerId + * @param monthId + * @author zxc + * @date 2020/8/31 2:15 下午 + */ + List selectActivityCount(@Param("customerId")String customerId, @Param("monthId")String monthId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityGovrnFiveScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityGovrnFiveScoreDao.java deleted file mode 100644 index 52cd149927..0000000000 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityGovrnFiveScoreDao.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright 2018 人人开源 https://www.renren.io - *

- * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - *

- * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.epmet.dao.screen; - -import com.epmet.commons.mybatis.dao.BaseDao; -import com.epmet.entity.screen.FactIndexCommunityGovrnFiveScoreEntity; -import org.apache.ibatis.annotations.Mapper; - -/** - * 社区相关-治理能力【五级权重】分数表 - * - * @author generator generator@elink-cn.com - * @since v1.0.0 2020-08-27 - */ -@Mapper -public interface FactIndexCommunityGovrnFiveScoreDao extends BaseDao { - -} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityPartyFiveScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityPartyFiveScoreDao.java deleted file mode 100644 index 4c628a1ec0..0000000000 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityPartyFiveScoreDao.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright 2018 人人开源 https://www.renren.io - *

- * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - *

- * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.epmet.dao.screen; - -import com.epmet.commons.mybatis.dao.BaseDao; -import com.epmet.dto.screen.FactIndexCommunityPartyFiveScoreDTO; -import com.epmet.entity.screen.FactIndexCommunityPartyFiveScoreEntity; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -/** - * 社区相关-党建能力【五级权重】分数表 - * - * @author generator generator@elink-cn.com - * @since v1.0.0 2020-08-27 - */ -@Mapper -public interface FactIndexCommunityPartyFiveScoreDao extends BaseDao { - - /** - * @Description 党建能力【社区】中间表插入 - * @param lists - * @author zxc - * @date 2020/8/27 5:05 下午 - */ - void insertCommunityPartyRecord(@Param("lists")List lists); - -} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityScoreDao.java index 9ea796d24a..607132ea18 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityScoreDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityScoreDao.java @@ -18,16 +18,47 @@ package com.epmet.dao.screen; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.screen.FactIndexCommunityScoreDTO; import com.epmet.entity.screen.FactIndexCommunityScoreEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 社区相关分数表 * * @author generator generator@elink-cn.com - * @since v1.0.0 2020-08-27 + * @since v1.0.0 2020-08-31 */ @Mapper public interface FactIndexCommunityScoreDao extends BaseDao { - + + /** + * @Description 党建能力【社区】中间表插入 + * @param lists + * @author zxc + * @date 2020/8/27 5:05 下午 + */ + void insertCommunityPartyRecord(@Param("lists") List lists); + + /** + * @Description 删除旧记录 + * @param customerId + * @param monthId + * @param indexCode + * @author zxc + * @date 2020/9/1 9:03 上午 + */ + void deleteOldRecord(@Param("customerId") String customerId,@Param("monthId")String monthId,@Param("indexCode")String indexCode); + + /** + * @Description 查询社区相关信息 + * @param customerId + * @param monthId + * @author zxc + * @date 2020/9/1 9:41 上午 + */ + List selectCommunityInfo(@Param("customerId") String customerId,@Param("monthId")String monthId); + } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityServiceFiveScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityServiceFiveScoreDao.java deleted file mode 100644 index 97a03ad2c9..0000000000 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexCommunityServiceFiveScoreDao.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright 2018 人人开源 https://www.renren.io - *

- * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - *

- * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.epmet.dao.screen; - -import com.epmet.commons.mybatis.dao.BaseDao; -import com.epmet.entity.screen.FactIndexCommunityServiceFiveScoreEntity; -import org.apache.ibatis.annotations.Mapper; - -/** - * 社区相关-服务能力【五级权重】分数表 - * - * @author generator generator@elink-cn.com - * @since v1.0.0 2020-08-27 - */ -@Mapper -public interface FactIndexCommunityServiceFiveScoreDao extends BaseDao { - -} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexGridScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexGridScoreDao.java index b95b41ff55..223a297db4 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexGridScoreDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/FactIndexGridScoreDao.java @@ -18,7 +18,9 @@ package com.epmet.dao.screen; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.screen.result.SubGridGovernAvgResultDTO; import com.epmet.dto.screen.result.SubGridPartyAvgResultDTO; +import com.epmet.dto.screen.result.SubGridServiceAvgResultDTO; import com.epmet.entity.screen.FactIndexGridScoreEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -43,4 +45,22 @@ public interface FactIndexGridScoreDao extends BaseDao */ List selectSubGridPartyAvgScore(@Param("customerId")String customerId,@Param("monthId")String monthId); + /** + * @Description 社区下属所有网格治理能力汇总平均值 + * @param customerId + * @param monthId + * @author zxc + * @date 2020/8/31 9:19 上午 + */ + List selectSubGridGovernAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId); + + /** + * @Description 社区下级所有网格服务能力得分平均值 + * @param customerId + * @param monthId + * @author zxc + * @date 2020/8/31 1:51 下午 + */ + List selectSubGridServiceAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId); + } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityPartyFiveScoreEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityFiveScoreEntity.java similarity index 92% rename from epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityPartyFiveScoreEntity.java rename to epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityFiveScoreEntity.java index c42849dd0b..b43e51ad7c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityPartyFiveScoreEntity.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityFiveScoreEntity.java @@ -34,8 +34,8 @@ import java.util.Date; */ @Data @EqualsAndHashCode(callSuper=false) -@TableName("fact_index_community_party_five_score") -public class FactIndexCommunityPartyFiveScoreEntity extends BaseEpmetEntity { +@TableName("fact_index_community_five_score") +public class FactIndexCommunityFiveScoreEntity extends BaseEpmetEntity { private static final long serialVersionUID = 1L; diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityGovrnFiveScoreEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityGovrnFiveScoreEntity.java deleted file mode 100644 index bf0bcbeac0..0000000000 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityGovrnFiveScoreEntity.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Copyright 2018 人人开源 https://www.renren.io - *

- * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - *

- * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.epmet.entity.screen; - -import com.baomidou.mybatisplus.annotation.TableName; - -import com.epmet.commons.mybatis.entity.BaseEpmetEntity; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.math.BigDecimal; -import java.util.Date; - -/** - * 社区相关-治理能力【五级权重】分数表 - * - * @author generator generator@elink-cn.com - * @since v1.0.0 2020-08-27 - */ -@Data -@EqualsAndHashCode(callSuper=false) -@TableName("fact_index_community_govrn_five_score") -public class FactIndexCommunityGovrnFiveScoreEntity extends BaseEpmetEntity { - - private static final long serialVersionUID = 1L; - - /** - * 机关iD - */ - private String agencyId; - - /** - * 月份ID - */ - private String monthId; - - /** - * 季度ID - */ - private String quarterId; - - /** - * 年度ID - */ - private String yearId; - - /** - * 指标ID - */ - private String indexId; - - /** - * 分数 - */ - private BigDecimal score; - - /** - * 社区被吹哨次数:transfered,社区办结项目数:closed_project,社区项目响应度:resp_project_ratio,社区超期项目率:overdue_project_ratio,社区办结项目率:closed_project_ratio,社区办结项目满意度:satisfaction_ratio - */ - private String type; - -} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityScoreEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityScoreEntity.java index 1c3899ef2d..01b0ff363f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityScoreEntity.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityScoreEntity.java @@ -30,7 +30,7 @@ import java.util.Date; * 社区相关分数表 * * @author generator generator@elink-cn.com - * @since v1.0.0 2020-08-27 + * @since v1.0.0 2020-08-31 */ @Data @EqualsAndHashCode(callSuper=false) @@ -40,38 +40,48 @@ public class FactIndexCommunityScoreEntity extends BaseEpmetEntity { private static final long serialVersionUID = 1L; /** - * 机关ID + * 客户Id + */ + private String customerId; + + /** + * 组织id */ private String agencyId; /** - * 月份ID + * 社区上一级组织id */ - private String monthId; + private String parentAgencyId; + + /** + * 年度ID: yyyy + */ + private String yearId; /** - * 季度ID + * 季度id: yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4 */ private String quarterId; /** - * 年度ID + * 月维度Id: yyyyMM */ - private String yearId; + private String monthId; /** - * 指标ID + * 1:总分;0不是;默认0 */ - private String indexId; + private String isTotal; /** - * 分数 + * 分值 */ private BigDecimal score; /** - * 党建能力:party,治理能力:govrn,服务能力:service + * 党建能力:dangjiannengli;治理能力:zhilinengli;服务能力:fuwunengli;社区相关:shequxiangguan */ - private String type; + private String indexCode; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityServiceFiveScoreEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityServiceFiveScoreEntity.java deleted file mode 100644 index 8d0fb8857f..0000000000 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/screen/FactIndexCommunityServiceFiveScoreEntity.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Copyright 2018 人人开源 https://www.renren.io - *

- * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - *

- * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.epmet.entity.screen; - -import com.baomidou.mybatisplus.annotation.TableName; - -import com.epmet.commons.mybatis.entity.BaseEpmetEntity; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.math.BigDecimal; -import java.util.Date; - -/** - * 社区相关-服务能力【五级权重】分数表 - * - * @author generator generator@elink-cn.com - * @since v1.0.0 2020-08-27 - */ -@Data -@EqualsAndHashCode(callSuper=false) -@TableName("fact_index_community_service_five_score") -public class FactIndexCommunityServiceFiveScoreEntity extends BaseEpmetEntity { - - private static final long serialVersionUID = 1L; - - /** - * 机关ID - */ - private String agencyId; - - /** - * 月度ID - */ - private String monthId; - - /** - * 季度ID - */ - private String quarterId; - - /** - * 年度ID - */ - private String yearId; - - /** - * 指标ID - */ - private String indexId; - - /** - * 分数 - */ - private BigDecimal score; - - /** - * 社区活动组织次数:activity - */ - private String type; - -} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexCalculateCommunityService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexCalculateCommunityService.java index daf11c1519..f597e3748f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexCalculateCommunityService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexCalculateCommunityService.java @@ -12,13 +12,13 @@ import java.util.List; public interface IndexCalculateCommunityService { /** - * @Description 社区名义发文数量计算 + * @Description 社区党建能力 * @param customerId * @param monthId * @author zxc * @date 2020/8/26 10:46 上午 */ - void communityPublishArticleCountCalculate(String customerId, String monthId); + void communityPartyCalculate(String customerId, String monthId); /** * @Description 社区治理能力 @@ -27,6 +27,23 @@ public interface IndexCalculateCommunityService { * @author zxc * @date 2020/8/26 1:40 下午 */ - void CommunityGovernAbilityCalculate(String customerId, String monthId); + void communityGovernAbilityCalculate(String customerId, String monthId); + /** + * @Description 社区服务能力 + * @param customerId + * @param monthId + * @author zxc + * @date 2020/8/31 1:38 下午 + */ + void communityServiceAbilityCalculate(String customerId, String monthId); + + /** + * @Description 社区相关计算 + * @param customerId + * @param monthId + * @author zxc + * @date 2020/9/1 9:21 上午 + */ + void communityRelate(String customerId, String monthId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateCommunityServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateCommunityServiceImpl.java index 15e0b36ff7..89554a0cf2 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateCommunityServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateCommunityServiceImpl.java @@ -1,30 +1,25 @@ package com.epmet.service.screen.impl; +import com.alibaba.druid.util.StringUtils; import com.epmet.commons.tools.constant.NumConstant; -import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.constant.IndexCalConstant; import com.epmet.dao.indexcoll.FactIndexGovrnAblityOrgMonthlyDao; -import com.epmet.dao.indexcoll.FactIndexPartyAblityCpcMonthlyDao; import com.epmet.dao.indexcoll.FactIndexPartyAblityOrgMonthlyDao; +import com.epmet.dao.indexcoll.FactIndexServiceAblityOrgMonthlyDao; import com.epmet.dao.screen.*; -import com.epmet.dto.indexcal.ExtremeValueCommonDTO; -import com.epmet.dto.screen.FactIndexCommunityPartyFiveScoreDTO; +import com.epmet.dto.screen.FactIndexCommunityScoreDTO; import com.epmet.dto.screen.result.*; import com.epmet.entity.screen.IndexGroupDetailEntity; import com.epmet.eum.IndexCodeEnum; import com.epmet.service.indexcal.IndexCodeFieldReService; import com.epmet.service.screen.IndexCalculateCommunityService; import com.epmet.service.screen.IndexGroupDetailService; -import com.epmet.support.normalizing.Correlation; -import com.epmet.support.normalizing.IntegerScoreCalculator; -import com.epmet.support.normalizing.ScoreCalculator; -import com.epmet.support.normalizing.ScoreConstants; +import com.epmet.support.normalizing.*; import com.epmet.support.normalizing.batch.BatchScoreCalculator; import com.epmet.support.normalizing.batch.IndexInputVO; import com.epmet.support.normalizing.batch.IndexOutputVO; import com.epmet.support.normalizing.batch.SampleValue; -import com.github.pagehelper.Page; -import com.github.pagehelper.PageHelper; -import io.swagger.models.auth.In; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -48,19 +43,15 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni @Autowired private FactIndexGovrnAblityOrgMonthlyDao factIndexGovrnAblityOrgMonthlyDao; @Autowired + private FactIndexServiceAblityOrgMonthlyDao factIndexServiceAblityOrgMonthlyDao; + @Autowired private IndexGroupDetailService indexGroupDetailService; @Autowired private IndexCodeFieldReService indexCodeFieldReService; @Autowired - private FactIndexCommunityPartyFiveScoreDao factIndexCommunityPartyFiveScoreDao; + private FactIndexCommunityScoreDao factIndexCommunityScoreDao; @Autowired private FactIndexGridScoreDao factIndexGridScoreDao; - @Autowired - private FactIndexCommunityServiceFiveScoreDao factIndexCommunityServiceFiveScoreDao; - @Autowired - private FactIndexCommunityGovrnFiveScoreDao factIndexCommunityGovrnFiveScoreDao; - @Autowired - private FactIndexCommunityScoreDao factIndexCommunityScoreDao; /** * @Description 社区名义发文数量计算【党建能力】 @@ -70,32 +61,48 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni */ @Transactional(rollbackFor = Exception.class) @Override - public void communityPublishArticleCountCalculate(String customerId, String monthId) { + public void communityPartyCalculate(String customerId, String monthId) { customerId = "b09527201c4409e19d1dbc5e3c3429a1"; // 党建能力 // 根据all_parent_index_code 获取指标明细 List detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(),IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); - - List subAllGridList = new ArrayList<>(); - List communityPublishArticle = new ArrayList<>(); - + List subAllGridList = new ArrayList<>(); + List communityPublishArticle = new ArrayList<>(); //下属所有网格的党建能力平均值 String finalCustomerId = customerId; detailListByParentCode.forEach(indexGroup -> { - if (indexGroup.getIndexCode().equals("xiazhusuoyouwgddjnlpjz")){ + if (indexGroup.getIndexCode().equals(IndexCalConstant.COMMUNITY_PARTY_AVG)){ List subGridPartyAvgScore = factIndexGridScoreDao.selectSubGridPartyAvgScore(finalCustomerId, monthId); if (subGridPartyAvgScore.size() != NumConstant.ZERO){ - subGridPartyAvgScore.forEach(subGridParty -> { - BigDecimal multiply = subGridParty.getScore().multiply(indexGroup.getWeight()); - subGridParty.setScore(multiply); - FactIndexCommunityPartyFiveScoreDTO dto = new FactIndexCommunityPartyFiveScoreDTO(); - BeanUtils.copyProperties(subGridParty,dto); - dto.setIndexId(indexGroup.getIndexId()); - dto.setTotalScore(dto.getPartyAbilityScore()); - subAllGridList.add(dto); - }); - factIndexCommunityPartyFiveScoreDao.insertCommunityPartyRecord(subAllGridList); + MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridPartyAvgScore.stream().map(o -> o.getScore()).collect(Collectors.toList())); + Integer indexStart = NumConstant.ZERO; + Integer indexEnd = NumConstant.TEN; + List collect; + do { + collect = subGridPartyAvgScore.stream().skip(indexEnd * indexStart).limit(indexEnd).collect(Collectors.toList()); + BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); + List index1SampleValues = new ArrayList<>(); + collect.forEach(c -> { + SampleValue s = new SampleValue(c.getAgencyId(), c.getScore()); + index1SampleValues.add(s); + FactIndexCommunityScoreDTO dto = new FactIndexCommunityScoreDTO(); + BeanUtils.copyProperties(c,dto); + subAllGridList.add(dto); + }); + IndexInputVO index1VO = new IndexInputVO(indexGroup.getIndexId(), index1SampleValues,indexGroup.getThreshold(), indexGroup.getWeight(), sc1); + List indexInputVOS = Arrays.asList(index1VO); + BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); + List result = batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS); + result.get(NumConstant.ZERO).getIndexScoreVOs().forEach(agency -> { + subAllGridList.forEach(grid -> { + if (grid.getAgencyId().equals(agency.getSampleId())){ + grid.setScore(agency.getSampleScore()); + } + }); + }); + indexStart++; + }while (collect.size() == NumConstant.TEN); } } }); @@ -105,13 +112,13 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni if (indexGroup.getIndexCode().equals("shequmingyifwsl")) { if (publishArticleCounts.size() == NumConstant.ONE) { //TODO 计算之后的分数 - FactIndexCommunityPartyFiveScoreDTO dto = new FactIndexCommunityPartyFiveScoreDTO(); + FactIndexCommunityScoreDTO dto = new FactIndexCommunityScoreDTO(); BeanUtils.copyProperties(detailListByParentCode.get(NumConstant.ZERO), dto); - dto.setPartyAbilityScore(BigDecimal.valueOf(50.00)); - dto.setIndexId(detailListByParentCode.get(NumConstant.ZERO).getIndexId()); + dto.setScore(BigDecimal.valueOf(50.00)); + dto.setIndexCode(detailListByParentCode.get(NumConstant.ZERO).getIndexCode()); communityPublishArticle.add(dto); - factIndexCommunityPartyFiveScoreDao.insertCommunityPartyRecord(communityPublishArticle); - } else if (publishArticleCounts.size() != NumConstant.ZERO) { + factIndexCommunityScoreDao.insertCommunityPartyRecord(communityPublishArticle); + } else if (publishArticleCounts.size() > NumConstant.ONE) { Integer indexStart = NumConstant.ZERO; Integer indexEnd = NumConstant.TEN; List collect; @@ -123,32 +130,37 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni collect.forEach(c -> { SampleValue s = new SampleValue(c.getAgencyId(), c.getPublishArticleCount()); ll.add(s); - FactIndexCommunityPartyFiveScoreDTO publishArticle = new FactIndexCommunityPartyFiveScoreDTO(); + FactIndexCommunityScoreDTO publishArticle = new FactIndexCommunityScoreDTO(); BeanUtils.copyProperties(c,publishArticle); communityPublishArticle.add(publishArticle); }); - IndexInputVO index1VO = new IndexInputVO<>(indexGroup.getIndexId(), ll, indexGroup.getWeight(), sc1); + IndexInputVO index1VO = new IndexInputVO<>(indexGroup.getIndexId(), ll,indexGroup.getThreshold(), indexGroup.getWeight(), sc1); List indexInputVOS = Arrays.asList(index1VO); BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); List result = batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS); result.get(NumConstant.ZERO).getIndexScoreVOs().forEach(agency -> { communityPublishArticle.forEach(publish -> { if (publish.getAgencyId().equals(agency.getSampleId())){ - publish.setIndexId(indexGroup.getIndexId()); - publish.setPartyAbilityScore(agency.getSampleScore()); - publish.setTotalScore(agency.getSampleScore()); + publish.setIndexCode(indexGroup.getIndexCode()); + publish.setScore(agency.getSampleScore()); } }); }); indexStart++; - } while (collect.size() == 10); - factIndexCommunityPartyFiveScoreDao.insertCommunityPartyRecord(communityPublishArticle); + } while (collect.size() == NumConstant.TEN); } } }); - - - + subAllGridList.forEach(grid -> { + communityPublishArticle.forEach(publish -> { + if (grid.getAgencyId().equals(publish.getAgencyId())){ + grid.setScore(grid.getScore().add(publish.getScore())); + grid.setIndexCode(IndexCalConstant.COMMUNITY_PARTY); + } + }); + }); + factIndexCommunityScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.COMMUNITY_PARTY); + factIndexCommunityScoreDao.insertCommunityPartyRecord(subAllGridList); } /** @@ -160,21 +172,260 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni */ @Transactional(rollbackFor = Exception.class) @Override - public void CommunityGovernAbilityCalculate(String customerId, String monthId) { - List communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbility(customerId, monthId); + public void communityGovernAbilityCalculate(String customerId, String monthId) { + customerId = "b09527201c4409e19d1dbc5e3c3429a1"; + + List subAllGridList = new ArrayList<>(); + + List detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); + + String finalCustomerId = customerId; + detailListByParentCode.forEach(detail -> { + if (detail.getIndexCode().equals(IndexCalConstant.COMMUNITY_GOVERN_AVG)){ + List subGridGovernAvg = factIndexGridScoreDao.selectSubGridGovernAvgScore(finalCustomerId, monthId); + if (subGridGovernAvg.size() == NumConstant.ONE){ + + // TODO + + }else if (subGridGovernAvg.size() > NumConstant.ONE){ + MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridGovernAvg.stream().map(o -> o.getScore()).collect(Collectors.toList())); + Integer indexStart = NumConstant.ZERO; + Integer indexEnd = NumConstant.TEN; + List collect; + do { + collect = subGridGovernAvg.stream().skip(indexEnd * indexStart).limit(indexEnd).collect(Collectors.toList()); + BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); + List index1SampleValues = new ArrayList<>(); + collect.forEach(c -> { + SampleValue s = new SampleValue(c.getAgencyId(), c.getScore()); + index1SampleValues.add(s); + FactIndexCommunityScoreDTO dto = new FactIndexCommunityScoreDTO(); + BeanUtils.copyProperties(c,dto); + subAllGridList.add(dto); + }); + IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold() ,detail.getWeight(), sc1); + List indexInputVOS = Arrays.asList(index1VO); + BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); + HashMap scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); + scoreCountOfSampleId.forEach((key,value) -> { + subAllGridList.forEach(grid -> { + if (grid.getAgencyId().equals(key)){ + grid.setScore(value); + } + }); + }); + indexStart++; + }while (collect.size() == NumConstant.TEN); + } + } + else { + + } + }); + + List> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbility(finalCustomerId, monthId); if (communityGovernAbility.size() == NumConstant.ONE){ - List result = new ArrayList<>(); - CommunityGovernAbilityCalculateResultDTO governAbility = new CommunityGovernAbilityCalculateResultDTO(); - BeanUtils.copyProperties(communityGovernAbility.get(NumConstant.ZERO),governAbility); - // TODO 计算之后的分数 + // TODO - result.add(governAbility); + }else if (communityGovernAbility.size() > NumConstant.ONE){ + List indexInputVOS = new ArrayList<>(); + detailListByParentCode.forEach(detail -> { + String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode()); + if (!StringUtils.isEmpty(fieldNameByIndexCode)){ + if (communityGovernAbility.get(NumConstant.ZERO).containsKey(fieldNameByIndexCode)) { + List decimalList = communityGovernAbility.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList()); + MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(decimalList); + Integer indexStart = NumConstant.ZERO; + Integer indexEnd = NumConstant.TEN; + List> collect; + do { + collect = communityGovernAbility.stream().skip(indexEnd * indexStart).limit(indexEnd).collect(Collectors.toList()); + ScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); + List index1SampleValues = new ArrayList<>(); + collect.forEach(c -> { + SampleValue s = new SampleValue((String) c.get(IndexCalConstant.AGENCY_ID), new BigDecimal(String.valueOf(c.get(fieldNameByIndexCode)))); + index1SampleValues.add(s); + }); + IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1); + indexInputVOS.add(index1VO); + } while (collect.size() == NumConstant.TEN); + BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); + HashMap scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); + scoreCountOfSampleId.forEach((key,value) -> { + subAllGridList.forEach(grid -> { + if (key.equals(grid.getAgencyId())) { + grid.setCustomerId(finalCustomerId); + grid.setIndexCode(IndexCalConstant.COMMUNITY_GOVERN); + grid.setScore(grid.getScore().add(value)); + } + }); + }); + } + } + }); } + factIndexCommunityScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.COMMUNITY_GOVERN); + factIndexCommunityScoreDao.insertCommunityPartyRecord(subAllGridList); } + /** + * @Description 社区服务能力 + * @param customerId + * @param monthId + * @author zxc + * @date 2020/8/31 1:38 下午 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void communityServiceAbilityCalculate(String customerId, String monthId) { + + + List subAllGridList = new ArrayList<>(); + List communityPublishArticle = new ArrayList<>(); + + + List detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), IndexCodeEnum.FU_WU_NENG_LI.getCode()); + detailListByParentCode.forEach(detail -> { + switch (detail.getIndexCode()){ + case IndexCalConstant.COMMUNITY_SERVICE_AVG: + List subGridServiceAvg = factIndexGridScoreDao.selectSubGridServiceAvgScore(customerId, monthId); + if (subGridServiceAvg.size() == NumConstant.ONE){ + + // TODO 只有一条记录时 + + }else if (subGridServiceAvg.size() > NumConstant.ONE ){ + MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridServiceAvg.stream().map(o -> o.getScore()).collect(Collectors.toList())); + Integer indexStart = NumConstant.ZERO; + Integer indexEnd = NumConstant.TEN; + List collect; + do { + collect = subGridServiceAvg.stream().skip(indexEnd * indexStart).limit(indexEnd).collect(Collectors.toList()); + BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); + List index1SampleValues = new ArrayList<>(); + collect.forEach(c -> { + SampleValue s = new SampleValue(c.getAgencyId(), c.getScore()); + index1SampleValues.add(s); + FactIndexCommunityScoreDTO dto = new FactIndexCommunityScoreDTO(); + BeanUtils.copyProperties(c,dto); + subAllGridList.add(dto); + }); + IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues,detail.getThreshold(), detail.getWeight(), sc1); + List indexInputVOS = Arrays.asList(index1VO); + BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); + List result = batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS); + result.get(NumConstant.ZERO).getIndexScoreVOs().forEach(agency -> { + subAllGridList.forEach(grid -> { + if (grid.getAgencyId().equals(agency.getSampleId())){ + grid.setScore(agency.getSampleScore()); + } + }); + }); + indexStart++; + }while (collect.size() == NumConstant.TEN); + } + break; + case "shequhuodongzzcs": + List communityActivityCount = factIndexServiceAblityOrgMonthlyDao.selectActivityCount(customerId, monthId); + if (communityActivityCount.size() == NumConstant.ONE){ + + // TODO + + }else if (communityActivityCount.size() > NumConstant.ONE){ + Integer indexStart = NumConstant.ZERO; + Integer indexEnd = NumConstant.TEN; + List collect; + MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(communityActivityCount.stream().map(o -> new BigDecimal(o.getActivityCount())).collect(Collectors.toList())); + do { + collect = communityActivityCount.stream().skip(indexEnd * indexStart).limit(indexEnd).collect(Collectors.toList()); + ScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); + List> ll = new ArrayList<>(); + collect.forEach(c -> { + SampleValue s = new SampleValue(c.getAgencyId(), c.getActivityCount()); + ll.add(s); + FactIndexCommunityScoreDTO publishArticle = new FactIndexCommunityScoreDTO(); + BeanUtils.copyProperties(c,publishArticle); + communityPublishArticle.add(publishArticle); + }); + IndexInputVO index1VO = new IndexInputVO<>(detail.getIndexId(), ll, detail.getThreshold(),detail.getWeight(), sc1); + List indexInputVOS = Arrays.asList(index1VO); + BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); + List result = batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS); + result.get(NumConstant.ZERO).getIndexScoreVOs().forEach(agency -> { + communityPublishArticle.forEach(publish -> { + if (publish.getAgencyId().equals(agency.getSampleId())){ + publish.setScore(agency.getSampleScore()); + } + }); + }); + indexStart++; + } while (collect.size() == NumConstant.TEN); + } + break; + default: + } + }); + subAllGridList.forEach(grid -> { + grid.setIndexCode(IndexCalConstant.COMMUNITY_SERVICE); + communityPublishArticle.forEach(publish -> { + if (grid.getAgencyId().equals(publish.getAgencyId())){ + grid.setScore(grid.getScore().add(publish.getScore())); + grid.setCustomerId(customerId); + } + }); + }); + factIndexCommunityScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.COMMUNITY_SERVICE); + factIndexCommunityScoreDao.insertCommunityPartyRecord(subAllGridList); + + } + + /** + * @Description 社区相关计算 + * @param customerId + * @param monthId + * @author zxc + * @date 2020/9/1 9:21 上午 + */ + @Override + public void communityRelate(String customerId, String monthId) { + + this.communityPartyCalculate(customerId, monthId); //党建能力 + this.communityGovernAbilityCalculate(customerId, monthId); // 治理能力 + this.communityServiceAbilityCalculate(customerId, monthId); // 服务能力 + + List communityPublishArticle = new ArrayList<>(); + + List detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode()); + List factIndexCommunityScoreEntities = factIndexCommunityScoreDao.selectCommunityInfo(customerId, monthId); + detailListByParentCode.forEach(detail -> { + factIndexCommunityScoreEntities.forEach(community -> { + if (detail.getIndexCode().equals(community.getIndexCode())){ + community.setScore(community.getScore().multiply(detail.getWeight())); + } + }); + }); + + Map> collect = factIndexCommunityScoreEntities.stream().collect(Collectors.groupingBy(FactIndexCommunityScoreDTO::getAgencyId)); + List result = new ArrayList<>(); + collect.forEach((key,value) -> { + FactIndexCommunityScoreDTO score = new FactIndexCommunityScoreDTO(); + score.setIsTotal(NumConstant.ONE_STR); + score.setCustomerId(customerId); + score.setAgencyId(key); + score.setMonthId(monthId); + score.setYearId(DateUtils.getYearId(monthId)); + score.setQuarterId(DateUtils.getQuarterId(monthId)); + factIndexCommunityScoreEntities.forEach(community -> { + score.setScore(score.getScore().add(community.getScore())); + }); + result.add(score); + }); + factIndexCommunityScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.COMMUNITY_RELATE); + factIndexCommunityScoreDao.insertCommunityPartyRecord(result); + } + /** * @Description Integer类型获取最大数和最小数 * @param list @@ -190,6 +441,16 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni return result; } + + public MaxAndMinBigDecimalResultDTO getMaxAndMinBigDecimal(List list){ + BigDecimal max = Collections.max(list); + BigDecimal min = Collections.min(list); + MaxAndMinBigDecimalResultDTO result = new MaxAndMinBigDecimalResultDTO(); + result.setMax(max); + result.setMin(min); + return result; + } + /** * @Description Double类型获取最大数和最小数 * @param list diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml index 11b87f6eb8..76d61d7b83 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml @@ -87,19 +87,19 @@ - SELECT - agency_id AS agencyId, - parent_id AS parentId, - month_id AS monthId, - quarter_id AS quarterId, - year_id AS yearId, - transfered_count AS transferedCount, - closed_project_count AS closedProjectCount, - resp_project_ratio AS respProjectRatio, - overdue_project_ratio AS overDueProjectRatio, - closed_project_ratio AS closedProjectRatio, - satisfaction_ratio AS satisfactionRatio + AGENCY_ID, + PARENT_ID, + MONTH_ID, + QUARTER_ID, + YEAR_ID, + TRANSFERED_COUNT, + CLOSED_PROJECT_COUNT, + RESP_PROJECT_RATIO, + OVERDUE_PROJECT_RATIO, + CLOSED_PROJECT_RATIO, + SATISFACTION_RATIO FROM fact_index_govrn_ablity_org_monthly WHERE diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml index ff41b99bd4..4e6bd0cd6c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml @@ -79,7 +79,8 @@ month_id, quarter_id, year_id, - publish_article_count + publish_article_count, + customer_id FROM fact_index_party_ablity_org_monthly WHERE diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexServiceAblityOrgMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexServiceAblityOrgMonthlyDao.xml index c475e2aca1..d223423e17 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexServiceAblityOrgMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexServiceAblityOrgMonthlyDao.xml @@ -70,4 +70,23 @@ ) + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityGovrnFiveScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityGovrnFiveScoreDao.xml deleted file mode 100644 index 721b8181ef..0000000000 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityGovrnFiveScoreDao.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityPartyFiveScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityPartyFiveScoreDao.xml deleted file mode 100644 index 7110ba2c04..0000000000 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityPartyFiveScoreDao.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - INSERT INTO fact_index_community_party_five_score ( ID, AGENCY_ID, MONTH_ID, INDEX_ID, TOTAL_SCORE, PARTY_ABILITY_SCORE, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME ) - VALUES - - ( - REPLACE ( UUID(), '-', '' ), - #{item.agencyId}, - #{item.monthId}, - #{item.indexId}, - #{item.totalScore}, - #{item.partyAbilityScore}, - #{item.delFlag}, - #{item.revision}, - #{item.createdBy}, - NOW(), - #{item.updatedBy}, - NOW() - ) - - - \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityScoreDao.xml index 54611e0f02..91bebf545b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityScoreDao.xml @@ -3,4 +3,60 @@ + + + INSERT INTO fact_index_community_score ( ID, CUSTOMER_ID, AGENCY_ID, PARENT_AGENCY_ID, YEAR_ID, QUARTER_ID, MONTH_ID, IS_TOTAL, SCORE, INDEX_CODE, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME ) + VALUES + + ( + REPLACE(UUID(),'-',''), + #{item.customerId}, + #{item.agencyId}, + #{item.parentAgencyId}, + #{item.yearId}, + #{item.quarterId}, + #{item.monthId}, + #{item.isTotal}, + #{item.score}, + #{item.indexCode}, + #{item.delFlag}, + #{item.revision}, + #{item.createdBy}, + NOW(), + #{item.updatedBy}, + NOW() + ) + + + + + + DELETE + FROM + fact_index_community_score + WHERE + del_flag = '0' + AND customer_id = #{customerId} + AND month_id = #{monthId} + AND index_code = #{indexCode} + + + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityServiceFiveScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityServiceFiveScoreDao.xml deleted file mode 100644 index 509f723548..0000000000 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityServiceFiveScoreDao.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexGridScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexGridScoreDao.xml index 7e4ad04732..b38cf57c0a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexGridScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexGridScoreDao.xml @@ -8,13 +8,55 @@ SELECT agency_id, month_id, - AVG( party_ablity_score ) AS score + quarter_id, + year_id, + AVG( score ) AS score, + customer_id FROM fact_index_grid_score WHERE del_flag = '0' AND customer_id = #{customerId} AND month_id = #{monthId} + AND index_code = 'dangjiannengli' GROUP BY agency_id + + + + + + \ No newline at end of file From ee00f86b5b6aa0f2725e3bb43eaf5acae8df134b Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 1 Sep 2020 10:27:51 +0800 Subject: [PATCH 18/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E5=BD=92=E4=B8=80=E7=AE=97=E6=B3=95=E6=9E=84=E9=80=A0?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../indexcal/impl/CpcIndexCalculateServiceImpl.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) 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 aa937dc3d6..26ed23abaa 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 @@ -221,13 +221,6 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { private Map> buildIndexInputVO(List indexList, Map minAndMaxMap) { Map> map = new HashMap<>(); for (IndexGroupDetailEntity index : indexList) { - IndexInputVO indexInputVO = new IndexInputVO(); - // 指标code - indexInputVO.setIndexId(index.getIndexCode()); - //权重 - indexInputVO.setWeight(index.getWeight()); - //阈值 - indexInputVO.setThreshold(index.getThreshold()); BigDecimal minValue = null; BigDecimal maxValue = null; @@ -247,10 +240,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { ScoreConstants.MAX_SCORE, Correlation.getCorrelation(index.getCorrelation()) ); - indexInputVO.setScoreCalculator(scoreCalculator); - List> sampleValueList = new ArrayList<>(); - indexInputVO.setIndexValueVOs(sampleValueList); - + IndexInputVO indexInputVO = new IndexInputVO(index.getIndexCode(),new ArrayList>(),index.getWeight(),index.getThreshold(),scoreCalculator); map.put(index.getIndexCode(), indexInputVO); } return map; From ea5250d1f9572fc1bd4ab2c68a7877aae5a80839 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Tue, 1 Sep 2020 10:28:04 +0800 Subject: [PATCH 19/22] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=98=88=E5=80=BCv1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/GridCorreLationServiceImpl.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) 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 98a35e93fe..7fa8281f15 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/GridCorreLationServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/GridCorreLationServiceImpl.java @@ -344,13 +344,13 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { private Map> buildGridCorrelationIndexInputVO(CalculateCommonFormDTO formDTO, List indexList, Map minAndMaxMap) { Map> map = new HashMap<>(); for (IndexGroupDetailEntity index : indexList) { - IndexInputVO indexInputVO = new IndexInputVO(); +// IndexInputVO indexInputVO = new IndexInputVO(); // 指标code - indexInputVO.setIndexId(index.getIndexCode()); +// indexInputVO.setIndexId(index.getIndexCode()); //阈值 - indexInputVO.setThreshold(index.getThreshold()); +// indexInputVO.setThreshold(index.getThreshold()); //权重 - indexInputVO.setWeight(index.getWeight()); +// indexInputVO.setWeight(index.getWeight()); BigDecimal minValue = null; BigDecimal maxValue = null; if (IndexCodeEnum.ZUZHINEIDANGYDLXQZNLKPFPJZ.getCode().equals(index.getIndexCode())) { @@ -384,11 +384,15 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { ScoreConstants.MAX_SCORE, Correlation.getCorrelation(index.getCorrelation()) ); - indexInputVO.setScoreCalculator(scoreCalculator); +// indexInputVO.setScoreCalculator(scoreCalculator); List> sampleValueList = new ArrayList<>(); - indexInputVO.setIndexValueVOs(sampleValueList); - - map.put(index.getIndexCode(), indexInputVO); +// indexInputVO.setIndexValueVOs(sampleValueList); + IndexInputVO indexInputVO1 = new IndexInputVO(index.getIndexCode(), + sampleValueList, + index.getThreshold(), + index.getWeight(), + scoreCalculator); + map.put(index.getIndexCode(), indexInputVO1); } return map; } From 4581826873537ce0faa0e916715a71dda1b3bbd4 Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 1 Sep 2020 10:32:12 +0800 Subject: [PATCH 20/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E5=BD=92=E4=B8=80=E7=AE=97=E6=B3=95=E6=9E=84=E9=80=A0?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/indexcal/impl/CpcIndexCalculateServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 26ed23abaa..c2d8a924cb 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/CpcIndexCalculateServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/CpcIndexCalculateServiceImpl.java @@ -240,7 +240,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { ScoreConstants.MAX_SCORE, Correlation.getCorrelation(index.getCorrelation()) ); - IndexInputVO indexInputVO = new IndexInputVO(index.getIndexCode(),new ArrayList>(),index.getWeight(),index.getThreshold(),scoreCalculator); + IndexInputVO indexInputVO = new IndexInputVO(index.getIndexCode(),new ArrayList<>(),index.getThreshold(),index.getWeight(),scoreCalculator); map.put(index.getIndexCode(), indexInputVO); } return map; From 990a81c5f9bfa3d5c1c7c8cc3b2b52e54f298f88 Mon Sep 17 00:00:00 2001 From: wangchao Date: Tue, 1 Sep 2020 10:57:16 +0800 Subject: [PATCH 21/22] =?UTF-8?q?=E5=85=9A=E5=91=98=E8=81=94=E7=B3=BB?= =?UTF-8?q?=E7=BE=A4=E4=BC=97=E6=9F=B1=E7=8A=B6=E5=9B=BE=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=80=BB=E5=92=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/result/ContactMassLineChartResultDTO.java | 10 ++++++++++ .../screen/impl/PartyMemberLeadServiceImpl.java | 2 ++ 2 files changed, 12 insertions(+) diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/ContactMassLineChartResultDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/ContactMassLineChartResultDTO.java index e57b0cc54f..17e31e33ee 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/ContactMassLineChartResultDTO.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/ContactMassLineChartResultDTO.java @@ -28,4 +28,14 @@ public class ContactMassLineChartResultDTO implements Serializable { * 群成员数 */ private List groupMemberData; + + /** + * 党员建群数 + **/ + private Integer groupTotal; + + /** + * 党成员数 + * */ + private Integer groupMemberTotal; } diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/screen/impl/PartyMemberLeadServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/screen/impl/PartyMemberLeadServiceImpl.java index 902861f5e2..b895b49651 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/screen/impl/PartyMemberLeadServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/screen/impl/PartyMemberLeadServiceImpl.java @@ -110,6 +110,8 @@ public class PartyMemberLeadServiceImpl implements PartyMemberLeadService { result.setXAxis(xAxis); result.setGroupData(groupData); result.setGroupMemberData(groupMemberData); + result.setGroupTotal(groupData.stream().mapToInt(Integer :: intValue).sum()); + result.setGroupMemberTotal(groupMemberData.stream().mapToInt(Integer :: intValue).sum()); return result; } From 5d41c26b04503b9ee92abc67493b149342faa972 Mon Sep 17 00:00:00 2001 From: wangchao Date: Tue, 1 Sep 2020 11:04:02 +0800 Subject: [PATCH 22/22] =?UTF-8?q?=E5=85=9A=E5=91=98=E8=81=94=E7=B3=BB?= =?UTF-8?q?=E7=BE=A4=E4=BC=97=E6=9F=B1=E7=8A=B6=E5=9B=BE=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=BF=94=E5=8F=82dto=E8=AE=BE=E7=BD=AE=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../screen/dto/result/ContactMassLineChartResultDTO.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/ContactMassLineChartResultDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/ContactMassLineChartResultDTO.java index 17e31e33ee..5a2b93acd9 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/ContactMassLineChartResultDTO.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/ContactMassLineChartResultDTO.java @@ -1,5 +1,6 @@ package com.epmet.screen.dto.result; +import com.epmet.commons.tools.constant.NumConstant; import lombok.Data; import java.io.Serializable; @@ -32,10 +33,10 @@ public class ContactMassLineChartResultDTO implements Serializable { /** * 党员建群数 **/ - private Integer groupTotal; + private Integer groupTotal = NumConstant.ZERO; /** * 党成员数 * */ - private Integer groupMemberTotal; + private Integer groupMemberTotal = NumConstant.ZERO; }