using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DeiNiu.wms.Data.Model { public class ObjectsFactory { private static Dictionary modelCache = new Dictionary(); private static Dictionary OutDetailCache = new Dictionary(); private static Dictionary goodsCache = new Dictionary(); public static DeiNiu.Data.BaseObject.BaseModel_Imp getModel(string className) { if (modelCache.ContainsKey(className)){ return modelCache[className]; }else{ return null; } } public static void putModel(string className,DeiNiu.Data.BaseObject.BaseModel_Imp modelImp ) { modelCache[className] = modelImp; } /// /// 取的缓存商品可能没有批号信息 /// /// /// /// public static WmsGoods getGoods(string goodsId,int skuId,string batch,bool isForceRefresh = false) { WmsGoods goods ; string key = goodsId + "&&" + skuId; if (isForceRefresh || !goodsCache.Keys.Contains(key)) { goods = new WmsGoods(goodsId, skuId, batch); goodsCache[key] = goods; }else{ goods = goodsCache[key]; } return goods; } public static void putGoods(WmsGoods goods){ goodsCache[goods.goodsId] = goods; } public static void putOutDetail(WmsOutPickDetail outDetail) { OutDetailCache[outDetail.goodsId + outDetail.batch] = outDetail; putGoods(outDetail.goods); } /// /// 取有生产日期批号信息的缓存商品出库明细 /// 不存在则返回一个新初始化的商品出库明细 /// /// /// /// public static WmsOutPickDetail getOutDetail(string goodsId, string batch) { string key = goodsId + batch; if (OutDetailCache.Keys.Contains(key)) { WmsOutPickDetail outd = OutDetailCache[key]; OutDetailCache.Remove(key); // remove the cache return outd; } return new WmsOutPickDetail(); } } }