diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/DeotScore.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/DeotScore.java new file mode 100644 index 0000000000..351a4e9ad6 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/DeotScore.java @@ -0,0 +1,47 @@ +package com.epmet.dto.indexcal; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 区直部门-相关分值 + * + * @author yinzuomei@elink-cn.com + * @date 2020/9/10 18:13 + */ +@Data +public class DeotScore implements Serializable { + /** + * 部门id + */ + private String deptId; + + /** + * 客户Id + */ + private String customerId; + + /** + * 部门所属的机关Id + */ + private String agencyId; + + /** + * 季度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/DeptScoreDetailDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/DeptScoreDetailDTO.java new file mode 100644 index 0000000000..e5f63cab5b --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/DeptScoreDetailDTO.java @@ -0,0 +1,32 @@ +package com.epmet.dto.indexcal; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 区直部门相关分值 + * + * @author yinzuomei@elink-cn.com + * @date 2020/9/10 17:56 + */ +@Data +public class DeptScoreDetailDTO implements Serializable { + private static final long serialVersionUID = -1520962964833708922L; + + /** + * 1:总分;0不是 + */ + private String isTotal; + + /** + * 分值 + */ + private BigDecimal score; + + /** + * 党建能力:dangjiannengli;治理能力:zhilinengli;服务能力:fuwunengli;网格相关:quzhibumen + */ + private String indexCode; +} 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 6a46b4008d..59ed8ba771 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 @@ -157,6 +157,8 @@ public class DemoController { private FactIndexServiceAblityGridMonthlyDao factIndexServiceAblityGridMonthlyDao; @Autowired private ScreenCustomerGridDao screenCustomerGridDao; + @Autowired + private CpcIndexCalculateService cpcIndexCalculateService; // private static Integer testcal=100; @PostMapping("testcal") @@ -165,7 +167,9 @@ public class DemoController { // //查询总记录数 // List gridScoreDTOList=gridScoreDao.selectList(formDTO); // return new Result>().ok(gridScoreDTOList); -// gridCorreLationService.calculateGridCorreLation(formDTO); + + cpcIndexCalculateService.cpcIndexCalculate(formDTO); + gridCorreLationService.calculateGridCorreLation(formDTO); deptScoreService.calculateDeptCorreLation(formDTO); return new Result(); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/DeptScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/DeptScoreDao.java index cbfa752bb0..c236c31e6c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/DeptScoreDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/DeptScoreDao.java @@ -18,6 +18,8 @@ package com.epmet.dao.evaluationindex.indexcal; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.indexcal.CalculateCommonFormDTO; +import com.epmet.dto.indexcal.DeotScore; import com.epmet.dto.indexcal.SubAgencyScoreAvgResultDTO; import com.epmet.dto.indexcal.DeptScoreDTO; import com.epmet.entity.evaluationindex.indexcal.DeptScoreEntity; @@ -79,7 +81,7 @@ public interface DeptScoreDao extends BaseDao { int deleteByDeptIdAndMonthId(@Param("customerId") String customerId, @Param("monthId")String monthId, @Param("indexCode") String indexCode, - @Param("deleteSize") int deleteSize); + @Param("deleteSize") Integer deleteSize); /** * @return int @@ -89,4 +91,13 @@ public interface DeptScoreDao extends BaseDao { * @Date 2020/9/10 10:40 **/ int insertBatchEntity(@Param("list") List deptScoreEntityList); + + /** + * @return java.util.List + * @param formDTO + * @author yinzuomei + * @description 查询每个部门下所有的指标对应的分值 + * @Date 2020/9/10 18:07 + **/ + List selectList(CalculateCommonFormDTO formDTO); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/DeptSubScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/DeptSubScoreDao.java index d0674e7fbd..fe388c6b6b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/DeptSubScoreDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/DeptSubScoreDao.java @@ -53,8 +53,8 @@ public interface DeptSubScoreDao extends BaseDao { * @description 批量删除 * @Date 2020/9/10 12:28 **/ - int deleteByDeptIdAndMonthId(@Param("customerId") String customerId, + int deleteBatches(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("allParentIndexCode") String allParentIndexCode, - @Param("deleteSize") int deleteSize); + @Param("deleteSize") Integer deleteSize); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/GridScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/GridScoreDao.java index bd0ba82f7e..e4eef189fd 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/GridScoreDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/GridScoreDao.java @@ -40,16 +40,16 @@ public interface GridScoreDao extends BaseDao { * @param customerId * @param monthId * @param indexCode - * @param deleteNum + * @param deleteSize * @return int * @author yinzuomei * @description * @Date 2020/8/31 14:00 **/ - int deleteByCusAndMonthId(@Param("customerId") String customerId, + int deleteBatches(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("indexCode") String indexCode, - @Param("deleteNum") int deleteNum); + @Param("deleteSize") Integer deleteSize); /** * @return int diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/GridSubScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/GridSubScoreDao.java index be9c55c66f..1005fcf781 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/GridSubScoreDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/GridSubScoreDao.java @@ -51,7 +51,7 @@ public interface GridSubScoreDao extends BaseDao { * @description 批量删除 * @Date 2020/9/10 13:36 **/ - int deleteByDeptIdAndMonthId(@Param("customerId") String customerId, + int deleteBatches(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("allParentIndexCode") String allParentIndexCode, @Param("deleteSize") Integer deleteSize); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/DeptScoreServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/DeptScoreServiceImpl.java index 736d30710a..027a7efe27 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/DeptScoreServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/DeptScoreServiceImpl.java @@ -31,9 +31,10 @@ import com.epmet.dao.evaluationindex.indexcal.DeptScoreDao; import com.epmet.dao.evaluationindex.indexcal.DeptSubScoreDao; import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityDeptMonthlyDao; import com.epmet.dao.evaluationindex.screen.ScreenCustomerDeptDao; -import com.epmet.dto.indexcal.CalculateCommonFormDTO; +import com.epmet.dto.indexcal.*; import com.epmet.entity.evaluationindex.indexcal.DeptScoreEntity; import com.epmet.entity.evaluationindex.indexcal.DeptSubScoreEntity; +import com.epmet.entity.evaluationindex.indexcal.GridScoreEntity; import com.epmet.entity.evaluationindex.indexcoll.FactIndexGovrnAblityDeptMonthlyEntity; import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity; import com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity; @@ -63,6 +64,8 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; /** @@ -94,26 +97,38 @@ public class DeptScoreServiceImpl extends BaseServiceImpl indexGroupDetailEntityList = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.QU_ZHI_BU_MEN.getCode(), IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); if (CollectionUtils.isEmpty(indexGroupDetailEntityList)) { log.warn("calculateDeptCorreLation customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); - throw new RenException("客户【区直部门:治理能力】指标权重信息不存在"); + throw new RenException("客户【区直部门:治理能力】下级指标权重信息不存在"); } - log.info(JSON.toJSONString(indexGroupDetailEntityList)); - + // log.info(JSON.toJSONString(indexGroupDetailEntityList)); //1、查询总记录数 int total = factIndexGovrnAblityDeptMonthlyDao.selectCount(formDTO); if (NumConstant.ZERO == total) { log.warn(String.format("customerId=%s,monthId=%s,fact_index_govrn_ablity_dept_monthly have not any fact record", formDTO.getCustomerId(), formDTO.getMonthId())); - return Boolean.FALSE; + return; } //2、计算最大最小值 Map minAndMaxMap = factIndexGovrnAblityDeptMonthlyDao.selectExtremeValue(formDTO); @@ -139,7 +154,61 @@ public class DeptScoreServiceImpl extends BaseServiceImpl 0); - return true; + log.info("区直部门-治理能力- 计算完成"); + } + + /** + * @return void + * @param formDTO + * @author yinzuomei + * @description 区直部门总分 + * @Date 2020/9/10 17:20 + **/ + private void calculateDeptTotalScore(CalculateCommonFormDTO formDTO) { + //计算区直部门总分 + List indexList = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), + IndexCodeEnum.QU_ZHI_BU_MEN.getCode()); + if (CollectionUtils.isEmpty(indexList)) { + log.warn("calculateDeptTotalScore customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); + throw new RenException("客户【区直部门】下级指标权重信息不存在"); + } + //查询总记录数 + List deptScoreDTOList = deptScoreDao.selectList(formDTO); + if(CollectionUtils.isEmpty(deptScoreDTOList)){ + log.error("calculateDeptTotalScore deptScoreDao.selectList return empty,customerId:{},monthId:{}", formDTO.getCustomerId(), formDTO.getMonthId()); + throw new RenException("客户一级指标分值记录不存在"); + } + Map indexMap = indexList.stream().collect(Collectors.toMap(IndexGroupDetailEntity::getIndexCode, Function.identity())); + List deotScoreEntityList = new ArrayList<>(); + for (DeotScore deptScore : deptScoreDTOList) { + DeptScoreEntity deptScoreEntity = ConvertUtils.sourceToTarget(deptScore, DeptScoreEntity.class); + deptScoreEntity.setIsTotal(NumConstant.ONE_STR); + deptScoreEntity.setIndexCode(IndexCodeEnum.QU_ZHI_BU_MEN.getCode()); + deptScoreEntity.setScore(BigDecimal.ZERO); + deptScoreEntity.setAllParentIndexCode(NumConstant.ZERO_STR); + for (DeptScoreDetailDTO deptScoreDetailDTO : deptScore.getDetailList()) { + BigDecimal indexScore = deptScoreDetailDTO.getScore().multiply(indexMap.get(deptScoreDetailDTO.getIndexCode()).getWeight()); + deptScoreEntity.setScore(deptScoreEntity.getScore().add(indexScore)); + } + deotScoreEntityList.add(deptScoreEntity); + } + //先删除 + int effectRow; + do { + effectRow = deptScoreDao.deleteByDeptIdAndMonthId(formDTO.getCustomerId(), + formDTO.getMonthId(), + IndexCodeEnum.QU_ZHI_BU_MEN.getCode(), + IndexCalConstant.DELETE_SIZE); + } while (effectRow > NumConstant.ZERO); + //后新增 + if (!CollectionUtils.isEmpty(deotScoreEntityList)) { + //批量插入 + List> partition = ListUtils.partition(deotScoreEntityList, IndexCalConstant.INSERT_SIZE); + partition.forEach(list -> { + deptScoreDao.insertBatchEntity(list); + }); + } + } /** @@ -165,7 +234,7 @@ public class DeptScoreServiceImpl extends BaseServiceImpl NumConstant.ZERO); + //批量插入 if (!CollectionUtils.isEmpty(gridScoreEntityList)) { - gridScoreDao.deleteByCusAndMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode, IndexCalConstant.DELETE_SIZE); //批量插入 List> partition = ListUtils.partition(gridScoreEntityList, IndexCalConstant.INSERT_SIZE); partition.forEach(list -> { diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java index 0440fd84fd..2545dc4da1 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java @@ -210,7 +210,6 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict List deptScoreAvgList = deptScoreDao.selectGovernDeptScoreAvg(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); if (CollectionUtils.isEmpty(deptScoreAvgList)) { log.error("查询所有直属部门治理能力平均值集合为空"); - return; } else{ MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(deptScoreAvgList.stream().map(o -> o.getScore()).collect(Collectors.toList())); List> governAvg = ListUtils.partition(deptScoreAvgList, IndexCalConstant.PAGE_SIZE); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/DeptScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/DeptScoreDao.xml index e6dff25c3d..f232171208 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/DeptScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/DeptScoreDao.xml @@ -63,7 +63,9 @@ and INDEX_CODE=#{indexCode} - limit #{deleteSize} + + limit #{deleteSize} + @@ -110,4 +112,39 @@ ) + + + + + + + + + + + + + + + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/DeptSubScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/DeptSubScoreDao.xml index 270477f93d..21ca50b196 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/DeptSubScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/DeptSubScoreDao.xml @@ -46,11 +46,13 @@ - + delete from fact_index_dept_sub_score where CUSTOMER_ID = #{customerId} AND MONTH_ID = #{monthId} and ALL_PARENT_INDEX_CODE=#{allParentIndexCode} - limit #{deleteSize} + + limit #{deleteSize} + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridScoreDao.xml index b0970024c6..9fd9adbb43 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridScoreDao.xml @@ -24,7 +24,7 @@ - + DELETE FROM fact_index_grid_score @@ -32,7 +32,9 @@ CUSTOMER_ID = #{customerId} AND MONTH_ID = #{monthId} AND INDEX_CODE = #{indexCode} - limit #{deleteNum} + + limit #{deleteSize} + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridSubScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridSubScoreDao.xml index 85f66f9009..7111976b9d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridSubScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridSubScoreDao.xml @@ -49,7 +49,7 @@ - + DELETE FROM fact_index_grid_sub_score @@ -57,6 +57,8 @@ CUSTOMER_ID = #{customerId} AND MONTH_ID = #{monthId} AND ALL_PARENT_INDEX_CODE = #{allParentIndexCode} - limit #{deleteSize} + + limit #{deleteSize} + \ No newline at end of file