| | |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.http.HttpUtils; |
| | | import com.ruoyi.common.utils.sign.Md5Utils; |
| | | import com.ruoyi.quartz.util.RandomStringGenerator; |
| | | import com.smartor.common.RandomStringGenerator; |
| | | import com.smartor.common.SendService; |
| | | import com.smartor.config.RobotPhoneUtils; |
| | | import com.smartor.domain.*; |
| | |
| | | private RedisCache redisCache; |
| | | |
| | | @Autowired |
| | | private RobotPhoneUtils robotPhoneUtils; |
| | | |
| | | @Autowired |
| | | private ServiceTaskMapper svyTaskMapper; |
| | | |
| | | @Autowired |
| | | private ServiceSubtaskMapper serviceSubtaskMapper; |
| | | |
| | | @Autowired |
| | | private ISvyTaskTemplateService iSvyTaskTemplateService; |
| | | |
| | | @Autowired |
| | | private IServiceSubtaskRecordService serviceSubtaskRecordService; |
| | |
| | | //如果contains不为true,说明当前的患者已经发送成功,直接循环下一个人就行 |
| | | if (!contains) continue; |
| | | } |
| | | |
| | | try { |
| | | ServiceTask ivrTask = ivrTaskMapper.selectServiceTaskByTaskid(serviceSubtask.getTaskid()); |
| | | if (ivrTask.getSendState() != null && ivrTask.getSendState() == 3 || ivrTask.getSendState() != null && ivrTask.getSendState() == 4) { |
| | |
| | | //短信 |
| | | //对url中两个参数加密 |
| | | RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample(); |
| | | String taskId = rsaPublicKeyExample.encryptedData(ivrTask1.getTaskid().toString(), pub_key); |
| | | |
| | | for (ServiceSubtask serviceSubtask : selectServiceSubtaskList) { |
| | | //先判断一下,subIds是否为空,如果不为空,只执行subIds里的患者 |
| | |
| | | } |
| | | |
| | | try { |
| | | String patid = rsaPublicKeyExample.encryptedData(serviceSubtask.getPatid().toString(), pub_key); |
| | | SendMagParam sendMagParam = new SendMagParam(); |
| | | sendMagParam.setType("4"); |
| | | if (type == 1) { |
| | | //随访 |
| | | ServiceOutPath serviceOutPath = new ServiceOutPath(); |
| | | serviceOutPath.setParam1(taskId); |
| | | serviceOutPath.setParam2(patid); |
| | | serviceOutPath.setCreateTime(new Date()); |
| | | iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | // sendMagParam.setUrl(ip + ":" + req_path + "/followvisit/particty?param1=" + taskId + "¶m2=" + patid + "¶m5=false"); |
| | | //转成16进制 |
| | | String format = String.format("%03X", serviceOutPath.getId()) + RandomStringGenerator.generateRandomString(); |
| | | serviceOutPath.setRadix(format); |
| | | serviceOutPath.setUpdateTime(new Date()); |
| | | iServiceOutPathService.updateServiceOutPath(serviceOutPath); |
| | | sendMagParam.setPhone(serviceSubtask.getPhone()); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/sf?p=" + format); |
| | | sendMagParam.setContent("您好,邀请您填写出院随访调查表,请点击" + sendMagParam.getUrl() + " 填写。感谢您配合!"); |
| | | log.info("888888888888:{}", sendMagParam); |
| | | sendMagParam.setContent("您好,邀请您填写出院随访调查表,请点击" + serviceSubtask.getOutPath() + " 填写。感谢您配合!"); |
| | | } else if (type == 2) { |
| | | //问券(问题) |
| | | ServiceOutPath serviceOutPath = new ServiceOutPath(); |
| | | serviceOutPath.setParam1(taskId); |
| | | serviceOutPath.setParam2(patid); |
| | | // serviceOutPath.setParam3(URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString())); |
| | | serviceOutPath.setParam3(ivrTask1.getTaskName()); |
| | | serviceOutPath.setCreateTime(new Date()); |
| | | iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | String format = String.format("%03X", serviceOutPath.getId()) + RandomStringGenerator.generateRandomString(); |
| | | serviceOutPath.setRadix(format); |
| | | serviceOutPath.setUpdateTime(new Date()); |
| | | iServiceOutPathService.updateServiceOutPath(serviceOutPath); |
| | | |
| | | // sendMagParam.setUrl(ip + ":" + req_path + "/outsideChainwt?param1=" + taskId + "¶m2=" + patid + "¶m3=" + URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()) + "¶m5=false"); |
| | | sendMagParam.setPhone(serviceSubtask.getPhone()); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/wt?p=" + format); |
| | | sendMagParam.setContent("您好,邀请您填写出院调查表,请点击" + sendMagParam.getUrl() + " 填写。感谢您配合!"); |
| | | log.info("您好,邀请您填写出院调查表,请点击,{}", sendMagParam.getUrl()); |
| | | sendMagParam.setContent("您好,邀请您填写出院调查表,请点击" + serviceSubtask.getOutPath() + " 填写。感谢您配合!"); |
| | | } else if (type == 3) { |
| | | //宣教 |
| | | ServiceOutPath serviceOutPath = new ServiceOutPath(); |
| | | serviceOutPath.setParam1(taskId); |
| | | serviceOutPath.setParam2(patid); |
| | | // serviceOutPath.setParam3(URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString())); |
| | | serviceOutPath.setParam3(ivrTask1.getTaskName()); |
| | | serviceOutPath.setCreateTime(new Date()); |
| | | iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | String format = String.format("%03X", serviceOutPath.getId()) + RandomStringGenerator.generateRandomString(); |
| | | serviceOutPath.setRadix(format); |
| | | serviceOutPath.setUpdateTime(new Date()); |
| | | iServiceOutPathService.updateServiceOutPath(serviceOutPath); |
| | | // sendMagParam.setUrl(ip + ":" + req_path + "/outsideChainxj?param1=" + taskId + "¶m2=" + patid + "¶m3=" + URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()) + "¶m5=false"); |
| | | sendMagParam.setPhone(serviceSubtask.getPhone()); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/xj?p=" + format); |
| | | sendMagParam.setContent("您好,邀请您填写出院宣教调查表,请点击" + sendMagParam.getUrl() + "查看。感谢您配合!"); |
| | | log.info("-----------sendMagParam的值为:{}", sendMagParam); |
| | | sendMagParam.setContent("您好,邀请您填写出院宣教调查表,请点击" + serviceSubtask.getOutPath() + "查看。感谢您配合!"); |
| | | } |
| | | //短信还需要模板 |
| | | // Map<String, String> req = new HashMap<>(); |
| | | // req.put("phone", sendMagParam.getPhone()); |
| | | // req.put("content", sendMagParam.getContent()); |
| | | // String s = HttpUtil.postJsonRequest(xhsmsPath, new Gson().toJson(req)); |
| | | //send_mac:签名值,=md5(send_source+send_to_mobiles+send_text+签名编码),32位小写 |
| | | String mac = "shuifang" + sendMagParam.getPhone() + sendMagParam.getContent() + "ShuiFang_jjty_20250106"; |
| | | |
| | | String mac = "shuifang" + serviceSubtask.getPhone() + sendMagParam.getContent() + "ShuiFang_jjty_20250106"; |
| | | |
| | | StringBuilder strb = new StringBuilder(); |
| | | strb.append("send_source=shuifang&send_to_mobiles=" + sendMagParam.getPhone()); |
| | | strb.append("send_source=shuifang&send_to_mobiles=" + serviceSubtask.getPhone()); |
| | | strb.append("&send_text=" + sendMagParam.getContent()); |
| | | strb.append("&send_mac=" + Md5Utils.hash(mac)); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddhhmmsszzz"); // 输出日期格式 |
| | |
| | | serviceSubtask.setRemark("短信发送成功"); |
| | | serviceSubtask.setGuid(uuid); |
| | | serviceSubtask.setSendstate(3L); |
| | | // serviceSubtask.setFinishtime(new Date()); |
| | | serviceSubtaskMapper.updateServiceSubtask(serviceSubtask); |
| | | |
| | | //任务发送记录 |
| | |
| | | sendMagParam.setContent(JSON.toJSONString(map)); |
| | | sendMagParam.setOpenid(serviceSubtask.getOpenid()); |
| | | Boolean aBoolean = sendService.sendMsg(sendMagParam); |
| | | String url = null; |
| | | |
| | | //// if (type == 1) { |
| | | //// url = ip + ":" + req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()) + "¶m5=false"; |
| | | //// } else if (type == 2) { |
| | | //// url = ip + ":" + req_path + "/outsideChainwt?param1=" + taskId + "¶m2=" + patid + "¶m3=" + URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()) + "¶m5=false"; |
| | | //// } else if (type == 3) { |
| | | //// url = ip + ":" + req_path + "/outsideChainxj?param1=" + taskId + "¶m2=" + patid + "¶m3=" + URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()) + "¶m5=false"; |
| | | //// } |
| | | // if (type == 1) { |
| | | // //随访 |
| | | // ServiceOutPath serviceOutPath = new ServiceOutPath(); |
| | | // serviceOutPath.setParam1(taskId); |
| | | // serviceOutPath.setParam2(patid); |
| | | // serviceOutPath.setCreateTime(new Date()); |
| | | // iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | // String format = String.format("%03X", serviceOutPath.getId()); |
| | | // serviceOutPath.setRadix(format); |
| | | // serviceOutPath.setUpdateTime(new Date()); |
| | | // iServiceOutPathService.updateServiceOutPath(serviceOutPath); |
| | | //// sendMagParam.setUrl(ip + ":" + req_path + "/followvisit/particty?param1=" + taskId + "¶m2=" + patid + "¶m5=false"); |
| | | // url = ip + ":" + req_path + "/sf?p=" + format; |
| | | // } else if (type == 2) { |
| | | // //问券 |
| | | // ServiceOutPath serviceOutPath = new ServiceOutPath(); |
| | | // serviceOutPath.setParam1(taskId); |
| | | // serviceOutPath.setParam2(patid); |
| | | //// serviceOutPath.setParam3(URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString())); |
| | | // serviceOutPath.setParam3(ivrTask1.getTaskName()); |
| | | // serviceOutPath.setCreateTime(new Date()); |
| | | // iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | // String format = String.format("%03X", serviceOutPath.getId()); |
| | | // serviceOutPath.setRadix(format); |
| | | // serviceOutPath.setUpdateTime(new Date()); |
| | | // iServiceOutPathService.updateServiceOutPath(serviceOutPath); |
| | | //// sendMagParam.setUrl(ip + ":" + req_path + "/outsideChainwt?param1=" + taskId + "¶m2=" + patid + "¶m3=" + URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()) + "¶m5=false"); |
| | | // url = ip + ":" + req_path + "/wt?p=" + format; |
| | | // } else if (type == 3) { |
| | | // //宣教 |
| | | // ServiceOutPath serviceOutPath = new ServiceOutPath(); |
| | | // serviceOutPath.setParam1(taskId); |
| | | // serviceOutPath.setParam2(patid); |
| | | //// serviceOutPath.setParam3(URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString())); |
| | | // serviceOutPath.setParam3(ivrTask1.getTaskName()); |
| | | // serviceOutPath.setCreateTime(new Date()); |
| | | // iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | // String format = String.format("%03X", serviceOutPath.getId()); |
| | | // serviceOutPath.setRadix(format); |
| | | // serviceOutPath.setUpdateTime(new Date()); |
| | | // iServiceOutPathService.updateServiceOutPath(serviceOutPath); |
| | | // url = ip + ":" + req_path + "/xj?p=" + format; |
| | | // } |
| | | // |
| | | // String wxCode = getWXCode(serviceSubtask.getSfzh(), url, serviceSubtask.getTaskName(), serviceSubtask.getTaskDesc(), "无"); |
| | | // Map<String, Object> map = JSONObject.parseObject(wxCode, Map.class); |
| | | // if (!map.isEmpty()) { |
| | | serviceSubtask.setResult("success"); |
| | | serviceSubtask.setSendstate(3L); |
| | | if (aBoolean == false) { |
| | |
| | | serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord); |
| | | continue; |
| | | } |
| | | // } |
| | | } catch (Exception e) { |
| | | ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); |
| | | serviceSubtaskRecord.setTaskid(serviceSubtask.getTaskid().toString()); |
| | |
| | | serviceSubtask.setRemark("发送失败"); |
| | | serviceSubtask.setSendstate(5L); |
| | | serviceSubtask.setId(id); |
| | | // serviceSubtask.setFinishtime(new Date()); |
| | | serviceSubtaskMapper.updateServiceSubtask(serviceSubtask); |
| | | } |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | // /** |
| | | // * 机器人第一句话语音 |
| | | // * concurrency = "50" 并发数为50 |
| | | // */ |
| | | // @RabbitListener(queues = "ob_queue", concurrency = "50") |
| | | // public void obVisit(String content, Message message, Channel channel) throws IOException { |
| | | // try { |
| | | // IvrTaskcallPhoneMQ commonTaskcallMQ = null; |
| | | // ObjectMapper mapper = new ObjectMapper(); |
| | | // commonTaskcallMQ = mapper.readValue(content, IvrTaskcallPhoneMQ.class); |
| | | // //判断患者是否已经接电话 |
| | | // String str = redisCache.getCacheObject(commonTaskcallMQ.getUuid() + "state_id"); |
| | | // System.out.println("-----------------" + str); |
| | | // if (StringUtils.isNotEmpty(str) && str.equals("0")) { |
| | | // //患者已经接听了电话 |
| | | // new PhoneUtils().ttsPlayback(commonTaskcallMQ.getScript(), commonTaskcallMQ.getUuid()); |
| | | // } else if (StringUtils.isNotEmpty(str) && str.equals("-10")) { |
| | | // //这个说明,已经打了指定遍数还是没有人接,可以将消息从队列中移除了 |
| | | // channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); |
| | | // return; |
| | | // } else { |
| | | // //进行队列尾部,进行下一次校验 |
| | | //// channel.basicRecover(false); |
| | | // channel.basicReject(message.getMessageProperties().getDeliveryTag(), true); |
| | | // System.out.println("++++++++++++++++++++++" + str); |
| | | // return; |
| | | // } |
| | | // //通知 MQ 消息已被接收,可以ACK(从队列中删除)了 (这个需要根据业务再去处理ACK) |
| | | // channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); |
| | | // } catch (Exception e) { |
| | | // log.error("============消费失败,尝试消息补发再次消费!=============="); |
| | | // log.error(e.getMessage()); |
| | | // channel.basicReject(message.getMessageProperties().getDeliveryTag(), true); |
| | | // } |
| | | // } |
| | | private String getKey() { |
| | | Map<String, String> map = new HashMap<>(); |
| | | for (int i = 0; i < 6; i++) { |