From e61bb0e26530b2aa9055737fade9e77ccb1feebf Mon Sep 17 00:00:00 2001
From: 肖洋 <cathay_xy@163.com>
Date: 星期二, 07 一月 2025 10:06:16 +0800
Subject: [PATCH] 更新多个文件,优化逻辑与配置

---
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs |   50 ++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 38 insertions(+), 12 deletions(-)

diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
index 232f01e..f8c0b78 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
@@ -1,12 +1,16 @@
 锘縰sing Mapster;
+using Newtonsoft.Json;
 using Quartz;
 using System.Diagnostics.CodeAnalysis;
+using System.Text;
 using WIDESEAWCS_BasicInfoRepository;
+using WIDESEAWCS_Common;
 using WIDESEAWCS_Common.TaskEnum;
 using WIDESEAWCS_Core.Caches;
 using WIDESEAWCS_Core.Helper;
 using WIDESEAWCS_Core.HttpContextUser;
 using WIDESEAWCS_IProcessRepository;
+using WIDESEAWCS_ISystemServices;
 using WIDESEAWCS_ITaskInfo_HtyRepository;
 using WIDESEAWCS_ITaskInfoRepository;
 using WIDESEAWCS_ITaskInfoService;
@@ -34,8 +38,9 @@
         private readonly INoticeService _noticeService;
         private readonly IDt_StationManagerRepository _stationManagerRepository;
         private readonly ITask_HtyRepository _htyRepository;
+        private readonly ISys_ConfigService _sys_ConfigService;
 
-        public CommonStackerCraneJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IProcessRepository processRepository, ICacheService cacheService, INoticeService noticeService, IDt_StationManagerRepository stationManagerRepository, ITask_HtyRepository htyRepository)
+        public CommonStackerCraneJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IProcessRepository processRepository, ICacheService cacheService, INoticeService noticeService, IDt_StationManagerRepository stationManagerRepository, ITask_HtyRepository htyRepository, ISys_ConfigService sys_ConfigService)
         {
             _taskService = taskService;
             _taskExecuteDetailService = taskExecuteDetailService;
@@ -46,6 +51,7 @@
             _noticeService = noticeService;
             _stationManagerRepository = stationManagerRepository;
             _htyRepository = htyRepository;
+            _sys_ConfigService = sys_ConfigService;
         }
 
         public Task Execute(IJobExecutionContext context)
@@ -78,12 +84,31 @@
                                 StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task);
                                 if (stackerCraneTaskCommand != null)
                                 {
-                                    bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand);
-                                    if (sendFlag)
+                                    var taskNum = commonStackerCrane.GetValue<StackerCraneDBName, int>(StackerCraneDBName.TaskNum);
+                                    //var taskBarCode = commonStackerCrane.GetValue<StackerCraneDBName, string>(StackerCraneDBName.Barcode);
+                                    ConsoleHelper.WriteColorLine($"銆恵commonStackerCrane.DeviceName}銆戝爢鍨涙満浠诲姟鍙凤細銆恵taskNum}銆戜换鍔′换鍔″彿锛氥�恵task.TaskNum}", ConsoleColor.DarkBlue);
+                                    if (taskNum == 0)
                                     {
-                                        commonStackerCrane.SetValue(StackerCraneDBName.StartCommand, 1);
-                                        commonStackerCrane.LastTaskType = task.TaskType;
-                                        _taskService.UpdateTaskStatusToNext(task.TaskNum);
+                                        ConsoleHelper.WriteColorLine($"銆恵commonStackerCrane.DeviceName}銆戜换鍔″彿涓恒�恵0}銆�,鎵樼洏鍙蜂笉涓�鑷村彲浠ヤ笅鍙戜换鍔�", ConsoleColor.DarkBlue);
+                                        bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand);
+                                        if (sendFlag)
+                                        {
+                                            StringBuilder builder = new StringBuilder();
+                                            builder.AppendLine();
+                                            builder.AppendLine($"銆恵commonStackerCrane.DeviceName}銆戝爢鍨涙満鐘舵�侊細銆恵commonStackerCrane.StackerCraneStatusDes}銆�,鏃堕棿锛氥�恵DateTime.Now}銆�");
+                                            builder.AppendLine($"銆恵commonStackerCrane.DeviceName}銆戞墜鑷姩鐘舵�侊細銆恵commonStackerCrane.StackerCraneAutoStatusDes}銆�,鏃堕棿锛氥�恵DateTime.Now}銆�");
+                                            builder.AppendLine($"銆恵commonStackerCrane.DeviceName}銆戜綔涓氱姸鎬侊細銆恵commonStackerCrane.StackerCraneWorkStatusDes}銆�,鏃堕棿锛氥�恵DateTime.Now}銆�");
+                                            builder.AppendLine($"銆恵commonStackerCrane.DeviceName}銆戜笅鍙戜换鍔℃垚鍔�,銆恵JsonConvert.SerializeObject(stackerCraneTaskCommand, Formatting.Indented)}銆�");
+                                            builder.AppendLine($"鏃堕棿锛氥�恵DateTime.Now}銆�");
+                                            builder.AppendLine();
+                                            ConsoleHelper.WriteColorLine(builder, ConsoleColor.Blue);
+                                            commonStackerCrane.LastTaskType = task.TaskType;
+                                            _taskService.UpdateTaskStatusToNext(task.TaskNum);
+                                        }
+                                    }
+                                    else
+                                    {
+                                        ConsoleHelper.WriteColorLine($"銆恵commonStackerCrane.DeviceName}銆戜换鍔″彿涓嶄负銆恵0}銆�,涓嶅彲浠ヤ笅鍙戜换鍔�", ConsoleColor.DarkBlue);
                                     }
                                 }
                             }
@@ -134,8 +159,7 @@
             CommonStackerCrane? commonStackerCrane = sender as CommonStackerCrane;
             if (commonStackerCrane != null)
             {
-                //var x = commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType);
-                //if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5)
+                if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5)
                 {
                     //Console.Out.WriteLine("TaskCompleted" + e.TaskNum);
                     ConsoleHelper.WriteColorLine($"銆恵commonStackerCrane.DeviceName}銆戜换鍔″畬鎴�,浠诲姟鍙凤細銆恵e.TaskNum}銆�", ConsoleColor.Blue);
@@ -283,7 +307,7 @@
                             _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒板嚭搴撶珯鍙般�恵task.TargetAddress}銆戝搴旂殑閫氳瀵硅薄锛屾棤娉曞垽鏂嚭搴撶珯鍙版槸鍚﹁鍗犵敤");
                         }
                     }
-                    _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒扮珯鍙般�恵task.TargetAddress}銆戜俊鎭紝鏃犳硶鏍¢獙绔欏彴");
+                    //_taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒扮珯鍙般�恵task.TargetAddress}銆戜俊鎭紝鏃犳硶鏍¢獙绔欏彴");
                 }
             }
             else
@@ -338,7 +362,7 @@
                 {
                     return candidateTask;
                 }
-                ConsoleHelper.WriteErrorLine($"浠诲姟鍙凤細銆恵occupiedStation.TaskNum}銆戝嚭搴撳湴鍧�锛氥�恵occupiedStation.NextAddress}銆戜笉鍏佽鏀捐揣");
+                ConsoleHelper.WriteErrorLine($"浠诲姟鍙凤細銆恵candidateTask.TaskNum}銆戝嚭搴撳湴鍧�锛氥�恵candidateTask.NextAddress}銆戜笉鍏佽鏀捐揣");
             }
 
             return null;
@@ -358,10 +382,12 @@
             stackerCraneTaskCommand.TaskNum = task.TaskNum;
             stackerCraneTaskCommand.WorkType = 1;
             stackerCraneTaskCommand.TrayType = 0;
-            //stackerCraneTaskCommand.StartCommand = 1;
+            stackerCraneTaskCommand.StartCommand = 1;
             if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)//鍒ゆ柇鏄惁鏄叆搴撲换鍔�
             {
-                if (task.SourceAddress == "1359-4" && task.Roadway.Contains("JZ"))
+                var value = _sys_ConfigService.GetByConfigKey(CateGoryConst.CONFIG_SYS_InStation, SysConfigKeyConst.JZNGInBoundStation).ConfigValue;
+                var valueList = value.Split(',').ToList();
+                if ((valueList.Contains(task.SourceAddress)) && task.Roadway.Contains("JZ"))
                 {
                     string[] souredCodes = task.CurrentAddress.Split("-");
                     if (souredCodes.Length == 3)

--
Gitblit v1.9.3