From 1a65da0a6c765b07527082272c8d1afc5119a3fa Mon Sep 17 00:00:00 2001
From: skyouc <958836976@qq.com>
Date: 星期六, 30 八月 2025 08:04:11 +0800
Subject: [PATCH] 接口对接修改

---
 rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java |   61 +++++++++++++++++++++++++++---
 1 files changed, 55 insertions(+), 6 deletions(-)

diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java
index 11a9ab3..27b6502 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java
@@ -19,6 +19,7 @@
 import com.vincent.rsf.server.api.controller.erp.params.TaskInParam;
 import com.vincent.rsf.server.api.entity.dto.SyncLocsDto;
 import com.vincent.rsf.server.api.entity.params.CommonRequest;
+import com.vincent.rsf.server.api.entity.params.ExMsgParams;
 import com.vincent.rsf.server.api.entity.params.WcsTaskParams;
 import com.vincent.rsf.server.manager.enums.*;
 import com.vincent.rsf.server.api.service.WcsService;
@@ -407,7 +408,7 @@
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public R syncLocsToWms() {
+    public void syncLocsToWms() {
         /**RCS鍩虹閰嶇疆閾炬帴*/
         CommonRequest params = new CommonRequest();
         params.setPageSize(100);
@@ -443,11 +444,30 @@
             }
         }, 1, 1, TimeUnit.SECONDS);
 
-        return R.ok();
     }
 
-    private List<SyncLocsDto> syncLocs(CommonRequest params) {
-        String rcsUrl = rcsApi.getHost() + ":" + rcsApi.getPort() + RcsConstant.syncLocs;
+    /**
+     * 寮傚父淇℃伅涓婃姤
+     * @return
+     */
+    @Override
+    public R receiveExMsg(ExMsgParams params) {
+        if (Objects.isNull(params)) {
+            return R.error("鍙傛暟涓嶈兘涓虹┖锛侊紒");
+        }
+        
+        log.info(JSONObject.toJSONString(params));
+        return R.ok(JSONObject.toJSONString(params));
+    }
+
+    /**
+     * 涓嬪彂浠诲姟鑷充腑杞珹PI
+     * @param params
+     * @return
+     */
+    @Override
+    public R pubWcsTask(WcsTaskParams params) {
+        String rcsUrl = rcsApi.getHost() + ":" + rcsApi.getPort() + RcsConstant.pubTask;
         log.info("浠诲姟涓嬪彂锛岃姹傚湴鍧�锛� {}锛� 璇锋眰鍙傛暟锛� {}", rcsUrl, JSONObject.toJSONString(params));
         HttpHeaders headers = new HttpHeaders();
         headers.add("Content-Type", "application/json");
@@ -464,8 +484,7 @@
             try {
                 CommonResponse result = objectMapper.readValue(exchange.getBody(), CommonResponse.class);
                 if (result.getCode() == 200) {
-                    JSONObject jsonObject = JSONObject.parseObject(exchange.getBody()).getJSONObject("data");
-                    return JSONArray.parseArray(jsonObject.getJSONArray("records").toJSONString(), SyncLocsDto.class);
+                    return R.ok();
                 } else {
                     throw new CoolException("浠诲姟涓嬪彂澶辫触锛侊紒");
                 }
@@ -475,6 +494,36 @@
         }
     }
 
+
+    private List<SyncLocsDto> syncLocs(CommonRequest params) {
+        String rcsUrl = rcsApi.getHost() + ":" + rcsApi.getPort() + RcsConstant.syncLocs;
+        log.info("搴撲綅鍚屾锛岃姹傚湴鍧�锛� {}锛� 璇锋眰鍙傛暟锛� {}", rcsUrl, JSONObject.toJSONString(params));
+        HttpHeaders headers = new HttpHeaders();
+        headers.add("Content-Type", "application/json");
+        headers.add("api-version", "v2.0");
+        HttpEntity httpEntity = new HttpEntity(params, headers);
+        ResponseEntity<String> exchange = restTemplate.exchange(rcsUrl, HttpMethod.POST, httpEntity, String.class);
+        log.info("搴撲綅鍚屾锛屽搷搴旂粨鏋滐細 {}", exchange);
+        if (Objects.isNull(exchange.getBody())) {
+            throw new CoolException("搴撲綅鍚屾涓嬪彂澶辫触锛侊紒");
+        } else {
+            ObjectMapper objectMapper = new ObjectMapper();
+            objectMapper.coercionConfigDefaults()
+                    .setCoercion(CoercionInputShape.EmptyString, CoercionAction.AsEmpty);
+            try {
+                CommonResponse result = objectMapper.readValue(exchange.getBody(), CommonResponse.class);
+                if (result.getCode() == 200) {
+                    JSONObject jsonObject = JSONObject.parseObject(exchange.getBody());
+                    return JSONArray.parseArray(jsonObject.getJSONArray("data").toJSONString(), SyncLocsDto.class);
+                } else {
+                    throw new CoolException("搴撲綅鍚屾澶辫触锛侊紒");
+                }
+            } catch (JsonProcessingException e) {
+                throw new CoolException(e.getMessage());
+            }
+        }
+    }
+
     private InTaskMsgDto getLocNoCrn(String orgLoc, DeviceBind deviceBind, Long area, Integer sourceStaNo, String matnr, String batch, LocTypeDto locTypeDto, int times, Integer ioType) {
         if (Cools.isEmpty(matnr)) {  //鐗╂枡鍙�
             matnr = "";

--
Gitblit v1.9.1