From ff3eaf8b0c8ce945ddf5f5e5dde433de9e073412 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 1 Sep 2020 16:34:30 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A4=BE=E5=8C=BA=E7=9B=B8=E5=85=B3=E4=BC=98?= =?UTF-8?q?=E5=8C=96=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IndexCalculateCommunityService.java | 31 +------ .../IndexCalculateCommunityServiceImpl.java | 93 +++++++++++-------- 2 files changed, 56 insertions(+), 68 deletions(-) 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 5a6f1bbaa9..b0803ae2be 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,38 +12,11 @@ import java.util.List; public interface IndexCalculateCommunityService { /** - * @Description 社区党建能力 - * @param customerId - * @param monthId - * @author zxc - * @date 2020/8/26 10:46 上午 - */ - void communityPartyCalculate(String customerId, String monthId); - - /** - * @Description 社区治理能力 - * @param customerId - * @param monthId - * @author zxc - * @date 2020/8/26 1:40 下午 - */ - 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 计算社区相关 + * @Description 计算社区相关总分 * @param customerId * @param monthId * @author zxc * @date 2020/9/1 4:12 下午 */ - void calAll(String customerId, String monthId); + Boolean calCommunityAll(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 4ff69ef236..bb7962faf6 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 @@ -2,6 +2,7 @@ package com.epmet.service.screen.impl; import com.alibaba.druid.util.StringUtils; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.constant.IndexCalConstant; import com.epmet.dao.indexcoll.FactIndexGovrnAblityOrgMonthlyDao; @@ -60,8 +61,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni * @date 2020/8/26 10:46 上午 */ @Transactional(rollbackFor = Exception.class) - @Override - public void communityPartyCalculate(String customerId, String monthId) { + public Boolean communityPartyCalculate(String customerId, String monthId) { // 党建能力 // 根据all_parent_index_code 获取指标明细 @@ -100,18 +100,12 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni } } }); - + // 社区名义发文数量 List publishArticleCounts = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCount(customerId, monthId); detailListByParentCode.forEach(indexGroup -> { if (indexGroup.getIndexCode().equals("shequmingyifwsl")) { if (publishArticleCounts.size() == NumConstant.ONE) { - //TODO 计算之后的分数 - FactIndexCommunityScoreDTO dto = new FactIndexCommunityScoreDTO(); - BeanUtils.copyProperties(detailListByParentCode.get(NumConstant.ZERO), dto); - dto.setScore(BigDecimal.valueOf(50.00)); - dto.setIndexCode(detailListByParentCode.get(NumConstant.ZERO).getIndexCode()); - communityPublishArticle.add(dto); - factIndexCommunityScoreDao.insertCommunityPartyRecord(communityPublishArticle); + //TODO 结果为一条时 } else if (publishArticleCounts.size() > NumConstant.ONE) { Integer indexStart = NumConstant.ZERO; Integer indexEnd = NumConstant.TEN; @@ -149,8 +143,8 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni } }); }); - factIndexCommunityScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.COMMUNITY_PARTY); - factIndexCommunityScoreDao.insertCommunityPartyRecord(subAllGridList); + deleteAndInsert(customerId,monthId,IndexCalConstant.COMMUNITY_PARTY,subAllGridList); + return true; } /** @@ -161,8 +155,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni * @date 2020/8/26 1:40 下午 */ @Transactional(rollbackFor = Exception.class) - @Override - public void communityGovernAbilityCalculate(String customerId, String monthId) { + public Boolean communityGovernAbilityCalculate(String customerId, String monthId) { List subAllGridList = new ArrayList<>(); List detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); detailListByParentCode.forEach(detail -> { @@ -243,9 +236,8 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni }); }); } - factIndexCommunityScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.COMMUNITY_GOVERN); - factIndexCommunityScoreDao.insertCommunityPartyRecord(subAllGridList); - + deleteAndInsert(customerId,monthId,IndexCalConstant.COMMUNITY_GOVERN,subAllGridList); + return true; } /** @@ -256,23 +248,16 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni * @date 2020/8/31 1:38 下午 */ @Transactional(rollbackFor = Exception.class) - @Override - public void communityServiceAbilityCalculate(String customerId, String monthId) { - - + public Boolean 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 -> { String indexCode = detail.getIndexCode(); if (indexCode.equals(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; @@ -306,9 +291,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni }else{ 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; @@ -346,9 +329,8 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni } }); }); - factIndexCommunityScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.COMMUNITY_SERVICE); - factIndexCommunityScoreDao.insertCommunityPartyRecord(subAllGridList); - + deleteAndInsert(customerId,monthId,IndexCalConstant.COMMUNITY_SERVICE,subAllGridList); + return true; } /** @@ -358,7 +340,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni * @author zxc * @date 2020/9/1 9:21 上午 */ - public void communityRelate(String customerId, String monthId) { + public Boolean communityRelate(String customerId, String monthId) { List detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode()); List factIndexCommunityScoreEntities = factIndexCommunityScoreDao.selectCommunityInfo(customerId, monthId); detailListByParentCode.forEach(detail -> { @@ -384,16 +366,35 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni }); result.add(score); }); - factIndexCommunityScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.COMMUNITY_RELATE); - factIndexCommunityScoreDao.insertCommunityPartyRecord(result); + deleteAndInsert(customerId,monthId,IndexCalConstant.COMMUNITY_RELATE,result); + return true; } - public void calAll(String customerId,String monthId){ - this.communityPartyCalculate(customerId, monthId); //党建能力 - this.communityGovernAbilityCalculate(customerId, monthId); // 治理能力 - this.communityServiceAbilityCalculate(customerId, monthId); // 服务能力 - - communityRelate(customerId, monthId); + /** + * @Description 计算社区相关总分 + * @param customerId + * @param monthId + * @author zxc + * @date 2020/9/1 4:12 下午 + */ + public Boolean calCommunityAll(String customerId,String monthId){ + Boolean aBoolean = communityPartyCalculate(customerId, monthId);//党建能力 + if (!aBoolean.equals(true)){ + throw new RenException("calculate community-party-ability failure ......"); + } + Boolean bBoolean = communityGovernAbilityCalculate(customerId, monthId);// 治理能力 + if (!bBoolean.equals(true)){ + throw new RenException("calculate community-govern-ability failure ......"); + } + Boolean cBoolean = communityServiceAbilityCalculate(customerId, monthId);// 服务能力 + if (!cBoolean.equals(true)){ + throw new RenException("calculate community-service-ability failure ......"); + } + Boolean dBoolean = communityRelate(customerId, monthId); + if (!dBoolean.equals(true)){ + throw new RenException("calculate community-all insert failure ......"); + } + return true; } /** @@ -418,4 +419,18 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); return batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); } + + /** + * @Description 先删除记录,在插入 + * @param customerId + * @param monthId + * @param indexCode + * @param subAllGridList + * @author zxc + * @date 2020/9/1 4:24 下午 + */ + public void deleteAndInsert(String customerId,String monthId,String indexCode,List subAllGridList){ + factIndexCommunityScoreDao.deleteOldRecord(customerId,monthId,indexCode); + factIndexCommunityScoreDao.insertCommunityPartyRecord(subAllGridList); + } }