肖洋
2024-12-22 cdabe47ad8128c5006202e55c29746a617e988d6
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,8 +62,8 @@
        public async Task Execute(IJobExecutionContext context)
        {
            string jobName = context.JobDetail.Key.Name;
            if (MemoryLockManager.TryAcquireLock(jobName))
            {
            //if (MemoryLockManager.TryAcquireLock(jobName))
            //{
                try
                {
                    CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams");
@@ -93,6 +94,28 @@
                                    }
                                }
                            }
                        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)
                                    {
                                        return;
                                    }
                                    ConsoleHelper.WriteWarningLine($"【{conveyorLine.DeviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{station.stationChildCode}】异常口请求扫码入库");
                                    HandleNewTask(conveyorLine, command, station.stationChildCode, 0);
                                }
                                else
                                {
                                    ConveyorLineSendFinish(conveyorLine, station.stationChildCode, 0, false);
                                }
                            }
                        }
                        }
                    }
                }
@@ -100,15 +123,15 @@
                {
                    Console.Out.WriteLine(nameof(CommonConveyorLineJob) + ":" + ex.ToString());
                }
                finally
                {
                    MemoryLockManager.ReleaseLock(jobName);
                }
            }
            else
            {
                ConsoleHelper.WriteErrorLine($"[CommonConveyorLineJob]【{jobName}】任务已被锁定,无法处理");
            }
            //    finally
            //    {
            //        MemoryLockManager.ReleaseLock(jobName);
            //    }
            //}
            //else
            //{
            //    ConsoleHelper.WriteErrorLine($"[CommonConveyorLineJob]【{jobName}】任务已被锁定,无法处理");
            //}
            return;
        }
@@ -361,7 +384,7 @@
            {
                if (command.Barcode == task.PalletCode && childDeviceCode == task.NextAddress)
                {
                    conveyorLine.SetValue(ConveyorLineDBName.ConveyorLineTargetAddress, "1000", childDeviceCode);
                    //conveyorLine.SetValue(ConveyorLineDBName.ConveyorLineTargetAddress, "1000", childDeviceCode);
                    ConsoleHelper.WriteWarningLine($"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】输送线入库完成,下一目标地址【等待分配货位,并写入1000】");