Browse Source

Merge remote-tracking branch 'origin/dev_screen_data' into dev_screen_data

dev_shibei_match
yinzuomei 5 years ago
parent
commit
24bc0ae189
  1. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java
  2. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexServiceAblityOrgMonthlyDao.java
  3. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/redis/IndexCodeFieldReRedis.java
  4. 14
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/CpcIndexCalculateServiceImpl.java
  5. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexCalculateCommunityService.java
  6. 261
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateCommunityServiceImpl.java
  7. 89
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java
  8. 28
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/BigDecimalScoreCalculator.java
  9. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/ScoreCalculator.java
  10. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexInputVO.java
  11. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/SampleValue.java
  12. 2
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml
  13. 19
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexServiceAblityOrgMonthlyDao.xml
  14. 1
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityScoreDao.xml
  15. 56
      epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/DemoScoreCal.java

8
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java

@ -144,13 +144,7 @@ public class DemoController {
@PostMapping("zxc2")
public Result getZxc2(){
indexCalculateCommunityService.communityServiceAbilityCalculate("b09527201c4409e19d1dbc5e3c3429a1","202008");
return new Result();
}
@PostMapping("zxcAll")
public Result getZxcAll(){
indexCalculateCommunityService.communityRelate("b09527201c4409e19d1dbc5e3c3429a1","202008");
indexCalculateCommunityService.calAll("b09527201c4409e19d1dbc5e3c3429a1","202008");
return new Result();
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexServiceAblityOrgMonthlyDao.java

@ -26,6 +26,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 服务能力-组织街道|社区|全区相关事实表
@ -73,4 +74,5 @@ public interface FactIndexServiceAblityOrgMonthlyDao extends BaseDao<FactIndexSe
* @date 2020/8/31 2:15 下午
*/
List<CommunityActivityCountResultDTO> selectActivityCount(@Param("customerId")String customerId, @Param("monthId")String monthId);
List<Map<String,Object>> selectActivityCountMap(@Param("customerId")String customerId, @Param("monthId")String monthId);
}

8
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/redis/IndexCodeFieldReRedis.java

@ -51,4 +51,12 @@ public class IndexCodeFieldReRedis {
hashOperations.putAll(RedisKeys.getIndexCodeFieldReKey(), records);
redisTemplate.expire(RedisKeys.getIndexCodeFieldReKey(), 1, TimeUnit.DAYS);
}
/**
* desc:删除指标字段关系缓存
* @return
*/
public Boolean deleteIndexCodeFromRedis() {
return redisTemplate.delete(RedisKeys.getIndexCodeFieldReKey());
}
}

14
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/CpcIndexCalculateServiceImpl.java

@ -1,5 +1,6 @@
package com.epmet.service.indexcal.impl;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.exception.RenException;
@ -104,17 +105,18 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService {
Map<String, String> indexCodeFieldReList = indexCodeFieldReService.getIndexCodeFieldReMap();
if (CollectionUtils.isEmpty(indexCodeFieldReList)) {
log.error("cpcIndexCalculate have any indexcodefieldre");
return;
throw new RenException("指标code与字段关系记录不存在");
}
//计算最大最小值
Map<String, Object> minAndMaxMap = factIndexPartyAblityCpcMonthlyDao.getExtremeValue(formDTO.getCustomerId());
if (CollectionUtils.isEmpty(minAndMaxMap)) {
log.error("cpcIndexCalculate getExtremeValue customerId:{} have not any fact record", formDTO.getCustomerId());
return;
throw new RenException("指标原始数据记录不存在");
}
//指标集合
Map<String, List<IndexGroupDetailEntity>> groupIndexDetailsMap = getIndexDetailMap(formDTO);
if (groupIndexDetailsMap == null) {
log.error("calculatePartScore");
return;
}
@ -152,7 +154,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService {
IndexInputVO<BigDecimal> value = entry.getValue();
String fieldName = indexCodeFieldReService.getFieldNameByIndexCode(indexCode);
if (StringUtils.isBlank(fieldName)) {
log.error("cpcIndexCalculate fieldName error");
log.error("calculateScore indexCode:{} get fieldName return blank", indexCode);
continue;
}
@ -179,9 +181,9 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService {
value.getIndexValueVOs().add(currentUserIndexValue);
}
}
log.warn("计算的参数:{}", indexMap);
log.info("计算的参数:{}", JSON.toJSONString(indexMap));
HashMap<String, BigDecimal> result = calculateScore(indexMap);
log.warn("计算的结果:{}", result);
log.info("计算的结果:{}", result);
//处理结果
saveCpcScore(formDTO, scoreEntityMap, parentIndexCode, result);
@ -240,7 +242,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService {
ScoreConstants.MAX_SCORE,
Correlation.getCorrelation(index.getCorrelation())
);
IndexInputVO indexInputVO = new IndexInputVO(index.getIndexCode(),new ArrayList<>(),index.getThreshold(),index.getWeight(),scoreCalculator);
IndexInputVO indexInputVO = new IndexInputVO(index.getIndexCode(), new ArrayList<>(), index.getThreshold(), index.getWeight(), scoreCalculator);
map.put(index.getIndexCode(), indexInputVO);
}
return map;

6
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexCalculateCommunityService.java

@ -39,11 +39,11 @@ public interface IndexCalculateCommunityService {
void communityServiceAbilityCalculate(String customerId, String monthId);
/**
* @Description 社区相关计算
* @Description 计算社区相关
* @param customerId
* @param monthId
* @author zxc
* @date 2020/9/1 9:21
* @date 2020/9/1 4:12
*/
void communityRelate(String customerId, String monthId);
void calAll(String customerId, String monthId);
}

261
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateCommunityServiceImpl.java

@ -62,7 +62,6 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
@Transactional(rollbackFor = Exception.class)
@Override
public void communityPartyCalculate(String customerId, String monthId) {
customerId = "b09527201c4409e19d1dbc5e3c3429a1";
// 党建能力
// 根据all_parent_index_code 获取指标明细
@ -70,10 +69,9 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
List<FactIndexCommunityScoreDTO> subAllGridList = new ArrayList<>();
List<FactIndexCommunityScoreDTO> communityPublishArticle = new ArrayList<>();
//下属所有网格的党建能力平均值
String finalCustomerId = customerId;
detailListByParentCode.forEach(indexGroup -> {
if (indexGroup.getIndexCode().equals(IndexCalConstant.COMMUNITY_PARTY_AVG)){
List<SubGridPartyAvgResultDTO> subGridPartyAvgScore = factIndexGridScoreDao.selectSubGridPartyAvgScore(finalCustomerId, monthId);
List<SubGridPartyAvgResultDTO> subGridPartyAvgScore = factIndexGridScoreDao.selectSubGridPartyAvgScore(customerId, monthId);
if (subGridPartyAvgScore.size() != NumConstant.ZERO){
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridPartyAvgScore.stream().map(o -> o.getScore()).collect(Collectors.toList()));
Integer indexStart = NumConstant.ZERO;
@ -81,7 +79,6 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
List<SubGridPartyAvgResultDTO> collect;
do {
collect = subGridPartyAvgScore.stream().skip(indexEnd * indexStart).limit(indexEnd).collect(Collectors.toList());
BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
List<SampleValue> index1SampleValues = new ArrayList<>();
collect.forEach(c -> {
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
@ -90,14 +87,11 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
BeanUtils.copyProperties(c,dto);
subAllGridList.add(dto);
});
IndexInputVO index1VO = new IndexInputVO(indexGroup.getIndexId(), index1SampleValues,indexGroup.getThreshold(), indexGroup.getWeight(), sc1);
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO);
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
List<IndexOutputVO> result = batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS);
result.get(NumConstant.ZERO).getIndexScoreVOs().forEach(agency -> {
HashMap<String, BigDecimal> result = this.getCalResult(maxAndMinBigDecimal, index1SampleValues, indexGroup);
result.forEach((key,value) -> {
subAllGridList.forEach(grid -> {
if (grid.getAgencyId().equals(agency.getSampleId())){
grid.setScore(agency.getSampleScore());
if (grid.getAgencyId().equals(key)){
grid.setScore(value);
}
});
});
@ -122,11 +116,10 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
Integer indexStart = NumConstant.ZERO;
Integer indexEnd = NumConstant.TEN;
List<CommunityPublishArticleCountResultDTO> collect;
MaxAndMinIntegerResultDTO maxAndMinInteger = this.getMaxAndMinInteger(publishArticleCounts.stream().map(CommunityPublishArticleCountResultDTO::getPublishArticleCount).collect(Collectors.toList()));
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(publishArticleCounts.stream().map(o -> new BigDecimal(o.getPublishArticleCount())).collect(Collectors.toList()));
do {
collect = publishArticleCounts.stream().skip(indexEnd * indexStart).limit(indexEnd).collect(Collectors.toList());
ScoreCalculator<Integer> sc1 = new IntegerScoreCalculator(maxAndMinInteger.getMin(), maxAndMinInteger.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
List<SampleValue<Integer>> ll = new ArrayList<>();
List<SampleValue> ll = new ArrayList<>();
collect.forEach(c -> {
SampleValue s = new SampleValue(c.getAgencyId(), c.getPublishArticleCount());
ll.add(s);
@ -134,15 +127,12 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
BeanUtils.copyProperties(c,publishArticle);
communityPublishArticle.add(publishArticle);
});
IndexInputVO<Integer> index1VO = new IndexInputVO<>(indexGroup.getIndexId(), ll,indexGroup.getThreshold(), indexGroup.getWeight(), sc1);
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO);
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
List<IndexOutputVO> result = batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS);
result.get(NumConstant.ZERO).getIndexScoreVOs().forEach(agency -> {
HashMap<String, BigDecimal> result = this.getCalResult(maxAndMinBigDecimal, ll, indexGroup);
result.forEach((key,value) -> {
communityPublishArticle.forEach(publish -> {
if (publish.getAgencyId().equals(agency.getSampleId())){
if (publish.getAgencyId().equals(key)){
publish.setIndexCode(indexGroup.getIndexCode());
publish.setScore(agency.getSampleScore());
publish.setScore(value);
}
});
});
@ -173,16 +163,11 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
@Transactional(rollbackFor = Exception.class)
@Override
public void communityGovernAbilityCalculate(String customerId, String monthId) {
customerId = "b09527201c4409e19d1dbc5e3c3429a1";
List<FactIndexCommunityScoreDTO> subAllGridList = new ArrayList<>();
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
String finalCustomerId = customerId;
detailListByParentCode.forEach(detail -> {
if (detail.getIndexCode().equals(IndexCalConstant.COMMUNITY_GOVERN_AVG)){
List<SubGridGovernAvgResultDTO> subGridGovernAvg = factIndexGridScoreDao.selectSubGridGovernAvgScore(finalCustomerId, monthId);
List<SubGridGovernAvgResultDTO> subGridGovernAvg = factIndexGridScoreDao.selectSubGridGovernAvgScore(customerId, monthId);
if (subGridGovernAvg.size() == NumConstant.ONE){
// TODO
@ -194,7 +179,6 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
List<SubGridGovernAvgResultDTO> collect;
do {
collect = subGridGovernAvg.stream().skip(indexEnd * indexStart).limit(indexEnd).collect(Collectors.toList());
BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
List<SampleValue> index1SampleValues = new ArrayList<>();
collect.forEach(c -> {
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
@ -203,11 +187,8 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
BeanUtils.copyProperties(c,dto);
subAllGridList.add(dto);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold() ,detail.getWeight(), sc1);
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO);
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
scoreCountOfSampleId.forEach((key,value) -> {
HashMap<String, BigDecimal> result = this.getCalResult(maxAndMinBigDecimal, index1SampleValues, detail);
result.forEach((key,value) -> {
subAllGridList.forEach(grid -> {
if (grid.getAgencyId().equals(key)){
grid.setScore(value);
@ -218,12 +199,9 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
}while (collect.size() == NumConstant.TEN);
}
}
else {
}
});
List<Map<String,Object>> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbility(finalCustomerId, monthId);
List<Map<String,Object>> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbility(customerId, monthId);
if (communityGovernAbility.size() == NumConstant.ONE){
// TODO
@ -250,21 +228,20 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
indexInputVOS.add(index1VO);
} while (collect.size() == NumConstant.TEN);
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
scoreCountOfSampleId.forEach((key,value) -> {
subAllGridList.forEach(grid -> {
if (key.equals(grid.getAgencyId())) {
grid.setCustomerId(finalCustomerId);
grid.setIndexCode(IndexCalConstant.COMMUNITY_GOVERN);
grid.setScore(grid.getScore().add(value));
}
});
});
}
}
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
scoreCountOfSampleId.forEach((key,value) -> {
subAllGridList.forEach(grid -> {
if (key.equals(grid.getAgencyId())) {
grid.setCustomerId(customerId);
grid.setIndexCode(IndexCalConstant.COMMUNITY_GOVERN);
grid.setScore(grid.getScore().add(value));
}
});
});
}
factIndexCommunityScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.COMMUNITY_GOVERN);
factIndexCommunityScoreDao.insertCommunityPartyRecord(subAllGridList);
@ -289,82 +266,75 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), IndexCodeEnum.FU_WU_NENG_LI.getCode());
detailListByParentCode.forEach(detail -> {
switch (detail.getIndexCode()){
case IndexCalConstant.COMMUNITY_SERVICE_AVG:
List<SubGridServiceAvgResultDTO> subGridServiceAvg = factIndexGridScoreDao.selectSubGridServiceAvgScore(customerId, monthId);
if (subGridServiceAvg.size() == NumConstant.ONE){
String indexCode = detail.getIndexCode();
if (indexCode.equals(IndexCalConstant.COMMUNITY_SERVICE_AVG)){
List<SubGridServiceAvgResultDTO> subGridServiceAvg = factIndexGridScoreDao.selectSubGridServiceAvgScore(customerId, monthId);
if (subGridServiceAvg.size() == NumConstant.ONE){
// TODO 只有一条记录时
// TODO 只有一条记录时
}else if (subGridServiceAvg.size() > NumConstant.ONE ){
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridServiceAvg.stream().map(o -> o.getScore()).collect(Collectors.toList()));
Integer indexStart = NumConstant.ZERO;
Integer indexEnd = NumConstant.TEN;
List<SubGridServiceAvgResultDTO> collect;
do {
collect = subGridServiceAvg.stream().skip(indexEnd * indexStart).limit(indexEnd).collect(Collectors.toList());
BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
List<SampleValue> index1SampleValues = new ArrayList<>();
collect.forEach(c -> {
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
FactIndexCommunityScoreDTO dto = new FactIndexCommunityScoreDTO();
BeanUtils.copyProperties(c,dto);
subAllGridList.add(dto);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues,detail.getThreshold(), detail.getWeight(), sc1);
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO);
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
List<IndexOutputVO> result = batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS);
result.get(NumConstant.ZERO).getIndexScoreVOs().forEach(agency -> {
subAllGridList.forEach(grid -> {
if (grid.getAgencyId().equals(agency.getSampleId())){
grid.setScore(agency.getSampleScore());
}
});
}else if (subGridServiceAvg.size() > NumConstant.ONE ){
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridServiceAvg.stream().map(o -> o.getScore()).collect(Collectors.toList()));
Integer indexStart = NumConstant.ZERO;
Integer indexEnd = NumConstant.TEN;
List<SubGridServiceAvgResultDTO> collect;
do {
collect = subGridServiceAvg.stream().skip(indexEnd * indexStart).limit(indexEnd).collect(Collectors.toList());
BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
List<SampleValue> index1SampleValues = new ArrayList<>();
collect.forEach(c -> {
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
FactIndexCommunityScoreDTO dto = new FactIndexCommunityScoreDTO();
BeanUtils.copyProperties(c,dto);
subAllGridList.add(dto);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues,detail.getThreshold(), detail.getWeight(), sc1);
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO);
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
List<IndexOutputVO> result = batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS);
result.get(NumConstant.ZERO).getIndexScoreVOs().forEach(agency -> {
subAllGridList.forEach(grid -> {
if (grid.getAgencyId().equals(agency.getSampleId())){
grid.setScore(agency.getSampleScore());
}
});
indexStart++;
}while (collect.size() == NumConstant.TEN);
}
break;
case "shequhuodongzzcs":
List<CommunityActivityCountResultDTO> communityActivityCount = factIndexServiceAblityOrgMonthlyDao.selectActivityCount(customerId, monthId);
if (communityActivityCount.size() == NumConstant.ONE){
});
indexStart++;
}while (collect.size() == NumConstant.TEN);
}
}else{
List<CommunityActivityCountResultDTO> communityActivityCount = factIndexServiceAblityOrgMonthlyDao.selectActivityCount(customerId, monthId);
if (communityActivityCount.size() == NumConstant.ONE){
// TODO
// TODO
}else if (communityActivityCount.size() > NumConstant.ONE){
Integer indexStart = NumConstant.ZERO;
Integer indexEnd = NumConstant.TEN;
List<CommunityActivityCountResultDTO> collect;
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(communityActivityCount.stream().map(o -> new BigDecimal(o.getActivityCount())).collect(Collectors.toList()));
do {
collect = communityActivityCount.stream().skip(indexEnd * indexStart).limit(indexEnd).collect(Collectors.toList());
ScoreCalculator<Integer> sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
List<SampleValue<Integer>> ll = new ArrayList<>();
collect.forEach(c -> {
SampleValue s = new SampleValue(c.getAgencyId(), c.getActivityCount());
ll.add(s);
FactIndexCommunityScoreDTO publishArticle = new FactIndexCommunityScoreDTO();
BeanUtils.copyProperties(c,publishArticle);
communityPublishArticle.add(publishArticle);
});
IndexInputVO<Integer> index1VO = new IndexInputVO<>(detail.getIndexId(), ll, detail.getThreshold(),detail.getWeight(), sc1);
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO);
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
List<IndexOutputVO> result = batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS);
result.get(NumConstant.ZERO).getIndexScoreVOs().forEach(agency -> {
communityPublishArticle.forEach(publish -> {
if (publish.getAgencyId().equals(agency.getSampleId())){
publish.setScore(agency.getSampleScore());
}
});
}else if (communityActivityCount.size() > NumConstant.ONE){
Integer indexStart = NumConstant.ZERO;
Integer indexEnd = NumConstant.TEN;
List<CommunityActivityCountResultDTO> collect;
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(communityActivityCount.stream().map(o -> new BigDecimal(o.getActivityCount())).collect(Collectors.toList()));
do {
collect = communityActivityCount.stream().skip(indexEnd * indexStart).limit(indexEnd).collect(Collectors.toList());
List<SampleValue> ll = new ArrayList<>();
collect.forEach(c -> {
SampleValue s = new SampleValue(c.getAgencyId(), c.getActivityCount());
ll.add(s);
FactIndexCommunityScoreDTO publishArticle = new FactIndexCommunityScoreDTO();
BeanUtils.copyProperties(c,publishArticle);
communityPublishArticle.add(publishArticle);
});
HashMap<String, BigDecimal> result = this.getCalResult(maxAndMinBigDecimal, ll, detail);
result.forEach((k,v) -> {
communityPublishArticle.forEach(publish -> {
if (publish.getAgencyId().equals(k)){
publish.setScore(v);
}
});
indexStart++;
} while (collect.size() == NumConstant.TEN);
}
break;
default:
});
indexStart++;
} while (collect.size() == NumConstant.TEN);
}
}
});
subAllGridList.forEach(grid -> {
@ -388,15 +358,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
* @author zxc
* @date 2020/9/1 9:21 上午
*/
@Override
public void communityRelate(String customerId, String monthId) {
this.communityPartyCalculate(customerId, monthId); //党建能力
this.communityGovernAbilityCalculate(customerId, monthId); // 治理能力
this.communityServiceAbilityCalculate(customerId, monthId); // 服务能力
List<FactIndexCommunityScoreDTO> communityPublishArticle = new ArrayList<>();
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode());
List<FactIndexCommunityScoreDTO> factIndexCommunityScoreEntities = factIndexCommunityScoreDao.selectCommunityInfo(customerId, monthId);
detailListByParentCode.forEach(detail -> {
@ -406,7 +368,6 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
}
});
});
Map<String, List<FactIndexCommunityScoreDTO>> collect = factIndexCommunityScoreEntities.stream().collect(Collectors.groupingBy(FactIndexCommunityScoreDTO::getAgencyId));
List<FactIndexCommunityScoreDTO> result = new ArrayList<>();
collect.forEach((key,value) -> {
@ -417,7 +378,8 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
score.setMonthId(monthId);
score.setYearId(DateUtils.getYearId(monthId));
score.setQuarterId(DateUtils.getQuarterId(monthId));
factIndexCommunityScoreEntities.forEach(community -> {
score.setIndexCode(IndexCalConstant.COMMUNITY_RELATE);
value.forEach(community -> {
score.setScore(score.getScore().add(community.getScore()));
});
result.add(score);
@ -426,22 +388,20 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
factIndexCommunityScoreDao.insertCommunityPartyRecord(result);
}
public void calAll(String customerId,String monthId){
this.communityPartyCalculate(customerId, monthId); //党建能力
this.communityGovernAbilityCalculate(customerId, monthId); // 治理能力
this.communityServiceAbilityCalculate(customerId, monthId); // 服务能力
communityRelate(customerId, monthId);
}
/**
* @Description Integer类型获取最大数和最小数
* @Description BigDecimal类型获取最大数和最小数
* @param list
* @author zxc
* @date 2020/8/27 1:30 下午
*/
public MaxAndMinIntegerResultDTO getMaxAndMinInteger(List<Integer> list){
Integer max = Collections.max(list);
Integer min = Collections.min(list);
MaxAndMinIntegerResultDTO result = new MaxAndMinIntegerResultDTO();
result.setMax(max);
result.setMin(min);
return result;
}
public MaxAndMinBigDecimalResultDTO getMaxAndMinBigDecimal(List<BigDecimal> list){
BigDecimal max = Collections.max(list);
BigDecimal min = Collections.min(list);
@ -451,20 +411,11 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
return result;
}
/**
* @Description Double类型获取最大数和最小数
* @param list
* @author zxc
* @date 2020/8/27 1:32 下午
*/
public MaxAndMinDoubleResultDTO getMaxAndMinDouble(List<Double> list){
Double max = Collections.max(list);
Double min = Collections.min(list);
MaxAndMinDoubleResultDTO result = new MaxAndMinDoubleResultDTO();
result.setMax(max);
result.setMin(min);
return result;
public HashMap<String, BigDecimal> getCalResult(MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal,List<SampleValue> ll, IndexGroupDetailEntity indexGroup){
BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
IndexInputVO index1VO = new IndexInputVO(indexGroup.getIndexId(), ll,indexGroup.getThreshold(), indexGroup.getWeight(), sc);
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO);
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
return batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
}
}

89
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java

@ -1,14 +1,15 @@
package com.epmet.service.screen.impl;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.indexcoll.FactIndexPartyAblityCpcMonthlyDao;
import com.epmet.dao.screen.IndexGroupDao;
import com.epmet.dao.screen.IndexGroupDetailDao;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.screen.form.IndexCalculateForm;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.redis.IndexCodeFieldReRedis;
import com.epmet.service.indexcal.CpcIndexCalculateService;
import com.epmet.service.indexcal.GridCorreLationService;
import com.epmet.service.screen.IndexCalculateCommunityService;
import com.epmet.service.screen.IndexCalculateService;
import com.epmet.util.DimIdGenerator;
import lombok.extern.slf4j.Slf4j;
@ -29,45 +30,65 @@ public class IndexCalculateServiceImpl implements IndexCalculateService {
@Autowired
private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient;
@Autowired
private FactIndexPartyAblityCpcMonthlyDao factIndexPartyAblityCpcMonthlyDao;
@Autowired
private GridCorreLationService gridCorreLationService;
@Autowired
private IndexGroupDao indexGroupDao;
private CpcIndexCalculateService cpcIndexCalculateService;
@Autowired
private IndexCodeFieldReRedis indexCodeFieldReRedis;
@Autowired
private IndexGroupDetailDao indexGroupDetailDao;
private IndexCalculateCommunityService indexCalculateCommunityService;
@Override
public Boolean indexCalculate(IndexCalculateForm formDTO) {
if (StringUtils.isBlank(formDTO.getMonthId())) {
//默认 当前月份-1
formDTO.setMonthId(DimIdGenerator.getMonthDimId(DateUtils.addDateMonths(new Date(), -1)));
}
//按照客户分组
if (CollectionUtils.isEmpty(formDTO.getCustomerIds())) {
Result<List<String>> externalCustomerIdsResult = epmetCommonServiceOpenFeignClient.getExternalCustomerIds();
if (!externalCustomerIdsResult.success()) {
log.error("cpcIndexCalculate epmetCommonServiceOpenFeignClient.getExternalCustomerIds return fail");
return false;
try {
if (StringUtils.isBlank(formDTO.getMonthId())) {
//默认 当前月份-1
formDTO.setMonthId(DimIdGenerator.getMonthDimId(DateUtils.addDateMonths(new Date(), -1)));
}
formDTO.setCustomerIds(externalCustomerIdsResult.getData());
}
formDTO.getCustomerIds().forEach(customerId -> {
CalculateCommonFormDTO calculateCommonFormDTO=new CalculateCommonFormDTO(customerId, formDTO.getMonthId());
//计算党员
try {
//Map<String, BigDecimal> list = factIndexPartyAblityCpcMonthlyDao.getCountByMonthId(customerId, formDTO.getMonthId(), (pageNo - 1) * pageSize, pageSize);
} catch (Exception e) {
//按照客户分组
if (CollectionUtils.isEmpty(formDTO.getCustomerIds())) {
Result<List<String>> externalCustomerIdsResult = epmetCommonServiceOpenFeignClient.getExternalCustomerIds();
if (!externalCustomerIdsResult.success()) {
log.error("indexCalculate epmetCommonServiceOpenFeignClient.getExternalCustomerIds return fail");
return false;
}
formDTO.setCustomerIds(externalCustomerIdsResult.getData());
}
formDTO.getCustomerIds().forEach(customerId -> {
CalculateCommonFormDTO calculateCommonFormDTO = new CalculateCommonFormDTO(customerId, formDTO.getMonthId());
//计算党员相关的
Boolean flag = false;
try {
CalculateCommonFormDTO param = new CalculateCommonFormDTO(customerId, formDTO.getMonthId());
flag = cpcIndexCalculateService.cpcIndexCalculate(param);
log.info("indexCalculate cpcIndexCalculate return result:{}", flag);
} catch (Exception e) {
log.error("indexCalculate cpcIndexCalculate exception", e);
}
//计算网格
//TODO
gridCorreLationService.calculateGridCorreLation(calculateCommonFormDTO);
//计算社区
//TODO
});
return true;
//计算网格
try {
flag = gridCorreLationService.calculateGridCorreLation(calculateCommonFormDTO);
log.info("indexCalculate calculateGridCorreLation return result:{}", flag);
} catch (Exception e) {
log.error("indexCalculate calculateGridCorreLation exception", e);
}
//计算社区
try {
indexCalculateCommunityService.calAll(customerId, formDTO.getMonthId());
log.info("indexCalculate calAll return result:{}", flag);
} catch (Exception e) {
log.error("indexCalculate calAll exception", e);
}
});
indexCodeFieldReRedis.deleteIndexCodeFromRedis();
return true;
} catch (Exception e) {
log.error("indexCalculate exception,param:{}", JSON.toJSONString(formDTO));
} finally {
//清除缓存
indexCodeFieldReRedis.deleteIndexCodeFromRedis();
}
return false;
}
}

28
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/BigDecimalScoreCalculator.java

@ -1,6 +1,9 @@
package com.epmet.support.normalizing;
import com.alibaba.fastjson.JSON;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
/**
@ -9,14 +12,14 @@ import java.util.List;
*/
public class BigDecimalScoreCalculator extends ScoreCalculator {
/**
/* *//**
* 初始化基于原数组的整数分值计算
* 务必在该构造方法最后调用父类的prepare()方法
* @param sourceArray 源数据完整数组
* @param minScore 分值区间的左边界
* @param maxScore 分值区间的右边界
* @param correlation 相关性
*/
*//*
public BigDecimalScoreCalculator(BigDecimal[] sourceArray, BigDecimal minScore, BigDecimal maxScore, Correlation correlation) {
this.sourceArrary = sourceArray.clone();
this.minScore = minScore;
@ -26,13 +29,13 @@ public class BigDecimalScoreCalculator extends ScoreCalculator {
System.out.println("最小值:"+minScore+";最大值:"+maxScore);
}
/**
*//**
* 初始化基于原数组的整数分值计算
* @param sourceList 源数据完整列表
* @param minScore 分值区间的左边界
* @param maxScore 分值区间的右边界
* @param correlation 相关性
*/
*//*
public BigDecimalScoreCalculator(List<BigDecimal> sourceList, BigDecimal minScore, BigDecimal maxScore, Correlation correlation) {
this.sourceArrary = sourceList.toArray();
this.minScore = minScore;
@ -40,7 +43,7 @@ public class BigDecimalScoreCalculator extends ScoreCalculator {
this.correlation = correlation;
prepare4SourceArray();
System.out.println("最小值:"+minScore+";最大值:"+maxScore);
}
}*/
/**
* 初始化基于边界值的整数分值计算
@ -63,12 +66,18 @@ public class BigDecimalScoreCalculator extends ScoreCalculator {
@Override
public BigDecimal getMaxFromSourceArray() {
if (this.sourceArrary == null){
return null;
}
BigDecimal[] intSourceArrary = (BigDecimal[]) this.sourceArrary;
return intSourceArrary[intSourceArrary.length - 1];
}
@Override
public BigDecimal getMinFromSourceArray() {
if (this.sourceArrary == null){
return null;
}
BigDecimal[] intSourceArrary = (BigDecimal[]) this.sourceArrary;
return intSourceArrary[0];
}
@ -77,4 +86,13 @@ public class BigDecimalScoreCalculator extends ScoreCalculator {
public BigDecimal convertValue2BigDecimal(Object sourceValue) {
return (BigDecimal) sourceValue;
}
public static void main(String[] args) {
BigDecimal minScore = new BigDecimal(0);
BigDecimal maxScore = new BigDecimal(100);
ScoreCalculator sc = new BigDecimalScoreCalculator(new BigDecimal("0.1"),new BigDecimal("1"), minScore, maxScore, Correlation.POSITIVE);
List<BigDecimal> ts = Arrays.asList(new BigDecimal("0.1"),new BigDecimal("1"));
List normalize = sc.normalize(ts);
System.out.println(JSON.toJSONString(normalize));
}
}

3
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/ScoreCalculator.java

@ -55,8 +55,8 @@ public abstract class ScoreCalculator<T> {
maxValue = getMaxFromSourceArray();
minValue = getMinFromSourceArray();
//计算系数
System.out.println("最小值:"+minScore+";最大值:"+maxScore);
coefficient = calcuteCoefficient(minValue, maxValue);
//System.out.println("最小分值:"+minScore+";最大分值:"+maxScore+";系数:"+coefficient);
}
/**
@ -176,7 +176,6 @@ public abstract class ScoreCalculator<T> {
if (fenmu.compareTo(BigDecimal.ZERO)==0)return new BigDecimal(0);
BigDecimal fenzi = maxScore.subtract(minScore);
BigDecimal divide = fenzi.divide(fenmu, MathContext.DECIMAL32);
System.out.println("分子:"+fenzi+"分母:"+fenmu+"系数:"+divide.toString());
return divide;
}

5
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/IndexInputVO.java

@ -3,15 +3,16 @@ package com.epmet.support.normalizing.batch;
import com.epmet.support.normalizing.ScoreCalculator;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
@Data
@AllArgsConstructor
public class IndexInputVO<T extends Number> {
public class IndexInputVO<T extends Number> implements Serializable {
private static final long serialVersionUID = -4855313801481921595L;
/**
* 指标标记由使用者传入用以标记该条指标的独有特性一般用id或者code
* 非必填

5
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/SampleValue.java

@ -3,13 +3,16 @@ package com.epmet.support.normalizing.batch;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.io.Serializable;
/**
* 样本值对象
*/
@Data
@AllArgsConstructor
public class SampleValue<T> {
public class SampleValue<T> implements Serializable {
private static final long serialVersionUID = 8661385412757324539L;
private String sampleId;
private T sampleValue;

2
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml

@ -73,7 +73,7 @@
SELECT
MIN( CREATE_TOPIC_COUNT ) CREATE_TOPIC_COUNT_MIN,
MAX( CREATE_TOPIC_COUNT ) CREATE_TOPIC_COUNT_MAX,
MAX( JOIN_TOPIC_COUNT ) JOIN_TOPIC_COUNT_MIN,
MIN( JOIN_TOPIC_COUNT ) JOIN_TOPIC_COUNT_MIN,
MAX( JOIN_TOPIC_COUNT ) JOIN_TOPIC_COUNT_MAX,
MIN( SHIFT_ISSUE_COUNT ) SHIFT_ISSUE_COUNT_MIN,
MAX( SHIFT_ISSUE_COUNT ) SHIFT_ISSUE_COUNT_MAX,

19
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexServiceAblityOrgMonthlyDao.xml

@ -89,4 +89,23 @@
AND customer_id = #{customerId}
AND month_id = #{monthId}
</select>
<!-- 社区活动组织次数 -->
<select id="selectActivityCountMap" resultType="java.util.Map">
SELECT
AGENCY_ID,
PARENT_ID,
MONTH_ID,
QUARTER_ID,
YEAR_ID,
ACTIVITY_COUNT,
CUSTOMER_ID
FROM
fact_index_service_ablity_org_monthly
WHERE
del_flag = '0'
AND data_type = 'community'
AND customer_id = #{customerId}
AND month_id = #{monthId}
</select>
</mapper>

1
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/FactIndexCommunityScoreDao.xml

@ -57,6 +57,7 @@
del_flag = 0
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
AND INDEX_CODE != "shequxiangguan"
</select>
</mapper>

56
epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/DemoScoreCal.java

@ -122,27 +122,63 @@ public class DemoScoreCal {
public void testBigDecimalBatchCalculateGroupBySampleId() throws InterruptedException {
//{4,8,1,3,2}
// 每个指标需要单独的分支计算器,因为每个指标的最大最小值是不同的
ScoreCalculator sc1 = new BigDecimalScoreCalculator(new BigDecimal(1), new BigDecimal(8), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.NEGATIVE);
ScoreCalculator sc2 = new BigDecimalScoreCalculator(new BigDecimal(1), new BigDecimal(8), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.NEGATIVE);
//分值计算器 每个指标需要单独的分值计算器,因为每个指标的最大最小值是不同的
ScoreCalculator sc1 = new BigDecimalScoreCalculator(new BigDecimal(50), new BigDecimal(100), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
ScoreCalculator sc2 = new BigDecimalScoreCalculator(new BigDecimal(20), new BigDecimal(100), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
ScoreCalculator sc3 = new BigDecimalScoreCalculator(new BigDecimal(20), new BigDecimal(40), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
ScoreCalculator sc4 = new BigDecimalScoreCalculator(new BigDecimal(10), new BigDecimal(100), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
//每个指标的数值 比如 a指标里有5条数据
List<SampleValue> index1SampleValues = Arrays.asList(
new SampleValue<>("id1", new BigDecimal(100)),
new SampleValue<>("id2", new BigDecimal(50)),
new SampleValue<>("id3", new BigDecimal(60)),
new SampleValue<>("id4", new BigDecimal(80)),
new SampleValue<>("id5", new BigDecimal(80))
);
List<SampleValue> index1SampleValues2 = Arrays.asList(
new SampleValue<>("id1", new BigDecimal(100)),
new SampleValue<>("id2", new BigDecimal(80)),
new SampleValue<>("id3", new BigDecimal(80)),
new SampleValue<>("id4", new BigDecimal(20)),
new SampleValue<>("id5", new BigDecimal(20))
);
List<SampleValue> index1SampleValues3 = Arrays.asList(
new SampleValue<>("id1", new BigDecimal(40)),
new SampleValue<>("id2", new BigDecimal(20)),
new SampleValue<>("id3", new BigDecimal(40)),
new SampleValue<>("id4", new BigDecimal(30)),
new SampleValue<>("id5", new BigDecimal(20))
);
List<SampleValue> index1SampleValues4 = Arrays.asList(
new SampleValue<>("id1", new BigDecimal(20)),
new SampleValue<>("id2", new BigDecimal(100)),
new SampleValue<>("id3", new BigDecimal(10)),
new SampleValue<>("id4", new BigDecimal(50)),
new SampleValue<>("id5", new BigDecimal(20))
);
List<SampleValue> index1SampleValues = Arrays.asList(new SampleValue<>("id1", new BigDecimal(4)), new SampleValue<>("id2", new BigDecimal(1)), new SampleValue<>("id3", new BigDecimal(8)));
List<SampleValue> index2SampleValues = Arrays.asList(new SampleValue<>("id1", new BigDecimal(1)), new SampleValue<>("id2", new BigDecimal(8)), new SampleValue<>("id3", new BigDecimal(3)));
// 每个指标的信息,包括样本列表,权重,指标标记
IndexInputVO index1VO = new IndexInputVO("aaa", index1SampleValues, new BigDecimal(6), new BigDecimal(1), sc1);
IndexInputVO index2VO = new IndexInputVO("bbb", index2SampleValues, new BigDecimal(6), new BigDecimal(1), sc2);
IndexInputVO index1VO = new IndexInputVO("aaa1", index1SampleValues, new BigDecimal(-1), new BigDecimal(0.2), sc1);
IndexInputVO index2VO = new IndexInputVO("aaa2", index1SampleValues2, new BigDecimal(-1), new BigDecimal(0.15), sc2);
IndexInputVO index3VO = new IndexInputVO("aaa3", index1SampleValues3, new BigDecimal(-1), new BigDecimal(0.15), sc3);
IndexInputVO index4VO = new IndexInputVO("aaa4", index1SampleValues4, new BigDecimal(-1), new BigDecimal(0.5), sc4);
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO, index2VO);
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO, index2VO,index3VO,index4VO);
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> result = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
System.err.println("--------------------------------");
System.err.println("----------------1----------------");
result.forEach((key, value) -> {
System.out.println(key.concat("的得分为:").concat(value.toString()));
});
System.err.println("--------------------------------");
System.err.println("-----------------2---------------");
}

Loading…
Cancel
Save