using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WCS.PLC
{
public class EquRouteHelper
{
///
/// 筛选路由信息
///
///
///
///
public static List QueryRoute(string startPos, string toPos)
{
var list = new List();
var equRouteS = Current.EquRouteSet.Where(v => v.ROUTE_STARTPOS == startPos).OrderByDescending(v => v.ISEND).ToList();//查询下一个路由地址
var endroute = equRouteS.Where(v => v.ROUTE_SONPOS == toPos || v.ROUTE_NEXTPOS == toPos);
if (endroute.Count() > 0)
{
//查询到最后的目标地址
foreach (var item in endroute)
{
if (list.Any(v => v.ROUTE_ID == item.ROUTE_ID) == false)
{
list.Add(item);
}
}
}
else
{
foreach (var equRoute in equRouteS)
{
//if (!string.IsNullOrWhiteSpace(outInType))
//{
// if (outInType == "in")
// {
// if (equRoute.ROUTE_INOUTTYPE == "out") continue;
// }
// else if (outInType == "out")
// {
// if (equRoute.ROUTE_INOUTTYPE == "in") continue;
// }
//}
if (equRoute.ISEND && equRoute.ROUTE_NEXTPOS != toPos && equRoute.ROUTE_NEXTPOS != toPos && equRoute.ROUTE_NOTES != "1")
{
//该路由地址为终点出口,并且不是任务的终点位置,则忽略该路由轨迹
continue;
}
var equRoutes = QueryRoute(equRoute.ROUTE_NEXTPOS, toPos);
foreach (var item in equRoutes)
{
if (list.Any(v => v.ROUTE_ID == item.ROUTE_ID) == false)
{
list.Add(item);
}
if (list.Any(v => v.ROUTE_ID == equRoute.ROUTE_ID) == false)
{
list.Add(equRoute);
}
}
}
}
return list;
}
}
}