using WcsMain.DataBase.TableEntity; using WcsMain.Enum.TaskEnum; using WcsMain.EquipOperation.Entity.Stacker; namespace WcsMain.ExtendMethod; /// /// wcs 任务表的扩展方法 /// public static class AppWcsTaskExtendMethod { /// /// 是否是第一个任务 /// /// /// /// 序号是 1 表示第一个任务 /// /// public static bool IsFirstTask(this AppWcsTask wcsTask) { if (wcsTask == default) return false; return wcsTask.TaskSort == 1; } /// /// 是否是最后一个任务 /// /// /// /// 最后一个任务下一任务号是空值 /// /// public static bool IsLastTask(this AppWcsTask wcsTask) { if (wcsTask == default) return false; return wcsTask.NextPlcId == default; } /// /// 生成一个入库任务 /// /// /// /// /// /// public static StackerPlcTask ToStackerInTask(this AppWcsTask wcsTask, int stackerId, int forkId, AppLocation destinationDetail) { StackerPlcTask stackerTask = new() { StackerId = stackerId, PlcId = wcsTask.PlcId, TaskType = (int)WcsTaskTypeEnum.inTask, GetStand = 0, InTunnelId = Convert.ToInt16(stackerId), OutTunnelId = Convert.ToInt16(stackerId), SetStand = 0, GetQueue = 2, GetLine = Convert.ToInt16(forkId), GetLayer = 1, GetDeep = 1, SetQueue = Convert.ToInt16(destinationDetail.Queue), SetLine = Convert.ToInt16(destinationDetail.Line), SetLayer = Convert.ToInt16(destinationDetail.Layer), SetDeep = Convert.ToInt16(destinationDetail.Depth), Size = Convert.ToInt16(wcsTask.VehicleSize), Weight = Convert.ToInt16(wcsTask.Weight), Code = wcsTask.PlcVehicleNo ?? 0, }; return stackerTask; } /// /// 生成一个入库任务 /// /// /// /// /// /// public static StackerPlcTask ToStackerOutTask(this AppWcsTask wcsTask, int stackerId, int forkId, AppLocation originDetail) { StackerPlcTask stackerTask = new() { StackerId = stackerId, PlcId = wcsTask.PlcId, TaskType = (int)WcsTaskTypeEnum.outTask, GetStand = 0, InTunnelId = Convert.ToInt16(stackerId), OutTunnelId = Convert.ToInt16(stackerId), SetStand = 0, GetQueue = Convert.ToInt16(originDetail.Queue), GetLine = Convert.ToInt16(originDetail.Queue), GetLayer = Convert.ToInt16(originDetail.Queue), GetDeep = Convert.ToInt16(originDetail.Queue), SetQueue = 2, SetLine = Convert.ToInt16(forkId), SetLayer = 2, SetDeep = 1, Size = Convert.ToInt16(wcsTask.VehicleSize), Weight = Convert.ToInt16(wcsTask.Weight), Code = wcsTask.PlcVehicleNo ?? 0, }; return stackerTask; } /// /// 生成一个移库任务 /// /// /// /// /// /// public static StackerPlcTask ToStackerMoveTask(this AppWcsTask wcsTask, int stackerId, AppLocation originDetail, AppLocation destinationDetail) { StackerPlcTask stackerTask = new() { StackerId = stackerId, PlcId = wcsTask.PlcId, TaskType = (int)WcsTaskTypeEnum.moveTask, GetStand = 0, InTunnelId = Convert.ToInt16(stackerId), OutTunnelId = Convert.ToInt16(stackerId), SetStand = 0, GetQueue = Convert.ToInt16(originDetail.Queue), GetLine = Convert.ToInt16(originDetail.Queue), GetLayer = Convert.ToInt16(originDetail.Queue), GetDeep = Convert.ToInt16(originDetail.Queue), SetQueue = Convert.ToInt16(destinationDetail.Queue), SetLine = Convert.ToInt16(destinationDetail.Line), SetLayer = Convert.ToInt16(destinationDetail.Layer), SetDeep = Convert.ToInt16(destinationDetail.Depth), Size = Convert.ToInt16(wcsTask.VehicleSize), Weight = Convert.ToInt16(wcsTask.Weight), Code = wcsTask.PlcVehicleNo ?? 0, }; return stackerTask; } }