From 65a231315d1dcc35d2996106d36e9cca9aba6ce6 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期五, 06 三月 2026 09:06:44 +0800
Subject: [PATCH] 更新码垛分配工位优化,老厂退库称重上报设定差异范围

---
 项目代码/WCS/WCSServices/WIDESEAWCS_Tasks/成品仓/StackerCraneJob_CP.cs |   34 +++++++++++++++++++++++++++-------
 1 files changed, 27 insertions(+), 7 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/StackerCraneJob_CP.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/StackerCraneJob_CP.cs"
index 35e320b..f7a83e6 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/StackerCraneJob_CP.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/StackerCraneJob_CP.cs"
@@ -23,6 +23,7 @@
 using SqlSugar.Extensions;
 using WIDESEAWCS_Tasks.ConveyorLineJob;
 using WIDESEAWCS_QuartzJob.Repository;
+using WIDESEAWCS_QuartzJob.StackerCrane;
 
 namespace WIDESEAWCS_Tasks
 {
@@ -57,8 +58,13 @@
                     {
                         commonStackerCrane.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢
                     }
-                    commonStackerCrane.CheckStackerCraneTaskCompleted();//闃叉浠诲姟瀹屾垚浜嬩欢鐩戞祴瓒呮椂锛屽啀鎵嬪姩瑙﹀彂涓�娆�
-                    if (commonStackerCrane.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && commonStackerCrane.StackerCraneStatusValue == StackerCraneStatus.Normal && commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby)
+                    //commonStackerCrane.CheckStackerCraneTaskCompleted();//闃叉浠诲姟瀹屾垚浜嬩欢鐩戞祴瓒呮椂锛屽啀鎵嬪姩瑙﹀彂涓�娆�
+                    if (commonStackerCrane.CurrentTaskNum > 0 && (commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.WorkCompleted || commonStackerCrane.Communicator.Read<short>("DB1000.40.0") == 3))
+                    {
+                        StackerCraneTaskCompletedEventArgs e = new StackerCraneTaskCompletedEventArgs(commonStackerCrane.CurrentTaskNum);
+                        CommonStackerCrane_StackerCraneTaskCompletedEventHandler(commonStackerCrane, e);
+                    }
+                    else if (commonStackerCrane.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && commonStackerCrane.StackerCraneStatusValue == StackerCraneStatus.Normal && commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby)
                     {
                         short stackerError = commonStackerCrane.Communicator.Read<short>("DB1000.54.0");
                         if (stackerError == 0)
@@ -121,7 +127,7 @@
                 {
                     if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
                     {
-                        Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StackerCraneStationCode == task.NextAddress && x.StackerCraneCode==deviceCode);
+                        Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == task.NextAddress && x.StackerCraneCode==deviceCode);
                         if (stationManger == null)
                         {
                             _taskExecuteDetailService.AddTaskExecuteDetail(taskNum, $"杈撻�佺嚎鍑哄簱绔欑偣鏈厤缃�,{task.NextAddress}");
@@ -182,6 +188,13 @@
         /// <returns></returns>
         private Dt_Task? GetTask(CommonStackerCrane commonStackerCrane)
         {
+            //鍒ゆ柇鏄惁鏈夋鎵ц鐨勪换鍔★紝濡傛灉鏈夊垯涓嶄笅鍙�
+            Dt_Task? taskOld = _taskRepository.QueryFirst(x => x.DeviceCode == commonStackerCrane.DeviceCode && x.Roadway == commonStackerCrane.DeviceCode && x.TaskState == TaskStatusEnum.SC_Executing.ObjToInt());
+            if (taskOld!=null)
+            {
+                return null;
+            }
+
             Dt_Task task;
             if (commonStackerCrane.LastTaskType == null)
             {
@@ -249,11 +262,17 @@
                 if (device != null)
                 {
                     OtherDevice client = (OtherDevice)device;
-                    if (client.GetValue<R_ConveyorLineCPDB, short>(R_ConveyorLineCPDB.Command, stationManger.StationCode)==3)//鍑哄簱绔欏彴鏈鍗犵敤
+                    short command = client.GetValue<R_ConveyorLineCPDB, short>(R_ConveyorLineCPDB.Command, stationManger.StationCode);
+                    if (command==3)//鍑哄簱绔欏彴鏈鍗犵敤
                     {
-                        task.NextAddress = stationManger.StackerCraneStationCode;
-                        _taskRepository.UpdateData(task);
+                        //task.NextAddress = stationManger.StackerCraneStationCode;
+                        //_taskRepository.UpdateData(task);
                         return task;
+                    }
+                    else
+                    {
+                        task.ExceptionMessage = "鍑哄簱绔欏彴鏃犳硶涓嬪彂";
+                        _taskRepository.UpdateData(task);
                     }
                 }
                 else
@@ -313,7 +332,8 @@
             }
             else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)//鍒ゆ柇鏄惁鏄嚭搴撲换鍔�
             {
-                string[] targetCodes = task.NextAddress.Split("-");
+                Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == task.NextAddress && x.StackerCraneCode == task.DeviceCode);
+                string[] targetCodes = stationManger.StackerCraneStationCode.Split("-");
                 if (targetCodes.Length == 3)
                 {
                     stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]);

--
Gitblit v1.9.3