using HH.MData;
using HH.WMS.Entitys.Basic;
using MongoDB.Driver;
using MongoDB.Driver.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HH.WMS.DAL.Basic
{
public class TN_AB_STOCK_LOCATIONDAL:BaseDAL
{
#region 根据货位编号查询货位实体(MongoDB)
///
/// 根据货位编号查询货位实体(MongoDB)
///
///
///
/// [Hanhe(XDL)] CREATED 2018-11-13
public AutoBomLocationEntity GetLocationModel(string CN_S_LOCATION_CODE)
{
IMongoQuery query = Query.And(Query.EQ("CN_S_LOCATION_CODE", CN_S_LOCATION_CODE));
return MongoDBSingleton.Instance.FindOne(query, "TN_AB_STOCK_LOCATION");
}
#endregion
#region 根据货位编号查询货位实体(MongoDB)
///
/// 根据货位编号查询货位实体(MongoDB)
///
///
///
/// [Hanhe(DBS)] created 2018-3-31
public AutoBomLocationEntity GetModel(string location)
{
IMongoQuery query = Query.And(Query.EQ("CN_S_LOCATION_CODE", location));
return MongoDBSingleton.Instance.FindOne(query, "TN_AB_STOCK_LOCATION");
}
#endregion
#region 根据货位编号查询货位实体重载(MongoDB)
///
/// 根据货位编号查询货位实体(MongoDB)
///
///
///
/// [Hanhe(zh)] created 2018-5-3
public AutoBomLocationEntity GetModel(string location, string stock)
{
IMongoQuery query = Query.And(Query.EQ("CN_S_LOCATION_CODE", location));
if (!string.IsNullOrEmpty(stock))
{
query = Query.And(query, Query.EQ("CN_S_STOCK_CODE", stock));
}
return MongoDBSingleton.Instance.FindOne(query, "TN_AB_STOCK_LOCATION");
}
#endregion
#region 更新库区编号获取库区下的所有货位
///
/// 更新库区编号获取库区下的所有货位
///
/// 库区编号
///
/// [Hanhe(DBS)] CREATED 2018-11-29
public List GetAreaLocations(string areaCode)
{
IMongoQuery query = Query.And(Query.EQ("CN_S_AREA_CODE", areaCode));
return MongoDBSingleton.Instance.Find(query,"TN_AB_STOCK_LOCATION");
}
#endregion
#region 根据货位获取仓库库区实体(MongoDB)
///
/// 根据货位获取仓库库区实体(MongoDB)
///
/// 库区编号
///
/// [Hanhe(XDL)] created 2018-4-18
/// [Hanhe(DBS)] created 2018-5-18
public AutoBomStockAreaEntity GetAreaModelByLocation(string locationCode)
{
AutoBomLocationEntity locationModel = GetModel(locationCode);
if (locationModel == null)
return null;
IMongoQuery query = Query.And(Query.EQ("CN_S_AREA_CODE", locationModel.CN_S_AREA_CODE));
return MongoDBSingleton.Instance.FindOne(query, "TN_AB_B_STOCK_AREA");
}
#endregion
}
}