From 7178ac3731005f2829fa9cca16dc125fc34ec12e Mon Sep 17 00:00:00 2001
From: ZY <zc857179121@qq.com>
Date: 星期五, 16 八月 2024 17:09:40 +0800
Subject: [PATCH] 出库代码提交和部分别的基础代码

---
 zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/timer/TaskTimer.java |   81 +++++++++++++++++++++++++++++++++++++---
 1 files changed, 75 insertions(+), 6 deletions(-)

diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/timer/TaskTimer.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/timer/TaskTimer.java
index e9a0f64..4b78bed 100644
--- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/timer/TaskTimer.java
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/timer/TaskTimer.java
@@ -21,20 +21,40 @@
 
     @Autowired
     private TaskService taskService;
+
     @Autowired
     private TaskDetlService taskDetlService;
+
     @Autowired
     private TaskDetlFieldService taskDetlFieldService;
+
     @Autowired
     private LocService locService;
+
     @Autowired
     private LocDetlService locDetlService;
+
     @Autowired
     private LocDetlFieldService locDetlFieldService;
+
     @Autowired
     private WaitPakinService waitPakinService;
+
     @Autowired
     private WaitPakinLogService waitPakinLogService;
+
+    @Autowired
+    private TaskDetlLogService taskDetlLogService;
+
+    @Autowired
+    private TaskDetlFieldLogService taskDetlFieldLogService;
+
+    @Autowired
+    private OrderService orderService;
+
+    @Autowired
+    private OrderDetlService orderDetlService;
+
 
     @Scheduled(cron = "0/3 * * * * ? ")
     @Transactional
@@ -53,11 +73,11 @@
                 switch (task.getTaskType().intValue()) {
                     case 1://鍏ュ簱
                         Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getTargetLoc()).eq(Loc::getHostId, hostId));
-                        if(loc == null) {
+                        if (loc == null) {
                             throw new CoolException("搴撲綅涓嶅瓨鍦�");
                         }
 
-                        if(loc.getLocStsId() != LocStsType.S.val()){
+                        if (loc.getLocStsId() != LocStsType.S.val()) {
                             throw new CoolException("搴撲綅鐘舵�佷笉澶勪簬S.鍏ュ簱棰勭害");
                         }
 
@@ -70,7 +90,7 @@
 
 
                         List<TaskDetl> taskDetls = taskDetlService.getTaskDetlByTaskId(task.getId());
-                        if(taskDetls.isEmpty()) {
+                        if (taskDetls.isEmpty()) {
                             throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦�");
                         }
 
@@ -106,7 +126,7 @@
 
                         //缁勬墭閫氱煡妗h浆鍘嗗彶妗�
                         List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, task.getBarcode()).eq(WaitPakin::getHostId, hostId));
-                        if(waitPakins.isEmpty()) {
+                        if (waitPakins.isEmpty()) {
                             throw new CoolException("缁勬墭閫氱煡妗d笉瀛樺湪");
                         }
                         for (WaitPakin waitPakin : waitPakins) {
@@ -132,7 +152,7 @@
         } catch (Exception e) {
             e.printStackTrace();
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-        }finally {
+        } finally {
             InterceptorIgnoreHelper.clearIgnoreStrategy();
         }
     }
@@ -142,11 +162,60 @@
     public void outExecute() {
         InterceptorIgnoreHelper.handle(IgnoreStrategy.builder().tenantLine(true).build());
         try {
+            //鑾峰彇鍑哄簱瀹屾垚浠诲姟
+            List<Task> list = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getTaskSts, 199));
+            if (list.isEmpty()) {
+                return;
+            }
+            for (Task task : list) {
+                //鍚屾鏁版嵁
+                Long hostId = task.getHostId();
+                Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getOriginLoc()).eq(Loc::getHostId, hostId));
+                if (loc == null) {
+                    throw new CoolException("搴撲綅涓嶅瓨鍦�");
+                }
+                if (loc.getLocStsId() != LocStsType.R.val()) {
+                    throw new CoolException("搴撲綅鐘舵�佷笉澶勪簬R.鍑哄簱棰勭害");
+                }
+                List<TaskDetl> taskDetls = taskDetlService.getTaskDetlByTaskId(task.getId());
+                if (taskDetls.isEmpty()) {
+                    throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦�");
+                }
+                switch (task.getTaskType().intValue()) {
+                    //鍑哄簱
+                    case 101:
+                        loc.setLocStsId(LocStsType.O.val());
+                        loc.setBarcode("");
+                        if (!locService.updateById(loc)) {
+                            throw new CoolException("搴撲綅鐘舵�佹洿鏂板け璐�");
+                        }
+                        List<LocDetl> detlList = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocNo, loc.getId()).eq(LocDetl::getHostId, hostId));
+                        //鍒犻櫎搴撳瓨鏄庣粏
+                        for (LocDetl locDetl : detlList) {
+                            if (!locDetlService.removeById(locDetl)) {
+                                throw new CoolException("鍒犻櫎搴撳瓨鏄庣粏澶辫触");
+                            }
+                            List<LocDetlField> detlFields = locDetlFieldService.list(new LambdaQueryWrapper<LocDetlField>().eq(LocDetlField::getDetlId, locDetl.getId()).eq(LocDetlField::getHostId, hostId));
+                            for (LocDetlField detlField : detlFields) {
+                                if (!locDetlFieldService.removeById(detlField)) {
+                                    throw new CoolException("鍒犻櫎鏄庣粏鎵╁睍瀛楁澶辫触");
+                                }
+                            }
+                        }
+                        break;
+
+                }
+
+                task.setTaskSts(200L);//200.搴撳瓨鏇存柊瀹屾垚
+                if (!taskService.updateById(task)) {
+                    throw new CoolException("搴撳瓨鏇存柊澶辫触");
+                }
+            }
 
         } catch (Exception e) {
             e.printStackTrace();
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-        }finally {
+        } finally {
             InterceptorIgnoreHelper.clearIgnoreStrategy();
         }
     }

--
Gitblit v1.9.1