From afb277a81e060c6275f11e9f9f102b5dcfd80a72 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期四, 27 六月 2024 09:46:05 +0800
Subject: [PATCH] 代码提交
---
smartor/src/main/java/com/smartor/service/impl/IvrTaskServiceImpl.java | 99 ++-----------------------------------------------
1 files changed, 4 insertions(+), 95 deletions(-)
diff --git a/smartor/src/main/java/com/smartor/service/impl/IvrTaskServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/IvrTaskServiceImpl.java
index de011f5..cb2053c 100644
--- a/smartor/src/main/java/com/smartor/service/impl/IvrTaskServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/IvrTaskServiceImpl.java
@@ -2,16 +2,17 @@
import java.text.SimpleDateFormat;
import java.util.*;
+import java.util.concurrent.TimeUnit;
import com.alibaba.fastjson2.JSON;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.DtoConversionUtils;
-import com.ruoyi.common.utils.StringUtils;
-import com.smartor.config.RabbitMqCallPhoneConfig;
+import org.apache.commons.lang3.StringUtils;
import com.smartor.domain.*;
import com.smartor.mapper.*;
import lombok.extern.slf4j.Slf4j;
@@ -46,7 +47,7 @@
private IvrLibaTemplateTargetoptionMapper ivrLibaTemplateTargetOptionMapper;
@Autowired
- private RabbitMqCallPhoneConfig rabbitMqCallPhoneConfig;
+ private RedisCache redisCache;
/**
* 鏌ヨ璇煶浠诲姟
@@ -185,97 +186,5 @@
return ivrLibaTemplateScriptVOS;
}
- /**
- * 浠诲姟鍙戦��
- *
- * @return
- */
- @Override
- public int taskSend(SendTaskVO sendTaskVO) {
- if (sendTaskVO.getTaskId() == null) throw new BaseException("浠诲姟ID涓嶈兘涓虹┖锛岃妫�鏌ュ悗锛屽啀杩涜鎵ц");
- IvrTask ivrTask = selectIvrTaskByTaskid(sendTaskVO.getTaskId());
- if (sendTaskVO.getSendState() != null && sendTaskVO.getSendState() == 3 || sendTaskVO.getSendState() != null && sendTaskVO.getSendState() == 4) {
- //浠诲姟鏆傚仠鎴栫粓姝�
- IvrTask ivrTask3 = new IvrTask();
- ivrTask3.setTaskid(sendTaskVO.getTaskId());
- ivrTask3.setStopState(ivrTask.getStopState() + 1);
- ivrTask3.setSendState(sendTaskVO.getSendState());
- updateIvrTask(ivrTask3);
- return 0;
- }
- //鍒ゆ柇鍙戦�佺姸鎬佹槸鍚︿负绌�
- if (org.apache.commons.lang3.StringUtils.isEmpty(sendTaskVO.getSendType())) {
- sendTaskVO.setSendType(ivrTask.getSendType().toString());
- }
- //鍒ゆ柇浠诲姟鏄惁鏄珛鍗冲彂閫�
- if (org.apache.commons.lang3.StringUtils.isNotEmpty(sendTaskVO.getSendType()) && sendTaskVO.getSendType().equals("2")) {
- IvrTaskcallMQ ivrTaskcallMQ = new IvrTaskcallMQ();
- ivrTaskcallMQ.setTaskid(sendTaskVO.getTaskId());
- ivrTaskcallMQ.setSendType(sendTaskVO.getSendType());
- ivrTaskcallMQ.setTemplateid(ivrTask.getTemplateid().toString());
- ivrTaskcallMQ.setPreachform(ivrTask.getPreachform());
- ivrTaskcallMQ.setStopState(ivrTask.getStopState());
-
- String ivrTaskcallMQJson = JSON.toJSONString(ivrTaskcallMQ);
- ivrTaskcallMQJson = ivrTaskcallMQJson.substring(1, ivrTaskcallMQJson.length() - 1);
-
- //绔嬪嵆鍙戦��
- rabbitMqCallPhoneConfig.sendMessage("phone_exchange", "phone.123", ivrTaskcallMQJson, 0L);
-
- //灏嗕换鍔$姸鎬佷慨鏀规垚鎵ц涓�
- IvrTask ivrTask2 = new IvrTask();
- ivrTask2.setTaskid(ivrTask.getTaskid());
- ivrTask2.setSendState(2);
- updateIvrTask(ivrTask2);
- } else if (org.apache.commons.lang3.StringUtils.isNotEmpty(sendTaskVO.getSendType()) && sendTaskVO.getSendType().equals("1")) {
- //鏃堕棿娈靛彂閫�
- ObjectMapper objectMapper = new ObjectMapper();
- if (org.apache.commons.lang3.StringUtils.isNotEmpty(ivrTask.getSendTimeSlot())) {
- List<TaskSendTimeVO> taskSendTimeVOList = null;
- try {
- taskSendTimeVOList = objectMapper.readValue(ivrTask.getSendTimeSlot(), new TypeReference<List<TaskSendTimeVO>>() {
- });
- } catch (JsonProcessingException e) {
- log.error("JsonProcessingException鎶ラ敊浜嗭細{}", e.getMessage());
- }
- for (TaskSendTimeVO taskSendTimeVO : taskSendTimeVOList) {
- //鍘籗endTimeslot涓紝鑾峰彇鎵�鏈夌殑鏃堕棿娈�
- 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);
- milliseconds = date.getTime() - System.currentTimeMillis();
- System.out.println("鏃ユ湡姣鏁帮細" + milliseconds);
- } catch (Exception e) {
- e.printStackTrace();
- }
- IvrTaskcallMQ ivrTaskcallMQ = new IvrTaskcallMQ();
- ivrTaskcallMQ.setTaskid(sendTaskVO.getTaskId());
- ivrTaskcallMQ.setSendType("1");
- ivrTaskcallMQ.setTemplateid(ivrTask.getTemplateid().toString());
- ivrTaskcallMQ.setSendTimeslot(list);
- ivrTaskcallMQ.setStopState(ivrTask.getStopState());
- ivrTaskcallMQ.setPreachform(ivrTask.getPreachform());
-
- Long finalMilliseconds = milliseconds;
- String ivrTaskcallMQJson = JSON.toJSONString(ivrTaskcallMQ);
- ivrTaskcallMQJson = ivrTaskcallMQJson.substring(1, ivrTaskcallMQJson.length() - 1);
- rabbitMqCallPhoneConfig.sendMessage("phone_exchange", "phone.123", ivrTaskcallMQJson, milliseconds);
- }
- //灏嗕换鍔$姸鎬佷慨鏀规垚鎵ц涓�
- IvrTask ivrTask2 = new IvrTask();
- ivrTask2.setTaskid(ivrTask.getTaskid());
- ivrTask2.setSendState(2);
- updateIvrTask(ivrTask2);
- }
- }
- return 1;
- }
}
--
Gitblit v1.9.3