From 6dcaeac0440ef7dd86d9513cea7d3033d68f7e65 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期二, 24 三月 2026 10:43:18 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/common/service/CommonService.java |  131 ++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 127 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/zy/common/service/CommonService.java b/src/main/java/com/zy/common/service/CommonService.java
index 68468a9..bf6fa7f 100644
--- a/src/main/java/com/zy/common/service/CommonService.java
+++ b/src/main/java/com/zy/common/service/CommonService.java
@@ -1,6 +1,7 @@
 package com.zy.common.service;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.core.common.Cools;
 import com.core.exception.CoolException;
 import com.zy.asrs.domain.Result.CancelTaskBatchResult;
@@ -21,6 +22,7 @@
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.Date;
 import java.util.List;
 import java.util.Random;
@@ -47,6 +49,8 @@
     private BasOutStationAreaService basOutStationAreaService;
     @Autowired
     private WrkCommandRollbackService wrkCommandRollbackService;
+    @Autowired
+    private WrkAnalysisService wrkAnalysisService;
 
     /**
      * 鐢熸垚宸ヤ綔鍙�
@@ -59,8 +63,8 @@
         }
 
         int workNo = wrkLastno.getWrkNo();
-        int sNo = wrkLastno.getSNo();
-        int eNo = wrkLastno.getENo();
+        int sNo = wrkLastno.getsNo();
+        int eNo = wrkLastno.geteNo();
         workNo = workNo>=eNo ? sNo : workNo+1;
         while (true) {
             WrkMast wrkMast = wrkMastService.selectByWorkNo(workNo);
@@ -179,6 +183,80 @@
         return true;
     }
 
+    public CancelTaskBatchResult cancelOutTaskBatchInfo(CancelTaskBatchParam param) {
+        if (param == null) {
+            throw new CoolException("鍙傛暟涓嶈兘涓虹┖");
+        }
+        List<CancelTaskParam> taskList = param.getTaskList();
+        if (taskList == null || taskList.isEmpty()) {
+            throw new CoolException("浠诲姟鍙傛暟鍒楄〃涓虹┖");
+        }
+
+        List<String> successList = new ArrayList<>();
+        List<String> failList = new ArrayList<>();
+        for (CancelTaskParam taskParam : taskList) {
+            if (taskParam == null) {
+                throw new CoolException("浠诲姟鍙傛暟涓嶈兘涓虹┖");
+            }
+            boolean cancelStatus = false;
+            try {
+                cancelStatus = cancelSingleOutTaskBatchInfo(taskParam);
+            } catch (Exception e) {
+            }
+
+            if (cancelStatus) {
+                successList.add(resolveTaskIdentifier(taskParam));
+            } else {
+                failList.add(resolveTaskIdentifier(taskParam));
+            }
+        }
+
+        CancelTaskBatchResult result = new CancelTaskBatchResult();
+        result.setSuccessList(successList);
+        result.setFailList(failList);
+        return result;
+    }
+
+    private boolean cancelSingleOutTaskBatchInfo(CancelTaskParam param) {
+        WrkMast wrkMast = null;
+        Integer wrkNo = param.getWrkNo();
+        String taskNo = param.getTaskNo();
+        if (wrkNo == null) {
+            if (Cools.isEmpty(taskNo)) {
+                throw new CoolException("WMS浠诲姟鍙蜂笉鑳戒负绌�");
+            }
+            wrkMast = wrkMastService.getOne(new QueryWrapper<WrkMast>().eq("wms_wrk_no", taskNo));
+        } else {
+            wrkMast = wrkMastService.selectByWorkNo(wrkNo);
+        }
+        if (wrkMast == null) {
+            throw new CoolException("浠诲姟涓嶅瓨鍦�");
+        }
+        if (!wrkMast.getIoType().equals(WrkIoType.OUT.id)) {
+            throw new CoolException("浠呮敮鎸佸嚭搴撲换鍔�");
+        }
+
+        boolean updated = wrkMast.getWrkNo() != null && wrkMastService.update(null, new UpdateWrapper<WrkMast>()
+                .eq("wrk_no", wrkMast.getWrkNo())
+                .set("batch", null)
+                .set("batch_seq", null)
+                .set("modi_time", new Date()));
+        if (!updated) {
+            throw new CoolException("鍙栨秷鍑哄簱浠诲姟鎵规鍜屾壒娆″簭鍙峰け璐�");
+        }
+        return true;
+    }
+
+    private String resolveTaskIdentifier(CancelTaskParam param) {
+        if (!Cools.isEmpty(param.getTaskNo())) {
+            return param.getTaskNo();
+        }
+        if (param.getWrkNo() != null) {
+            return String.valueOf(param.getWrkNo());
+        }
+        return "";
+    }
+
     public CancelTaskBatchResult cancelTaskBatch(CancelTaskBatchParam param) {
         if (param == null) {
             throw new CoolException("鍙傛暟涓嶈兘涓虹┖");
@@ -289,6 +367,7 @@
             News.error("绉诲簱浠诲姟 --- 淇濆瓨宸ヤ綔妗eけ璐ワ紒");
             throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
         }
+        wrkAnalysisService.initForTask(wrkMast);
 
         sourceLocMast.setLocSts("R");
         sourceLocMast.setModiTime(new Date());
@@ -357,6 +436,7 @@
             News.error("鍏ュ簱浠诲姟 --- 淇濆瓨宸ヤ綔妗eけ璐ワ紒");
             throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
         }
+        wrkAnalysisService.initForTask(wrkMast);
 
         locMast.setLocSts("S");
         locMast.setModiTime(new Date());
@@ -474,11 +554,54 @@
             News.error("鍑哄簱浠诲姟 --- 淇濆瓨宸ヤ綔妗eけ璐ワ紒");
             throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
         }
+        wrkAnalysisService.initForTask(wrkMast);
 
         locMast.setLocSts("R");
         locMast.setModiTime(new Date());
         locMastService.updateById(locMast);
         return true;
+    }
+
+    public boolean createOutTaskBatch(CreateOutTaskBatchParam param) {
+        if (param == null) {
+            throw new CoolException("鍙傛暟涓嶈兘涓虹┖");
+        }
+
+        List<CreateOutTaskParam> taskList = param.getTaskList();
+        if (taskList == null || taskList.isEmpty()) {
+            throw new CoolException("浠诲姟鍒楄〃涓嶈兘涓虹┖");
+        }
+
+        List<CreateOutTaskParam> sortedTaskList = new ArrayList<>(taskList);
+        sortedTaskList.sort(Comparator.nullsLast(Comparator
+                .comparing(this::getSortableBatch, Comparator.nullsLast(String::compareTo))
+                .thenComparing(this::getSortableBatchSeq, Comparator.nullsLast(Integer::compareTo))));
+
+        for (CreateOutTaskParam createOutTaskParam : sortedTaskList) {
+            if (createOutTaskParam == null) {
+                throw new CoolException("浠诲姟鍙傛暟涓嶈兘涓虹┖");
+            }
+            createOutTask(createOutTaskParam);
+        }
+        return true;
+    }
+
+    private String getSortableBatch(CreateOutTaskParam param) {
+        if (param == null) {
+            return null;
+        }
+        String batch = param.getBatch();
+        if (batch == null || batch.trim().isEmpty()) {
+            return null;
+        }
+        return batch;
+    }
+
+    private Integer getSortableBatchSeq(CreateOutTaskParam param) {
+        if (param == null) {
+            return null;
+        }
+        return param.getBatchSeq();
     }
 
     public FindCrnNoResult findCrnNoByLocNo(String locNo) {
@@ -530,7 +653,7 @@
         Integer targetStationId = null;
         for (StationObjModel stationObjModel : stationList) {
             try {
-                List<NavigateNode> navigateNodes = navigateUtils.calcByStationId(sourceStationId, stationObjModel.getStationId());
+                List<NavigateNode> navigateNodes = navigateUtils.calcReachablePathByStationId(sourceStationId, stationObjModel.getStationId());
                 if(!navigateNodes.isEmpty()) {
                     targetStationId = stationObjModel.getStationId();
                     break;
@@ -562,7 +685,7 @@
         Integer finalSourceStationId = null;
         for (StationObjModel stationObjModel : stationList) {
             try {
-                List<NavigateNode> navigateNodes = navigateUtils.calcByStationId(stationObjModel.getStationId(), targetStationId);
+                List<NavigateNode> navigateNodes = navigateUtils.calcReachablePathByStationId(stationObjModel.getStationId(), targetStationId);
                 if(!navigateNodes.isEmpty()) {
                     finalSourceStationId = stationObjModel.getStationId();
                     break;

--
Gitblit v1.9.1