| | |
| | | import com.smartor.common.SendService; |
| | | import com.smartor.config.RobotPhoneUtils; |
| | | import com.smartor.domain.*; |
| | | import com.smartor.mapper.IvrTaskMapper; |
| | | import com.smartor.mapper.IvrTaskSingleMapper; |
| | | import com.smartor.mapper.ServiceSubtaskMapper; |
| | | import com.smartor.mapper.ServiceTaskMapper; |
| | | import com.smartor.mapper.SvyTaskMapper; |
| | | import com.smartor.mapper.SvyTaskSingleMapper; |
| | | import com.smartor.service.IIvrTaskTemplateService; |
| | | import com.smartor.service.IServiceSubtaskRecordService; |
| | | import com.smartor.service.ISvyTaskTemplateService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import org.springframework.data.redis.listener.RedisMessageListenerContainer; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.concurrent.ExecutorService; |
| | | import java.util.concurrent.Executors; |
| | | import java.util.concurrent.TimeUnit; |
| | |
| | | |
| | | private static IIvrTaskTemplateService ivrTaskTemplateService; |
| | | |
| | | private static IvrTaskSingleMapper ivrTaskcallMapper; |
| | | private static ServiceSubtaskMapper ivrTaskcallMapper; |
| | | |
| | | private static IvrTaskMapper ivrTaskMapper; |
| | | private static ServiceTaskMapper ivrTaskMapper; |
| | | |
| | | private static SendService sendService; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private ISvyTaskTemplateService iSvyTaskTemplateService; |
| | | |
| | | @Autowired |
| | | private IServiceSubtaskRecordService serviceSubtaskRecordService; |
| | | |
| | | // 创建固定大小的线程池 |
| | | private static final ExecutorService executorService = Executors.newFixedThreadPool(10); |
| | |
| | | } |
| | | |
| | | @Autowired |
| | | public void setIvrTaskcallMapper(IvrTaskSingleMapper ivrTaskcallMapper) { |
| | | public void setIvrTaskcallMapper(ServiceSubtaskMapper ivrTaskcallMapper) { |
| | | RedisMqReceiver.ivrTaskcallMapper = ivrTaskcallMapper; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setIvrTaskMapper(IvrTaskMapper ivrTaskMapper) { |
| | | public void setIvrTaskMapper(ServiceTaskMapper ivrTaskMapper) { |
| | | RedisMqReceiver.ivrTaskMapper = ivrTaskMapper; |
| | | } |
| | | |
| | |
| | | */ |
| | | private void sfHandle(CommonTaskcallMQ commonTaskcallMQ) { |
| | | //判断一下commonTaskcallMQ中的stopstate是否与ivr_task中的一致,不一致,则说明是暂停了 |
| | | IvrTask ivrTask1 = ivrTaskMapper.selectIvrTaskByTaskid(commonTaskcallMQ.getTaskid()); |
| | | ServiceTask ivrTask1 = ivrTaskMapper.selectServiceTaskByTaskid(commonTaskcallMQ.getTaskid()); |
| | | if (ivrTask1.getStopState() != commonTaskcallMQ.getStopState()) { |
| | | //将消息从队列中剔除 |
| | | return; |
| | |
| | | IvrTaskTemplateVO ivrTaskTemplateVO1 = ivrTaskTemplateService.selectInfoByCondition(ivrTaskTemplateVO); |
| | | |
| | | //通过任务ID拿到患者信息 |
| | | IvrTaskSingle ivrTaskcall = new IvrTaskSingle(); |
| | | ServiceSubtask ivrTaskcall = new ServiceSubtask(); |
| | | ivrTaskcall.setTaskid(commonTaskcallMQ.getTaskid()); |
| | | List<IvrTaskSingle> ivrTaskcalls = ivrTaskcallMapper.selectIvrTaskcallList(ivrTaskcall); |
| | | List<ServiceSubtask> ivrTaskcalls = ivrTaskcallMapper.selectServiceSubtaskList(ivrTaskcall); |
| | | if (descByCode.equals("电话")) { |
| | | for (IvrTaskSingle ivrTaskcall1 : ivrTaskcalls) { |
| | | IvrTask ivrTask = ivrTaskMapper.selectIvrTaskByTaskid(ivrTaskcall1.getTaskid()); |
| | | for (ServiceSubtask ivrTaskcall1 : ivrTaskcalls) { |
| | | ServiceTask ivrTask = ivrTaskMapper.selectServiceTaskByTaskid(ivrTaskcall1.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.setUuid(UUID.randomUUID().toString()); |
| | | serviceSubtaskRecord.setTasktype(ivrTaskcall1.getType()); |
| | | serviceSubtaskRecord.setPreachform("3"); |
| | | serviceSubtaskRecord.setStartTime(System.currentTimeMillis()); |
| | | serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord); |
| | | |
| | | //通过多线程的方式去打电话 |
| | | executorService.submit(new PhoneTask(ivrTaskcall1, ivrTaskTemplateVO1, redisCache, sendService, phonePath, robotPhoneUtils)); |
| | | } |
| | |
| | | String taskId = rsaPublicKeyExample.encryptedData(ivrTask1.getTaskid().toString(), pub_key); |
| | | |
| | | |
| | | for (IvrTaskSingle ivrTaskSingle : ivrTaskcalls) { |
| | | for (ServiceSubtask ivrTaskSingle : ivrTaskcalls) { |
| | | String patid = rsaPublicKeyExample.encryptedData(ivrTaskSingle.getPatid().toString(), pub_key); |
| | | SendMagParam sendMagParam = new SendMagParam(); |
| | | sendMagParam.setType("4"); |
| | | sendMagParam.setUrl(req_path + "/followvisit/particty?param1=" + taskId + "¶m2=" + patid); |
| | | sendService.sendMsg(sendMagParam); |
| | | Boolean aBoolean = sendService.sendMsg(sendMagParam); |
| | | |
| | | //任务发送记录 |
| | | ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); |
| | | serviceSubtaskRecord.setTaskid(ivrTaskSingle.getTaskid().toString()); |
| | | serviceSubtaskRecord.setUuid(UUID.randomUUID().toString()); |
| | | serviceSubtaskRecord.setTasktype(ivrTaskSingle.getType()); |
| | | serviceSubtaskRecord.setPreachform("4"); |
| | | serviceSubtaskRecord.setStartTime(System.currentTimeMillis()); |
| | | serviceSubtaskRecord.setResult(aBoolean == true ? "成功" : "失败"); |
| | | serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord); |
| | | } |
| | | } else if (descByCode.equals("公众号")) { |
| | | //公众号 |
| | | RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample(); |
| | | String taskId = rsaPublicKeyExample.encryptedData(ivrTask1.getTaskid().toString(), pub_key); |
| | | for (IvrTaskSingle ivrTaskSingle : ivrTaskcalls) { |
| | | for (ServiceSubtask ivrTaskSingle : ivrTaskcalls) { |
| | | String patid = rsaPublicKeyExample.encryptedData(ivrTaskSingle.getPatid().toString(), pub_key); |
| | | SendMagParam sendMagParam = new SendMagParam(); |
| | | sendMagParam.setType("5"); |
| | |
| | | Map map = new HashMap(); |
| | | map.put("first", ivrTask1.getTaskName()); |
| | | sendMagParam.setContent(JSON.toJSONString(map)); |
| | | sendService.sendMsg(sendMagParam); |
| | | Boolean aBoolean = sendService.sendMsg(sendMagParam); |
| | | |
| | | //任务发送记录 |
| | | ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); |
| | | serviceSubtaskRecord.setTaskid(ivrTaskSingle.getTaskid().toString()); |
| | | serviceSubtaskRecord.setUuid(UUID.randomUUID().toString()); |
| | | serviceSubtaskRecord.setTasktype(ivrTaskSingle.getType()); |
| | | serviceSubtaskRecord.setPreachform("4"); |
| | | serviceSubtaskRecord.setStartTime(System.currentTimeMillis()); |
| | | serviceSubtaskRecord.setResult(aBoolean == true ? "成功" : "失败"); |
| | | serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord); |
| | | } |
| | | } |
| | | //通知 MQ 消息已被接收,可以ACK(从队列中删除)了 (这个需要根据业务再去处理ACK) |
| | |
| | | //如何任务被“暂停”或“终止” |
| | | break; |
| | | } |
| | | |
| | | //任务发送记录(这个代码应该写在phoneTask中,先写在这,后面再改) |
| | | ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); |
| | | serviceSubtaskRecord.setTaskid(svyTaskSingle1.getTaskid().toString()); |
| | | serviceSubtaskRecord.setUuid(UUID.randomUUID().toString()); |
| | | serviceSubtaskRecord.setTasktype(svyTaskSingle1.getType()); |
| | | serviceSubtaskRecord.setPreachform("3"); |
| | | serviceSubtaskRecord.setStartTime(System.currentTimeMillis()); |
| | | serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord); |
| | | //通过多线程的方式去打电话 |
| | | // executorService.submit(new PhoneTask(ivrTaskcall1, ivrTaskTemplateVO1, redisCache, sendService, phonePath, robotPhoneUtils)); |
| | | } |
| | |
| | | Map map = new HashMap(); |
| | | map.put("first", svyTask.getTaskName()); |
| | | sendMagParam.setContent(JSON.toJSONString(map)); |
| | | sendService.sendMsg(sendMagParam); |
| | | Boolean aBoolean = sendService.sendMsg(sendMagParam); |
| | | |
| | | //任务发送记录 |
| | | ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); |
| | | serviceSubtaskRecord.setTaskid(svyTaskSingle1.getTaskid().toString()); |
| | | serviceSubtaskRecord.setUuid(UUID.randomUUID().toString()); |
| | | serviceSubtaskRecord.setTasktype(svyTaskSingle1.getType()); |
| | | serviceSubtaskRecord.setPreachform("4"); |
| | | serviceSubtaskRecord.setStartTime(System.currentTimeMillis()); |
| | | serviceSubtaskRecord.setResult(aBoolean == true ? "成功" : "失败"); |
| | | serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord); |
| | | } |
| | | } |
| | | //通知 MQ 消息已被接收,可以ACK(从队列中删除)了 (这个需要根据业务再去处理ACK) |