|
|
@ -73,7 +73,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { |
|
|
|
Map<String, IndexGroupDetailEntity> indexWeightMap = parentIndexDetails.stream().collect(Collectors.toMap(IndexGroupDetailEntity::getIndexCode, o -> o)); |
|
|
|
|
|
|
|
//获取数据
|
|
|
|
List<CpcScoreEntity> list = cpcScoreDao.getPartScore(formDTO.getCustomerId(), formDTO.getMonthId()); |
|
|
|
List<CpcScoreEntity> list = cpcScoreDao.getPartScore(formDTO.getCustomerId(), formDTO.getMonthId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode()); |
|
|
|
if (CollectionUtils.isEmpty(list)) { |
|
|
|
log.error("calculateTotalScore cpcScoreDao.getPartScore return empty,customerId:{},monthId:{}", formDTO.getCustomerId(), formDTO.getMonthId()); |
|
|
|
throw new RenException("客户四级指标分值记录不存在"); |
|
|
@ -83,11 +83,16 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { |
|
|
|
CpcScoreEntity totalEntity = null; |
|
|
|
for (CpcScoreEntity part : partScoreList) { |
|
|
|
IndexGroupDetailEntity indexGroupDetailEntity = indexWeightMap.get(part.getIndexCode()); |
|
|
|
if (indexGroupDetailEntity == null) { |
|
|
|
log.error(" indexCode:{} 在指标明细中不存在", part.getIndexCode()); |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (totalEntity == null) { |
|
|
|
totalEntity = ConvertUtils.sourceToTarget(part, CpcScoreEntity.class); |
|
|
|
totalEntity.setIsTotal(NumConstant.ONE_STR); |
|
|
|
totalEntity.setIndexCode(IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode()); |
|
|
|
totalEntity.setScore(new BigDecimal(0)); |
|
|
|
totalEntity.setAllParentIndexCode(indexGroupDetailEntity.getAllParentIndexCode()); |
|
|
|
cpcScoreTotalMap.put(userId, totalEntity); |
|
|
|
} |
|
|
|
//自建群活跃度——议题转项目率 有阈值 >60%按60%算
|
|
|
@ -160,8 +165,8 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { |
|
|
|
//如果是第一页且仅有一条数据 则直接给50分
|
|
|
|
if (pageNo == NumConstant.ONE && list.size() == NumConstant.ONE) { |
|
|
|
List<CpcScoreEntity> insertList = new ArrayList<>(); |
|
|
|
for (String parentIndexCode : groupIndexDetailsMap.keySet()) { |
|
|
|
insertList.add(handleOneGridScene(formDTO, parentIndexCode, list.get(0))); |
|
|
|
for (String indexCode : groupIndexDetailsMap.keySet()) { |
|
|
|
insertList.add(handleOneGridScene(formDTO, indexCode, list.get(0))); |
|
|
|
} |
|
|
|
if (CollectionUtils.isEmpty(insertList)) { |
|
|
|
deleteAndInsertBatch(formDTO, insertList, null); |
|
|
@ -169,9 +174,9 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { |
|
|
|
} else { |
|
|
|
//遍历指标分组 计算分数
|
|
|
|
for (Map.Entry<String, List<IndexGroupDetailEntity>> entry : groupIndexDetailsMap.entrySet()) { |
|
|
|
String parentIndexCode = entry.getKey(); |
|
|
|
String indexCode = entry.getKey(); |
|
|
|
List<IndexGroupDetailEntity> details = entry.getValue(); |
|
|
|
calculateScore(formDTO, details, list, minAndMaxMap, parentIndexCode); |
|
|
|
calculateScore(formDTO, details, list, minAndMaxMap, indexCode); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -216,7 +221,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { |
|
|
|
cpcScoreEntity.setMonthId(formDTO.getMonthId()); |
|
|
|
cpcScoreEntity.setScore(new BigDecimal(0)); |
|
|
|
cpcScoreEntity.setIndexCode(parentIndexCode); |
|
|
|
|
|
|
|
cpcScoreEntity.setAllParentIndexCode(value.getAllParentIndexCode()); |
|
|
|
scoreEntityMap.put(userId, cpcScoreEntity); |
|
|
|
|
|
|
|
//构造样本值对象
|
|
|
@ -251,10 +256,14 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { |
|
|
|
result.forEach((userId, score) -> { |
|
|
|
CpcScoreEntity cpcScoreEntity = indexDetails.get(userId); |
|
|
|
cpcScoreEntity.setScore(score.getTotalScore()); |
|
|
|
String allParentIndexCode = score.getDetails().get(0).getAllParentIndexCode(); |
|
|
|
cpcScoreEntity.setAllParentIndexCode(allParentIndexCode.substring(0, allParentIndexCode.lastIndexOf(StrConstant.COLON))); |
|
|
|
list.add(cpcScoreEntity); |
|
|
|
CpcScoreEntity parent = ConvertUtils.sourceToTarget(cpcScoreEntity, CpcScoreEntity.class); |
|
|
|
score.getDetails().forEach(o -> { |
|
|
|
CpcScoreEntity child = ConvertUtils.sourceToTarget(o, CpcScoreEntity.class); |
|
|
|
CpcScoreEntity child = ConvertUtils.sourceToTarget(parent, CpcScoreEntity.class); |
|
|
|
child.setIndexCode(o.getIndexCode()); |
|
|
|
child.setAllParentIndexCode(o.getAllParentIndexCode()); |
|
|
|
child.setScore(o.getScore()); |
|
|
|
list.add(child); |
|
|
|
}); |
|
|
|