From 1824228ee4f0f25383d1c9e9fea684dfc8a460bc Mon Sep 17 00:00:00 2001 From: wankeda <Administrator@DESKTOP-HAU3ST3> Date: 星期六, 01 三月 2025 17:36:43 +0800 Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/MeiRuiAn/HuaiAn --- 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/测试架仓/GroundStationJob_CSJ.cs | 97 ++++++++++++++++++++++++++++++++++-------------- 1 files changed, 69 insertions(+), 28 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\265\213\350\257\225\346\236\266\344\273\223/GroundStationJob_CSJ.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\265\213\350\257\225\346\236\266\344\273\223/GroundStationJob_CSJ.cs" index 023c6cd..d2ae90d 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\265\213\350\257\225\346\236\266\344\273\223/GroundStationJob_CSJ.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\265\213\350\257\225\346\236\266\344\273\223/GroundStationJob_CSJ.cs" @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; using WIDESEAWCS_Common; @@ -12,6 +13,7 @@ using WIDESEAWCS_ITaskInfoService; using WIDESEAWCS_Model.Models; using WIDESEAWCS_QuartzJob; +using WIDESEAWCS_Tasks.HoisterJob; namespace WIDESEAWCS_Tasks { @@ -41,46 +43,85 @@ { if (device == null) { - WriteInfo(nameof(GroundStationJob_CSJ), "璋冨害閿欒,璁惧瀵硅薄浼犲�间负null"); + WriteError(nameof(GroundStationJob_CSJ), "璋冨害閿欒,璁惧瀵硅薄浼犲�间负null"); return Task.CompletedTask; } - + List<string> deviceStations = device.DeviceProDTOs.Select(x => x.DeviceChildCode).ToList(); List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == device.DeviceCode); - foreach (var item in stationMangers) + foreach (var item in stationMangers.Where(x => deviceStations.Contains(x.StationCode))) { - bool isCanPut = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanPut, item.StationCode); - bool isCanTake = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanTake, item.StationCode); - bool putRequest = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_PutRequest, item.StationCode); - bool putFinish = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_PutFinish, item.StationCode); - bool takeRequest = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_TakeRequest, item.StationCode); - bool takeFinish = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_TakeFinish, item.StationCode); - - if (item.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt()) + try { - Dt_Task task = _taskRepository.QueryFirst(x => x.DeviceCode == item.StackerCraneCode && x.TaskState == TaskStatusEnum.New.ObjToInt() && string.IsNullOrEmpty(x.NextAddress)); - if (task != null && isCanPut && !isCanTake && !putRequest && !putFinish && !takeRequest && !takeFinish) + bool isCanPut = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanPut, item.StationCode); + bool isCanTake = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanTake, item.StationCode); + bool putRequest = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_PutRequest, item.StationCode); + bool putFinish = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_PutFinish, item.StationCode); + bool takeRequest = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_TakeRequest, item.StationCode); + bool takeFinish = device.GetValue<GroundStationDBName, bool>(GroundStationDBName.W_TakeFinish, item.StationCode); + + if (item.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt()) { - string oldAddress = task.NextAddress; - int oldStatus = task.TaskState; - task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt(); - task.NextAddress = item.StationCode; - _taskRepository.UpdateData(task); - _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskNum, $"绯荤粺鑷姩娴佺▼,鐩爣鍦板潃鐢眥oldAddress}鍙樻洿涓簕task.NextAddress},浠诲姟鐘舵�佺敱{oldStatus}鍙樻洿涓簕task.TaskState}"); + Dt_Task task = _taskRepository.QueryFirst(x => x.DeviceCode == item.StackerCraneCode && x.TaskState == TaskStatusEnum.SC_Execute.ObjToInt() && string.IsNullOrEmpty(x.NextAddress)); + if (task != null && isCanPut && !isCanTake && !putRequest && !putFinish && !takeRequest && !takeFinish) + { + _taskService.UpdateTask(task, TaskStatusEnum.SC_Execute, nextAddress: item.StationCode); + } + } + if (item.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt()) + { + Dt_Task task = _taskRepository.QueryFirst(x => (x.TargetAddress == item.StackerCraneCode || string.IsNullOrEmpty(x.TargetAddress) || x.NextAddress == item.StackerCraneCode || string.IsNullOrEmpty(x.NextAddress)) && (x.TaskState == TaskStatusEnum.New.ObjToInt() || x.TaskState == TaskStatusEnum.AGV_Finish.ObjToInt()) && (x.SourceAddress == item.StationCode || x.CurrentAddress == item.AGVStationCode || x.CurrentAddress == item.StationCode)); + if (task != null) + { + string oldAddress = task.NextAddress; + int oldStatus = task.TaskState; + Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationCode == item.StationCode); + if (stationManger == null) + { + WriteError(item.StationName, $"鏈壘鍒板搴旂珯鍙颁俊鎭�,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}"); + continue; + } + string? locationCode = _taskService.RequestAssignLocation(task.TaskNum, stationManger.StackerCraneCode); + if (string.IsNullOrEmpty(locationCode)) + { + WriteError(item.StationName, $"璇锋眰鍒嗛厤璐т綅杩斿洖淇℃伅閿欒,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}"); + continue; + } + _taskService.UpdateTask(task, TaskStatusEnum.SC_Execute, currentAddress: stationManger.StackerCraneStationCode, targetAddress: locationCode, nextAddress: locationCode, deviceCode: stationManger.StackerCraneCode); + } } } - else if (item.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt()) + catch (Exception ex) { - Dt_Task task = _taskRepository.QueryFirst(x => x.TargetAddress == item.StackerCraneCode && x.TaskState == TaskStatusEnum.New.ObjToInt() && string.IsNullOrEmpty(x.NextAddress)); - if (task != null && isCanPut && !isCanTake && !putRequest && !putFinish && !takeRequest && !takeFinish) + WriteError(device.DeviceCode, $"{item}浜や簰閿欒", ex); + } + } + + foreach (var item in stationMangers.Where(x => !deviceStations.Contains(x.StationCode))) + { + try + { + Dt_Task task = _taskRepository.QueryFirst(x => x.TaskState == TaskStatusEnum.New.ObjToInt() && x.SourceAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType)); + if (task != null) { - string oldAddress = task.NextAddress; - int oldStatus = task.TaskState; - task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt(); - task.NextAddress = item.StationCode; - _taskRepository.UpdateData(task); - _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskNum, $"绯荤粺鑷姩娴佺▼,鐩爣鍦板潃鐢眥oldAddress}鍙樻洿涓簕task.NextAddress},浠诲姟鐘舵�佺敱{oldStatus}鍙樻洿涓簕task.TaskState}"); + Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationCode == item.StationCode); + if (stationManger == null) + { + WriteError(item.StationName, $"鏈壘鍒板搴旂珯鍙颁俊鎭�,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}"); + continue; + } + string? locationCode = _taskService.RequestAssignLocation(task.TaskNum, stationManger.StackerCraneCode); + if (string.IsNullOrEmpty(locationCode)) + { + WriteError(item.StationName, $"璇锋眰鍒嗛厤璐т綅杩斿洖淇℃伅閿欒,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}"); + continue; + } + _taskService.UpdateTask(task, TaskStatusEnum.SC_Execute, currentAddress: stationManger.StackerCraneStationCode, targetAddress: locationCode, nextAddress: locationCode, deviceCode: stationManger.StackerCraneCode); } } + catch (Exception ex) + { + + } } } catch (Exception ex) -- Gitblit v1.9.3