| | |
| | | package com.smartor.service.impl; |
| | | |
| | | import java.util.List; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.google.gson.Gson; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.DtoConversionUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.smartor.domain.*; |
| | | import com.smartor.mapper.IvrLibaScriptMapper; |
| | | import com.smartor.mapper.IvrLibaScriptTagMapper; |
| | | import com.smartor.mapper.IvrLibaScriptTargetMapper; |
| | | import com.smartor.mapper.IvrLibaScriptTargetoptionMapper; |
| | | import com.smartor.service.IIvrLibaScriptService; |
| | | 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.IvrLibaScriptMapper; |
| | | import com.smartor.domain.IvrLibaScript; |
| | | import com.smartor.service.IIvrLibaScriptService; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 话术库Service业务层处理 |
| | | * |
| | | * @author smartor |
| | | * @date 2023-03-22 |
| | | * 问题话术库Service业务层处理 |
| | | * |
| | | * @author ruoyi |
| | | * @date 2023-12-21 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class IvrLibaScriptServiceImpl implements IIvrLibaScriptService |
| | | { |
| | | public class IvrLibaScriptServiceImpl implements IIvrLibaScriptService { |
| | | @Autowired |
| | | private IvrLibaScriptMapper ivrLibaScriptMapper; |
| | | |
| | | @Autowired |
| | | private IvrLibaScriptTagMapper ivrLibaScriptTagMapper; |
| | | |
| | | @Autowired |
| | | private IvrLibaScriptTargetoptionMapper ivrLibaScriptTargetoptionMapper; |
| | | |
| | | @Autowired |
| | | private IvrLibaScriptTargetMapper ivrLibaScriptTargetMapper; |
| | | |
| | | /** |
| | | * 查询话术库 |
| | | * |
| | | * @param questionid 话术库主键 |
| | | * @return 话术库 |
| | | * 查询问题话术库 |
| | | * |
| | | * @param questionid 问题话术库主键 |
| | | * @return 问题话术库 |
| | | */ |
| | | @Override |
| | | public IvrLibaScript selectIvrLibaScriptByQuestionid(String questionid) |
| | | { |
| | | public IvrLibaScript selectIvrLibaScriptByQuestionid(String questionid) { |
| | | return ivrLibaScriptMapper.selectIvrLibaScriptByQuestionid(questionid); |
| | | } |
| | | |
| | | /** |
| | | * 查询话术库列表 |
| | | * |
| | | * @param ivrLibaScript 话术库 |
| | | * @return 话术库 |
| | | * 查询问题话术库列表 |
| | | * |
| | | * @param ivrLibaScript 问题话术库 |
| | | * @return 问题话术库 |
| | | */ |
| | | @Override |
| | | public List<IvrLibaScript> selectIvrLibaScriptList(IvrLibaScript ivrLibaScript) |
| | | { |
| | | public List<IvrLibaScript> selectIvrLibaScriptList(IvrLibaScript ivrLibaScript) { |
| | | return ivrLibaScriptMapper.selectIvrLibaScriptList(ivrLibaScript); |
| | | } |
| | | |
| | | /** |
| | | * 新增话术库 |
| | | * |
| | | * @param ivrLibaScript 话术库 |
| | | * 查询问题话术详情根据条件 |
| | | */ |
| | | @Override |
| | | public IvrLibaScriptVO selectInfoByCondition(IvrLibaScriptVO ivrLibaScriptVO) { |
| | | log.info("查询问题话术详情根据条件的入参为 : {}", ivrLibaScriptVO); |
| | | //先根据条件查询问题表信息 |
| | | IvrLibaScript ivrLibaScript = DtoConversionUtils.sourceToTarget(ivrLibaScriptVO, IvrLibaScript.class); |
| | | List<IvrLibaScript> ivrLibaScripts = selectIvrLibaScriptList(ivrLibaScript); |
| | | if (CollectionUtils.isEmpty(ivrLibaScripts)) { |
| | | log.info("提供的条件,查询数据为空:{}", ivrLibaScript); |
| | | return null; |
| | | } |
| | | log.info("ivrLibaScript的查询结果为:{},数量为 : {}", ivrLibaScripts.get(0), ivrLibaScripts.size()); |
| | | //定义IvrLibaScriptVO 用于返参 |
| | | IvrLibaScriptVO scriptVO = DtoConversionUtils.sourceToTarget(ivrLibaScripts.get(0), IvrLibaScriptVO.class); |
| | | |
| | | //获取tag信息 |
| | | IvrLibaScriptTag ivrLibaScriptTag = new IvrLibaScriptTag(); |
| | | ivrLibaScriptTag.setScriptid(ivrLibaScripts.get(0).getId()); |
| | | List<IvrLibaScriptTag> ivrLibaScriptTags = ivrLibaScriptTagMapper.selectIvrLibaScriptTagList(ivrLibaScriptTag); |
| | | scriptVO.setIvrLibaScriptTagList(ivrLibaScriptTags); |
| | | |
| | | //获取option信息 |
| | | IvrLibaScriptTargetoption ivrLibaScriptTargetoption = new IvrLibaScriptTargetoption(); |
| | | ivrLibaScriptTargetoption.setScriptid(ivrLibaScripts.get(0).getId()); |
| | | List<IvrLibaScriptTargetoption> ivrLibaScriptTargetoptions = ivrLibaScriptTargetoptionMapper.selectIvrLibaScriptTargetoptionList(ivrLibaScriptTargetoption); |
| | | for (IvrLibaScriptTargetoption ivrLibaScriptTargetoption1 : ivrLibaScriptTargetoptions) { |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | try { |
| | | if (StringUtils.isNotEmpty(ivrLibaScriptTargetoption1.getDynamiccruxsJson())) |
| | | ivrLibaScriptTargetoption1.setDynamiccruxs(objectMapper.readValue(ivrLibaScriptTargetoption1.getDynamiccruxsJson(), List.class)); |
| | | if (StringUtils.isNotEmpty(ivrLibaScriptTargetoption1.getNodynamiccruxsJson())) |
| | | ivrLibaScriptTargetoption1.setNodynamiccruxs(objectMapper.readValue(ivrLibaScriptTargetoption1.getNodynamiccruxsJson(), List.class)); |
| | | } catch (JsonProcessingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | scriptVO.setIvrLibaScriptTargetoptionList(ivrLibaScriptTargetoptions); |
| | | |
| | | // //查询问题指标接口 |
| | | // IvrLibaScriptTarget ivrLibaScriptTarget = new IvrLibaScriptTarget(); |
| | | // ivrLibaScriptTarget.setScriptid(ivrLibaScripts.get(0).getId()); |
| | | // List<IvrLibaScriptTarget> ivrLibaScriptTargets = ivrLibaScriptTargetMapper.selectIvrLibaScriptTargetList(ivrLibaScriptTarget); |
| | | // scriptVO.setIvrLibaScriptTargetList(ivrLibaScriptTargets); |
| | | |
| | | return scriptVO; |
| | | } |
| | | |
| | | /** |
| | | * 新增或修改问题详情 |
| | | * |
| | | * @param ivrLibaScriptVO |
| | | * @return |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public Integer saveOrUpdateScript(IvrLibaScriptVO ivrLibaScriptVO) { |
| | | IvrLibaScript ivrLibaScript = DtoConversionUtils.sourceToTarget(ivrLibaScriptVO, IvrLibaScript.class); |
| | | //对问题表进行数据处理 |
| | | Integer i = null; |
| | | if (ivrLibaScriptVO.getIsoperation() != null && ivrLibaScriptVO.getIsoperation() == 1) { |
| | | i = ivrLibaScriptMapper.insertIvrLibaScript(ivrLibaScript); |
| | | } else if (ivrLibaScriptVO.getIsoperation() != null && ivrLibaScriptVO.getIsoperation() == 2) { |
| | | i = ivrLibaScriptMapper.updateIvrLibaScript(ivrLibaScript); |
| | | } |
| | | log.info("问题表对应的id为:{}", ivrLibaScript.getId()); |
| | | if (ivrLibaScript.getId() == null) { |
| | | throw new BaseException("话术ID为空,请检查话术入参信息是否完整"); |
| | | } |
| | | |
| | | //对问题指标选项进行处理 |
| | | if (CollectionUtils.isNotEmpty(ivrLibaScriptVO.getIvrLibaScriptTargetoptionList())) { |
| | | for (IvrLibaScriptTargetoption ivrLibaScriptTargetoption : ivrLibaScriptVO.getIvrLibaScriptTargetoptionList()) { |
| | | if (CollectionUtils.isNotEmpty(ivrLibaScriptTargetoption.getNodynamiccruxs())) { |
| | | ivrLibaScriptTargetoption.setNodynamiccruxsJson(new Gson().toJson(ivrLibaScriptTargetoption.getNodynamiccruxs())); |
| | | } |
| | | if (CollectionUtils.isNotEmpty(ivrLibaScriptTargetoption.getDynamiccruxs())) { |
| | | ivrLibaScriptTargetoption.setDynamiccruxsJson(new Gson().toJson(ivrLibaScriptTargetoption.getDynamiccruxs())); |
| | | } |
| | | |
| | | if (ivrLibaScriptTargetoption.getIsoperation() != null && ivrLibaScriptTargetoption.getIsoperation() == 1) { |
| | | //新增 |
| | | ivrLibaScriptTargetoption.setScriptid(ivrLibaScript.getId()); |
| | | ivrLibaScriptTargetoptionMapper.insertIvrLibaScriptTargetoption(ivrLibaScriptTargetoption); |
| | | } |
| | | if (ivrLibaScriptTargetoption.getIsoperation() != null && ivrLibaScriptTargetoption.getIsoperation() == 2) { |
| | | //修改 |
| | | ivrLibaScriptTargetoption.setScriptid(ivrLibaScript.getId()); |
| | | ivrLibaScriptTargetoptionMapper.updateIvrLibaScriptTargetoption(ivrLibaScriptTargetoption); |
| | | } |
| | | if (ivrLibaScriptTargetoption.getIsoperation() != null && ivrLibaScriptTargetoption.getIsoperation() == 3) { |
| | | //删除 |
| | | if (ivrLibaScriptTargetoption.getId() == null) { |
| | | log.info("删除失败,问题指标选项id为空"); |
| | | } else { |
| | | Boolean aBoolean = ivrLibaScriptTargetoptionMapper.deleteIvrLibaScriptTargetoptionByTargetoptionid(ivrLibaScriptTargetoption.getId()); |
| | | log.info("aBoolean的值为:{}", aBoolean); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //对问题标签进行处理 |
| | | if (CollectionUtils.isNotEmpty(ivrLibaScriptVO.getIvrLibaScriptTagList())) { |
| | | for (IvrLibaScriptTag ivrLibaScriptTag : ivrLibaScriptVO.getIvrLibaScriptTagList()) { |
| | | if (ivrLibaScriptTag.getIsoperation() != null && ivrLibaScriptTag.getIsoperation() == 1) { |
| | | //新增 |
| | | ivrLibaScriptTag.setScriptid(ivrLibaScript.getId()); |
| | | ivrLibaScriptTagMapper.insertIvrLibaScriptTag(ivrLibaScriptTag); |
| | | } |
| | | if (ivrLibaScriptTag.getIsoperation() != null && ivrLibaScriptTag.getIsoperation() == 2) { |
| | | //修改 |
| | | ivrLibaScriptTag.setScriptid(ivrLibaScript.getId()); |
| | | ivrLibaScriptTagMapper.updateIvrLibaScriptTag(ivrLibaScriptTag); |
| | | } |
| | | if (ivrLibaScriptTag.getIsoperation() != null && ivrLibaScriptTag.getIsoperation() == 3) { |
| | | //删除 |
| | | if (ivrLibaScriptTag.getId() == null) { |
| | | log.info("删除失败,问题标签id为空"); |
| | | } else { |
| | | ivrLibaScriptTagMapper.deleteIvrLibaScriptTagById(ivrLibaScriptTag.getId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return i; |
| | | } |
| | | |
| | | /** |
| | | * 新增问题话术库 |
| | | * |
| | | * @param ivrLibaScript 问题话术库 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertIvrLibaScript(IvrLibaScript ivrLibaScript) |
| | | { |
| | | public int insertIvrLibaScript(IvrLibaScript ivrLibaScript) { |
| | | ivrLibaScript.setCreateTime(DateUtils.getNowDate()); |
| | | return ivrLibaScriptMapper.insertIvrLibaScript(ivrLibaScript); |
| | | } |
| | | |
| | | /** |
| | | * 修改话术库 |
| | | * |
| | | * @param ivrLibaScript 话术库 |
| | | * 修改问题话术库 |
| | | * |
| | | * @param ivrLibaScript 问题话术库 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int updateIvrLibaScript(IvrLibaScript ivrLibaScript) |
| | | { |
| | | public int updateIvrLibaScript(IvrLibaScript ivrLibaScript) { |
| | | ivrLibaScript.setUpdateTime(DateUtils.getNowDate()); |
| | | return ivrLibaScriptMapper.updateIvrLibaScript(ivrLibaScript); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除话术库 |
| | | * |
| | | * @param questionids 需要删除的话术库主键 |
| | | * 批量删除问题话术库 |
| | | * |
| | | * @param questionids 需要删除的问题话术库主键 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteIvrLibaScriptByQuestionids(String[] questionids) |
| | | { |
| | | return ivrLibaScriptMapper.deleteIvrLibaScriptByQuestionids(questionids); |
| | | public int deleteIvrLibaScriptByQuestionids(String[] questionids) { |
| | | Integer i = null; |
| | | for (String id : questionids) { |
| | | i = ivrLibaScriptMapper.deleteIvrLibaScriptByQuestionid(Integer.valueOf(id)); |
| | | } |
| | | return i; |
| | | } |
| | | |
| | | /** |
| | | * 删除话术库信息 |
| | | * |
| | | * @param questionid 话术库主键 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteIvrLibaScriptByQuestionid(String questionid) |
| | | { |
| | | return ivrLibaScriptMapper.deleteIvrLibaScriptByQuestionid(questionid); |
| | | } |
| | | } |