From a19133219811f9286fa71a0fb8c1deb628cf74a3 Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期四, 28 十一月 2024 16:51:08 +0800
Subject: [PATCH] #

---
 zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WorkServiceImpl.java |   57 ++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 38 insertions(+), 19 deletions(-)

diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WorkServiceImpl.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WorkServiceImpl.java
index 141bcf3..97ceb6c 100644
--- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WorkServiceImpl.java
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WorkServiceImpl.java
@@ -8,6 +8,8 @@
 import com.zy.asrs.wms.asrs.entity.param.GeneratePakInParam;
 import com.zy.asrs.wms.asrs.service.*;
 import com.zy.asrs.wms.utils.LocUtils;
+import com.zy.asrs.wms.utils.OrderUtils;
+import com.zy.asrs.wms.utils.Utils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -57,6 +59,10 @@
     private LocTypeService locTypeService;
     @Autowired
     private MatService matService;
+    @Autowired
+    private OrderUtils orderUtils;
+    @Autowired
+    private WaveDetlService waveDetlService;
 
     @Override
     public String generateTaskNo(Long taskType) {
@@ -263,7 +269,7 @@
 
         Task task = new Task();
         task.setTaskNo(this.generateTaskNo(taskType.getId()));//浠诲姟鍙�
-        task.setTaskSts(1L);//1.鐢熸垚鍏ュ簱浠诲姟
+        task.setTaskSts(TaskStsType.GENERATE_IN.id);//1.鐢熸垚鍏ュ簱浠诲姟
         task.setTaskType(taskType.getId());//浠诲姟绫诲瀷
         task.setIoPri(this.generateIoPri(taskType.getId()));//浼樺厛绾�
         task.setOriginLoc(null);
@@ -372,7 +378,7 @@
 
         Task task = new Task();
         task.setTaskNo(this.generateTaskNo(taskType.getId()));//浠诲姟鍙�
-        task.setTaskSts(1L);//1.鐢熸垚鍏ュ簱浠诲姟
+        task.setTaskSts(TaskStsType.GENERATE_IN.id);//1.鐢熸垚鍏ュ簱浠诲姟
         task.setTaskType(taskType.getId());//浠诲姟绫诲瀷
         task.setIoPri(this.generateIoPri(taskType.getId()));//浼樺厛绾�
         task.setOriginLoc(null);
@@ -410,10 +416,15 @@
 
         if (task.getTaskType() < 100) {
             //鍏ュ簱
-            task.setTaskSts(99L);//99.鍏ュ簱瀹屾垚
+            task.setTaskSts(TaskStsType.COMPLETE_IN.id);//99.鍏ュ簱瀹屾垚
         }else {
             //鍑哄簱
-            task.setTaskSts(199L);//199.鍑哄簱瀹屾垚
+            TaskDetl taskDetl = taskDetls.get(0);
+            if (taskDetl.getWaveId() == null) {
+                task.setTaskSts(TaskStsType.COMPLETE_OUT.id);//199.鍑哄簱瀹屾垚
+            }else {
+                task.setTaskSts(TaskStsType.WAVE_SEED.id);//198.鎾涓�
+            }
         }
 
         task.setUpdateTime(new Date());
@@ -470,6 +481,26 @@
                 if(!locService.updateById(loc)){
                     throw new CoolException("搴撲綅鐘舵�佸彉鏇村け璐�");
                 }
+
+                List<TaskDetl> taskDetls = taskDetlService.getTaskDetlByTaskId(taskId);
+                for (TaskDetl taskDetl : taskDetls) {
+                    if (taskDetl.getWaveId() == null) {
+                        continue;
+                    }
+
+                    String matUniqueKey = Utils.getMatUniqueKey(taskDetl.getMatnr(), taskDetl.getBatch(), taskDetl.getUniqueField());
+                    WaveDetl waveDetl = waveDetlService.getOne(new LambdaQueryWrapper<WaveDetl>().eq(WaveDetl::getStockIndex, matUniqueKey).eq(WaveDetl::getWaveId, taskDetl.getWaveId()));
+                    if(waveDetl == null){
+                        continue;
+                    }
+                    waveDetl.setWorkQty(waveDetl.getWorkQty() - taskDetl.getAnfme());
+                    waveDetl.setUpdateTime(new Date());
+                    if (!waveDetlService.updateById(waveDetl)) {
+                        throw new CoolException("娉㈡鏄庣粏鏇存柊澶辫触");
+                    }
+                }
+
+
                 break;
         }
 
@@ -496,19 +527,7 @@
             //鍥炴粴璁㈠崟
             for (TaskDetl taskDetl : taskDetls) {
                 if (taskDetl.getDetlId() != null) {
-                    OrderDetl orderDetl = orderDetlService.getById(taskDetl.getDetlId());
-                    if(orderDetl == null){
-                        throw new CoolException("璁㈠崟鏄庣粏涓嶅瓨鍦�");
-                    }
-
-                    //鍥炴粴宸ヤ綔鏁伴噺
-                    orderDetl.setWorkQty(orderDetl.getWorkQty() - taskDetl.getAnfme());
-                    orderDetl.setUpdateTime(new Date());
-                    boolean orderDetlUpdate = orderDetlService.updateById(orderDetl);
-                    if(!orderDetlUpdate){
-                        throw new CoolException("宸ヤ綔鏁伴噺鍥炴粴澶辫触");
-                    }
-
+                    orderUtils.updateWorkQty(taskDetl.getDetlId(), taskDetl.getAnfme(), false);
                 }
 
                 //鍏ュ簱鍥炴粴缁勬墭閫氱煡妗�
@@ -586,7 +605,7 @@
         }
 
         //鑾峰彇婧愬簱浣嶉珮搴�
-        LocTypeBind locTypeBind = locTypeBindService.getOne(new LambdaQueryWrapper<LocTypeBind>().eq(LocTypeBind::getLocId, originLoc.getId()));
+        LocTypeBind locTypeBind = locTypeBindService.getOne(new LambdaQueryWrapper<LocTypeBind>().eq(LocTypeBind::getLocId, originLoc.getId()).in(LocTypeBind::getTypeId, LocBindType.HEIGHT.list()));
         if(locTypeBind == null){
             throw new CoolException("搴撲綅绫诲瀷涓嶅瓨鍦�");
         }
@@ -613,7 +632,7 @@
             throw new CoolException("娌℃湁绌哄簱浣�");
         }
 
-        task.setTaskSts(1L);//1.鐢熸垚鍏ュ簱浠诲姟
+        task.setTaskSts(TaskStsType.GENERATE_IN.id);//1.鐢熸垚鍏ュ簱浠诲姟
         task.setTaskType(taskType);
         task.setTargetLoc(loc.getLocNo());
         task.setUpdateTime(new Date());

--
Gitblit v1.9.1