using HH.WCS.Mobox3.HD.util;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Runtime.ConstrainedExecution;
|
using System.Text;
|
using System.Threading.Tasks;
|
using static HH.WCS.Mobox3.HD.wms.LocationHelper;
|
|
namespace HH.WCS.Mobox3.HD.wms {
|
internal class ItemHelper {
|
private static Dictionary<string,ItemInfo > itemInfos = null;
|
|
static ItemHelper() {
|
try {
|
//初始化Location加入到字典缓存
|
itemInfos = new Dictionary<string, ItemInfo>();
|
var list = GetAllItemList();
|
if (list.Count > 0) {
|
list.ForEach(a => {
|
if (!itemInfos.ContainsKey(a.S_ITEM_CODE)) {
|
itemInfos.Add(a.S_ITEM_CODE, a);
|
}
|
});
|
}
|
}
|
catch (Exception ex) {
|
Console.WriteLine(ex.Message);
|
}
|
}
|
/* internal static ItemInfo GetItemInfo(string code) {
|
if (itemInfos.ContainsKey(code)) {
|
return itemInfos[code];
|
}
|
else {
|
return null;
|
}
|
}*/
|
|
internal static ItemInfo GetItemInfo(string code)
|
{
|
var db = new SqlHelper<object>().GetInstance();
|
return db.Queryable<ItemInfo>().Where(a => a.S_ITEM_CODE == code).First();
|
}
|
|
|
internal static List<ItemInfo> GetAllItemList() {
|
var db = new SqlHelper<object>().GetInstance();
|
return db.Queryable<ItemInfo>().ToList();
|
}
|
|
internal static void AddItemInfo(ItemInfo itemInfo) {
|
var db = new SqlHelper<object>().GetInstance();
|
db.Insertable<ItemInfo>(itemInfo).ExecuteCommand();
|
}
|
|
internal static void UpdateItemInfo(ItemInfo itemInfo)
|
{
|
var db = new SqlHelper<object>().GetInstance();
|
db.Updateable<ItemInfo>(itemInfo).ExecuteCommand();
|
}
|
|
internal static CntrItemRel GetCntrItemByItemCode(string itemCode)
|
{
|
var db = new SqlHelper<object>().GetInstance();
|
return db.Queryable<CntrItemRel>().Where(a => a.S_ITEM_CODE == itemCode).First();
|
}
|
|
internal static List<CntrItemRel> GetCntrItemByCntrCode(string cntrCode)
|
{
|
var db = new SqlHelper<object>().GetInstance();
|
return db.Queryable<CntrItemRel>().Where(a => a.S_CNTR_CODE == cntrCode).ToList();
|
}
|
|
internal static void updateCntrItem(CntrItemRel cntrItemInfo) {
|
var db = new SqlHelper<object>().GetInstance();
|
db.Updateable<CntrItemRel>(cntrItemInfo).ExecuteCommand();
|
}
|
|
internal static CntrItemRel GetCoilItemInfo(string coilCode)
|
{
|
var db = new SqlHelper<object>().GetInstance();
|
return db.Queryable<CntrItemRel>().Where(a => a.S_COIL_NO == coilCode).First();
|
}
|
|
internal static List<CntrItemRel> GetNarrowCoilInfo(string coilCode)
|
{
|
coilCode = coilCode + "-";
|
var db = new SqlHelper<object>().GetInstance();
|
return db.Queryable<CntrItemRel>().Where(a => a.S_COIL_NO.Contains(coilCode)).ToList();
|
}
|
internal static bool UpdateCntrItemInfo(CntrItemRel cntrItemRel)
|
{
|
var db = new SqlHelper<object>().GetInstance();
|
return db.Updateable<CntrItemRel>(cntrItemRel).ExecuteCommand()>0;
|
}
|
internal static bool CreateCntrItemInfo(CntrItemRel cntrItemRel)
|
{
|
var db = new SqlHelper<object>().GetInstance();
|
return db.Insertable<CntrItemRel>(cntrItemRel).ExecuteCommand() > 0;
|
}
|
|
}
|
}
|