Browse Source

社区相关优化 1

dev_shibei_match
zxc 5 years ago
parent
commit
ff3eaf8b0c
  1. 31
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexCalculateCommunityService.java
  2. 93
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateCommunityServiceImpl.java

31
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 { public interface IndexCalculateCommunityService {
/** /**
* @Description 社区党建能力 * @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 计算社区相关
* @param customerId * @param customerId
* @param monthId * @param monthId
* @author zxc * @author zxc
* @date 2020/9/1 4:12 下午 * @date 2020/9/1 4:12 下午
*/ */
void calAll(String customerId, String monthId); Boolean calCommunityAll(String customerId, String monthId);
} }

93
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.alibaba.druid.util.StringUtils;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.constant.IndexCalConstant; import com.epmet.constant.IndexCalConstant;
import com.epmet.dao.indexcoll.FactIndexGovrnAblityOrgMonthlyDao; import com.epmet.dao.indexcoll.FactIndexGovrnAblityOrgMonthlyDao;
@ -60,8 +61,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
* @date 2020/8/26 10:46 上午 * @date 2020/8/26 10:46 上午
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override public Boolean communityPartyCalculate(String customerId, String monthId) {
public void communityPartyCalculate(String customerId, String monthId) {
// 党建能力 // 党建能力
// 根据all_parent_index_code 获取指标明细 // 根据all_parent_index_code 获取指标明细
@ -100,18 +100,12 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
} }
} }
}); });
// 社区名义发文数量
List<CommunityPublishArticleCountResultDTO> publishArticleCounts = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCount(customerId, monthId); List<CommunityPublishArticleCountResultDTO> publishArticleCounts = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCount(customerId, monthId);
detailListByParentCode.forEach(indexGroup -> { detailListByParentCode.forEach(indexGroup -> {
if (indexGroup.getIndexCode().equals("shequmingyifwsl")) { if (indexGroup.getIndexCode().equals("shequmingyifwsl")) {
if (publishArticleCounts.size() == NumConstant.ONE) { if (publishArticleCounts.size() == NumConstant.ONE) {
//TODO 计算之后的分数 //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);
} else if (publishArticleCounts.size() > NumConstant.ONE) { } else if (publishArticleCounts.size() > NumConstant.ONE) {
Integer indexStart = NumConstant.ZERO; Integer indexStart = NumConstant.ZERO;
Integer indexEnd = NumConstant.TEN; Integer indexEnd = NumConstant.TEN;
@ -149,8 +143,8 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
} }
}); });
}); });
factIndexCommunityScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.COMMUNITY_PARTY); deleteAndInsert(customerId,monthId,IndexCalConstant.COMMUNITY_PARTY,subAllGridList);
factIndexCommunityScoreDao.insertCommunityPartyRecord(subAllGridList); return true;
} }
/** /**
@ -161,8 +155,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
* @date 2020/8/26 1:40 下午 * @date 2020/8/26 1:40 下午
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override public Boolean communityGovernAbilityCalculate(String customerId, String monthId) {
public void communityGovernAbilityCalculate(String customerId, String monthId) {
List<FactIndexCommunityScoreDTO> subAllGridList = new ArrayList<>(); List<FactIndexCommunityScoreDTO> subAllGridList = new ArrayList<>();
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
detailListByParentCode.forEach(detail -> { detailListByParentCode.forEach(detail -> {
@ -243,9 +236,8 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
}); });
}); });
} }
factIndexCommunityScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.COMMUNITY_GOVERN); deleteAndInsert(customerId,monthId,IndexCalConstant.COMMUNITY_GOVERN,subAllGridList);
factIndexCommunityScoreDao.insertCommunityPartyRecord(subAllGridList); return true;
} }
/** /**
@ -256,23 +248,16 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
* @date 2020/8/31 1:38 下午 * @date 2020/8/31 1:38 下午
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override public Boolean communityServiceAbilityCalculate(String customerId, String monthId) {
public void communityServiceAbilityCalculate(String customerId, String monthId) {
List<FactIndexCommunityScoreDTO> subAllGridList = new ArrayList<>(); List<FactIndexCommunityScoreDTO> subAllGridList = new ArrayList<>();
List<FactIndexCommunityScoreDTO> communityPublishArticle = new ArrayList<>(); List<FactIndexCommunityScoreDTO> communityPublishArticle = new ArrayList<>();
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), IndexCodeEnum.FU_WU_NENG_LI.getCode()); List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), IndexCodeEnum.FU_WU_NENG_LI.getCode());
detailListByParentCode.forEach(detail -> { detailListByParentCode.forEach(detail -> {
String indexCode = detail.getIndexCode(); String indexCode = detail.getIndexCode();
if (indexCode.equals(IndexCalConstant.COMMUNITY_SERVICE_AVG)){ if (indexCode.equals(IndexCalConstant.COMMUNITY_SERVICE_AVG)){
List<SubGridServiceAvgResultDTO> subGridServiceAvg = factIndexGridScoreDao.selectSubGridServiceAvgScore(customerId, monthId); List<SubGridServiceAvgResultDTO> subGridServiceAvg = factIndexGridScoreDao.selectSubGridServiceAvgScore(customerId, monthId);
if (subGridServiceAvg.size() == NumConstant.ONE){ if (subGridServiceAvg.size() == NumConstant.ONE){
// TODO 只有一条记录时 // TODO 只有一条记录时
}else if (subGridServiceAvg.size() > NumConstant.ONE ){ }else if (subGridServiceAvg.size() > NumConstant.ONE ){
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridServiceAvg.stream().map(o -> o.getScore()).collect(Collectors.toList())); MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridServiceAvg.stream().map(o -> o.getScore()).collect(Collectors.toList()));
Integer indexStart = NumConstant.ZERO; Integer indexStart = NumConstant.ZERO;
@ -306,9 +291,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
}else{ }else{
List<CommunityActivityCountResultDTO> communityActivityCount = factIndexServiceAblityOrgMonthlyDao.selectActivityCount(customerId, monthId); List<CommunityActivityCountResultDTO> communityActivityCount = factIndexServiceAblityOrgMonthlyDao.selectActivityCount(customerId, monthId);
if (communityActivityCount.size() == NumConstant.ONE){ if (communityActivityCount.size() == NumConstant.ONE){
// TODO // TODO
}else if (communityActivityCount.size() > NumConstant.ONE){ }else if (communityActivityCount.size() > NumConstant.ONE){
Integer indexStart = NumConstant.ZERO; Integer indexStart = NumConstant.ZERO;
Integer indexEnd = NumConstant.TEN; Integer indexEnd = NumConstant.TEN;
@ -346,9 +329,8 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
} }
}); });
}); });
factIndexCommunityScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.COMMUNITY_SERVICE); deleteAndInsert(customerId,monthId,IndexCalConstant.COMMUNITY_SERVICE,subAllGridList);
factIndexCommunityScoreDao.insertCommunityPartyRecord(subAllGridList); return true;
} }
/** /**
@ -358,7 +340,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
* @author zxc * @author zxc
* @date 2020/9/1 9:21 上午 * @date 2020/9/1 9:21 上午
*/ */
public void communityRelate(String customerId, String monthId) { public Boolean communityRelate(String customerId, String monthId) {
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode()); List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode());
List<FactIndexCommunityScoreDTO> factIndexCommunityScoreEntities = factIndexCommunityScoreDao.selectCommunityInfo(customerId, monthId); List<FactIndexCommunityScoreDTO> factIndexCommunityScoreEntities = factIndexCommunityScoreDao.selectCommunityInfo(customerId, monthId);
detailListByParentCode.forEach(detail -> { detailListByParentCode.forEach(detail -> {
@ -384,16 +366,35 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
}); });
result.add(score); result.add(score);
}); });
factIndexCommunityScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.COMMUNITY_RELATE); deleteAndInsert(customerId,monthId,IndexCalConstant.COMMUNITY_RELATE,result);
factIndexCommunityScoreDao.insertCommunityPartyRecord(result); return true;
} }
public void calAll(String customerId,String monthId){ /**
this.communityPartyCalculate(customerId, monthId); //党建能力 * @Description 计算社区相关总分
this.communityGovernAbilityCalculate(customerId, monthId); // 治理能力 * @param customerId
this.communityServiceAbilityCalculate(customerId, monthId); // 服务能力 * @param monthId
* @author zxc
communityRelate(customerId, monthId); * @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(); BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
return batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); 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<FactIndexCommunityScoreDTO> subAllGridList){
factIndexCommunityScoreDao.deleteOldRecord(customerId,monthId,indexCode);
factIndexCommunityScoreDao.insertCommunityPartyRecord(subAllGridList);
}
} }

Loading…
Cancel
Save