From 2c889b38311883ceb703c4e0034c798fdaa2e21c Mon Sep 17 00:00:00 2001 From: wangxinhui <wangxinhui@hnkhzn.com> Date: 星期二, 12 八月 2025 23:11:57 +0800 Subject: [PATCH] 更新代码,货位分配优化等 --- 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/阻焊仓/AGV_ZHExtend.cs | 132 +++++++++++++++++++++++++++++++++---------- 1 files changed, 100 insertions(+), 32 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\351\230\273\347\204\212\344\273\223/AGV_ZHExtend.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\351\230\273\347\204\212\344\273\223/AGV_ZHExtend.cs" index cc068a3..5289c17 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\351\230\273\347\204\212\344\273\223/AGV_ZHExtend.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\351\230\273\347\204\212\344\273\223/AGV_ZHExtend.cs" @@ -7,6 +7,7 @@ using WIDESEAWCS_Common.APIEnum; using WIDESEAWCS_Common.TaskEnum; using WIDESEAWCS_Core; +using WIDESEAWCS_Core.Enums; using WIDESEAWCS_Core.Helper; using WIDESEAWCS_Model.Models; using WIDESEAWCS_QuartzJob; @@ -16,46 +17,64 @@ { public partial class AGV_ZHJob { + /// <summary> + /// 涓嬪彂浠诲姟 + /// </summary> public void SendAGVTask() { try { - var newTasks = _taskService.Db.Queryable<Dt_Task>().Where(x => (x.TaskState == TaskStatusEnum.AGV_Execute.ObjToInt()) && nameof(AGV_PPJob).Contains(x.DeviceCode) && !string.IsNullOrEmpty(x.DeviceCode)).ToList().OrderBy(x => x.Grade).ThenBy(x => x.CreateDate).ToList(); - foreach (var task in newTasks) + var newTasks = _taskService.Db.Queryable<Dt_Task>().Where(x => x.TaskState == TaskStatusEnum.AGV_Execute.ObjToInt() && !string.IsNullOrEmpty(x.DeviceCode) && nameof(AGV_ZHJob).Contains(x.DeviceCode)).OrderByDescending(x => x.Grade).OrderBy(x => x.CreateDate).ToList(); + if (newTasks.Count > 0) { - try + foreach (var agvTask in newTasks) { - AgvTaskDTO TaskDTO = new AgvTaskDTO() + try { - TaskCode = task.AgvTaskNum, - ReqCode = DateTime.Now.ToString("yyyyMMddHHmmss") + task.AgvTaskNum, - TaskTyp = task.TaskType < TaskTypeEnum.Inbound.ObjToInt() ? "FLC" : "FLR", - ctnrCode = task.PalletCode, - PositionCodePath = new List<CodePath>() - { + AgvTaskDTO taskDTO = new AgvTaskDTO() + { + ReqCode = Guid.NewGuid().ToString().Replace("-", ""), + TaskTyp = "22", + PositionCodePath = new List<CodePath>() + { new CodePath() { type="00", - positionCode=task.CurrentAddress + positionCode=agvTask.CurrentAddress }, new CodePath() { - type="00", - positionCode=task.NextAddress + type="04", + positionCode=agvTask.NextAddress } - }, - }; - WebResponseContent content = _taskService.AgvSendTask(TaskDTO, APIEnum.Agv_ZHSendTask); - if (!content.Status) throw new Exception(content.Message); - task.TaskState = TaskStatusEnum.AGV_Executing.ObjToInt(); + }, + TaskCode = agvTask.AgvTaskNum, + PodTyp = agvTask.PalletType < 2 ? "XX" : "DD", + }; + WebResponseContent content = _taskService.AgvSendTask(taskDTO); + if (content.Status) + { + agvTask.TaskState = TaskStatusEnum.AGV_Executing.ObjToInt(); + //agvTask.Remark = content.Data.ObjToString(); + _taskService.UpdateTask(agvTask, TaskStatusEnum.AGV_Executing); + } + else + { + agvTask.TaskState = TaskStatusEnum.Exception.ObjToInt(); + //agvTask.Remark = content.Data.ObjToString(); + agvTask.ExceptionMessage = content.Message; + } + } + catch (Exception ex) + { + agvTask.TaskState = TaskStatusEnum.Exception.ObjToInt(); + //agvTask.Remark = content.Data.ObjToString(); + agvTask.ExceptionMessage = ex.Message; + WriteError(nameof(AGV_ZHJob), ex.Message, ex); + } } - catch (Exception ex) - { - task.TaskState = TaskStatusEnum.Exception.ObjToInt(); - task.ExceptionMessage = ex.Message; - } + _taskService.UpdateData(newTasks); } - _taskService.UpdateData(newTasks); } catch (Exception ex) { @@ -69,9 +88,10 @@ { try { - var WaitToTasks = _taskService.Db.Queryable<Dt_Task>().Where(x => x.TaskState == TaskStatusEnum.AGV_WaitToExecute.ObjToInt() && nameof(AGV_CSJJob).Contains(x.DeviceCode)).ToList().OrderBy(x => x.Grade).ThenBy(x => x.CreateDate).ToList(); + var WaitToTasks = _taskService.Db.Queryable<Dt_Task>().Where(x => x.TaskState == TaskStatusEnum.AGV_WaitToExecute.ObjToInt() && nameof(AGV_ZHJob).Contains(x.DeviceCode)).ToList().OrderBy(x => x.Grade).ThenBy(x => x.CreateDate).ToList(); foreach (var WaitToTask in WaitToTasks) { + AgvSecureReplyDTO replyDTO = new AgvSecureReplyDTO(); if (WaitToTask.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup) { if (WaitToTasks.FirstOrDefault(x => x.TaskState == TaskStatusEnum.AGV_Puting.ObjToInt() || x.TaskState == TaskStatusEnum.Finish.ObjToInt()) != null) @@ -101,6 +121,14 @@ continue; } otherDevice.SetValue(GroundStationDBName.W_PutPalletType, WaitToTask.PalletType, stationManger.StationCode); + + replyDTO.ReqCode = Guid.NewGuid().ToString().Replace("-", "");//WaitToTask.TaskNum.ToString(), + replyDTO.taskCode = WaitToTask.AgvTaskNum; + replyDTO.nextPositionCode = new CodePath() + { + type="00", + positionCode= stationManger.AGVStationCode + }; } else { @@ -126,13 +154,9 @@ { continue; } + replyDTO.ReqCode = Guid.NewGuid().ToString().Replace("-", "");//WaitToTask.TaskNum.ToString(), + replyDTO.taskCode = WaitToTask.AgvTaskNum; } - - AgvSecureReplyDTO replyDTO = new AgvSecureReplyDTO() - { - ReqCode = Guid.NewGuid().ToString().Replace("-", ""), //WaitToTask.TaskNum.ToString(), - taskCode = WaitToTask.AgvTaskNum, - }; WebResponseContent content = _taskService.AgvSecureReply(replyDTO); if (content.Status && WaitToTask.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup) { @@ -153,10 +177,54 @@ } } _taskService.UpdateData(WaitToTasks); + + //鍙栨斁璐у畬鎴愬啓鍏ュ紓甯稿鐞� + Dt_Task? TakeErroeTask = _taskService.Db.Queryable<Dt_Task>().Where(x => x.TaskState == TaskStatusEnum.AGV_TakeError.ObjToInt() && nameof(AGV_ZHJob).Contains(x.DeviceCode)).First(); + if (TakeErroeTask != null) + { + Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.AGVStationCode == TakeErroeTask.CurrentAddress); + if (stationManger == null) + { + throw new Exception($"鏈壘鍒扮珯鍙伴厤缃�"); + } + IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode); + if (device == null) + { + throw new Exception($"鏈壘鍒板搴旇澶�"); + } + OtherDevice otherDevice = (OtherDevice)device; + otherDevice.SetValue(GroundStationDBName.W_TakeFinish, true, stationManger.StationCode); + Thread.Sleep(1000); + otherDevice.SetValue(GroundStationDBName.W_TakeFinish, false, stationManger.StationCode); + TakeErroeTask.TaskState = TaskStatusEnum.AGV_Finish.ObjToInt(); + var up = _taskRepository.DeleteAndMoveIntoHty(TakeErroeTask, OperateTypeEnum.鑷姩瀹屾垚); + _taskService.TaskCompleted(TakeErroeTask.TaskNum); + } + Dt_Task? PutErroeTask = _taskService.Db.Queryable<Dt_Task>().Where(x => x.TaskState == TaskStatusEnum.AGV_PutError.ObjToInt() && nameof(AGV_ZHJob).Contains(x.DeviceCode)).First(); + if (PutErroeTask != null) + { + Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.AGVStationCode == PutErroeTask.NextAddress); + if (stationManger == null) + { + throw new Exception($"鏈壘鍒扮珯鍙伴厤缃�"); + } + IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode); + if (device == null) + { + throw new Exception($"鏈壘鍒扮珯鍙伴厤缃�"); + } + OtherDevice otherDevice = (OtherDevice)device; + otherDevice.SetValue(GroundStationDBName.W_PutFinish, true, stationManger.StationCode); + PutErroeTask.CurrentAddress = stationManger.StationCode; + PutErroeTask.NextAddress = ""; + PutErroeTask.TaskState = TaskStatusEnum.AGV_Finish.ObjToInt(); + PutErroeTask.DeviceCode = "SC01_ZH"; + var up = _taskRepository.UpdateData(PutErroeTask); + } } catch (Exception ex) { - Console.Out.WriteLine(nameof(AGV_CSJJob) + ":" + ex.Message); + Console.Out.WriteLine(nameof(AGV_ZHJob) + ":" + ex.Message); } } } -- Gitblit v1.9.3