浏览代码

修改报告内容添加维度得分范围和得分百分比提交

zsy 1 年之前
父节点
当前提交
3b0f730c68

+ 17 - 0
src/main/java/com/rf/psychological/dao/dto/scale/NewResultDto.java

@@ -32,5 +32,22 @@ public class NewResultDto {
 
     private String isTotalScoreExplain;
 
+    private String minScore;
+
+    private String maxScore;
+
+    private String percent;
+
+    public NewResultDto(String name, String score, String symptom, String improvementSuggestions, String flag, String reference, String nameExplain, String suggestion, String isTotalScoreExplain) {
+        this.name = name;
+        this.score = score;
+        this.symptom = symptom;
+        this.improvementSuggestions = improvementSuggestions;
+        this.flag = flag;
+        this.reference = reference;
+        this.nameExplain = nameExplain;
+        this.suggestion = suggestion;
+        this.isTotalScoreExplain = isTotalScoreExplain;
+    }
 
 }

+ 23 - 0
src/main/java/com/rf/psychological/scale/rest/WebScaleResultController.java

@@ -7,6 +7,7 @@ import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.rf.psychological.base.rest.BaseController;
 import com.rf.psychological.dao.dto.InstitutionRecordingUsersDTO;
+import com.rf.psychological.dao.dto.scale.NewResultDto;
 import com.rf.psychological.enums.UserRole;
 import com.rf.psychological.file.excel.ExcelClass;
 import com.rf.psychological.dao.model.*;
@@ -272,6 +273,28 @@ public class WebScaleResultController extends BaseController {
             dbJson.put("newTableContext", "");
         } else {
             newResultJson = (Map<String, Object>) resultJson.get("newResultJson");
+            List<NewResultDto> newResultDtos = (List<NewResultDto>) newResultJson.get("result");
+            for (int y = 1; y < newResultDtos.size(); y++) {
+                List<ScaleMarksEntity> scaleMarksEntityList = this.scaleMarksService.getScaleMarksByFlagAndName(flag,newResultDtos.get(y).getName());
+                if(scaleMarksEntityList != null && scaleMarksEntityList.size() > 0 ){
+                    //取最大值最小值
+                    double minScore = Double.parseDouble(scaleMarksEntityList.get(0).getScoreStart());
+                    double maxScore = Double.parseDouble(scaleMarksEntityList.get(0).getScoreEnd());
+                    for (int i = 1; i < scaleMarksEntityList.size(); i++) {
+                        if(Double.parseDouble(scaleMarksEntityList.get(i).getScoreStart()) < minScore){
+                            minScore = Double.parseDouble(scaleMarksEntityList.get(i).getScoreStart());
+                        }
+                        if(Double.parseDouble(scaleMarksEntityList.get(i).getScoreEnd()) > maxScore){
+                            maxScore = Double.parseDouble(scaleMarksEntityList.get(i).getScoreEnd());
+                        }
+                    }
+                    newResultDtos.get(y).setMinScore(String.valueOf(minScore));
+                    newResultDtos.get(y).setMaxScore(String.valueOf(maxScore));
+                    DecimalFormat df   = new DecimalFormat("######0.00");
+                    String percent = Double.parseDouble(df.format((Double.parseDouble(newResultDtos.get(y).getScore())-minScore)/(maxScore-minScore)*100)) + "%";
+                    newResultDtos.get(y).setPercent(percent);
+                }
+            }
             dbJson.put("version", 2.0);
             dbJson.put("newTableContext", newResultJson);
             versionFlag = true;