From f67945d53b20f6a45ae50b27d74c966eb1355bb4 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期日, 16 十一月 2025 22:53:54 +0800
Subject: [PATCH] feat: 增加分段GPS计算行程距离
---
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/LegacySystemSyncServiceImpl.java | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 50 insertions(+), 3 deletions(-)
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/LegacySystemSyncServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/LegacySystemSyncServiceImpl.java
index db1fa94..a58c2c8 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/LegacySystemSyncServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/LegacySystemSyncServiceImpl.java
@@ -11,6 +11,11 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.security.cert.X509Certificate;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.service.*;
@@ -977,11 +982,20 @@
}
/**
- * 鍙戦�丠TTP POST璇锋眰
+ * 鍙戦�丠TTP/HTTPS POST璇锋眰
+ * 鏀寔HTTPS鑷鍚嶈瘉涔�
*/
private String sendHttpPost(String urlString, Map<String, String> params) throws Exception {
URL url = new URL(urlString);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+
+ // 濡傛灉鏄疕TTPS璇锋眰锛岄厤缃甋SL淇′换鎵�鏈夎瘉涔�
+ if (conn instanceof HttpsURLConnection) {
+ HttpsURLConnection httpsConn = (HttpsURLConnection) conn;
+ httpsConn.setSSLSocketFactory(createTrustAllSSLContext().getSocketFactory());
+ httpsConn.setHostnameVerifier((hostname, session) -> true); // 淇′换鎵�鏈変富鏈哄悕
+ log.debug("閰嶇疆HTTPS杩炴帴锛屼俊浠绘墍鏈塖SL璇佷功锛孶RL: {}", urlString);
+ }
try {
// 璁剧疆杩炴帴灞炴��
@@ -1027,8 +1041,7 @@
}
} else {
log.error("璇锋眰澶辫触锛岃姹俇RL {},鍙傛暟 {}",urlString,postData);
-
- throw new Exception("HTTP璇锋眰澶辫触锛屽搷搴旂爜: " + responseCode);
+ throw new Exception("HTTP/HTTPS璇锋眰澶辫触锛屽搷搴旂爜: " + responseCode);
}
} finally {
@@ -1037,6 +1050,40 @@
}
/**
+ * 鍒涘缓淇′换鎵�鏈塖SL璇佷功鐨凷SLContext
+ * 鐢ㄤ簬鏀寔鑷鍚嶈瘉涔︾殑HTTPS璇锋眰
+ *
+ * 娉ㄦ剰锛氭鏂规硶浼氫俊浠绘墍鏈塖SL璇佷功锛屽寘鎷嚜绛惧悕璇佷功
+ * 浠呯敤浜庝笌鏃х郴缁熺殑鍐呴儴閫氫俊锛岀敓浜х幆澧冨缓璁娇鐢ㄦ瑙凜A璇佷功
+ */
+ private SSLContext createTrustAllSSLContext() throws Exception {
+ // 鍒涘缓淇′换鎵�鏈夎瘉涔︾殑TrustManager
+ TrustManager[] trustAllCerts = new TrustManager[] {
+ new X509TrustManager() {
+ @Override
+ public X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+
+ @Override
+ public void checkClientTrusted(X509Certificate[] certs, String authType) {
+ // 淇′换鎵�鏈夊鎴风璇佷功
+ }
+
+ @Override
+ public void checkServerTrusted(X509Certificate[] certs, String authType) {
+ // 淇′换鎵�鏈夋湇鍔″櫒璇佷功
+ }
+ }
+ };
+
+ // 瀹夎淇′换鎵�鏈夎瘉涔︾殑TrustManager
+ SSLContext sslContext = SSLContext.getInstance("TLS");
+ sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
+ return sslContext;
+ }
+
+ /**
* 瑙f瀽鏃х郴缁熷搷搴�
* 棰勬湡鏍煎紡: "OK:ServiceOrdID" 鎴栭敊璇俊鎭�
*/
--
Gitblit v1.9.1