using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HH.MData;
using HH.WMS.Entitys.Algorithm;
using MongoDB.Driver.Builders;
using MongoDB.Bson;
using MongoDB.Driver;
using HH.WMS.Entitys.Basic;
namespace HH.WMS.DAL.Algorithm
{
///
/// 用户读取mongodb中的货位信息
///
public class TN_WMS_LOCATIONDAL : BaseDAL
{
#region 根据仓库编号获得所有货位
///
/// 根据仓库编号获得所有货位
///
///
///
public List GetLocationByStockCode(string stockCode)
{
List lstLocation = new List();
//作为查询条件
var query = Query.And(Query.EQ("CN_S_STOCK_CODE", stockCode), Query.NE("CN_S_STATUS", "报废"));
lstLocation = MongoDBSingleton.Instance.Find(query, "TN_AB_STOCK_LOCATION");
return lstLocation;
}
#endregion
#region 根据货位编号获得货位
///
/// 根据货位编号获得货位
///
/// 货位编号
///
public List GetLocationByLocationCode(List locationCodes)
{
List lstLocation = new List();
//作为查询条件
var listLocation = locationCodes.ConvertAll(x => x);
var query = Query.And(Query.In("CN_S_LOCATION_CODE", listLocation), Query.NE("CN_S_STATUS", "报废"));
lstLocation = MongoDBSingleton.Instance.Find(query, "TN_AB_STOCK_LOCATION");
return lstLocation;
}
public List GetLocationByLocationCode(List locationCodes, string CN_S_TYPE)
{
List lstLocation = new List();
//作为查询条件
//获得排列表
var listLocation = locationCodes.ConvertAll(x => x);
var query = Query.And(Query.In("CN_S_LOCATION_CODE", listLocation), Query.EQ("CN_S_TYPE", CN_S_TYPE), Query.NE("CN_S_STATUS", "报废"));
lstLocation = MongoDBSingleton.Instance.Find(query, "TN_AB_STOCK_LOCATION");
return lstLocation;
}
#endregion
#region 获取仓库中货位状态为报废的数据
public List GetScrapLocationByCondition(List lstAreaCode)
{
List lstLocation = new List();
//作为查询条件
var listAreaCode = lstAreaCode.ConvertAll(x => x);
var query = Query.And(Query.In("CN_S_AREA_CODE", listAreaCode), Query.EQ("CN_S_STATUS", "报废"));
lstLocation = MongoDBSingleton.Instance.Find(query, "TN_AB_STOCK_LOCATION");
return lstLocation.Select(o => o.CN_S_LOCATION_CODE).ToList();
}
#endregion
#region 获取货位的配送节拍
public List GetBeatBitByLocation(List lstLocationCode)
{
List lstLocation = new List();
//作为查询条件
var listLocationCode = lstLocationCode.ConvertAll(x => x);
var query = Query.And(Query.In("CN_S_LOCATION_CODE", listLocationCode));
lstLocation = MongoDBSingleton.Instance.Find(query, "TN_AB_STOCK_LOCATION");
return lstLocation;
}
#endregion
#region 根据货位编号获得货位详细信息
///
/// 根据货位编号获得货位详细信息
///
///
///
public AutoBomLocationAbbreEntity GetLocationByLocationCodeAbbre(string locationCode)
{
//作为查询条件
//获得排列表
var query = Query.And(Query.EQ("CN_S_LOCATION_CODE", locationCode), Query.NE("CN_S_STATUS", "报废"));
AutoBomLocationAbbreEntity lstLocation = MongoDBSingleton.Instance.FindOne(query, "TN_AB_STOCK_LOCATION");
return lstLocation;
}
///
/// 根据货位编号获得货位详细信息
///
///
///
public AutoBomLocationEntity GetModel(string locationCode)
{
//作为查询条件
//获得排列表
var query = Query.And(Query.EQ("CN_S_LOCATION_CODE", locationCode), Query.NE("CN_S_STATUS", "报废"));
AutoBomLocationEntity lstLocation = MongoDBSingleton.Instance.FindOne(query, "TN_AB_STOCK_LOCATION");
return lstLocation;
}
#endregion
public List GetScrapLocationCode(List locationCodes)
{
List lstLocation = new List();
//作为查询条件
var listLocation = locationCodes.ConvertAll(x => x);
var query = Query.And(Query.In("CN_S_LOCATION_CODE", listLocation), Query.EQ("CN_S_STATUS", "报废"));
lstLocation = MongoDBSingleton.Instance.Find(query, "TN_AB_STOCK_LOCATION");
return lstLocation;
}
#region 根据库区编码获得该库区下所有的货位,针对货位有效,站点无效
///
/// 根据库区编码获得该库区下所有的货位
///
///
///
public List GetLocationByAreaCode(string areaCode)
{
var query = Query.And(Query.EQ("CN_S_AREA_CODE", areaCode), Query.NE("CN_S_STATUS", "报废"));
//var query = Query.And(Query.EQ("CN_S_AREA_CODE", areaCode),Query.EQ("CN_S_AREA_CODE", areaCode), Query.NE("CN_S_STATUS", "报废"));
List lstLocation = MongoDBSingleton.Instance.Find(query, "TN_AB_STOCK_LOCATION");
//List lstStruct = GetStructList(areaCode);
//if (lstStruct != null && lstStruct.Count > 0)
//{
// //获得仓库编号
// string stockCode = lstStruct[0].CN_S_STOCK_CODE;
// //获得排列表
// var listRow = lstStruct.ConvertAll(x => x.CN_S_ROW);
// //作为查询条件
// var query = Query.And(Query.EQ("CN_S_STOCK_CODE", stockCode), Query.NE("CN_S_STATUS", "报废"), Query.In("CN_S_ROW", listRow));
// lstLocation = MongoDBSingleton.Instance.Find(oquery, "TN_AB_STOCK_LOCATION");
//}
return lstLocation;
}
#endregion
#region 根据库区编码获得该库区下所有的货位,针对货位有效,站点无效
///
/// 根据库区编码获得该库区下所有的货位
///
///
///
public List GetLocationByAreaCode(string areaCode,string CN_S_TYPE)
{
var query = Query.And(Query.EQ("CN_S_AREA_CODE", areaCode), Query.EQ("CN_S_TYPE", CN_S_TYPE), Query.NE("CN_S_STATUS", "报废"));
List lstLocation = MongoDBSingleton.Instance.Find(query, "TN_AB_STOCK_LOCATION");
//List lstStruct = GetStructList(areaCode);
//if (lstStruct != null && lstStruct.Count > 0)
//{
// //获得仓库编号
// string stockCode = lstStruct[0].CN_S_STOCK_CODE;
// //获得排列表
// var listRow = lstStruct.ConvertAll(x => x.CN_S_ROW);
// //作为查询条件
// var query = Query.And(Query.EQ("CN_S_STOCK_CODE", stockCode), Query.NE("CN_S_STATUS", "报废"), Query.In("CN_S_ROW", listRow));
// lstLocation = MongoDBSingleton.Instance.Find(query, "TN_AB_STOCK_LOCATION");
//}
return lstLocation;
}
#endregion
#region 更新货位表中的入库任务数量
///
/// 根据库区编码获得该库区下所有的货位
///
///
///
public bool UpdateLocationTaskQty(string locationCode, int CN_N_INTASK_QTY)
{
bool result = false;
var query = Query.EQ("CN_S_LOCATION_CODE", locationCode);
IMongoUpdate update = Update.Set("CN_N_INTASK_QTY", CN_N_INTASK_QTY);
result = MongoDBSingleton.Instance.Update(query, update, "TN_AB_STOCK_LOCATION", UpdateFlags.Multi);
return result;
}
#endregion
#region 查询mongo
public List GetItemList(string itemcode, int pageIndex, int pageSize)
{
var query = Query.And(Query.EQ("CN_S_ITEM_CODE", itemcode));
//SortByDocument sortBy = new SortByDocument();
//List lstStruct = MongoDBSingleton.Instance.Find(query, pageIndex, pageSize, sortBy, "TN_AB_ITEM");
List lstStruct = MongoDBSingleton.Instance.Find(query, "TN_AB_ITEM");
return lstStruct;
}
#endregion
}
}