|
@ -9,6 +9,7 @@ import org.junit.Test; |
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
import java.util.Arrays; |
|
|
import java.util.Arrays; |
|
|
|
|
|
import java.util.HashMap; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
public class DemoScoreCal { |
|
|
public class DemoScoreCal { |
|
@ -83,7 +84,7 @@ public class DemoScoreCal { |
|
|
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO, index2VO); |
|
|
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO, index2VO); |
|
|
|
|
|
|
|
|
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); |
|
|
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); |
|
|
List<IndexOutputVO> result = batchScoreCalculator.exec(indexInputVOS); |
|
|
List<IndexOutputVO> result = batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS); |
|
|
|
|
|
|
|
|
System.err.println("--------------------------------"); |
|
|
System.err.println("--------------------------------"); |
|
|
result.stream().forEach(r -> System.out.println(r)); |
|
|
result.stream().forEach(r -> System.out.println(r)); |
|
@ -109,7 +110,7 @@ public class DemoScoreCal { |
|
|
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO, index2VO); |
|
|
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO, index2VO); |
|
|
|
|
|
|
|
|
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); |
|
|
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); |
|
|
List<IndexOutputVO> result = batchScoreCalculator.exec(indexInputVOS); |
|
|
List<IndexOutputVO> result = batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS); |
|
|
|
|
|
|
|
|
System.err.println("--------------------------------"); |
|
|
System.err.println("--------------------------------"); |
|
|
result.stream().forEach(r -> System.out.println(r)); |
|
|
result.stream().forEach(r -> System.out.println(r)); |
|
@ -117,5 +118,32 @@ public class DemoScoreCal { |
|
|
System.err.println("--------------------------------"); |
|
|
System.err.println("--------------------------------"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
|
|
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(1), sc1); |
|
|
|
|
|
IndexInputVO index2VO = new IndexInputVO("bbb", index2SampleValues, new BigDecimal(1), sc2); |
|
|
|
|
|
|
|
|
|
|
|
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO, index2VO); |
|
|
|
|
|
|
|
|
|
|
|
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); |
|
|
|
|
|
HashMap<String, BigDecimal> result = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); |
|
|
|
|
|
|
|
|
|
|
|
System.err.println("--------------------------------"); |
|
|
|
|
|
result.forEach((key, value) -> { |
|
|
|
|
|
System.out.println(key.concat("的得分为:").concat(value.toString())); |
|
|
|
|
|
}); |
|
|
|
|
|
System.err.println("--------------------------------"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|