外呼回调bug修改

This commit is contained in:
zhuangyuanke 2024-12-17 18:21:28 +08:00
parent e34168bb7c
commit 5ad8001621
2 changed files with 23 additions and 5 deletions

View File

@ -31,4 +31,9 @@ public class AiobRecord {
* 意图 * 意图
*/ */
private String intent; private String intent;
/**
* 回答内容文本
*/
private String content;
} }

View File

@ -351,7 +351,8 @@ public class AIOBServiceImpl implements IAIOBService {
PhoneDialRecord phoneDialRecordQuery = new PhoneDialRecord(); PhoneDialRecord phoneDialRecordQuery = new PhoneDialRecord();
phoneDialRecordQuery.setManageRouteNodeId(signPatientManageRouteNode.getId()); phoneDialRecordQuery.setManageRouteNodeId(signPatientManageRouteNode.getId());
List<PhoneDialRecord> phoneDialRecordList = phoneDialRecordMapper.selectPhoneDialRecordList(phoneDialRecordQuery); List<PhoneDialRecord> phoneDialRecordList = phoneDialRecordMapper.selectPhoneDialRecordList(phoneDialRecordQuery);
if ((CollectionUtils.isEmpty(phoneDialRecordList) && PhoneRedialTimesEnum.getValueByInfo(signPatientManageRouteNode.getPhoneRedialTimes()).getValue() > 0) || phoneDialRecordList.size() + 1 < PhoneRedialTimesEnum.getValueByInfo(signPatientManageRouteNode.getPhoneRedialTimes()).getValue()) { String redialTimes = StringUtils.isEmpty(signPatientManageRouteNode.getPhoneRedialTimes())?"NOT_REPLAY":signPatientManageRouteNode.getPhoneRedialTimes();
if ((CollectionUtils.isEmpty(phoneDialRecordList) && PhoneRedialTimesEnum.getValueByInfo(redialTimes).getValue() > 0) || phoneDialRecordList.size() + 1 < PhoneRedialTimesEnum.getValueByInfo(signPatientManageRouteNode.getPhoneRedialTimes()).getValue()) {
// 重拨 // 重拨
needRedial = true; needRedial = true;
} }
@ -550,6 +551,9 @@ public class AIOBServiceImpl implements IAIOBService {
.stream() .stream()
.sorted(Comparator.comparing(AiobRecord::getTimestamp)) .sorted(Comparator.comparing(AiobRecord::getTimestamp))
.collect(Collectors.toList()); .collect(Collectors.toList());
speechList.forEach(s->{
if(StringUtils.isNull(s.getIntent())) s.setIntent("");
});
// 查询患者画像信息 // 查询患者画像信息
List<LabelFieldInfoContentVo> labelFieldContentList = labelFieldContentMapper.selectByPatientId(patientInfoId); List<LabelFieldInfoContentVo> labelFieldContentList = labelFieldContentMapper.selectByPatientId(patientInfoId);
@ -598,11 +602,17 @@ public class AIOBServiceImpl implements IAIOBService {
} }
} }
if (hasQuestion) { if (hasQuestion) {
String finalAiobQuestionName = aiobQuestionName;
AiobRecord nextRecord = getNextQuestion(speechList, finalAiobQuestionName);
PatientQuestionSubjectResult patientQuestionSubjectResult = new PatientQuestionSubjectResult(); PatientQuestionSubjectResult patientQuestionSubjectResult = new PatientQuestionSubjectResult();
BeanUtils.copyProperties(questionSubjectVO, patientQuestionSubjectResult); BeanUtils.copyProperties(questionSubjectVO, patientQuestionSubjectResult);
patientQuestionSubjectResult.setId(null); patientQuestionSubjectResult.setId(null);
patientQuestionSubjectResult.setQuestionSubmitResultId(patientQuestionSubmitResult.getId()); patientQuestionSubjectResult.setQuestionSubmitResultId(patientQuestionSubmitResult.getId());
patientQuestionSubjectResult.setCreateTime(LocalDateTime.now()); patientQuestionSubjectResult.setCreateTime(LocalDateTime.now());
//不管是否是 填空题 写入回答 文本
patientQuestionSubjectResult.setFillBlanksAnswer(nextRecord.getContent());
patientQuestionSubjectResultMapper.insertPatientQuestionSubjectResult(patientQuestionSubjectResult); patientQuestionSubjectResultMapper.insertPatientQuestionSubjectResult(patientQuestionSubjectResult);
// 3保存patient_question_option_result // 3保存patient_question_option_result
@ -610,13 +620,12 @@ public class AIOBServiceImpl implements IAIOBService {
questionSubjectOptionQuery.setQuestionnaireSubjectId(questionSubjectVO.getId()); questionSubjectOptionQuery.setQuestionnaireSubjectId(questionSubjectVO.getId());
List<QuestionSubjectOption> questionSubjectOptions = questionSubjectOptionMapper.selectQuestionSubjectOptionList(questionSubjectOptionQuery); List<QuestionSubjectOption> questionSubjectOptions = questionSubjectOptionMapper.selectQuestionSubjectOptionList(questionSubjectOptionQuery);
List<PatientQuestionOptionResult> patientQuestionOptionResults = new ArrayList<>(); List<PatientQuestionOptionResult> patientQuestionOptionResults = new ArrayList<>();
String finalAiobQuestionName = aiobQuestionName;
questionSubjectOptions.forEach(questionSubjectOption -> { questionSubjectOptions.forEach(questionSubjectOption -> {
PatientQuestionOptionResult patientQuestionOptionResult = new PatientQuestionOptionResult(); PatientQuestionOptionResult patientQuestionOptionResult = new PatientQuestionOptionResult();
BeanUtils.copyProperties(questionSubjectOption, patientQuestionOptionResult); BeanUtils.copyProperties(questionSubjectOption, patientQuestionOptionResult);
// 设置是否选中, 通过通话记录中下一个问题的intent字段查询QuestionSubjectOption // 设置是否选中, 通过通话记录中下一个问题的intent字段查询QuestionSubjectOption
List<String> intents = Arrays.asList(questionSubjectOption.getIntent().split("\\|")); List<String> intents = Arrays.asList(questionSubjectOption.getIntent().split("\\|"));
AiobRecord nextRecord = getNextQuestion(speechList, finalAiobQuestionName);
if (ObjectUtils.isNotEmpty(nextRecord) && intents.contains(nextRecord.getIntent())) { if (ObjectUtils.isNotEmpty(nextRecord) && intents.contains(nextRecord.getIntent())) {
patientQuestionOptionResult.setOptionChooseSign(0); patientQuestionOptionResult.setOptionChooseSign(0);
} else { } else {
@ -641,7 +650,9 @@ public class AIOBServiceImpl implements IAIOBService {
} }
} }
questionSubmitResultMapper.updatePatientQuestionSubmitResult(patientQuestionSubmitResult); questionSubmitResultMapper.updatePatientQuestionSubmitResult(patientQuestionSubmitResult);
patientQuestionOptionResultMapper.saveQuestionOptionList(patientQuestionOptionResults); if(patientQuestionOptionResults.size()>0) {
patientQuestionOptionResultMapper.saveQuestionOptionList(patientQuestionOptionResults);
}
totalScore[0] = totalScore[0].add(questionSubjectVO.getQuestionScore() == null ? BigDecimal.ZERO : questionSubjectVO.getQuestionScore()); totalScore[0] = totalScore[0].add(questionSubjectVO.getQuestionScore() == null ? BigDecimal.ZERO : questionSubjectVO.getQuestionScore());
} else { } else {
// 没问到问卷中的问题则保存空问题+空选项 // 没问到问卷中的问题则保存空问题+空选项
@ -667,7 +678,9 @@ public class AIOBServiceImpl implements IAIOBService {
patientQuestionOptionResult.setQuestionSubjectResultId(patientQuestionSubjectResult.getId()); patientQuestionOptionResult.setQuestionSubjectResultId(patientQuestionSubjectResult.getId());
patientQuestionOptionResults.add(patientQuestionOptionResult); patientQuestionOptionResults.add(patientQuestionOptionResult);
}); });
patientQuestionOptionResultMapper.saveQuestionOptionList(patientQuestionOptionResults); if(patientQuestionOptionResults.size()>0) {
patientQuestionOptionResultMapper.saveQuestionOptionList(patientQuestionOptionResults);
}
totalScore[0] = totalScore[0].add(BigDecimal.ZERO); totalScore[0] = totalScore[0].add(BigDecimal.ZERO);
} }
}); });