From e83dacb5066a86db29dbdc232218d8aba6adc95f Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期五, 02 八月 2024 13:34:04 +0800
Subject: [PATCH] #

---
 zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/timer/TaskTimer.java |   34 ++++++++++++++++++++++++++++++----
 1 files changed, 30 insertions(+), 4 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 770ff8c..e9a0f64 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
@@ -11,6 +11,7 @@
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 import java.util.Date;
 import java.util.List;
@@ -32,6 +33,8 @@
     private LocDetlFieldService locDetlFieldService;
     @Autowired
     private WaitPakinService waitPakinService;
+    @Autowired
+    private WaitPakinLogService waitPakinLogService;
 
     @Scheduled(cron = "0/3 * * * * ? ")
     @Transactional
@@ -68,7 +71,7 @@
 
                         List<TaskDetl> taskDetls = taskDetlService.getTaskDetlByTaskId(task.getId());
                         if(taskDetls.isEmpty()) {
-                            throw new CoolException("搴撳瓨鏄庣粏涓嶅瓨鍦�");
+                            throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦�");
                         }
 
                         //娣诲姞搴撳瓨鏄庣粏
@@ -93,6 +96,7 @@
                                 locDetlField.setDetlId(locDetl.getId());
                                 locDetlField.setFieldId(detlField.getFieldId());
                                 locDetlField.setName(detlField.getName());
+                                locDetlField.setValue(detlField.getValue());
                                 locDetlField.setHostId(hostId);
                                 if (!locDetlFieldService.save(locDetlField)) {
                                     throw new CoolException("鎻掑叆鏄庣粏鎵╁睍瀛楁澶辫触");
@@ -100,8 +104,21 @@
                             }
                         }
 
-                        //鍒犻櫎缁勬墭閫氱煡妗�
-                        waitPakinService.remove(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, task.getBarcode()).eq(WaitPakin::getHostId, hostId));
+                        //缁勬墭閫氱煡妗h浆鍘嗗彶妗�
+                        List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, task.getBarcode()).eq(WaitPakin::getHostId, hostId));
+                        if(waitPakins.isEmpty()) {
+                            throw new CoolException("缁勬墭閫氱煡妗d笉瀛樺湪");
+                        }
+                        for (WaitPakin waitPakin : waitPakins) {
+                            WaitPakinLog waitPakinLog = new WaitPakinLog();
+                            waitPakinLog.sync(waitPakin);
+                            if (!waitPakinLogService.save(waitPakinLog)) {
+                                throw new CoolException("缁勬墭閫氱煡妗h浆鍘嗗彶妗eけ璐�");
+                            }
+
+                            //鍒犻櫎缁勬墭閫氱煡妗�
+                            waitPakinService.removeById(waitPakin.getId());
+                        }
 
                         break;
                 }
@@ -113,7 +130,8 @@
                 }
             }
         } catch (Exception e) {
-
+            e.printStackTrace();
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
         }finally {
             InterceptorIgnoreHelper.clearIgnoreStrategy();
         }
@@ -122,7 +140,15 @@
     @Scheduled(cron = "0/3 * * * * ? ")
     @Transactional
     public void outExecute() {
+        InterceptorIgnoreHelper.handle(IgnoreStrategy.builder().tenantLine(true).build());
+        try {
 
+        } catch (Exception e) {
+            e.printStackTrace();
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+        }finally {
+            InterceptorIgnoreHelper.clearIgnoreStrategy();
+        }
     }
 
 }

--
Gitblit v1.9.1