From 0bee2b3f40638460f3fa961792d43570e4b46911 Mon Sep 17 00:00:00 2001
From: vincentlu <t1341870251@gmail.com>
Date: 星期四, 05 二月 2026 16:06:07 +0800
Subject: [PATCH] #

---
 zy-acs-manager/src/main/java/com/zy/acs/manager/core/integrate/wms/TaskReportService.java |   75 ++++++++++++++++++++++++++++++++-----
 1 files changed, 64 insertions(+), 11 deletions(-)

diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/integrate/wms/TaskReportService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/integrate/wms/TaskReportService.java
index e6eaaee..5f000de 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/integrate/wms/TaskReportService.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/integrate/wms/TaskReportService.java
@@ -4,13 +4,23 @@
 import com.alibaba.fastjson.TypeReference;
 import com.zy.acs.framework.common.Cools;
 import com.zy.acs.framework.common.R;
+import com.zy.acs.framework.common.SnowflakeIdWorker;
 import com.zy.acs.manager.common.config.UplinkProperties;
+import com.zy.acs.manager.common.constant.Constants;
 import com.zy.acs.manager.common.utils.HttpGo;
+import com.zy.acs.manager.core.domain.type.NamespaceType;
 import com.zy.acs.manager.core.integrate.dto.HttpResult;
+import com.zy.acs.manager.core.integrate.dto.TaskUplinkParam;
 import com.zy.acs.manager.core.service.ThreadPoolRegulator;
+import com.zy.acs.manager.manager.entity.Bus;
+import com.zy.acs.manager.manager.entity.IntegrationRecord;
 import com.zy.acs.manager.manager.entity.Task;
+import com.zy.acs.manager.manager.enums.IntegrationDirectionType;
+import com.zy.acs.manager.manager.enums.StatusType;
 import com.zy.acs.manager.manager.enums.TaskStsType;
 import com.zy.acs.manager.manager.enums.TaskUplinkStateType;
+import com.zy.acs.manager.manager.service.BusService;
+import com.zy.acs.manager.manager.service.IntegrationRecordService;
 import com.zy.acs.manager.manager.service.TaskService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -18,6 +28,7 @@
 
 import javax.annotation.PostConstruct;
 import java.time.Duration;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.CompletableFuture;
@@ -32,6 +43,12 @@
     private TaskService taskService;
     @Autowired
     private ThreadPoolRegulator threadPoolRegulator;
+    @Autowired
+    private BusService busService;
+    @Autowired
+    private SnowflakeIdWorker snowflakeIdWorker;
+    @Autowired
+    private IntegrationRecordService integrationRecordService;
 
     private HttpGo http;
 
@@ -57,10 +74,13 @@
             return false;
         }
         TaskUplinkStateType uplinkStateType = TaskUplinkStateType.of(task.getUplinkSts());
-        if (!uplinkStateType.equals(TaskUplinkStateType.PENDING) && !uplinkStateType.equals(TaskUplinkStateType.FAILED)) {
+        if (!uplinkStateType.equals(TaskUplinkStateType.PENDING)
+                && !uplinkStateType.equals(TaskUplinkStateType.SENDING)
+                && !uplinkStateType.equals(TaskUplinkStateType.FAILED)
+        ) {
             return false;
         }
-
+        Date now = new Date();
         // block
 //        Future<R> future = threadPoolRegulator.getInstance().submit(() -> {
 //            mapDataDispatcher.modifyDynamicMatrix(null, null, param.getAgvNo(), true);
@@ -76,34 +96,67 @@
         }, threadPoolRegulator.getInstance());
 
         // url
-        String url = this.http.buildUrl(uplinkProperties.getHost(), uplinkProperties.getPort(), "/cv/station/query");
+        String url = this.http.buildUrl(uplinkProperties.getHost(), uplinkProperties.getPort(), uplinkProperties.getUrl());
         // headers
         Map<String, String> headers = new HashMap<>();
         // params
-        Map<String, Object> params = new HashMap<>();
+        TaskUplinkParam param = new TaskUplinkParam();
+        if (null != task.getBusId()) {
+            Bus bus = busService.getById(task.getBusId());
+            param.setBatchNo(bus.getBusNo());
+        }
+        param.setTaskNo(task.getSeqNum());
+        param.setTimestamp(null == task.getEndTime() ? System.currentTimeMillis() : task.getEndTime().getTime());
 
+        IntegrationRecord integrationRecord = new IntegrationRecord(
+                String.valueOf(snowflakeIdWorker.nextId()).substring(3),    // 缂栧彿
+                NamespaceType.RCS_TASK_REPORT.desc,    // 鍚嶇О绌洪棿
+                uplinkProperties.getUrl(),    // 鎺ュ彛鍦板潃
+                null,    // 骞冲彴瀵嗛挜
+                Constants.RCS,    // 璋冪敤鏂规爣璇�
+                IntegrationDirectionType.OUTBOUND.value,    // 鏂瑰悜[闈炵┖]
+                String.valueOf(now.getTime()),    // 鏃堕棿鎴�
+                uplinkProperties.getHost(),    // 瀹㈡埛绔疘P
+                JSON.toJSONString(param),    // 璇锋眰鍐呭
+                null,    // 鍝嶅簲鍐呭
+                null,    // 寮傚父鍐呭
+                0,    // 缁撴灉
+                null,    // 鑰楁椂
+                StatusType.ENABLE.val,    // 鐘舵��
+                now,    // 娣诲姞鏃堕棿[闈炵┖]
+                now,    // 淇敼鏃堕棿[闈炵┖]
+                null    // 澶囨敞
+        );
         HttpResult<?> result;
         try {
-            result = postForResult(url, headers, params);
+            result = postForResult(url, headers, param);
+            integrationRecord.setResponse(JSON.toJSONString(result));
+
             Integer code = result.getCode();
             if (null == code || 200 != code) {
                 return false;
             }
-            Object data = result.getData();
-            if (Cools.isEmpty(data)) {
-                return false;
-            }
+//            Object data = result.getData();
+//            if (Cools.isEmpty(data)) {
+//                return false;
+//            }
+
+            integrationRecord.setResult(1);
         } catch (Exception e) {
             log.error("Uplink report failed, taskId={}",
                     JSON.toJSONString(task),
                     e);
+            integrationRecord.setErr(e.getMessage());
             return false;
+        } finally {
+            integrationRecord.setCostMs((int) (System.currentTimeMillis() - now.getTime()));
+            integrationRecordService.syncRecord(integrationRecord);
         }
         return true;
     }
 
-    private HttpResult<?> postForResult(String url, Map<String, String> headers, Map<String, Object> params) throws Exception {
-        String json = JSON.toJSONString(params);
+    private HttpResult<?> postForResult(String url, Map<String, String> headers, TaskUplinkParam param) throws Exception {
+        String json = JSON.toJSONString(param);
         HttpGo.HttpResponse response = this.http.postJson(url, headers, json);
 
         int status = response.statusCode();

--
Gitblit v1.9.1