|  |  | 
 |  |  | import com.ruoyi.common.utils.RSAPublicKeyExample; | 
 |  |  | import com.ruoyi.common.utils.StringUtils; | 
 |  |  | import com.ruoyi.common.utils.poi.ExcelUtil; | 
 |  |  | import com.smartor.common.SendService; | 
 |  |  | import com.smartor.domain.*; | 
 |  |  | import com.smartor.service.IServiceSubtaskService; | 
 |  |  | import com.smartor.service.IServiceTaskService; | 
 |  |  | 
 |  |  | import org.apache.commons.collections4.CollectionUtils; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.beans.factory.annotation.Value; | 
 |  |  | import org.springframework.security.access.prepost.PreAuthorize; | 
 |  |  | import org.springframework.web.bind.annotation.*; | 
 |  |  |  | 
 |  |  | import javax.servlet.http.HttpServletResponse; | 
 |  |  | import java.io.UnsupportedEncodingException; | 
 |  |  | import java.net.URLDecoder; | 
 |  |  | import java.util.List; | 
 |  |  | import java.util.Map; | 
 |  |  | import java.util.stream.Collectors; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private RSAPublicKeyExample rsaPublicKeyExample; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private SendService sendService; | 
 |  |  |  | 
 |  |  |     @PostMapping("/test") | 
 |  |  |     public TableDataInfo test(@RequestBody SendMagParam sendMagParam) { | 
 |  |  |         try { | 
 |  |  |             Boolean aBoolean = sendService.sendMsg(sendMagParam); | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |         return null; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 查询语音任务列表 | 
 |  |  |      */ | 
 |  |  | 
 |  |  |  | 
 |  |  |         if (CollectionUtils.isNotEmpty(serviceTaskVOS)) { | 
 |  |  |             for (ServiceTaskVO ServiceTaskVO : serviceTaskVOS) { | 
 |  |  |                     ServiceSubtaskVO serviceSubtaskVO = new ServiceSubtaskVO(); | 
 |  |  |                     serviceSubtaskVO.setTaskid(ServiceTaskVO.getTaskid()); | 
 |  |  |                     serviceSubtaskVO.setStartOutHospTime(serviceTask.getStartOutHospTime()); | 
 |  |  |                     serviceSubtaskVO.setEndOutHospTime(serviceTask.getEndOutHospTime()); | 
 |  |  |                     List<ServiceSubtask> ServiceTaskcalls = iServiceTaskCallService.selectServiceSubtaskList(serviceSubtaskVO); | 
 |  |  |                     if (CollectionUtils.isNotEmpty(ServiceTaskcalls)) { | 
 |  |  |                         //已发送 | 
 |  |  |                         long yfs = ServiceTaskcalls.stream().filter(serviceTaskcall1 -> serviceTaskcall1.getSendstate() != null && serviceTaskcall1.getSendstate() == 3L).collect(Collectors.toList()).stream().count(); | 
 |  |  |                         //未发送 | 
 |  |  |                         long wfs = ServiceTaskcalls.stream().filter(serviceTaskcall1 -> serviceTaskcall1.getSendstate() != null && serviceTaskcall1.getSendstate() == 2L).collect(Collectors.toList()).stream().count(); | 
 |  |  |                         ServiceTaskVO.setYfs(yfs); | 
 |  |  |                         ServiceTaskVO.setWfs(wfs); | 
 |  |  |                     } | 
 |  |  |                 ServiceSubtaskVO serviceSubtaskVO = new ServiceSubtaskVO(); | 
 |  |  |                 serviceSubtaskVO.setTaskid(ServiceTaskVO.getTaskid()); | 
 |  |  |                 serviceSubtaskVO.setStartOutHospTime(serviceTask.getStartOutHospTime()); | 
 |  |  |                 serviceSubtaskVO.setEndOutHospTime(serviceTask.getEndOutHospTime()); | 
 |  |  |                 List<ServiceSubtask> ServiceTaskcalls = iServiceTaskCallService.selectServiceSubtaskList(serviceSubtaskVO); | 
 |  |  |                 if (CollectionUtils.isNotEmpty(ServiceTaskcalls)) { | 
 |  |  |                     //已发送(子任务中的 sendstate=1为被领取) | 
 |  |  |                     long yfs = ServiceTaskcalls.stream().filter(serviceTaskcall1 -> (serviceTaskcall1.getSendstate() != null && serviceTaskcall1.getSendstate() >= 3L) || (serviceTaskcall1.getSendstate() != null && serviceTaskcall1.getSendstate() == 1L)).collect(Collectors.toList()).stream().count(); | 
 |  |  |                     //未发送 | 
 |  |  |                     long wfs = ServiceTaskcalls.stream().filter(serviceTaskcall1 -> serviceTaskcall1.getSendstate() != null && serviceTaskcall1.getSendstate() == 2L).collect(Collectors.toList()).stream().count(); | 
 |  |  |                     ServiceTaskVO.setYfs(yfs); | 
 |  |  |                     ServiceTaskVO.setWfs(wfs); | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |             } | 
 |  |  |             //获取total | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 获取随访及时率 | 
 |  |  |      */ | 
 |  |  |     @ApiOperation("获取随访及时率") | 
 |  |  |     //@PreAuthorize("@ss.hasPermi('smartor:ServiceTask:add')") | 
 |  |  |     @Log(title = "获取随访及时率", businessType = BusinessType.INSERT) | 
 |  |  |     @PostMapping("/selectTimelyRate") | 
 |  |  |     public AjaxResult selectTimelyRate(@RequestBody ServiceSubtask serviceSubtask) { | 
 |  |  |         SysUser user = getLoginUser().getUser(); | 
 |  |  |         serviceSubtask.setOrgid(user.getOrgid()); | 
 |  |  |         return success(serviceTaskService.selectTimelyRate(serviceSubtask)); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 修改语音任务 | 
 |  |  |      */ | 
 |  |  |     @ApiOperation("修改任务") | 
 |  |  | 
 |  |  |     public AjaxResult getScriptInfoByCondition(@RequestBody ServiceTaskScriptQues serviceTaskScriptQues) { | 
 |  |  |         Long tid = null; | 
 |  |  |         Long pid = null; | 
 |  |  |         log.error("getScriptInfoByCondition入参为:{}", serviceTaskScriptQues); | 
 |  |  |         log.info("getScriptInfoByCondition入参为:{}", serviceTaskScriptQues); | 
 |  |  |         try { | 
 |  |  |             tid = Long.valueOf(rsaPublicKeyExample.decryptedData(serviceTaskScriptQues.getParam1(), pri_key)); | 
 |  |  |             pid = Long.valueOf(rsaPublicKeyExample.decryptedData(serviceTaskScriptQues.getParam2(), pri_key)); | 
 |  |  | 
 |  |  |             log.error("getScriptInfoByCondition报错了:{}", e.getMessage()); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         log.error("tid和pid的值为:{},{}", tid, pid); | 
 |  |  |         log.info("tid和pid的值为:{},{}", tid, pid); | 
 |  |  |         if (StringUtils.isEmpty(serviceTaskScriptQues.getPatfrom())) serviceTaskScriptQues.setPatfrom("0"); | 
 |  |  |         return success(serviceTaskService.getScriptInfoByCondition(tid, pid, true, serviceTaskScriptQues.getPatfrom())); | 
 |  |  |     } | 
 |  |  | 
 |  |  |             log.error("getScriptInfoByCondition报错了:{}", e.getMessage()); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         log.error("tid和pid的值为:{},{}", tid, pid); | 
 |  |  |         log.info("tid和pid的值为:{},{}", tid, pid); | 
 |  |  |         if (StringUtils.isEmpty(serviceTaskScriptQues.getPatfrom())) serviceTaskScriptQues.setPatfrom("0"); | 
 |  |  |         return success(serviceTaskService.getScriptInfoByCondition(tid, pid, true, serviceTaskScriptQues.getPatfrom())); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 通过任务ID和患者ID获取单个人的题目信息 | 
 |  |  |      * | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @ApiOperation("通过任务ID和诊疗记录号获取单个人的题目信息") | 
 |  |  |     @PostMapping("/getScriptByCondition") | 
 |  |  |     public AjaxResult getScriptByCondition(@RequestBody ServiceTaskScriptQues serviceTaskScriptQues) { | 
 |  |  |         RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample(); | 
 |  |  |         Long taskId = Long.valueOf(rsaPublicKeyExample.decryptedData(serviceTaskScriptQues.getParam1(), pri_key)); | 
 |  |  |         String zyserialnum = null; | 
 |  |  |         String mzserialnum = null; | 
 |  |  |         String tsserialnum = null; | 
 |  |  |         if (StringUtils.isNotEmpty(serviceTaskScriptQues.getParam2())) | 
 |  |  |             zyserialnum = rsaPublicKeyExample.decryptedData(serviceTaskScriptQues.getParam2(), pri_key); | 
 |  |  |         if (StringUtils.isNotEmpty(serviceTaskScriptQues.getParam3())) | 
 |  |  |             mzserialnum = rsaPublicKeyExample.decryptedData(serviceTaskScriptQues.getParam3(), pri_key); | 
 |  |  |         if (StringUtils.isNotEmpty(serviceTaskScriptQues.getParam4())) | 
 |  |  |             tsserialnum = rsaPublicKeyExample.decryptedData(serviceTaskScriptQues.getParam4(), pri_key); | 
 |  |  |         Map<String, Object> scriptByCondition = serviceTaskService.getScriptByCondition(taskId, zyserialnum, mzserialnum, tsserialnum); | 
 |  |  |         scriptByCondition.put("zy", serviceTaskScriptQues.getParam2()); | 
 |  |  |         scriptByCondition.put("mz", serviceTaskScriptQues.getParam3()); | 
 |  |  |         scriptByCondition.put("tid", serviceTaskScriptQues.getParam1()); | 
 |  |  |         return success(scriptByCondition); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } |