|  |  |  | 
|---|
|  |  |  | package com.ruoyi.web.controller.smartor; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.fasterxml.jackson.core.JsonProcessingException; | 
|---|
|  |  |  | import com.fasterxml.jackson.databind.ObjectMapper; | 
|---|
|  |  |  | import com.google.gson.Gson; | 
|---|
|  |  |  | import com.ruoyi.common.annotation.Log; | 
|---|
|  |  |  | import com.ruoyi.common.core.controller.BaseController; | 
|---|
|  |  |  | import com.ruoyi.common.core.domain.AjaxResult; | 
|---|
|  |  |  | import com.ruoyi.common.core.page.TableDataInfo; | 
|---|
|  |  |  | import com.ruoyi.common.enums.BusinessType; | 
|---|
|  |  |  | import com.ruoyi.common.utils.DateUtils; | 
|---|
|  |  |  | import com.ruoyi.common.utils.DtoConversionUtils; | 
|---|
|  |  |  | import com.ruoyi.common.utils.PageUtils; | 
|---|
|  |  |  | import com.ruoyi.common.utils.StringUtils; | 
|---|
|  |  |  | import com.ruoyi.common.utils.poi.ExcelUtil; | 
|---|
|  |  |  | import com.smartor.domain.HeTaskVO; | 
|---|
|  |  |  | import com.smartor.domain.IvrTaskcall; | 
|---|
|  |  |  | import com.smartor.domain.IvrTaskcallVO; | 
|---|
|  |  |  | import com.smartor.domain.*; | 
|---|
|  |  |  | import com.smartor.service.IIvrTaskcallService; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.servlet.http.HttpServletResponse; | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 单一任务(随访)Controller | 
|---|
|  |  |  | 
|---|
|  |  |  | * @author ruoyi | 
|---|
|  |  |  | * @date 2024-02-02 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Api(description = "单一任务(随访)") | 
|---|
|  |  |  | @Api(description = "单一任务(随访宣教)") | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @RequestMapping("/smartor/taskcall") | 
|---|
|  |  |  | public class IvrTaskcallController extends BaseController { | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 查询单一任务(随访)列表 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ApiOperation("查询单一任务(随访)列表") | 
|---|
|  |  |  | @ApiOperation("查询单一任务(随访宣教)列表") | 
|---|
|  |  |  | @PreAuthorize("@ss.hasPermi('system:taskcall:list')") | 
|---|
|  |  |  | @PostMapping("/list") | 
|---|
|  |  |  | public TableDataInfo list(@RequestBody IvrTaskcall ivrTaskcall) { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 导出单一任务(随访)列表 | 
|---|
|  |  |  | * 导出单一任务(随访宣教)列表 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PreAuthorize("@ss.hasPermi('system:taskcall:export')") | 
|---|
|  |  |  | @Log(title = "单一任务(随访)", businessType = BusinessType.EXPORT) | 
|---|
|  |  |  | @Log(title = "单一任务(随访宣教)", businessType = BusinessType.EXPORT) | 
|---|
|  |  |  | @PostMapping("/export") | 
|---|
|  |  |  | public void export(HttpServletResponse response, IvrTaskcall ivrTaskcall) { | 
|---|
|  |  |  | List<IvrTaskcall> list = ivrTaskcallService.selectIvrTaskcallList(ivrTaskcall); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 根据条件查询任务信息 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ApiOperation("根据条件查询任务信息") | 
|---|
|  |  |  | @PostMapping("/queryTaskByCondition") | 
|---|
|  |  |  | public AjaxResult queryTaskByCondition(@RequestBody IvrTaskcallVO ivrTaskcallVO) { | 
|---|
|  |  |  | //根据入参查询信息 | 
|---|
|  |  |  | IvrTaskcall ivrTaskcall = DtoConversionUtils.sourceToTarget(ivrTaskcallVO, IvrTaskcall.class); | 
|---|
|  |  |  | List<IvrTaskcall> list = ivrTaskcallService.selectIvrTaskcallList(ivrTaskcall); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //定义患者与单一任务关联表集合 | 
|---|
|  |  |  | List<PatTaskRelevance> patTaskRelevances = new ArrayList<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //将查出来的数据倒入IvrTaskcallVO中 | 
|---|
|  |  |  | IvrTaskcallVO ivrTaskcallVO2 = DtoConversionUtils.sourceToTarget(list.get(0), IvrTaskcallVO.class); | 
|---|
|  |  |  | String sendTimeSlot = list.get(0).getSendTimeSlot(); | 
|---|
|  |  |  | ObjectMapper objectMapper = new ObjectMapper(); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | //获取到发送时间的集合 | 
|---|
|  |  |  | if (StringUtils.isNotEmpty(sendTimeSlot)) { | 
|---|
|  |  |  | List<TaskSendTimeVO> taskSendTimeVOList = objectMapper.readValue(sendTimeSlot, List.class); | 
|---|
|  |  |  | ivrTaskcallVO2.setSendTimeslot(taskSendTimeVOList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //文本变量参数 | 
|---|
|  |  |  | if (StringUtils.isNotEmpty(list.get(0).getTextParam())) { | 
|---|
|  |  |  | Map<String, Map<String, String>> textParam = objectMapper.readValue(list.get(0).getTextParam(), Map.class); | 
|---|
|  |  |  | ivrTaskcallVO2.setTextParam(textParam); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (JsonProcessingException e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (IvrTaskcall ivrTaskcall1 : list) { | 
|---|
|  |  |  | PatTaskRelevance patTaskRelevance = new PatTaskRelevance(); | 
|---|
|  |  |  | //获取到患者信息,并放入到集合中 | 
|---|
|  |  |  | patTaskRelevance.setName(ivrTaskcall1.getSendname()); | 
|---|
|  |  |  | patTaskRelevance.setAge(ivrTaskcall1.getAge()); | 
|---|
|  |  |  | patTaskRelevance.setSfzh(ivrTaskcall1.getSfzh()); | 
|---|
|  |  |  | patTaskRelevance.setPhone(ivrTaskcall1.getPhone()); | 
|---|
|  |  |  | patTaskRelevance.setAddr(ivrTaskcall1.getAddr()); | 
|---|
|  |  |  | patTaskRelevances.add(patTaskRelevance); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ivrTaskcallVO2.setPatTaskRelevances(patTaskRelevances); | 
|---|
|  |  |  | return success(ivrTaskcallVO2); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 任务发送执行 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ApiOperation("任务发送执行") | 
|---|
|  |  |  | @PostMapping("/heTaskSend") | 
|---|
|  |  |  | public AjaxResult heTaskSend(@RequestBody IvrTaskcallVO ivrTaskcallVO) { | 
|---|
|  |  |  | return toAjax(ivrTaskcallService.heTaskSend(ivrTaskcallVO)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 电话回调任务 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ApiOperation("电话回调任务") | 
|---|
|  |  |  | @PostMapping("/phoneCallBack") | 
|---|
|  |  |  | public AjaxResult phoneCallBack(@RequestBody PhoneCallBackVO phoneCallBackVO) { | 
|---|
|  |  |  | //如果uuid在redis中找不到,那就直接报异常 | 
|---|
|  |  |  | return success(ivrTaskcallService.phoneCallBack(phoneCallBackVO)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|