From 83b51a5a0774ea8ecb9a06304af3b956a21307c8 Mon Sep 17 00:00:00 2001
From: pjb <123456>
Date: 星期六, 08 三月 2025 09:06:55 +0800
Subject: [PATCH] CUT库条码T开头,截取后10位

---
 zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/timer/TaskLogTimer.java |  164 +++++++++++++++++++++++++++---------------------------
 1 files changed, 81 insertions(+), 83 deletions(-)

diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/timer/TaskLogTimer.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/timer/TaskLogTimer.java
index 8c62e0c..f86ad18 100644
--- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/timer/TaskLogTimer.java
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/timer/TaskLogTimer.java
@@ -1,6 +1,7 @@
 package com.zy.asrs.wms.asrs.timer;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.plugins.IgnoreStrategy;
 import com.baomidou.mybatisplus.core.plugins.InterceptorIgnoreHelper;
 import com.zy.asrs.framework.common.DateUtils;
@@ -17,8 +18,11 @@
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
+import java.util.Collections;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 @Component
 public class TaskLogTimer {
@@ -44,8 +48,8 @@
     @Autowired
     private WaveService waveService;
 
-//    @Scheduled(cron = "0/3 * * * * ? ")
-    @Transactional
+    @Scheduled(cron = "0/15 * * * * ? ")
+    @Transactional(rollbackFor = Exception.class)
     public void inExecute() {
         InterceptorIgnoreHelper.handle(IgnoreStrategy.builder().tenantLine(true).build());
         try {
@@ -57,7 +61,6 @@
 
             for (Task task : list) {
                 Long hostId = task.getHostId();
-
                 //淇濆瓨浠诲姟鍘嗗彶妗�
                 TaskLog taskLog = new TaskLog();
                 taskLog.sync(task);
@@ -65,17 +68,51 @@
                 if (!taskLogService.save(taskLog)) {
                     throw new CoolException("淇濆瓨浠诲姟鍘嗗彶妗eけ璐�");
                 }
+                //淇濆瓨浠诲姟鏄庣粏鍘嗗彶妗�
+                List<TaskDetl> taskDetls = taskDetlService.getTaskDetlByTaskId(task.getId());
+
+                if (taskDetls.isEmpty()) {
+                    throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦�");
+                } else {
+                        //浠诲姟绫诲瀷涓�53锛屾牴鎹甒aveId淇敼璁㈠崟鏄庣粏
+                        for (TaskDetl taskDetl : taskDetls) {
+                            if (taskDetl.getDetlId() == null) {
+                                continue;
+                            }
+                            OrderDetl orderDetl = orderDetlService.getById(taskDetl.getDetlId());
+                            if (orderDetl == null) {
+                                throw new CoolException("璁㈠崟鏄庣粏涓嶅瓨鍦�");
+                            }
+                            orderDetl.setWorkQty(orderDetl.getWorkQty() - taskDetl.getAnfme());//宸ヤ綔涓暟閲忓噺灏�
+                            orderDetl.setQty(orderDetl.getQty() + taskDetl.getAnfme());//宸插畬鎴愭暟閲忓鍔�
+                            orderDetl.setUpdateTime(new Date());
+                            if (!orderDetlService.updateById(orderDetl)) {
+                                throw new CoolException("鏇存柊璁㈠崟鏄庣粏澶辫触");
+                            }
+                            //妫�娴嬭鍗曟槸鍚﹀畬鎴�
+                            boolean checkOrderComplete = orderService.checkOrderComplete(orderDetl.getOrderId());
+
+                            if (checkOrderComplete) {
+                                //璁㈠崟宸茬粡瀹屾垚
+                                Order order = orderService.getById(orderDetl.getOrderId());
+                                if (order == null) {
+                                    throw new CoolException("璁㈠崟涓嶅瓨鍦�");
+                                }
+                                order.setOrderSettle(OrderSettleType.COMPLETE.val());
+                                order.setUpdateTime(new Date());
+                                if (!orderService.updateById(order)) {
+                                    throw new CoolException("璁㈠崟鏇存柊澶辫触");
+                                }
+
+                            }
+                        }
+                }
 
                 //鍒犻櫎浠诲姟鍘嗗彶妗f
                 if (!taskService.removeById(task.getId())) {
                     throw new CoolException("鍒犻櫎浠诲姟妗eけ璐�");
                 }
 
-                //淇濆瓨浠诲姟鏄庣粏鍘嗗彶妗�
-                List<TaskDetl> taskDetls = taskDetlService.getTaskDetlByTaskId(task.getId());
-                if (taskDetls.isEmpty()) {
-                    throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦�");
-                }
                 for (TaskDetl taskDetl : taskDetls) {
                     TaskDetlLog taskDetlLog = new TaskDetlLog();
                     taskDetlLog.sync(taskDetl);
@@ -111,42 +148,6 @@
                     }
                 }
 
-                //鏇存柊璁㈠崟淇℃伅
-                for (TaskDetl taskDetl : taskDetls) {
-                    if (taskDetl.getDetlId() == null) {
-                        continue;
-                    }
-
-                    OrderDetl orderDetl = orderDetlService.getById(taskDetl.getDetlId());
-                    if (orderDetl == null) {
-                        throw new CoolException("璁㈠崟鏄庣粏涓嶅瓨鍦�");
-                    }
-
-                    orderDetl.setWorkQty(orderDetl.getWorkQty() - taskDetl.getAnfme());//宸ヤ綔涓暟閲忓噺灏�
-                    orderDetl.setQty(orderDetl.getQty() + taskDetl.getAnfme());//宸插畬鎴愭暟閲忓鍔�
-                    orderDetl.setUpdateTime(new Date());
-                    if (!orderDetlService.updateById(orderDetl)) {
-                        throw new CoolException("鏇存柊璁㈠崟鏄庣粏澶辫触");
-                    }
-
-                    //妫�娴嬭鍗曟槸鍚﹀畬鎴�
-                    boolean checkOrderComplete = orderService.checkOrderComplete(orderDetl.getOrderId());
-                    if (checkOrderComplete) {
-                        //璁㈠崟宸茬粡瀹屾垚
-                        Order order = orderService.getById(orderDetl.getOrderId());
-                        if (order == null) {
-                            throw new CoolException("璁㈠崟涓嶅瓨鍦�");
-                        }
-
-                        order.setOrderSettle(OrderSettleType.COMPLETE.val());
-                        order.setUpdateTime(new Date());
-                        if (!orderService.updateById(order)) {
-                            throw new CoolException("璁㈠崟鏇存柊澶辫触");
-                        }
-                    }
-                }
-
-
             }
 
         } catch (Exception e) {
@@ -157,8 +158,8 @@
         }
     }
 
-//    @Scheduled(cron = "0/3 * * * * ? ")
-    @Transactional
+    @Scheduled(cron = "0/10 * * * * ? ")
+    @Transactional(rollbackFor = Exception.class)
     public void outExecute() {
         InterceptorIgnoreHelper.handle(IgnoreStrategy.builder().tenantLine(true).build());
         try {
@@ -171,7 +172,7 @@
             }
 
             Dict dict = dictService.getOne(new LambdaQueryWrapper<Dict>().eq(Dict::getFlag, "taskLogDiffDays").eq(Dict::getStatus, 1));
-            if(dict == null) {
+            if (dict == null) {
                 return;
             }
             for (Task task : list) {
@@ -213,6 +214,39 @@
                 taskLog.setId(null);
                 if (!taskLogService.save(taskLog)) {
                     throw new CoolException("淇濆瓨浠诲姟鍘嗗彶妗eけ璐�");
+                } else {
+                    //鏇存柊璁㈠崟淇℃伅
+                    taskDetls.forEach(taskDetl -> {
+                        if (taskDetl.getDetlId() != null) {
+                            OrderDetl orderDetl = orderDetlService.getById(taskDetl.getDetlId());
+                            if (orderDetl == null) {
+                                throw new CoolException("璁㈠崟鏄庣粏涓嶅瓨鍦�");
+                            }
+
+                            orderDetl.setWorkQty(orderDetl.getWorkQty() - taskDetl.getAnfme());//宸ヤ綔涓暟閲忓噺灏�
+                            orderDetl.setQty(orderDetl.getQty() + taskDetl.getAnfme());//宸插畬鎴愭暟閲忓鍔�
+                            orderDetl.setUpdateTime(new Date());
+                            if (!orderDetlService.updateById(orderDetl)) {
+                                throw new CoolException("鏇存柊璁㈠崟鏄庣粏澶辫触");
+                            }
+
+                            //妫�娴嬭鍗曟槸鍚﹀畬鎴�
+                            boolean checkOrderComplete = orderService.checkOrderComplete(orderDetl.getOrderId());
+                            if (checkOrderComplete) {
+                                //璁㈠崟宸茬粡瀹屾垚
+                                Order order = orderService.getById(orderDetl.getOrderId());
+                                if (order == null) {
+                                    throw new CoolException("璁㈠崟涓嶅瓨鍦�");
+                                }
+
+                                order.setOrderSettle(OrderSettleType.COMPLETE.val());
+                                order.setUpdateTime(new Date());
+                                if (!orderService.updateById(order)) {
+                                    throw new CoolException("璁㈠崟鏇存柊澶辫触");
+                                }
+                            }
+                        }
+                    });
                 }
 
                 //鍒犻櫎浠诲姟鍘嗗彶妗f
@@ -254,42 +288,6 @@
                         throw new CoolException("鏄庣粏鍒犻櫎澶辫触");
                     }
                 }
-
-                //鏇存柊璁㈠崟淇℃伅
-                for (TaskDetl taskDetl : taskDetls) {
-                    if (taskDetl.getDetlId() == null) {
-                        continue;
-                    }
-
-                    OrderDetl orderDetl = orderDetlService.getById(taskDetl.getDetlId());
-                    if (orderDetl == null) {
-                        throw new CoolException("璁㈠崟鏄庣粏涓嶅瓨鍦�");
-                    }
-
-                    orderDetl.setWorkQty(orderDetl.getWorkQty() - taskDetl.getAnfme());//宸ヤ綔涓暟閲忓噺灏�
-                    orderDetl.setQty(orderDetl.getQty() + taskDetl.getAnfme());//宸插畬鎴愭暟閲忓鍔�
-                    orderDetl.setUpdateTime(new Date());
-                    if (!orderDetlService.updateById(orderDetl)) {
-                        throw new CoolException("鏇存柊璁㈠崟鏄庣粏澶辫触");
-                    }
-
-                    //妫�娴嬭鍗曟槸鍚﹀畬鎴�
-                    boolean checkOrderComplete = orderService.checkOrderComplete(orderDetl.getOrderId());
-                    if (checkOrderComplete) {
-                        //璁㈠崟宸茬粡瀹屾垚
-                        Order order = orderService.getById(orderDetl.getOrderId());
-                        if (order == null) {
-                            throw new CoolException("璁㈠崟涓嶅瓨鍦�");
-                        }
-
-                        order.setOrderSettle(OrderSettleType.COMPLETE.val());
-                        order.setUpdateTime(new Date());
-                        if (!orderService.updateById(order)) {
-                            throw new CoolException("璁㈠崟鏇存柊澶辫触");
-                        }
-                    }
-                }
-
 
             }
         } catch (Exception e) {

--
Gitblit v1.9.1