From d7e3192804fca756d881af360ffd5eea157ef9ad Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期三, 21 十月 2026 15:45:18 +0800
Subject: [PATCH] 【市一】电话挂断服务

---
 ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java |   44 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java
index 0310368..ef2d3f3 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java
@@ -95,6 +95,50 @@
         return httpClient;
     }
 
+    /**
+     * POST JSON锛屽彧鏍¢獙 HTTP 鐘舵�佺爜锛屽厑璁稿搷搴斾綋涓虹┖銆�
+     * <p>
+     * 鐢ㄤ簬 /hangup 杩欑被"鎴愬姛鍙洖 200銆佹病鏈夊搷搴斾綋"鐨勬帴鍙o細
+     * {@link #postJsonRequest(String, String)} 鍦ㄨ鍝嶅簲浣撴椂濡傛灉涓虹┖浼氭姏 RESPONSE_NULL_ERROR_CODE(999994)锛�
+     * 浼氭妸涓�娆℃垚鍔熺殑鎸傛柇璇垽鎴愬け璐ワ紙杩樹細瑙﹀彂鏃犳剰涔夌殑閲嶈瘯锛夈��
+     * <p>
+     * 闈� 2xx 鏃舵姏鍑虹殑 HttpRequestException 閲屽甫涓婄姸鎬佺爜鍜屽搷搴斾綋锛屾柟渚挎帓鏌ャ��
+     *
+     * @param url     璇锋眰鍦板潃
+     * @param request json 璇锋眰浣�
+     */
+    public static void postJsonRequestAllowEmptyResponse(String url, String request) throws HttpRequestException {
+        Assert.hasLength(url, "璇锋眰url涓嶈兘涓虹┖瀛楃涓层��");
+        EntityEnclosingMethod httpMethod = new PostMethod(url);
+        httpMethod.addRequestHeader("Content-Type", "application/json; charset=UTF-8");
+        setHeaderRequestId(httpMethod);
+        try {
+            RequestEntity entity = new StringRequestEntity(request, "application/json", "utf-8");
+            httpMethod.setRequestEntity(entity);
+            int resultCode = httpClient.executeMethod(httpMethod);
+            if (resultCode >= 200 && resultCode < 300) {
+                return;
+            }
+            String respJson = "";
+            try {
+                respJson = httpMethod.getResponseBodyAsString();
+            } catch (Exception ignore) {
+                // 璇讳笉鍒板搷搴斾綋涓嶅奖鍝嶅垽鏂紝鐘舵�佺爜宸茬粡鑳借鏄庨棶棰�
+            }
+            throw new HttpRequestException(resultCode, respJson);
+        } catch (UnsupportedEncodingException e) {
+            throw new HttpRequestException(ENCODING_ERROR_CODE, e);
+        } catch (HttpException e) {
+            throw new HttpRequestException(HTTP_ERROR_CODE, e);
+        } catch (IOException e) {
+            throw new HttpRequestException(IO_ERROR_CODE, e);
+        } finally {
+            if (httpMethod != null) {
+                httpMethod.releaseConnection();
+            }
+        }
+    }
+
     public static Boolean postJsonRequest(String url, String request) throws HttpRequestException {
         Assert.hasLength(url, "璇锋眰url涓嶈兘涓虹┖瀛楃涓层��");
         EntityEnclosingMethod httpMethod = new PostMethod(url);

--
Gitblit v1.9.3