| | |
| | | package com.smartor.service.impl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.smartor.domain.IvrTaskSingle; |
| | | import com.smartor.mapper.IvrTaskSingleMapper; |
| | | import com.ruoyi.common.utils.DtoConversionUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.smartor.domain.*; |
| | | import com.smartor.mapper.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.smartor.mapper.IvrTaskMapper; |
| | | import com.smartor.domain.IvrTask; |
| | | import com.smartor.service.IIvrTaskService; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | * @author smartor |
| | | * @date 2023-03-24 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class IvrTaskServiceImpl implements IIvrTaskService { |
| | | @Autowired |
| | |
| | | |
| | | @Autowired |
| | | private IvrTaskSingleMapper ivrTaskcallMapper; |
| | | |
| | | @Autowired |
| | | private IvrLibaTemplateScriptMapper ivrLibaTemplateScriptMapper; |
| | | |
| | | @Autowired |
| | | private PatArchiveMapper patArchiveMapper; |
| | | |
| | | @Autowired |
| | | private IvrLibaTemplateTargetoptionMapper ivrLibaTemplateTargetOptionMapper; |
| | | |
| | | /** |
| | | * 查询语音任务 |
| | |
| | | isSuccess = ivrTaskMapper.deleteIvrTaskByTaskid(taskid); |
| | | return isSuccess; |
| | | } |
| | | |
| | | @Override |
| | | public List<IvrLibaTemplateScriptVO> getScriptInfoByCondition(Long taskid, Long patid) { |
| | | //通过任务ID获取模板ID |
| | | IvrTask ivrTask = selectIvrTaskByTaskid(taskid); |
| | | |
| | | //通过模板ID获取问题信息 |
| | | IvrLibaTemplateScript ivrLibaTemplateScript = new IvrLibaTemplateScript(); |
| | | ivrLibaTemplateScript.setTemplateID(ivrTask.getTemplateid()); |
| | | ivrLibaTemplateScript.setDelFlag("0"); |
| | | List<IvrLibaTemplateScript> ivrLibaTemplateScripts = ivrLibaTemplateScriptMapper.selectIvrLibaTemplateScriptList(ivrLibaTemplateScript); |
| | | if (CollectionUtils.isEmpty(ivrLibaTemplateScripts) || ivrLibaTemplateScripts.size() == 0) { |
| | | log.info("ivrLibaTemplateScripts为空了,请尽快联系管理员处理"); |
| | | return new ArrayList<>(); |
| | | } |
| | | List<IvrLibaTemplateScriptVO> ivrLibaTemplateScriptVOS = DtoConversionUtils.sourceToTarget(ivrLibaTemplateScripts, IvrLibaTemplateScriptVO.class); |
| | | |
| | | //获取患者信息 |
| | | PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(patid); |
| | | |
| | | //通过患者信息和任务信息中的textParam对问题中的变量进行填充 |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | Map<String, Map<String, String>> ivrTaskMap = null; |
| | | try { |
| | | ivrTaskMap = objectMapper.readValue(ivrTask.getTextParam(), Map.class); |
| | | } catch (JsonProcessingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | List<Map<String, String>> mapList = new ArrayList<>(); |
| | | |
| | | for (Map<String, String> map : ivrTaskMap.values()) { |
| | | mapList.add(map); |
| | | } |
| | | |
| | | //将模板问题话术里的通配符替换 |
| | | for (IvrLibaTemplateScriptVO ivrLibaTemplateScriptVO : ivrLibaTemplateScriptVOS) { |
| | | if (StringUtils.isNotEmpty(ivrLibaTemplateScriptVO.getQuestionText())) { |
| | | for (Map<String, String> map : mapList) { |
| | | for (String key : map.keySet()) { |
| | | |
| | | ivrLibaTemplateScriptVO.setQuestionText(ivrLibaTemplateScriptVO.getQuestionText().replace(key, StringUtils.isNotEmpty(map.get(key)) ? map.get(key) : "")); |
| | | } |
| | | } |
| | | //替换患者个人信息数据 |
| | | ivrLibaTemplateScriptVO.setQuestionText(ivrLibaTemplateScriptVO.getQuestionText().replace("${name}", StringUtils.isNotEmpty(patArchive.getName()) ? patArchive.getName() : "")); |
| | | ivrLibaTemplateScriptVO.setQuestionText(ivrLibaTemplateScriptVO.getQuestionText().replace("${dzz}", StringUtils.isNotEmpty(patArchive.getPlaceOfResidence()) ? patArchive.getPlaceOfResidence() : "")); |
| | | ivrLibaTemplateScriptVO.setQuestionText(ivrLibaTemplateScriptVO.getQuestionText().replace("${dhh}", StringUtils.isNotEmpty(patArchive.getTelcode()) ? patArchive.getTelcode() : "")); |
| | | |
| | | //获取问题选项 |
| | | IvrLibaTemplateTargetoption ivrLibaTemplateTargetoption = new IvrLibaTemplateTargetoption(); |
| | | ivrLibaTemplateTargetoption.setScriptid(ivrLibaTemplateScriptVO.getID()); |
| | | List<IvrLibaTemplateTargetoption> ivrLibaTemplateTargetoptions = ivrLibaTemplateTargetOptionMapper.selectIvrLibaTemplateTargetoptionList(ivrLibaTemplateTargetoption); |
| | | ivrLibaTemplateScriptVO.setIvrLibaScriptTargetoptionList(ivrLibaTemplateTargetoptions); |
| | | } |
| | | } |
| | | |
| | | |
| | | return ivrLibaTemplateScriptVOS; |
| | | } |
| | | } |