|
@ -41,6 +41,7 @@ import java.util.ArrayList; |
|
|
import java.util.HashMap; |
|
|
import java.util.HashMap; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
@Slf4j |
|
|
@Slf4j |
|
@ -82,28 +83,18 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { |
|
|
int pageSize = IndexCalConstant.PAGE_SIZE; |
|
|
int pageSize = IndexCalConstant.PAGE_SIZE; |
|
|
List<CpcScoreEntity> list = null; |
|
|
List<CpcScoreEntity> list = null; |
|
|
|
|
|
|
|
|
Map<String, CpcScoreEntity> preLastCpcScoreTotalMap = new HashMap<>(); |
|
|
|
|
|
//当前最后一条记录
|
|
|
|
|
|
//CpcScoreEntity currentLastCpcScore = null;
|
|
|
|
|
|
//当前第一条记录
|
|
|
|
|
|
//CpcScoreEntity currentFirstCpcScore = null;
|
|
|
|
|
|
do { |
|
|
|
|
|
Map<String, CpcScoreEntity> cpcScoreTotalMap = new HashMap<>(); |
|
|
Map<String, CpcScoreEntity> cpcScoreTotalMap = new HashMap<>(); |
|
|
|
|
|
Map<String, AtomicInteger> userTotalCount = new HashMap<>(); |
|
|
|
|
|
//删除总分 然后插入
|
|
|
|
|
|
cpcScoreDao.deleteByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(), IndexCalConstant.DELETE_SIZE, NumConstant.ONE_STR); |
|
|
|
|
|
do { |
|
|
|
|
|
List<CpcScoreEntity> result = new ArrayList<>(); |
|
|
//获取数据
|
|
|
//获取数据
|
|
|
list = cpcScoreDao.getPartScore(formDTO.getCustomerId(), formDTO.getMonthId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(), (pageNo - NumConstant.ONE) * pageSize, pageSize); |
|
|
list = cpcScoreDao.getPartScore(formDTO.getCustomerId(), formDTO.getMonthId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(), (pageNo - NumConstant.ONE) * pageSize, pageSize); |
|
|
pageNo++; |
|
|
pageNo++; |
|
|
if (CollectionUtils.isEmpty(list)) { |
|
|
if (CollectionUtils.isEmpty(list)) { |
|
|
log.warn("calculateTotalScore cpcScoreDao.getPartScore return empty,customerId:{},monthId:{}", formDTO.getCustomerId(), formDTO.getMonthId()); |
|
|
log.warn("calculateTotalScore cpcScoreDao.getPartScore return empty,customerId:{},monthId:{}", formDTO.getCustomerId(), formDTO.getMonthId()); |
|
|
} else { |
|
|
} else { |
|
|
//获取最后一条
|
|
|
|
|
|
//currentLastCpcScore = list.get(list.size() - 1);
|
|
|
|
|
|
//获取第一条
|
|
|
|
|
|
//currentFirstCpcScore = list.get(0);
|
|
|
|
|
|
/*if (preLastCpcScoreTotalMap.containsKey(currentFirstCpcScore.getUserId())) { |
|
|
|
|
|
cpcScoreTotalMap.putAll(preLastCpcScoreTotalMap); |
|
|
|
|
|
preLastCpcScoreTotalMap.clear(); |
|
|
|
|
|
preLastCpcScoreTotalMap.put(currentLastCpcScore.getUserId(), null); |
|
|
|
|
|
}*/ |
|
|
|
|
|
Map<String, List<CpcScoreEntity>> userGroupMap = list.stream().collect(Collectors.groupingBy(CpcScoreEntity::getUserId)); |
|
|
Map<String, List<CpcScoreEntity>> userGroupMap = list.stream().collect(Collectors.groupingBy(CpcScoreEntity::getUserId)); |
|
|
userGroupMap.forEach((userId, partScoreList) -> { |
|
|
userGroupMap.forEach((userId, partScoreList) -> { |
|
|
CpcScoreEntity totalEntity = null; |
|
|
CpcScoreEntity totalEntity = null; |
|
@ -121,27 +112,26 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { |
|
|
totalEntity.setAllParentIndexCode(NumConstant.ZERO_STR); |
|
|
totalEntity.setAllParentIndexCode(NumConstant.ZERO_STR); |
|
|
totalEntity.setWeight(new BigDecimal(NumConstant.ONE_NEG)); |
|
|
totalEntity.setWeight(new BigDecimal(NumConstant.ONE_NEG)); |
|
|
cpcScoreTotalMap.put(userId, totalEntity); |
|
|
cpcScoreTotalMap.put(userId, totalEntity); |
|
|
|
|
|
|
|
|
/* if (preLastCpcScoreTotalMap.containsKey(part.getUserId())) { |
|
|
|
|
|
preLastCpcScoreTotalMap.put(part.getUserId(), part); |
|
|
|
|
|
} else { |
|
|
|
|
|
}*/ |
|
|
|
|
|
} |
|
|
} |
|
|
//自建群活跃度——议题转项目率 有阈值 >60%按60%算
|
|
|
//自建群活跃度——议题转项目率 有阈值 >60%按60%算
|
|
|
BigDecimal total = part.getScore().multiply(indexGroupDetailEntity.getWeight()); |
|
|
BigDecimal total = part.getScore().multiply(indexGroupDetailEntity.getWeight()); |
|
|
|
|
|
AtomicInteger atomicInteger = userTotalCount.get(part.getUserId()); |
|
|
|
|
|
|
|
|
|
|
|
if (atomicInteger == null) { |
|
|
|
|
|
atomicInteger = new AtomicInteger(0); |
|
|
|
|
|
userTotalCount.put(part.getUserId(), atomicInteger); |
|
|
|
|
|
} |
|
|
|
|
|
int totalCount = atomicInteger.addAndGet(1); |
|
|
|
|
|
//todo 次代码限制了 党员的 4级指标的个数 看看是否还有更好的方式
|
|
|
|
|
|
if (totalCount == 3) { |
|
|
|
|
|
result.add(totalEntity); |
|
|
|
|
|
} |
|
|
log.info("userId:{},分数:{},权重:{},total:{}", userId, part.getScore(), indexGroupDetailEntity.getWeight(), total); |
|
|
log.info("userId:{},分数:{},权重:{},total:{}", userId, part.getScore(), indexGroupDetailEntity.getWeight(), total); |
|
|
totalEntity.setScore(totalEntity.getScore().add(total)); |
|
|
totalEntity.setScore(totalEntity.getScore().add(total)); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
insertCpcScoreBatch(formDTO, result, IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode()); |
|
|
//没查询到数据 就把上次的放进去
|
|
|
|
|
|
if (list == null || list.size() < pageSize || !CollectionUtils.isEmpty(preLastCpcScoreTotalMap)) { |
|
|
|
|
|
cpcScoreTotalMap.putAll(preLastCpcScoreTotalMap); |
|
|
|
|
|
} |
|
|
|
|
|
//删除总分 然后插入
|
|
|
|
|
|
cpcScoreDao.deleteByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(), IndexCalConstant.DELETE_SIZE, NumConstant.ONE_STR); |
|
|
|
|
|
insertCpcScoreBatch(formDTO, cpcScoreTotalMap.values().stream().collect(Collectors.toList()), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode()); |
|
|
|
|
|
} while (!CollectionUtils.isEmpty(list)); |
|
|
} while (!CollectionUtils.isEmpty(list)); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
@ -180,7 +170,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { |
|
|
*/ |
|
|
*/ |
|
|
public void insertCpcScoreBatch(CalculateCommonFormDTO formDTO, List<CpcScoreEntity> values, String indexCode) { |
|
|
public void insertCpcScoreBatch(CalculateCommonFormDTO formDTO, List<CpcScoreEntity> values, String indexCode) { |
|
|
if (CollectionUtils.isEmpty(values)) { |
|
|
if (CollectionUtils.isEmpty(values)) { |
|
|
log.error("insertCpcScoreBatch要插入的数据为空,param:{},indexCode:{}", JSON.toJSONString(formDTO), indexCode); |
|
|
log.warn("insertCpcScoreBatch要插入的数据为空,param:{},indexCode:{}", JSON.toJSONString(formDTO), indexCode); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
List<List<CpcScoreEntity>> partition = ListUtils.partition(values, IndexCalConstant.INSERT_SIZE); |
|
|
List<List<CpcScoreEntity>> partition = ListUtils.partition(values, IndexCalConstant.INSERT_SIZE); |
|
@ -338,7 +328,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { |
|
|
*/ |
|
|
*/ |
|
|
public void insertCpcSubScoreBatch(CalculateCommonFormDTO formDTO, List<CpcSubScoreEntity> subList, String parentIndexCode) { |
|
|
public void insertCpcSubScoreBatch(CalculateCommonFormDTO formDTO, List<CpcSubScoreEntity> subList, String parentIndexCode) { |
|
|
if (CollectionUtils.isEmpty(subList)) { |
|
|
if (CollectionUtils.isEmpty(subList)) { |
|
|
log.error("insertCpcScoreBatch要插入的数据为空,param:{},indexCode:{}", JSON.toJSONString(formDTO), parentIndexCode); |
|
|
log.warn("insertCpcScoreBatch要插入的数据为空,param:{},indexCode:{}", JSON.toJSONString(formDTO), parentIndexCode); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
List<List<CpcSubScoreEntity>> partition = ListUtils.partition(subList, IndexCalConstant.INSERT_SIZE); |
|
|
List<List<CpcSubScoreEntity>> partition = ListUtils.partition(subList, IndexCalConstant.INSERT_SIZE); |
|
|