From 124e7de0dc6dd727677fc04c53774c415e8783db Mon Sep 17 00:00:00 2001
From: czt <czt18638530771@163.com>
Date: 星期一, 02 二月 2026 14:07:13 +0800
Subject: [PATCH] 优化代码
---
fzzy-igdss-inte/src/main/java/com/fzzy/igds/api/v1/ApiV1Controller.java | 81 +++++++++++++++++++++++++++++++++++++++-
1 files changed, 78 insertions(+), 3 deletions(-)
diff --git a/fzzy-igdss-inte/src/main/java/com/fzzy/igds/api/v1/ApiV1Controller.java b/fzzy-igdss-inte/src/main/java/com/fzzy/igds/api/v1/ApiV1Controller.java
index 46dc6fd..0148b11 100644
--- a/fzzy-igdss-inte/src/main/java/com/fzzy/igds/api/v1/ApiV1Controller.java
+++ b/fzzy-igdss-inte/src/main/java/com/fzzy/igds/api/v1/ApiV1Controller.java
@@ -2,6 +2,7 @@
import com.fzzy.igds.api.v1.data.ApiV1Req;
import com.fzzy.igds.api.v1.data.ApiV1Resp;
+import com.fzzy.igds.api.v1.data.Param3030;
import com.fzzy.igds.api.v1.service.*;
import com.fzzy.igds.api.v1.util.ApiV1Constant;
import com.fzzy.igds.constant.Constant;
@@ -11,12 +12,16 @@
import lombok.extern.slf4j.Slf4j;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.stereotype.Controller;
+import org.springframework.util.StreamUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
/**
* @Description 鐩戠鎺ュ彛瑙f瀽鍏ュ彛
@@ -45,12 +50,11 @@
@Resource
private ApiV1Service3032 apiV1Service3032;
-
@PostMapping
@ResponseBody
- public ApiV1Resp<Object> gateway(@RequestBody ApiV1Req<JSONObject> req) {
+ public ApiV1Resp<Object> gateway(@RequestBody ApiV1Req<Object> req) {
- log.info("璐ㄦ娂鐩戠鎺ュ彛V1锛屾敹鍒板簱鍖虹綉鍏充俊鎭�={}", req);
+ log.debug("璐ㄦ娂鐩戠鎺ュ彛V1锛屾敹鍒板簱鍖虹綉鍏充俊鎭�={}", req.getFunctionId());
try {
//鍙傛暟鏍¢獙
@@ -102,4 +106,75 @@
}
+ // @PostMapping
+// @ResponseBody
+// public ApiV1Resp<Object> receiveRawRequest(HttpServletRequest request) throws IOException {
+// // 璇诲彇鍘熷璇锋眰浣�
+// String rawJson = StreamUtils.copyToString(request.getInputStream(), StandardCharsets.UTF_8);
+// System.out.println("鍘熷璇锋眰JSON锛�" + rawJson);
+//// System.out.println("绗�92鍒楀瓧绗︼細" + (rawJson.length() >= 92 ? rawJson.charAt(91) : "闀垮害涓嶈冻"));
+// rawJson = cleanInvalidUtf8(rawJson);
+// ApiV1Req<Object> req = JSONObject.parseObject(rawJson, ApiV1Req.class);
+//
+//
+// log.debug("璐ㄦ娂鐩戠鎺ュ彛V1锛屾敹鍒板簱鍖虹綉鍏充俊鎭�={}", req.getFunctionId());
+// try {
+//
+// //鍙傛暟鏍¢獙
+// if (req == null) {
+// return ApiV1Resp.error("鍙傛暟鏈夎锛�", req);
+// }
+//
+// //鏍¢獙鎺ュ彛缂栫爜鍜岀綉鍏砈N
+// if (StringUtils.isEmpty(req.getFunctionId()) || StringUtils.isEmpty(req.getSn())) {
+// return ApiV1Resp.error("鍙傛暟鏈夎锛�", req);
+// }
+//
+// //鏍¢獙缃戝叧鏄惁瀛樺湪
+// GatewaySer gatewaySer = gatewaySerService.getCacheSerById(null, req.getSn());
+// if (null == gatewaySer) {
+// return ApiV1Resp.error("褰撳墠缃戝叧<SN=" + req.getSn() + ">鏆傛湭娣诲姞锛岃鏍告煡锛�", req);
+// }
+//
+// //寮傛鏇存柊缃戝叧鐘舵��
+// gatewaySerService.updateStatus(gatewaySer, Constant.YN_Y, ApiV1Constant.API_FUNCTION_3010.equals(req.getFunctionId()));
+//
+// //瑙f瀽
+// String functionId = req.getFunctionId();
+// switch (functionId) {
+// case ApiV1Constant.API_FUNCTION_3010:
+// return apiV1Service3010.analysis(req, gatewaySer);
+// case ApiV1Constant.API_FUNCTION_3020:
+// return apiV1Service3020.analysis(req, gatewaySer);
+// case ApiV1Constant.API_FUNCTION_3021:
+// return apiV1Service3021.analysis(req, gatewaySer);
+// case ApiV1Constant.API_FUNCTION_3022:
+// return apiV1Service3022.analysis(req, gatewaySer);
+// case ApiV1Constant.API_FUNCTION_3030:
+// return apiV1Service3030.analysis(req, gatewaySer);
+// case ApiV1Constant.API_FUNCTION_3031:
+// return apiV1Service3031.analysis(req, gatewaySer);
+// case ApiV1Constant.API_FUNCTION_3032:
+// return apiV1Service3032.analysis(req, gatewaySer);
+// }
+//
+// return ApiV1Resp.error("鎺ュ彛缂栫爜<" + functionId + ">涓嶅瓨鍦紝璇锋牳鏌ワ紒", req);
+//
+// } catch (Exception e) {
+//
+// log.info("璐ㄦ娂鐩戠鎺ュ彛V1锛屾帴鍙hВ鏋愬紓甯�={}", e.toString());
+//
+// return ApiV1Resp.error("瑙f瀽寮傚父锛�", req);
+// }
+//// // 鍚庣画閫昏緫...
+//// return "success";
+// }
+
+ // 娓呯悊鏃犳晥UTF-8瀛楃鍜屾帶鍒跺瓧绗�
+ public static String cleanInvalidUtf8(String json) {
+ if (json == null) return null;
+ // 绉婚櫎鏃犳晥UTF-8瀛楄妭鍜屾帶鍒跺瓧绗︼紙闄や簡鎹㈣銆佸洖杞︺�佸埗琛ㄧ锛�
+ return json.replaceAll("[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F\\x7F-\\x9F\\xC1]", "");
+ }
+
}
--
Gitblit v1.9.3