新增拣选分配两个区域按比率平衡
This commit is contained in:
parent
263d18f6c6
commit
a3dcfff0c2
|
|
@ -86,4 +86,10 @@ public class AppConfigEntity
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[ConfigKey("ExcuteStackerInTaskWithScan")]
|
[ConfigKey("ExcuteStackerInTaskWithScan")]
|
||||||
public string? ExcuteStackerInTaskWithScan { get; set; }
|
public string? ExcuteStackerInTaskWithScan { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 去往 pick2 箱子的比率
|
||||||
|
/// </summary>
|
||||||
|
[ConfigKey("Pick2Lv")]
|
||||||
|
public int Pick2Lv { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,19 +77,31 @@ public class StackerOutC1(ConveyOperation conveyOperation, DataBaseData dataBase
|
||||||
ConsoleLog.Warning($"【警告】出库分流:{area} 箱码:{msg},写入PLC失败,{plcTask},信息:{errText}");
|
ConsoleLog.Warning($"【警告】出库分流:{area} 箱码:{msg},写入PLC失败,{plcTask},信息:{errText}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* 检查是不是有 1~5 站台(pick1 区域)的拣选任务,若有则不移栽,走下层 */
|
|
||||||
|
(bool isHavePick1, bool isHavePick2) = (false, false); // 默认都不含有任务
|
||||||
|
// 检验是否存在 pick1 区域的任务
|
||||||
List<AppConveyStand> pick1Stand = CommonData.AppConveyStands.FindAll(f => f.StandType == (int)ConveyStandTypeEnum.pick && f.Area == "pick1");
|
List<AppConveyStand> pick1Stand = CommonData.AppConveyStands.FindAll(f => f.StandType == (int)ConveyStandTypeEnum.pick && f.Area == "pick1");
|
||||||
List<string?> pick1Stands = pick1Stand.Select(f => f.StandId).ToList();
|
List<string?> pick1Stands = pick1Stand.Select(f => f.StandId).ToList();
|
||||||
bool exists = false; // 默认不存在 1~5 站台(pick1 区域) 任务
|
|
||||||
foreach (var conveyTask in conveyTasks)
|
foreach (var conveyTask in conveyTasks)
|
||||||
{
|
{
|
||||||
if (pick1Stands.Contains(conveyTask.Location))
|
if (pick1Stands.Contains(conveyTask.Location))
|
||||||
{
|
{
|
||||||
exists = true;
|
isHavePick1 = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(exists) // 存在该区域任务 1~5 站台(pick1 区域)
|
// 校验是否含有 pick2区域的任务
|
||||||
|
List<AppConveyStand> pick2Stand = CommonData.AppConveyStands.FindAll(f => f.StandType == (int)ConveyStandTypeEnum.pick && f.Area == "pick2");
|
||||||
|
List<string?> pick2Stands = pick2Stand.Select(f => f.StandId).ToList();
|
||||||
|
foreach (var conveyTask in conveyTasks)
|
||||||
|
{
|
||||||
|
if (pick2Stands.Contains(conveyTask.Location))
|
||||||
|
{
|
||||||
|
isHavePick2 = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isHavePick1 && !isHavePick2) // 存在该区域任务 1~5 站台(pick1 区域),不存在 pick2 区域任务
|
||||||
{
|
{
|
||||||
ConsoleLog.Info($"出库分流:{area} 箱码:{msg} 存在 1~5 站台任务");
|
ConsoleLog.Info($"出库分流:{area} 箱码:{msg} 存在 1~5 站台任务");
|
||||||
ConveyPLCTask plcTask = new(plcId, (short)ConveyRouterEnum.Go);
|
ConveyPLCTask plcTask = new(plcId, (short)ConveyRouterEnum.Go);
|
||||||
|
|
@ -102,7 +114,7 @@ public class StackerOutC1(ConveyOperation conveyOperation, DataBaseData dataBase
|
||||||
ConsoleLog.Warning($"【警告】出库分流:{area} 箱码:{msg},写入PLC失败,{plcTask},信息:{errText}");
|
ConsoleLog.Warning($"【警告】出库分流:{area} 箱码:{msg},写入PLC失败,{plcTask},信息:{errText}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else // 6~9 站台(pick2 区域)
|
else if (!isHavePick1 && isHavePick2) // 不存在该区域pick1任务,存在 pick2 区域任务
|
||||||
{
|
{
|
||||||
ConsoleLog.Info($"出库分流:{area} 箱码:{msg} 不存在 1~5 站台任务");
|
ConsoleLog.Info($"出库分流:{area} 箱码:{msg} 不存在 1~5 站台任务");
|
||||||
ConveyPLCTask plcTask = new(plcId, (short)ConveyRouterEnum.Move);
|
ConveyPLCTask plcTask = new(plcId, (short)ConveyRouterEnum.Move);
|
||||||
|
|
@ -115,5 +127,21 @@ public class StackerOutC1(ConveyOperation conveyOperation, DataBaseData dataBase
|
||||||
ConsoleLog.Warning($"【警告】出库分流:{area} 箱码:{msg},写入PLC失败,{plcTask},信息:{errText}");
|
ConsoleLog.Warning($"【警告】出库分流:{area} 箱码:{msg},写入PLC失败,{plcTask},信息:{errText}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else // 两个地区都存在任务
|
||||||
|
{
|
||||||
|
ConsoleLog.Info($"出库分流:{area} 箱码:{msg} 存在 1~5 站台任务且存在 6~9 区域任务");
|
||||||
|
Random random = new();
|
||||||
|
var id = random.Next(0, 100);
|
||||||
|
ConveyPLCTask plcTask = new(plcId, id < CommonData.AppConfig.Pick2Lv ? (short)ConveyRouterEnum.Move : (short)ConveyRouterEnum.Go);
|
||||||
|
string errText = conveyOperation.WriteTask(area, plcTask);
|
||||||
|
if (string.IsNullOrEmpty(errText))
|
||||||
|
{
|
||||||
|
ConsoleLog.Success($"出库分流:{area} 箱码:{msg},写入PLC成功,{plcTask}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ConsoleLog.Warning($"【警告】出库分流:{area} 箱码:{msg},写入PLC失败,{plcTask},信息:{errText}");
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user