From 2fc477de92ef724cd37a79a3679c7d605adb94ab Mon Sep 17 00:00:00 2001
From: zhangc <zc@123>
Date: 星期二, 14 一月 2025 14:57:06 +0800
Subject: [PATCH] 添加MES库存同步功能及配置

---
 src/main/java/com/zy/asrs/task/AgvWrkMastScheduler.java |   68 ++++++++++++++++++++++++---------
 1 files changed, 49 insertions(+), 19 deletions(-)

diff --git a/src/main/java/com/zy/asrs/task/AgvWrkMastScheduler.java b/src/main/java/com/zy/asrs/task/AgvWrkMastScheduler.java
index f3c8e4e..90fe463 100644
--- a/src/main/java/com/zy/asrs/task/AgvWrkMastScheduler.java
+++ b/src/main/java/com/zy/asrs/task/AgvWrkMastScheduler.java
@@ -4,6 +4,7 @@
 import com.baomidou.mybatisplus.mapper.Wrapper;
 import com.baomidou.mybatisplus.plugins.Page;
 import com.core.common.Cools;
+import com.core.common.DateUtils;
 import com.zy.asrs.entity.AgvBasDevp;
 import com.zy.asrs.entity.AgvWrkMast;
 import com.zy.asrs.service.AgvBasDevpService;
@@ -18,6 +19,7 @@
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -43,7 +45,8 @@
     /*
     瀹氭椂澶勭悊AGV宸ヤ綔妗d腑宸ヤ綔鐘舵�佷负205.宸ヤ綔瀹屾垚 涓� 锛�1.鍏ュ簱 || 53锛屾嫞鏂欏叆搴� || 57.鐩樼偣鍏ュ簱 || 10.绌烘澘鍏ュ簱 || 11.鍗曞眰绉诲簱 || 12.璺ㄥ眰绉诲簱 || 108.鑷姩璋冩嫧 || 109.鎵嬪姩璋冩嫧)鐨勬暟鎹�
      */
-    @Scheduled(cron = "0/3 * * * * ? ")
+    //@Scheduled(cron = "0/1 * * * * ? ")
+    @Scheduled(fixedDelay = 1000)
     public void excutePutwayWrk(){
         List<AgvWrkMast> agvWrkMastList = agvWrkMastService.selectList(new EntityWrapper<AgvWrkMast>()
                 .eq("wrk_sts", 205)
@@ -56,10 +59,19 @@
                 .or().eq("io_type",12)
                 .or().eq("io_type",108)
                 .or().eq("io_type",109)
-                .or().eq("io_type",112));
+                .or().eq("io_type",111)
+                .or().eq("io_type",112)
+                .or().eq("io_type",113)
+                .or().eq("io_type",114)
+                .or().eq("io_type",121)
+        );
         if(!Cools.isEmpty(agvWrkMastList)){
             agvWrkMastList.stream().forEach(agvWrkMast -> {
-                agvWrkMastHandler.completedPutWayWrk(agvWrkMast);
+                try{
+                    agvWrkMastHandler.completedPutWayWrk(agvWrkMast);
+                } catch (Exception e){
+                    log.error("宸ヤ綔鍙�"+agvWrkMast.getWrkNo()+"瀹氭椂澶勭悊AGV宸ヤ綔妗d腑宸ヤ綔鐘舵�佷负205,澶勭悊澶辫触锛�===銆嬪紓甯稿師鍥狅細"+e.getMessage());
+                }
             });
         }
     }
@@ -67,7 +79,8 @@
     /*
     瀹氭椂澶勭悊AGV宸ヤ綔妗d腑宸ヤ綔鐘舵�佷负206.鍑哄簱瀹屾垚 涓� (101.鍑哄簱 || 110.绌烘澘鍑哄簱)
      */
-    @Scheduled(cron = "0/3 * * * * ? ")
+    //@Scheduled(cron = "0/1 * * * * ? ")
+    @Scheduled(fixedDelay = 1000)
     public void excuteCarryWrk(){
         List<AgvWrkMast> agvWrkMastList = agvWrkMastService.selectList(new EntityWrapper<AgvWrkMast>()
                 .eq("wrk_sts", 206)
@@ -75,7 +88,12 @@
                 .or().eq("io_type",101));
         if(!Cools.isEmpty(agvWrkMastList)){
             agvWrkMastList.stream().forEach(agvWrkMast -> {
-                ReturnT<String> returnT = agvWrkMastHandler.completedCarryWrk(agvWrkMast);
+                try{
+                    agvWrkMastHandler.completedCarryWrk(agvWrkMast);
+                } catch (Exception e){
+                    //e.printStackTrace();
+                    log.error("宸ヤ綔鍙�"+agvWrkMast.getWrkNo()+"瀹氭椂澶勭悊AGV宸ヤ綔妗d腑宸ヤ綔鐘舵�佷负206,澶勭悊澶辫触锛�===銆嬪紓甯稿師鍥狅細"+e.getMessage());
+                }
             });
         }
     }
@@ -84,7 +102,8 @@
     /*
     瀹氭椂澶勭悊AGV宸ヤ綔妗d腑宸ヤ綔鐘舵�佷负206.鍑哄簱瀹屾垚 涓� (101.鍑哄簱 || 110.绌烘澘鍑哄簱)
      */
-    @Scheduled(cron = "0/3 * * * * ? ")
+    //@Scheduled(cron = "0/1 * * * * ? ")
+    @Scheduled(fixedDelay = 1000)
     public void excuteCarryWrk2(){
         List<AgvWrkMast> agvWrkMastList = agvWrkMastService.selectList(new EntityWrapper<AgvWrkMast>()
                 .eq("wrk_sts", 208)
@@ -92,7 +111,11 @@
                 .or().eq("io_type",101));
         if(!Cools.isEmpty(agvWrkMastList)){
             agvWrkMastList.stream().forEach(agvWrkMast -> {
-                ReturnT<String> returnT = agvWrkMastHandler.completedCarryWrk2(agvWrkMast);
+                try{
+                    agvWrkMastHandler.completedCarryWrk2(agvWrkMast);
+                } catch (Exception e){
+                    log.error("宸ヤ綔鍙�"+agvWrkMast.getWrkNo()+"瀹氭椂澶勭悊AGV宸ヤ綔妗d腑宸ヤ綔鐘舵�佷负206,澶勭悊澶辫触锛�===銆嬪紓甯稿師鍥狅細"+e.getMessage());
+                }
             });
         }
     }
@@ -102,8 +125,9 @@
     putaway锛氫笂鏋�
     瀹氭椂澶勭悊AGV宸ヤ綔妗d腑宸ヤ綔鐘舵�佷负201.鐢熸垚鍏ュ簱浠诲姟ID 涓�(鍑哄簱绫诲瀷涓� 53.鎷f枡鍐嶅叆搴� || 1.鍏ュ簱 || 10.绌烘澘鍏ュ簱鏍� || 57.鐩樼偣鍐嶅叆搴�)鐨勬暟鎹�
      */
-    @Scheduled(cron = "0/3 * * * * ? ")
-    public void startPutwayWrk(){
+    //@Scheduled(cron = "0/1 * * * * ? ")
+    @Scheduled(fixedDelay = 3000)
+    public synchronized void startPutwayWrk(){
         List<AgvWrkMast> agvWrkMastList = agvWrkMastService.selectPage(new Page<>(1, 50)
                 ,new EntityWrapper<AgvWrkMast>()
                 .eq("wrk_sts", 201)
@@ -116,14 +140,17 @@
                 .or().eq("io_type", 12)
                 .or().eq("io_type", 109)
                 .or().eq("io_type", 108)
-                .or().eq("io_type", 112)).getRecords();
+                .or().eq("io_type", 111)
+                .or().eq("io_type", 112)
+                .or().eq("io_type", 113)
+                .or().eq("io_type", 114)).getRecords();
 
         if(!Cools.isEmpty(agvWrkMastList)){
             agvWrkMastList.forEach(agvWrkMast -> {
-                try {
+                try{
                     agvWrkMastHandler.startPutWayWrk(agvWrkMast);
-                } catch (IOException e) {
-                    log.error(e.getMessage());
+                } catch (Exception e){
+                    log.error("宸ヤ綔鍙�"+agvWrkMast.getWrkNo()+"瀹氭椂澶勭悊AGV宸ヤ綔妗d腑宸ヤ綔鐘舵�佷负201,澶勭悊澶辫触锛�===銆嬪紓甯稿師鍥狅細"+e.getMessage());
                 }
             });
         }
@@ -133,7 +160,8 @@
     putaway锛氫笂鏋�
     瀹氭椂澶勭悊AGV宸ヤ綔妗d腑宸ヤ綔鐘舵�佷负201.鐢熸垚鍏ュ簱浠诲姟ID 涓�(鍑哄簱绫诲瀷涓� 53.鎷f枡鍐嶅叆搴� || 1.鍏ュ簱 || 10.绌烘澘鍏ュ簱鏍� || 57.鐩樼偣鍐嶅叆搴�)鐨勬暟鎹�
      */
-    @Scheduled(cron = "0/3 * * * * ? ")
+    //@Scheduled(cron = "0/1 * * * * ? ")
+    @Scheduled(fixedDelay = 1000)
     public void startAllcationIn(){
         List<AgvWrkMast> agvWrkMastList = agvWrkMastService.selectPage(new Page<>(1, 50)
                 ,new EntityWrapper<AgvWrkMast>()
@@ -155,7 +183,8 @@
     carry锛氭惉杩愶紝缁熸寚鍑哄簱銆佺Щ搴撱�佺偣鍒扮偣鎼繍绛�
     瀹氭椂澶勭悊AGV宸ヤ綔妗d腑宸ヤ綔鐘舵�佷负21.鐢熸垚鍑哄簱浠诲姟 涓�(鍑哄簱绫诲瀷涓� 101.鍑哄簱 || 103.鎷f枡鍑哄簱 || 11.搴撴牸绉绘牻 || 110.绌烘澘鍑哄簱 || 107.鐩樼偣鍑哄簱)鐨勬暟鎹�
      */
-    @Scheduled(cron = "0/3 * * * * ? ")
+    //@Scheduled(cron = "0/1 * * * * ? ")
+    @Scheduled(fixedDelay = 2000)
     public void startCarryWrk(){
         List<AgvWrkMast> agvWrkMastList = agvWrkMastService.selectPage(new Page<>(1, 50)
                 ,new EntityWrapper<AgvWrkMast>()
@@ -166,6 +195,7 @@
                         .or().eq("io_type", 11)
                         .or().eq("io_type", 110)
                         .or().eq("io_type", 107)
+                        .or().eq("io_type", 109)
                         .or().eq("io_type", 108)).getRecords();
 
         if(!Cools.isEmpty(agvWrkMastList)){
@@ -195,10 +225,9 @@
                     if(!Cools.isEmpty(agvWrkMastWorking)){
                         return;
                     }
-
                     agvWrkMastHandler.startPutWayWrk(agvWrkMast);
-                } catch (IOException e) {
-                    log.error(e.getMessage());
+                } catch (Exception e) {
+                    log.error("鎼繍锛岀粺鎸囧嚭搴撱�佺Щ搴撱�佺偣鍒扮偣鎼繍绛�"+e.getMessage());
                 }
             });
         }
@@ -222,7 +251,8 @@
     /*
     鑷姩鐢熸垚绌烘澘鍑哄簱浠诲姟
      */
-    @Scheduled(cron = "0/3 * * * * ? ")
+    //@Scheduled(cron = "0/1 * * * * ? ")
+    @Scheduled(fixedDelay = 1000)
     public void autoEmptyOut(){
         boolean packageEmptyAutoOUt = Cools.eq("Y",Parameter.get().getPackageEmptyAutoOUt());
         boolean mateEmptyAutoOut = Cools.eq("Y",Parameter.get().getMateEmptyAutoOut());

--
Gitblit v1.9.1