From cdabe47ad8128c5006202e55c29746a617e988d6 Mon Sep 17 00:00:00 2001 From: 肖洋 <cathay_xy@163.com> Date: 星期日, 22 十二月 2024 15:29:57 +0800 Subject: [PATCH] 添加静置NG入库功能,更新相关接口和配置,优化代码结构 --- Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs | 92 +++++++++++++++++++++++++++++---------------- 1 files changed, 59 insertions(+), 33 deletions(-) diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs index 8352fc6..22255f1 100644 --- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs +++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs @@ -24,6 +24,7 @@ using WIDESEAWCS_QuartzJob.Service; using WIDESEAWCS_SignalR; using WIDESEAWCS_Tasks.ConveyorLineJob; +using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database; using ICacheService = WIDESEAWCS_Core.Caches.ICacheService; namespace WIDESEAWCS_Tasks @@ -61,54 +62,76 @@ public async Task Execute(IJobExecutionContext context) { string jobName = context.JobDetail.Key.Name; - if (MemoryLockManager.TryAcquireLock(jobName)) + //if (MemoryLockManager.TryAcquireLock(jobName)) + //{ + try { - try + CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams"); + if (conveyorLine != null) { - CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams"); - if (conveyorLine != null) - { - List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode); - var tasks = childDeviceCodes.Select(childDeviceCode => ProcessDeviceAsync(conveyorLine, childDeviceCode)).ToList(); - await Task.WhenAll(tasks); + List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode); + var tasks = childDeviceCodes.Select(childDeviceCode => ProcessDeviceAsync(conveyorLine, childDeviceCode)).ToList(); + await Task.WhenAll(tasks); - List<Dt_StationManager> stationManagers = _stationManagerService.GetAllStationByDeviceCode(conveyorLine.DeviceCode); - foreach (var station in stationManagers) + List<Dt_StationManager> stationManagers = _stationManagerService.GetAllStationByDeviceCode(conveyorLine.DeviceCode); + foreach (var station in stationManagers) + { + if (station.stationType == 11) { - if (station.stationType == 11) + ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(station.stationChildCode); + ConveyorLineTaskCommandWrite commandWrite = conveyorLine.ReadCustomer<ConveyorLineTaskCommandWrite>(station.stationChildCode, "DeviceCommand"); + if (command != null && commandWrite != null) { - ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(station.stationChildCode); - ConveyorLineTaskCommandWrite commandWrite = conveyorLine.ReadCustomer<ConveyorLineTaskCommandWrite>(station.stationChildCode, "DeviceCommand"); - if (command != null && commandWrite != null) + var structs = BitConverter.GetBytes(commandWrite.WriteInteractiveSignal).Reverse().ToArray().ToBoolArray(); + if (structs[0] == true) { - var structs = BitConverter.GetBytes(commandWrite.WriteInteractiveSignal).Reverse().ToArray().ToBoolArray(); - if (structs[0] == true) + ConsoleHelper.WriteWarningLine($"銆恵conveyorLine.DeviceName}銆戜换鍔″彿锛氥�恵command.TaskNum}銆�,鎵樼洏鏉$爜锛氥�恵command.Barcode}銆戝凡鍒拌揪銆恵station.stationChildCode}銆戠┖鎵樼洏璇锋眰鎵爜鍏ュ簱"); + NGRequestTaskInbound(conveyorLine, command, station.stationChildCode, 0, station.stationLocation); + } + else + { + ConveyorLineSendFinish(conveyorLine, station.stationChildCode, 0, false); + } + } + } + else if (station.stationType == 5) + { + ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(station.stationChildCode); + ConveyorLineTaskCommandWrite commandWrite = conveyorLine.ReadCustomer<ConveyorLineTaskCommandWrite>(station.stationChildCode, "DeviceCommand"); + if (command != null && commandWrite != null) + { + var structs = BitConverter.GetBytes(commandWrite.WriteInteractiveSignal).Reverse().ToArray().ToBoolArray(); + if (structs[0] == true) + { + if (_taskRepository.QueryData(x => x.SourceAddress == station.stationChildCode).Count() > 0) { - ConsoleHelper.WriteWarningLine($"銆恵conveyorLine.DeviceName}銆戜换鍔″彿锛氥�恵command.TaskNum}銆�,鎵樼洏鏉$爜锛氥�恵command.Barcode}銆戝凡鍒拌揪銆恵station.stationChildCode}銆戠┖鎵樼洏璇锋眰鎵爜鍏ュ簱"); - NGRequestTaskInbound(conveyorLine, command, station.stationChildCode, 0, station.stationLocation); + return; } - else - { - ConveyorLineSendFinish(conveyorLine, station.stationChildCode, 0, false); - } + ConsoleHelper.WriteWarningLine($"銆恵conveyorLine.DeviceName}銆戜换鍔″彿锛氥�恵command.TaskNum}銆�,鎵樼洏鏉$爜锛氥�恵command.Barcode}銆戝凡鍒拌揪銆恵station.stationChildCode}銆戝紓甯稿彛璇锋眰鎵爜鍏ュ簱"); + HandleNewTask(conveyorLine, command, station.stationChildCode, 0); + } + else + { + ConveyorLineSendFinish(conveyorLine, station.stationChildCode, 0, false); } } } } } - catch (Exception ex) - { - Console.Out.WriteLine(nameof(CommonConveyorLineJob) + ":" + ex.ToString()); - } - finally - { - MemoryLockManager.ReleaseLock(jobName); - } } - else + catch (Exception ex) { - ConsoleHelper.WriteErrorLine($"[CommonConveyorLineJob]銆恵jobName}銆戜换鍔″凡琚攣瀹氾紝鏃犳硶澶勭悊"); + Console.Out.WriteLine(nameof(CommonConveyorLineJob) + ":" + ex.ToString()); } + // finally + // { + // MemoryLockManager.ReleaseLock(jobName); + // } + //} + //else + //{ + // ConsoleHelper.WriteErrorLine($"[CommonConveyorLineJob]銆恵jobName}銆戜换鍔″凡琚攣瀹氾紝鏃犳硶澶勭悊"); + //} return; } @@ -361,7 +384,10 @@ { if (command.Barcode == task.PalletCode && childDeviceCode == task.NextAddress) { - ConsoleHelper.WriteWarningLine($"銆恵conveyorLine._deviceName}銆戜换鍔″彿锛氥�恵command.TaskNum}銆�,鎵樼洏鏉$爜锛氥�恵command.Barcode}銆戝凡鍒拌揪銆恵childDeviceCode}銆戣緭閫佺嚎鍏ュ簱瀹屾垚,涓嬩竴鐩爣鍦板潃銆愮瓑寰呭垎閰嶈揣浣嶃��"); + //conveyorLine.SetValue(ConveyorLineDBName.ConveyorLineTargetAddress, "1000", childDeviceCode); + + ConsoleHelper.WriteWarningLine($"銆恵conveyorLine._deviceName}銆戜换鍔″彿锛氥�恵command.TaskNum}銆�,鎵樼洏鏉$爜锛氥�恵command.Barcode}銆戝凡鍒拌揪銆恵childDeviceCode}銆戣緭閫佺嚎鍏ュ簱瀹屾垚,涓嬩竴鐩爣鍦板潃銆愮瓑寰呭垎閰嶈揣浣�,骞跺啓鍏�1000銆�"); + ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true); if (task.TaskType == (int)TaskInboundTypeEnum.InNG) -- Gitblit v1.9.3