From 0ba846024a89bbdfe2b2e2183d0ed944ac9782bf Mon Sep 17 00:00:00 2001 From: hutongqing <hutongqing@hnkhzn.com> Date: 星期六, 04 一月 2025 09:52:28 +0800 Subject: [PATCH] 更新 --- 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/干膜仓/ConveyorLineJob_GM.cs | 141 +++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 130 insertions(+), 11 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\345\271\262\350\206\234\344\273\223/ConveyorLineJob_GM.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\345\271\262\350\206\234\344\273\223/ConveyorLineJob_GM.cs" index 80b7d03..1a2f5e4 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\345\271\262\350\206\234\344\273\223/ConveyorLineJob_GM.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\345\271\262\350\206\234\344\273\223/ConveyorLineJob_GM.cs" @@ -6,6 +6,8 @@ using System.Threading.Tasks; using WIDESEAWCS_Common; using WIDESEAWCS_Common.Helper; +using WIDESEAWCS_Common.TaskEnum; +using WIDESEAWCS_Core; using WIDESEAWCS_Core.Helper; using WIDESEAWCS_IBasicInfoRepository; using WIDESEAWCS_ITaskInfoRepository; @@ -13,6 +15,8 @@ using WIDESEAWCS_Model.Models; using WIDESEAWCS_QuartzJob; using WIDESEAWCS_QuartzJob.DTO; +using WIDESEAWCS_QuartzJob.Models; +using WIDESEAWCS_QuartzJob.Repository; using WIDESEAWCS_Tasks.ConveyorLineJob; namespace WIDESEAWCS_Tasks @@ -25,13 +29,15 @@ private readonly ITaskExecuteDetailService _taskExecuteDetailService; private readonly ITaskRepository _taskRepository; private readonly IStationMangerRepository _stationMangerRepository; + private readonly IRouterRepository _routerRepository; - public ConveyorLineJob_GM(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IStationMangerRepository stationMangerRepository) + public ConveyorLineJob_GM(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IStationMangerRepository stationMangerRepository,IRouterRepository routerRepository) { _taskService = taskService; _taskExecuteDetailService = taskExecuteDetailService; _taskRepository = taskRepository; _stationMangerRepository = stationMangerRepository; + _routerRepository = routerRepository; } public Task Execute(IJobExecutionContext context) @@ -44,21 +50,134 @@ List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == device.DeviceCode); foreach (var item in stationMangers.Where(x => deviceStations.Contains(x.StationCode))) { - if (item.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt()) + DeviceProDTO? deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode && x.DeviceProParamType == nameof(R_ConveyorLineDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); + + DeviceProDTO? deviceProWrite = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode && x.DeviceProParamType == nameof(W_ConveyorLineDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); + + if (deviceProRead != null && deviceProWrite != null) { - DeviceProDTO? devicePro = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); - if (devicePro != null) - { - R_ConveyorLineInfo conveyorLineInfo = device.Communicator.ReadCustomer<R_ConveyorLineInfo>(devicePro.DeviceProAddress); + R_ConveyorLineInfo conveyorLineInfoRead = device.Communicator.ReadCustomer<R_ConveyorLineInfo>(deviceProRead.DeviceProAddress); - R_ConveyorLineStatus conveyorLineStatus = conveyorLineInfo.Status.ByteToBoolObject<R_ConveyorLineStatus>(); + R_ConveyorLineStatus conveyorLineStatus = conveyorLineInfoRead.Status.ByteToBoolObject<R_ConveyorLineStatus>(); - bool stb = device.GetValue<R_ConveyorLineDBName, bool>(R_ConveyorLineDBName.STB); - } - else + ConveyorLineSignal conveyorLineSignalRead = conveyorLineInfoRead.Signal.ByteToBoolObject<ConveyorLineSignal>(); + + W_ConveyorLineInfo conveyorLineInfoWrite = device.Communicator.ReadCustomer<W_ConveyorLineInfo>(deviceProWrite.DeviceProAddress); + + ConveyorLineSignal conveyorLineSignalWrite = conveyorLineInfoWrite.Signal.ByteToBoolObject<ConveyorLineSignal>(); + if (item.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt()) { - WriteInfo(device.DeviceName, $"鏈壘鍒拌澶囧瓙缂栧彿{item.StationCode}鐨勫崗璁俊鎭�"); + if (conveyorLineSignalRead.STB && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !conveyorLineSignalWrite.ACK) + { + if (!string.IsNullOrEmpty(conveyorLineInfoRead.Barcode)) + { + WebResponseContent content = _taskService.RequestWMSTask(conveyorLineInfoRead.Barcode, item.StationCode); + if (content.Status) + { + device.SetValue(W_ConveyorLineDB.ACK, true); + } + } + } + else if (!conveyorLineSignalRead.STB && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && conveyorLineSignalWrite.ACK) + { + device.SetValue(W_ConveyorLineDB.ACK, false); + } + } + else if (item.StationType == StationTypeEnum.StationType_InboundAndOutbound.ObjToInt()) + { + if(conveyorLineSignalRead.STB && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !conveyorLineSignalWrite.ACK) + { + Dt_Task task = _taskRepository.QueryFirst(x => x.NextAddress == item.StackerCraneCode); + if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup) + { + Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationCode == item.StationCode); + if (stationManger == null) + { + WriteInfo(item.StationName, $"鏈壘鍒板搴旂珯鍙颁俊鎭�,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}"); + continue; + } + string? locationCode = _taskService.RequestAssignLocation(task.TaskNum, stationManger.StackerCraneCode); + if (string.IsNullOrEmpty(locationCode)) + { + WriteInfo(item.StationName, $"璇锋眰鍒嗛厤璐т綅杩斿洖淇℃伅閿欒,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}"); + continue; + } + string oldAddress = task.NextAddress; + int oldStatus = task.TaskState; + task.CurrentAddress = stationManger.StackerCraneStationCode; + task.TargetAddress = locationCode; + task.NextAddress = locationCode; + task.DeviceCode = stationManger.StackerCraneCode; + task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt(); + _taskRepository.UpdateData(task); + + _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskNum, $"绯荤粺鑷姩娴佺▼,鐩爣鍦板潃鐢眥oldAddress}鍙樻洿涓簕task.NextAddress},浠诲姟鐘舵�佺敱{oldStatus}鍙樻洿涓簕task.TaskState}"); + + device.SetValue(W_ConveyorLineDB.ACK, true); + } + } + else if (!conveyorLineSignalRead.STB && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && conveyorLineSignalWrite.ACK) + { + device.SetValue(W_ConveyorLineDB.ACK, false); + } + else + { + if (!conveyorLineSignalWrite.STB && !conveyorLineSignalRead.ACK && conveyorLineStatus.Goods) + { + Dt_Task task = _taskRepository.QueryFirst(x => x.CurrentAddress == item.StationCode && x.TaskState == TaskStatusEnum.Line_Execute.ObjToInt()); + if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) + { + Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationCode == item.StationCode); + if (stationManger == null) + { + WriteInfo(item.StationName, $"鏈壘鍒板搴旂珯鍙颁俊鎭�,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}"); + continue; + } + + Dt_Router router = _routerRepository.QueryFirst(x => x.InOutType == task.TaskType && (task.CurrentAddress == x.StartPosi)); + if (router == null) + { + WriteInfo(item.StationName, $"鏈壘鍒拌矾鐢遍厤缃俊鎭�,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}"); + continue; + } + + string oldAddress = task.NextAddress; + int oldStatus = task.TaskState; + task.NextAddress = router.NextPosi; + task.TargetAddress = router.NextPosi; + task.TaskState = TaskStatusEnum.Line_Executing.ObjToInt(); + _taskRepository.UpdateData(task); + + _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskNum, $"绯荤粺鑷姩娴佺▼,鐩爣鍦板潃鐢眥oldAddress}鍙樻洿涓簕task.NextAddress},浠诲姟鐘舵�佺敱{oldStatus}鍙樻洿涓簕task.TaskState}"); + + device.SetValue(W_ConveyorLineDB.TaskNum, task.TaskNum); + device.SetValue(W_ConveyorLineDB.EndPos, task.NextAddress); + device.SetValue(W_ConveyorLineDB.StartPos, task.CurrentAddress); + device.SetValue(W_ConveyorLineDB.STB, true); + } + } + else if(conveyorLineSignalWrite.STB && conveyorLineSignalRead.ACK && conveyorLineStatus.Goods) + { + //todo 浠诲姟瀹屾垚 + } + } + } + else if (item.StationType == StationTypeEnum.StationType_InStartAndOutEnd.ObjToInt()) + { + if(!conveyorLineSignalWrite.STB && !conveyorLineSignalWrite.ACK && !conveyorLineSignalRead.STB && !conveyorLineSignalRead.ACK && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm) + { + Dt_Task task = _taskRepository.QueryFirst(x => x.TaskState == TaskStatusEnum.New.ObjToInt() && string.IsNullOrEmpty(x.TargetAddress) && x.SourceAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType)); + if(task != null) + { + device.SetValue(W_ConveyorLineDB.STB, true); + } + } + } + } + else + { + WriteInfo(device.DeviceName, $"鏈壘鍒拌澶囧瓙缂栧彿{item.StationCode}鐨勫崗璁俊鎭�"); } } } -- Gitblit v1.9.3