Files
wcs/WCS.BLL/Manager/ShelfManager.cs
hehaibing-1996 375d6971cc 增加MXL4模组
2024-12-07 17:52:56 +08:00

69 lines
2.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WCS.BLL.Config;
using WCS.BLL.DbModels;
using WCS.BLL.HardWare;
using WCS.DAL.Db;
using WCS.DAL.DbModels;
namespace WCS.BLL.Manager
{
public static class ShelfManager
{
public static List<IShelfBase> Shelves { get; set; } = new List<IShelfBase>();
static ShelfManager()
{
}
public static void InitShelves()
{
Logs.Write("【InitShelves】开始", LogsType.StartBoot);
var shelvesInDbQueryable = DbHelp.db.Queryable<ShelfInfo>();
if (LocalFile.Config.IsMx)
shelvesInDbQueryable = shelvesInDbQueryable.Where(t => t.GroupName == LocalFile.Config.GroupName);
var shelvesInDb = shelvesInDbQueryable.ToList();
foreach (var shelfInDb in shelvesInDb)
{
Shelves.Add(InitShelf(shelfInDb));
}
Logs.Write("【InitShelves】结束", LogsType.StartBoot);
}
public static IShelfBase InitShelf(ShelfInfo shelfInDb)
{
switch (shelfInDb.ShelfTypeId)
{
case 1:
return new SmartShelf(shelfInDb)
{
ShelfId = shelfInDb.Id,
ShelfCode = shelfInDb.ShelfCode,
GroupName = shelfInDb.GroupName,
};
case 2:
return new SingleLightShelf(shelfInDb)
{
ShelfId = shelfInDb.Id,
ShelfCode = shelfInDb.ShelfCode,
GroupName = shelfInDb.GroupName,
};
case 3:
return new MXL4Shelf(shelfInDb)
{
ShelfId = shelfInDb.Id,
ShelfCode = shelfInDb.ShelfCode,
GroupName = shelfInDb.GroupName,
};
default:
return null;
}
}
}
}