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/OpenController.java |   72 ++++++++++++++++++++++++++++-------
 1 files changed, 57 insertions(+), 15 deletions(-)

diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/integrate/wms/OpenController.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/integrate/wms/OpenController.java
index 76e14e1..85268f6 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/integrate/wms/OpenController.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/integrate/wms/OpenController.java
@@ -2,30 +2,39 @@
 
 import com.zy.acs.framework.common.Cools;
 import com.zy.acs.framework.common.R;
+import com.zy.acs.manager.common.annotation.IntegrationAuth;
 import com.zy.acs.manager.common.annotation.OperationLog;
 import com.zy.acs.manager.common.constant.Constants;
+import com.zy.acs.manager.common.domain.TaskBoolDto;
+import com.zy.acs.manager.core.domain.type.NamespaceType;
 import com.zy.acs.manager.core.integrate.dto.OpenBusCancelParam;
+import com.zy.acs.manager.core.integrate.dto.OpenBusCancelResult;
 import com.zy.acs.manager.core.integrate.dto.OpenBusSubmitParam;
 import com.zy.acs.manager.core.service.MainService;
 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.TaskStsType;
 import com.zy.acs.manager.manager.service.BusService;
 import com.zy.acs.manager.manager.service.TaskService;
-import com.zy.acs.manager.system.controller.BaseController;
 import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 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.servlet.http.HttpServletRequest;
+
 /**
  * Created by vincent on 2023/6/12
  */
+@Slf4j
 @Api(tags = "Open Api")
 @RestController
 @RequestMapping("/api/open")
-public class OpenController extends BaseController {
+public class OpenController {
 
     @Autowired
     private MainService mainService;
@@ -36,34 +45,67 @@
 
     @PostMapping("/bus/submit")
     @OperationLog("generate task from open api")
-    public R submit(@RequestBody OpenBusSubmitParam param) {
+    @IntegrationAuth(name = NamespaceType.RCS_BUS_RECEIVE)
+    public R submit(@RequestBody OpenBusSubmitParam param, HttpServletRequest request) {
+        IntegrationRecord integrationRecord = new IntegrationRecord(
+                null,    // 缂栧彿
+                null,    // 鍚嶇О绌洪棿
+                null,    // 鎺ュ彛鍦板潃
+                null,    // 骞冲彴瀵嗛挜
+                null,    // 璋冪敤鏂规爣璇�
+                null,    // 鏂瑰悜[闈炵┖]
+                null,    // 鏃堕棿鎴�
+                null,    // 瀹㈡埛绔疘P
+                null,    // 璇锋眰鍐呭
+                null,    // 鍝嶅簲鍐呭
+                null,    // 寮傚父鍐呭
+                null,    // 缁撴灉
+                null,    // 鑰楁椂
+                null,    // 鐘舵��
+                null,    // 娣诲姞鏃堕棿[闈炵┖]
+                null,    // 淇敼鏃堕棿[闈炵┖]
+                null    // 澶囨敞
+        );
+        request.setAttribute("integrationRecord", integrationRecord);
+
         mainService.generateBusAndTask(param, null);
         return R.ok("generate tasks success");
     }
 
-    @PostMapping("/bus/cancel")
+    @PostMapping("/task/cancel")
     @OperationLog("cancel task from open api")
     public R cancel(@RequestBody OpenBusCancelParam param) {
+        if (Cools.isEmpty(param.getBatchNo())) {
+            return R.error("batchNo is empty");
+        }
         if (Cools.isEmpty(param.getTasks())) {
             return R.error("tasks is empty");
         }
-        Long busId = null;
-        if (!Cools.isEmpty(param.getBatchNo())) {
-            Bus bus = busService.selectByBusNo(param.getBatchNo());
-            if (null != bus) {
-                busId = bus.getId();
-            }
-        } else {
-//            return R.error("batch_no is empty");
+        Bus bus = busService.selectByBusNo(param.getBatchNo());
+        if (null == bus) {
+            return R.error("batchNo is not exist");
         }
+        OpenBusCancelResult result = new OpenBusCancelResult();
+        result.setBatchNo(param.getBatchNo());
         for (String taskNo : param.getTasks()) {
-            Task task = taskService.selectBySeqNum(busId, taskNo);
+            Task task = taskService.selectBySeqNum(bus.getId(), taskNo);
             if (null == task) {
+                result.getTasks().add(new TaskBoolDto(taskNo, Boolean.FALSE, "task " + taskNo + " is not exist"));
                 continue;
             }
-            taskService.cancel(task.getId(), null, Constants.UPLINK);
+            if (!task.getTaskSts().equals(TaskStsType.INIT.val())) {
+                result.getTasks().add(new TaskBoolDto(taskNo, Boolean.FALSE,  "task " + taskNo + " has already been assigned"));
+                continue;
+            }
+            Boolean cancel = false;
+            try {
+                cancel = taskService.cancel(task.getId(), null, Constants.UPLINK);
+            } catch (Exception e) {
+                log.error("failed to cancel task {}", taskNo, e);
+            }
+            result.getTasks().add(new TaskBoolDto(taskNo, cancel, "failed to cancel task " + taskNo));
         }
-        return R.ok("cancel tasks success");
+        return R.ok("cancel tasks success").add(result);
     }
 
 }

--
Gitblit v1.9.1