Browse Source

Merge remote-tracking branch 'origin/dev_screen_data_2.0' into dev_temp

master
zxc 5 years ago
parent
commit
5c3ec277b1
  1. 26
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java

26
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java

@ -1,7 +1,10 @@
package com.epmet.support.normalizing.batch;
import com.alibaba.fastjson.JSON;
import com.epmet.support.normalizing.BigDecimalScoreCalculator;
import com.epmet.support.normalizing.Correlation;
import com.epmet.support.normalizing.ScoreCalculator;
import com.epmet.support.normalizing.ScoreConstants;
import java.math.BigDecimal;
import java.math.RoundingMode;
@ -59,21 +62,20 @@ public class BatchScoreCalculator {
String sampleId = vo.getSampleId();
//归一后的值
BigDecimal normalizeValue;// = scoreCalculator.normalize(getFinalSampleValue(vo.getSampleValue(), threshold));
BigDecimal maxValue = idx.getScoreCalculator().getMaxValue();
BigDecimal minValue = idx.getScoreCalculator().getMinValue();
BigDecimal minScoreValue = idx.getScoreCalculator().getMinScore();
if (maxValue.compareTo(minValue) == 0) {
BigDecimal maxScoreValue = idx.getScoreCalculator().getMaxScore();
if (idx.getScoreCalculator().getMaxValue().compareTo(idx.getScoreCalculator().getMinValue()) == 0) {
//*((max-min)/ (Math.PI/2))+min
//Math.atan(new Double(vo.getSampleValue().toString()))*
normalizeValue = new BigDecimal(Math.atan(new Double(getFinalSampleValue(vo.getSampleValue(), threshold).toString())))
.multiply(
(maxValue.subtract(minValue).divide(new BigDecimal(Math.PI / 2), 10, RoundingMode.UNNECESSARY)))
(maxScoreValue.subtract(minScoreValue).divide(new BigDecimal(Math.PI / 2), 10, RoundingMode.HALF_UP)))
.add(minScoreValue).setScale(6, RoundingMode.HALF_UP);
//
if (scoreCalculator.getCorrelation().getCode().equals(Correlation.NEGATIVE)) {
normalizeValue = maxValue.subtract(normalizeValue);
normalizeValue = maxScoreValue.subtract(normalizeValue);
}
}else {
//如果不需要归一 则 直接value*权重
if (idx.isScore()) {
@ -119,4 +121,16 @@ public class BatchScoreCalculator {
? bdRealValue
: threshold;
}
public static void main(String[] args) {
List<IndexInputVO> indexInputVOS = new ArrayList<>();
String jsonStr = "{\"allParentIndexCode\":\"quanquxiangguan:zhilinengli\",\"indexId\":\"suoyoujiedaozlnlpjz\",\"indexValueVOs\":[{\"sampleId\":\"7b6f9a9f9f38d5f9fa7ce94a93d6eb28\",\"sampleValue\":69.830369}],\"score\":true,\"scoreCalculator\":{\"coefficient\":0,\"correlation\":\"POSITIVE\",\"maxScore\":100,\"maxValue\":69.830369,\"minScore\":60,\"minValue\":69.830369},\"threshold\":-1.0000,\"weight\":0.8000}";
IndexInputVO vo = JSON.parseObject(jsonStr, IndexInputVO.class);
BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(new BigDecimal("69.830369"), new BigDecimal("69.830369"), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(Correlation.POSITIVE.getCode()));
vo.setScoreCalculator(sc);
indexInputVOS.add(vo);
BatchScoreCalculator sc2 = new BatchScoreCalculator();
HashMap<String, CalculateResult> scoreTotalOfSampleId = sc2.getScoreTotalOfSampleId(indexInputVOS);
System.out.println(JSON.toJSONString(scoreTotalOfSampleId));
}
}

Loading…
Cancel
Save