using HH.WCS.Mobox3.YNJT_BZP.util; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using static HH.WCS.Mobox3.YNJT_BZP.api.ApiHelper; using static HH.WCS.Mobox3.YNJT_BZP.wms.LocationHelper; namespace HH.WCS.Mobox3.YNJT_BZP.wms { internal class ItemHelper { private static Dictionary itemInfos = null; static ItemHelper() { try { //初始化Location加入到字典缓存 itemInfos = new Dictionary(); 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 List GetAllItemList() { var db = new SqlHelper().GetInstance(); return db.Queryable().ToList(); } internal static CntrItemRel GetCntrItem(string itemCode) { var db = new SqlHelper().GetInstance(); return db.Queryable().Where(a => a.S_ITEM_CODE == itemCode).First(); } public static bool addCntrItem(string cntrCode,List itemInfos) { var db = new SqlHelper().GetInstance(); var cntrItemRels = db.Queryable().Where(a => a.S_CNTR_CODE == cntrCode).ToList(); if (cntrItemRels.Count > 0) { ContainerHelper.deleteCntrItem(cntrCode); } if (itemInfos != null && itemInfos.Count > 0) { foreach (var itemInfo in itemInfos) { CntrItemRel cntrItemRel = new CntrItemRel() { S_CNTR_CODE = cntrCode, S_ITEM_CODE = itemInfo.item, S_CG_ID = itemInfo.bc_entried, S_MCN = itemInfo.mcn, S_ITEM_STATE = itemInfo.jdge, F_QTY = itemInfo.qty, S_OPR = itemInfo.opr, S_TXNDATE = itemInfo.txndate, S_SHIFT = itemInfo.shift, S_FOVRAGE = itemInfo.fovrage, S_EFFECTIVE_TIME = itemInfo.effective_time, S_EXPIRATION_TIME = itemInfo.expiration_time, S_SARANA = itemInfo.sarana, }; ContainerHelper.addCntrItem(cntrCode, cntrItemRel); } } return true; } } }