|
|
@ -6,19 +6,25 @@ import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|
|
|
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.CommunityScoreDao; |
|
|
|
import com.epmet.dao.evaluationindex.indexcal.CommunitySelfSubScoreDao; |
|
|
|
import com.epmet.dao.evaluationindex.indexcal.CommunitySubScoreDao; |
|
|
|
import com.epmet.dao.evaluationindex.indexcal.GridScoreDao; |
|
|
|
import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityOrgMonthlyDao; |
|
|
|
import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityOrgMonthlyDao; |
|
|
|
import com.epmet.dao.evaluationindex.indexcoll.FactIndexServiceAblityOrgMonthlyDao; |
|
|
|
import com.epmet.dao.evaluationindex.screen.IndexGroupDetailDao; |
|
|
|
import com.epmet.dto.indexcal.CalculateCommonFormDTO; |
|
|
|
import com.epmet.dto.indexcal.CommunityCalResultDTO; |
|
|
|
import com.epmet.dto.screen.FactIndexCommunityScoreDTO; |
|
|
|
import com.epmet.dto.screen.result.MaxAndMinBigDecimalResultDTO; |
|
|
|
import com.epmet.dto.screen.result.SubGridAvgResultDTO; |
|
|
|
import com.epmet.entity.evaluationindex.indexcal.CommunitySelfSubScoreEntity; |
|
|
|
import com.epmet.entity.evaluationindex.indexcal.FactIndexCommunitySubScoreEntity; |
|
|
|
import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity; |
|
|
|
import com.epmet.eum.IndexCodeEnum; |
|
|
|
import com.epmet.service.evaluationindex.indexcal.IndexCalculateCommunityService; |
|
|
@ -68,6 +74,10 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni |
|
|
|
private GridScoreDao factIndexGridScoreDao; |
|
|
|
@Autowired |
|
|
|
private CommunitySubScoreDao communitySubScoreDao; |
|
|
|
@Autowired |
|
|
|
private IndexGroupDetailDao indexGroupDetailDao; |
|
|
|
@Autowired |
|
|
|
private CommunitySelfSubScoreDao communitySelfSubScoreDao; |
|
|
|
|
|
|
|
/** |
|
|
|
* @param customerId |
|
|
@ -76,6 +86,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni |
|
|
|
* @author zxc |
|
|
|
* @date 2020/9/1 4:12 下午 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Boolean calCommunityAll(String customerId, String monthId) { |
|
|
|
Boolean aBoolean = communityPartyCalculate(customerId, monthId);//党建能力
|
|
|
|
if (!aBoolean.equals(true)) { |
|
|
@ -93,9 +104,84 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni |
|
|
|
if (!dBoolean.equals(true)) { |
|
|
|
throw new RenException("calculate community-all insert failure ......"); |
|
|
|
} |
|
|
|
//计算自身和下级
|
|
|
|
CalculateCommonFormDTO formDTO = new CalculateCommonFormDTO(); |
|
|
|
formDTO.setMonthId(monthId); |
|
|
|
formDTO.setCustomerId(customerId); |
|
|
|
calculateSelfSubScore(formDTO); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
private void calculateSelfSubScore(CalculateCommonFormDTO formDTO) { |
|
|
|
//todo 指标添加缓存
|
|
|
|
List<IndexGroupDetailEntity> indexList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(), |
|
|
|
IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode()); |
|
|
|
if (CollectionUtils.isEmpty(indexList)) { |
|
|
|
log.error("calculateSelfSubScore customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); |
|
|
|
throw new RenException("客户【网格相关】指标权重信息不存在"); |
|
|
|
} |
|
|
|
indexList.forEach(index -> { |
|
|
|
String levelIndexPath = index.getAllParentIndexCode().concat(StrConstant.COLON).concat(index.getIndexCode()); |
|
|
|
//获取出指标之间的关系
|
|
|
|
List<IndexGroupDetailEntity> selfSubIndexList = indexGroupDetailDao.selectSelfSubIndex(formDTO.getCustomerId(), levelIndexPath); |
|
|
|
if (CollectionUtils.isEmpty(selfSubIndexList)) { |
|
|
|
log.error("calculateSelfSubScore indexGroupDetailDao.selectSelfSubIndex return empty,customerId:{}", formDTO.getCustomerId()); |
|
|
|
return; |
|
|
|
} |
|
|
|
//获取该能力下的分数
|
|
|
|
List<FactIndexCommunitySubScoreEntity> subScore = communitySubScoreDao.selectSubListByPath(formDTO.getCustomerId(), formDTO.getMonthId(), levelIndexPath); |
|
|
|
if (CollectionUtils.isEmpty(subScore)) { |
|
|
|
log.error("calculateSelfSubScore communitySubScoreDao.selectSubListByPath return empty,customerId:{} ", formDTO.getCustomerId()); |
|
|
|
return; |
|
|
|
} |
|
|
|
Map<String, Set<String>> selfSubParentMap = new HashMap<>(); |
|
|
|
selfSubParentMap.put("zishen", new HashSet<>()); |
|
|
|
selfSubParentMap.put("xiaji", new HashSet<>()); |
|
|
|
selfSubIndexList.forEach(o -> { |
|
|
|
//找出自身 和下级的指标
|
|
|
|
if (o.getAllIndexCodePath().indexOf("xiaji") > -1) { |
|
|
|
selfSubParentMap.get("xiaji").add(o.getIndexCode()); |
|
|
|
} else { |
|
|
|
selfSubParentMap.get("zishen").add(o.getIndexCode()); |
|
|
|
} |
|
|
|
}); |
|
|
|
Map<String, CommunitySelfSubScoreEntity> insertMap = new HashMap<>(); |
|
|
|
subScore.forEach(score -> { |
|
|
|
String key = score.getAgencyId().concat(index.getIndexCode()); |
|
|
|
CommunitySelfSubScoreEntity scoreEntity = insertMap.get(key); |
|
|
|
if (scoreEntity == null) { |
|
|
|
scoreEntity = ConvertUtils.sourceToTarget(score, CommunitySelfSubScoreEntity.class); |
|
|
|
insertMap.put(key, scoreEntity); |
|
|
|
scoreEntity.setSelfScore(new BigDecimal(0)); |
|
|
|
scoreEntity.setSubScore(new BigDecimal(0)); |
|
|
|
scoreEntity.setParentIndexCode(index.getIndexCode()); |
|
|
|
scoreEntity.setSelfWeight(new BigDecimal(0)); |
|
|
|
scoreEntity.setSubWeight(new BigDecimal(0)); |
|
|
|
} |
|
|
|
BigDecimal partScore = score.getScore().multiply(score.getWeight()); |
|
|
|
if (selfSubParentMap.get("xiaji").contains(score.getIndexCode())) { |
|
|
|
scoreEntity.setSubScore(scoreEntity.getSubScore().add(partScore)); |
|
|
|
scoreEntity.setSubWeight(scoreEntity.getSubWeight().add(score.getWeight())); |
|
|
|
} else { |
|
|
|
scoreEntity.setSelfScore(scoreEntity.getSelfScore().add(partScore)); |
|
|
|
scoreEntity.setSelfWeight(scoreEntity.getSelfWeight().add(score.getWeight())); |
|
|
|
} |
|
|
|
log.debug("=====key" + key + ",grid:{},originScore:{},weight:{},finalScore:{},total", score.getAgencyId(), score.getScore(), score.getWeight(), partScore); |
|
|
|
}); |
|
|
|
deleteAndInsertSelfSubScore(formDTO, index.getIndexCode(), insertMap); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void deleteAndInsertSelfSubScore(CalculateCommonFormDTO formDTO, String indexCode, Map<String, CommunitySelfSubScoreEntity> insertMap) { |
|
|
|
int effectRow = 0; |
|
|
|
do { |
|
|
|
communitySelfSubScoreDao.deleteByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode); |
|
|
|
} while (effectRow > 0); |
|
|
|
|
|
|
|
communitySelfSubScoreDao.insertBatch(new ArrayList<>(insertMap.values())); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param customerId |
|
|
|
* @Description 社区名义发文数量计算【党建能力】 |
|
|
|