From dbbb114c25b2406b6d1fd52019d2f2228ffcacd0 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期三, 27 十一月 2024 18:04:16 +0800
Subject: [PATCH] 代码提交
---
smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java | 66 ++++++++++++++++++++++++++++++++-
1 files changed, 64 insertions(+), 2 deletions(-)
diff --git a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
index d96e13e..9294e4f 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
@@ -8,6 +8,7 @@
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.*;
import com.smartor.common.FtpService;
+import com.smartor.common.SendService;
import com.smartor.config.PhoneUtils;
import com.smartor.domain.*;
import com.smartor.mapper.*;
@@ -21,6 +22,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
@@ -73,13 +75,22 @@
private IIvrTaskTemplateScriptService iIvrTaskTemplateScriptService;
@Autowired
+ private IServiceOutPathService iServiceOutPathService;
+
+ @Autowired
private FtpService ftpService;
@Value("${pri_key}")
private String pri_key;
+ @Value("${pub_key}")
+ private String pub_key;
+
@Value("${ASRCallBackPath}")
private String ASRCallBackPath;
+
+ @Autowired
+ private SendService sendService;
@Value("${hangup}")
private String hangup;
@@ -93,6 +104,14 @@
@Value("${voicePathPrefix}")
private String voicePathPrefix;
+ @Value("${localIP}")
+ private String localIP;
+
+ @Value("${req_path}")
+ private String req_path;
+
+ @Value("${xhsmsPath}")
+ private String xhsmsPath;
/**
* 鏌ヨ鍗曚竴浠诲姟锛堥殢璁匡級
@@ -708,12 +727,18 @@
public PhoneCallBackYQVO phoneCallBackYQ(PhoneCallReqYQVO phoneCallReqYQVO) {
//鍒ゆ柇鏄惁鎸傛満
String hangupState = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "- hangup");
- if (StringUtils.isNotEmpty(hangupState) && hangup.equals("1")) {
+ Object cacheObject1 = redisCache.getCacheObject(phoneCallReqYQVO.getTaskid() + "recordAccept-hungup");
+ if (StringUtils.isNotEmpty(hangupState) && hangup.equals("1") || ObjectUtils.isNotEmpty(cacheObject1) && String.valueOf(cacheObject1).equals("1")) {
return new PhoneCallBackYQVO();
}
if ("AsrCallback".equals(phoneCallReqYQVO.getOperate()) && phoneCallReqYQVO.getEnd_time() != null && phoneCallReqYQVO.getEnd_time() != -1) {
//澶勭悊鎸傛柇
if (phoneCallReqYQVO.getAsrtext().contains("鎷ㄥ彨鐨勭敤鎴锋蹇�")) {
+ //鍒ゆ柇 recordAccept-hungup 鏄惁鏈夊�硷紝濡傛灉鏈夛紝鍒欒鏄庝笉鐢ㄥ鐞嗕簡锛屼箣鍓嶅凡缁忓鐞嗚繃浜嗭紙recordAccept-hungup杩欎釜涓昏鏄粰鈥滈�氳瘽璁板綍鐢ㄧ殑锛屸�濓級
+ Object cacheObject = redisCache.getCacheObject(phoneCallReqYQVO.getTaskid() + "recordAccept-hungup");
+ if (ObjectUtils.isNotEmpty(cacheObject) && String.valueOf(cacheObject).equals("1")) {
+ return new PhoneCallBackYQVO();
+ }
ServiceSubtask serviceSubtask2 = new ServiceSubtask();
serviceSubtask2.setRemark("鐢佃瘽鍙戦�佹垚鍔燂紙鎮h�呮寕鏂級");
serviceSubtask2.setSenduuid(phoneCallReqYQVO.getUuid());
@@ -724,6 +749,8 @@
req.put("caller", phoneCallReqYQVO.getPhone());
HttpUtil.postJsonRequest(hangup, new Gson().toJson(req));
redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "- hangup", "1", 2, TimeUnit.MINUTES);
+ //杩欎釜鏃跺�欏氨闇�瑕佽蛋琛ュ伩鏈哄埗浜嗭紝鍏堟殏瀹氳蛋鐭俊
+ getSmsCompensate(Long.valueOf(phoneCallReqYQVO.getTaskid()));
return new PhoneCallBackYQVO();
}
}
@@ -754,6 +781,7 @@
HttpUtil.postJsonRequest(hangup, new Gson().toJson(req));
//鍒犻櫎缁撴潫璇殑鎮e瓨
redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "- jsy");
+ redisCache.setCacheObject(phoneCallReqYQVO.getTaskid() + "recordAccept-hungup", "2", 10, TimeUnit.MINUTES);
} else {
redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "PlayEventCallbackPlaystop", true, 120, TimeUnit.MINUTES);
log.error("-------PlayEventCallbackPlaystop鐨勫�间负锛歿}", true);
@@ -1672,7 +1700,9 @@
@Override
public Integer recordAccept(PhoneCallRecordVO phoneCallRecordVO) {
- if (phoneCallRecordVO.getAnswered() != null && phoneCallRecordVO.getAnswered() == true) {
+ Object cacheObject = redisCache.getCacheObject("recordAccept-hungup");
+ if (ObjectUtils.isNotEmpty(cacheObject) && String.valueOf(cacheObject).equals("2")) {
+// if (phoneCallRecordVO.getAnswered() != null && phoneCallRecordVO.getAnswered() == true) {
log.error("鏈変汉鎺ョ數璇濅簡锛屽苟涓斿畬浜�");
//璇存槑鏈変汉鎺ヤ簡
int startIndex = phoneCallRecordVO.getRecord_path().indexOf("voice") + "voice".length() + 1; // 鍔�1鏄烦杩�/绗﹀彿
@@ -1680,7 +1710,11 @@
String result = phoneCallRecordVO.getRecord_path().substring(startIndex, endIndex);
//涓嬭浇鏂囦欢
ftpService.downloadFolder("/" + LocalDate.now().toString(), profile + "/upload/vadio/voice/" + LocalDate.now().toString());
+ } else if (phoneCallRecordVO.getHangup_cause().equals("NO_USER_RESPONSE") || ObjectUtils.isNotEmpty(cacheObject) && !String.valueOf(cacheObject).equals("2")) {
+ //鏃犱汉鎺ュ惉
+ getSmsCompensate(Long.valueOf(phoneCallRecordVO.getTaskid()));
}
+ redisCache.deleteObject("recordAccept-hungup");
return 1;
}
@@ -1772,4 +1806,32 @@
return serviceSubtaskDetail;
}
+ private void getSmsCompensate(Long subTaskId) {
+ ServiceSubtask serviceSubtask = serviceSubtaskMapper.selectServiceSubtaskById(subTaskId);
+ RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample();
+ String taskId = rsaPublicKeyExample.encryptedData(serviceSubtask.getTaskid().toString(), pub_key);
+ String patid = rsaPublicKeyExample.encryptedData(serviceSubtask.getPatid().toString(), pub_key);
+ ServiceOutPath serviceOutPath = new ServiceOutPath();
+ serviceOutPath.setParam1(taskId);
+ serviceOutPath.setParam2(patid);
+ serviceOutPath.setCreateTime(new Date());
+ iServiceOutPathService.insertServiceOutPath(serviceOutPath);
+ //杞垚16杩涘埗
+ String format = String.format("%03X", serviceOutPath.getId());
+ serviceOutPath.setRadix(format);
+ serviceOutPath.setUpdateTime(new Date());
+ iServiceOutPathService.updateServiceOutPath(serviceOutPath);
+ SendMagParam sendMagParam = new SendMagParam();
+ sendMagParam.setUrl(localIP + ":" + req_path + "/sf?p=" + format);
+ sendMagParam.setContent("銆愭柊鍗庡尰闄€�戞偍濂斤紝閭�璇锋偍濉啓鍑洪櫌闅忚璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "濉啓銆傛劅璋㈡偍閰嶅悎锛�");
+ Map<String, String> map = new HashMap<>();
+ map.put("phone", serviceSubtask.getPhone());
+ map.put("content", sendMagParam.getContent());
+ String result = HttpUtil.postJsonRequest(xhsmsPath, new Gson().toJson(map));
+ redisCache.setCacheObject(subTaskId + "recordAccept-hungup", "1", 10, TimeUnit.MINUTES);
+ if (StringUtils.isNotEmpty(serviceSubtask.getRemark()))
+ serviceSubtask.setRemark("鐢佃瘽鍙戦�佹嫆鎺�,鐭俊琛ュ伩鍙戦�佹垚鍔�");
+ else serviceSubtask.setRemark("鐭俊琛ュ伩鍙戦�佹垚鍔�");
+ serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
+ }
}
--
Gitblit v1.9.3