diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java index d97a697f7b..fa9ae610f4 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java @@ -51,7 +51,7 @@ public interface AgencyScoreDao extends BaseDao { * @author zxc * @date 2020/9/2 15:47 */ - void deleteOldRecord(@Param("customerId") String customerId, @Param("monthId")String monthId, @Param("dataType")String dataType); + Integer deleteOldRecord(@Param("customerId") String customerId, @Param("monthId")String monthId, @Param("dataType")String dataType,@Param("delNum")Integer delNum); /** * @Description 查询【fact_index_agency_score】相关信息 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencySubScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencySubScoreDao.java index 906ef53470..970b671a7f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencySubScoreDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencySubScoreDao.java @@ -50,6 +50,6 @@ public interface AgencySubScoreDao extends BaseDao { * @author zxc * @date 2020/9/2 15:47 */ - void deleteOldRecord(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("dataType") String dataType); + Integer deleteOldRecord(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("dataType") String dataType,@Param("delNum")Integer delNum); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunityScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunityScoreDao.java index ab1439481e..4df07097d9 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunityScoreDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunityScoreDao.java @@ -50,7 +50,7 @@ public interface CommunityScoreDao extends BaseDao o.getScore()).collect(Collectors.toList())); - Integer indexEnd = NumConstant.TEN; - List> subPartyAvgList = ListUtils.partition(subGridPartyAvgScore, indexEnd); + List> subPartyAvgList = ListUtils.partition(subGridPartyAvgScore, IndexCalConstant.PAGE_SIZE); subPartyAvgList.forEach(party -> { List index1SampleValues = new ArrayList<>(); party.forEach(c -> { @@ -141,8 +140,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni HashMap scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS); log.info("communityPartyCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); CommunityCalResultDTO result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), pid); - communitySubScoreDao.deleteOldRecord(customerId,monthId); - factIndexCommunityScoreDao.deleteOldRecord(customerId, monthId); + deleteOldRecord(customerId,monthId); deleteAndInsert(result); return true; } @@ -385,13 +383,37 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni @Transactional(rollbackFor = Exception.class) public void deleteAndInsert(CommunityCalResultDTO result) { if (!CollectionUtils.isEmpty(result.getOneLevel())) { - factIndexCommunityScoreDao.insertCommunityPartyRecord(result.getOneLevel()); + List> partition = ListUtils.partition(result.getOneLevel(), IndexCalConstant.INSERT_SIZE); + partition.forEach(p -> { + factIndexCommunityScoreDao.insertCommunityPartyRecord(p); + }); } if (!CollectionUtils.isEmpty(result.getFiveLevel())){ - communitySubScoreDao.insertCommunityPartyRecord(result.getFiveLevel()); + List> partition = ListUtils.partition(result.getFiveLevel(), IndexCalConstant.INSERT_SIZE); + partition.forEach(p -> { + communitySubScoreDao.insertCommunityPartyRecord(p); + }); } } + /** + * @Description + * @param customerId + * @param monthId + * @author zxc + * @date 2020/9/10 2:50 下午 + */ + public void deleteOldRecord(String customerId,String monthId){ + Integer num; + do { + num = factIndexCommunityScoreDao.deleteOldRecord(customerId, monthId,IndexCalConstant.DELETE_SIZE); + }while (num != NumConstant.ZERO); + Integer subNum; + do { + subNum = communitySubScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.DELETE_SIZE); + }while (subNum != NumConstant.ZERO); + } + /** * @param scoreCountOfSampleId 指标计算结果 * @param customerId 客户ID 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 4f6d07669b..0440fd84fd 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 @@ -165,9 +165,8 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict log.info("districtPartyAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); log.info("districtPartyAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); AgencyCalResultDTO result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode(), pid); - agencyScoreDao.deleteOldRecord(customerId, monthId,IndexCalConstant.DISTRICT_LEVEL); - agencySubScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.DISTRICT_LEVEL); - deleteAndInsert(result); + deleteOldRecord(customerId,monthId,IndexCalConstant.DISTRICT_LEVEL); + insertDetail(result); return true; } @@ -236,7 +235,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict log.info("districtGovernAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); log.info("districtGovernAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); AgencyCalResultDTO result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode(), pid); - deleteAndInsert(result); + insertDetail(result); return true; } @@ -286,7 +285,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict log.info("districtServiceAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); log.info("districtServiceAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); AgencyCalResultDTO result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(), IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode(), pid); - deleteAndInsert(result); + insertDetail(result); return true; } @@ -347,6 +346,25 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict return result; } + /** + * @Description + * @param customerId + * @param monthId + * @param dataType 数据类型 (街道:street,全区:district) + * @author zxc + * @date 2020/9/10 2:50 下午 + */ + public void deleteOldRecord(String customerId,String monthId,String dataType){ + Integer num; + do { + num = agencyScoreDao.deleteOldRecord(customerId, monthId,dataType,IndexCalConstant.DELETE_SIZE); + }while (num != NumConstant.ZERO); + Integer subNum; + do { + subNum = agencySubScoreDao.deleteOldRecord(customerId,monthId,dataType,IndexCalConstant.DELETE_SIZE); + }while (subNum != NumConstant.ZERO); + } + /** * @param result * @Description 先删除记录,在插入 @@ -354,12 +372,18 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict * @date 2020/9/1 4:24 下午 */ @Transactional(rollbackFor = Exception.class) - public void deleteAndInsert(AgencyCalResultDTO result) { + public void insertDetail(AgencyCalResultDTO result) { if (!CollectionUtils.isEmpty(result.getOneTwoLevel())){ - agencyScoreDao.insertStreetRecord(result.getOneTwoLevel()); + List> partition = ListUtils.partition(result.getOneTwoLevel(), IndexCalConstant.INSERT_SIZE); + partition.forEach(p -> { + agencyScoreDao.insertStreetRecord(p); + }); } if (!CollectionUtils.isEmpty(result.getFiveLevel())){ - agencySubScoreDao.insertStreetRecord(result.getFiveLevel()); + List> partition = ListUtils.partition(result.getFiveLevel(), IndexCalConstant.INSERT_SIZE); + partition.forEach(p -> { + agencySubScoreDao.insertStreetRecord(p); + }); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java index 1d9757041f..d556a24894 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java @@ -168,9 +168,8 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ log.info("streetPartyAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); log.info("streetPartyAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); AgencyCalResultDTO result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), pid); - agencySubScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.STREET_LEVEL); - agencyScoreDao.deleteOldRecord(customerId, monthId, IndexCalConstant.STREET_LEVEL); - deleteAndInsert(result); + deleteOldRecord(customerId, monthId, IndexCalConstant.STREET_LEVEL); + insertDetail(result); return true; } @@ -244,7 +243,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ log.info("streetGovernAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); log.info("streetGovernAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); AgencyCalResultDTO result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), pid); - deleteAndInsert(result); + insertDetail(result); return true; } @@ -318,7 +317,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ log.info("streetServiceAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); log.info("streetServiceAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); AgencyCalResultDTO result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(), IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), pid); - deleteAndInsert(result); + insertDetail(result); return true; } @@ -384,15 +383,40 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ * @date 2020/9/1 4:24 下午 */ @Transactional(rollbackFor = Exception.class) - public void deleteAndInsert(AgencyCalResultDTO result) { + public void insertDetail(AgencyCalResultDTO result) { if (!CollectionUtils.isEmpty(result.getOneTwoLevel())) { - agencyScoreDao.insertStreetRecord(result.getOneTwoLevel()); + List> partition = ListUtils.partition(result.getOneTwoLevel(), IndexCalConstant.INSERT_SIZE); + partition.forEach(p -> { + agencyScoreDao.insertStreetRecord(p); + }); } if (!CollectionUtils.isEmpty(result.getFiveLevel())){ - agencySubScoreDao.insertStreetRecord(result.getFiveLevel()); + List> partition = ListUtils.partition(result.getFiveLevel(), IndexCalConstant.INSERT_SIZE); + partition.forEach(p -> { + agencySubScoreDao.insertStreetRecord(p); + }); } } + /** + * @Description + * @param customerId + * @param monthId + * @param dataType 数据类型 (街道:street,全区:district) + * @author zxc + * @date 2020/9/10 2:50 下午 + */ + public void deleteOldRecord(String customerId,String monthId,String dataType){ + Integer num; + do { + num = agencyScoreDao.deleteOldRecord(customerId, monthId,dataType,IndexCalConstant.DELETE_SIZE); + }while (num != NumConstant.ZERO); + Integer subNum; + do { + subNum = agencySubScoreDao.deleteOldRecord(customerId,monthId,dataType,IndexCalConstant.DELETE_SIZE); + }while (subNum != NumConstant.ZERO); + } + /** * @param scoreCountOfSampleId 指标计算结果 * @param customerId 客户ID diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml index 45768cdde6..a0c7f2cdae 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml @@ -41,6 +41,7 @@ AND customer_id = #{customerId} AND month_id = #{monthId} AND data_type = #{dataType} + LIMIT #{delNum}