From 8554717a7abbe2889ae1d835857661dc8b91aa68 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期六, 25 五月 2024 10:05:23 +0800
Subject: [PATCH] 优化自动切换大小托盘

---
 代码管理/WMS/WMS_Server/WIDESEA_WebApi/Controllers/JobQueueTask.cs                   |   14 ++
 代码管理/WMS/WMS_Server/WIDESEA_WMS/Common/QueueTask/ReplaceTray.cs                  |  143 ++++++++++++++++++++++++++++
 代码管理/WMS/WMS_Server/WIDESEA_WebApi/Controllers/JobSendTask.cs                    |    4 
 代码管理/PCS/WCS_Server/WIDESEA_WCS/Jobs/Task/AutoTaskJob.cs                         |    3 
 代码管理/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/AGVServer.cs                      |    1 
 代码管理/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs                                 |   55 +++--------
 代码管理/WMS/WMS_Server/WIDESEA_Comm/StateEnum/LocationStateEnum.cs                  |   10 +
 代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/ReplaceTray.cs                   |    4 
 代码管理/PCS/WCS_Server/WIDESEA_Comm/StateEnum/LocationStateEnum.cs                  |    6 +
 代码管理/WMS/WMS_Server/WIDESEA_WMS/Services/system/Partial/dt_stationinfoService.cs |   15 ++-
 10 files changed, 201 insertions(+), 54 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Comm/StateEnum/LocationStateEnum.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Comm/StateEnum/LocationStateEnum.cs"
index e2c7715..80b8a1f 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Comm/StateEnum/LocationStateEnum.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Comm/StateEnum/LocationStateEnum.cs"
@@ -35,6 +35,10 @@
         /// <summary>
         /// 妗佹灦涓嬫枡
         /// </summary>
-        Load
+        Load,
+        /// <summary>
+        /// 鎵樼洏鍒囨崲
+        /// </summary>
+        Trayswitching
     }
 }
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs"
index c1ad6b1..9ad8b37 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs"
@@ -590,8 +590,6 @@
                             WriteLog.Write_Log(name + "鐢宠鏀炬枡寮傚父", "杞﹁疆SN鍙蜂负绌�", "", $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN鍙凤細{Wheel_id}涓虹┖");
                             continue;
                         }
-
-
                         var Work = workinfoRepository.Find(x => x.SN == Wheel_id && x.processCode == "17").FirstOrDefault();
                         if (Work == null)
                         {
@@ -600,22 +598,7 @@
                             WriteLog.Write_Log(name + "鐢宠鏀炬枡寮傚父", Wheel_id, "鏌ヨ鏈哄姞宸ュ伐鍗�", $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN鍙凤細{Wheel_id}鏈煡璇㈠埌宸ュ崟淇℃伅\n鍐欏叆妗佹灦淇℃伅锛歕n鏄惁鍏佽涓嬫枡锛歿false}");
                             continue;
                         }
-
-
                         #endregion
-
-
-
-                        #region MyRegion
-                        //var currentAreaNr = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "W_Are00aNr").First(), client);
-                        //var currentAreaCode = PipelineJob.area_code(name);   //鏍规嵁涓嬫枡鍙e崟鍏冨悕鑾峰彇鍖哄煙浠g爜
-                        //var currentStation = stationinfoRepository.FindFirst(x => x.area == currentAreaCode && x.stationCode.Substring(x.stationCode.Length - 1, 1) == currentAreaNr.ToString());
-                        //if (!currentStation.enable || currentStation.location_state == LocationStateEnum.Empty.ToString())
-                        //    client.WriteByOrder("W_Enabl_Load", false, name);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆
-                        #endregion
-
-
-
 
                         var wheel = Pipeline.QueryMateriel(Work.drawingNo);
                         var wheel1 = Pipeline.QueryMateriel1(Work.drawingNo);
@@ -639,6 +622,21 @@
                                 agvtask(stationinfoRepository, station, Work, "TaskType_Inbound");
                         }
                         #endregion
+
+                        #region 鎵樼洏绫诲瀷涓嶄竴鑷撮渶鏇存崲鎵樼洏
+                        foreach (var Stationinfo in Stations)
+                        {
+                            if (Stationinfo.tray_type != "LargeTray" && (wheel == null ? wheel1.e : wheel.e) > 1100)
+                            {
+                                client.WriteByOrder("W_Enabl_Load", false, name);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆
+                                Stationinfo.location_state = LocationStateEnum.Trayswitching.ToString();
+                                Stationinfo.remark = "鎵樼洏绫诲瀷涓嶄竴鑷撮渶鏇存崲鎵樼洏";
+                                stationinfoRepository.Update(Stationinfo, x => new { x.location_state }, true);
+                            }
+                        }
+                        #endregion
+
+                        Stations = stationinfoRepository.Find(x => x.area == Pipeline.area_code(name)).OrderBy(x => x.lastUpdateTime).ToList();
 
                         var PartStatus = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PartStatus").First(), client);//1:ok;2:nok
 
@@ -708,18 +706,6 @@
                                         agvtask(stationinfoRepository, stationinfo, Work, name == "3鍗曞厓涓嬫枡鍖�" ? "TaskType_OutsourceInbound" : "TaskType_Inbound");
                                 }
 
-                                #endregion
-
-                                #region 鎵樼洏绫诲瀷涓嶄竴鑷撮渶鏇存崲鎵樼洏
-                                if (Stationinfo.tray_type != "LargeTray" && (wheel == null ? wheel1.e : wheel.e) > 1100)
-                                {
-                                    client.WriteByOrder("W_Enabl_Load", false, name);//淇″彿涓篺alse妗佹灦鍋滄杩涘叆
-                                    Stationinfo.location_state = LocationStateEnum.Abnormal.ToString();
-                                    Stationinfo.tray_type = Stationinfo.tray_type == "SmallTray" ? "SmallTray/LargeTray" : "LargeTray/SmallTray";
-                                    Stationinfo.remark = "鎵樼洏绫诲瀷涓嶄竴鑷撮渶鏇存崲鎵樼洏";
-                                    stationinfoRepository.Update(Stationinfo, true);
-                                    continue;
-                                }
                                 #endregion
 
                                 var Pipelinedetails = plcRepository.Find(x => x.plcdetail_iotype == Pipelineplc.plcinfo_iotyep && x.plcdetail_number == Stationinfo.stationCode).ToList();
@@ -831,17 +817,6 @@
                             }
                             if (Stationinfo != null)
                             {
-                                #region 鎵樼洏绫诲瀷涓嶄竴鑷撮渶鏇存崲鎵樼洏
-                                //if (Stationinfo.tray_type != ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray"))
-                                if (Stationinfo.tray_type != "LargeTray" && (wheel == null ? wheel1.e : wheel.e) > 1100)
-                                {
-                                    Stationinfo.location_state = LocationStateEnum.Abnormal.ToString();
-                                    Stationinfo.tray_type = Stationinfo.tray_type == "SmallTray" ? "SmallTray/LargeTray" : "LargeTray/SmallTray";
-                                    Stationinfo.remark = "鎵樼洏绫诲瀷涓嶄竴鑷撮渶鏇存崲鎵樼洏";
-                                    stationinfoRepository.Update(Stationinfo, true);
-                                    continue;
-                                }
-                                #endregion
                                 var Pipelinedetails = plcRepository.Find(x => x.plcdetail_iotype == Pipelineplc.plcinfo_iotyep && x.plcdetail_number == Stationinfo.stationCode).ToList();
                                 var PalletSignal = (Int16)DBExtension.Read(Pipelinedetails.Where(x => x.plcdetail_name == "R_PalletSignal").First(), Pipeline_client);//璇诲彇鎵樼洏淇″彿:1:鏈�,2鏃�
                                 var MaterialSignal = (Int16)DBExtension.Read(Pipelinedetails.Where(x => x.plcdetail_name == "R_MaterialSignal").First(), Pipeline_client);//璇诲彇璐х墿淇″彿:1:鏈�,2鏃�
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/Task/AutoTaskJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/Task/AutoTaskJob.cs"
index d3978c3..87e801e 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/Task/AutoTaskJob.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/Task/AutoTaskJob.cs"
@@ -30,10 +30,9 @@
 
         private void DoAction(IJobExecutionContext context)
         {
-            //EmptyTray.EmptyTrayIn();//绌烘墭鍙犵洏鍏ュ簱
             StationTask.CreateTask();//鍏ュ簱
             OutboundTask.CreateOutboundTask();//鍑哄簱
-            ReplaceTray.ReplaceTrayTask();//鏇存崲鎵樼洏
+            //ReplaceTray.ReplaceTrayTask();//鏇存崲鎵樼洏
             RestockHCJ.HCJGetBarcode();//鏇存柊闃熷垪
             EmptyTrayTask.CreateEmptyTrayTask();//鍒涘缓琛ョ┖鎵�
             AutoUpdateWork.FinishMesWork();//澶勭悊宸ュ崟
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/ReplaceTray.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/ReplaceTray.cs"
index 32e1d90..4962644 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/ReplaceTray.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/ReplaceTray.cs"
@@ -55,10 +55,10 @@
         {
             try
             {
-                VOLContext context = new VOLContext(); 
+                VOLContext context = new VOLContext();
                 Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context);
                 Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(context);//"Abnormal" 
-                var stations = stationinfoRepository.Find(x => (x.stationCode.Contains("X") || x.stationCode.Contains("W01001004") || x.stationCode.Contains("W01001005")) && x.location_state == LocationStateEnum.Abnormal.ToString() && (x.tray_type == "SmallTray/LargeTray" || x.tray_type == "LargeTray/SmallTray") && x.enable).ToList();
+                var stations = stationinfoRepository.Find(x => (x.stationCode.Contains("X") || x.stationCode.Contains("W01001004") || x.stationCode.Contains("W01001005")) && x.location_state == LocationStateEnum.Trayswitching.ToString() && x.enable).ToList();
                 foreach (var station in stations)
                 {
                     if (agvtaskRepository.Find(x => x.agv_fromaddress == station.stationCode || x.agv_toaddress == station.stationCode).Any()) continue;
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_Comm/StateEnum/LocationStateEnum.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_Comm/StateEnum/LocationStateEnum.cs"
index 2e3dab7..80b8a1f 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_Comm/StateEnum/LocationStateEnum.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_Comm/StateEnum/LocationStateEnum.cs"
@@ -31,6 +31,14 @@
         /// <summary>
         /// 寮傚父
         /// </summary>
-        Abnormal
+        Abnormal,
+        /// <summary>
+        /// 妗佹灦涓嬫枡
+        /// </summary>
+        Load,
+        /// <summary>
+        /// 鎵樼洏鍒囨崲
+        /// </summary>
+        Trayswitching
     }
 }
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/AGVServer.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/AGVServer.cs"
index e55620e..4257532 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/AGVServer.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/AGVServer.cs"
@@ -25,7 +25,6 @@
         /// </summary>
         public static void SendAgvTask()
         {
-            WriteLog.Write_Log("鑷姩涓嬪彂浠诲姟", "SendAgvTask", "");
             Respone respone = new Respone();
             RequestTask requestTask = new RequestTask();
             string postJson = string.Empty;
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Common/QueueTask/ReplaceTray.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Common/QueueTask/ReplaceTray.cs"
new file mode 100644
index 0000000..d6c076e
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Common/QueueTask/ReplaceTray.cs"
@@ -0,0 +1,143 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Cryptography.Xml;
+using System.Text;
+using System.Threading.Tasks;
+using WIDESEA_Comm;
+using WIDESEA_Comm.LogInfo;
+using WIDESEA_Comm.TaskNo;
+using WIDESEA_Common;
+using WIDESEA_Core.BaseProvider;
+using WIDESEA_Core.EFDbContext;
+using WIDESEA_Core.ManageUser;
+using WIDESEA_Entity.DomainModels;
+using WIDESEA_WCS.IRepositories;
+using WIDESEA_WCS.Repositories;
+using WIDESEA_WMS.IRepositories;
+using WIDESEA_WMS.Repositories;
+using static FreeSql.Internal.GlobalFilter;
+using static System.Collections.Specialized.BitVector32;
+
+namespace WIDESEA_WMS.Common
+{
+    public class QueueTask
+    {
+        /// <summary>
+        /// 鍒涘缓鏇存崲鎵樼洏浠诲姟,闇�淇敼
+        /// </summary>
+        public static void ReplaceTrayTask()
+        {
+            try
+            {
+                VOLContext context = new VOLContext();
+                Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context);
+                Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(context);
+                IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(context);
+                var stations = stationinfoRepository.Find(x => (x.stationCode.Contains("X") || x.stationCode.Contains("W01001004") || x.stationCode.Contains("W01001005")) && x.location_state == LocationStateEnum.Trayswitching.ToString() && x.enable).ToList();
+                foreach (var station in stations)
+                {
+                    var task = agvtaskRepository.Find(x => x.agv_toaddress == station.stationCode).FirstOrDefault();
+                    if (task != null)
+                    {
+                        if (task.agv_taskstate != AGVTaskStateEnum.Queue.ToString()) continue;
+                        task.agv_Traytype = station.tray_type == TrayTypeEnum.SmallTray.ToString() ? TrayTypeEnum.LargeTray.ToString() : TrayTypeEnum.SmallTray.ToString();
+                        agvtaskRepository.Update(task, x => new { x.agv_Traytype }, true);
+                    }
+                    else if (!agvtaskRepository.Find(x => x.agv_fromaddress == station.stationCode).Any())
+                    {
+                        #region 涓虹┖鎵樺苟涓旀暟閲忎负0,鍒涘缓鍙栫┖鎵樹换鍔�
+                        if (station.tray_status == TrayStateEnum.EmptyTray.ToString() && station.quantity == 0)
+                        {
+                            dt_agvtask agvtask = new dt_agvtask()
+                            {
+                                agv_fromaddress = station.stationCode,
+                                agv_id = Guid.NewGuid(),
+                                agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"),
+                                agv_grade = 1,
+                                agv_createtime = DateTime.Now,
+                                agv_taskstate = AGVTaskStateEnum.Queue.ToString(),
+                                agv_qty = 1,
+                                StarQuantity = 0,
+                                EndQuantity = 0,
+                                agv_tasktype = AGVTaskTypeEnum.TaskType_EmptyPallet.ToString(),
+                                agv_toaddress = "",
+                                agv_userid = "WMS",
+                                agv_TrayStatus = station.tray_status,
+                                agv_Traytype = station.tray_type
+                            };
+                            agvtaskRepository.Add(agvtask, true);
+
+                            station.location_state = LocationStateEnum.Busy.ToString();
+                        }
+                        #endregion
+
+                        #region 鍒涘缓鍏ュ簱浠诲姟
+                        else if (station.location_state == LocationStateEnum.Stroge.ToString() && station.quantity > 0)
+                        {
+                            var Work = workinfoRepository.Find(x => x.workOrder == station.Number && x.processCode == "17").FirstOrDefault();
+                            if (Work == null) throw new Exception($"鏈壘鍒拌揣浣峽station.stationCode}鐨勬満鍔犲伐宸ュ崟淇℃伅锛�");
+                            dt_agvtask agvtask = new dt_agvtask()
+                            {
+                                agv_fromaddress = station.stationCode,
+                                agv_id = Guid.NewGuid(),
+                                agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"),
+                                agv_grade = 1,
+                                agv_createtime = DateTime.Now,
+                                agv_taskstate = AGVTaskStateEnum.Queue.ToString(),
+                                agv_materielid = station.stationType,
+                                agv_qty = station.quantity,
+                                agv_tasktype = station.stationCode.Contains("3") ? AGVTaskTypeEnum.TaskType_OutsourceInbound.ToString() : AGVTaskTypeEnum.TaskType_Inbound.ToString(),
+                                agv_toaddress = "",
+                                agv_userid = "WMS",
+                                bindSN = station.bindSN,
+                                agv_worktype = Convert.ToInt32(Work.processCode),
+                                agv_materbarcode = Work.materialCode,
+                                agv_Traytype = station.tray_type,
+                                jobID = station.Number,
+                                agv_TrayStatus = station.tray_status
+                            };
+                            agvtaskRepository.Add(agvtask, true);
+
+                            station.location_state = LocationStateEnum.InBusy.ToString();
+                        }
+                        #endregion
+                    }
+                    station.tray_type = station.tray_type == TrayTypeEnum.SmallTray.ToString() ? TrayTypeEnum.LargeTray.ToString() : TrayTypeEnum.SmallTray.ToString();
+                    stationinfoRepository.Update(station, x => new { x.location_state, x.tray_type }, true);
+                }
+            }
+            catch (Exception ex)
+            {
+                WriteDBLog.Error("鍒涘缓鏇存崲绌虹洏浠诲姟", $"閿欒淇℃伅锛歿ex.Message}", "PCS");
+            }
+        }
+        /// <summary>
+        /// 鍒涘缓瀹屾暣鐨勮ˉ绌烘墭浠诲姟
+        /// </summary>
+        /// <param name="agvtask"></param>
+        public static void CreatePartQueue(Idt_agvtaskRepository agvtaskRepository, dt_agvtask agvtask, string type = "")
+        {
+            //if (agvtask.agv_fromaddress.Contains("X") || agvtask.agv_fromaddress.Contains("W01001004") || agvtask.agv_fromaddress.Contains("W01001005"))
+            //{
+            dt_agvtask taskPart = new dt_agvtask()
+            {
+                agv_fromaddress = "",
+                agv_id = Guid.NewGuid(),
+                agv_tasknum = agvtask.agv_tasknum + "_1",
+                agv_grade = 1,
+                agv_createtime = DateTime.Now,
+                agv_taskstate = "Queue",
+                agv_qty = 1,
+                agv_tasktype = "TaskType_EmptyPallet",
+                agv_toaddress = agvtask.agv_fromaddress,
+                agv_userid = "绯荤粺",
+                agv_TrayStatus = agvtask.agv_TrayStatus,
+                agv_Traytype = type,
+            };
+            agvtaskRepository.Add(taskPart, true);
+            WriteDBLog.Success("鍒涘缓鏇存崲绌虹洏浠诲姟", $"浠诲姟缂栧彿锛歿taskPart.agv_tasknum}", "PCS");
+            //}
+        }
+    }
+}
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Services/system/Partial/dt_stationinfoService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Services/system/Partial/dt_stationinfoService.cs"
index 6230dc3..bef8d16 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Services/system/Partial/dt_stationinfoService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Services/system/Partial/dt_stationinfoService.cs"
@@ -111,20 +111,25 @@
             VOLContext context = new VOLContext();
             Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(context);
             IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(context);
-            string completor = UserContext.Current.UserName;
             foreach (var Key in saveModel.DelKeys)
             {
                 try
                 {
                     var station = repository.Find(x => x.id.ToString() == Key.ToString()).FirstOrDefault();
-                    if (!station.stationCode.Contains("X")) throw new Exception($"鏃爗station.stationCode}浣跨敤鏉冮檺锛�");
+                    if (!station.stationCode.Contains("X") && !station.stationCode.Contains("W01001004") && !station.stationCode.Contains("W01001005")) throw new Exception($"鏃爗station.stationCode}浣跨敤鏉冮檺锛�");
                     if (!station.enable) throw new Exception($"{station.stationCode}鏈惎鐢紒");
                     if (station.location_state == LocationStateEnum.Abnormal.ToString()) throw new Exception($"{station.stationCode}鐘舵�佸紓甯革紒");
                     if (station.location_state == LocationStateEnum.Empty.ToString()) throw new Exception($"{station.stationCode}鐘舵�佷负绌猴紒");
                     if (station.remark == "妗佹灦涓嬫枡") throw new Exception($"{station.stationCode}妗佹灦姝e湪涓嬫枡锛�");
-                    if (agvtaskRepository.Find(x => x.agv_toaddress == station.stationCode).Any()) throw new Exception($"{station.stationCode}瀛樺湪浠诲姟锛�");
-                    
-                    if (!agvtaskRepository.Find(x => x.agv_fromaddress == station.stationCode).Any())
+
+                    var task = agvtaskRepository.Find(x => x.agv_toaddress == station.stationCode).FirstOrDefault();
+                    if (task != null)
+                    {
+                        if (task.agv_taskstate != AGVTaskStateEnum.Queue.ToString()) throw new Exception($"{station.stationCode}瀛樺湪浠诲姟锛�");
+                        task.agv_Traytype = station.tray_type == TrayTypeEnum.SmallTray.ToString() ? TrayTypeEnum.LargeTray.ToString() : TrayTypeEnum.SmallTray.ToString();
+                        agvtaskRepository.Update(task, x => new { x.agv_Traytype }, true);
+                    }
+                    else if (!agvtaskRepository.Find(x => x.agv_fromaddress == station.stationCode).Any())
                     {
                         #region 涓虹┖鎵樺苟涓旀暟閲忎负0,鍒涘缓鍙栫┖鎵樹换鍔�
                         if (station.tray_status == TrayStateEnum.EmptyTray.ToString() && station.quantity == 0)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WebApi/Controllers/JobQueueTask.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WebApi/Controllers/JobQueueTask.cs"
new file mode 100644
index 0000000..48d3bd6
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WebApi/Controllers/JobQueueTask.cs"
@@ -0,0 +1,14 @@
+锘縰sing Pomelo.AspNetCore.TimedJob;
+using WIDESEA_WMS.Common;
+
+namespace WIDESEA_WebApi.Controllers
+{
+    public class JobQueueTask : Job
+    {
+        [Invoke(Begin = "2024-01-01 00:00", Interval = 1000 * 2, /*IsEnabled = true,*/ SkipWhileExecuting = true)]
+        public void QueueTaskTiem()
+        {
+            QueueTask.ReplaceTrayTask();
+        }
+    }
+}
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WebApi/Controllers/JobTask.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WebApi/Controllers/JobSendTask.cs"
similarity index 87%
rename from "\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WebApi/Controllers/JobTask.cs"
rename to "\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WebApi/Controllers/JobSendTask.cs"
index 95174be..821dbcf 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WebApi/Controllers/JobTask.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WebApi/Controllers/JobSendTask.cs"
@@ -7,10 +7,10 @@
 
 namespace WIDESEA_WebApi.Controllers
 {
-    public class JobTask : Job
+    public class JobSendTask : Job
     {
         [Invoke(Begin = "2024-01-01 00:00", Interval = 1000 * 5, /*IsEnabled = true,*/ SkipWhileExecuting = true)]
-        public void TaskTime()
+        public void SendTaskTime()
         {
             AGVServer.SendFromaddress();
             AGVServer.SendToaddress();

--
Gitblit v1.9.3