浏览代码

修改打分跳转效验提交

zsy 1 年之前
父节点
当前提交
8538af7a19

+ 4 - 1
src/main/java/com/rf/kjb/chat/dao/domain/QuestionSkipEntity.java

@@ -22,7 +22,10 @@ public class QuestionSkipEntity extends BaseEntry {
     @Column(name = "question_no",columnDefinition = "varchar(50) not null comment '问题编号'")
     @Column(name = "question_no",columnDefinition = "varchar(50) not null comment '问题编号'")
     private String questionNo;
     private String questionNo;
 
 
-    @Column(name = "type",columnDefinition = "varchar(2) not null comment '分类:1-评测结果;2-治疗成绩;3-训练内容;4-情绪打分跳转;5-开场白'")
+    @Column(name = "skip_question_no",columnDefinition = "varchar(50) null comment '跳转问题编号'")
+    private String skipQuestionNo;
+
+    @Column(name = "type",columnDefinition = "varchar(2) not null comment '分类:1-评测结果;2-治疗成绩;3-训练内容;4-情绪二次打分跳转;5-情绪首次打分跳转'")
     private String type;
     private String type;
 
 
     @Column(name = "label",columnDefinition = "varchar(2) not null comment '类型:1-焦虑;2-抑郁;3-失眠;4-压力;5-开场白'")
     @Column(name = "label",columnDefinition = "varchar(2) not null comment '类型:1-焦虑;2-抑郁;3-失眠;4-压力;5-开场白'")

+ 13 - 0
src/main/java/com/rf/kjb/chat/dao/repository/QuestionSkipRepository.java

@@ -0,0 +1,13 @@
+package com.rf.kjb.chat.dao.repository;
+
+
+import com.rf.kjb.base.repository.BaseRepository;
+import com.rf.kjb.chat.dao.domain.ChatAnswerEntity;
+import com.rf.kjb.chat.dao.domain.QuestionSkipEntity;
+
+import java.util.List;
+
+public interface QuestionSkipRepository extends BaseRepository<QuestionSkipEntity,String> {
+
+    List<QuestionSkipEntity> findByLabelAndNumAndType(String label, String num, String type);
+}

+ 66 - 12
src/main/java/com/rf/kjb/chat/rest/ChatController.java

@@ -4,10 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.auth0.jwt.interfaces.DecodedJWT;
 import com.auth0.jwt.interfaces.DecodedJWT;
 import com.rf.kjb.base.rest.BaseController;
 import com.rf.kjb.base.rest.BaseController;
 import com.rf.kjb.chat.dao.domain.*;
 import com.rf.kjb.chat.dao.domain.*;
-import com.rf.kjb.chat.service.ChatAnswerService;
-import com.rf.kjb.chat.service.ChatQuestionService;
-import com.rf.kjb.chat.service.ChatRecordService;
-import com.rf.kjb.chat.service.ResultQuestionService;
+import com.rf.kjb.chat.service.*;
 import com.rf.kjb.excel.ExcelUtil;
 import com.rf.kjb.excel.ExcelUtil;
 import com.rf.kjb.exception.ErrorCode;
 import com.rf.kjb.exception.ErrorCode;
 import com.rf.kjb.intelligentDialogue.dao.domain.IntelligentDialogueEntity;
 import com.rf.kjb.intelligentDialogue.dao.domain.IntelligentDialogueEntity;
@@ -69,11 +66,8 @@ public class ChatController extends BaseController {
     @Autowired
     @Autowired
     private IntelligentDialogueService intelligentDialogueService;
     private IntelligentDialogueService intelligentDialogueService;
 
 
-    private String depressedOneEvaluationResult = "'5','134','298'";
-    private String depressedTwoEvaluationResult = "'5','134'";
-    private String depressedThreeEvaluationResult = "'5','134'";
-    private String depressedFourEvaluationResult = "'5','134'";
-    private String depressedFiveEvaluationResult = "'5','134'";
+    @Autowired
+    private QuestionSkipService questionSkipService;
 
 
     /**
     /**
      * 查询会话问题
      * 查询会话问题
@@ -97,7 +91,63 @@ public class ChatController extends BaseController {
             questionEntity.setQuestion(userEntry.getUserName()+questionEntity.getQuestion());
             questionEntity.setQuestion(userEntry.getUserName()+questionEntity.getQuestion());
         }
         }
         //情绪打分跳转
         //情绪打分跳转
-        if (label.equals("2")){
+        List<QuestionSkipEntity> questionSkipEntities = this.questionSkipService.findByLabelAndNumAndType(label,num,"5");
+        for (QuestionSkipEntity questionSkipEntity : questionSkipEntities) {
+            if (id.equals(questionSkipEntity.getQuestionNo())){
+                int a = emotionScore(identifier,label,num,questionSkipEntity.getSkipQuestionNo());
+                switch (a) {
+                    case 1:
+                        questionEntity = this.questionService.findByIdAndLabelAndNum(id, label, num);
+                        break;
+                    case 2:
+                        questionEntity = this.questionService.findByIdAndLabelAndNum(String.valueOf(Integer.valueOf(id)+2), label, num);
+                        break;
+                    case 3:
+                        questionEntity = this.questionService.findByIdAndLabelAndNum(String.valueOf(Integer.valueOf(id)+4), label, num);
+                        break;
+                    case 4:
+                        questionEntity = this.questionService.findByIdAndLabelAndNum(String.valueOf(Integer.valueOf(id)+6), label, num);
+                        break;
+                    default:
+                        break;
+                }
+            }
+        }
+        //情绪二次打分跳转
+        if (id.equals("4")){
+            if (num.equals("2") || num.equals("3") || num.equals("4") || num.equals("5")){
+                String lastNum = String.valueOf(Integer.valueOf(num) - 1);
+                IntelligentDialogueEntity intelligentDialogue = this.intelligentDialogueService.findLastScoreByIdentifierByLabelByNumByQuestionNo(identifier,label,lastNum,"5");
+                int lastScore = 0;
+                if (intelligentDialogue != null){
+                    lastScore = Integer.valueOf(intelligentDialogue.getContent());
+                }
+                IntelligentDialogueEntity intelligentDialogueEntity = this.intelligentDialogueService.findScoreByIdentifierByLabelByNumByQuestionNo(identifier,label,num);
+                int score = Integer.valueOf(intelligentDialogueEntity.getContent()) - lastScore;
+                if (score <= -80){
+                    questionEntity = this.questionService.findByIdAndLabelAndNum("13", label, num);
+                }else if (score <= -60 && score > -80){
+                    questionEntity = this.questionService.findByIdAndLabelAndNum("11", label, num);
+                }else if (score <= -40 && score > -60){
+                    questionEntity = this.questionService.findByIdAndLabelAndNum("9", label, num);
+                }else if (score <= -20 && score > -40){
+                    questionEntity = this.questionService.findByIdAndLabelAndNum("7", label, num);
+                }else if (score <= 0 && score > -20){
+                    questionEntity = this.questionService.findByIdAndLabelAndNum("5", label, num);
+                }else if (score <= 20 && score > 0){
+                    questionEntity = this.questionService.findByIdAndLabelAndNum("4", label, num);
+                }else if (score <= 40 && score > 20){
+                    questionEntity = this.questionService.findByIdAndLabelAndNum("6", label, num);
+                }else if (score <= 60 && score > 40){
+                    questionEntity = this.questionService.findByIdAndLabelAndNum("8", label, num);
+                }else if (score <= 80 && score > 60){
+                    questionEntity = this.questionService.findByIdAndLabelAndNum("10", label, num);
+                }else {
+                    questionEntity = this.questionService.findByIdAndLabelAndNum("12", label, num);
+                }
+            }
+        }
+        /*if (label.equals("2")){
             if (num.equals("1")){
             if (num.equals("1")){
                 if (id.equals("41")){
                 if (id.equals("41")){
                     questionEntity = emotionScoreSkip(identifier,label,num,"40");
                     questionEntity = emotionScoreSkip(identifier,label,num,"40");
@@ -164,7 +214,11 @@ public class ChatController extends BaseController {
                 //情绪二次打分跳转
                 //情绪二次打分跳转
                 if (id.equals("4")){
                 if (id.equals("4")){
                     String lastNum = String.valueOf(Integer.valueOf(num) - 1);
                     String lastNum = String.valueOf(Integer.valueOf(num) - 1);
-                    int lastScore = Integer.valueOf(this.intelligentDialogueService.findLastScoreByIdentifierByLabelByNumByQuestionNo(identifier,label,lastNum,"4").getContent());
+                    IntelligentDialogueEntity intelligentDialogue = this.intelligentDialogueService.findLastScoreByIdentifierByLabelByNumByQuestionNo(identifier,label,lastNum,"4");
+                    int lastScore = 0;
+                    if (intelligentDialogue != null){
+                        lastScore = Integer.valueOf(intelligentDialogue.getContent());
+                    }
                     IntelligentDialogueEntity intelligentDialogueEntity = this.intelligentDialogueService.findScoreByIdentifierByLabelByNumByQuestionNo(identifier,label,num);
                     IntelligentDialogueEntity intelligentDialogueEntity = this.intelligentDialogueService.findScoreByIdentifierByLabelByNumByQuestionNo(identifier,label,num);
                     int score = Integer.valueOf(intelligentDialogueEntity.getContent()) - lastScore;
                     int score = Integer.valueOf(intelligentDialogueEntity.getContent()) - lastScore;
                     if (score <= -80){
                     if (score <= -80){
@@ -190,7 +244,7 @@ public class ChatController extends BaseController {
                     }
                     }
                 }
                 }
             }
             }
-        }
+        }*/
         //替换用户名
         //替换用户名
         if (questionEntity.getQuestion().contains("userName")){
         if (questionEntity.getQuestion().contains("userName")){
             questionEntity.setQuestion(questionEntity.getQuestion().replace("userName",userEntry.getUserName()));
             questionEntity.setQuestion(questionEntity.getQuestion().replace("userName",userEntry.getUserName()));

+ 12 - 0
src/main/java/com/rf/kjb/chat/service/QuestionSkipService.java

@@ -0,0 +1,12 @@
+package com.rf.kjb.chat.service;
+
+
+import com.rf.kjb.chat.dao.domain.ChatAnswerEntity;
+import com.rf.kjb.chat.dao.domain.QuestionSkipEntity;
+
+import java.util.List;
+
+public interface QuestionSkipService {
+
+    List<QuestionSkipEntity> findByLabelAndNumAndType(String label, String num, String type);
+}

+ 29 - 0
src/main/java/com/rf/kjb/chat/service/impl/QuestionSkipServiceImpl.java

@@ -0,0 +1,29 @@
+package com.rf.kjb.chat.service.impl;
+
+import com.rf.kjb.chat.dao.domain.ChatAnswerEntity;
+import com.rf.kjb.chat.dao.domain.QuestionSkipEntity;
+import com.rf.kjb.chat.dao.repository.ChatAnswerRepository;
+import com.rf.kjb.chat.dao.repository.QuestionSkipRepository;
+import com.rf.kjb.chat.service.ChatAnswerService;
+import com.rf.kjb.chat.service.QuestionSkipService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @Author:zzf
+ * @Date:2022/10/21:01:06
+ * @Description:
+ */
+@Service
+public class QuestionSkipServiceImpl implements QuestionSkipService {
+
+    @Autowired
+    private QuestionSkipRepository questionSkipRepository;
+
+    @Override
+    public List<QuestionSkipEntity> findByLabelAndNumAndType(String label, String num, String type) {
+        return this.questionSkipRepository.findByLabelAndNumAndType(label,num,type);
+    }
+}

+ 1 - 1
src/main/java/com/rf/kjb/intelligentDialogue/dao/repository/IntelligentDialogueRepository.java

@@ -55,7 +55,7 @@ public interface IntelligentDialogueRepository extends BaseRepository<Intelligen
     IntelligentDialogueEntity findEmotionScoreByIdentifierByLabelByNumByQuestionNo(@Param("identifier") String identifier,@Param("label") String label,@Param("num") String num,@Param("questionNo") String questionNo);
     IntelligentDialogueEntity findEmotionScoreByIdentifierByLabelByNumByQuestionNo(@Param("identifier") String identifier,@Param("label") String label,@Param("num") String num,@Param("questionNo") String questionNo);
 
 
     @Query(value = "SELECT * FROM t_intelligent_dialogue WHERE identifier = :identifier AND type = :label AND num = :num AND question_no in(" +
     @Query(value = "SELECT * FROM t_intelligent_dialogue WHERE identifier = :identifier AND type = :label AND num = :num AND question_no in(" +
-            "SELECT question_no FROM t_question_skip WHERE label = :label AND num = :num AND type = :type " +
+            "SELECT skip_question_no FROM t_question_skip WHERE label = :label AND num = :num AND type = :type " +
             ") AND label = '1' ORDER BY create_time DESC LIMIT 1 ", nativeQuery = true)
             ") AND label = '1' ORDER BY create_time DESC LIMIT 1 ", nativeQuery = true)
     IntelligentDialogueEntity findLastScoreByIdentifierByLabelByNumByQuestionNo(@Param("identifier") String identifier,@Param("label") String label,@Param("num") String num,@Param("type") String type);
     IntelligentDialogueEntity findLastScoreByIdentifierByLabelByNumByQuestionNo(@Param("identifier") String identifier,@Param("label") String label,@Param("num") String num,@Param("type") String type);