|  | @ -1,7 +1,10 @@ | 
			
		
	
		
		
			
				
					|  |  | package com.epmet.support.normalizing.batch; |  |  | 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.Correlation; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.support.normalizing.ScoreCalculator; |  |  | import com.epmet.support.normalizing.ScoreCalculator; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.support.normalizing.ScoreConstants; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | import java.math.BigDecimal; |  |  | import java.math.BigDecimal; | 
			
		
	
		
		
			
				
					|  |  | import java.math.RoundingMode; |  |  | import java.math.RoundingMode; | 
			
		
	
	
		
		
			
				
					|  | @ -59,30 +62,28 @@ public class BatchScoreCalculator { | 
			
		
	
		
		
			
				
					|  |  |                 String sampleId = vo.getSampleId(); |  |  |                 String sampleId = vo.getSampleId(); | 
			
		
	
		
		
			
				
					|  |  |                 //归一后的值
 |  |  |                 //归一后的值
 | 
			
		
	
		
		
			
				
					|  |  |                 BigDecimal normalizeValue;// = scoreCalculator.normalize(getFinalSampleValue(vo.getSampleValue(), threshold));
 |  |  |                 BigDecimal normalizeValue;// = scoreCalculator.normalize(getFinalSampleValue(vo.getSampleValue(), threshold));
 | 
			
		
	
		
		
			
				
					
					|  |  |                 //如果不需要归一 则 直接value*权重
 |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					|  |  |                 if (idx.isScore()) { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |                     normalizeValue = getFinalSampleValue(vo.getSampleValue(), threshold); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |                 } else { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |                     normalizeValue = scoreCalculator.normalize(getFinalSampleValue(vo.getSampleValue(), threshold)); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |                 } |  |  |  | 
			
		
	
		
		
			
				
					|  |  |                 //反正切函数 [-pi/2,pi/2]
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |                 BigDecimal maxValue = idx.getScoreCalculator().getMaxValue(); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |                 BigDecimal minValue = idx.getScoreCalculator().getMinValue(); |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					|  |  |                 BigDecimal minScoreValue = idx.getScoreCalculator().getMinScore(); |  |  |                 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
 |  |  |                     //*((max-min)/ (Math.PI/2))+min
 | 
			
		
	
		
		
			
				
					|  |  |                     //Math.atan(new Double(vo.getSampleValue().toString()))*
 |  |  |                     //Math.atan(new Double(vo.getSampleValue().toString()))*
 | 
			
		
	
		
		
			
				
					|  |  |                     normalizeValue = new BigDecimal(Math.atan(new Double(getFinalSampleValue(vo.getSampleValue(), threshold).toString()))) |  |  |                     normalizeValue = new BigDecimal(Math.atan(new Double(getFinalSampleValue(vo.getSampleValue(), threshold).toString()))) | 
			
		
	
		
		
			
				
					|  |  |                             .multiply( |  |  |                             .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); |  |  |                             .add(minScoreValue).setScale(6, RoundingMode.HALF_UP); | 
			
		
	
		
		
			
				
					|  |  |                     //
 |  |  |                     //
 | 
			
		
	
		
		
			
				
					|  |  |                     if (scoreCalculator.getCorrelation().getCode().equals(Correlation.NEGATIVE)) { |  |  |                     if (scoreCalculator.getCorrelation().getCode().equals(Correlation.NEGATIVE)) { | 
			
		
	
		
		
			
				
					
					|  |  |                         normalizeValue = maxValue.subtract(normalizeValue); |  |  |                         normalizeValue = maxScoreValue.subtract(normalizeValue); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |                     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 }else { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     //如果不需要归一 则 直接value*权重
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     if (idx.isScore()) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         normalizeValue = getFinalSampleValue(vo.getSampleValue(), threshold); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     } else { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         normalizeValue = scoreCalculator.normalize(getFinalSampleValue(vo.getSampleValue(), threshold)); | 
			
		
	
		
		
			
				
					|  |  |                     } |  |  |                     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |                 } |  |  |                 } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |                 BigDecimal score = normalizeValue.multiply(weight).setScale(6, RoundingMode.HALF_UP); |  |  |                 BigDecimal score = normalizeValue.multiply(weight).setScale(6, RoundingMode.HALF_UP); | 
			
		
	
		
		
			
				
					|  |  |                 CalculateResult result = scoreCountOfSamples.get(sampleId); |  |  |                 CalculateResult result = scoreCountOfSamples.get(sampleId); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  | @ -120,4 +121,16 @@ public class BatchScoreCalculator { | 
			
		
	
		
		
			
				
					|  |  |                 ? bdRealValue |  |  |                 ? bdRealValue | 
			
		
	
		
		
			
				
					|  |  |                 : threshold; |  |  |                 : 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)); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | } |  |  | } | 
			
		
	
	
		
		
			
				
					|  | 
 |