21c27eaa5280713b0ec39423bbe6e3d7541f1da7..673757e7a669769041a54ef6471b4d8d250e3416
2026-07-28 陈昶聿
【丽水】JZ_MZ_WanChengJZ 就诊信息同步生成随访任务
673757 对比 | 目录
2026-07-28 陈昶聿
【省立同德】AI识别
eac6df 对比 | 目录
已修改4个文件
147 ■■■■ 文件已修改
smartor/src/main/java/com/smartor/service/IPatMedOuthospService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/impl/PatMedOuthospServiceImpl.java 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/IPatMedOuthospService.java
@@ -1,5 +1,6 @@
package com.smartor.service;
import java.util.Date;
import java.util.List;
import com.ruoyi.common.core.page.TableDataInfo;
@@ -69,4 +70,7 @@
    public Integer dealOutpatientInfo();
    public ServiceSubtask boxedServiceSubtask(ServiceTask serviceTask, PatMedOuthosp patMedOuthosp, PatArchive patArchive);
    //门诊记录再次随访
    public Integer followUpAgainByPatMedOuthosp(PatMedOuthosp patMedOuthosp, Date adminDate, Integer visitTimeNum);
}
smartor/src/main/java/com/smartor/service/impl/PatMedOuthospServiceImpl.java
@@ -531,6 +531,68 @@
        return serviceSubtask;
    }
    /**
     *
     * @param patMedOuthosp
     * @return
     */
    @Override
    public Integer followUpAgainByPatMedOuthosp(PatMedOuthosp patMedOuthosp,Date adminDate, Integer visitTimeNum){
        int hoursToAdd = visitTimeNum * 24;
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(adminDate);
        calendar.add(Calendar.HOUR_OF_DAY, hoursToAdd);
        Date newDate = calendar.getTime();
        Integer i = 0;
        String deptcode = patMedOuthosp.getDeptcode();
        Long patid = patMedOuthosp.getPatid();
        //查看有无进行中的任务
        ServiceSubtaskEntity serviceSubtaskEntity0 = new ServiceSubtaskEntity();
        serviceSubtaskEntity0.setOrgid(patMedOuthosp.getOrgid());
        serviceSubtaskEntity0.setSendstates(new ArrayList<>(Arrays.asList(1L, 2L, 3L, 7L)));
        serviceSubtaskEntity0.setPatid(patid);
        serviceSubtaskEntity0.setDeptcode(deptcode);
        serviceSubtaskEntity0.setSort(0);
        List<ServiceSubtask> serviceSubtaskList0 = serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskEntity0);
        if(!CollectionUtils.isEmpty(serviceSubtaskList0)){
            ServiceSubtask serviceSubtask0 = serviceSubtaskList0.get(0);
            serviceSubtask0.setSendstate(6L);
            serviceSubtask0.setUpdateTime(new Date());
            serviceSubtask0.setFinishtime(adminDate);
            serviceSubtaskMapper.updateServiceSubtask(serviceSubtask0);
            ServiceSubtask serviceSubtask1 = serviceSubtaskList0.get(0);
            serviceSubtask1.setSendstate(2L);
            serviceSubtask1.setCreateTime(new Date());
            serviceSubtask1.setUpdateTime(new Date());
            serviceSubtask1.setVisitTime(newDate);
            serviceSubtask1.setLongSendTime(newDate);
            i = serviceSubtaskMapper.insertServiceSubtask(serviceSubtask1);
        }else {
            //查看已完成的任务
//            ServiceSubtaskEntity serviceSubtaskEntity = new ServiceSubtaskEntity();
//            serviceSubtaskEntity0.setOrgid(patMedOuthosp.getOrgid());
//            serviceSubtaskEntity.setSendstates(new ArrayList<>(Arrays.asList(6L)));
//            serviceSubtaskEntity.setPatid(patid);
//            serviceSubtaskEntity.setDeptcode(deptcode);
//            serviceSubtaskEntity.setSort(0);
//            List<ServiceSubtask> serviceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskEntity);
//            if(!CollectionUtils.isEmpty(serviceSubtaskList)){
//                ServiceSubtask serviceSubtask = serviceSubtaskList.get(0);
//                serviceSubtask.setSendstate(2L);
//                serviceSubtask.setCreateTime(new Date());
//                serviceSubtask.setUpdateTime(new Date());
//
//                serviceSubtask.setVisitTime(newDate);
//                serviceSubtask.setLongSendTime(newDate);
//                i = serviceSubtaskMapper.insertServiceSubtask(serviceSubtask);
//            }
        }
        return i;
    }
    private Date addDays(Date date, Integer days) {
        if (days == null) {
            days = 1;
smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
@@ -1204,12 +1204,23 @@
                patMedOuthosp.setFuflag("1");
            }
        }
        Integer visitTimeNum = null;
        String visitTimeUnit = "天";
        for (ExternalWZInfo externalWZInfo : ExternalWZInfoList) {
            if (externalWZInfo.getWenZhenLXMC().equals("现病史")) {
                patMedOuthosp.setHpi(externalWZInfo.getNeiRong());
            }
            if (externalWZInfo.getWenZhenLXMC().equals("主诉")) {
                patMedOuthosp.setMainsuit(externalWZInfo.getNeiRong());
            }
            if (externalWZInfo.getWenZhenLXMC().equals("随访天数")) {
                String visitTimeNumStr = externalWZInfo.getNeiRong();
                if(StringUtils.isNotEmpty(visitTimeNumStr) && visitTimeNumStr.matches("^-?\\d+$")){
                    visitTimeNum = Integer.parseInt(visitTimeNumStr);
                }
            }
            if (externalWZInfo.getWenZhenLXMC().equals("随访天数单位")) {
                visitTimeUnit = externalWZInfo.getNeiRong();
            }
        }
        int i = 0;
@@ -1231,6 +1242,11 @@
            i = patMedOuthospService.insertPatMedOuthosp(patMedOuthosp);
        }
        Date adminDate = externalJZInfo.getJiuZhenRQ();
        //完成接诊 已经完成任务再次随访
        if(ObjectUtils.isNotEmpty(visitTimeNum) && ObjectUtils.isNotEmpty(adminDate)){
            patMedOuthospService.followUpAgainByPatMedOuthosp(patMedOuthosp, adminDate, visitTimeNum);
        }
        if (i > 0) {
            return true;
smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
@@ -13,9 +13,11 @@
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.*;
import com.ruoyi.common.core.service.IConfigService;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.mapper.SysConfigMapper;
import com.ruoyi.system.service.ISysConfigService;
import com.smartor.common.DeepSeekApi;
import com.smartor.common.FtpService;
import com.smartor.common.MtSubmitSmUtil;
@@ -146,6 +148,9 @@
    @Value("${ASRCallBackPath}")
    private String ASRCallBackPath;
    @Autowired
    private ISysConfigService configService;
    @Autowired
    private MtSubmitSmUtil mtSubmitSmUtil;
@@ -1734,14 +1739,14 @@
            if (ivrTaskTemplateScriptVO.getScriptType().equals("1")) {
                //用来标记,是否有匹配上的
                Integer flag = 0;
//                //2-AI识别
//                SysConfig configVoiceMatchType = new SysConfig();
//                configVoiceMatchType.setOrgid(phoneCallReqYQVO.getOrgid());
//                configVoiceMatchType.setConfigKey("sys.voice.match.type");
//                SysConfig matchType = sysConfigMapper.selectConfig(configVoiceMatchType);
//
//            if (ObjectUtils.isNotEmpty(matchType) && StringUtils.isNotEmpty(matchType.getConfigValue())
//                    && matchType.getConfigValue().equals("2")) {
                //1-AI识别
                SysConfig configVoiceMatchAi = new SysConfig();
                configVoiceMatchAi.setOrgid(phoneCallReqYQVO.getOrgid());
                configVoiceMatchAi.setConfigKey("sys.voice.match.ai");
                SysConfig matchAi = sysConfigMapper.selectConfig(configVoiceMatchAi);
//            if (ObjectUtils.isNotEmpty(matchAi) && StringUtils.isNotEmpty(matchAi.getConfigValue())
//                    && matchAi.getConfigValue().equals("1")) {
//                PhoneCallBackYQVO aiMatchResult = AiMatch(phoneCallReqYQVO, phoneCallBackYQVO,
//                        ivrTaskTemplateScriptVO, serviceSubtask, ivrTaskTemplate,
//                        ivrTaskTemplateScripts, scriptId, flag);
@@ -4976,34 +4981,45 @@
     * @param options
     * @return
     */
    public String matchOptionIndex(String questionText, String voiceText, List<IvrTaskTemplateTargetoption> options) {
    public Integer matchOptionIndex(String questionText, String voiceText, List<IvrTaskTemplateTargetoption> options){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("userQuestion",questionText);
        jsonObject.put("userAnswer",voiceText);
        jsonObject.put("options", options);
        String jsonString = jsonObject.toJSONString();
        String result = null;
        try {
            result = OkHttpExample.post("http://localhost:8099/matchOptionIndex", jsonString);
        } catch (IOException e) {
            throw new RuntimeException(e);
        String url = "http://localhost:8099/matchOptionIndex";
//        String url = configService.selectConfigByKey("sys.voice.match.ai.url");
        if(StringUtils.isNotEmpty(url)){
            try {
                Map<String, String> headers = new HashMap<>();
                headers.put("Content-Type", "application/json");
                result = HttpUtils.sendPostByHeader(url, jsonString, headers);
            } catch (Exception e) {
                log.error("AI识别失败", e);
            }
        }
        return result;
        if(StringUtils.isNotEmpty(result) && result.matches("^-?\\d+$")){
            return Integer.parseInt(result);
        }else {
            return -1;
        }
    }
    public PhoneCallBackYQVO AiMatch(PhoneCallReqYQVO phoneCallReqYQVO, PhoneCallBackYQVO phoneCallBackYQVO,
                        IvrTaskTemplateScriptVO ivrTaskTemplateScriptVO, ServiceSubtask serviceSubtask, IvrTaskTemplate ivrTaskTemplate,
                        List<IvrTaskTemplateScript> ivrTaskTemplateScripts, String scriptId, Integer flag){
        PhoneCallBackYQVO back = null;
        String result = "0";
        List<IvrTaskTemplateTargetoption> options = ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList();
        String voiceText = phoneCallReqYQVO.getAsrtext();
        String questionText = StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrtext()) ? ivrTaskTemplateScriptVO.getIvrtext() : ivrTaskTemplateScriptVO.getScriptContent();
        result = matchOptionIndex(questionText, voiceText, options);
        Integer matched = Integer.valueOf(result);
        IvrTaskTemplateTargetoption chosenOption = options.get(matched);
        Integer matched = -1;
        matched = matchOptionIndex(questionText, voiceText, options);
        //说明匹配正确了
        if(matched != null && matched != 0){
        if(matched != null && matched >= 0){
            IvrTaskTemplateTargetoption chosenOption = options.get(matched);
            //这里应该先判断类型,去再修改,设置IsUserOperation是单选题的改法
            log.info("匹配正确了吗--------------");
            chosenOption.setIsUserOperation(1);
@@ -5225,7 +5241,7 @@
    public void TestMatch(){
        String questionText = "您好,请问您是患者本人还是家属?\n";
        String voiceText = "我自己";
        Long scriptid = 31231L;
        String matchedText = "";
        List<IvrTaskTemplateTargetoption> options = new ArrayList<>();
        IvrTaskTemplateTargetoption ivrTaskTemplateTargetoption1 = new IvrTaskTemplateTargetoption();
        ivrTaskTemplateTargetoption1.setTargetvalue("本人");
@@ -5236,6 +5252,13 @@
        IvrTaskTemplateTargetoption ivrTaskTemplateTargetoption3 = new IvrTaskTemplateTargetoption();
        ivrTaskTemplateTargetoption3.setTargetvalue("其他");
        options.add(ivrTaskTemplateTargetoption3);
        matchOptionIndex(questionText,voiceText,options);
        Integer matched = matchOptionIndex(questionText,voiceText,options);
        if(ObjectUtils.isNotEmpty(matched)){
            if(matched >= 0){
                matchedText = options.get(matched).getTargetvalue();
            }
        }
        log.info("ai匹配成功,匹配结果是:" + matchedText);
    }
}