From db94945ebe7e7941ea73c826270f160b792e040f Mon Sep 17 00:00:00 2001
From: 肖洋 <cathay_xy@163.com>
Date: 星期二, 10 十二月 2024 14:15:34 +0800
Subject: [PATCH] 高温出库修改

---
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs |   77 +++++++++++++++++++++++++++++---------
 1 files changed, 58 insertions(+), 19 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 a2a6076..6d678cd 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
@@ -1,8 +1,10 @@
 锘縰sing Autofac.Core;
 using HslCommunication;
+using Mapster;
 using Newtonsoft.Json;
 using Quartz;
 using System.Diagnostics.CodeAnalysis;
+using WIDESEAWCS_BasicInfoRepository;
 using WIDESEAWCS_Common.TaskEnum;
 using WIDESEAWCS_Core.Caches;
 using WIDESEAWCS_Core.Helper;
@@ -19,6 +21,7 @@
 using WIDESEAWCS_QuartzJob.Service;
 using WIDESEAWCS_QuartzJob.StackerCrane.Enum;
 using WIDESEAWCS_SignalR;
+using WIDESEAWCS_Tasks.ConveyorLineJob;
 using WIDESEAWCS_Tasks.StackerCraneJob;
 
 namespace WIDESEAWCS_Tasks
@@ -33,8 +36,9 @@
         private readonly IProcessRepository _processRepository;
         private readonly ICacheService _cacheService;
         private readonly INoticeService _noticeService;
+        private readonly IDt_StationManagerRepository _stationManagerRepository;
 
-        public CommonStackerCraneJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IProcessRepository processRepository, ICacheService cacheService, INoticeService noticeService)
+        public CommonStackerCraneJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IProcessRepository processRepository, ICacheService cacheService, INoticeService noticeService, IDt_StationManagerRepository stationManagerRepository)
         {
             _taskService = taskService;
             _taskExecuteDetailService = taskExecuteDetailService;
@@ -43,6 +47,7 @@
             _processRepository = processRepository;
             _cacheService = cacheService;
             _noticeService = noticeService;
+            _stationManagerRepository = stationManagerRepository;
         }
 
         public Task Execute(IJobExecutionContext context)
@@ -91,7 +96,8 @@
                     var tokenInfos = _cacheService.Get<List<UserInfo>>("Cache_UserToken");
                     if (tokenInfos == null || !tokenInfos.Any())
                     {
-                        throw new Exception(commonStackerCrane.DeviceName + "缂撳瓨涓湭鎵惧埌Token缂撳瓨");
+                        //throw new Exception(commonStackerCrane.DeviceName + "缂撳瓨涓湭鎵惧埌Token缂撳瓨");
+                        return Task.CompletedTask;
                     }
                     var userTokenIds = tokenInfos?.Select(x => x.Token_ID).ToList();
                     var userIds = tokenInfos?.Select(x => x.UserId).ToList();
@@ -136,6 +142,29 @@
                 {
                     //Console.Out.WriteLine("TaskCompleted" + e.TaskNum);
                     ConsoleHelper.WriteColorLine($"銆恵commonStackerCrane.DeviceName}銆戜换鍔″畬鎴�,浠诲姟鍙凤細銆恵e.TaskNum}銆�", ConsoleColor.Blue);
+                    if (commonStackerCrane.DeviceCode.Contains("GW"))
+                    {
+                        var task = _taskRepository.QueryFirst(x => x.TaskNum == e.TaskNum);
+
+                        var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.TargetAddress);
+
+                        IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == station.stationPLC);
+                        if (device != null)
+                        {
+                            CommonConveyorLine_GW conveyorLine = (CommonConveyorLine_GW)device;
+                            var isResult = conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineBarcode, task.PalletCode, task.TargetAddress);
+                            if (!isResult)
+                            {
+                                var result = conveyorLine.GetValue<ConveyorLineDBName_After, string>(ConveyorLineDBName_After.ConveyorLineBarcode, task.TargetAddress);
+                                if(result!= task.PalletCode)
+                                {
+                                    conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineBarcode, task.PalletCode, task.TargetAddress);
+                                }
+                            }
+                        }
+                        else
+                            return;
+                    }
                     _taskService.StackCraneTaskCompleted(e.TaskNum);
                     commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5);
                 }
@@ -212,33 +241,43 @@
             {
                 if (router != null)
                 {
-
                     IDevice? device = null;
                     if (task.Roadway.Contains("CW"))
                     {
                         device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == router.ChildPosiDeviceCode);
-                    }
-
-                    else
-                    {
-                        device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1015");
-                    }
-
-                    if (device != null)
-                    {
-                        CommonConveyorLine_GW conveyorLine = (CommonConveyorLine_GW)device;
-                        if (conveyorLine.IsOccupied(task.TargetAddress))//鍑哄簱绔欏彴鏈鍗犵敤
+                        if (device != null)
                         {
-                            return task;
+                            CommonConveyorLine_GW conveyorLine = (CommonConveyorLine_GW)device;
+                            if (conveyorLine.IsOccupied(task.NextAddress))//鍑哄簱绔欏彴鏈鍗犵敤
+                            {
+                                return task;
+                            }
                         }
-                    }
-                    else
-                    {
-                        _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒板嚭搴撶珯鍙般�恵task.TargetAddress}銆戝搴旂殑閫氳瀵硅薄锛屾棤娉曞垽鏂嚭搴撶珯鍙版槸鍚﹁鍗犵敤");
+                        else
+                        {
+                            _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒板嚭搴撶珯鍙般�恵task.TargetAddress}銆戝搴旂殑閫氳瀵硅薄锛屾棤娉曞垽鏂嚭搴撶珯鍙版槸鍚﹁鍗犵敤");
+                        }
                     }
                 }
                 else
                 {
+                    IDevice? device = null;
+                    if (task.Roadway.Contains("GW"))
+                    {
+                        device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1015");
+                        if (device != null)
+                        {
+                            CommonConveyorLine_GW conveyorLine = (CommonConveyorLine_GW)device;
+                            if (conveyorLine.IsOccupied(task.TargetAddress))//鍑哄簱绔欏彴鏈鍗犵敤
+                            {
+                                return task;
+                            }
+                        }
+                        else
+                        {
+                            _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒板嚭搴撶珯鍙般�恵task.TargetAddress}銆戝搴旂殑閫氳瀵硅薄锛屾棤娉曞垽鏂嚭搴撶珯鍙版槸鍚﹁鍗犵敤");
+                        }
+                    }
                     _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒扮珯鍙般�恵task.NextAddress}銆戜俊鎭紝鏃犳硶鏍¢獙绔欏彴");
                 }
             }

--
Gitblit v1.9.3