Browse Source

量表查询调整

zsf 1 year ago
parent
commit
76126af2c6

+ 22 - 17
src/main/java/com/rf/psychological/dao/dto/InstitutionRecordingUserDTO.java

@@ -1,6 +1,6 @@
 package com.rf.psychological.dao.dto;
 
-import javax.xml.soap.Text;
+import lombok.Data;
 
 /**
  * @author lpf
@@ -8,42 +8,47 @@ import javax.xml.soap.Text;
  * @date 23/9/2021上午10:30
  */
 
-public interface InstitutionRecordingUserDTO {
+@Data
+public class InstitutionRecordingUserDTO {
 
-    public String getPhone();
+    public String phone;
 
-    public String getPetName();
+    public String petName;
 
-    public String getPassword();
+    public String password;
 
-    public String getGender();
+    public String gender;
 
-    public String getBirthday();
+    public String birthday;
 
-    public String getProfession();
+    public String profession;
 
-    public String getInstitutionName();
+    public String institutionName;
 
-    public String getInstitutionNo();
+    public String institutionNo;
 
-    public String getUserStatus();
+    public String userStatus;
 
-    public String getAdditionInfo();
+    public String additionInfo;
 
-    public String getTestResults();
+    public String testResults;
 
-    public String getImg();
+    public String img;
+
+    public String structureNo;
+
+    public String  gId;
 
     /**
      * 记录表id
      *
      * @return
      */
-    public String getId();
+    public String id;
 
-    public String getTestDate();
+    public String testDate;
 
-    public String getTestResult();
+    public String testResult;
 
 
 }

+ 7 - 1
src/main/java/com/rf/psychological/institution/rest/InstitutionController.java

@@ -211,8 +211,14 @@ public class InstitutionController extends BaseController {
         log.info("格式化后为beginFormat:" + beginFormat);
         log.info("格式化后为endFormat:" + endFormat);
         int num;
-        List<InstitutionRecordingUserDTO> institutionUserRecordingList = this.userRecordService.getInstitutionRecording(pageNum, pageSize, institutionNo, name, searchKey, beginFormat, endFormat);
+        List<JSONObject> institutionUserRecordingList = this.userRecordService.getInstitutionRecording(pageNum, pageSize, institutionNo, name, searchKey, beginFormat, endFormat);
         num = this.userRecordService.allCountInstitutionRecording(institutionNo, name, searchKey, beginFormat, endFormat);
+        if (CollectionUtils.isNotEmpty(institutionUserRecordingList)){
+            institutionUserRecordingList.forEach(item->{
+                String path=null;
+                item.put("gid",structureService.getPath(path,item.getString("structureNo"),item.getString("institutionNo")));
+            });
+        }
         JSONObject jsonObject = new JSONObject();
         jsonObject.put("institutionUserRecordingList", institutionUserRecordingList);
         jsonObject.put("allNum", num);

+ 3 - 0
src/main/java/com/rf/psychological/scale/dao/model/ScaleMarksEntity.java

@@ -67,6 +67,9 @@ public class ScaleMarksEntity extends BaseEntity {
     @Column(name = "is_total_score_explain", columnDefinition = "varchar(50) default '否' comment '是否为总分解读'")
     private String isTotalScoreExplain;
 
+    @Column(name = "scoring_type", columnDefinition = "varchar(2) default '0' comment '计分类型:0---求和,1---求平均值保留两位小数,2---求平均值四舍五入'")
+    private String scoringType;
+
 
 
     ///**

+ 1 - 1
src/main/java/com/rf/psychological/scale/dao/repository/ScaleMarksRepository.java

@@ -22,7 +22,7 @@ public interface ScaleMarksRepository extends BaseRepository<ScaleMarksEntity,St
      * @param flag
      * @return
      */
-    @Query(value = "select id, flag, improvement_suggestions, score_end, score_start, symptom, name, name_explain, reference,standard_deviation,suggestion, is_total_score_explain from t_scale_marks where flag = :flag", nativeQuery = true)
+    @Query(value = "select id, flag, improvement_suggestions, score_end, score_start, symptom, name, name_explain, reference,standard_deviation,suggestion, is_total_score_explain,scoring_type from t_scale_marks where flag = :flag", nativeQuery = true)
     List<ScaleMarksEntity> getScaleMarksByFlag(@Param("flag") String flag);
 
     /**

+ 4 - 2
src/main/java/com/rf/psychological/scale/dao/repository/UserRecordRepository.java

@@ -1,5 +1,6 @@
 package com.rf.psychological.scale.dao.repository;
 
+import com.alibaba.fastjson.JSONObject;
 import com.rf.psychological.base.repository.BaseRepository;
 import com.rf.psychological.dao.dto.InstitutionRecordingDTO;
 import com.rf.psychological.dao.dto.InstitutionRecordingUserDTO;
@@ -134,10 +135,11 @@ public interface UserRecordRepository extends BaseRepository<UserRecordEntity, S
      * @param name
      * @return
      */
-    @Query(value = "select tui.phone,tui.pet_name as petName,tui.password,tui.gender,tui.birthday,tui.profession,tui.institution_name as institutionName,tui.institution_no as institutionNo,tui.user_status as userStatus,tur.id as id,tur.test_date as testDate ,tur.test_result as testResult from t_user_info tui  join t_user_record tur on tur.phone = tui.phone  and tui.role_type='1' and tui.institution_no=tur.institution_no where  tui.institution_no= :institutionNo and tur.name= :name and " +
+    @Query(value = "select tui.phone,tui.pet_name as petName,tui.password,tui.gender,tui.birthday,tui.profession,tui.institution_name as institutionName,tui.structure_no as structureNo," +
+            "tui.institution_no as institutionNo,tui.user_status as userStatus,tur.id as id,tur.test_date as testDate ,tur.test_result as testResult from t_user_info tui  join t_user_record tur on tur.phone = tui.phone  and tui.role_type='1' and tui.institution_no=tur.institution_no where  tui.institution_no= :institutionNo and tur.name= :name and " +
             "if(:beginFormat is not null and :beginFormat!='',tur.test_date>:beginFormat ,1=1)  and if(:endFormat is not null and :endFormat!='', tur.test_date<:endFormat ,1=1) and " +
             "( if(:searchKey is not null and :searchKey!='',tui.pet_name like CONCAT('%',:searchKey,'%')  ,1=1) or if(:searchKey is not null and :searchKey!='',tui.phone like CONCAT('%',:searchKey,'%')  ,1=1) ) order by tur.test_date desc ", nativeQuery = true)
-    List<InstitutionRecordingUserDTO> getInstitutionRecording(Pageable pageable, @Param("institutionNo") String institutionNo, @Param("name") String name, @Param("searchKey") String searchKey, @Param("beginFormat") String beginFormat, @Param("endFormat") String endFormat);
+    List<JSONObject> getInstitutionRecording(Pageable pageable, @Param("institutionNo") String institutionNo, @Param("name") String name, @Param("searchKey") String searchKey, @Param("beginFormat") String beginFormat, @Param("endFormat") String endFormat);
 
     @Query(value = "select count(tui.id) from t_user_info tui  join t_user_record tur on tur.phone = tui.phone  and tui.role_type='1' and tui.institution_no=tur.institution_no  where  tui.institution_no= :institutionNo and tur.name= :name and " +
             "if(:beginFormat is not null and :beginFormat!='',tur.test_date>:beginFormat ,1=1)  and if(:endFormat is not null and :endFormat!='', tur.test_date<:endFormat ,1=1) and " +

+ 62 - 57
src/main/java/com/rf/psychological/scale/resultBusiness/scaleResult/COMMONScale.java

@@ -7,23 +7,21 @@ import com.rf.psychological.dao.model.DimensionEntity;
 import com.rf.psychological.scale.dao.model.ScaleMarksEntity;
 
 import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * @author zsy
  * @description:简单相加和分维度量表通用算法
  * @date 2021/7/20 15:55
  */
-public class COMMONScale extends BaseScale{
+public class COMMONScale extends BaseScale {
+
 
     public COMMONScale(JSONArray jsonArray, JSONObject resultJson) {
         super(jsonArray, resultJson);
     }
 
-    public  JSONObject scaleCalculate() throws Exception {
+    public JSONObject scaleCalculate() throws Exception {
 
         // 自定义路径使用
         /*ScaleUtil.getScaleDll("FESCVSCALE.dll");
@@ -38,7 +36,7 @@ public class COMMONScale extends BaseScale{
         //总分
         double score = 0;
         Map<String, String> resultMap0 = new LinkedHashMap<>();
-        List<Map<String,String>> resultMapList = new ArrayList<>();
+        List<Map<String, String>> resultMapList = new ArrayList<>();
 
         //获取答案列表
         List<AnswerEntity> answerEntities = (List<AnswerEntity>) resultJson.get("answerEntities");
@@ -46,21 +44,25 @@ public class COMMONScale extends BaseScale{
         List<ScaleMarksEntity> scaleMarksEntities = (List<ScaleMarksEntity>) resultJson.get("scaleMarksEntities");
         //获取维度信息列表
         List<DimensionEntity> dimensionEntities = (List<DimensionEntity>) resultJson.get("dimensionEntities");
-        if (dimensionEntities.size() > 0){
+        double[] dimensionScore = new double[dimensionEntities.size()];
+        Map<String,Double> dimensionScoreMap = new HashMap<>();
+        if (dimensionEntities.size() > 0) {
+
             //计算每个维度得分
-            double[] dimensionScore = new double[dimensionEntities.size()];
+
             for (int i = 0; i < jsonArray.size(); i++) {
                 JSONObject jsonObject1 = jsonArray.getJSONObject(i);
                 for (int y = 0; y < dimensionEntities.size(); y++) {
                     //for (DimensionEntity dimensionEntity:dimensionEntities){
                     DimensionEntity dimensionEntity = dimensionEntities.get(y);
                     String questionNos = dimensionEntity.getQuestionNo();
-                    String[] questionNo = questionNos.split(";");
-                    for (String question:questionNo){
-                        if (question.equals(jsonObject1.getString("questionNo"))){
-                            for (AnswerEntity answerEntity:answerEntities){
-                                if (answerEntity.getQuestionNo().equals(question) && answerEntity.getName().equals(jsonObject1.getString("checkItems"))){
-                                    dimensionScore[y] += Double.valueOf(answerEntity.getScore());
+                    String[] questionNo = questionNos.replaceAll("\\s", "").split(";");
+                    for (String question : questionNo) {
+                        if (question.equals(jsonObject1.getString("questionNo"))) {
+                            for (AnswerEntity answerEntity : answerEntities) {
+                                if (answerEntity.getQuestionNo().equals(question) && answerEntity.getName().replaceAll("\\s", "").equals(jsonObject1.getString("checkItems").replaceAll("\\s", ""))) {
+                                    dimensionScore[y] += Double.parseDouble(answerEntity.getScore());
+                                    dimensionScoreMap.put(dimensionEntity.getId(),dimensionScoreMap.get(dimensionEntity.getId())==null?Double.parseDouble(answerEntity.getScore()):(dimensionScoreMap.get(dimensionEntity.getId()) +Double.parseDouble(answerEntity.getScore())));
                                 }
                             }
                             break;
@@ -68,10 +70,10 @@ public class COMMONScale extends BaseScale{
                     }
                 }
                 //计算总分
-                for (AnswerEntity answerEntity:answerEntities){
-                    if (answerEntity.getQuestionNo().equals(String.valueOf(i+1))){
-                        if (answerEntity.getName().equals(jsonObject1.getString("checkItems"))){
-                            score += Integer.valueOf(answerEntity.getScore());
+                for (AnswerEntity answerEntity : answerEntities) {
+                    if (answerEntity.getQuestionNo().equals(String.valueOf(i + 1))) {
+                        if (answerEntity.getName().replaceAll("\\s", "").equals(jsonObject1.getString("checkItems").replaceAll("\\s", ""))) {
+                            score += Integer.parseInt(answerEntity.getScore());
                         }
                     }
                 }
@@ -79,15 +81,15 @@ public class COMMONScale extends BaseScale{
 
             resultMap0.put("总分", String.valueOf(score));
             resultJson.put("总分", String.valueOf(score));
-            if (scaleMarksEntities.size() > 0){
-                for (ScaleMarksEntity scaleMarksEntity:scaleMarksEntities){
-                    if (scaleMarksEntity.getName() != null && scaleMarksEntity.getName().equals("无")){
-                        if (score <= Integer.valueOf(scaleMarksEntity.getScoreEnd()) && score >= Integer.valueOf(scaleMarksEntity.getScoreStart())){
-                            if (!scaleMarksEntity.getSymptom().equals("无")){
-                                resultMap0.put("解读", scaleMarksEntity.getSymptom());
-                                resultJson.put("解读", scaleMarksEntity.getSymptom());
+            if (scaleMarksEntities.size() > 0) {
+                for (ScaleMarksEntity scaleMarksEntity : scaleMarksEntities) {
+                    if (scaleMarksEntity.getName() != null && (scaleMarksEntity.getName().equals("无") || scaleMarksEntity.getName().equals("总分"))) {
+                        if (score <= Integer.parseInt(scaleMarksEntity.getScoreEnd()) && score >= Integer.parseInt(scaleMarksEntity.getScoreStart())) {
+                            if (!scaleMarksEntity.getSymptom().equals("无")) {
+                                resultMap0.put("结论", scaleMarksEntity.getSymptom());
+                                resultJson.put("结论", scaleMarksEntity.getSymptom());
                             }
-                            if (scaleMarksEntity.getImprovementSuggestions() != null && !scaleMarksEntity.getImprovementSuggestions().equals("无")){
+                            if (scaleMarksEntity.getImprovementSuggestions() != null && !scaleMarksEntity.getImprovementSuggestions().equals("无")) {
                                 resultMap0.put("建议", scaleMarksEntity.getImprovementSuggestions());
                                 resultJson.put("建议", scaleMarksEntity.getImprovementSuggestions());
                             }
@@ -95,29 +97,29 @@ public class COMMONScale extends BaseScale{
                     }
                 }
             }
-            if (scaleMarksEntities.size() > 0){
+            if (scaleMarksEntities.size() > 0) {
                 for (int y = 0; y < dimensionEntities.size(); y++) {
                     DimensionEntity dimensionEntity = dimensionEntities.get(y);
-                    DecimalFormat df   = new DecimalFormat("######0.00");
-                    resultMap0.put(dimensionEntity.getName()+"得分", String.valueOf(Double.parseDouble(df.format(dimensionScore[y]))));
-                    resultJson.put(dimensionEntity.getName()+"得分", String.valueOf(Double.parseDouble(df.format(dimensionScore[y]))));
-                    for (ScaleMarksEntity scaleMarksEntity:scaleMarksEntities){
-                        if (scaleMarksEntity.getName() != null && scaleMarksEntity.getName().equals(dimensionEntity.getName())){
-                            if (dimensionScore[y] <= Integer.valueOf(scaleMarksEntity.getScoreEnd()) && dimensionScore[y] >= Integer.valueOf(scaleMarksEntity.getScoreStart())){
-                                if (!scaleMarksEntity.getSymptom().equals("无")){
-                                    resultMap0.put(dimensionEntity.getName()+"解读", scaleMarksEntity.getSymptom());
-                                    resultJson.put(dimensionEntity.getName()+"解读", scaleMarksEntity.getSymptom());
+                    DecimalFormat df = new DecimalFormat("######0.00");
+                    resultMap0.put(dimensionEntity.getName() + "得分", String.valueOf(Double.parseDouble(df.format(dimensionScore[y]))));
+                    resultJson.put(dimensionEntity.getName() + "得分", String.valueOf(Double.parseDouble(df.format(dimensionScore[y]))));
+                    for (ScaleMarksEntity scaleMarksEntity : scaleMarksEntities) {
+                        if (scaleMarksEntity.getName() != null && scaleMarksEntity.getName().equals(dimensionEntity.getName())) {
+                            if (dimensionScore[y] <= Integer.parseInt(scaleMarksEntity.getScoreEnd()) && dimensionScore[y] >= Integer.parseInt(scaleMarksEntity.getScoreStart())) {
+                                if (!scaleMarksEntity.getSymptom().equals("无")) {
+                                    resultMap0.put(dimensionEntity.getName() + "结论", scaleMarksEntity.getSymptom());
+                                    resultJson.put(dimensionEntity.getName() + "结论", scaleMarksEntity.getSymptom());
                                 }
-                                if (scaleMarksEntity.getImprovementSuggestions() != null && !scaleMarksEntity.getImprovementSuggestions().equals("无")){
-                                    resultMap0.put(dimensionEntity.getName()+"建议", scaleMarksEntity.getImprovementSuggestions());
-                                    resultJson.put(dimensionEntity.getName()+"建议", scaleMarksEntity.getImprovementSuggestions());
+                                if (scaleMarksEntity.getImprovementSuggestions() != null && !scaleMarksEntity.getImprovementSuggestions().equals("无")) {
+                                    resultMap0.put(dimensionEntity.getName() + "建议", scaleMarksEntity.getImprovementSuggestions());
+                                    resultJson.put(dimensionEntity.getName() + "建议", scaleMarksEntity.getImprovementSuggestions());
                                 }
                             }
                         }
                     }
                 }
                 resultMapList.add(resultMap0);
-            }else {
+            } else {
                 for (int y = 0; y < dimensionEntities.size(); y++) {
                     DimensionEntity dimensionEntity = dimensionEntities.get(y);
                     DecimalFormat df = new DecimalFormat("######0.00");
@@ -126,14 +128,13 @@ public class COMMONScale extends BaseScale{
                 }
                 resultMapList.add(resultMap0);
             }
-
-        }else {
+        } else {
             for (int i = 0; i < jsonArray.size(); i++) {
                 JSONObject jsonObject1 = jsonArray.getJSONObject(i);
-                for (AnswerEntity answerEntity:answerEntities){
-                    if (answerEntity.getQuestionNo().equals(String.valueOf(i+1))){
-                        if (answerEntity.getName().equals(jsonObject1.getString("checkItems"))){
-                            score += Integer.valueOf(answerEntity.getScore());
+                for (AnswerEntity answerEntity : answerEntities) {
+                    if (answerEntity.getQuestionNo().equals(String.valueOf(i + 1))) {
+                        if (answerEntity.getName().replaceAll("\\s", "").equals(jsonObject1.getString("checkItems").replaceAll("\\s", ""))) {
+                            score += Double.parseDouble(answerEntity.getScore());
                         }
                     }
                 }
@@ -141,14 +142,14 @@ public class COMMONScale extends BaseScale{
 
             resultMap0.put("总分", String.valueOf(score));
             resultJson.put("总分", String.valueOf(score));
-            if (scaleMarksEntities.size() > 0){
-                for (ScaleMarksEntity scaleMarksEntity:scaleMarksEntities){
-                    if (score <= Integer.valueOf(scaleMarksEntity.getScoreEnd()) && score >= Integer.valueOf(scaleMarksEntity.getScoreStart())){
-                        if (!scaleMarksEntity.getSymptom().equals("无")){
-                            resultMap0.put("解读", scaleMarksEntity.getSymptom());
-                            resultJson.put("解读", scaleMarksEntity.getSymptom());
+            if (scaleMarksEntities.size() > 0) {
+                for (ScaleMarksEntity scaleMarksEntity : scaleMarksEntities) {
+                    if (score <= Integer.parseInt(scaleMarksEntity.getScoreEnd()) && score >= Integer.parseInt(scaleMarksEntity.getScoreStart())) {
+                        if (!scaleMarksEntity.getSymptom().equals("无")) {
+                            resultMap0.put("结论", scaleMarksEntity.getSymptom());
+                            resultJson.put("结论", scaleMarksEntity.getSymptom());
                         }
-                        if (scaleMarksEntity.getImprovementSuggestions() != null && !scaleMarksEntity.getImprovementSuggestions().equals("无")){
+                        if (scaleMarksEntity.getImprovementSuggestions() != null && !scaleMarksEntity.getImprovementSuggestions().equals("无")) {
                             resultMap0.put("建议", scaleMarksEntity.getImprovementSuggestions());
                             resultJson.put("建议", scaleMarksEntity.getImprovementSuggestions());
                         }
@@ -157,12 +158,16 @@ public class COMMONScale extends BaseScale{
             }
             resultMapList.add(resultMap0);
         }
+        resultJson.put("dimensionScoreMap",dimensionScoreMap);
+
+
 
         JSONObject returnJson = new JSONObject(true);
-        returnJson.put("resultMapList",resultMapList);
-        //returnJson.put("scaleName",resultJson.getString("scaleName"));
-        returnJson.put("resultJson",resultJson);
+        returnJson.put("resultMapList", resultMapList);
+        returnJson.put("resultJson", resultJson);
 
         return returnJson;
     }
+
+
 }

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

@@ -7,6 +7,7 @@ import com.rf.psychological.dao.model.AnswerEntity;
 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 org.springframework.beans.BeanUtils;
 import org.springframework.lang.Nullable;
 
@@ -45,19 +46,19 @@ public class NEWCOMMONScale extends BaseScale {
         List<DimensionEntity> dimensionEntities = (List<DimensionEntity>) resultJson.get("dimensionEntities");
         //计算每个维度得分dimensionEntities
         double[] dimensionScore = new double[dimensionEntities.size()];
+        Map<String,Double> dimensionScoreMap = new HashMap<>();
         //jsonArray:用户自己选择的题目选项
         for (int i = 0; i < jsonArray.size(); i++) {
             JSONObject jsonObject1 = jsonArray.getJSONObject(i);
             //计算总分
             for (AnswerEntity answerEntity : answerEntities) {
                 if (answerEntity.getQuestionNo().equals(jsonObject1.getString("questionNo"))) {
-                    if (answerEntity.getName().equals(jsonObject1.getString("checkItems"))) {
+                    if (answerEntity.getName().replaceAll("\\s", "").equals(jsonObject1.getString("checkItems").replaceAll("\\s", ""))) {
                         score += Double.parseDouble(answerEntity.getScore());
                         break;
                     }
                 }
             }
-
             //计算维度分数
             for (int y = 0; y < dimensionEntities.size(); y++) {
                 //获取维度信息
@@ -65,7 +66,7 @@ public class NEWCOMMONScale extends BaseScale {
                 //获取该维度下有哪些选项
                 String questionNos = dimensionEntity.getQuestionNo();
                 //删除空白字符后得到进行划分得到选择题号
-                String[] questionNo = questionNos.replaceAll("\\s","").split(";");
+                String[] questionNo = questionNos.replaceAll("\\s", "").split(";");
                 //计算每道题的得分
                 for (String question : questionNo) {
                     if (question.equals(jsonObject1.getString("questionNo"))) {
@@ -73,7 +74,8 @@ public class NEWCOMMONScale extends BaseScale {
                         List<AnswerEntity> nowQuestionAnswerList = answerEntities.stream().filter(answerEntity -> answerEntity.getQuestionNo().equals(question)).collect(Collectors.toList());
                         //本题目的正确答案与自己的选项进行对比,正确的话相应分数进行相加
                         for (AnswerEntity answerEntity : nowQuestionAnswerList) {
-                            if (answerEntity.getName().equals(jsonObject1.getString("checkItems"))) {
+                            if (answerEntity.getName().replaceAll("\\s", "").equals(jsonObject1.getString("checkItems").replaceAll("\\s", ""))) {
+                                dimensionScoreMap.put(dimensionEntity.getId(),dimensionScoreMap.get(dimensionEntity.getId())==null?Double.parseDouble(answerEntity.getScore()):(dimensionScoreMap.get(dimensionEntity.getId()) +Double.parseDouble(answerEntity.getScore())));
                                 dimensionScore[y] += Double.parseDouble(answerEntity.getScore());
                                 break;
                             }
@@ -81,7 +83,45 @@ public class NEWCOMMONScale extends BaseScale {
                     }
                 }
             }
+            resultJson.put("dimensionScoreMap",dimensionScoreMap);
+        }
+
+        //判断维度分是否为求平均值
+        boolean totalMark = true;
+        if(dimensionEntities.size() > 0) {
+            for (int y = 0; y < dimensionEntities.size(); y++) {
+                String[] questionNo = dimensionEntities.get(y).getQuestionNo().split(";");
+                for (ScaleMarksEntity scaleMarksEntity : scaleMarksEntities){
+                    //判断总分是否需要处理
+                    if (totalMark){
+                        if (scaleMarksEntity.getName().equals("总分") || scaleMarksEntity.getName().equals("无")){
+                            if (scaleMarksEntity.getScoringType().equals(Constant.DEFAULT_VALUE_ONE)){
+                                score = Double.parseDouble(df.format(score / jsonArray.size()));
+                                totalMark = false;
+                            }else if (scaleMarksEntity.getScoringType().equals(Constant.QUESTION_TYPE_TWO)){
+                                score = Math.round(score / jsonArray.size());
+                                totalMark = false;
+                            }
+                        }
+                    }
+                    //判断维度分是否需要处理
+                    if (scaleMarksEntity.getName().equals(dimensionEntities.get(y).getName())){
+                        if (scaleMarksEntity.getScoringType().equals(Constant.DEFAULT_VALUE_ONE)){
+                            dimensionScore[y] = Double.parseDouble(df.format(dimensionScore[y] / questionNo.length));
+                            dimensionScoreMap.put(dimensionEntities.get(y).getId(),dimensionScore[y]);
+                            break;
+                        }else if (scaleMarksEntity.getScoringType().equals(Constant.QUESTION_TYPE_TWO)){
+                            dimensionScore[y] = Math.round(dimensionScore[y] / questionNo.length);
+                            dimensionScoreMap.put(dimensionEntities.get(y).getId(),dimensionScore[y]);
+                            break;
+                        }
+
+                    }
+                }
+            }
         }
+
+
         //将量表总维度根据维度名称进行分组
         Map<String, List<ScaleMarksEntity>> scaleMarksMap = scaleMarksEntities.stream().collect(Collectors.groupingBy(ScaleMarksEntity::getName));
         //返回值以及存数据库格式
@@ -91,9 +131,29 @@ public class NEWCOMMONScale extends BaseScale {
         BigDecimal scoreDecimal = new BigDecimal(df.format(score));
         //如果没有总分这一栏,需要手动赋值返回
         List<ScaleMarksEntity> totalScore = scaleMarksMap.get("总分");
+        List<ScaleMarksEntity> totalScores = scaleMarksMap.get("无");
         if (totalScore == null) {
-            newResultDtos.add(new NewResultDto("总分", df.format(score), "无", "无",
-                    "无", "无", "无", "无", "是"));
+            if (totalScores == null){
+                newResultDtos.add(new NewResultDto("总分", df.format(score), "无", "无",
+                        "无", "无", "无", "无", "是"));
+            }else {
+                for (ScaleMarksEntity tempTotalScore : totalScores) {
+                    BigDecimal scoreStart = new BigDecimal(tempTotalScore.getScoreStart());
+                    BigDecimal scoreEnd = new BigDecimal(tempTotalScore.getScoreEnd());
+                    if (scoreDecimal.compareTo(scoreEnd) <= 0 && scoreDecimal.compareTo(scoreStart) >= 0) {
+                        newResultDtos.add(new NewResultDto("总分", df.format(score), tempTotalScore.getSymptom(), tempTotalScore.getImprovementSuggestions(),
+                                tempTotalScore.getFlag(), tempTotalScore.getReference(), tempTotalScore.getNameExplain(), tempTotalScore.getSuggestion(), tempTotalScore.getIsTotalScoreExplain()));
+                        resultMap0.put("总分症状", tempTotalScore.getSymptom());
+                        resultMap0.put("总分指导语", tempTotalScore.getImprovementSuggestions());
+                        resultMap0.put("总分因子解释", tempTotalScore.getNameExplain());
+                        resultMap0.put("总分建议", tempTotalScore.getSuggestion());
+                        resultJson.put("总分症状", tempTotalScore.getSymptom());
+                        resultJson.put("总分指导语", tempTotalScore.getImprovementSuggestions());
+                        resultJson.put("总分因子解释", tempTotalScore.getNameExplain());
+                        resultJson.put("总分建议", tempTotalScore.getSuggestion());
+                    }
+                }
+            }
         } else {
             for (ScaleMarksEntity tempTotalScore : totalScore) {
                 BigDecimal scoreStart = new BigDecimal(tempTotalScore.getScoreStart());
@@ -101,6 +161,14 @@ public class NEWCOMMONScale extends BaseScale {
                 if (scoreDecimal.compareTo(scoreEnd) <= 0 && scoreDecimal.compareTo(scoreStart) >= 0) {
                     newResultDtos.add(new NewResultDto("总分", df.format(score), tempTotalScore.getSymptom(), tempTotalScore.getImprovementSuggestions(),
                             tempTotalScore.getFlag(), tempTotalScore.getReference(), tempTotalScore.getNameExplain(), tempTotalScore.getSuggestion(), tempTotalScore.getIsTotalScoreExplain()));
+                    resultMap0.put("总分症状", tempTotalScore.getSymptom());
+                    resultMap0.put("总分指导语", tempTotalScore.getImprovementSuggestions());
+                    resultMap0.put("总分因子解释", tempTotalScore.getNameExplain());
+                    resultMap0.put("总分建议", tempTotalScore.getSuggestion());
+                    resultJson.put("总分症状", tempTotalScore.getSymptom());
+                    resultJson.put("总分指导语", tempTotalScore.getImprovementSuggestions());
+                    resultJson.put("总分因子解释", tempTotalScore.getNameExplain());
+                    resultJson.put("总分建议", tempTotalScore.getSuggestion());
                 }
             }
         }
@@ -130,6 +198,7 @@ public class NEWCOMMONScale extends BaseScale {
         newResult.put("result", newResultDtos);
         resultMapList.add(resultMap0);
 
+
         JSONObject returnJson = new JSONObject(true);
         returnJson.put("resultMapList", resultMapList);
         returnJson.put("resultJson", resultJson);
@@ -179,7 +248,7 @@ public class NEWCOMMONScale extends BaseScale {
                         if ("1".equals(dimensionEntity.getIsIconFlag())) {
                             indicatorMap.put("text", dimensionEntity.getName());
                             //将当前维度按照分数的结尾值来进行排序scaleMarksEntities1
-                            List<ScaleMarksEntity> collect = scaleMarksEntities1.stream().sorted(Comparator.comparing(ScaleMarksEntity::getScoreEnd, Comparator.comparingInt(Integer::parseInt))
+                            List<ScaleMarksEntity> collect = scaleMarksEntities1.stream().sorted(Comparator.comparing(ScaleMarksEntity::getScoreEnd, Comparator.comparingDouble(Double::parseDouble))
                                     .reversed()).collect(Collectors.toList());
                             //排序完成后第一个的scoreEnd最大,也就是该维度最大的
                             indicatorMap.put("max", collect.get(0).getScoreEnd());
@@ -278,13 +347,15 @@ 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());
+        resultJson.put(dimensionName + "结论", scaleMarksEntity.getSymptom());
         resultMap0.put(dimensionName + "因子解释", scaleMarksEntity.getNameExplain());
+        resultJson.put(dimensionName + "因子解释", scaleMarksEntity.getNameExplain());
         resultMap0.put(dimensionName + "指导语", scaleMarksEntity.getImprovementSuggestions());
         resultJson.put(dimensionName + "指导语", scaleMarksEntity.getImprovementSuggestions());
         resultMap0.put(dimensionName + "建议", scaleMarksEntity.getSuggestion());
+        resultJson.put(dimensionName + "建议", scaleMarksEntity.getSuggestion());
         BeanUtils.copyProperties(scaleMarksEntity, newResultDto1);
     }
 

+ 2 - 1
src/main/java/com/rf/psychological/scale/service/UserRecordService.java

@@ -1,5 +1,6 @@
 package com.rf.psychological.scale.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.rf.psychological.dao.dto.InstitutionRecordingDTO;
 import com.rf.psychological.dao.dto.InstitutionRecordingUserDTO;
 import com.rf.psychological.dao.dto.InstitutionRecordingUsersDTO;
@@ -118,7 +119,7 @@ public interface UserRecordService {
      * @param name
      * @return
      */
-    List<InstitutionRecordingUserDTO> getInstitutionRecording(int pageNum, int pageSize, String institutionNo, String name, String searchKey, String beginFormat, String endFormat);
+    List<JSONObject> getInstitutionRecording(int pageNum, int pageSize, String institutionNo, String name, String searchKey, String beginFormat, String endFormat);
 
     int allCountInstitutionRecording(String institutionNo, String name, String searchKey, String beginFormat, String endFormat);
 

+ 2 - 1
src/main/java/com/rf/psychological/scale/service/impl/UserRecordServiceImpl.java

@@ -1,6 +1,7 @@
 package com.rf.psychological.scale.service.impl;
 
 
+import com.alibaba.fastjson.JSONObject;
 import com.querydsl.core.BooleanBuilder;
 import com.querydsl.core.types.Projections;
 import com.querydsl.core.types.dsl.Wildcard;
@@ -242,7 +243,7 @@ public class UserRecordServiceImpl implements UserRecordService {
     }
 
     @Override
-    public List<InstitutionRecordingUserDTO> getInstitutionRecording(int pageNum, int pageSize, String institutionNo, String name, String searchKey, String beginFormat, String endFormat) {
+    public List<JSONObject> getInstitutionRecording(int pageNum, int pageSize, String institutionNo, String name, String searchKey, String beginFormat, String endFormat) {
         Pageable pageRequest = PageRequest.of(pageNum - 1, pageSize);
         return this.userRecordRepository.getInstitutionRecording(pageRequest, institutionNo, name, searchKey, beginFormat, endFormat);
     }