From f640a3ab00189bb0f55a7bfb65f309f80803e88b Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期六, 18 四月 2026 14:25:25 +0800
Subject: [PATCH] 优化成品移库任务,添加WMS任务号加流水号确保WMS任务号唯一

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/TSJJob.cs |  152 +++-----------------------------------------------
 1 files changed, 11 insertions(+), 141 deletions(-)

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 870675c..abb8476 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"
@@ -14,6 +14,7 @@
 using System.Text;
 using System.Threading.Tasks;
 using WIDESEAWCS_Common;
+using WIDESEAWCS_Common.LocationEnum;
 using WIDESEAWCS_Common.TaskEnum;
 using WIDESEAWCS_Communicator;
 using WIDESEAWCS_Core.Helper;
@@ -29,167 +30,36 @@
 namespace WIDESEAWCS_Tasks
 {
     [DisallowConcurrentExecution]
-    public class TSJJob : JobBase, IJob
+    public partial class TSJJob : JobBase, IJob
     {
         private readonly ITaskService _taskService;
         private readonly IStationMangerService _stationMangerService;
-        public TSJJob(ITaskService taskService, IStationMangerService stationMangerService)
+        private readonly IStationInfoService _stationInfoService;
+        
+        public TSJJob(ITaskService taskService, IStationMangerService stationMangerService, IStationInfoService stationInfoService)
         {
             _taskService = taskService;//娉ㄥ叆
             _stationMangerService = stationMangerService;
+            _stationInfoService = stationInfoService;
         }
 
         public Task Execute(IJobExecutionContext context)
         {
-
             bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
             if (flag && value != null)
             {
                 OtherDevice device = (OtherDevice)value;
-                //Example
-                //device.GetValue  璇诲彇
-                //device.SetValue  鍐欏叆
-                // _taskService.Repository 浠撳偍灞傦紝杩涜鏁版嵁搴撹闂�-
-                try
-                {
-                    List<Dt_Task> Uptasks = new List<Dt_Task>();
-                    //鏌ヨ鎵�鏈変换鍔$被鍨嬩负3,4妤肩殑鍏ュ簱浠诲姟绫诲瀷涓斾换鍔$姸鎬佷负AGV_WaitToExecute鐨勪换鍔� 
-                    var taskList = _taskService.Repository.QueryData(x => x.TaskState == TaskStatusEnum.AGV_WaitToExecute.ObjToInt());
-                    //浠诲姟鐨勭洰鏍囧湴鍧�瀵逛簬绔欏彴鍙凤紱
-                    foreach (var task in taskList)
-                    {
-                        //鍏堟鏌ヨ澶囩姸鎬�
-                        if (device.GetValue<HoistEnum, short>(HoistEnum.EquipmentStatus, "TSJ") == 2)
-                        {
-                            if (task.ExceptionMessage == "鎻愬崌鏈鸿澶囨晠闅�")
-                            {
-                                continue;
-                            }
-                            task.ExceptionMessage = "鎻愬崌鏈鸿澶囨晠闅�";
-                            Uptasks.Add(task);
-                            continue;
-                            //throw new Exception("璁惧鏁呴殰");
-                        }
-                        if (task.TaskType == TaskTypeEnum.RK3F.ObjToInt())
-                        {
-                            //鍒ゆ柇3妤煎叆搴撶鍙锋湁鏃�
-                            if (device.GetValue<HoistEnum, string>(HoistEnum.OutboundInplace, "TSJ") == "1")
-                            {
-                                if (task.ExceptionMessage == "3妤煎叆搴撶鍙锋湁璐э紝璇峰厛澶勭悊")
-                                {
-                                    continue;
-                                }
-                                task.ExceptionMessage = "3妤煎叆搴撶鍙锋湁璐э紝璇峰厛澶勭悊";
-                                Uptasks.Add(task);
-                                continue;
-                            }
-                           
-                            //鐒跺悗璋冪敤杈撻�佺嚎鎺ュ彛锛岄�氱煡杈撻�佺嚎鏈夋枡绠遍渶瑕佸叆搴擄紝浠诲姟涓捐鎵ц
-                            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);
-                            //杩欓噷浠诲姟鍙樻垚浜咰heckPalletCodeing
+                HKConexecutTask(device);
 
-                        }
-                        else if(task.TaskType == TaskTypeEnum.CK3F.ObjToInt()) //鍑哄簱
-                        {
-                            ////鍑哄簱鏂欑缂撳瓨鏁伴噺
-                            //if (device.GetValue<HoistEnum, short>(HoistEnum.Outboundmaterialbox, "TSJ") == 0) throw new Exception("娌℃湁鍑哄簱鏂欑缂撳瓨鏁伴噺涓虹┖");
-                            //璇诲彇3妤煎嚭搴撴枡绠卞埌浣�
-                            if (device.GetValue<HoistEnum, short>(HoistEnum.SOutboundmaterialbox, "TSJ") != 1) throw new Exception("3妤煎嚭搴撴枡绠辨病鏈夊埌浣�");
-                            //鐒跺悗璋冪敤杈撻�佺嚎鎺ュ彛锛岄�氱煡杈撻�佺嚎鏈夋枡绠遍渶瑕佸叆搴擄紝浠诲姟涓捐鎵ц
-                            if (_taskService.Hikvisiontaskscontinue(task.WMSTaskNum).Status == false) throw new Exception($"3妤煎嚭搴撲换鍔′妇琛屾墽琛屽け璐ワ紝閿欒淇℃伅{_taskService.Hikvisiontaskscontinue(task.WMSTaskNum).Message}");//缁欎换鍔″彿
+                PalletNumConfirmation(device);
 
-                            //鍘绘洿鏂颁换鍔¢噷鍐欏��
-                            //鍐�3妤煎嚭搴撶鍙栬揣瀹屾垚
-                            device.SetValue<HoistEnum, short>(HoistEnum.Outboundboxon, 1);
-                        }
-                        else if (task.TaskType == TaskTypeEnum.Q1TSJ4.ObjToInt())//4妤煎叆搴�
-                        {
-                            //鍥炵┖绠辩殑鏃跺�欒璇讳竴涓悧
-                            if (device.GetValue<HoistEnum, short>(HoistEnum.Emptycontainernumber, "TSJ") == null) throw new Exception($"4妤肩┖绠�,璇荤爜鍣ㄦ病鏈夎鍒板��");
-                           
-                            //鍒ゆ柇4妤肩┖绠卞埌浣�
-                            if (device.GetValue<HoistEnum, short>(HoistEnum.ReturnbinAvailable, "TSJ") == 2) throw new Exception("4妤煎洖鏂欑涓虹┖");
-                            if (_taskService.Hikvisiontaskscontinue(task.WMSTaskNum).Status == false) throw new Exception($"3妤煎嚭搴撲换鍔′妇琛屾墽琛屽け璐ワ紝閿欒淇℃伅{_taskService.Hikvisiontaskscontinue(task.WMSTaskNum).Message}");//缁欎换鍔″彿
-                            //鍐欏叆绌虹鏀惧埌浣嶄俊鍙�
-                            device.SetValue(HoistEnum.Emptyboxplacedinposition, "TSJ", "1");
-                        }
-                        else if (task.TaskType == TaskTypeEnum.CHUKU1.ObjToInt()) //鍥涙ゼ搴撳唴鍒版彁鍗囨満 
-                        {
-                            
-                            //4妤煎嚭搴撴枡绠卞埌浣�
-                            if (device.GetValue<HoistEnum, short>(HoistEnum.FOutboundmaterialbox, "TSJ") == 2) throw new Exception("4妤煎嚭搴撴枡绠辨病鏈夊埌浣�");
-                            //鍐欎互涓�涓嚭搴撳畬鎴愪俊鍙�
-                            device.SetValue(HoistEnum.Outboundboxretrievalcompleted, "TSJ", "1");
-                        }
-                     
-                        
-                    }
+                PalletReportingToWMS(device);
 
-
-                    //鏌ユ壘涓夋ゼ鍏ュ簱浠诲姟鐘舵�佷负CheckPalletCodeing鐨勪换鍔℃墭鐩樺彿纭涓�
-                    var RK3FTasks = taskList.Where(x => x.TaskType == TaskTypeEnum.RK3F.ObjToInt()&&x.TaskState== (int)TaskStatusEnum.CheckPalletCodeing).ToList();
-                    foreach (var item in RK3FTasks)
-                    {
-                        var Barcode = device.SetValue<HoistEnum, short>(HoistEnum.Codereadingtriggered, 1);
-                        //妫�鏌�3妤煎叆搴撶鍙锋槸澶氬皯锛岀劧鍚庝紶缁檞ms
-                        var BinNumber = device.GetValue<HoistEnum, string>(HoistEnum.Inboxnumber, "TSJ");
-                        //鏍规嵁璇诲埌鐨勭鍙疯繘琛屾枡绠辨楠岋紝妫�楠岄�氳繃灏辫Е鍙戣鐮佸櫒璇诲彇锛屽鏋滀笉閫氳繃灏辨姏鍑哄紓甯�
-                        var Verification = _taskService.MaterialBoxInspection(item.WMSTaskNum, BinNumber.ToString());
-                        if (!Verification.Status) 
-                        {
-                            if (!(item.ExceptionMessage == Verification.Message))
-                            {
-                                item.ExceptionMessage = Verification.Message;
-                                Uptasks.Add(item);
-                            }
-                            //鏂欑楠岃瘉鍐欏ソ鍚庯紝闇�瑕佹洿鏀�
-                            item.TargetAddress = Verification.Data.ToString();
-                        } 
-                        
-                        //濡傛灉鏂欑妫�楠屾垚鍔熷氨鍐欏叆璇荤爜鍣ㄧ殑鍊�
-                        var result = _taskService.Hikvisiontaskscontinue(item.WMSTaskNum, item.TargetAddress);
-                        if (result.Status == false)
-                        {
-                            if (item.ExceptionMessage != result.Message)
-                            {
-                                item.ExceptionMessage = result.Message;
-                                Uptasks.Add(item);
-                            }
-                            continue;
-                        }
-                        item.TaskState = (int)TaskStatusEnum.CheckPalletCodeFinish;
-
-
-                        Uptasks.Add(item);
-                    }
-                    if (Uptasks.Count > 0)
-                    {
-                        _taskService.UpdateData(Uptasks);
-                    }
-                    WriteInfo(device.DeviceName, "infoLog");
-
-                    WriteDebug(device.DeviceName, "debugLog");
-                }
-                catch (Exception ex)
-                {
-                    WriteError(device.DeviceName, "閿欒", ex);
-                }
+                TSJAlarm(device);
             }
             else
             {
-                WriteError(nameof(TestJob), "鍙傛暟閿欒,鏈紶閫掕澶囧弬鏁版垨璁惧绫诲瀷閿欒");
+                WriteError(nameof(TSJJob), "鍙傛暟閿欒,鏈紶閫掕澶囧弬鏁版垨璁惧绫诲瀷閿欒");
             }
 
 

--
Gitblit v1.9.3