liusheng
2024-07-04 bfdc738a7d11d7a132747c52fe51f6887405fae4
smartor/src/main/java/com/smartor/config/PhoneUtils.java
@@ -1,17 +1,13 @@
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.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
@@ -206,6 +202,7 @@
     * @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);
@@ -245,6 +242,7 @@
        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/outbound");
    }
@@ -254,16 +252,36 @@
     *
     * @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);
        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");
    }
@@ -274,6 +292,13 @@
            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));
    }