Browse Source

Merge remote-tracking branch 'origin/master'

zsf 1 năm trước cách đây
mục cha
commit
5167588a4d

+ 1 - 1
src/main/java/com/rf/psychological/scale/resultBusiness/scaleResult/NEWCOMMONScale.java

@@ -347,7 +347,7 @@ public class NEWCOMMONScale extends BaseScale {
 
 
     private static void putDimResult(Map<String, String> resultMap0, JSONObject resultJson, String dimensionName, NewResultDto newResultDto1, ScaleMarksEntity scaleMarksEntity) {
-        resultMap0.put(dimensionName + "常模参考值", scaleMarksEntity.getReference());
+        //resultMap0.put(dimensionName + "常模参考值", scaleMarksEntity.getReference());
         resultMap0.put(dimensionName + "症状", scaleMarksEntity.getSymptom());
         resultJson.put(dimensionName + "结论", scaleMarksEntity.getSymptom());
         resultMap0.put(dimensionName + "因子解释", scaleMarksEntity.getNameExplain());

+ 105 - 6
src/main/java/com/rf/psychological/scale/resultBusiness/scaleResult/TTTScale.java

@@ -2,12 +2,17 @@ package com.rf.psychological.scale.resultBusiness.scaleResult;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.rf.psychological.dao.dto.scale.NewResultDto;
+import com.rf.psychological.dao.model.DimensionEntity;
+import com.rf.psychological.scale.dao.model.ScaleMarksEntity;
+import com.rf.psychological.scale.scaleresult.ScaleConstant;
 import com.rf.psychological.utils.Constant;
 
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import java.text.DecimalFormat;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import static com.rf.psychological.scale.resultBusiness.scaleResult.NEWCOMMONScale.commonComputeDimensionScore;
 
 /**
  * @author zsy
@@ -88,8 +93,9 @@ public class TTTScale extends BaseScale{
                 }
             }
         }
+
         //得分列表
-        Map<String, String> resultMap = new LinkedHashMap<>();
+        /*Map<String, String> resultMap = new LinkedHashMap<>();
         resultMap.put("胆汁质得分", String.valueOf(score1));
         resultJson.put("胆汁质得分", String.valueOf(score1));
         resultMap.put("多血质得分", String.valueOf(score2));
@@ -105,7 +111,100 @@ public class TTTScale extends BaseScale{
         JSONObject returnJson = new JSONObject(true);
         returnJson.put("resultMapList",resultMapList);
         returnJson.put("scaleName", Constant.SHEET_NAME_TTT);
-        returnJson.put("resultJson",resultJson);
+        returnJson.put("resultJson",resultJson);*/
+
+        Map<String, String> resultMap0 = new LinkedHashMap<>();
+        List<Map<String, String>> resultMapList = new ArrayList<>();
+        //返回值以及存数据库格式
+        List<NewResultDto> newResultDtos = new ArrayList<>();
+        //获取维度信息列表
+        List<DimensionEntity> dimensionEntities = (List<DimensionEntity>) resultJson.get("dimensionEntities");
+        //获取评分规则列表
+        List<ScaleMarksEntity> scaleMarksEntities = (List<ScaleMarksEntity>) resultJson.get("scaleMarksEntities");
+        //新版本数据格式
+        Map<String, Object> newResult = new LinkedHashMap<>();
+        Map<String,Double> dimensionScoreMap = new HashMap<>();
+
+        //判断最高分
+        int a;
+        if (score1 >= score2 && score1 >= score3 && score1 >= score4) {
+            a = score1;
+        } else if (score2 >= score1 && score2 >= score3 && score2 >= score4) {
+            a = score2;
+        } else if (score3 >= score1 && score3 >= score2 && score3 >= score4) {
+            a = score3;
+        } else {
+            a = score4;
+        }
+        JSONObject jsonObject = new JSONObject(true);
+        if (score1 == a){
+            jsonObject.put("胆汁质",a);
+        }
+        if (score2 == a){
+            jsonObject.put("多血质",a);
+        }
+        if (score3 == a){
+            jsonObject.put("粘液质",a);
+        }
+        if (score4 == a){
+            jsonObject.put("抑郁质",a);
+        }
+        Set<String> keys = jsonObject.keySet();
+        double[] dimensionScore = new double[keys.size()];
+        List<DimensionEntity> dimensionEntitieList = new ArrayList<>();
+        int b = 0;
+        for (String key : keys) {
+            for (DimensionEntity dimensionEntity : dimensionEntities) {
+                if (dimensionEntity.getName().equals(key)){
+                    dimensionEntitieList.add(dimensionEntity);
+                    dimensionScore[b] = jsonObject.getInteger(key);
+                    b++;
+                }
+            }
+        }
+        DecimalFormat df = new DecimalFormat("######0.00");
+
+        int totalScore = score1 + score2 + score3 + score4;
+        resultMap0.put("总分", String.valueOf(totalScore));
+        resultJson.put("总分", String.valueOf(totalScore));
+
+
+        //将量表总维度根据维度名称进行分组
+        Map<String, List<ScaleMarksEntity>> scaleMarksMap = scaleMarksEntities.stream().collect(Collectors.groupingBy(ScaleMarksEntity::getName));
+        JSONObject iconInfo = new JSONObject();
+        //雷达图需要的维度以及最大值
+        List<Map<String, Object>> indicator = new LinkedList<>();
+        //雷达图所需要的常模参考值
+        LinkedList<String> reference = new LinkedList<>();
+        //雷达图需要的分数
+        LinkedList<String> scoreList = new LinkedList<>();
+        //计算维度所在评分区间
+        commonComputeDimensionScore(df, resultMap0, resultJson, dimensionEntitieList, dimensionScore, scaleMarksMap, newResultDtos, indicator, reference, scoreList);
+        //需要图表展示的
+        iconInfo.put("indicator", indicator);
+        //判断是否有常模参考值,即reference的内容如果全为0,则不进行返回
+        if (!reference.stream().allMatch("0"::equals)) {
+            iconInfo.put("reference", reference);
+        }
+        iconInfo.put("scoreList", scoreList);
+        if (indicator.size() == 0 && reference.size() == 0) {
+            newResult.put("iconInfo", "");
+        } else {
+            newResult.put("iconInfo", iconInfo);
+        }
+
+        dimensionScoreMap.put("8af178857b94d581017b94f8727a1b20", Double.valueOf(score1));
+        dimensionScoreMap.put("8af178857b94d581017b94f872d01b21", Double.valueOf(score2));
+        dimensionScoreMap.put("8af178857b94d581017b94f873251b22", Double.valueOf(score3));
+        dimensionScoreMap.put("8af178857b94d581017b94f8737a1b23", Double.valueOf(score4));
+        resultJson.put("dimensionScoreMap",dimensionScoreMap);
+
+        newResult.put("result", newResultDtos);
+        resultMapList.add(resultMap0);
+        JSONObject returnJson = new JSONObject(true);
+        returnJson.put("resultMapList", resultMapList);
+        returnJson.put("resultJson", resultJson);
+        returnJson.put(ScaleConstant.ResultEnum.RESULT_NEW_FIELD.getKeyword(), newResult);
 
         return returnJson;
     }

+ 19 - 1
src/main/java/com/rf/psychological/utils/ExcelUtil.java

@@ -683,7 +683,25 @@ public class ExcelUtil {
                                     } else if (value.equals("1")) {
                                         value = "多选";
                                     } else if (value.equals("2")) {
-                                        value = "填空";
+                                        value = "文本";
+                                    } else if (value.equals("3")) {
+                                        value = "数字";
+                                    } else if (value.equals("4")) {
+                                        value = "日期";
+                                    } else if (value.equals("5")) {
+                                        value = "下拉选";
+                                    } else if (value.equals("6")) {
+                                        value = "跳转单选";
+                                    } else if (value.equals("7")) {
+                                        value = "说明单选";
+                                    } else if (value.equals("8")) {
+                                        value = "附图单选";
+                                    } else if (value.equals("9")) {
+                                        value = "附图多选";
+                                    } else if (value.equals("10")) {
+                                        value = "附说明单选";
+                                    } else if (value.equals("11")) {
+                                        value = "附说明多选";
                                     }
                                 }
                                 if (propertyName.equals("scoreDirection")) {