liusheng
2024-04-16 63e17909e1eee7ff54c38827a4096cbad82e5dad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
package com.ruoyi.web.controller.smartor;
 
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
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.DtoConversionUtils;
import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.smartor.domain.*;
import com.smartor.service.IIvrTaskSingleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
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 = "单一任务(随访宣教)")
@RestController
@RequestMapping("/smartor/tasksingle")
public class IvrTaskcallController extends BaseController {
    @Autowired
    private IIvrTaskSingleService ivrTaskcallService;
 
 
    /**
     * 查询患者随访信息
     */
    @ApiOperation("查询患者随访信息")
    @PreAuthorize("@ss.hasPermi('system:taskcall:list')")
    @PostMapping("/patItem")
    public TableDataInfo patItem(@RequestBody IvrTaskSingle ivrTaskcall) {
        PageUtils.startPageByPost(ivrTaskcall.getPageNum(), ivrTaskcall.getPageSize());
        return getDataTable(ivrTaskcallService.patItem(ivrTaskcall));
    }
 
    /**
     * 导出单一任务(随访宣教)列表
     */
    @PreAuthorize("@ss.hasPermi('system:taskcall:export')")
    @Log(title = "单一任务(随访宣教)", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IvrTaskSingle ivrTaskcall) {
        List<IvrTaskSingle> list = ivrTaskcallService.selectIvrTaskcallList(ivrTaskcall);
        ExcelUtil<IvrTaskSingle> util = new ExcelUtil<IvrTaskSingle>(IvrTaskSingle.class);
        util.exportExcel(response, list, "单一任务(随访)数据");
    }
 
    /**
     * 获取单一任务(随访)详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:taskcall:query')")
    @GetMapping(value = "/getInfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(ivrTaskcallService.selectIvrTaskcallById(id));
    }
 
    /**
     * 新增或修改删除单一任务
     */
    @ApiOperation("新增或修改删除单一任务")
    @PreAuthorize("@ss.hasPermi('system:task:add')")
    @Log(title = "单一任务(随访)", businessType = BusinessType.INSERT)
    @PostMapping("/insertOrUpdateTask")
    public AjaxResult insertOrUpdateHeTask(@RequestBody IvrTaskSingleVO ivrTaskcallVO) {
        return toAjax(ivrTaskcallService.insertOrUpdateTask(ivrTaskcallVO));
    }
 
 
    /**
     * 根据条件查询任务信息
     */
    @ApiOperation("根据条件查询任务信息")
    @PostMapping("/queryTaskByCondition")
    public AjaxResult queryTaskByCondition(@RequestBody IvrTaskSingleVO ivrTaskcallVO) {
        //根据入参查询信息
        IvrTaskSingle ivrTaskcall = DtoConversionUtils.sourceToTarget(ivrTaskcallVO, IvrTaskSingle.class);
        List<IvrTaskSingle> list = ivrTaskcallService.selectIvrTaskcallList(ivrTaskcall);
 
        //定义患者与单一任务关联表集合
        List<PatTaskRelevance> patTaskRelevances = new ArrayList<>();
 
        //将查出来的数据倒入IvrTaskcallVO中
        IvrTaskSingleVO ivrTaskcallVO2 = DtoConversionUtils.sourceToTarget(list.get(0), IvrTaskSingleVO.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 (IvrTaskSingle 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 IvrTaskSingleVO ivrTaskcallVO) {
        return toAjax(ivrTaskcallService.heTaskSend(ivrTaskcallVO));
    }
 
 
    /**
     * 电话回调任务
     */
    @ApiOperation("电话回调任务")
    @PostMapping("/phoneCallBack")
    public AjaxResult phoneCallBack(@RequestBody PhoneCallBackVO phoneCallBackVO) {
        //如果uuid在redis中找不到,那就直接报异常
        return success(ivrTaskcallService.phoneCallBack(phoneCallBackVO));
    }
 
}