From efaf0b8aeb26aca6536a4b384c912cc3cac4d070 Mon Sep 17 00:00:00 2001 From: wangxinhui <wangxinhui@hnkhzn.com> Date: 星期六, 15 三月 2025 16:07:45 +0800 Subject: [PATCH] 成品代码,其他仓优化,前端优化界面增加 --- 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/成品仓/AGV_CPExtend.cs | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 103 insertions(+), 10 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/AGV_CPExtend.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/AGV_CPExtend.cs" index 1e451d5..c446cbb 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/AGV_CPExtend.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/AGV_CPExtend.cs" @@ -1,4 +1,5 @@ -锘縰sing System; +锘縰sing OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,7 +9,9 @@ using WIDESEAWCS_Common.TaskEnum; using WIDESEAWCS_Core; using WIDESEAWCS_Core.Helper; +using WIDESEAWCS_DTO.Agv; using WIDESEAWCS_Model.Models; +using WIDESEAWCS_QuartzJob; namespace WIDESEAWCS_Tasks { @@ -18,7 +21,7 @@ { try { - var newTasks = _taskService.Db.Queryable<Dt_Task>().Where(x => x.TaskState == TaskStatusEnum.AGV_Execute.ObjToInt() && nameof(AGV_CPJob).Contains(x.DeviceCode) && !string.IsNullOrEmpty(x.DeviceCode)).ToList().OrderBy(x => x.Grade).ThenBy(x => x.CreateDate).ToList(); + var newTasks = _taskService.Db.Queryable<Dt_Task>().Where(x => (x.TaskState == TaskStatusEnum.AGV_Execute.ObjToInt()|| x.TaskState == TaskStatusEnum.New.ObjToInt()) && nameof(AGV_CPJob).Contains(x.DeviceCode) && !string.IsNullOrEmpty(x.DeviceCode)).ToList().OrderBy(x => x.Grade).ThenBy(x => x.CreateDate).ToList(); foreach (var task in newTasks) { try @@ -47,11 +50,11 @@ } }, }; + //鍙戦�丄GV浠诲姟 WebResponseContent content = _taskService.AgvSendTask(taskDTO, APIEnum.Agv_CPSendTask); - if (!content.Status) throw new Exception(content.Message); - + if (!content.Status) + throw new Exception(content.Message); task.TaskState = TaskStatusEnum.AGV_Executing.ObjToInt(); - } catch (Exception ex) { @@ -62,6 +65,96 @@ if (newTasks.Count>0) { _taskService.UpdateData(newTasks); + } + } + catch (Exception ex) + { + WriteError(nameof(AGV_CPJob), ex.Message, ex); + } + } + /// <summary> + /// AGV鍙栨斁璐у洖璋� + /// </summary> + public void ContinueAGVTask() + { + try + { + //鑾峰彇鏄惁鏈夊畨鍏ㄧ敵璇蜂腑鐨勪换鍔� + var continueTask = _taskService.Db.Queryable<Dt_Task>().Where(x => (x.TaskState == TaskStatusEnum.AGV_WaitToExecute.ObjToInt()) && nameof(AGV_CPJob).Contains(x.DeviceCode) && !string.IsNullOrEmpty(x.DeviceCode)).ToList().OrderBy(x => x.Grade).ThenBy(x => x.CreateDate).FirstOrDefault(); + if (continueTask!=null) + { + //鍙栬揣鍥炶皟 + if (continueTask.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup) + { + Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.AGVStationCode == continueTask.CurrentAddress); + if (stationManger == null) + { + throw new Exception($"鏈壘鍒扮珯鍙皗continueTask.CurrentAddress}淇℃伅"); + } + IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode); + if (device == null) + { + throw new Exception($"鏈壘鍒拌澶噞stationManger.StationDeviceCode}淇℃伅"); + } + OtherDevice otherDevice = (OtherDevice)device; + short canTake = otherDevice.GetValue<GroundStationDBName, short>(GroundStationDBName.R_IsCanTake, stationManger.StationCode); + if (canTake != 1) + { + return; + } + } + else//鏀捐揣鍥炶皟 + { + Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.AGVStationCode == continueTask.NextAddress); + if (stationManger == null) + { + throw new Exception($"鏈壘鍒扮珯鍙皗continueTask.NextAddress}淇℃伅"); + } + IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode); + if (device == null) + { + throw new Exception($"鏈壘鍒拌澶噞stationManger.StationDeviceCode}淇℃伅"); + } + OtherDevice otherDevice = (OtherDevice)device; + short canPut = otherDevice.GetValue<GroundStationDBName, short>(GroundStationDBName.R_IsCanPut, stationManger.StationCode); + if (canPut != 1) + { + return; + } + } + //鑾峰彇璋冨叆鍙傛暟 + AGVBoxApplyPassDTO boxApplyPassDTO = new AGVBoxApplyPassDTO() + { + ReqCode = Guid.NewGuid().ToString().Replace("-", ""), + ReqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), + TaskCode = continueTask.AgvTaskNum + }; + if (continueTask.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup) + { + boxApplyPassDTO.Type = "1"; + } + else + { + boxApplyPassDTO.Type = "2"; + } + //璇锋眰鏂欑鍥炶皟鎺ュ彛 + WebResponseContent content = _taskService.AgvBoxApplyPass(boxApplyPassDTO); + if (content.Status && continueTask.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup) + { + continueTask.TaskState = TaskStatusEnum.AGV_Executing.ObjToInt(); + _taskService.UpdateTask(continueTask, TaskStatusEnum.AGV_Executing); + } + else if (content.Status && continueTask.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) + { + continueTask.TaskState = TaskStatusEnum.AGV_Puting.ObjToInt(); + _taskService.UpdateTask(continueTask, TaskStatusEnum.AGV_Puting); + } + else + { + continueTask.TaskState = TaskStatusEnum.Exception.ObjToInt(); + continueTask.ExceptionMessage = content.Message; + _taskService.UpdateTask(continueTask, TaskStatusEnum.Exception); + } } } catch (Exception ex) @@ -84,11 +177,11 @@ var Layer = Convert.ToInt16(targetCodes[3]); var a = Row switch { - 1 => "A1", - 2 => "B1", - 3 => "C1", - 4 => "D1", - 5 => "E1", + 1 => "A", + 2 => "B", + 3 => "C", + 4 => "D", + 5 => "E", _ => throw new Exception($"鏈畾涔夌殑鎺�,鍦板潃:銆恵Address}銆�"), }; var b = Layer > 9 ? "" + Layer : "0" + Layer; -- Gitblit v1.9.3