|
|
@ -4,6 +4,7 @@ import com.epmet.support.normalizing.ScoreCalculator; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
@ -12,6 +13,7 @@ public class BatchScoreCalculator { |
|
|
|
|
|
|
|
/** |
|
|
|
* 执行计算,每个指标中每个样本的得分明细 |
|
|
|
* |
|
|
|
* @return 每一条都是一个指标的,所有样本对应的,得分值 |
|
|
|
*/ |
|
|
|
public List<IndexOutputVO> getScoreDetailOfIndexId(List<IndexInputVO> indexInputVOS) { |
|
|
@ -26,7 +28,7 @@ public class BatchScoreCalculator { |
|
|
|
|
|
|
|
// 循环同一个指标内的多个样本值的SampleValue列表
|
|
|
|
List<SampleScore> scores4OneIndex = indexValueVOs.stream().map(vo -> { |
|
|
|
BigDecimal score = scoreCalculator.normalize(getFinalSampleValue(vo.getSampleValue(), threshold), weight).setScale(6, RoundingMode.HALF_UP);; |
|
|
|
BigDecimal score = scoreCalculator.normalize(getFinalSampleValue(vo.getSampleValue(), threshold), weight).setScale(6, RoundingMode.HALF_UP); |
|
|
|
return new SampleScore(vo.getSampleId(), score); |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
@ -34,8 +36,49 @@ public class BatchScoreCalculator { |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 执行计算,以样本的所有指标总得分及明细分数值 |
|
|
|
* |
|
|
|
* @param indexInputVOS |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public HashMap<String, CalculateResult> getScoreTotalOfSampleId(List<IndexInputVO> indexInputVOS) { |
|
|
|
|
|
|
|
// 每个样本的总得分
|
|
|
|
HashMap<String, CalculateResult> scoreCountOfSamples = new HashMap<>(); |
|
|
|
//遍历指标
|
|
|
|
for (IndexInputVO idx : indexInputVOS) { |
|
|
|
// 每个指标循环一次
|
|
|
|
List<SampleValue> indexValueVOs = idx.getIndexValueVOs(); |
|
|
|
BigDecimal weight = idx.getWeight(); |
|
|
|
ScoreCalculator scoreCalculator = idx.getScoreCalculator(); |
|
|
|
BigDecimal threshold = idx.getThreshold(); |
|
|
|
//遍历该指标下的每个数据
|
|
|
|
for (SampleValue vo : indexValueVOs) { |
|
|
|
String sampleId = vo.getSampleId(); |
|
|
|
BigDecimal score = scoreCalculator.normalize(getFinalSampleValue(vo.getSampleValue(), threshold), weight).setScale(6, RoundingMode.HALF_UP); |
|
|
|
CalculateResult result = scoreCountOfSamples.get(sampleId); |
|
|
|
|
|
|
|
if (result == null) { |
|
|
|
score.setScale(6, RoundingMode.HALF_UP); |
|
|
|
result = new CalculateResult(); |
|
|
|
result.setSampleId(sampleId); |
|
|
|
result.setTotalScore(new BigDecimal(0)); |
|
|
|
result.setDetails(new ArrayList<>()); |
|
|
|
scoreCountOfSamples.put(sampleId, result); |
|
|
|
} |
|
|
|
SampleScore sampleScore = new SampleScore(idx.getIndexId(), score); |
|
|
|
result.getDetails().add(sampleScore); |
|
|
|
result.setTotalScore(result.getTotalScore().add(score).setScale(6, RoundingMode.HALF_UP)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return scoreCountOfSamples; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 执行计算,以样本的所有指标总得分 |
|
|
|
* |
|
|
|
* @param indexInputVOS |
|
|
|
* @return |
|
|
|
*/ |
|
|
@ -69,6 +112,7 @@ public class BatchScoreCalculator { |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取最终样本值 |
|
|
|
* |
|
|
|
* @param realValue |
|
|
|
* @param threshold |
|
|
|
* @return |
|
|
@ -81,6 +125,6 @@ public class BatchScoreCalculator { |
|
|
|
} |
|
|
|
return (bdRealValue.compareTo(threshold) < 0) || (bdRealValue.equals(threshold)) |
|
|
|
? bdRealValue |
|
|
|
: threshold ; |
|
|
|
: threshold; |
|
|
|
} |
|
|
|
} |
|
|
|