From 01c9667cfb06970564e837dc343d5cee0eb3aed7 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期三, 24 四月 2024 17:53:42 +0800
Subject: [PATCH] 代码提交

---
 smartor/src/main/java/com/smartor/config/PhoneUtils.java |   33 ++++++++++++++++++++++-----------
 1 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/smartor/src/main/java/com/smartor/config/PhoneUtils.java b/smartor/src/main/java/com/smartor/config/PhoneUtils.java
index a1ca8d3..df4a3dc 100644
--- a/smartor/src/main/java/com/smartor/config/PhoneUtils.java
+++ b/smartor/src/main/java/com/smartor/config/PhoneUtils.java
@@ -1,12 +1,18 @@
 package com.smartor.config;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.ruoyi.common.utils.HttpUtil;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.http.HttpEntity;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.params.HttpMethodParams;
+import org.apache.http.util.EntityUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
+import sun.net.www.http.HttpClient;
 
 import javax.mail.Multipart;
+import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -15,6 +21,9 @@
 
     @Value("${phoneIP}")
     private String phoneIP;
+
+    @Value("${phonePort}")
+    private String phonePort;
 
     /**
      * 娣诲姞鍒嗘満add_user
@@ -165,7 +174,7 @@
     public String getAgentState(String name) {
         Map<String, Object> map = new HashMap<>();
         map.put("name", name);
-        return sendReq(map, "/tel/ai_api/set_agent_state");
+        return sendReq(map, "/tel/ai_api/get_agent_state");
     }
 
     /**
@@ -186,7 +195,7 @@
         map.put("dnis", dnis);
         map.put("force_call", force_call);
         if (force_call == null) map.put("force_call", true);
-        return sendReq(map, "/tel/ai_api/set_agent_state");
+        return sendReq(map, "/tel/ai_api/manual_outbound");
     }
 
     /**
@@ -201,7 +210,7 @@
         map.put("text", fileText);
         map.put("uuid", uuid);
 
-        return sendReq(map, "/tel/ai_api/set_agent_state");
+        return sendReq(map, "/tel/ai_api/tts_playback");
     }
 
     /**
@@ -216,7 +225,7 @@
         map.put("wav_file", wav_file);
         map.put("uuid", uuid);
 
-        return sendReq(map, "/tel/ai_api/set_agent_state");
+        return sendReq(map, "/tel/ai_api/playback");
     }
 
     /**
@@ -224,7 +233,7 @@
      *
      * @return
      */
-    public String ob(String kg_uuid, String kg_file, String data, String app_id, String ani, String special_ch, String sign, String extension, String dnis, Boolean call_uuid, Boolean force_call) {
+    public String ob(String kg_uuid, String kg_file, String data, String app_id, String ani, String special_ch, String sign, String dnis, String call_uuid, Boolean force_call) {
         Map<String, Object> map = new HashMap<>();
         map.put("kg_uuid", kg_uuid);
         map.put("kg_file", kg_file);
@@ -233,14 +242,12 @@
         map.put("ani", ani);
         map.put("special_ch", special_ch);
         map.put("sign", sign);
-        map.put("extension", extension);
         map.put("dnis", dnis);
         map.put("call_uuid", call_uuid);
         map.put("force_call", force_call);
         if (force_call == null) map.put("force_call", true);
-        return sendReq(map, "/tel/ai_api/set_agent_state");
+        return sendReq(map, "/tel/ai_api/outbound");
     }
-
 
     /**
      * 鎸傛柇閫氳瘽
@@ -257,13 +264,17 @@
         map.put("sign", sign);
         map.put("dnis", dnis);
         map.put("call_uuid", call_uuid);
-        return sendReq(map, "/tel/ai_api/set_agent_state");
+        return sendReq(map, "/tel/ai_api/hangup");
     }
 
     private String sendReq(Map<String, Object> map, String path) {
         HttpEntity<Map<String, Object>> req = new HttpEntity<>(getHead(), map);
-        HttpEntity<String> stringHttpEntity = HttpUtil.postJsonRequestV2(phoneIP + path, req, String.class);
-        return stringHttpEntity.getBody();
+        if (StringUtils.isEmpty(phoneIP)) {
+            phoneIP = "http://124.220.50.51";
+            phonePort = "8001";
+        }
+        HttpEntity<String> stringHttpEntity = HttpUtil.postJsonRequestV2(phoneIP + ":" + phonePort + path, req, String.class);
+        return new String(stringHttpEntity.getBody().getBytes(StandardCharsets.UTF_8));
     }
 
     private Map<String, String> getHead() {

--
Gitblit v1.9.3