|  |  | 
 |  |  |             //宣教 | 
 |  |  |             return xjSend(sendTaskVO); | 
 |  |  |         } | 
 |  |  |         log.error("走到这里了嘛"); | 
 |  |  |         return null; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |         //判断任务是否是立即发送 | 
 |  |  |         if (StringUtils.isNotEmpty(sendTaskVO.getSendType()) && sendTaskVO.getSendType().equals("2")) { | 
 |  |  |             String content = sendMQContent(sendTaskVO, ivrTask.getTemplateid().toString(), ivrTask.getPreachform(), ivrTask.getStopState(), null); | 
 |  |  |             //先修改状态 | 
 |  |  |             updateServiceSubtask(ivrTask.getTaskid(), new Date()); | 
 |  |  |             //立即发送 | 
 |  |  |             redisCache.setCacheObject(content, content, 1, TimeUnit.SECONDS); | 
 |  |  |             //将任务状态修改成执行中 | 
 |  |  | 
 |  |  |                 } catch (JsonProcessingException e) { | 
 |  |  |                     log.error("JsonProcessingException报错了:{}", e.getMessage()); | 
 |  |  |                 } | 
 |  |  |                 Date date = new Date(); | 
 |  |  |                 for (TaskSendTimeVO taskSendTimeVO : taskSendTimeVOList) { | 
 |  |  | //                    //去SendTimeslot中,获取所有的时间段 | 
 |  |  | //                    List<TaskSendTimeVO> list = new ArrayList<>(); | 
 |  |  | //                    list.add(taskSendTimeVO); | 
 |  |  |  | 
 |  |  |                     //获取开始发送时间 | 
 |  |  |                     String begantime = taskSendTimeVO.getBegantime(); | 
 |  |  |                     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 
 |  |  |                     //记录目前到发送时间的毫秒值 (发送时间的毫秒值 - 当前时间的毫秒值) | 
 |  |  |                     Long milliseconds = 1000L; | 
 |  |  |                     try { | 
 |  |  |                         Date date = sdf.parse(begantime); | 
 |  |  |                         date = sdf.parse(begantime); | 
 |  |  |                         milliseconds = date.getTime() - System.currentTimeMillis(); | 
 |  |  |                         System.out.println("日期毫秒数:" + milliseconds); | 
 |  |  |                         SendTaskVO sendTaskVO1 = DtoConversionUtils.sourceToTarget(sendTaskVO, SendTaskVO.class); | 
 |  |  |                         sendTaskVO1.setSendType("1"); | 
 |  |  |                         String content = sendMQContent(sendTaskVO1, ivrTask.getTemplateid().toString(), ivrTask.getPreachform(), ivrTask.getStopState(), taskSendTimeVO); | 
 |  |  |  | 
 |  |  |                         //先修改状态 | 
 |  |  |                         updateServiceSubtask(ivrTask.getTaskid(), date); | 
 |  |  |                         redisCache.setCacheObject(content, content, milliseconds / 1000, TimeUnit.SECONDS); | 
 |  |  |                     } catch (Exception e) { | 
 |  |  |                         e.printStackTrace(); | 
 |  |  | 
 |  |  |         if (StringUtils.isNotEmpty(sendTaskVO.getSendType()) && sendTaskVO.getSendType().equals("2")) { | 
 |  |  |  | 
 |  |  |             String content = sendMQContent(sendTaskVO, serviceTask1.getTemplateid().toString(), serviceTask1.getPreachform(), serviceTask1.getStopState(), null); | 
 |  |  |             //先修改状态 | 
 |  |  |             updateServiceSubtask(serviceTask1.getTaskid(), new Date()); | 
 |  |  |             //立即发送 | 
 |  |  |             redisCache.setCacheObject(content, content, 1, TimeUnit.SECONDS); | 
 |  |  |  | 
 |  |  | 
 |  |  |                 } catch (JsonProcessingException e) { | 
 |  |  |                     log.error("JsonProcessingException报错了:{}", e.getMessage()); | 
 |  |  |                 } | 
 |  |  |                 Date date = new Date(); | 
 |  |  |                 for (TaskSendTimeVO taskSendTimeVO : taskSendTimeVOList) { | 
 |  |  |                     //去SendTimeslot中,获取所有的时间段 | 
 |  |  | //                    List<TaskSendTimeVO> list = new ArrayList<>(); | 
 |  |  | 
 |  |  |                     //记录目前到发送时间的毫秒值 (发送时间的毫秒值 - 当前时间的毫秒值) | 
 |  |  |                     Long milliseconds = 1000L; | 
 |  |  |                     try { | 
 |  |  |                         Date date = sdf.parse(begantime); | 
 |  |  |                         date = sdf.parse(begantime); | 
 |  |  |                         milliseconds = date.getTime() - System.currentTimeMillis(); | 
 |  |  |                         if (milliseconds < 0) { | 
 |  |  |                             milliseconds = 1000L; | 
 |  |  | 
 |  |  |                     SendTaskVO sendTaskVO1 = DtoConversionUtils.sourceToTarget(sendTaskVO, SendTaskVO.class); | 
 |  |  |                     sendTaskVO1.setSendType("1"); | 
 |  |  |                     String content = sendMQContent(sendTaskVO1, serviceTask1.getTemplateid().toString(), serviceTask1.getPreachform(), serviceTask1.getStopState(), taskSendTimeVO); | 
 |  |  |                     //先修改状态 | 
 |  |  |                     updateServiceSubtask(serviceTask1.getTaskid(), date); | 
 |  |  |                     redisCache.setCacheObject(content, content, milliseconds / 1000, TimeUnit.SECONDS); | 
 |  |  |                 } | 
 |  |  |                 //将任务状态修改成执行中 | 
 |  |  | 
 |  |  |         if (StringUtils.isNotEmpty(sendTaskVO.getSendType()) && sendTaskVO.getSendType().equals("2")) { | 
 |  |  |  | 
 |  |  |             String content = sendMQContent(sendTaskVO, serviceTask1.getLibtemplateid().toString(), serviceTask1.getPreachform(), serviceTask1.getStopState(), null); | 
 |  |  |             //先修改状态 | 
 |  |  |             updateServiceSubtask(serviceTask1.getTaskid(), new Date()); | 
 |  |  |             //立即发送 | 
 |  |  |             redisCache.setCacheObject(content, content, 1, TimeUnit.SECONDS); | 
 |  |  |  | 
 |  |  | 
 |  |  |         } else if (StringUtils.isNotEmpty(sendTaskVO.getSendType()) && sendTaskVO.getSendType().equals("1") || StringUtils.isNotEmpty(sendTaskVO.getSendType()) && sendTaskVO.getSendType().equals("3")) { | 
 |  |  |             //时间段发送 | 
 |  |  |             ObjectMapper objectMapper = new ObjectMapper(); | 
 |  |  |             Date date = new Date(); | 
 |  |  |             if (StringUtils.isNotEmpty(serviceTask1.getSendTimeSlot())) { | 
 |  |  |                 List<TaskSendTimeVO> taskSendTimeVOList = null; | 
 |  |  |                 try { | 
 |  |  | 
 |  |  |                     //记录目前到发送时间的毫秒值 (发送时间的毫秒值 - 当前时间的毫秒值) | 
 |  |  |                     Long milliseconds = 1000L; | 
 |  |  |                     try { | 
 |  |  |                         Date date = sdf.parse(begantime); | 
 |  |  |                         date = sdf.parse(begantime); | 
 |  |  |                         milliseconds = date.getTime() - System.currentTimeMillis(); | 
 |  |  |                         System.out.println("日期毫秒数:" + milliseconds); | 
 |  |  |                     } catch (Exception e) { | 
 |  |  | 
 |  |  |                     SendTaskVO sendTaskVO1 = DtoConversionUtils.sourceToTarget(sendTaskVO, SendTaskVO.class); | 
 |  |  |                     sendTaskVO1.setSendType("1"); | 
 |  |  |                     String content = sendMQContent(sendTaskVO1, serviceTask1.getTemplateid().toString(), serviceTask1.getPreachform(), serviceTask1.getStopState(), taskSendTimeVO); | 
 |  |  |                     //先修改状态 | 
 |  |  |                     updateServiceSubtask(serviceTask1.getTaskid(), date); | 
 |  |  |                     redisCache.setCacheObject(content, content, milliseconds / 1000, TimeUnit.SECONDS); | 
 |  |  |                 } | 
 |  |  |                 //将任务状态修改成执行中 | 
 |  |  | 
 |  |  |         commonTaskcallMQJson = commonTaskcallMQJson.substring(1, commonTaskcallMQJson.length() - 1); | 
 |  |  |         return commonTaskcallMQJson; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private void updateServiceSubtask(Long taskId, Date date) { | 
 |  |  |         //只要进入队列就算待发送 | 
 |  |  |         ServiceSubtaskVO serviceSubtaskVO = new ServiceSubtaskVO(); | 
 |  |  |         serviceSubtaskVO.setTaskid(taskId); | 
 |  |  |         serviceSubtaskVO.setSendstate(1L); | 
 |  |  |         List<ServiceSubtask> serviceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskVO); | 
 |  |  |         for (ServiceSubtask serviceSubtask : serviceSubtaskList) { | 
 |  |  |             serviceSubtask.setSendstate(2L); | 
 |  |  |             serviceSubtask.setVisitTime(date); | 
 |  |  |             serviceSubtaskMapper.updateServiceSubtask(serviceSubtask); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  | } |