外呼回调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 content;
}

View File

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