| | |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.enums.ServiceFromEnum; |
| | | import com.ruoyi.common.utils.IPUtils; |
| | | import com.ruoyi.common.utils.RSAPublicKeyExample; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.web.task.PhoneTask; |
| | |
| | | import org.springframework.data.redis.connection.Message; |
| | | import org.springframework.data.redis.listener.KeyExpirationEventMessageListener; |
| | | import org.springframework.data.redis.listener.RedisMessageListenerContainer; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.*; |
| | | import javax.annotation.Syntax; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | import java.util.concurrent.ExecutorService; |
| | | import java.util.concurrent.Executors; |
| | | import java.util.concurrent.TimeUnit; |
| | |
| | | @Value("${pub_key}") |
| | | private String pub_key; |
| | | |
| | | @Value("${localIP}") |
| | | private String localIP; |
| | | |
| | | @Value("${req_path}") |
| | | private String req_path; |
| | | |
| | | private static IIvrTaskTemplateService ivrTaskTemplateService; |
| | | @Autowired |
| | | private IIvrTaskTemplateService ivrTaskTemplateService; |
| | | |
| | | private static ServiceSubtaskMapper ivrTaskcallMapper; |
| | | @Autowired |
| | | private ServiceSubtaskMapper ivrTaskcallMapper; |
| | | |
| | | private static ServiceTaskMapper ivrTaskMapper; |
| | | @Autowired |
| | | private ServiceTaskMapper ivrTaskMapper; |
| | | |
| | | private static SendService sendService; |
| | | @Autowired |
| | | private SendService sendService; |
| | | |
| | | private static RedisCache redisCache; |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | | |
| | | private static RobotPhoneUtils robotPhoneUtils; |
| | | @Autowired |
| | | private RobotPhoneUtils robotPhoneUtils; |
| | | |
| | | @Autowired |
| | | private SvyTaskMapper svyTaskMapper; |
| | |
| | | super(listenerContainer); |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | public void setIIvrTaskTemplateService(IIvrTaskTemplateService ivrTaskTemplateService) { |
| | | RedisMqReceiver.ivrTaskTemplateService = ivrTaskTemplateService; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setRobotPhoneUtilsService(RobotPhoneUtils robotPhoneUtils) { |
| | | RedisMqReceiver.robotPhoneUtils = robotPhoneUtils; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setSendService(SendService sendService) { |
| | | RedisMqReceiver.sendService = sendService; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setIvrTaskcallMapper(ServiceSubtaskMapper ivrTaskcallMapper) { |
| | | RedisMqReceiver.ivrTaskcallMapper = ivrTaskcallMapper; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setIvrTaskMapper(ServiceTaskMapper ivrTaskMapper) { |
| | | RedisMqReceiver.ivrTaskMapper = ivrTaskMapper; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setRedisCache(RedisCache redisCache) { |
| | | RedisMqReceiver.redisCache = redisCache; |
| | | } |
| | | |
| | | @Override |
| | | public void onMessage(Message message, byte[] pattern) { |
| | | log.info("监听Redis key过期,key:{},channel:{}", message.toString(), new String(pattern)); |
| | | String ip = "116.62.18.175"; |
| | | String ip = localIP; |
| | | log.error("本机的网络IP为:{}", ip); |
| | | String content = message.toString(); |
| | | //判断是不是任务信息,如果不是,直接返回,不需要执行 |
| | |
| | | //宣教 |
| | | xjHandle(commonTaskcallMQ, ip); |
| | | } |
| | | |
| | | //处理完成,移除redis |
| | | redisCache.deleteObject(message.toString()); |
| | | |
| | | } catch (Exception e) { |
| | | Integer integer = redisCache.getCacheObject(commonTaskcallMQ.getTaskid().toString()); |
| | |
| | | log.error("============消费失败,尝试消息补发再次消费!============== {}", e.getMessage()); |
| | | redisCache.setCacheObject(message.toString(), message.toString(), 60, TimeUnit.SECONDS); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | //通过模板ID获取模板问题 |
| | | IvrTaskTemplateVO ivrTaskTemplateVO = new IvrTaskTemplateVO(); |
| | | ivrTaskTemplateVO.setID(Long.valueOf(commonTaskcallMQ.getTemplateid())); |
| | | ivrTaskTemplateVO.setId(Long.valueOf(commonTaskcallMQ.getTemplateid())); |
| | | IvrTaskTemplateVO ivrTaskTemplateVO1 = ivrTaskTemplateService.selectInfoByCondition(ivrTaskTemplateVO); |
| | | |
| | | //通过任务ID拿到患者信息 |
| | | ServiceSubtask ivrTaskcall = new ServiceSubtask(); |
| | | ivrTaskcall.setTaskid(commonTaskcallMQ.getTaskid()); |
| | | List<ServiceSubtask> ivrTaskcalls = ivrTaskcallMapper.selectServiceSubtaskList(ivrTaskcall); |
| | | List<ServiceSubtask> selectServiceSubtaskList = ivrTaskcallMapper.selectServiceSubtaskList(ivrTaskcall); |
| | | if (descByCode.equals("电话")) { |
| | | for (ServiceSubtask ivrTaskcall1 : ivrTaskcalls) { |
| | | ServiceTask ivrTask = ivrTaskMapper.selectServiceTaskByTaskid(ivrTaskcall1.getTaskid()); |
| | | for (ServiceSubtask serviceSubtask : selectServiceSubtaskList) { |
| | | ServiceTask ivrTask = ivrTaskMapper.selectServiceTaskByTaskid(serviceSubtask.getTaskid()); |
| | | if (ivrTask.getSendState() != null && ivrTask.getSendState() == 3 || ivrTask.getSendState() != null && ivrTask.getSendState() == 4) { |
| | | //如何任务被“暂停”或“终止” |
| | | break; |
| | |
| | | |
| | | //任务发送记录(这个代码应该写在phoneTask中,先写在这,后面再改) |
| | | ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); |
| | | serviceSubtaskRecord.setTaskid(ivrTaskcall1.getTaskid().toString()); |
| | | serviceSubtaskRecord.setTaskid(serviceSubtask.getTaskid().toString()); |
| | | serviceSubtaskRecord.setUuid(UUID.randomUUID().toString()); |
| | | serviceSubtaskRecord.setTasktype(ivrTaskcall1.getType()); |
| | | serviceSubtaskRecord.setTasktype(serviceSubtask.getType()); |
| | | serviceSubtaskRecord.setPreachform("3"); |
| | | serviceSubtaskRecord.setStartTime(System.currentTimeMillis()); |
| | | serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord); |
| | | |
| | | //通过多线程的方式去打电话 |
| | | executorService.submit(new PhoneTask(ivrTaskcall1, ivrTaskTemplateVO1, redisCache, sendService, phonePath, robotPhoneUtils)); |
| | | executorService.submit(new PhoneTask(serviceSubtask, ivrTaskTemplateVO1, redisCache, sendService, phonePath, robotPhoneUtils)); |
| | | } |
| | | } else if (descByCode.equals("多媒体")) { |
| | | //多媒体 |
| | | return; |
| | | } else if (descByCode.equals("纸质")) { |
| | | //纸质 |
| | | return; |
| | | } else if (descByCode.equals("短信")) { |
| | | //短信 |
| | | // http://localhost:8099/followvisit/particty?param1=3¶m2=348 |
| | |
| | | RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample(); |
| | | String taskId = rsaPublicKeyExample.encryptedData(ivrTask1.getTaskid().toString(), pub_key); |
| | | |
| | | for (ServiceSubtask ivrTaskSingle : ivrTaskcalls) { |
| | | String patid = rsaPublicKeyExample.encryptedData(ivrTaskSingle.getPatid().toString(), pub_key); |
| | | for (ServiceSubtask serviceSubtask : selectServiceSubtaskList) { |
| | | String patid = rsaPublicKeyExample.encryptedData(serviceSubtask.getPatid().toString(), pub_key); |
| | | SendMagParam sendMagParam = new SendMagParam(); |
| | | sendMagParam.setType("4"); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/followvisit/particty?param1=" + taskId + "¶m2=" + patid); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/followvisit/particty?param1=" + taskId + "¶m2=" + patid + "¶m5=false"); |
| | | Boolean aBoolean = sendService.sendMsg(sendMagParam); |
| | | |
| | | |
| | | //任务发送记录 |
| | | ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); |
| | | serviceSubtaskRecord.setTaskid(ivrTaskSingle.getTaskid().toString()); |
| | | serviceSubtaskRecord.setTaskid(serviceSubtask.getTaskid().toString()); |
| | | serviceSubtaskRecord.setUuid(UUID.randomUUID().toString()); |
| | | serviceSubtaskRecord.setTasktype(ivrTaskSingle.getType()); |
| | | serviceSubtaskRecord.setTasktype(serviceSubtask.getType()); |
| | | serviceSubtaskRecord.setPreachform("4"); |
| | | serviceSubtaskRecord.setStartTime(System.currentTimeMillis()); |
| | | serviceSubtaskRecord.setResult(aBoolean == true ? "成功" : "失败"); |
| | |
| | | //公众号 |
| | | RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample(); |
| | | String taskId = rsaPublicKeyExample.encryptedData(ivrTask1.getTaskid().toString(), pub_key); |
| | | for (ServiceSubtask ivrTaskSingle : ivrTaskcalls) { |
| | | String patid = rsaPublicKeyExample.encryptedData(ivrTaskSingle.getPatid().toString(), pub_key); |
| | | for (ServiceSubtask serviceSubtask : selectServiceSubtaskList) { |
| | | String patid = rsaPublicKeyExample.encryptedData(serviceSubtask.getPatid().toString(), pub_key); |
| | | SendMagParam sendMagParam = new SendMagParam(); |
| | | sendMagParam.setType("5"); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/outsideChain?param1=" + ivrTask1.getTaskid().toString() + "¶m2=" + ivrTaskSingle.getPatid().toString() + "¶m3=" + ivrTask1.getTaskName()); |
| | | log.info("链接完整路径:{}", req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + ivrTask1.getTaskName()); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/outsideChain?param1=" + ivrTask1.getTaskid().toString() + "¶m2=" + serviceSubtask.getPatid().toString() + "¶m3=" + ivrTask1.getTaskName() + "¶m5=false"); |
| | | log.info("链接完整路径:{}", ip + ":" + req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + ivrTask1.getTaskName() + "¶m5=false"); |
| | | //这个模板ID先写死,后面做成可选 |
| | | sendMagParam.setTmpCode("oG3pJHPVWpE81DmZsua_2tKwgJ97r0qz37z56ns7NB4"); |
| | | Map map = new HashMap(); |
| | | map.put("first", ivrTask1.getTaskName()); |
| | | sendMagParam.setContent(JSON.toJSONString(map)); |
| | | sendMagParam.setOpenid(serviceSubtask.getOpenid()); |
| | | |
| | | Boolean aBoolean = sendService.sendMsg(sendMagParam); |
| | | |
| | | //任务发送记录 |
| | | ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); |
| | | serviceSubtaskRecord.setTaskid(ivrTaskSingle.getTaskid().toString()); |
| | | serviceSubtaskRecord.setTaskid(serviceSubtask.getTaskid().toString()); |
| | | serviceSubtaskRecord.setUuid(UUID.randomUUID().toString()); |
| | | serviceSubtaskRecord.setTasktype(ivrTaskSingle.getType()); |
| | | serviceSubtaskRecord.setTasktype(serviceSubtask.getType()); |
| | | serviceSubtaskRecord.setPreachform("4"); |
| | | serviceSubtaskRecord.setStartTime(System.currentTimeMillis()); |
| | | serviceSubtaskRecord.setResult(aBoolean == true ? "成功" : "失败"); |
| | |
| | | |
| | | //通过模板ID获取模板问题 |
| | | IvrTaskTemplateVO ivrTaskTemplateVO = new IvrTaskTemplateVO(); |
| | | ivrTaskTemplateVO.setID(Long.valueOf(commonTaskcallMQ.getTemplateid())); |
| | | ivrTaskTemplateVO.setId(Long.valueOf(commonTaskcallMQ.getTemplateid())); |
| | | IvrTaskTemplateVO ivrTaskTemplateVO1 = ivrTaskTemplateService.selectInfoByCondition(ivrTaskTemplateVO); |
| | | |
| | | //通过任务ID拿到患者信息 |
| | |
| | | String patid = rsaPublicKeyExample.encryptedData(ivrTaskSingle.getPatid().toString(), pub_key); |
| | | SendMagParam sendMagParam = new SendMagParam(); |
| | | sendMagParam.setType("4"); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/followvisit/particty?param1=" + taskId + "¶m2=" + patid); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/followvisit/particty?param1=" + taskId + "¶m2=" + patid + "¶m5=false"); |
| | | Boolean aBoolean = sendService.sendMsg(sendMagParam); |
| | | |
| | | //任务发送记录 |
| | |
| | | String patid = rsaPublicKeyExample.encryptedData(ivrTaskSingle.getPatid().toString(), pub_key); |
| | | SendMagParam sendMagParam = new SendMagParam(); |
| | | sendMagParam.setType("5"); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + ivrTask1.getTaskName()); |
| | | log.info("链接完整路径:{}", req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + ivrTask1.getTaskName()); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + ivrTask1.getTaskName() + "¶m5=false"); |
| | | log.info("链接完整路径:{}", req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + ivrTask1.getTaskName() + "¶m5=false"); |
| | | //这个模板ID先写死,后面做成可选 |
| | | sendMagParam.setTmpCode("oG3pJHPVWpE81DmZsua_2tKwgJ97r0qz37z56ns7NB4"); |
| | | Map map = new HashMap(); |
| | |
| | | String patid = rsaPublicKeyExample.encryptedData(svyTaskSingle1.getPatid().toString(), pub_key); |
| | | SendMagParam sendMagParam = new SendMagParam(); |
| | | sendMagParam.setType("5"); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + svyTask.getTaskName()); |
| | | log.info("链接完整路径:{}", req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + svyTask.getTaskName()); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + svyTask.getTaskName() + "¶m5=false"); |
| | | log.info("链接完整路径:{}", req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + svyTask.getTaskName() + "¶m5=false"); |
| | | //这个模板ID先写死,后面做成可选 |
| | | sendMagParam.setTmpCode("oG3pJHPVWpE81DmZsua_2tKwgJ97r0qz37z56ns7NB4"); |
| | | Map map = new HashMap(); |