|
@@ -1,5 +1,6 @@
|
|
|
package com.rf.psychological.scale.resultBusiness.scaleResult;
|
|
|
|
|
|
+import cn.hutool.core.util.NumberUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.rf.psychological.dao.dto.scale.NewResultDto;
|
|
@@ -13,6 +14,7 @@ import org.springframework.lang.Nullable;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.DecimalFormat;
|
|
|
+import java.text.NumberFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -151,8 +153,17 @@ public class NEWCOMMONScale extends BaseScale {
|
|
|
resultJson.put("总分说明", tempTotalScore.getImprovementSuggestions());
|
|
|
resultJson.put("总分解读", tempTotalScore.getNameExplain());
|
|
|
resultJson.put("总分建议", tempTotalScore.getSuggestion());
|
|
|
+ break;
|
|
|
}
|
|
|
+ //计算总分占比
|
|
|
+ //获取维度最大值
|
|
|
+ int max = getMaxValue(totalScores);
|
|
|
+ System.out.println("------------------------"+max);
|
|
|
+ String value = percnet(score,max);
|
|
|
+ resultMap0.put("总分百分比", value);
|
|
|
+ resultJson.put("总分百分比", value);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
} else {
|
|
|
for (ScaleMarksEntity tempTotalScore : totalScore) {
|
|
@@ -169,8 +180,16 @@ public class NEWCOMMONScale extends BaseScale {
|
|
|
resultJson.put("总分说明", tempTotalScore.getImprovementSuggestions());
|
|
|
resultJson.put("总分解读", tempTotalScore.getNameExplain());
|
|
|
resultJson.put("总分建议", tempTotalScore.getSuggestion());
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
+ //计算总分占比
|
|
|
+ //获取维度最大值
|
|
|
+ int max = getMaxValue(totalScore);
|
|
|
+ System.out.println("------------------------"+max);
|
|
|
+ String value = percnet(score,max);
|
|
|
+ resultMap0.put("总分百分比", value);
|
|
|
+ resultJson.put("总分百分比", value);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -207,6 +226,28 @@ public class NEWCOMMONScale extends BaseScale {
|
|
|
return returnJson;
|
|
|
}
|
|
|
|
|
|
+ private int getMaxValue(List<ScaleMarksEntity> list){
|
|
|
+ int value = -1;
|
|
|
+ for (ScaleMarksEntity entity :list){
|
|
|
+ int endScore = Integer.parseInt(entity.getScoreEnd());
|
|
|
+ if (value < 0){
|
|
|
+ value = endScore;
|
|
|
+ }
|
|
|
+ if (value <=endScore){
|
|
|
+ value = endScore;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String percnet(double d,double e){
|
|
|
+ double p = d/e;
|
|
|
+ DecimalFormat nf = (DecimalFormat) NumberFormat.getPercentInstance();
|
|
|
+ nf.applyPattern("00%"); //00表示小数点2位
|
|
|
+ nf.setMaximumFractionDigits(2); //2表示精确到小数点后2位
|
|
|
+ return nf.format(p);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 通用计算量表所有维度分数,以及其维度所在分数段症状等
|
|
|
*
|