86 lines
2.6 KiB
C#
86 lines
2.6 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
|
|||
|
namespace DeiNiu.wms.Data.Model
|
|||
|
{
|
|||
|
public class ObjectsFactory
|
|||
|
{
|
|||
|
|
|||
|
private static Dictionary<string, DeiNiu.Data.BaseObject.BaseModel_Imp> modelCache = new Dictionary<string, DeiNiu.Data.BaseObject.BaseModel_Imp>();
|
|||
|
private static Dictionary<string, WmsOutPickDetail> OutDetailCache = new Dictionary<string, WmsOutPickDetail>();
|
|||
|
private static Dictionary<string, WmsGoods> goodsCache = new Dictionary<string, WmsGoods>();
|
|||
|
|
|||
|
|
|||
|
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;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 取的缓存商品可能没有批号信息
|
|||
|
/// </summary>
|
|||
|
/// <param name="goodsId"></param>
|
|||
|
/// <param name="isForceRefresh"></param>
|
|||
|
/// <returns></returns>
|
|||
|
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);
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 取有生产日期批号信息的缓存商品出库明细
|
|||
|
/// 不存在则返回一个新初始化的商品出库明细
|
|||
|
/// </summary>
|
|||
|
/// <param name="goodsId"></param>
|
|||
|
/// <param name="batch"></param>
|
|||
|
/// <returns></returns>
|
|||
|
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();
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|