From 259a60f240fdfff356a236d380d8d682949fc571 Mon Sep 17 00:00:00 2001
From: tuqin <tuqin@tuqin.cn>
Date: 星期一, 26 十月 2026 09:24:25 +0800
Subject: [PATCH] feat(环保门禁): 巡检设备数据回传开放接口(无人机/机器人/AI摄像头)、无人值守地磅模块(表+后端+日报)、车辆采集照片字段、修复车辆修改接口缺@RequestBody
---
src/main/java/com/ruoyi/tide/utils/TideUtils.java | 58 ++++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 44 insertions(+), 14 deletions(-)
diff --git a/src/main/java/com/ruoyi/tide/utils/TideUtils.java b/src/main/java/com/ruoyi/tide/utils/TideUtils.java
index 4cac75a..dff51f8 100644
--- a/src/main/java/com/ruoyi/tide/utils/TideUtils.java
+++ b/src/main/java/com/ruoyi/tide/utils/TideUtils.java
@@ -9,6 +9,8 @@
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.security.MessageDigest;
@@ -20,12 +22,29 @@
@Component
@Slf4j
public class TideUtils {
- private final static String appId = "19472937-3039-4bf1-8334-13dc20e076e5";
- private final static String appSecret = "b57bbad60724f810e7bb7e1e7b8791b63eba50e50faef6fa819ade822fac9e4a";
+ public static String APP_ID;
+ public static String APP_SECRET;
+
+
+ @Value("${inspur.appId}")
+ private String appId;
+
+ @Value("${inspur.appSecret}")
+ private String appSecret;
+
+ @Value("${inspur.appId}")
+ public void setAppId(String appId) {
+ TideUtils.APP_ID = appId;
+ }
+
+ @Value("${inspur.appSecret}")
+ public void setAppSecret(String appSecret) {
+ TideUtils.APP_SECRET = appSecret;
+ }
// 鍐呯綉鍦板潃
- private final static String ip = "http://58.56.84.138:8083";
+ private final static String ip = "http://10.136.0.8:8083";
// MD5鍔犲瘑骞惰浆鎹负16杩涘埗
public static String md5Encryption(String input) {
@@ -61,14 +80,14 @@
xSignSplicingTogether = "x-random=" + xRandom + "&x-time=" + xTime;
}
// 閰嶇疆鍔犲瘑鏂瑰紡涓庡瘑閽�
- HMac hMac = new HMac(HmacAlgorithm.HmacSHA256, appSecret.getBytes());
+ HMac hMac = new HMac(HmacAlgorithm.HmacSHA256, APP_SECRET.getBytes());
// 寰楀嚭x-sign
String xSign = hMac.digestHex(xSignSplicingTogether);
HashMap<String, String> result = new HashMap<>();
result.put("x-time", xTime);
result.put("x-random", xRandom);
result.put("x-sign", xSign);
- result.put("appKey", appId);
+ result.put("appKey", APP_ID);
return result;
}
@@ -90,25 +109,25 @@
xSignSplicingTogether = "x-random=" + xRandom + "&x-time=" + xTime;
}
// x-sign 鍔犲瘑
- HMac hMac = new HMac(HmacAlgorithm.HmacSHA256, appSecret.getBytes());
+ HMac hMac = new HMac(HmacAlgorithm.HmacSHA256, APP_SECRET.getBytes());
String xSign = hMac.digestHex(xSignSplicingTogether);
HashMap<String, String> result = new HashMap<>();
result.put("x-time", xTime);
result.put("x-random", xRandom);
result.put("x-sign", xSign);
- result.put("appKey", appId);
+ result.put("appKey", APP_ID);
return result;
}
/**
* 浜斿垎閽熶竴娆$殑蹇冭烦
*/
-// @Scheduled(cron = "0 0/5 * * * ?")
+ @Scheduled(cron = "0 0/5 * * * ?")
public static void heartbeat(){
HashMap<String, String> header = getGetHeader(null);
String url = ip + "/cpn/api/extra/v1/application/heartbeat";
String body = HttpRequest.get(url).headerMap(header, false).execute().body();
- System.out.println(body + "=======MES蹇冭烦鎵ц鎴愬姛锛�");
+ System.out.println(body + "搴旂敤蹇冭烦鎵ц鎴愬姛锛�");
}
// 鑾峰彇token
@@ -116,30 +135,41 @@
String url = ip + "/cpn/extral/applicationCode/appAuthCheck";
JSONObject json = new JSONObject();
json.put("code", code);
- json.put("appID", appId);
- json.put("appSecret", appSecret);
+ json.put("appID", APP_ID);
+ json.put("appSecret", APP_SECRET);
HashMap<String, String> header = getPostHeader(json.toString());
String body = HttpRequest.post(url)
.headerMap(header, false)
.body(json.toString())
.execute().body();
+ log.info("[娴疆SSO] appAuthCheck 杩斿洖: {}", body);
JSONObject jsonObject = JSONObject.parseObject(body);
- return jsonObject.get("data").toString();
+ Object data = jsonObject == null ? null : jsonObject.get("data");
+ return data == null ? null : data.toString();
}
// 鑾峰彇鐢ㄦ埛淇℃伅
public static JSONObject getUserInfo(String token) {
String url = ip + "/cpn/api/extral/applicationCode/getUserInfoByToken";
JSONObject json = new JSONObject();
- json.put("appID", appId);
+ json.put("appID", APP_ID);
HashMap<String, String> header = getPostHeader(json.toString());
header.put("Authorization", token);
String body = HttpRequest.post(url)
.headerMap(header, false)
.body(json.toString())
.execute().body();
+ log.info("[娴疆SSO] getUserInfoByToken 杩斿洖: {}", body);
JSONObject jsonObject = JSONObject.parseObject(body);
- return JSONObject.parseObject(jsonObject.get("data").toString());
+ Object data = jsonObject == null ? null : jsonObject.get("data");
+ if (data == null) {
+ return null;
+ }
+ String dataStr = data.toString();
+ if (dataStr.isEmpty() || "null".equalsIgnoreCase(dataStr)) {
+ return null;
+ }
+ return JSONObject.parseObject(dataStr);
}
public static JSONObject getResult(Integer code, String msg, Object data) {
--
Gitblit v1.9.3