ai接口改造
This commit is contained in:
parent
a7f9b9c77f
commit
31e2249edd
|
@ -47,7 +47,7 @@ public class AiController {
|
|||
fifteenInfo.setCustomId(temp.getCustomId());
|
||||
List<BusFifteenInfo> list = fifteenInfoService.selectBusFifteenInfoList(fifteenInfo);
|
||||
if (list.size() == 0) {
|
||||
aiService.addAiTask("外卖商户", "客户", ss.split(",")[0], ss.split(",")[1]);
|
||||
aiService.addAiTask(ss.split(",")[0], ss.split(",")[1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,14 +42,14 @@ public class RyTask
|
|||
// }
|
||||
|
||||
/**
|
||||
* 获取订单并解析号码
|
||||
* 获取订单并解析号码 5分钟
|
||||
*/
|
||||
public void getOrders(){
|
||||
iMeituanService.orderInfoList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送AI
|
||||
* 发送AI 1分钟
|
||||
* @throws Exception
|
||||
*/
|
||||
public void sendToAi() throws Exception
|
||||
|
@ -66,13 +66,13 @@ public class RyTask
|
|||
List<BusFifteenInfo> listInfo = fifteenInfoService.selectBusFifteenInfoList(fifteenInfo);
|
||||
if (new Date().getTime() >= sdf.parse(busOrderInfo.getCompleteTime()).getTime()+(10*60*1000)
|
||||
&& listInfo.size() == 0){
|
||||
aiService.addAiTask("外卖商户", "客户",busOrderInfo.getPrivcyPhone().split(",")[0], busOrderInfo.getPrivcyPhone().split(",")[1]);
|
||||
aiService.addAiTask(busOrderInfo.getPrivcyPhone().split(",")[0], busOrderInfo.getPrivcyPhone().split(",")[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取AI结果
|
||||
* 获取AI结果 5分钟
|
||||
*/
|
||||
public void getAiResult() {
|
||||
aiService.queryAiTask();
|
||||
|
|
|
@ -15,7 +15,7 @@ public interface IAiService
|
|||
* @param phoneNo
|
||||
* @param virtualPhone
|
||||
*/
|
||||
R addAiTask(String storeName,String remark,String phoneNo,String virtualPhone);
|
||||
void addAiTask(String phoneNo,String virtualPhone);
|
||||
|
||||
void queryAiTask();
|
||||
|
||||
|
|
|
@ -10,13 +10,11 @@ import com.ruoyi.business.service.*;
|
|||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.utils.HttpClientUtilT;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 代理管理Service业务层处理
|
||||
|
@ -37,9 +35,13 @@ public class AiServiceImpl implements IAiService
|
|||
private IBusAgentInfoService agentInfoService;
|
||||
@Autowired
|
||||
private IBusFifteenInfoService fifteenInfoService;
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
@Override
|
||||
public R addAiTask(String storeName,String remark,String phoneNo, String virtualPhone) {
|
||||
private String userSn = "SYSUSER|8398f13f3feccef770ee4d465fe22fbf";
|
||||
private String projectSn1 = "projects|00dd4cb88fc5f777d5c578c0fdb6b3a0";
|
||||
|
||||
private R login() {
|
||||
String url = "https://ai002.ciopaas.com/api/login";
|
||||
String userName = "zw982210";
|
||||
Map<String, String> header = new HashMap<>();
|
||||
|
@ -51,52 +53,53 @@ public class AiServiceImpl implements IAiService
|
|||
if ("0".equals(jsonObject.getString("code"))){
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
String apiKey = data.getString("api_key");
|
||||
long apiKeyExpire = Long.valueOf(data.getString("api_key_expire"));
|
||||
String userSn = data.getString("user_sn");
|
||||
String projectSn = data.getString("project_sn");
|
||||
System.out.println("login 返回:===========apikey,userSn,projectSn============="+apiKey+","+userSn+","+projectSn);
|
||||
|
||||
String projectSn1 = projectSn.split(",")[1];
|
||||
|
||||
String requestJson = "{\"api_key\": \""+apiKey+"\",\"user_sn\": \""+userSn+"\",\"source\": \""+storeName+"\",\"project_sn\": \""+projectSn1+"\",\"ai_user_sn\": \"SYSUSER|2665bcca63a2b5c724095fa01dce0470\",\"is_zidong\": \"on\",\"client_info_json\": {\"data\": [{\"姓名\": \""+storeName+"\",\"电话\": \""+phoneNo+"\",\"备注\": \"客户\",\"虚拟分机号\": \""+virtualPhone+"\"}]},\"is_open_second_dialing\": \"1\",\n" +
|
||||
"\"is_open_remove_duplication\": \"0\",\"is_append\": \"0\"}";
|
||||
String requestUrl = "https://ai002.ciopaas.com/api/addJsonOfAsync";
|
||||
String requestResult = HttpClientUtilT.doPostJson(requestUrl,header,requestJson);
|
||||
JSONObject jo = JSONObject.parseObject(requestResult);
|
||||
if ("0".equals(jo.getString("code"))){
|
||||
JSONObject data1 = jo.getJSONObject("data");
|
||||
String taskMainId = data1.getString("dial_task_main_id");
|
||||
String taskMainSn = data1.getString("dial_task_main_sn");
|
||||
|
||||
// dialTaskMainSn = taskMainSn;
|
||||
// JSONArray jsonArray = jsonObject.getJSONArray("list");
|
||||
// JSONObject joo = jsonArray.getJSONObject(0);
|
||||
// String taskMainSn1 = joo.getString("dial_task_main_sn");
|
||||
// System.out.println(taskMainSn1);
|
||||
|
||||
|
||||
System.out.println("建立任务返回: ============taskMainId,taskMainSn==========="+taskMainId+","+taskMainSn);
|
||||
|
||||
// try {
|
||||
// Thread.sleep(30000);
|
||||
// } catch (InterruptedException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
//
|
||||
// appendAiTask(phoneNo,virtualPhone,apiKey,userSn,projectSn1,taskMainSn);
|
||||
|
||||
return R.ok();
|
||||
} else {
|
||||
System.out.println("建立任务接口返回错误: " + jo.toString());
|
||||
}
|
||||
redisTemplate.opsForValue().set("apiKey",apiKey,apiKeyExpire);
|
||||
} else {
|
||||
System.out.println("login接口返回错误: " + jsonObject.toString());
|
||||
}
|
||||
return R.fail();
|
||||
}
|
||||
|
||||
private void appendAiTask(String phoneNo, String virtualPhone,String aKey, String uSn,String pSn,String dialTaskMainSn) {
|
||||
public void addAiTask(String phoneNo,String virtualPhone){
|
||||
String apiKey = Optional.ofNullable(redisTemplate.opsForValue().get("apiKey")).orElse(null);
|
||||
if (apiKey == null){
|
||||
login();
|
||||
apiKey = redisTemplate.opsForValue().get("apiKey");
|
||||
}
|
||||
String dialTaskMainSn = Optional.ofNullable(redisTemplate.opsForValue().get("dialTaskMainSn")).orElse(null);
|
||||
if (dialTaskMainSn != null){
|
||||
appendAiTask(apiKey,phoneNo,virtualPhone,dialTaskMainSn);
|
||||
} else {
|
||||
Map<String, String> header = new HashMap<>();
|
||||
header.put("Accept", "application/json");
|
||||
header.put("Content-Type", "application/json;charset=utf-8");
|
||||
String requestJson = "{\"api_key\": \"" + apiKey + "\",\"user_sn\": \"" + userSn + "\",\"source\": \"商户\",\"project_sn\": \"" + projectSn1 + "\",\"ai_user_sn\": \"SYSUSER|2665bcca63a2b5c724095fa01dce0470\",\"is_zidong\": \"on\",\"client_info_json\": {\"data\": [{\"姓名\": \"商户\",\"电话\": \"" + phoneNo + "\",\"备注\": \"客户\",\"虚拟分机号\": \"" + virtualPhone + "\"}]},\"is_open_second_dialing\": \"1\",\n" +
|
||||
"\"is_open_remove_duplication\": \"0\",\"is_append\": \"0\"}";
|
||||
String requestUrl = "https://ai002.ciopaas.com/api/addJsonOfAsync";
|
||||
String requestResult = HttpClientUtilT.doPostJson(requestUrl, header, requestJson);
|
||||
JSONObject jo = JSONObject.parseObject(requestResult);
|
||||
if ("0".equals(jo.getString("code"))) {
|
||||
JSONObject data1 = jo.getJSONObject("data");
|
||||
String taskMainId = data1.getString("dial_task_main_id");
|
||||
String taskMainSn = data1.getString("dial_task_main_sn");
|
||||
|
||||
String requestJson = "{\"api_key\": \"" + aKey + "\",\"user_sn\": \"" + uSn + "\",\"source\": \"测试任务\",\"project_sn\": \"" + pSn + "\",\"ai_user_sn\": \"SYSUSER|2665bcca63a2b5c724095fa01dce0470\",\"is_zidong\": \"on\",\"client_info_json\": {\"data\": [{\"姓名\": \"ws测试\",\"电话\": \"" + phoneNo + "\",\"备注\": \"门店新客\",\"虚拟分机号\": \"" + virtualPhone + "\"}]},\"is_open_second_dialing\": \"1\",\n" +
|
||||
System.out.println("建立任务返回: ============taskMainId,taskMainSn===========" + taskMainId + "," + taskMainSn);
|
||||
|
||||
redisTemplate.opsForValue().set("dialTaskMainSn", taskMainSn);
|
||||
|
||||
} else {
|
||||
System.out.println("建立任务接口返回错误: " + jo.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void appendAiTask(String aKey, String phoneNo, String virtualPhone, String dialTaskMainSn) {
|
||||
|
||||
String requestJson = "{\"api_key\": \"" + aKey + "\",\"user_sn\": \"" + userSn + "\",\"source\": \"测试任务\",\"project_sn\": \"" + projectSn1 + "\",\"ai_user_sn\": \"SYSUSER|2665bcca63a2b5c724095fa01dce0470\",\"is_zidong\": \"on\",\"client_info_json\": {\"data\": [{\"姓名\": \"ws测试\",\"电话\": \"" + phoneNo + "\",\"备注\": \"门店新客\",\"虚拟分机号\": \"" + virtualPhone + "\"}]},\"is_open_second_dialing\": \"1\",\n" +
|
||||
"\"is_open_remove_duplication\": \"0\",\"dial_task_main_sn\": \"" + dialTaskMainSn + "\",\"is_append\": \"1\"}";
|
||||
String requestUrl = "https://ai002.ciopaas.com/api/addJsonOfAsync";
|
||||
Map<String, String> header = new HashMap<>();
|
||||
|
|
Loading…
Reference in New Issue