| | |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.web.task.PhoneTask; |
| | | import com.ruoyi.web.task.PhoneTask2; |
| | | import com.smartor.common.SendService; |
| | | import com.smartor.config.RabbitMqConfig; |
| | | import com.smartor.domain.IvrLibaTemplateVO; |
| | | import com.smartor.domain.IvrTask; |
| | | import com.smartor.domain.IvrTaskSingle; |
| | | import com.smartor.domain.IvrTaskcallMQ; |
| | | import com.smartor.mapper.IvrTaskMapper; |
| | | import com.smartor.mapper.IvrTaskSingleMapper; |
| | | import com.smartor.service.IIvrLibaTemplateService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | |
| | | private static IvrTaskSingleMapper ivrTaskcallMapper; |
| | | |
| | | private static IvrTaskMapper ivrTaskMapper; |
| | | |
| | | private static SendService sendService; |
| | | |
| | | private static RedisCache redisCache; |
| | | |
| | | // 创建固定大小的线程池 |
| | |
| | | } |
| | | |
| | | @Autowired |
| | | public void setSendService(SendService sendService) { |
| | | RabbitMqReceiver.sendService = sendService; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setIvrTaskcallMapper(IvrTaskSingleMapper ivrTaskcallMapper) { |
| | | RabbitMqReceiver.ivrTaskcallMapper = ivrTaskcallMapper; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setIvrTaskMapper(IvrTaskMapper ivrTaskMapper) { |
| | | RabbitMqReceiver.ivrTaskMapper = ivrTaskMapper; |
| | | } |
| | | |
| | | @Autowired |
| | |
| | | List<IvrTaskSingle> ivrTaskcalls = ivrTaskcallMapper.selectIvrTaskcallList(ivrTaskcall); |
| | | |
| | | for (IvrTaskSingle ivrTaskcall1 : ivrTaskcalls) { |
| | | //通过多线程的方式去打电话 |
| | | executorService.submit(new PhoneTask(ivrTaskcall1, ivrLibaTemplateVO1, redisCache, channel, message)); |
| | | IvrTask ivrTask = ivrTaskMapper.selectIvrTaskByTaskid(ivrTaskcall1.getTaskid()); |
| | | if (StringUtils.isNotEmpty(ivrTask.getSendState()) && ivrTask.getSendState().equals(3) || StringUtils.isNotEmpty(ivrTask.getSendState()) && ivrTask.getSendState().equals(4)) { |
| | | //如何任务被“暂停”或“终止” |
| | | break; |
| | | } |
| | | // //通过多线程的方式去打电话 |
| | | // executorService.submit(new PhoneTask(ivrTaskcall1, ivrLibaTemplateVO1, redisCache, channel, message, sendService)); |
| | | new PhoneTask2().runPhone(ivrTaskcall1, ivrLibaTemplateVO1, redisCache, channel, message, sendService); |
| | | } |
| | | //通知 MQ 消息已被接收,可以ACK(从队列中删除)了 (这个需要根据业务再去处理ACK) |
| | | channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); |