From b96eaef26b767ab8b69f44bbc0d6277e367f4cfd Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Thu, 10 Sep 2020 14:05:40 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=91=E6=A0=BC=E7=9B=B8=E5=85=B3=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=EF=BC=9A=E6=8F=92=E5=85=A5=E4=BA=94=E7=BA=A7=E6=8C=87?= =?UTF-8?q?=E6=A0=87=E6=98=8E=E7=BB=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../indexcal/DeptScoreDao.java | 34 ++-- .../indexcal/DeptSubScoreDao.java | 66 ++------ .../indexcal/GridScoreDao.java | 16 +- .../indexcal/GridSubScoreDao.java | 84 ++-------- .../indexcal/AgencySubScoreEntity.java | 2 +- .../indexcal/CpcSubScoreEntity.java | 2 +- .../indexcal/DeptSubScoreEntity.java | 7 +- .../indexcal/GridSubScoreEntity.java | 2 +- .../indexcal/GridCorreLationService.java | 3 +- .../indexcal/impl/DeptScoreServiceImpl.java | 98 ++++++++---- .../impl/GridCorreLationServiceImpl.java | 119 +++++++++++--- .../evaluationindex/indexcal/DeptScoreDao.xml | 50 +++--- .../indexcal/DeptSubScoreDao.xml | 71 ++------ .../evaluationindex/indexcal/GridScoreDao.xml | 50 +----- .../indexcal/GridSubScoreDao.xml | 151 ++---------------- 15 files changed, 279 insertions(+), 476 deletions(-) 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 4be461b59a..cbfa752bb0 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 @@ -45,17 +45,6 @@ public interface DeptScoreDao extends BaseDao { **/ List selectListDeptScore(@Param("customerId")String customerId, @Param("monthId")String monthId); - /** - * 批量插入 区直部门分值表 - * - * @param list - * @param customerId - * @return void - * @Author zhangyong - * @Date 11:11 2020-09-04 - **/ - void batchInsertDeptScoreData(@Param("list") List list, @Param("customerId")String customerId); - /** * 根据入参查询 区直部门分值表id * @param customerId @@ -79,12 +68,25 @@ public interface DeptScoreDao extends BaseDao { /** * @return int - * @param customerId - * @param monthId - * @param deptId + * @param customerId 客户id + * @param monthId 月id + * @param indexCode 不必填 + * @param deleteSize * @author yinzuomei - * @description + * @description 根据客户id+monthId,删除这个月某个指标所有的数据 一次至多删除50条 * @Date 2020/9/7 14:30 **/ - int deleteByDeptIdAndMonthId(@Param("customerId") String customerId, @Param("monthId")String monthId,@Param("deptId") String deptId); + int deleteByDeptIdAndMonthId(@Param("customerId") String customerId, + @Param("monthId")String monthId, + @Param("indexCode") String indexCode, + @Param("deleteSize") int deleteSize); + + /** + * @return int + * @param deptScoreEntityList + * @author yinzuomei + * @description 批量插入计算结果 + * @Date 2020/9/10 10:40 + **/ + int insertBatchEntity(@Param("list") List deptScoreEntityList); } 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 e084506452..d0674e7fbd 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 @@ -18,12 +18,11 @@ package com.epmet.dao.evaluationindex.indexcal; import com.epmet.commons.mybatis.dao.BaseDao; -import com.epmet.dto.indexcal.DeptScoreDTO; -import com.epmet.dto.indexcal.SubAgencyScoreAvgResultDTO; -import com.epmet.entity.evaluationindex.indexcal.DeptScoreEntity; +import com.epmet.entity.evaluationindex.indexcal.DeptSubScoreEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import javax.annotation.security.PermitAll; import java.util.List; /** @@ -33,60 +32,29 @@ import java.util.List; * @since v1.0.0 2020-09-02 */ @Mapper -public interface DeptSubScoreDao extends BaseDao { +public interface DeptSubScoreDao extends BaseDao { /** - * 根据入参查询 区直部门分值表 记录 - * - * @param customerId - * @param monthId - * @return java.util.List - * @Author zhangyong - * @Date 10:43 2020-09-03 - **/ - List selectListDeptScore(@Param("customerId") String customerId, @Param("monthId") String monthId); - - /** - * 批量插入 区直部门分值表 - * - * @param list - * @param customerId - * @return void - * @Author zhangyong - * @Date 11:11 2020-09-04 - **/ - void batchInsertDeptScoreData(@Param("list") List list, @Param("customerId") String customerId); - - /** - * 根据入参查询 区直部门分值表id - * - * @param customerId - * @param monthId - * @return java.lang.String - * @Author zhangyong - * @Date 10:43 2020-09-03 + * @param insertDeptSubList + * @return int + * @author yinzuomei + * @description 批量插入计算结果 五级指标分数值 + * @Date 2020/9/10 10:39 **/ - List selectListDeptId(@Param("customerId") String customerId, @Param("monthId") String monthId); - - - /** - * @param customerId - * @param monthId - * @param indexCode - * @Description 所有直属部门治理能力平均值 - * @author zxc - * @date 2020/9/4 10:53 上午 - */ - List selectGovernDeptScoreAvg(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("indexCode") String indexCode); + int insertBatchEntity(@Param("list") List insertDeptSubList); /** * @param customerId * @param monthId - * @param deptId + * @param allParentIndexCode + * @param deleteSize 一次至多删除XX条记录 * @return int * @author yinzuomei - * @description - * @Date 2020/9/7 14:30 + * @description 批量删除 + * @Date 2020/9/10 12:28 **/ - int deleteByDeptIdAndMonthId(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("deptId") String deptId); + int deleteByDeptIdAndMonthId(@Param("customerId") String customerId, + @Param("monthId") String monthId, + @Param("allParentIndexCode") String allParentIndexCode, + @Param("deleteSize") int 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 b4db5f05f9..bd0ba82f7e 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,7 +40,7 @@ public interface GridScoreDao extends BaseDao { * @param customerId * @param monthId * @param indexCode - * @param isTotal 1:总分;0不是 + * @param deleteNum * @return int * @author yinzuomei * @description @@ -49,7 +49,7 @@ public interface GridScoreDao extends BaseDao { int deleteByCusAndMonthId(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("indexCode") String indexCode, - @Param("isTotal") String isTotal); + @Param("deleteNum") int deleteNum); /** * @return int @@ -58,7 +58,7 @@ public interface GridScoreDao extends BaseDao { * @description * @Date 2020/8/31 14:01 **/ - int insertBatches(List gridScoreEntityList); + int insertBatches(@Param("list")List gridScoreEntityList); /** * @return java.util.List @@ -98,15 +98,5 @@ public interface GridScoreDao extends BaseDao { **/ List selectListGridId(@Param("customerId")String customerId, @Param("monthId")String monthId); - /** - * 批量插入 网格相关分值表 - * - * @param list - * @param customerId - * @return void - * @Author zhangyong - * @Date 11:11 2020-09-04 - **/ - void batchInsertGridScoreData(@Param("list") List list,@Param("customerId")String customerId); } \ No newline at end of file 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 e0cf724899..be9c55c66f 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 @@ -18,11 +18,7 @@ package com.epmet.dao.evaluationindex.indexcal; import com.epmet.commons.mybatis.dao.BaseDao; -import com.epmet.dto.indexcal.CalculateCommonFormDTO; -import com.epmet.dto.indexcal.GridScoreDTO; -import com.epmet.dto.screen.FactIndexGridScoreDTO; -import com.epmet.dto.screen.result.SubGridAvgResultDTO; -import com.epmet.entity.evaluationindex.indexcal.GridScoreEntity; +import com.epmet.entity.evaluationindex.indexcal.GridSubScoreEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -35,80 +31,28 @@ import java.util.List; * @since v1.0.0 2020-08-31 */ @Mapper -public interface GridSubScoreDao extends BaseDao { +public interface GridSubScoreDao extends BaseDao { /** - * @param customerId - * @param monthId - * @param indexCode - * @param isTotal 1:总分;0不是 - * @return int - * @author yinzuomei - * @description - * @Date 2020/8/31 14:00 - **/ - int deleteByCusAndMonthId(@Param("customerId") String customerId, - @Param("monthId") String monthId, - @Param("indexCode") String indexCode, - @Param("isTotal") String isTotal); - - /** - * @param gridScoreEntityList + * @param gridSubScoreEntityList * @return int * @author yinzuomei * @description * @Date 2020/8/31 14:01 **/ - int insertBatches(List gridScoreEntityList); - - /** - * @param formDTO - * @return java.util.List - * @author yinzuomei - * @description - * @Date 2020/8/31 16:42 - **/ - List selectList(CalculateCommonFormDTO formDTO); + int insertBatches(@Param("list") List gridSubScoreEntityList); /** * @param customerId * @param monthId - * @Description 下属所有网格的平均值 - * @author zxc - * @date 2020/8/28 3:20 下午 - */ - List selectSubGridAvgScore(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("indexCode") String indexCode); - - /** - * 根据入参查询 网格相关分值记录 - * - * @param customerId - * @param monthId - * @return java.util.List - * @Author zhangyong - * @Date 10:43 2020-09-03 - **/ - List selectListGridScore(@Param("customerId") String customerId, @Param("monthId") String monthId); - - /** - * 根据入参查询 网格id - * - * @param customerId - * @param monthId - * @return java.util.List - * @Author zhangyong - * @Date 10:43 2020-09-03 - **/ - List selectListGridId(@Param("customerId") String customerId, @Param("monthId") String monthId); - - /** - * 批量插入 网格相关分值表 - * - * @param list - * @param customerId - * @return void - * @Author zhangyong - * @Date 11:11 2020-09-04 + * @param allParentIndexCode + * @param deleteSize 一次至多删除XX条记录 + * @return int + * @author yinzuomei + * @description 批量删除 + * @Date 2020/9/10 13:36 **/ - void batchInsertGridScoreData(@Param("list") List list, @Param("customerId") String customerId); - + int deleteByDeptIdAndMonthId(@Param("customerId") String customerId, + @Param("monthId") String monthId, + @Param("allParentIndexCode") String allParentIndexCode, + @Param("deleteSize") Integer deleteSize); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/AgencySubScoreEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/AgencySubScoreEntity.java index a3e18f4b4f..2f1d277b46 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/AgencySubScoreEntity.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/AgencySubScoreEntity.java @@ -32,7 +32,7 @@ import java.math.BigDecimal; */ @Data @EqualsAndHashCode(callSuper = false) -@TableName("fact_index_sub_agency_score") +@TableName("fact_index_agency_sub_score") public class AgencySubScoreEntity extends BaseEpmetEntity { private static final long serialVersionUID = 1L; diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/CpcSubScoreEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/CpcSubScoreEntity.java index e69c222258..2183f77502 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/CpcSubScoreEntity.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/CpcSubScoreEntity.java @@ -32,7 +32,7 @@ import java.math.BigDecimal; */ @Data @EqualsAndHashCode(callSuper = false) -@TableName("fact_index_sub_cpc_score") +@TableName("fact_index_cpc_sub_score") public class CpcSubScoreEntity extends BaseEpmetEntity { private static final long serialVersionUID = 1L; diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/DeptSubScoreEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/DeptSubScoreEntity.java index 476f3c2568..db12edfeec 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/DeptSubScoreEntity.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/DeptSubScoreEntity.java @@ -32,7 +32,7 @@ import java.math.BigDecimal; */ @Data @EqualsAndHashCode(callSuper = false) -@TableName("fact_index_sub_dept_score") +@TableName("fact_index_dept_sub_score") public class DeptSubScoreEntity extends BaseEpmetEntity { private static final long serialVersionUID = 1L; @@ -67,11 +67,6 @@ public class DeptSubScoreEntity extends BaseEpmetEntity { */ private String monthId; - /** - * 1:总分;0不是;默认0 - */ - private String isTotal; - /** * 分值 */ diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/GridSubScoreEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/GridSubScoreEntity.java index ad99f92586..01f40a5ddd 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/GridSubScoreEntity.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/GridSubScoreEntity.java @@ -32,7 +32,7 @@ import java.math.BigDecimal; */ @Data @EqualsAndHashCode(callSuper = false) -@TableName("fact_index_sub_grid_score") +@TableName("fact_index_grid_sub_score") public class GridSubScoreEntity extends BaseEpmetEntity { private static final long serialVersionUID = 1L; diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/GridCorreLationService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/GridCorreLationService.java index a93697ce12..994f8818fb 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/GridCorreLationService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/GridCorreLationService.java @@ -3,6 +3,7 @@ package com.epmet.service.evaluationindex.indexcal; import com.epmet.dto.ScreenCustomerGridDTO; import com.epmet.dto.indexcal.CalculateCommonFormDTO; import com.epmet.dto.indexcal.PageQueryGridFormDTO; +import com.epmet.support.normalizing.batch.CalculateResult; import com.epmet.support.normalizing.batch.IndexInputVO; import java.math.BigDecimal; @@ -52,5 +53,5 @@ public interface GridCorreLationService { * @description 通用计算方法 * @Date 2020/9/3 16:07 **/ - HashMap calculate(Map> indexMap); + HashMap calculate(Map> indexMap); } 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 6dc176a887..d2feec5c47 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 @@ -23,14 +23,17 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; 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.DataSourceConstant; import com.epmet.constant.IndexCalConstant; 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.entity.evaluationindex.indexcal.DeptScoreEntity; +import com.epmet.entity.evaluationindex.indexcal.DeptSubScoreEntity; import com.epmet.entity.evaluationindex.indexcoll.FactIndexGovrnAblityDeptMonthlyEntity; import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity; import com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity; @@ -43,9 +46,12 @@ import com.epmet.support.normalizing.BigDecimalScoreCalculator; import com.epmet.support.normalizing.Correlation; import com.epmet.support.normalizing.ScoreCalculator; import com.epmet.support.normalizing.ScoreConstants; +import com.epmet.support.normalizing.batch.CalculateResult; import com.epmet.support.normalizing.batch.IndexInputVO; +import com.epmet.support.normalizing.batch.IndexScoreVo; import com.epmet.support.normalizing.batch.SampleValue; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -81,6 +87,8 @@ public class DeptScoreServiceImpl extends BaseServiceImpl minAndMaxMap = factIndexGovrnAblityDeptMonthlyDao.selectExtremeValue(formDTO); if (CollectionUtils.isEmpty(minAndMaxMap)) { @@ -123,7 +123,10 @@ public class DeptScoreServiceImpl extends BaseServiceImpl> indexMap = buildDeptCorrelationIndexInputVO(indexGroupDetailEntityList, minAndMaxMap); - //4、分批计算 + //4、先全部删除,后批量插入 + //quzhibumen:zhilinengli + deleteBeforeDataList(formDTO,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),IndexCalConstant.DEPT_ZL_ALL_PARENT_INDEX_CODE); + //5、分批计算 int pageNo = NumConstant.ONE; int pageSize = IndexCalConstant.PAGE_SIZE; //分页查询 要计算的原始数据 @@ -139,6 +142,38 @@ public class DeptScoreServiceImpl extends BaseServiceImpl resultMap = gridCorreLationService.calculate(indexMap); + HashMap resultMap = gridCorreLationService.calculate(indexMap); //保存中间表记录 this.saveDeptScoreEntity(formDTO,resultMap); } @@ -177,10 +212,12 @@ public class DeptScoreServiceImpl extends BaseServiceImpl resultMap) { + public void saveDeptScoreEntity(CalculateCommonFormDTO formDTO, HashMap resultMap) { String quarterId = DateUtils.getQuarterId(formDTO.getMonthId()); String yearId = DateUtils.getYearId(formDTO.getMonthId()); - resultMap.forEach((deptId, governAblityScore) -> { + List deptScoreEntityList=new ArrayList<>(); + List deptSubScoreEntityList=new ArrayList<>(); + resultMap.forEach((deptId, calculateResult) -> { DeptScoreEntity deptScoreEntity = new DeptScoreEntity(); deptScoreEntity.setCustomerId(formDTO.getCustomerId()); deptScoreEntity.setDeptId(deptId); @@ -195,26 +232,29 @@ public class DeptScoreServiceImpl extends BaseServiceImpl> partitionDeptSubScoreList = ListUtils.partition(deptSubScoreEntityList, IndexCalConstant.INSERT_SIZE); + for (List insertDeptSubList : partitionDeptSubScoreList) { + deptSubScoreDao.insertBatchEntity(insertDeptSubList); + } } - /** - * @param formDTO - * @return void - * @author yinzuomei - * @description 只有一个部门的事实记录时无需处理以下代码注释 - * @Date 2020/9/3 9:35 - **/ - /*private void handleOneGridScene(CalculateCommonFormDTO formDTO) { - FactIndexGovrnAblityDeptMonthlyEntity entity = factIndexGovrnAblityDeptMonthlyDao.selectOneRecord(formDTO.getCustomerId(), formDTO.getMonthId()); - HashMap resultMap = new HashMap<>(); - resultMap.put(entity.getDeptId(), new BigDecimal(NumConstant.FIFTY_STR)); - this.saveDeptScoreEntity(formDTO, resultMap); - }*/ - /** * @param indexList * @param minAndMaxMap diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/GridCorreLationServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/GridCorreLationServiceImpl.java index 707a462ba0..1a3ba3a353 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/GridCorreLationServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/GridCorreLationServiceImpl.java @@ -11,13 +11,16 @@ import com.epmet.constant.DataSourceConstant; import com.epmet.constant.IndexCalConstant; import com.epmet.dao.evaluationindex.indexcal.CpcScoreDao; import com.epmet.dao.evaluationindex.indexcal.GridScoreDao; +import com.epmet.dao.evaluationindex.indexcal.GridSubScoreDao; import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityGridMonthlyDao; import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityGridMonthlyDao; import com.epmet.dao.evaluationindex.indexcoll.FactIndexServiceAblityGridMonthlyDao; import com.epmet.dao.evaluationindex.screen.ScreenCustomerGridDao; import com.epmet.dto.ScreenCustomerGridDTO; import com.epmet.dto.indexcal.*; +import com.epmet.entity.evaluationindex.indexcal.DeptSubScoreEntity; import com.epmet.entity.evaluationindex.indexcal.GridScoreEntity; +import com.epmet.entity.evaluationindex.indexcal.GridSubScoreEntity; import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity; import com.epmet.eum.IndexCodeEnum; import com.epmet.service.evaluationindex.indexcal.GridCorreLationService; @@ -27,11 +30,9 @@ import com.epmet.support.normalizing.BigDecimalScoreCalculator; import com.epmet.support.normalizing.Correlation; import com.epmet.support.normalizing.ScoreCalculator; import com.epmet.support.normalizing.ScoreConstants; -import com.epmet.support.normalizing.batch.BatchScoreCalculator; -import com.epmet.support.normalizing.batch.IndexInputVO; -import com.epmet.support.normalizing.batch.IndexOutputVO; -import com.epmet.support.normalizing.batch.SampleValue; +import com.epmet.support.normalizing.batch.*; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -69,6 +70,8 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { private CpcScoreDao cpcScoreDao; @Autowired private GridScoreDao gridScoreDao; + @Autowired + private GridSubScoreDao gridSubScoreDao; /** @@ -154,7 +157,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { } //指标集合 Map> indexMap = buildGridCorrelationIndexInputVO(formDTO, indexList, minAndMaxMap); - List> resultMapList = new ArrayList<>(); + List> resultMapList = new ArrayList<>(); //分页查询采集记录 for (int pageNo = 1; pageNo <= totalPage; pageNo++) { int pageIndex = (pageNo - NumConstant.ONE) * IndexCalConstant.PAGE_SIZE; @@ -186,11 +189,16 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { } }); }); - HashMap resultMap = calculate(indexMap); + HashMap resultMap = calculate(indexMap); resultMapList.add(resultMap); } // 保存中间表 - saveGridCorreLationResult(formDTO, resultMapList, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), NumConstant.ZERO_STR); + deleteBeforeDataList(formDTO,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),IndexCalConstant.GRID_DJ_ALL_PARENT_INDEX_CODE); + saveGridCorreLationResult(formDTO, + resultMapList, + IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), + IndexCalConstant.GRID_DJ_ALL_PARENT_INDEX_CODE, + NumConstant.ZERO_STR); } /** @@ -318,6 +326,36 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { return map; } + /** + * @return void + * @param formDTO + * @param indexCode 当前计算的指标(党建能力,治理能力,服务能力) + * @param allParentIndexCode + * @author yinzuomei + * @description + * @Date 2020/9/10 13:58 + **/ + private void deleteBeforeDataList(CalculateCommonFormDTO formDTO,String indexCode,String allParentIndexCode) { + //先删除 + int masterDeleteNum; + do { + //一次删除50条 + masterDeleteNum = gridScoreDao.deleteByCusAndMonthId(formDTO.getCustomerId(), + formDTO.getMonthId(), + indexCode, + IndexCalConstant.DELETE_SIZE); + } while (masterDeleteNum != NumConstant.ZERO); + //删除明细时,需要根据分组删,比方说当前计算的是网格相关-党建能力,主表需要删除indexCode=dangjiannengli的,明细需要删除网格相关:党建能力 下面所有的指标明细 + int detailDelteNum; + do { + detailDelteNum = gridSubScoreDao.deleteByDeptIdAndMonthId(formDTO.getCustomerId(), + formDTO.getMonthId(), + allParentIndexCode, + IndexCalConstant.DELETE_SIZE); + } while (detailDelteNum != NumConstant.ZERO); + log.info("delete fact_index_grid_score and fact_index_grid_sub_score complete"); + } + /** * @param formDTO 客户id 月份id: yyyyMM * @param resultMapList @@ -329,15 +367,18 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { * @Date 2020/8/30 22:50 **/ private void saveGridCorreLationResult(CalculateCommonFormDTO formDTO, - List> resultMapList, + List> resultMapList, String indexCode, + String allParentIndexCode, 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) -> { - log.info("网格id:" + gridId + ";index_Code:"+indexCode+";分值:" + partyAblityScore); + //三大能力结果表 + List gridScoreEntityList = new ArrayList<>(); + //五级指标分值明细 + List gridSubScoreList = new ArrayList<>(); + for (HashMap resultMap : resultMapList) { + resultMap.forEach((gridId, calculateResult) -> { GridScoreEntity gridScoreEntity = new GridScoreEntity(); gridScoreEntity.setCustomerId(formDTO.getCustomerId()); gridScoreEntity.setGridId(gridId); @@ -355,18 +396,36 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { gridScoreEntity.setQuarterId(quarterId); gridScoreEntity.setYearId(yearId); gridScoreEntity.setMonthId(formDTO.getMonthId()); - gridScoreEntity.setScore(partyAblityScore); + gridScoreEntity.setScore(calculateResult.getTotalScore()); + //新增ALL_PARENT_INDEX_CODE 所有指标code拼接的字符串 冒号隔开 + gridScoreEntity.setAllParentIndexCode(IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode()); gridScoreEntityList.add(gridScoreEntity); + for(IndexScoreVo detail:calculateResult.getDetails()){ + GridSubScoreEntity gridSubScoreEntity= ConvertUtils.sourceToTarget(gridScoreEntity, GridSubScoreEntity.class); + //重新赋值 + gridSubScoreEntity.setIndexCode(detail.getIndexCode()); + gridSubScoreEntity.setAllParentIndexCode(detail.getAllParentIndexCode()); + gridSubScoreEntity.setScore(detail.getScore()); + gridSubScoreList.add(gridSubScoreEntity); + } }); } + //后新增 if (!CollectionUtils.isEmpty(gridScoreEntityList)) { - gridScoreDao.deleteByCusAndMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode, isTotal); //批量插入 - List> partition = ListUtils.partition(gridScoreEntityList, 100); + List> partition = ListUtils.partition(gridScoreEntityList, IndexCalConstant.INSERT_SIZE); partition.forEach(list -> { gridScoreDao.insertBatches(list); }); } + if (!CollectionUtils.isEmpty(gridSubScoreList)) { + //批量插入 + List> subPartition = ListUtils.partition(gridSubScoreList, IndexCalConstant.INSERT_SIZE); + subPartition.forEach(subList -> { + gridSubScoreDao.insertBatches(subList); + }); + } + log.info("insert fact_index_grid_score and fact_index_grid_sub_score complete"); } /** @@ -377,7 +436,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { * @Date 2020/8/30 21:40 **/ @Override - public HashMap calculate(Map> indexMap) { + public HashMap calculate(Map> indexMap) { //构造入参 List indexInputVOS = this.getIndexInputVOList(indexMap); log.info("计算的参数"+JSON.toJSONString(indexInputVOS)); @@ -387,7 +446,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { List listTemp=batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS); log.info("计算的结果(List)"+JSON.toJSONString(listTemp)); - HashMap resultMap = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); + HashMap resultMap = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS); log.info("计算的结果{}", resultMap); return resultMap; } @@ -503,7 +562,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { } //指标集合 Map> indexMap = buildGridCorrelationIndexInputVO(formDTO, indexList, minAndMaxMap); - List> resultMapList = new ArrayList<>(); + List> resultMapList = new ArrayList<>(); //分页查询采集记录 for (int pageNo = 1; pageNo <= totalPage; pageNo++) { int pageIndex = (pageNo - NumConstant.ONE) * IndexCalConstant.PAGE_SIZE; @@ -532,11 +591,16 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { } }); }); - HashMap resultMap = calculate(indexMap); + HashMap resultMap = calculate(indexMap); resultMapList.add(resultMap); } // 保存中间表 - saveGridCorreLationResult(formDTO, resultMapList, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), NumConstant.ZERO_STR); + deleteBeforeDataList(formDTO,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),IndexCalConstant.GRID_ZL_ALL_PARENT_INDEX_CODE); + saveGridCorreLationResult(formDTO, + resultMapList, + IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), + IndexCalConstant.GRID_ZL_ALL_PARENT_INDEX_CODE, + NumConstant.ZERO_STR); } @@ -572,7 +636,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { } //指标集合 Map> indexMap = buildGridCorrelationIndexInputVO(formDTO, indexList, minAndMaxMap); - List> resultMapList = new ArrayList<>(); + List> resultMapList = new ArrayList<>(); //分页查询采集记录 for (int pageNo = 1; pageNo <= totalPage; pageNo++) { int pageIndex = (pageNo - NumConstant.ONE) * IndexCalConstant.PAGE_SIZE; @@ -597,11 +661,16 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { } }); }); - HashMap resultMap = calculate(indexMap); + HashMap resultMap = calculate(indexMap); resultMapList.add(resultMap); } // 保存中间表 - saveGridCorreLationResult(formDTO, resultMapList, IndexCodeEnum.FU_WU_NENG_LI.getCode(), NumConstant.ZERO_STR); + deleteBeforeDataList(formDTO,IndexCodeEnum.FU_WU_NENG_LI.getCode(),IndexCalConstant.GRID_FW_ALL_PARENT_INDEX_CODE); + saveGridCorreLationResult(formDTO, + resultMapList, + IndexCodeEnum.FU_WU_NENG_LI.getCode(), + IndexCalConstant.GRID_FW_ALL_PARENT_INDEX_CODE, + NumConstant.ZERO_STR); } /** @@ -637,9 +706,9 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { gridScoreEntityList.add(gridScoreEntity); } if (!CollectionUtils.isEmpty(gridScoreEntityList)) { - gridScoreDao.deleteByCusAndMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode, NumConstant.ONE_STR); + gridScoreDao.deleteByCusAndMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode, IndexCalConstant.DELETE_SIZE); //批量插入 - List> partition = ListUtils.partition(gridScoreEntityList, 100); + List> partition = ListUtils.partition(gridScoreEntityList, IndexCalConstant.INSERT_SIZE); partition.forEach(list -> { gridScoreDao.insertBatches(list); }); 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 077c6a7430..d17f344e40 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 @@ -43,7 +43,31 @@ GROUP BY fidc.agency_id - + + + + + + delete from fact_index_dept_score where CUSTOMER_ID = #{customerId} + AND MONTH_ID = #{monthId} + + and INDEX_CODE=#{indexCode} + + limit #{deleteSize} + + + + insert into fact_index_dept_score ( ID, @@ -56,7 +80,7 @@ IS_TOTAL, SCORE, INDEX_CODE, - + ALL_PARENT_INDEX_CODE, DEL_FLAG, REVISION, CREATED_BY, @@ -72,12 +96,12 @@ #{item.agencyId}, #{item.quarterId}, #{item.yearId}, - #{item.monthId}, #{item.isTotal}, #{item.score}, #{item.indexCode}, - #{item.delFlag}, + #{item.allParentIndexCode}, + 0, 0, 'APP_USER', now(), @@ -86,22 +110,4 @@ ) - - - - - delete from fact_index_dept_score where CUSTOMER_ID = #{customerId} - AND MONTH_ID = #{monthId} - and DEPT_ID=#{deptId} - 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 f75bed424b..a20c5311e1 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 @@ -2,47 +2,9 @@ - - - - - - - - insert into fact_index_dept_score + + + insert into fact_index_dept_sub_score ( ID, CUSTOMER_ID, @@ -53,7 +15,7 @@ MONTH_ID, SCORE, INDEX_CODE, - + ALL_PARENT_INDEX_CODE, DEL_FLAG, REVISION, CREATED_BY, @@ -69,11 +31,11 @@ #{item.agencyId}, #{item.quarterId}, #{item.yearId}, - #{item.monthId}, #{item.score}, #{item.indexCode}, - #{item.delFlag}, + #{item.allParentIndexCode}, + 0, 0, 'APP_USER', now(), @@ -83,21 +45,12 @@ - - + - delete from fact_index_dept_score where CUSTOMER_ID = #{customerId} - AND MONTH_ID = #{monthId} - and DEPT_ID=#{deptId} + delete from fact_index_dept_sub_score + where CUSTOMER_ID = #{customerId} + AND MONTH_ID = #{monthId} + and ALL_PARENT_INDEX_CODE=#{allParentIndexCode} + 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 d42d063e35..b0970024c6 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 @@ -15,6 +15,7 @@ + @@ -31,9 +32,10 @@ CUSTOMER_ID = #{customerId} AND MONTH_ID = #{monthId} AND INDEX_CODE = #{indexCode} - and IS_TOTAL=#{isTotal} + limit #{deleteNum} + INSERT INTO `fact_index_grid_score` ( `ID`, @@ -47,6 +49,7 @@ `IS_TOTAL`, `SCORE`, `INDEX_CODE`, + ALL_PARENT_INDEX_CODE, `DEL_FLAG`, `REVISION`, `CREATED_BY`, @@ -68,6 +71,7 @@ #{item.isTotal}, #{item.score}, #{item.indexCode}, + #{item.allParentIndexCode}, 0, 0, 'APP_USER', @@ -156,50 +160,6 @@ ORDER BY GRID_ID - - 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), - #{customerId}, - #{item.gridId}, - #{item.agencyId}, - #{item.allParentIds}, - #{item.quarterId}, - - #{item.yearId}, - #{item.monthId}, - #{item.isTotal}, - #{item.score}, - #{item.indexCode}, - #{item.delFlag}, - 0, - 'APP_USER', - now(), - 'APP_USER', - now() - ) - - - SELECT - m.GRID_ID, - m.CUSTOMER_ID, - m.AGENCY_ID, - m.ALL_PARENT_IDS, - m.QUARTER_ID, - m.YEAR_ID, - m.MONTH_ID, - M.SCORE, - M.INDEX_CODE - FROM - fact_index_grid_score m - WHERE - m.DEL_FLAG = '0' - AND m.CUSTOMER_ID =#{customerId} - AND m.MONTH_ID =#{monthId} - - - - - - - - - - - insert into fact_index_grid_score - ( - ID, - CUSTOMER_ID, - GRID_ID, - AGENCY_ID, - ALL_PARENT_IDS, - QUARTER_ID, - YEAR_ID, - MONTH_ID, - SCORE, - INDEX_CODE, - DEL_FLAG, - REVISION, - CREATED_BY, - CREATED_TIME, - UPDATED_BY, - UPDATED_TIME - ) values - - ( - (SELECT REPLACE(UUID(), '-', '') AS id), - #{customerId}, - #{item.gridId}, - #{item.agencyId}, - #{item.allParentIds}, - #{item.quarterId}, - - #{item.yearId}, - #{item.monthId}, - #{item.score}, - #{item.indexCode}, - #{item.delFlag}, - 0, - 'APP_USER', - now(), - 'APP_USER', - now() - ) - - - - - + CUSTOMER_ID = #{customerId} + AND MONTH_ID = #{monthId} + AND ALL_PARENT_INDEX_CODE = #{allParentIndexCode} + limit #{deleteNum} + \ No newline at end of file