|
@@ -1,4 +1,5 @@
|
|
|
using Newtonsoft.Json;
|
|
|
+using PlcSiemens.Core.Extension;
|
|
|
using ServiceCenter.Extensions;
|
|
|
using ServiceCenter.Logs;
|
|
|
using ServiceCenter.SqlSugars;
|
|
@@ -24,6 +25,11 @@ namespace WCS.WorkEngineering.Systems
|
|
|
{
|
|
|
protected override bool ParallelDo => true;
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 是否有出库任务可执行
|
|
|
+ /// </summary>
|
|
|
+ private static Dictionary<string, bool> isOut = null;
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 取货点设备集合
|
|
|
/// </summary>
|
|
@@ -46,6 +52,16 @@ namespace WCS.WorkEngineering.Systems
|
|
|
PickUpDevices.Add(robot.Code, robot.Sources.Where(v => v.HasFlag(DeviceFlags.输送机)).Select(v => v).ToList());
|
|
|
PutDevices.Add(robot.Code, robot.Targets.Where(v => v.HasFlag(DeviceFlags.输送机)).Select(v => new Device<IStation520, IStation521, IStation523, IRobot530>(v, World)).ToList());
|
|
|
}
|
|
|
+
|
|
|
+ if (isOut.IsEmpty())
|
|
|
+ {
|
|
|
+ isOut.Add("Robot1", true);
|
|
|
+ isOut.Add("Robot2", true);
|
|
|
+ isOut.Add("Robot3", true);
|
|
|
+ isOut.Add("Robot4", true);
|
|
|
+ isOut.Add("Robot5", true);
|
|
|
+ isOut.Add("Robot6", true);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public override void Do(Device<IRobot520, IRobot521, IRobot522> obj)
|
|
@@ -176,20 +192,29 @@ namespace WCS.WorkEngineering.Systems
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ //先按可取货位数量排序,再按任务号排序
|
|
|
+ var devGroup = arrIn.OrderByDescending(x => x.Item2.Count(i => i.Data2.TaskNumber > 0 && i.Data.Status.HasFlag(StationStatus.PH_Status)))
|
|
|
+ .ThenBy(x => x.Item1.Data2.TaskNumber).First().Item2
|
|
|
+ .Where(x => x.Data2.TaskNumber > 0 && x.Data.Status.HasFlag(StationStatus.PH_Status));
|
|
|
+ //可用取货位数量为1,且出库任务有优先
|
|
|
+ if (devGroup.Count() == 1 && isOut.Any(x => x.Key == obj.Entity.Code && x.Value))
|
|
|
+ {
|
|
|
+ obj.Entity.SetFlag("InQuantity", 4); //跳过入库任务执行出库任务,下次直接查询是否有出库任务,避免无效检查周期的产生
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!devGroup.Any())
|
|
|
+ {
|
|
|
+ obj.Entity.SetFlag("InQuantity", 4); //在无有效取货位的情况下,只检查一次,下次直接查询是否有出库任务,避免无效检查周期的产生
|
|
|
+ throw new KnownException($"无有效入库取货位", LogLevelEnum.High);
|
|
|
+ }
|
|
|
+
|
|
|
+ //如果入库任务只有一个
|
|
|
+
|
|
|
//等待下发的任务信息
|
|
|
var taskList = new List<Tuple<WCS_TaskInfo, Device<IStation523, IStation524>>>();
|
|
|
SqlSugarHelper.Do(db =>
|
|
|
{
|
|
|
- //跟据设备组中第一个设备任务号最小的一个先执行
|
|
|
- var devGroup = arrIn.MinBy(x => x.Item1.Data2.TaskNumber).Item2
|
|
|
- .Where(x => x.Data2.TaskNumber > 0 && x.Data.Status.HasFlag(StationStatus.PH_Status));
|
|
|
-
|
|
|
- if (!devGroup.Any())
|
|
|
- {
|
|
|
- obj.Entity.SetFlag("InQuantity", 4); //在无有效取货位的情况下,只检查一次,下次直接查询是否有出库任务,避免无效检查周期的产生
|
|
|
- throw new KnownException($"无有效入库取货位", LogLevelEnum.High);
|
|
|
- }
|
|
|
-
|
|
|
foreach (var dev in devGroup)
|
|
|
{
|
|
|
var task = db.Default.Queryable<WCS_TaskInfo>().First(v => v.Type == TaskType.SetPlate && v.Status == Entity.TaskStatus.FinishOfShunt && dev.Data2.TaskNumber == v.ID);
|
|
@@ -353,9 +378,12 @@ namespace WCS.WorkEngineering.Systems
|
|
|
taskInfos = taskInfos.OrderByDescending(x => x.ProdLine).ToList();
|
|
|
}
|
|
|
|
|
|
+ var surplusTaskNumber = taskInfos.Count; //剩余任务数量
|
|
|
taskInfos = taskInfos.Take(2).ToList();
|
|
|
var warehouseCode = taskInfos.FirstOrDefault().WarehouseCode;
|
|
|
- if (taskInfos.Count == 2) //有两个任务
|
|
|
+ var exTaskNumber = taskInfos.Count;//执行任务数量
|
|
|
+ surplusTaskNumber -= exTaskNumber;
|
|
|
+ if (exTaskNumber == 2) //有两个任务
|
|
|
{
|
|
|
var minDepth = taskInfos!.MinBy(x => x.Depth);
|
|
|
var maxDepth = taskInfos.MaxBy(x => x.Depth);
|
|
@@ -394,6 +422,15 @@ namespace WCS.WorkEngineering.Systems
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ #region 计算剩余可执行任务数
|
|
|
+
|
|
|
+ //如果有两个任务,且只有一个任务可以执行,剩余任务数+1
|
|
|
+ if (exTaskNumber == 2 && taskInfoList.Count == 1) surplusTaskNumber += 1;
|
|
|
+ if (surplusTaskNumber >= 1) isOut[obj.Entity.Code] = true; //剩余任务数大于或等于1,下次满足条件时可以优先执行出库任务
|
|
|
+ else isOut[obj.Entity.Code] = false; //剩余任务数等于或小于0,下次满足条件时不可以优先执行出库任务
|
|
|
+
|
|
|
+ #endregion 计算剩余可执行任务数
|
|
|
+
|
|
|
foreach (var task in taskInfos)
|
|
|
{
|
|
|
task.Status = Entity.TaskStatus.StackerExecution;
|