From 67954f1959b432c39c0988d092e7ce1d19b71354 Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期一, 23 三月 2026 08:44:43 +0800
Subject: [PATCH] 优化提升机job

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs |   10 +-
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/TSJJob.cs                |   70 +++++++++++------
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/ScheduledTaskJob.cs |  113 +++++++++++++++-------------
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/TaskJob.cs          |    4 
 4 files changed, 112 insertions(+), 85 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs"
index 8d78b60..9d4026f 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs"
@@ -100,7 +100,7 @@
                                     {
                                         DeviceProDTO? deviceProDTO = device.DeviceProDTOs.FirstOrDefault((DeviceProDTO x) => x.DeviceProParamName == HoistEnum.Inboundboxon.ToString());
                                         if (device.IsConnected)
-                                            device.SetValue(HoistEnum.Inboundboxon, 1);//鍏ュ簱瀹屾垚
+                                            device.SetValue(HoistEnum.Inboundboxon, 1);//
                                         else
                                             task.ExceptionMessage = "鎻愬崌鏈轰俊鎭澶囪繛鎺ュけ璐�";
                                     }
@@ -114,12 +114,12 @@
                                     else
                                     {
                                         if (device.IsConnected)
-                                            device.SetValue(HoistEnum.Outboundboxon, 1);//鍑哄簱瀹屾垚
+                                            device.SetValue(HoistEnum.Outboundboxon,1);//鍑哄簱瀹屾垚
                                         else
                                             task.ExceptionMessage = "鎻愬崌鏈轰俊鎭澶囪繛鎺ュけ璐�";
                                     }
                                 }
-                                //鍥涙ゼ 鍏ュ簱
+                                //鍥涙ゼ 鍑哄簱
                                 if (task.TaskType == TaskTypeEnum.CHUKU1.ObjToInt() && task.TaskState == (int)TaskStatusEnum.AGV_ToExecute)
                                 {
                                     var device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "TSJ") as OtherDevice;
@@ -132,7 +132,7 @@
                                             task.ExceptionMessage = "鎻愬崌鏈轰俊鎭澶囪繛鎺ュけ璐�";
                                     } 
                                 }
-                                //鍥涙ゼ 鍑哄簱
+                                //鍥涙ゼ 鍏ュ簱
                                 if (task.TaskType == TaskTypeEnum.Q1TSJ4.ObjToInt() && task.TaskState == (int)TaskStatusEnum.AGV_ToExecute)
                                 {
                                     var device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "TSJ") as OtherDevice;
@@ -141,7 +141,7 @@
                                     {
                                         if (device.IsConnected)
                                             //鍐欎互涓�涓嚭搴撳畬鎴愪俊鍙�
-                                            device.SetValue(HoistEnum.Outboundboxretrievalcompleted, "1");
+                                            device.SetValue(HoistEnum.Outboundboxretrievalcompleted,"1",task.SourceAddress);
                                         else
                                             task.ExceptionMessage = "鎻愬崌鏈轰俊鎭澶囪繛鎺ュけ璐�";
                                     } 
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/TSJJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/TSJJob.cs"
index 49bc592..f667d86 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/TSJJob.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/TSJJob.cs"
@@ -69,12 +69,12 @@
                             continue;
                             //throw new Exception("璁惧鏁呴殰");
                         }
-                        if (task.TaskType == TaskTypeEnum.RK3F.ObjToInt()|| task.TaskType == TaskTypeEnum.CHUKU1.ObjToInt())
+                        if (task.TaskType == TaskTypeEnum.RK3F.ObjToInt()|| task.TaskType == TaskTypeEnum.Q1TSJ4.ObjToInt())
                         {
                             if (task.TaskType == TaskTypeEnum.RK3F.ObjToInt())
                             {
                                 //鍒ゆ柇3妤煎叆搴撶鍙锋湁鏃�
-                                if (device.GetValue<HoistEnum, short>(HoistEnum.OutboundInplace, task.SourceAddress) != 2)
+                                if (device.GetValue<HoistEnum, short>(HoistEnum.OutboundInplace, task.TargetAddress) != 2)
                                 {
                                     if (task.ExceptionMessage == "3妤煎叆搴撶鍙锋湁璐э紝璇峰厛澶勭悊")
                                     {
@@ -87,27 +87,21 @@
                             }
                             else
                             {
-                                //鍥炵┖绠辩殑鏃跺�欒璇讳竴涓悧
-                                if (device.GetValue<HoistEnum, string>(HoistEnum.Emptycontainernumber, task.SourceAddress) == null)
+
+                                #region 4妤煎叆搴�
+                                //4妤煎嚭搴撴枡绠卞埌浣�
+                                if (device.GetValue<HoistEnum, short>(HoistEnum.FOutboundmaterialbox, task.SourceAddress) != 1)
                                 {
-                                    if (task.ExceptionMessage != "4妤肩┖绠�,璇荤爜鍣ㄦ病鏈夎鍒板��")
+                                    if (task.ExceptionMessage != "4妤煎叆搴撴枡绠辨病鏈夊埌浣�")
                                     {
-                                        task.ExceptionMessage = "4妤肩┖绠�,璇荤爜鍣ㄦ病鏈夎鍒板��";
+                                        task.ExceptionMessage = "4妤煎叆搴撴枡绠辨病鏈夊埌浣�";
                                         Uptasks.Add(task);
                                     }
                                     continue;
                                 }
-                                //鍒ゆ柇4妤肩┖绠卞埌浣�
-                                if (device.GetValue<HoistEnum, short>(HoistEnum.ReturnbinAvailable, task.SourceAddress) == 2)
-                                {
-                                    if (task.ExceptionMessage != "TSJ4妤煎洖鏂欑涓虹┖")
-                                    {
-                                        task.ExceptionMessage = "TSJ4妤煎洖鏂欑涓虹┖";
-                                        Uptasks.Add(task);
-                                    }
-                                    continue;
-                                }
-                              
+
+                                #endregion
+                            
                             }
 
 
@@ -133,8 +127,10 @@
                         {
                             ////鍑哄簱鏂欑缂撳瓨鏁伴噺(杩欎釜鏄簱鍖烘煡璇㈢殑鏃跺�欒鏌ヤ竴涓嬶紝杩旂粰wms)
                             //if (device.GetValue<HoistEnum, short>(HoistEnum.Outboundmaterialbox, "TSJ") == 0) throw new Exception("娌℃湁鍑哄簱鏂欑缂撳瓨鏁伴噺涓虹┖");
+
+
                             //璇诲彇3妤煎嚭搴撴枡绠卞埌浣�
-                            if (device.GetValue<HoistEnum, short>(HoistEnum.SOutboundmaterialbox, task.TargetAddress) != 1)
+                            if (device.GetValue<HoistEnum, short>(HoistEnum.SOutboundmaterialbox, task.SourceAddress) != 1)
                             {
                                 if (task.ExceptionMessage != "3妤煎嚭搴撴枡绠辨病鏈夊埌浣�")
                                 {
@@ -158,21 +154,43 @@
                             task.ExceptionMessage = "";
                             Uptasks.Add(task);
                         }
-                        else if (task.TaskType == TaskTypeEnum.Q1TSJ4.ObjToInt())//鍜�3妤煎嚭搴撲腑涓�鏍凤紱
+                        else if (task.TaskType == TaskTypeEnum.CHUKU1.ObjToInt())//4妤煎嚭搴撲换鍔�
                         {
-                            #region 4妤煎嚭搴�
-                            //4妤煎嚭搴撴枡绠卞埌浣�
-                            if (device.GetValue<HoistEnum, short>(HoistEnum.FOutboundmaterialbox, task.TargetAddress) != 2)
+
+                            #region 鍑哄簱淇″彿
+                            //鍥炵┖绠辩殑鏃跺�欒璇讳竴涓悧
+                            if (device.GetValue<HoistEnum, string>(HoistEnum.Emptycontainernumber, task.TargetAddress) == null)
                             {
-                                if (task.ExceptionMessage != "4妤煎嚭搴撴枡绠辨病鏈夊埌浣�")
+                                if (task.ExceptionMessage != "4妤肩┖绠�,璇荤爜鍣ㄦ病鏈夎鍒板��")
                                 {
-                                    task.ExceptionMessage = "3妤煎叆搴撶鍙锋湁璐э紝璇峰厛澶勭悊";
+                                    task.ExceptionMessage = "4妤肩┖绠�,璇荤爜鍣ㄦ病鏈夎鍒板��";
                                     Uptasks.Add(task);
                                 }
                                 continue;
                             }
-                           
+                            //鍒ゆ柇4妤肩┖绠卞埌浣�
+                            if (device.GetValue<HoistEnum, short>(HoistEnum.ReturnbinAvailable, task.TargetAddress) != 2)
+                            {
+                                if (task.ExceptionMessage != "鎻愬崌鏈哄叆搴撶┖鏃犺揣")
+                                {
+                                    task.ExceptionMessage = "鎻愬崌鏈哄叆搴撶┖鏃犺揣";
+                                    Uptasks.Add(task);
+                                }
+                                continue;
+                            }
                             #endregion
+                            //鐒跺悗璋冪敤杈撻�佺嚎鎺ュ彛锛岄�氱煡杈撻�佺嚎鏈夋枡绠遍渶瑕佸叆搴擄紝浠诲姟涓捐鎵ц
+                            var result = _taskService.Hikvisiontaskscontinue(task.WMSTaskNum);
+                            if (result.Status == false)
+                            {
+                                if (task.ExceptionMessage != result.Message)
+                                {
+                                    task.ExceptionMessage = result.Message;
+                                    Uptasks.Add(task);
+                                }
+                                continue;
+                            }
+
                             task.TaskState = (int)TaskStatusEnum.AGV_ToExecute;
                             task.ExceptionMessage = "";
                             Uptasks.Add(task);
@@ -190,7 +208,7 @@
                     {
                         var Barcode = device.SetValue<HoistEnum, short>(HoistEnum.Codereadingtriggered, 1);
                         //妫�鏌�3妤煎叆搴撶鍙锋槸澶氬皯锛岀劧鍚庝紶缁檞ms
-                        var BinNumber = device.GetValue<HoistEnum, string>(HoistEnum.Inboxnumber, "TSJ");
+                        var BinNumber = device.GetValue<HoistEnum, string>(HoistEnum.Inboxnumber, RK3FTasks.TargetAddress);
                         //鏍规嵁璇诲埌鐨勭鍙疯繘琛屾枡绠辨楠岋紝妫�楠岄�氳繃灏辫Е鍙戣鐮佸櫒璇诲彇锛屽鏋滀笉閫氳繃灏辨姏鍑哄紓甯�
                         //var Verification = _taskService.MaterialBoxInspection(RK3FTasks.WMSTaskNum, BinNumber.ToString());
                         //if (!Verification.Status)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/ScheduledTaskJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/ScheduledTaskJob.cs"
index b83c5ec..885f017 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/ScheduledTaskJob.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/ScheduledTaskJob.cs"
@@ -79,33 +79,37 @@
                 {
                     if (device.GetValue<HoistEnum, short>(HoistEnum.SOutboundmaterialbox, "TSJC3F") == 1)
                     {
-                        station = stations.FirstOrDefault(x => x.StationStatus == (int)LocationStatusEnum.Free);
-                        if (station != null)
+                        Dt_Task dt_Task = _taskService.Repository.QueryFirst(x => x.SourceAddress == "TSJC3F");
+                        if (dt_Task == null)
                         {
-                            var tasknum = _taskService.GetTaskNum(nameof(SequenceEnum.SeqTaskNum));
-                            Dt_Task dt_Task = new Dt_Task()
+                            station = stations.FirstOrDefault(x => x.StationStatus == (int)LocationStatusEnum.Free);
+                            if (station != null)
                             {
-                                TaskNum = tasknum,
-                                WMSTaskNum = "GP" + tasknum,
-                                Grade = 60,
-                                PalletCode = station.PalletCode,
-                                Roadway = "",
-                                TaskState = (int)TaskStatusEnum.New,
-                                TaskType = TaskTypeEnum.CK3F.ObjToInt(),
-                                SourceAddress = "TSJC3F",
-                                CurrentAddress = "TSJC3F",
-                                NextAddress = station.StationCode,
-                                TargetAddress = station.StationCode,
-                                Creater = "WCS",
-                            };
-                            var content = _taskService.SendHIKROBOTTask(dt_Task);
-                            if (content.Status)
-                            {
-                                dt_Task.TaskState = (int)TaskStatusEnum.Execut;
-                                dt_Task.Dispatchertime = DateTime.Now;
-                                station.StationStatus = (int)LocationStatusEnum.InLock;
-                                _taskService.AddData(dt_Task);
-                                _StationInfoService.UpdateData(station);
+                                var tasknum = _taskService.GetTaskNum(nameof(SequenceEnum.SeqTaskNum));
+                                dt_Task = new Dt_Task()
+                                {
+                                    TaskNum = tasknum,
+                                    WMSTaskNum = "GP" + tasknum,
+                                    Grade = 60,
+                                    PalletCode = "LXM" + tasknum,
+                                    Roadway = "",
+                                    TaskState = (int)TaskStatusEnum.New,
+                                    TaskType = TaskTypeEnum.CK3F.ObjToInt(),
+                                    SourceAddress = "TSJC3F",
+                                    CurrentAddress = "TSJC3F",
+                                    NextAddress = station.StationCode,
+                                    TargetAddress = station.StationCode,
+                                    Creater = "WCS",
+                                };
+                                var content = _taskService.SendHIKROBOTTask(dt_Task);
+                                if (content.Status)
+                                {
+                                    dt_Task.TaskState = (int)TaskStatusEnum.Execut;
+                                    dt_Task.Dispatchertime = DateTime.Now;
+                                    station.StationStatus = (int)LocationStatusEnum.InLock;
+                                    _taskService.AddData(dt_Task);
+                                    _StationInfoService.UpdateData(station);
+                                }
                             }
                         }
                     }
@@ -115,7 +119,7 @@
                 #endregion
 
                 #region 鍥涙ゼ鑷姩浠诲姟
-                List<string> LocationCodes = new() { "RGD0304A04011", "RG0105A04031", "RG0202A05021" };
+                List<string> LocationCodes = new() { "RGD0303A04041","RG0302A05041","RG0304A05041","RG0205A05031" };
                 var hKLocationInfos = _HKLocationInfoService.Repository.QueryData(x => LocationCodes.Contains(x.LocationCode));
                 #region 鍏ユ彁鍗囨満浠诲姟
                 var hKLocation = hKLocationInfos.FirstOrDefault(x => x.LocationStatus == (int)LocationStatusEnum.InStock);
@@ -152,37 +156,42 @@
                 #region 鍑烘彁鍗囨満浠诲姟
                 if (device != null && device.IsConnected)
                 {
-                    if (device.GetValue<HoistEnum, short>(HoistEnum.FOutboundmaterialbox, "TSJC3F") == 1)
+                    if (device.GetValue<HoistEnum, short>(HoistEnum.FOutboundmaterialbox, "TSJC4F") == 1)
                     {
-                        hKLocation = hKLocationInfos.FirstOrDefault(x => x.LocationStatus == (int)LocationStatusEnum.Free);
-                        if (hKLocation != null)
+                        Dt_Task dt_Task = _taskService.Repository.QueryFirst(x => x.SourceAddress == "TSJC4F");
+                        if (dt_Task == null)
                         {
-                            var tasknum = _taskService.GetTaskNum(nameof(SequenceEnum.SeqTaskNum));
-                            Dt_Task dt_Task = new Dt_Task()
+                            hKLocation = hKLocationInfos.FirstOrDefault(x => x.LocationStatus == (int)LocationStatusEnum.Free);
+                            if (hKLocation != null)
                             {
-                                TaskNum = tasknum,
-                                WMSTaskNum = "GP" + tasknum,
-                                Grade = 60,
-                                PalletCode = hKLocation.PalletCode,
-                                Roadway = "",
-                                TaskState = (int)TaskStatusEnum.New,
-                                TaskType = TaskTypeEnum.Q1TSJ4.ObjToInt(),
-                                SourceAddress = "TSJC4F",
-                                CurrentAddress = "TSJC4F",
-                                NextAddress = hKLocation.LocationCode,
-                                TargetAddress = hKLocation.LocationCode,
-                                Creater = "WCS",
-                            };
-                            var content = _taskService.SendHIKROBOTTask(dt_Task);
-                            if (content.Status)
-                            {
-                                dt_Task.TaskState = (int)TaskStatusEnum.Execut;
-                                dt_Task.Dispatchertime = DateTime.Now;
-                                hKLocation.LocationStatus = (int)LocationStatusEnum.InLock;
-                                _taskService.AddData(dt_Task);
-                                _HKLocationInfoService.UpdateData(hKLocation);
+                                var tasknum = _taskService.GetTaskNum(nameof(SequenceEnum.SeqTaskNum));
+                                 dt_Task = new Dt_Task()
+                                {
+                                    TaskNum = tasknum,
+                                    WMSTaskNum = "GP" + tasknum,
+                                    Grade = 60,
+                                    PalletCode = "LXM" + tasknum,
+                                    Roadway = "",
+                                    TaskState = (int)TaskStatusEnum.New,
+                                    TaskType = TaskTypeEnum.Q1TSJ4.ObjToInt(),
+                                    SourceAddress = "TSJC4F",
+                                    CurrentAddress = "TSJC4F",
+                                    NextAddress = hKLocation.LocationCode,
+                                    TargetAddress = hKLocation.LocationCode,
+                                    Creater = "WCS",
+                                };
+                                var content = _taskService.SendHIKROBOTTask(dt_Task);
+                                if (content.Status)
+                                {
+                                    dt_Task.TaskState = (int)TaskStatusEnum.Execut;
+                                    dt_Task.Dispatchertime = DateTime.Now;
+                                    hKLocation.LocationStatus = (int)LocationStatusEnum.InLock;
+                                    _taskService.AddData(dt_Task);
+                                    _HKLocationInfoService.UpdateData(hKLocation);
+                                }
                             }
                         }
+                         
                     }
                 }
                 #endregion
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/TaskJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/TaskJob.cs"
index deaccf2..62f4f3c 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/TaskJob.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/TaskJob.cs"
@@ -49,9 +49,9 @@
         {
             try
             {
-                //SendNewTask();
+                SendNewTask();
 
-                //SendWaitToTask();
+                SendWaitToTask();
             }
             catch (Exception ex)
             {

--
Gitblit v1.9.3