Browse Source

拖延症量表开发

zsf 3 months ago
parent
commit
c064a2def9

+ 3 - 0
src/main/java/com/rf/psychological/filter/JWTInterceptorConfig.java

@@ -50,6 +50,7 @@ public class JWTInterceptorConfig implements WebMvcConfigurer {
                 .excludePathPatterns("/param/**")
                 .excludePathPatterns("/userImport")
                 .excludePathPatterns("/test/token")
+                .excludePathPatterns("/system/updateMarks/**")
                 .excludePathPatterns(swaggerExcludes)
 //                .excludePathPatterns(temporarily)
                 .excludePathPatterns("/favicon.ico")
@@ -72,6 +73,8 @@ public class JWTInterceptorConfig implements WebMvcConfigurer {
                 .excludePathPatterns("/param/**")
                 .excludePathPatterns("/userImport")
                 .excludePathPatterns("/test/token")
+                .excludePathPatterns("/system/updateMarks/**")
+
                 .excludePathPatterns(swaggerExcludes)
 //                .excludePathPatterns(temporarily)
                 .excludePathPatterns("/favicon.ico")

+ 0 - 10
src/main/java/com/rf/psychological/scale/resultBusiness/scaleResult/COMMONScale.java

@@ -24,16 +24,6 @@ public class COMMONScale extends BaseScale {
 
     public JSONObject scaleCalculate() throws Exception {
 
-        // 自定义路径使用
-        /*ScaleUtil.getScaleDll("FESCVSCALE.dll");
-        System.out.println("JSONArray:"+jsonArray);
-        System.out.println("JSONObject:"+resultJson);
-        ScalesJNI scalesJNI = new ScalesJNI(jsonArray,resultJson);
-        String result = scalesJNI.commonScale(jsonArray.toString(), resultJson.toString());
-        JSONObject jsonObjectc =JSONObject.parseObject(result);
-        System.out.println("jsonObjectc:"+jsonObjectc);
-        return jsonObjectc;*/
-
         //总分
         double score = 0;
         Map<String, String> resultMap0 = new LinkedHashMap<>();

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

@@ -141,17 +141,18 @@ public class NEWCOMMONScale extends BaseScale {
                     if (scoreDecimal.compareTo(scoreEnd) <= 0 && scoreDecimal.compareTo(scoreStart) >= 0) {
 
                         String suggest = RandomSuggestionUtil.getSuggestion(tempTotalScore.getImprovementSuggestions());
+                        String suggest2 = RandomSuggestionUtil.getSuggestion2(tempTotalScore.getSuggestion());
                         newResultDtos.add(new NewResultDto("总分", df.format(score), tempTotalScore.getSymptom(), suggest,
-                                tempTotalScore.getFlag(), tempTotalScore.getReference(), tempTotalScore.getNameExplain(), tempTotalScore.getSuggestion(), tempTotalScore.getIsTotalScoreExplain()));
+                                tempTotalScore.getFlag(), tempTotalScore.getReference(), tempTotalScore.getNameExplain(), suggest2, tempTotalScore.getIsTotalScoreExplain()));
 
                         resultMap0.put("总分解释", tempTotalScore.getSymptom());
                         resultMap0.put("总分说明", suggest);
                         resultMap0.put("总分解读", tempTotalScore.getNameExplain());
-                        resultMap0.put("总分建议", tempTotalScore.getSuggestion());
+                        resultMap0.put("总分建议", suggest2);
                         resultJson.put("总分解释", tempTotalScore.getSymptom());
                         resultJson.put("总分说明", suggest);
                         resultJson.put("总分解读", tempTotalScore.getNameExplain());
-                        resultJson.put("总分建议", tempTotalScore.getSuggestion());
+                        resultJson.put("总分建议", suggest2);
                         break;
                     }
                     //计算总分占比
@@ -170,17 +171,18 @@ public class NEWCOMMONScale extends BaseScale {
                 BigDecimal scoreEnd = new BigDecimal(tempTotalScore.getScoreEnd());
                 if (scoreDecimal.compareTo(scoreEnd) <= 0 && scoreDecimal.compareTo(scoreStart) >= 0) {
                     String suggest = RandomSuggestionUtil.getSuggestion(tempTotalScore.getImprovementSuggestions());
+                    String suggest2 = RandomSuggestionUtil.getSuggestion2(tempTotalScore.getSuggestion());
                     newResultDtos.add(new NewResultDto("总分", df.format(score), tempTotalScore.getSymptom(), suggest,
-                            tempTotalScore.getFlag(), tempTotalScore.getReference(), tempTotalScore.getNameExplain(), tempTotalScore.getSuggestion(), tempTotalScore.getIsTotalScoreExplain()));
+                            tempTotalScore.getFlag(), tempTotalScore.getReference(), tempTotalScore.getNameExplain(), suggest2, tempTotalScore.getIsTotalScoreExplain()));
 
                     resultMap0.put("总分解释", tempTotalScore.getSymptom());
                     resultMap0.put("总分说明", suggest);
                     resultMap0.put("总分解读", tempTotalScore.getNameExplain());
-                    resultMap0.put("总分建议", tempTotalScore.getSuggestion());
+                    resultMap0.put("总分建议", suggest2);
                     resultJson.put("总分解释", tempTotalScore.getSymptom());
                     resultJson.put("总分说明", suggest);
                     resultJson.put("总分解读", tempTotalScore.getNameExplain());
-                    resultJson.put("总分建议", tempTotalScore.getSuggestion());
+                    resultJson.put("总分建议", suggest2);
                     break;
                 }
             }
@@ -412,14 +414,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());
         String suggest = RandomSuggestionUtil.getSuggestion(scaleMarksEntity.getImprovementSuggestions());
+        String suggest2 = RandomSuggestionUtil.getSuggestion2(scaleMarksEntity.getSuggestion());
         resultMap0.put(dimensionName + "解释", scaleMarksEntity.getSymptom());
         resultJson.put(dimensionName + "解释", scaleMarksEntity.getSymptom());
         resultMap0.put(dimensionName + "解读", scaleMarksEntity.getNameExplain());
         resultJson.put(dimensionName + "解读", scaleMarksEntity.getNameExplain());
         resultMap0.put(dimensionName + "说明", suggest);
         resultJson.put(dimensionName + "说明", suggest);
-        resultMap0.put(dimensionName + "建议", scaleMarksEntity.getSuggestion());
-        resultJson.put(dimensionName + "建议", scaleMarksEntity.getSuggestion());
+        resultMap0.put(dimensionName + "建议", suggest2);
+        resultJson.put(dimensionName + "建议", suggest2);
         BeanUtils.copyProperties(scaleMarksEntity, newResultDto1);
         newResultDto1.setImprovementSuggestions(suggest);
     }

+ 35 - 22
src/main/java/com/rf/psychological/user/rest/SystemController.java

@@ -639,26 +639,38 @@ public class SystemController extends BaseController {
         try {
             List<List<List<Object>>> datas = ExcelUtil.getBankListByExcelSheet(new FileInputStream(file.getAbsolutePath()), file.getName());
             List<ScaleEntity> scaleEntities = scaleService.getScaleByFlag(flag);
-            List<List<Object>> an = datas.get(1);
-            for (ScaleEntity scaleEntity : scaleEntities) {
-                log.info("------" + scaleEntity.getCheckItems());
-                String no = scaleEntity.getQuestionNo();
-                String item = null;
-                for (List<Object> objects : an) {
-                    if (objects.get(0).equals(no)) {
-                        if (StringUtils.isEmpty(item)) {
-                            item = objects.get(1).toString();
-                        } else {
-                            item = item + ";" + objects.get(1).toString();
-                        }
-                    }
-                }
-                scaleEntity.setCheckItems(item);
-                if (item != null){
-                     //scaleService.saveScale(scaleEntity);
-                }
-                log.info("------" + scaleEntity.toString());
-            }
+            List<List<Object>> an = datas.get(0);
+            for (int i= scaleEntities.size() ;i< an.size();i++){
+                List<Object> objects = an.get(i);
+                ScaleEntity scaleEntity = new ScaleEntity();
+                scaleEntity.setCheckItems(objects.get(3).toString());
+                scaleEntity.setSerialNo(String.valueOf(i+1));
+                scaleEntity.setAnswer(objects.get(2).toString());
+                scaleEntity.setFlag(flag);
+                scaleEntity.setQuestionNo(String.valueOf(i+1));
+                scaleEntity.setScoreDirection(Constant.DEFAULT_VALUE_ONE);
+                scaleService.saveScale(scaleEntity);
+                log.info(scaleEntity.toString());
+            }
+//            for (ScaleEntity scaleEntity : scaleEntities) {
+//                log.info("------" + scaleEntity.getCheckItems());
+//                String no = scaleEntity.getQuestionNo();
+//                String item = null;
+//                for (List<Object> objects : an) {
+//                    if (objects.get(0).equals(no)) {
+//                        if (StringUtils.isEmpty(item)) {
+//                            item = objects.get(1).toString();
+//                        } else {
+//                            item = item + ";" + objects.get(1).toString();
+//                        }
+//                    }
+//                }
+//                scaleEntity.setCheckItems(item);
+//                if (item != null){
+//                     //scaleService.saveScale(scaleEntity);
+//                }
+//                log.info("------" + scaleEntity.toString());
+//            }
         }catch (Exception e){
             e.printStackTrace();
         }
@@ -696,9 +708,10 @@ public class SystemController extends BaseController {
             List<List<Object>> markObj = datas.get(2);
             for (int i =0;i<scaleMarksEntities.size();i++){
                 ScaleMarksEntity entity = scaleMarksEntities.get(i);
-                entity.setImprovementSuggestions(markObj.get(i).get(4).toString());
+                entity.setImprovementSuggestions(markObj.get(i).get(7).toString());
+                entity.setSuggestion(markObj.get(i).get(8).toString());
                 log.info(entity.toString());
-                //scaleMarksService.saveScaleMarks(entity);
+                scaleMarksService.saveScaleMarks(entity);
             }
 
         }catch (Exception e){

+ 12 - 0
src/main/java/com/rf/psychological/utils/RandomSuggestionUtil.java

@@ -23,4 +23,16 @@ public class RandomSuggestionUtil {
             return suggestion;
         }
     }
+
+    public static String getSuggestion2(String suggestion){
+        List<String> list = Arrays.asList(suggestion.split("#;"));
+        if (list.size()>1){
+            int size = list.size();
+            int num = RandomUtil.randomInt(0,size-1);
+            String text = list.get(num);
+            return text.contains("#")?text.replace("#",""):text;
+        }else {
+            return suggestion;
+        }
+    }
 }