From 51a1786ef3e4e016d5f3f7bad8c2e2e8a84247a6 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期日, 22 三月 2026 18:42:19 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/common/service/CommonService.java |   90 +++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 86 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 cc2f16c..bb00969 100644
--- a/src/main/java/com/zy/common/service/CommonService.java
+++ b/src/main/java/com/zy/common/service/CommonService.java
@@ -13,6 +13,7 @@
 import com.zy.common.utils.NavigateUtils;
 import com.zy.common.utils.RedisUtil;
 import com.zy.core.News;
+import com.zy.core.service.WrkCommandRollbackService;
 import com.zy.core.enums.*;
 import com.zy.core.model.StationObjModel;
 import lombok.extern.slf4j.Slf4j;
@@ -20,6 +21,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;
@@ -44,6 +46,10 @@
     private RedisUtil redisUtil;
     @Autowired
     private BasOutStationAreaService basOutStationAreaService;
+    @Autowired
+    private WrkCommandRollbackService wrkCommandRollbackService;
+    @Autowired
+    private WrkAnalysisService wrkAnalysisService;
 
     /**
      * 鐢熸垚宸ヤ綔鍙�
@@ -56,8 +62,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);
@@ -149,6 +155,33 @@
         return true;
     }
 
+    public boolean updateTaskPriorityAndBatchSeq(UpdateTaskPriorityAndBatchSeqParam param) {
+        if (param == null) {
+            throw new CoolException("鍙傛暟涓嶈兘涓虹┖");
+        }
+        if (Cools.isEmpty(param.getTaskNo())) {
+            throw new CoolException("WMS浠诲姟鍙蜂笉鑳戒负绌�");
+        }
+        if (param.getTaskPri() == null && param.getBatchSeq() == null) {
+            throw new CoolException("浠诲姟浼樺厛绾у拰鎵规搴忓彿涓嶈兘鍚屾椂涓虹┖");
+        }
+
+        WrkMast wrkMast = wrkMastService.getOne(new QueryWrapper<WrkMast>().eq("wms_wrk_no", param.getTaskNo()));
+        if (wrkMast == null) {
+            throw new CoolException("浠诲姟涓嶅瓨鍦�");
+        }
+
+        if (param.getTaskPri() != null) {
+            wrkMast.setIoPri(param.getTaskPri().doubleValue());
+        }
+        if (param.getBatchSeq() != null) {
+            wrkMast.setBatchSeq(param.getBatchSeq());
+        }
+        wrkMast.setModiTime(new Date());
+        wrkMastService.updateById(wrkMast);
+        return true;
+    }
+
     public CancelTaskBatchResult cancelTaskBatch(CancelTaskBatchParam param) {
         if (param == null) {
             throw new CoolException("鍙傛暟涓嶈兘涓虹┖");
@@ -184,6 +217,10 @@
         result.setSuccessList(successList);
         result.setFailList(failList);
         return result;
+    }
+
+    public boolean manualRollbackTask(ManualRollbackTaskParam param) {
+        return wrkCommandRollbackService.manualRollbackTask(param);
     }
 
     //绉诲簱浠诲姟
@@ -255,6 +292,7 @@
             News.error("绉诲簱浠诲姟 --- 淇濆瓨宸ヤ綔妗eけ璐ワ紒");
             throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
         }
+        wrkAnalysisService.initForTask(wrkMast);
 
         sourceLocMast.setLocSts("R");
         sourceLocMast.setModiTime(new Date());
@@ -323,6 +361,7 @@
             News.error("鍏ュ簱浠诲姟 --- 淇濆瓨宸ヤ綔妗eけ璐ワ紒");
             throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
         }
+        wrkAnalysisService.initForTask(wrkMast);
 
         locMast.setLocSts("S");
         locMast.setModiTime(new Date());
@@ -440,11 +479,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) {
@@ -496,7 +578,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;
@@ -528,7 +610,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