From 9ca146e7afa543d2c516a91c95929d34aa48a52c Mon Sep 17 00:00:00 2001
From: cl <1442464845@qq.com>
Date: 星期四, 16 四月 2026 11:45:23 +0800
Subject: [PATCH] 电视机提醒
---
rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/WmsRcsController.java | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 102 insertions(+), 7 deletions(-)
diff --git a/rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/WmsRcsController.java b/rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/WmsRcsController.java
index 4a4dcb8..eace48f 100644
--- a/rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/WmsRcsController.java
+++ b/rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/WmsRcsController.java
@@ -5,19 +5,28 @@
import com.vincent.rsf.openApi.entity.dto.CommonResponse;
import com.vincent.rsf.openApi.entity.params.ExMsgCallbackParams;
import com.vincent.rsf.openApi.entity.params.LocSiteParams;
+import com.vincent.rsf.openApi.entity.params.LocationAllocateParams;
import com.vincent.rsf.openApi.entity.params.RcsPubTaskParams;
import com.vincent.rsf.openApi.entity.params.SyncRcsLocsParam;
import com.vincent.rsf.openApi.entity.params.TaskReportParams;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.vincent.rsf.httpaudit.support.HttpAuditSupport;
import com.vincent.rsf.openApi.service.WmsRcsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
+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.RestController;
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.nio.charset.Charset;
import java.util.Map;
import java.util.Objects;
@@ -27,8 +36,64 @@
@RequestMapping("/rcs")
public class WmsRcsController {
+ private static final String API_AGV_ERROR = "RCS-AGV寮傚父涓婃姤锛堜粎鎺ユ敹锛�";
+ private static final String API_PUB_TASK = "璋冨害浠诲姟涓嬪彂";
+ private static final String API_CANCEL_TASK = "鍙栨秷璋冨害浠诲姟";
+ private static final String API_CALLBACK_EVENT = "鐘舵�佷笂鎶ュ洖璋�";
+ private static final String API_SYNC_LOCS = "RCS搴撲綅淇℃伅鍚屾";
+ private static final String API_MODIFY_STATUS = "RCS淇敼搴撲綅鎴栫珯鐐圭姸鎬�";
+ private static final String API_TASK_REPORT = "RCS鍥炶皟鎺ュ彛";
+ private static final String API_ALLOCATE = "RCS-鐢宠鍏ュ簱浠诲姟";
+
@Autowired
private WmsRcsService wmsRcsService;
+
+ @Resource
+ private ObjectMapper objectMapper;
+
+ /**
+ * RCS AGV 寮傚父涓婃姤锛氬師鏍锋帴鏀惰姹備綋锛屾墦鏃ュ織锛沨ttp-audit 闇�閰嶇疆 URI 鐧藉悕鍗曡 version/db
+ */
+ @ApiOperation(API_AGV_ERROR)
+ @PostMapping("/api/open/agvError")
+ public CommonResponse agvError(HttpServletRequest request) throws IOException {
+ Charset charset = HttpAuditSupport.resolveCharset(request);
+ String body = StreamUtils.copyToString(request.getInputStream(), charset);
+ log.info("RCS POST /rcs/api/open/agvError | {} contentType={} charset={} bytes={}\n{}",
+ API_AGV_ERROR,
+ request.getContentType(),
+ charset.name(),
+ body.getBytes(charset).length,
+ formatBodyForLog(body));
+ return CommonResponse.ok();
+ }
+
+ private String formatBodyForLog(String body) {
+ if (body.isEmpty()) {
+ return "(empty body)";
+ }
+ try {
+ JsonNode n = objectMapper.readTree(body);
+ return objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(n);
+ } catch (Exception e) {
+ int max = 16384;
+ return body.length() > max ? body.substring(0, max) + "...(truncated,len=" + body.length() + ")" : body;
+ }
+ }
+
+ /** RCS 鍏ョ珯璇锋眰浣撴墦鏃ュ織锛堝惈 @ApiOperation 涓枃璇存槑锛� */
+ private void logRcsRequest(String action, String apiOperationValue, Object body) {
+ if (body == null) {
+ log.info("RCS {} | {} request body=null", action, apiOperationValue);
+ return;
+ }
+ try {
+ log.info("RCS {} | {} request:\n{}", action, apiOperationValue,
+ objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(body));
+ } catch (Exception e) {
+ log.info("RCS {} | {} request: {}", action, apiOperationValue, body);
+ }
+ }
/**
* @author Ryan
@@ -36,9 +101,10 @@
* @description: 浠诲姟涓嬪彂
* @version 1.0
*/
- @ApiOperation("璋冨害浠诲姟涓嬪彂")
+ @ApiOperation(API_PUB_TASK)
@PostMapping("/pub/task")
public CommonResponse pubTasks(@RequestBody RcsPubTaskParams params) {
+ logRcsRequest("POST /rcs/pub/task", API_PUB_TASK, params);
if (Objects.isNull(params)) {
throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒");
}
@@ -51,9 +117,10 @@
* @description: 鍙栨秷浠诲姟
* @version 1.0
*/
- @ApiOperation("鍙栨秷璋冨害浠诲姟")
+ @ApiOperation(API_CANCEL_TASK)
@PostMapping("/cancel/task")
public CommonResponse cancelTasks(@RequestBody Map<String, Object> params) {
+ logRcsRequest("POST /rcs/cancel/task", API_CANCEL_TASK, params);
return wmsRcsService.cancelTasks(params);
}
@@ -63,9 +130,10 @@
* @description: 浠诲姟鍥炶皟锛岀姸鎬佸洖鍐�
* @version 1.0
*/
- @ApiOperation("鐘舵�佷笂鎶ュ洖璋�")
+ @ApiOperation(API_CALLBACK_EVENT)
@PostMapping("/callback/event")
public CommonResponse callBackEvent(@RequestBody ExMsgCallbackParams params) {
+ logRcsRequest("POST /rcs/callback/event", API_CALLBACK_EVENT, params);
return wmsRcsService.callBackEvent(params);
}
@@ -76,9 +144,10 @@
* @description: RCS搴撲綅淇℃伅鍚屾
* @version 1.0
*/
- @ApiOperation("RCS搴撲綅淇℃伅鍚屾")
+ @ApiOperation(API_SYNC_LOCS)
@PostMapping("/sync/locs")
public R syncLocsToWms(@RequestBody SyncRcsLocsParam params) {
+ logRcsRequest("POST /rcs/sync/locs", API_SYNC_LOCS, params);
if (Objects.isNull(params)) {
return R.error("鍙傛暟涓嶈兘涓虹┖锛侊紒");
}
@@ -91,9 +160,10 @@
* @description: WMS 鍑哄簱鎴愬姛鍚庯紝淇敼搴撲綅銆佺珯鐐圭姸鎬�
* @version 1.0
*/
- @ApiOperation("RCS淇敼搴撲綅鎴栫珯鐐圭姸鎬�")
+ @ApiOperation(API_MODIFY_STATUS)
@PostMapping("/modify/status")
public R modifyLocOrSite(@RequestBody LocSiteParams params) {
+ logRcsRequest("POST /rcs/modify/status", API_MODIFY_STATUS, params);
if (Objects.isNull(params)) {
return R.error("鍙傛暟涓嶈兘涓虹┖锛侊紒");
}
@@ -106,14 +176,39 @@
* @description: RCS鍥炶皟鎺ュ彛
* @version 1.0
*/
- @ApiOperation("RCS鍥炶皟鎺ュ彛")
+ @ApiOperation(API_TASK_REPORT)
@PostMapping("/api/open/task/report")
public CommonResponse reportTask(@RequestBody TaskReportParams params) {
- log.debug("RCS鍥炶皟锛歿}", params);
+ logRcsRequest("POST /rcs/api/open/task/report", API_TASK_REPORT, params);
if (Objects.isNull(params)) {
throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒");
}
return wmsRcsService.reportTask(params);
}
+ /**
+ * @author Ryan
+ * @date 2026/2/6
+ * @description: 鐢宠鍏ュ簱浠诲姟
+ * @version 1.0
+ */
+ @ApiOperation(API_ALLOCATE)
+ @PostMapping("/api/open/location/allocate")
+ public R allocateLocation(@RequestBody LocationAllocateParams params) {
+ logRcsRequest("POST /rcs/api/open/location/allocate", API_ALLOCATE, params);
+ if (Objects.isNull(params)) {
+ return R.error("鍙傛暟涓嶈兘涓虹┖锛侊紒");
+ }
+ if (Objects.isNull(params.getBarcode()) || params.getBarcode().isEmpty()) {
+ return R.error("鏂欑鐮佷笉鑳戒负绌猴紒锛�");
+ }
+ if (Objects.isNull(params.getStaNo()) || params.getStaNo().isEmpty()) {
+ return R.error("鍏ュ簱绔欑偣涓嶈兘涓虹┖锛侊紒");
+ }
+ if (Objects.isNull(params.getType())) {
+ params.setType(18);
+ }
+ return wmsRcsService.allocateLocation(params);
+ }
+
}
--
Gitblit v1.9.1