diff --git a/postdischarge-admin/src/main/resources/application-dev.yml b/postdischarge-admin/src/main/resources/application-dev.yml index e636aadf..e00ff645 100644 --- a/postdischarge-admin/src/main/resources/application-dev.yml +++ b/postdischarge-admin/src/main/resources/application-dev.yml @@ -7,7 +7,7 @@ spring: # 主库数据源 master: # url: jdbc:mysql://192.168.16.64:3306/post-discharge?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true - url: jdbc:mysql://8.131.93.145:54081/post-discharge?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true + url: jdbc:mysql://8.131.93.145:54081/post-discharge-0331?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true # url: jdbc:mysql://182.92.166.109:8000/post-discharge?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true username: root password: 1qaz!@#$ diff --git a/postdischarge-admin/src/main/resources/application.yml b/postdischarge-admin/src/main/resources/application.yml index 9f79c399..881442f9 100644 --- a/postdischarge-admin/src/main/resources/application.yml +++ b/postdischarge-admin/src/main/resources/application.yml @@ -110,7 +110,7 @@ token: # 令牌有效期(默认30分钟) expireTime: 120 # 请求拦截白名单 - ant-matchers: /postDischarge/**,/testMobile/**,/postDischargeApplet/**,/api/**,/manage/patientInfoimporttemp/** + ant-matchers: /postDischarge/**,/testMobile/**,/postDischargeApplet/**,/api/**,/manage/patientInfoimporttemp/**,/yzapi/** ## MyBatis-Plus配置 mybatis-plus: @@ -302,6 +302,7 @@ yzaiobs: # 请求地址 url: http://47.109.194.76:8094/AIOBS userId: 00447a7b-3174-4bc5-b917-8b72b29bc920 + roleId: 1001 routeNum: 1 callPhone: 1234 xinyilu-database: diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/controller/yaiobs/YZAIOBSController.java b/postdischarge-manage/src/main/java/com/xinelu/manage/controller/yaiobs/YZAIOBSController.java new file mode 100644 index 00000000..aef3722e --- /dev/null +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/controller/yaiobs/YZAIOBSController.java @@ -0,0 +1,41 @@ +package com.xinelu.manage.controller.yaiobs; + +import com.alibaba.fastjson2.JSONObject; +import com.aliyuncs.exceptions.ClientException; +import com.xinelu.manage.dto.aiob.DutyCallbackDto; +import com.xinelu.manage.service.yzaiobs.IYZAIOBSService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import javax.annotation.Resource; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @description: 曜智·智能外呼平台控制器 + * @author: haown + * @create: 2025-12-29 10:08 + **/ +@Api(tags = "曜智·智能外呼平台控制器") +@RestController +@RequestMapping("/yzapi") +public class YZAIOBSController { + + @Resource + private IYZAIOBSService iyzaiobsService; + + /** + * @description 任务回调 + * @param dutyCallbackDto: 回调数据 + * @return null + * @Author haown + * @Date 2024-8-29 11:15 + */ + @ApiOperation("任务回调") + @PostMapping("/taskCallBack") + public JSONObject taskCallBack(@RequestBody DutyCallbackDto dutyCallbackDto) throws ClientException { + + return iyzaiobsService.taskCallBack(dutyCallbackDto); + } +} diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/dto/aiob/CreateDutyDto.java b/postdischarge-manage/src/main/java/com/xinelu/manage/dto/aiob/CreateDutyDto.java index 069ea67f..b2124876 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/dto/aiob/CreateDutyDto.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/dto/aiob/CreateDutyDto.java @@ -1,7 +1,7 @@ package com.xinelu.manage.dto.aiob; import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson2.JSONObject; import lombok.Data; /** diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.java b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.java index 9d3ec3cc..fa749949 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.java @@ -101,7 +101,7 @@ public interface SignPatientManageRouteNodeMapper { int updateDialStatus(SignPatientManageRouteNode signPatientManageRouteNode); /** - * 修改 拔打状态 + * 修改 拔打状态、第三方返回的任务ID * @param signPatientManageRouteNode * @return */ diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/aiob/IAIOBService.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/aiob/IAIOBService.java index 16674167..511427f2 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/aiob/IAIOBService.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/aiob/IAIOBService.java @@ -10,6 +10,7 @@ import com.xinelu.manage.dto.aiob.CreateTaskDto; import com.xinelu.manage.dto.aiob.ImportTaskDto; import com.xinelu.manage.dto.aiob.TaskCallbackDataDto; import com.xinelu.manage.vo.aiob.ImportTaskVo; +import com.xinelu.manage.vo.labelfieldcontent.LabelFieldInfoContentVo; import java.util.List; /** @@ -98,4 +99,8 @@ public interface IAIOBService { void redialInfoSave(SignPatientManageRouteNode signPatientManageRouteNode, PatientVisitRecord patientVisitRecord); void parseQuestionInfo(JSONArray records, SignPatientManageRouteNode node, Long patientInfoId, Long taskExecuteRecordId); + + String replaceQuestionName(String questionNameAlias, List labelFieldContentList); + + String videoPath(String downloadPath, String ccUuid); } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/aiob/impl/AIOBServiceImpl.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/aiob/impl/AIOBServiceImpl.java index c7eac923..39f884c0 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/aiob/impl/AIOBServiceImpl.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/aiob/impl/AIOBServiceImpl.java @@ -762,7 +762,8 @@ public class AIOBServiceImpl implements IAIOBService { return null; } - private String replaceQuestionName(String questionNameAlias, List labelFieldContentList) { + @Override + public String replaceQuestionName(String questionNameAlias, List labelFieldContentList) { Pattern pattern = Pattern.compile("\\{%\\s*&[\\s\\S]*?\\s*%}"); Matcher matcher = pattern.matcher(questionNameAlias); while (matcher.find()) { @@ -808,12 +809,16 @@ public class AIOBServiceImpl implements IAIOBService { */ @Override public String getPhoneDialRecord(String ccUuid) { - String url = ""; String downLoadUrl = record(ccUuid); + return videoPath(downLoadUrl, ccUuid); + } + + @Override + public String videoPath(String downLoadUrl, String ccUuid) { if (StringUtils.isBlank(downLoadUrl)) { throw new ServiceException("暂未获取到录音,请稍后再试!"); } - url = systemBusinessConfig.getProfile() + systemBusinessConfig.getPhoneDialRecordVideo() + "/" + ccUuid + ".wav"; + String url = systemBusinessConfig.getProfile() + systemBusinessConfig.getPhoneDialRecordVideo() + "/" + ccUuid + ".wav"; File outputPath = new File(url); File dir = outputPath.getParentFile(); if (!dir.exists()){ diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/yzaiobs/IYZAIOBSService.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/yzaiobs/IYZAIOBSService.java index 015cc85c..776d49bf 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/yzaiobs/IYZAIOBSService.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/yzaiobs/IYZAIOBSService.java @@ -31,5 +31,12 @@ public interface IYZAIOBSService { */ JSONObject taskCallBack(DutyCallbackDto callbackDto) throws ClientException; - + /** + * @description 单通电话数据回传接口 + * @Param * @param null + * @return null + * @Author haown + * @Date 2025-12-26 15:59 + */ + JSONObject phoneCallBack(); } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/yzaiobs/impl/YZAIOBSServiceImpl.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/yzaiobs/impl/YZAIOBSServiceImpl.java index 893c45df..882c5b4f 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/yzaiobs/impl/YZAIOBSServiceImpl.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/yzaiobs/impl/YZAIOBSServiceImpl.java @@ -27,13 +27,20 @@ import com.xinelu.manage.domain.questionsubjectoption.QuestionSubjectOption; import com.xinelu.manage.domain.signpatientmanageroute.SignPatientManageRoute; import com.xinelu.manage.domain.signpatientmanageroutenode.SignPatientManageRouteNode; import com.xinelu.manage.domain.signpatientrecord.SignPatientRecord; -import com.xinelu.manage.dto.aiob.AiobRecord; import com.xinelu.manage.dto.aiob.CreateDutyDto; import com.xinelu.manage.dto.aiob.DutyCallbackDataDto; import com.xinelu.manage.dto.aiob.DutyCallbackDto; +import com.xinelu.manage.mapper.labelfieldcontent.LabelFieldContentMapper; +import com.xinelu.manage.mapper.patientinfo.PatientInfoMapper; +import com.xinelu.manage.mapper.patientquestionoptionresult.PatientQuestionOptionResultMapper; +import com.xinelu.manage.mapper.patientquestionsubjectresult.PatientQuestionSubjectResultMapper; +import com.xinelu.manage.mapper.patientquestionsubmitresult.PatientQuestionSubmitResultMapper; import com.xinelu.manage.mapper.patienttaskexecuterecord.PatientTaskExecuteRecordMapper; import com.xinelu.manage.mapper.patientvisitrecord.PatientVisitRecordMapper; import com.xinelu.manage.mapper.phonedialrecord.PhoneDialRecordMapper; +import com.xinelu.manage.mapper.questioninfo.QuestionInfoMapper; +import com.xinelu.manage.mapper.questionsubject.QuestionSubjectMapper; +import com.xinelu.manage.mapper.questionsubjectoption.QuestionSubjectOptionMapper; import com.xinelu.manage.mapper.scriptinfotaskinfo.ScriptInfoTaskInfoMapper; import com.xinelu.manage.mapper.signpatientmanageroute.SignPatientManageRouteMapper; import com.xinelu.manage.mapper.signpatientmanageroutenode.SignPatientManageRouteNodeMapper; @@ -43,23 +50,21 @@ import com.xinelu.manage.service.patienttaskstatistics.IPatientTaskStatisticsSer import com.xinelu.manage.service.yzaiobs.IYZAIOBSService; import com.xinelu.manage.vo.labelfieldcontent.LabelFieldInfoContentVo; import com.xinelu.manage.vo.questionsubject.QuestionSubjectVO; +import com.xinelu.manage.vo.yzaiobs.CallRecord; import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Arrays; -import java.util.Comparator; -import java.util.Iterator; import java.util.List; -import java.util.Map; import java.util.Objects; -import java.util.Set; import java.util.stream.Collectors; import javax.annotation.Resource; import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; -import org.springframework.http.HttpMethod; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -76,6 +81,8 @@ public class YZAIOBSServiceImpl implements IYZAIOBSService { private String url; @Value("${yzaiobs.userId}") private String userId; + @Value("${yzaiobs.roleId}") + private String roleId; @Value("${yzaiobs.routeNum}") private Integer routeNum; @Value("${yzaiobs.callPhone}") @@ -98,15 +105,52 @@ public class YZAIOBSServiceImpl implements IYZAIOBSService { private PatientTaskExecuteRecordMapper patientTaskExecuteRecordMapper; @Resource private IPatientTaskStatisticsService patientTaskStatisticsService; + @Resource + private PatientInfoMapper patientInfoMapper; + @Resource + private QuestionInfoMapper questionInfoMapper; + @Resource + private PatientQuestionSubmitResultMapper questionSubmitResultMapper; + @Resource + private QuestionSubjectMapper questionSubjectMapper; + @Resource + private PatientQuestionSubjectResultMapper patientQuestionSubjectResultMapper; + @Resource + private QuestionSubjectOptionMapper questionSubjectOptionMapper; + @Resource + private PatientQuestionOptionResultMapper patientQuestionOptionResultMapper; + @Resource + private LabelFieldContentMapper labelFieldContentMapper; @Override public JSONObject createDuty(CreateDutyDto createDutyDto) { createDutyDto.setUserId(userId); + createDutyDto.setRoleId(roleId); createDutyDto.setRouteNum(routeNum); createDutyDto.setCallPhone(callPhone); - HttpEntity requestEntity = new HttpEntity<>((JSONObject) JSON.toJSON(createDutyDto)); + // RestTemplate restTemplate = new RestTemplate(); - ResponseEntity responseEntity = restTemplate.exchange(url + "/createDuty", HttpMethod.POST, requestEntity, String.class); + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + String requestBody = JSON.toJSONString(createDutyDto); + HttpEntity requestEntity = new HttpEntity<>(requestBody, headers); + ResponseEntity responseEntity = restTemplate.postForEntity(url + "/duty/createDuty", requestEntity, String.class); JSONObject object = JSON.parseObject(responseEntity.getBody()); + + + /*try { + HttpPost httpPost = new HttpPost(url); + httpPost.setHeader("Content-Type", "application/json"); + httpPost.setEntity(new StringEntity(JSON.toJSONString(createDutyDto))); + CloseableHttpClient httpclient = HttpClients.createDefault(); + CloseableHttpResponse response = httpclient.execute(httpPost); + int status + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } catch (ClientProtocolException e) { + throw new RuntimeException(e); + } catch (IOException e) { + throw new RuntimeException(e); + }*/ /*{ "flag": true, "message": "任务名已存在!!!", @@ -133,22 +177,22 @@ public class YZAIOBSServiceImpl implements IYZAIOBSService { throw new ServiceException("创建任务失败," + object.getString("message")); } JSONObject data = object.getJSONObject("value"); - Set taskIds = data.keySet(); - Iterator iterator = taskIds.iterator(); - String taskId = iterator.next(); + //Set taskIds = data.keySet(); + //Iterator iterator = taskIds.iterator(); + //String taskId = iterator.next(); return data; } @Override public JSONObject taskCallBack(DutyCallbackDto callbackDto) throws ClientException { - // 根据第三方任务批次id查询任务列表 - String accountId = callbackDto.getAccountId(); // 从data中获取任务id JSONArray JSONArr = callbackDto.getData(); if (!CollectionUtils.isEmpty(JSONArr)) { for (int i = 0; i < JSONArr.size(); i++) { - JSONObject jsonObject = (JSONObject) JSONArr.get(i); + JSONObject jsonObject = JSONArr.getJSONObject(i); + System.out.println("数据回调-----------------------"); + System.out.println("数据" + i + ":"+jsonObject.toJSONString()); DutyCallbackDataDto dutyCallbackDataDto = JSON.parseObject(jsonObject.toJSONString(), DutyCallbackDataDto.class); - + System.out.println("数据转实体类" + i + ":" +dutyCallbackDataDto.toString()); // 是否发送短信标识 boolean needSendSms = false; // 是否重拨 @@ -258,7 +302,8 @@ public class YZAIOBSServiceImpl implements IYZAIOBSService { phoneDialRecord.setCreateTime(LocalDateTime.now()); phoneDialRecord.setCtUuid(dutyCallbackDataDto.getCallid()); - //phoneDialRecord.setPhoneDialRecordVideo(getPhoneDialRecord(data.getContactUUID())); + // 通话录音地址 + phoneDialRecord.setPhoneDialRecordVideo(iaiobService.videoPath(dutyCallbackDataDto.getMediaPath(), dutyCallbackDataDto.getCallid())); phoneDialRecordMapper.insertPhoneDialRecord(phoneDialRecord); @@ -272,7 +317,7 @@ public class YZAIOBSServiceImpl implements IYZAIOBSService { if (dutyCallbackDataDto.getIsAnswer() != null && dutyCallbackDataDto.getIsAnswer() == 1) { // 问卷记录保存 if (StringUtils.equals(signPatientManageRouteNode.getTaskNodeType(), TaskNodeTypeEnum.QUESTIONNAIRE_SCALE.getInfo())) { - iaiobService.parseQuestionInfo(data.getRecord(), signPatientManageRouteNode, signPatientManageRoute.getPatientId(), patientTaskExecuteRecord.getId()); + parseQuestionInfo(dutyCallbackDataDto.getCallResultType(), dutyCallbackDataDto.getInteractions(),signPatientManageRouteNode, signPatientManageRoute.getPatientId(), patientTaskExecuteRecord.getId()); } } @@ -280,29 +325,38 @@ public class YZAIOBSServiceImpl implements IYZAIOBSService { } } + JSONObject retObj = new JSONObject(); + retObj.fluentPut("code", 200); + return retObj; + } + @Override public JSONObject phoneCallBack() { return null; } - private void parseQuestionInfo(String interactions, SignPatientManageRouteNode signPatientManageRouteNode, Long patientInfoId, String taskExecuteRecordId) { - - List aiobRecords = records.toList(AiobRecord.class); - List speechList = aiobRecords.stream().filter(record -> StringUtils.equals("speech", record.getRole()) && !StringUtils.equals("抱歉,我不太理解您的意思", record.getContextText())) - .collect(Collectors.toMap(AiobRecord::getContextText, p -> p, (p1, p2) -> p2)) - .values() - .stream() - .sorted(Comparator.comparing(AiobRecord::getTimestamp)) - .collect(Collectors.toList()); - speechList.forEach(s->{ - if(StringUtils.isNull(s.getIntent())) s.setIntent(""); - }); + /** + * @description + * @Param callResultType: 命中的意向用,隔开 + * @Param interactions: 通话内容文本 + * @return null + * @Author haown + * @Date 2025-12-25 15:45 + */ + private void parseQuestionInfo(String callResultTypes, String interactions, SignPatientManageRouteNode node, Long patientInfoId, Long taskExecuteRecordId) { + if(StringUtils.isBlank(interactions)) { + return; + } + List callResultIntents = Arrays.asList(callResultTypes.split(",")); + // 通话记录解析,先用|分隔完整的问题与答案,再用:分隔角色 + List recordList = parseRecord(interactions); + if (CollectionUtils.isEmpty(recordList)) { + return; + } + PatientInfo patientInfo = patientInfoMapper.selectPatientInfoById(patientInfoId); // 查询患者画像信息 List labelFieldContentList = labelFieldContentMapper.selectByPatientId(patientInfoId); - Map contextMap = speechList.stream().collect(Collectors.toMap(AiobRecord::getContextText, AiobRecord::getIntent)); - - PatientInfo patientInfo = patientInfoMapper.selectPatientInfoById(patientInfoId); QuestionInfo questionInfo = questionInfoMapper.selectQuestionInfoById(node.getQuestionInfoId()); // 1、保存patient_question_submit_result PatientQuestionSubmitResult patientQuestionSubmitResult = new PatientQuestionSubmitResult(); @@ -332,21 +386,21 @@ public class YZAIOBSServiceImpl implements IYZAIOBSService { List questionSubjectList = questionSubjectMapper.selectQuestionSubjectBy(node.getQuestionInfoId()); questionSubjectList.forEach(questionSubjectVO -> { // 判断问题中有无变量,有变量替换变量 - String questionNameAlias = replaceQuestionName(questionSubjectVO.getQuestionNameAlias(), labelFieldContentList); + String questionNameAlias = iaiobService.replaceQuestionName(questionSubjectVO.getQuestionNameAlias(), labelFieldContentList); // 根据通话记录筛查是否询问该问题 boolean hasQuestion = false; String aiobQuestionName = ""; - for (String questionContent : contextMap.keySet()) { - if (questionContent.replaceAll("\\p{P}", "").contains(questionNameAlias.replaceAll("\\p{P}", ""))) { + for (int i = 0; i < recordList.size(); i++) { + if (recordList.get(i).getContent().contains(questionNameAlias.replaceAll("\\p{P}", ""))) { hasQuestion = true; - aiobQuestionName = questionContent; + aiobQuestionName = recordList.get(i).getContent(); break; } } + if (hasQuestion) { String finalAiobQuestionName = aiobQuestionName; - AiobRecord nextRecord = getNextQuestion(speechList, finalAiobQuestionName); PatientQuestionSubjectResult patientQuestionSubjectResult = new PatientQuestionSubjectResult(); BeanUtils.copyProperties(questionSubjectVO, patientQuestionSubjectResult); @@ -354,7 +408,7 @@ public class YZAIOBSServiceImpl implements IYZAIOBSService { patientQuestionSubjectResult.setQuestionSubmitResultId(patientQuestionSubmitResult.getId()); patientQuestionSubjectResult.setCreateTime(LocalDateTime.now()); //不管是否是 填空题,都 写入回答 文本 - patientQuestionSubjectResult.setFillBlanksAnswer(nextRecord.getContent()); + patientQuestionSubjectResult.setFillBlanksAnswer(getReply(recordList, finalAiobQuestionName)); patientQuestionSubjectResult.setQuestionSubjectId(questionSubjectVO.getId()); patientQuestionSubjectResultMapper.insertPatientQuestionSubjectResult(patientQuestionSubjectResult); @@ -368,42 +422,49 @@ public class YZAIOBSServiceImpl implements IYZAIOBSService { questionSubjectOptions.forEach(questionSubjectOption -> { PatientQuestionOptionResult patientQuestionOptionResult = new PatientQuestionOptionResult(); BeanUtils.copyProperties(questionSubjectOption, patientQuestionOptionResult); - // 设置是否选中, 通过通话记录中下一个问题的intent字段查询QuestionSubjectOption, + patientQuestionOptionResult.setOptionChooseSign(0); + // 设置是否选中, 根据回调数据中命中的意向查询 List intents = Arrays.asList(questionSubjectOption.getIntent().split("\\|")); - if (ObjectUtils.isNotEmpty(nextRecord) && intents.contains(nextRecord.getIntent())) { - patientQuestionOptionResult.setOptionChooseSign(0); - } else { - patientQuestionOptionResult.setOptionChooseSign(1); + for (String intent : intents) { + if (callResultIntents.contains(intent)) { + patientQuestionOptionResult.setOptionChooseSign(1); + } } + patientQuestionOptionResult.setId(null); patientQuestionOptionResult.setCreateTime(LocalDateTime.now()); patientQuestionOptionResult.setQuestionSubjectResultId(patientQuestionSubjectResult.getId()); patientQuestionOptionResult.setQuestionSubjectOptionId(questionSubjectOption.getId()); + patientQuestionOptionResults.add(patientQuestionOptionResult); }); - //判断问卷 满意项与异常项 - patientQuestionSubmitResult.setRemarkableFlag(ContentedAndRemarkableFlagEnum.ROUTINE.getInfo()); - patientQuestionSubmitResult.setContentedFlag(ContentedAndRemarkableFlagEnum.CONTENTED.getInfo()); - if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(patientQuestionOptionResults)) { + + if (!CollectionUtils.isEmpty(patientQuestionOptionResults)) { List remarkableFlag = patientQuestionOptionResults.stream().filter(Objects::nonNull) - .filter(item -> org.apache.commons.lang3.StringUtils.isNotBlank(item.getRemarkableFlag()) + .filter(item -> StringUtils.isNotBlank(item.getRemarkableFlag()) && Objects.nonNull(item.getOptionChooseSign()) && item.getOptionChooseSign().equals(0) && ContentedAndRemarkableFlagEnum.REMARKABLE.getInfo().equals(item.getRemarkableFlag())) .collect(Collectors.toList()); - if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(remarkableFlag)) { + if (!CollectionUtils.isEmpty(remarkableFlag)) { patientQuestionSubmitResult.setRemarkableFlag(ContentedAndRemarkableFlagEnum.REMARKABLE.getInfo()); } - List contentedFlag = patientQuestionOptionResults.stream().filter(Objects::nonNull).filter(item -> org.apache.commons.lang3.StringUtils.isNotBlank(item.getContentedFlag()) && Objects.nonNull(item.getOptionChooseSign()) && item.getOptionChooseSign().equals(0) && ContentedAndRemarkableFlagEnum.DISCONTENTED.getInfo().equals(item.getRemarkableFlag())).collect(Collectors.toList()); - if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(contentedFlag)) { + List contentedFlag = patientQuestionOptionResults.stream() + .filter(Objects::nonNull) + .filter(item -> org.apache.commons.lang3.StringUtils.isNotBlank(item.getContentedFlag()) + && Objects.nonNull(item.getOptionChooseSign()) + && item.getOptionChooseSign().equals(0) + && ContentedAndRemarkableFlagEnum.DISCONTENTED.getInfo().equals(item.getRemarkableFlag())) + .collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(contentedFlag)) { patientQuestionSubmitResult.setContentedFlag(ContentedAndRemarkableFlagEnum.DISCONTENTED.getInfo()); } - } - questionSubmitResultMapper.updatePatientQuestionSubmitResult(patientQuestionSubmitResult); - if(patientQuestionOptionResults.size()>0) { - patientQuestionOptionResultMapper.saveQuestionOptionList(patientQuestionOptionResults); } + questionSubmitResultMapper.updatePatientQuestionSubmitResult(patientQuestionSubmitResult); + + patientQuestionOptionResultMapper.saveQuestionOptionList(patientQuestionOptionResults); + totalScore[0] = totalScore[0].add(questionSubjectVO.getQuestionScore() == null ? BigDecimal.ZERO : questionSubjectVO.getQuestionScore()); } else { // 没问到问卷中的问题,则保存空问题+空选项 @@ -437,8 +498,43 @@ public class YZAIOBSServiceImpl implements IYZAIOBSService { }); // 4、更新总得分 - patientQuestionSubmitResult.setTotalScore(totalScore[0]); - questionSubmitResultMapper.updatePatientQuestionSubmitResult(patientQuestionSubmitResult); + //patientQuestionSubmitResult.setTotalScore(totalScore[0]); + //questionSubmitResultMapper.updatePatientQuestionSubmitResult(patientQuestionSubmitResult); + } + private List parseRecord(String interactions) { + // 先用|分隔完整的问题与答案,再用:分隔角色 + List retList = new ArrayList<>(); + List records = Arrays.asList(interactions.split("\\|")); + if (CollectionUtils.isEmpty(records)) { + return null; + } + for (String record : records) { + CallRecord callRecord = new CallRecord(); + String[] str1 = record.split(":"); + callRecord.setRole(str1[0]); + callRecord.setContent(str1[1]); + retList.add(callRecord); + } + return retList; + } + + /** + * @description 根据通话记录获取回复 + * @Param callRecordList: 通话记录列表 + * @Param question: 问题名称 + * @return 回复内容 + * @Author haown + * @Date 2025-12-26 9:40 + */ + private String getReply(List callRecordList, String question) { + for (int i = 0; i < callRecordList.size(); i++) { + if (StringUtils.equals(callRecordList.get(i).getContent(), question)) { + if (StringUtils.equals("用户",callRecordList.get(i+1).getRole())) { + return callRecordList.get(i+1).getContent(); + } + } + } + return null; } } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/yzaiobs/CallRecord.java b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/yzaiobs/CallRecord.java new file mode 100644 index 00000000..420d0c00 --- /dev/null +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/yzaiobs/CallRecord.java @@ -0,0 +1,22 @@ +package com.xinelu.manage.vo.yzaiobs; + +import lombok.Data; + +/** + * @description: 曜智通话聊天记录视图类 + * @author: haown + * @create: 2025-12-25 17:07 + **/ +@Data +public class CallRecord { + + /** + * 角色 + */ + private String role; + /** + * 说话内容 + */ + private String content; + +} diff --git a/postdischarge-manage/src/main/resources/mapper/manage/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.xml index 16b3aff2..c4f84ddb 100644 --- a/postdischarge-manage/src/main/resources/mapper/manage/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.xml +++ b/postdischarge-manage/src/main/resources/mapper/manage/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.xml @@ -859,7 +859,7 @@ - update sign_patient_manage_route_node set dial_status = #{dialStatus} + update sign_patient_manage_route_node set dial_status = #{dialStatus}, task_id_ext = #{taskIdExt} where id = #{id}