Просмотр исходного кода

修改对话记录功能提交

zsy 1 год назад
Родитель
Сommit
c314db01a9

+ 2 - 1
src/main/java/com/rf/kjb/chat/dao/domain/ChatQuestionEntity.java

@@ -28,7 +28,7 @@ public class ChatQuestionEntity   {
     @Column(name = "next_question_no",columnDefinition = "varchar(50) not null comment '下一个问题编号'")
     private String nextQuestionNo;
 
-    @Column(name = "question_type",columnDefinition = "varchar(200) not null comment '题目类型:0 选择题 1填空题 2跳转路由'")
+    @Column(name = "question_type",columnDefinition = "varchar(200) not null comment '题目类型:0 选择题 1填空题 2跳转路由 3整数(0-100)'")
     private String questionType;
 
     @Id
@@ -38,6 +38,7 @@ public class ChatQuestionEntity   {
     @Column(name = "scale_flag",columnDefinition = "varchar(50) comment '量表标志,如果是量表的题目信息,此处为量表flag'")
     private String scaleFlag;
 
+    @Id
     @Column(name = "num",columnDefinition = "varchar(2) not null comment '对话轮次:1-第一次对话;2-第二次对话;3-第三次对话;4-第四次对话;5-第五次对话'")
     private String num;
 }

+ 1 - 0
src/main/java/com/rf/kjb/chat/dao/domain/ChatQuestionId.java

@@ -15,4 +15,5 @@ import java.io.Serializable;
 public class ChatQuestionId implements Serializable {
     String id;
     String label;
+    String num;
 }

+ 33 - 0
src/main/java/com/rf/kjb/chat/dao/domain/QuestionSkipEntity.java

@@ -0,0 +1,33 @@
+package com.rf.kjb.chat.dao.domain;
+
+import com.rf.kjb.base.model.BaseEntry;
+import lombok.*;
+
+import javax.persistence.*;
+
+/**
+ * @Author:zzf
+ * @Date:2022/10/21:00:30
+ * @Description:
+ */
+@Entity
+@Data
+@Getter
+@Setter
+@NoArgsConstructor
+@AllArgsConstructor
+@Table(name = "t_question_skip")
+@org.hibernate.annotations.Table(appliesTo = "t_question_skip", comment = "对话问题跳转表")
+public class QuestionSkipEntity extends BaseEntry {
+    @Column(name = "question_no",columnDefinition = "varchar(50) not null comment '问题编号'")
+    private String questionNo;
+
+    @Column(name = "type",columnDefinition = "varchar(2) not null comment '分类:1-评测结果;2-治疗成绩;3-训练内容;4-情绪打分跳转;5-开场白'")
+    private String type;
+
+    @Column(name = "label",columnDefinition = "varchar(2) not null comment '类型:1-焦虑;2-抑郁;3-失眠;4-压力;5-开场白'")
+    private String label;
+
+    @Column(name = "num",columnDefinition = "varchar(2) not null comment '对话轮次:1-第一次对话;2-第二次对话;3-第三次对话;4-第四次对话;5-第五次对话'")
+    private String num;
+}

+ 3 - 1
src/main/java/com/rf/kjb/chat/dao/repository/ResultQuestionRepository.java

@@ -5,5 +5,7 @@ import com.rf.kjb.base.repository.BaseRepository;
 import com.rf.kjb.chat.dao.domain.ResultQuestionEntity;
 
 public interface ResultQuestionRepository extends BaseRepository<ResultQuestionEntity,String> {
-    ResultQuestionEntity findByLabelAndResult(String label, String result);
+    ResultQuestionEntity findByLabelAndResultAndNum(String label, String result, String num);
+
+    ResultQuestionEntity findByLabelAndNum(String label, String num);
 }

+ 559 - 24
src/main/java/com/rf/kjb/chat/rest/ChatController.java

@@ -10,6 +10,9 @@ import com.rf.kjb.chat.service.ChatRecordService;
 import com.rf.kjb.chat.service.ResultQuestionService;
 import com.rf.kjb.excel.ExcelUtil;
 import com.rf.kjb.exception.ErrorCode;
+import com.rf.kjb.intelligentDialogue.dao.domain.IntelligentDialogueEntity;
+import com.rf.kjb.intelligentDialogue.service.IntelligentDialogueService;
+import com.rf.kjb.opLog.dao.model.SysLogEntity;
 import com.rf.kjb.scale.util.DateUtil;
 import com.rf.kjb.user.dao.model.UserEntry;
 import com.rf.kjb.user.service.UserService;
@@ -23,8 +26,6 @@ import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.time.DateUtils;
-import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.usermodel.XSSFCell;
 import org.apache.poi.xssf.usermodel.XSSFRow;
 import org.apache.poi.xssf.usermodel.XSSFSheet;
@@ -65,6 +66,15 @@ public class ChatController extends BaseController {
     @Autowired
     private UserService userService;
 
+    @Autowired
+    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'";
+
     /**
      * 查询会话问题
      */
@@ -77,24 +87,165 @@ public class ChatController extends BaseController {
             id = "1";
         }
         ChatQuestionEntity questionEntity = this.questionService.findByIdAndLabelAndNum(id, label, num);
+        String token = request.getHeader("Authorization");
+        token = token.split(" ")[1];//以空格划分Bearer token,获取token
+        //从请求头中获取token
+        DecodedJWT verify = JWTUtil.verify(token);
+        String identifier = verify.getClaim("identifier").asString();
+        UserEntry userEntry = this.userService.findByIdentifier(identifier);
         if (questionEntity.getLabel().equals("5") && questionEntity.getId().equals("3")){
-            String token = request.getHeader("Authorization");
-            token = token.split(" ")[1];//以空格划分Bearer token,获取token
-            //从请求头中获取token
-            DecodedJWT verify = JWTUtil.verify(token);
-            String identifier = verify.getClaim("identifier").asString();
-            UserEntry userEntry = this.userService.findByIdentifier(identifier);
             questionEntity.setQuestion(userEntry.getUserName()+questionEntity.getQuestion());
         }
-        if (!questionEntity.getLabel().equals("5") && questionEntity.getId().equals("1")){
-            String token = request.getHeader("Authorization");
-            token = token.split(" ")[1];//以空格划分Bearer token,获取token
-            //从请求头中获取token
-            DecodedJWT verify = JWTUtil.verify(token);
-            String identifier = verify.getClaim("identifier").asString();
-            UserEntry userEntry = this.userService.findByIdentifier(identifier);
-            questionEntity.setQuestion(userEntry.getUserName()+questionEntity.getQuestion());
+        //情绪打分跳转
+        if (label.equals("2")){
+            if (num.equals("1")){
+                if (id.equals("41")){
+                    questionEntity = emotionScoreSkip(identifier,label,num,"40");
+                }
+                if (id.equals("83")){
+                    questionEntity = emotionScoreSkip(identifier,label,num,"82");
+                }
+                if (id.equals("121")){
+                    questionEntity = emotionScoreSkip(identifier,label,num,"120");
+                }
+                if (id.equals("169")){
+                    questionEntity = emotionScoreSkip(identifier,label,num,"168");
+                }
+                if (id.equals("210")){
+                    questionEntity = emotionScoreSkip(identifier,label,num,"209");
+                }
+                if (id.equals("249")){
+                    questionEntity = emotionScoreSkip(identifier,label,num,"246");
+                }
+                if (id.equals("288")){
+                    questionEntity = emotionScoreSkip(identifier,label,num,"285");
+                }
+                if (id.equals("336")){
+                    questionEntity = emotionScoreSkip(identifier,label,num,"333");
+                }
+                if (id.equals("377")){
+                    questionEntity = emotionScoreSkip(identifier,label,num,"374");
+                }
+                if (id.equals("414")){
+                    questionEntity = emotionScoreSkip(identifier,label,num,"411");
+                }
+            }
+            if (num.equals("2") || num.equals("3") || num.equals("4") || num.equals("5")){
+                if (id.equals("57")){
+                    questionEntity = emotionScoreSkip(identifier,label,num,"56");
+                }
+                if (id.equals("99")){
+                    questionEntity = emotionScoreSkip(identifier,label,num,"98");
+                }
+                if (id.equals("137")){
+                    questionEntity = emotionScoreSkip(identifier,label,num,"136");
+                }
+                if (id.equals("185")){
+                    questionEntity = emotionScoreSkip(identifier,label,num,"184");
+                }
+                if (id.equals("226")){
+                    questionEntity = emotionScoreSkip(identifier,label,num,"225");
+                }
+                if (id.equals("265")){
+                    questionEntity = emotionScoreSkip(identifier,label,num,"262");
+                }
+                if (id.equals("304")){
+                    questionEntity = emotionScoreSkip(identifier,label,num,"301");
+                }
+                if (id.equals("352")){
+                    questionEntity = emotionScoreSkip(identifier,label,num,"349");
+                }
+                if (id.equals("393")){
+                    questionEntity = emotionScoreSkip(identifier,label,num,"390");
+                }
+                if (id.equals("430")){
+                    questionEntity = emotionScoreSkip(identifier,label,num,"427");
+                }
+                //情绪二次打分跳转
+                if (id.equals("4")){
+                    String lastNum = String.valueOf(Integer.valueOf(num) - 1);
+                    int lastScore = Integer.valueOf(this.intelligentDialogueService.findLastScoreByIdentifierByLabelByNumByQuestionNo(identifier,label,lastNum,"4").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 (questionEntity.getQuestion().contains("userName")){
+            questionEntity.setQuestion(questionEntity.getQuestion().replace("userName",userEntry.getUserName()));
+        }
+        //替换使用时长
+        if (questionEntity.getQuestion().contains("utilityTime")){
+            IntelligentDialogueEntity intelligentDialogueEntity = this.intelligentDialogueService.findByIdentifierByLabelByNum(identifier,label,num);
+            Date beginTime = intelligentDialogueEntity.getCreateTime();
+            //当前时间
+            Date endTime = new Date();
+            //计算时间差
+            int diff = DateUtil.getDistanceByUnit(beginTime, endTime, 2);
+            if (diff <= 60){
+                questionEntity.setQuestion(questionEntity.getQuestion().replace("utilityTime",diff+"分钟"));
+            }else {
+                int MINUTE = diff%60;
+                int HOUR = diff/60;
+                if (HOUR <= 24){
+                    questionEntity.setQuestion(questionEntity.getQuestion().replace("utilityTime",HOUR + "小时" + MINUTE + "分钟"));
+                }else {
+                    int DAY = HOUR/24;
+                    HOUR = HOUR%24;
+                    questionEntity.setQuestion(questionEntity.getQuestion().replace("utilityTime",DAY + "天" + HOUR + "小时" + MINUTE + "分钟"));
+                }
+            }
+        }
+        //替换天数问候
+        if (questionEntity.getQuestion().contains("days")){
+            String lastNum = String.valueOf(Integer.valueOf(num) - 1);
+            IntelligentDialogueEntity intelligentDialogueEntity = this.intelligentDialogueService.findDateByIdentifierByLabelByNum(identifier,label,lastNum);
+            Date beginTime = intelligentDialogueEntity.getCreateTime();
+            //当前时间
+            Date endTime = new Date();
+            //计算时间差
+            int diff = DateUtil.getDistanceByUnit(beginTime, endTime, 4);
+            questionEntity.setQuestion(questionEntity.getQuestion().replace("days",String.valueOf(diff)));
+        }
+        //替换评测结果
+        if (questionEntity.getQuestion().contains("SDSEvaluationResult")){
+            IntelligentDialogueEntity intelligentDialogueEntity = this.intelligentDialogueService.findByIdentifierByLabelByNumByQuestionNo(identifier,label,num,"1");
+            questionEntity.setQuestion(questionEntity.getQuestion().replace("SDSEvaluationResult",intelligentDialogueEntity.getContent()));
         }
+        //替换治疗成绩
+        if (questionEntity.getQuestion().contains("therapeuticAchievement")){
+            List<IntelligentDialogueEntity> intelligentDialogueEntityList = this.intelligentDialogueService.findGradeByIdentifierByLabelByNumByQuestionNo(identifier,label,num,"2");
+            int therapeuticAchievement = Integer.valueOf(intelligentDialogueEntityList.get(1).getContent()) - Integer.valueOf(intelligentDialogueEntityList.get(0).getContent());
+            questionEntity.setQuestion(questionEntity.getQuestion().replace("therapeuticAchievement",String.valueOf(therapeuticAchievement)));
+        }
+        //替换上次训练内容
+        if (questionEntity.getQuestion().contains("LastTrainingContent")){
+            String lastNum = String.valueOf(Integer.valueOf(num) - 1);
+            IntelligentDialogueEntity intelligentDialogueEntity = this.intelligentDialogueService.findJobByIdentifierByLabelByNumByQuestionNo(identifier,label,lastNum,"3");
+            questionEntity.setQuestion(questionEntity.getQuestion().replace("LastTrainingContent",intelligentDialogueEntity.getContent()));
+        }
+
         return success(questionEntity);
     }
 
@@ -118,7 +269,8 @@ public class ChatController extends BaseController {
                 ChatQuestionEntity chatQuestionEntity = new ChatQuestionEntity();
                 chatQuestionEntity.setId((String) item.get(0));
                 chatQuestionEntity.setQuestion((String) item.get(1));
-                chatQuestionEntity.setNextQuestionNo((String) item.get(2));
+                String nextQuestionNo = String.valueOf(item.get(2)).replace("aaa","");
+                chatQuestionEntity.setNextQuestionNo(nextQuestionNo);
                 String questionType = (String) item.get(3);
                 if (questionType.equals("单选")) {
                     chatQuestionEntity.setQuestionType("0");
@@ -149,11 +301,11 @@ public class ChatController extends BaseController {
         }
 
         if (chatQuestionEntityList.size() > 0 && chatAnswerEntityList.size() > 0) {
-            this.questionService.deleteByLabel(label);
-            this.answerService.deleteByLabel(label);
+            //this.questionService.deleteByLabel(label);
+            //this.answerService.deleteByLabel(label);
 
-            this.questionService.saveBatch(chatQuestionEntityList);
-            this.answerService.saveBatch(chatAnswerEntityList);
+            /*this.questionService.saveBatch(chatQuestionEntityList);
+            this.answerService.saveBatch(chatAnswerEntityList);*/
         }
 
 
@@ -162,7 +314,7 @@ public class ChatController extends BaseController {
     }
 
     @GetMapping("/getAnswer/{questionNo}/{label}/{num}")
-    @ApiOperation("查询答案列表,questionNo为问题的id字段,nextQuestionNo 为此答案被选中后的下一个应该呈现的问题")
+    @ApiOperation("查询答案信息列表,questionNo为问题的id字段,nextQuestionNo 为此答案被选中后的下一个应该呈现的问题")
     public Result getAnswer(@PathVariable String questionNo, @PathVariable String label, @PathVariable String num) {
         List<ChatAnswerEntity> answerEntities = this.answerService.findByQuestionNoAndLabelAndNum(questionNo, label, num);
         return success(answerEntities);
@@ -170,9 +322,10 @@ public class ChatController extends BaseController {
 
     @GetMapping("/getNextQuestionByScaleResult")
     @ApiOperation("根据量表测试结果查询下一问题编号")
-    public Result getNextQuestionByScaleResult(String label, String result) {
+    public Result getNextQuestionByScaleResult(String label, String result, String num) {
 
-        ResultQuestionEntity resultQuestionEntity = this.resultQuestionService.findByLabelAndResult(label, result);
+        ResultQuestionEntity resultQuestionEntity = this.resultQuestionService.findByLabelAndResultAndNum(label, result, num);
+        //ResultQuestionEntity resultQuestionEntity = this.resultQuestionService.findByLabelAndNum(label, num);
         if (resultQuestionEntity == null) {
             return fail(ErrorCode.NEXT_QUESTION_NO_NOT_FOUND);
         }
@@ -519,4 +672,386 @@ public class ChatController extends BaseController {
         }
     }
 
+    private ChatQuestionEntity emotionScoreSkip(String identifier, String label, String num, String questionNo) {
+        int a = emotionScore(identifier,label,num,questionNo);
+        ChatQuestionEntity questionEntity = new ChatQuestionEntity();
+        if (label.equals("2")){
+            if (num.equals("1")){
+                if (questionNo.equals("40")){
+                    switch (a) {
+                        case 1:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("41", label, num);
+                            break;
+                        case 2:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("43", label, num);
+                            break;
+                        case 3:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("45", label, num);
+                            break;
+                        case 4:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("47", label, num);
+                            break;
+                        default:
+                            break;
+                    }
+                }
+                if (questionNo.equals("82")){
+                    switch (a) {
+                        case 1:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("83", label, num);
+                            break;
+                        case 2:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("85", label, num);
+                            break;
+                        case 3:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("87", label, num);
+                            break;
+                        case 4:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("89", label, num);
+                            break;
+                        default:
+                            break;
+                    }
+                }
+                if (questionNo.equals("120")){
+                    switch (a) {
+                        case 1:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("121", label, num);
+                            break;
+                        case 2:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("123", label, num);
+                            break;
+                        case 3:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("125", label, num);
+                            break;
+                        case 4:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("157", label, num);
+                            break;
+                        default:
+                            break;
+                    }
+                }
+                if (questionNo.equals("168")){
+                    switch (a) {
+                        case 1:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("169", label, num);
+                            break;
+                        case 2:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("171", label, num);
+                            break;
+                        case 3:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("173", label, num);
+                            break;
+                        case 4:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("175", label, num);
+                            break;
+                        default:
+                            break;
+                    }
+                }
+                if (questionNo.equals("209")){
+                    switch (a) {
+                        case 1:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("210", label, num);
+                            break;
+                        case 2:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("212", label, num);
+                            break;
+                        case 3:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("214", label, num);
+                            break;
+                        case 4:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("216", label, num);
+                            break;
+                        default:
+                            break;
+                    }
+                }
+                if (questionNo.equals("246")){
+                    switch (a) {
+                        case 1:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("249", label, num);
+                            break;
+                        case 2:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("251", label, num);
+                            break;
+                        case 3:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("253", label, num);
+                            break;
+                        case 4:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("255", label, num);
+                            break;
+                        default:
+                            break;
+                    }
+                }
+                if (questionNo.equals("285")){
+                    switch (a) {
+                        case 1:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("288", label, num);
+                            break;
+                        case 2:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("290", label, num);
+                            break;
+                        case 3:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("292", label, num);
+                            break;
+                        case 4:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("294", label, num);
+                            break;
+                        default:
+                            break;
+                    }
+                }
+                if (questionNo.equals("333")){
+                    switch (a) {
+                        case 1:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("336", label, num);
+                            break;
+                        case 2:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("338", label, num);
+                            break;
+                        case 3:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("340", label, num);
+                            break;
+                        case 4:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("342", label, num);
+                            break;
+                        default:
+                            break;
+                    }
+                }
+                if (questionNo.equals("374")){
+                    switch (a) {
+                        case 1:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("377", label, num);
+                            break;
+                        case 2:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("379", label, num);
+                            break;
+                        case 3:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("381", label, num);
+                            break;
+                        case 4:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("383", label, num);
+                            break;
+                        default:
+                            break;
+                    }
+                }
+                if (questionNo.equals("411")){
+                    switch (a) {
+                        case 1:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("414", label, num);
+                            break;
+                        case 2:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("416", label, num);
+                            break;
+                        case 3:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("418", label, num);
+                            break;
+                        case 4:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("420", label, num);
+                            break;
+                        default:
+                            break;
+                    }
+                }
+            }
+        }
+        if (label.equals("2")) {
+            if (num.equals("2") || num.equals("3") || num.equals("4") || num.equals("5")){
+                if (questionNo.equals("56")) {
+                    switch (a) {
+                        case 1:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("57", label, num);
+                            break;
+                        case 2:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("59", label, num);
+                            break;
+                        case 3:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("61", label, num);
+                            break;
+                        case 4:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("63", label, num);
+                            break;
+                        default:
+                            break;
+                    }
+                }
+                if (questionNo.equals("98")) {
+                    switch (a) {
+                        case 1:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("99", label, num);
+                            break;
+                        case 2:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("101", label, num);
+                            break;
+                        case 3:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("103", label, num);
+                            break;
+                        case 4:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("105", label, num);
+                            break;
+                        default:
+                            break;
+                    }
+                }if (questionNo.equals("136")) {
+                    switch (a) {
+                        case 1:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("137", label, num);
+                            break;
+                        case 2:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("139", label, num);
+                            break;
+                        case 3:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("141", label, num);
+                            break;
+                        case 4:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("143", label, num);
+                            break;
+                        default:
+                            break;
+                    }
+                }if (questionNo.equals("184")) {
+                    switch (a) {
+                        case 1:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("185", label, num);
+                            break;
+                        case 2:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("187", label, num);
+                            break;
+                        case 3:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("189", label, num);
+                            break;
+                        case 4:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("191", label, num);
+                            break;
+                        default:
+                            break;
+                    }
+                }if (questionNo.equals("225")) {
+                    switch (a) {
+                        case 1:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("226", label, num);
+                            break;
+                        case 2:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("228", label, num);
+                            break;
+                        case 3:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("230", label, num);
+                            break;
+                        case 4:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("232", label, num);
+                            break;
+                        default:
+                            break;
+                    }
+                }if (questionNo.equals("262")) {
+                    switch (a) {
+                        case 1:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("265", label, num);
+                            break;
+                        case 2:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("267", label, num);
+                            break;
+                        case 3:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("269", label, num);
+                            break;
+                        case 4:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("271", label, num);
+                            break;
+                        default:
+                            break;
+                    }
+                }if (questionNo.equals("301")) {
+                    switch (a) {
+                        case 1:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("304", label, num);
+                            break;
+                        case 2:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("306", label, num);
+                            break;
+                        case 3:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("308", label, num);
+                            break;
+                        case 4:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("310", label, num);
+                            break;
+                        default:
+                            break;
+                    }
+                }if (questionNo.equals("349")) {
+                    switch (a) {
+                        case 1:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("352", label, num);
+                            break;
+                        case 2:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("354", label, num);
+                            break;
+                        case 3:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("356", label, num);
+                            break;
+                        case 4:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("358", label, num);
+                            break;
+                        default:
+                            break;
+                    }
+                }if (questionNo.equals("390")) {
+                    switch (a) {
+                        case 1:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("393", label, num);
+                            break;
+                        case 2:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("395", label, num);
+                            break;
+                        case 3:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("397", label, num);
+                            break;
+                        case 4:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("399", label, num);
+                            break;
+                        default:
+                            break;
+                    }
+                }if (questionNo.equals("427")) {
+                    switch (a) {
+                        case 1:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("430", label, num);
+                            break;
+                        case 2:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("432", label, num);
+                            break;
+                        case 3:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("434", label, num);
+                            break;
+                        case 4:
+                            questionEntity = this.questionService.findByIdAndLabelAndNum("436", label, num);
+                            break;
+                        default:
+                            break;
+                    }
+                }
+            }
+        }
+
+        return questionEntity;
+    }
+
+    private int emotionScore(String identifier, String label, String num, String questionNo) {
+        IntelligentDialogueEntity intelligentDialogueEntity = this.intelligentDialogueService.findEmotionScoreByIdentifierByLabelByNumByQuestionNo(identifier,label,num,questionNo);
+        int emotionScore = Integer.valueOf(intelligentDialogueEntity.getContent());
+        if (emotionScore <= 25){
+            emotionScore = 1;
+        }else if (emotionScore <= 50 && emotionScore >= 26){
+            emotionScore = 2;
+        }else if (emotionScore <= 75 && emotionScore >= 51){
+            emotionScore = 3;
+        }else {
+            emotionScore = 4;
+        }
+        return emotionScore;
+    }
+
 }

+ 3 - 1
src/main/java/com/rf/kjb/chat/service/ResultQuestionService.java

@@ -4,5 +4,7 @@ package com.rf.kjb.chat.service;
 import com.rf.kjb.chat.dao.domain.ResultQuestionEntity;
 
 public interface ResultQuestionService {
-    ResultQuestionEntity findByLabelAndResult(String label, String result);
+    ResultQuestionEntity findByLabelAndResultAndNum(String label, String result, String num);
+
+    ResultQuestionEntity findByLabelAndNum(String label, String num);
 }

+ 7 - 2
src/main/java/com/rf/kjb/chat/service/impl/ResultQuestionServiceImpl.java

@@ -16,7 +16,12 @@ public class ResultQuestionServiceImpl implements ResultQuestionService {
     @Autowired
     private ResultQuestionRepository repository;
     @Override
-    public ResultQuestionEntity findByLabelAndResult(String label, String result) {
-        return repository.findByLabelAndResult(label,result);
+    public ResultQuestionEntity findByLabelAndResultAndNum(String label, String result, String num) {
+        return repository.findByLabelAndResultAndNum(label,result, num);
+    }
+
+    @Override
+    public ResultQuestionEntity findByLabelAndNum(String label, String num) {
+        return repository.findByLabelAndNum(label, num);
     }
 }

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

@@ -33,4 +33,35 @@ public interface IntelligentDialogueRepository extends BaseRepository<Intelligen
     @Query(value = "SELECT * FROM t_intelligent_dialogue WHERE type = :type and identifier = :identifier ORDER BY create_time DESC,id DESC  ",
             countQuery = "SELECT * FROM t_intelligent_dialogue WHERE type = :type and identifier = :identifier ", nativeQuery = true)
     Page<IntelligentDialogueEntity> getIntelligentDialogueEntityByIdentifier(Pageable pageable, @Param("identifier") String identifier, @Param("type") String type);
+
+    @Query(value = "SELECT * FROM t_intelligent_dialogue WHERE identifier = :identifier AND type = :label AND num = :num AND question_no = '1' AND label = '0' ORDER BY create_time DESC LIMIT 1 ", nativeQuery = true)
+    IntelligentDialogueEntity findByIdentifierByLabelByNum(@Param("identifier") String identifier,@Param("label") String label,@Param("num") String num);
+
+    @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 " +
+            ") AND label = '0' ORDER BY create_time DESC LIMIT 1 ", nativeQuery = true)
+    IntelligentDialogueEntity findByIdentifierByLabelByNumByQuestionNo(@Param("identifier") String identifier,@Param("label") String label,@Param("num") String num,@Param("type") String type);
+    @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 " +
+            ") AND label = '0' ORDER BY create_time DESC LIMIT 1 ", nativeQuery = true)
+    IntelligentDialogueEntity findJobByIdentifierByLabelByNumByQuestionNo(@Param("identifier") String identifier,@Param("label") String label,@Param("num") String num,@Param("type") String type);
+
+    @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 " +
+            ") AND label = '1' ORDER BY create_time DESC LIMIT 2 ", nativeQuery = true)
+    List<IntelligentDialogueEntity> findGradeByIdentifierByLabelByNumByQuestionNo(@Param("identifier") String identifier,@Param("label") String label,@Param("num") String num,@Param("type") String type);
+
+    @Query(value = "SELECT * FROM t_intelligent_dialogue WHERE identifier = :identifier AND type = :label AND num = :num AND question_no = :questionNo AND label = '1' ORDER BY create_time DESC LIMIT 1 ", nativeQuery = true)
+    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(" +
+            "SELECT 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)
+    IntelligentDialogueEntity findLastScoreByIdentifierByLabelByNumByQuestionNo(@Param("identifier") String identifier,@Param("label") String label,@Param("num") String num,@Param("type") String type);
+
+    @Query(value = "SELECT * FROM t_intelligent_dialogue WHERE identifier = :identifier AND type = :label AND num = :num AND question_no = '3' AND label = '1' ORDER BY create_time DESC LIMIT 1 ", nativeQuery = true)
+    IntelligentDialogueEntity findScoreByIdentifierByLabelByNumByQuestionNo(@Param("identifier") String identifier,@Param("label") String label,@Param("num") String num);
+
+    @Query(value = "SELECT * FROM t_intelligent_dialogue WHERE identifier = :identifier AND type = :label AND num = :num ORDER BY create_time DESC LIMIT 1 ", nativeQuery = true)
+    IntelligentDialogueEntity findDateByIdentifierByLabelByNum(@Param("identifier") String identifier,@Param("label") String label,@Param("num") String lastNum);
 }

+ 16 - 0
src/main/java/com/rf/kjb/intelligentDialogue/service/IntelligentDialogueService.java

@@ -1,5 +1,6 @@
 package com.rf.kjb.intelligentDialogue.service;
 
+import com.rf.kjb.chat.dao.domain.ChatQuestionEntity;
 import com.rf.kjb.intelligentDialogue.dao.domain.IntelligentDialogueEntity;
 import org.springframework.data.domain.Page;
 
@@ -15,4 +16,19 @@ public interface IntelligentDialogueService {
     List<IntelligentDialogueEntity> findAllIdentifier();
 
     Page<IntelligentDialogueEntity> getIntelligentDialogueEntityByIdentifier(String identifier, int pageNum, int pageSize, String type);
+
+    IntelligentDialogueEntity findByIdentifierByLabelByNum(String identifier, String label, String num);
+
+    IntelligentDialogueEntity findByIdentifierByLabelByNumByQuestionNo(String identifier, String label, String num, String type);
+    IntelligentDialogueEntity findJobByIdentifierByLabelByNumByQuestionNo(String identifier, String label, String num, String type);
+
+    List<IntelligentDialogueEntity> findGradeByIdentifierByLabelByNumByQuestionNo(String identifier, String label, String num, String type);
+
+    IntelligentDialogueEntity findEmotionScoreByIdentifierByLabelByNumByQuestionNo(String identifier, String label, String num, String questionNo);
+
+    IntelligentDialogueEntity findLastScoreByIdentifierByLabelByNumByQuestionNo(String identifier, String label, String lastNum, String type);
+
+    IntelligentDialogueEntity findScoreByIdentifierByLabelByNumByQuestionNo(String identifier, String label, String num);
+
+    IntelligentDialogueEntity findDateByIdentifierByLabelByNum(String identifier, String label, String lastNum);
 }

+ 40 - 0
src/main/java/com/rf/kjb/intelligentDialogue/service/impl/IntelligentDialogueServiceImpl.java

@@ -1,5 +1,6 @@
 package com.rf.kjb.intelligentDialogue.service.impl;
 
+import com.rf.kjb.chat.dao.domain.ChatQuestionEntity;
 import com.rf.kjb.intelligentDialogue.dao.domain.IntelligentDialogueEntity;
 import com.rf.kjb.intelligentDialogue.dao.repository.IntelligentDialogueRepository;
 import com.rf.kjb.intelligentDialogue.service.IntelligentDialogueService;
@@ -70,4 +71,43 @@ public class IntelligentDialogueServiceImpl implements IntelligentDialogueServic
     public Page<IntelligentDialogueEntity> getIntelligentDialogueEntityByIdentifier(String identifier, int pageNum, int pageSize, String type) {
         return this.repository.getIntelligentDialogueEntityByIdentifier(PageRequest.of(pageNum - 1, pageSize), identifier, type);
     }
+
+    @Override
+    public IntelligentDialogueEntity findByIdentifierByLabelByNum(String identifier, String label, String num) {
+        return this.repository.findByIdentifierByLabelByNum(identifier,label,num);
+    }
+
+    @Override
+    public IntelligentDialogueEntity findByIdentifierByLabelByNumByQuestionNo(String identifier, String label, String num, String type) {
+        return this.repository.findByIdentifierByLabelByNumByQuestionNo(identifier,label,num,type);
+    }
+    @Override
+    public IntelligentDialogueEntity findJobByIdentifierByLabelByNumByQuestionNo(String identifier, String label, String num, String type) {
+        return this.repository.findJobByIdentifierByLabelByNumByQuestionNo(identifier,label,num,type);
+    }
+
+    @Override
+    public List<IntelligentDialogueEntity> findGradeByIdentifierByLabelByNumByQuestionNo(String identifier, String label, String num, String type) {
+        return this.repository.findGradeByIdentifierByLabelByNumByQuestionNo(identifier,label,num,type);
+    }
+
+    @Override
+    public IntelligentDialogueEntity findEmotionScoreByIdentifierByLabelByNumByQuestionNo(String identifier, String label, String num, String questionNo) {
+        return this.repository.findEmotionScoreByIdentifierByLabelByNumByQuestionNo(identifier,label,num,questionNo);
+    }
+
+    @Override
+    public IntelligentDialogueEntity findLastScoreByIdentifierByLabelByNumByQuestionNo(String identifier, String label, String lastNum, String type) {
+        return this.repository.findLastScoreByIdentifierByLabelByNumByQuestionNo(identifier,label,lastNum,type);
+    }
+
+    @Override
+    public IntelligentDialogueEntity findScoreByIdentifierByLabelByNumByQuestionNo(String identifier, String label, String num) {
+        return this.repository.findScoreByIdentifierByLabelByNumByQuestionNo(identifier,label,num);
+    }
+
+    @Override
+    public IntelligentDialogueEntity findDateByIdentifierByLabelByNum(String identifier, String label, String lastNum) {
+        return this.repository.findDateByIdentifierByLabelByNum(identifier,label,lastNum);
+    }
 }