From bb60b5747d5f4b85655a541d4990ec7464497b1b Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期五, 10 五月 2024 18:18:02 +0800
Subject: [PATCH] 代码提交

---
 smartor/src/main/java/com/smartor/config/PhoneUtils.java |   62 ++++++++++++++++++++++++------
 1 files changed, 49 insertions(+), 13 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..07a7497 100644
--- a/smartor/src/main/java/com/smartor/config/PhoneUtils.java
+++ b/smartor/src/main/java/com/smartor/config/PhoneUtils.java
@@ -7,6 +7,8 @@
 import org.springframework.stereotype.Component;
 
 import javax.mail.Multipart;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -15,6 +17,9 @@
 
     @Value("${phoneIP}")
     private String phoneIP;
+
+    @Value("${phonePort}")
+    private String phonePort;
 
     /**
      * 娣诲姞鍒嗘満add_user
@@ -165,7 +170,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 +191,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");
     }
 
     /**
@@ -197,11 +202,12 @@
      * @return
      */
     public String ttsPlayback(String fileText, String uuid) {
+        System.out.println("=====================闂鍐呭锛�" + fileText + "UUID ; " + uuid);
         Map<String, Object> map = new HashMap<>();
         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 +222,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 +230,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,37 +239,67 @@
         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);
+        map.put("fs_node_id", 8021);
         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");
     }
-
 
     /**
      * 鎸傛柇閫氳瘽
      *
      * @return
      */
-    public String hangup(String kg_uuid, String dnis, String data, String app_id, String ani, String special_ch, String sign, Boolean call_uuid) {
+    public String hangup(String kg_uuid, String dnis, String data, String app_id, String ani, String special_ch, String sign, String call_uuid) {
         Map<String, Object> map = new HashMap<>();
         map.put("kg_uuid", kg_uuid);
+        map.put("kg_file", kg_uuid);
+        map.put("dnis", dnis);
         map.put("data", data);
         map.put("app_id", app_id);
         map.put("ani", ani);
         map.put("special_ch", special_ch);
         map.put("sign", sign);
-        map.put("dnis", dnis);
         map.put("call_uuid", call_uuid);
-        return sendReq(map, "/tel/ai_api/set_agent_state");
+        map.put("fs_node_id", "");
+
+
+//        map.put("app_id", app_id);
+//        map.put("kg_uuid", kg_uuid);
+//        map.put("ani", ani);
+//        map.put("dnis", dnis);
+//        map.put("call_direction", call_direction_str);
+//        map.put("hangup_cause", hangup_cause);
+//        map.put("endpoint_disposition", endpoint_disposition);
+//        map.put("wait_msec", wait_msec);
+//        map.put("duration_msec", duration_msec);
+//        map.put("answer_msec", answer_msec);
+//        map.put("bill_msec", bill_msec);
+//        map.put("start_stamp", start_stamp);
+//        map.put("answered_stamp", answered_stamp);
+//        map.put("end_stamp", end_stamp);
+//        map.put("vad_total_talk_time_msec", vad_total_talk_time_msec);
+//        map.put("time_stamp", time_stamp);
+        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);
+        String responseBody = null;
+        try {
+            responseBody = new String(stringHttpEntity.getBody().getBytes("ISO-8859-1"), "UTF-8");
+            System.out.println(responseBody);
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        return new String(stringHttpEntity.getBody().getBytes(StandardCharsets.UTF_8));
     }
 
     private Map<String, String> getHead() {

--
Gitblit v1.9.3