using iWareCommon.Utils;
using iWareDataCore.BASE.EnumType;
using iWareDataCore.ORM;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace iWareDataCore.BASE.Service
{
public class WareHouseService
{
private static object Lock = new Object();
private static WareHouseService Instance = null;
///
/// 获取单例的方法
///
/// 单例实体
public static WareHouseService GetInstance()
{
if (Instance == null)
{
lock (Lock)
{
if (Instance == null)
{
Instance = new WareHouseService();
}
}
}
return Instance;
}
///
/// 获取辅助不实际使用的库位号
///
///
///
public List GetALlNoUsePlace()
{
using (DbModelCore context = new DbModelCore())
{
try
{
return context.BASEPlaces.Where(x =>x.typeid == 17).Select(x=>x.code).ToList();
}
catch (Exception ex)
{
LogTextHelper.WriteLine("WareHouseService", "GetALlPlace", ex.ToString());
return new List();
}
}
}
///
/// 获取所有库位号
///
///
///
public List GetALlPlace()
{
using (DbModelCore context = new DbModelCore())
{
try
{
string sql = "select code from [dbo].[BASEPlace] where typeid={0} ";
return context.Database.SqlQuery(sql, (int)EPlaceType.普通库位).ToList();
}
catch (Exception ex)
{
LogTextHelper.WriteLine("WareHouseService", "GetALlPlace", ex.ToString());
return new List();
}
}
}
///
/// 获取有物料的库位名称
///
///
public List GetItemInPlace()
{
using (DbModelCore context = new DbModelCore())
{
try
{
string sql = "SELECT code from BASEPlace where id in (select placeid from BASEPlaceMaterial ) and typeid={0} and islock =0 ";
return context.Database.SqlQuery(sql, (int)EPlaceType.普通库位).ToList();
}
catch (Exception ex)
{
LogTextHelper.WriteLine("WareHouseService", "GetItemInPlace", ex.ToString());
return new List();
}
}
}
///
/// 获取锁定库位
///
///
public List GetLockedPlace()
{
using (DbModelCore context = new DbModelCore())
{
try
{
string sql = "select code from [dbo].[BASEPlace] where islock = 1 and typeid={0}";
return context.Database.SqlQuery(sql, (int)EPlaceType.普通库位).ToList();
}
catch (Exception ex)
{
LogTextHelper.WriteLine("WareHouseService", "GetLockedPlace", ex.ToString());
return new List();
}
}
}
///
/// 获取空库位库位号
///
///
public List GetEmptyInPlace()
{
using (DbModelCore context = new DbModelCore())
{
try
{
string sql = " SELECT code from BASEPlace where id not in (select placeid from BASEPlaceMaterial ) and typeid={0}";
return context.Database.SqlQuery(sql, (int)EPlaceType.普通库位).ToList();
}
catch (Exception ex)
{
LogTextHelper.WriteLine("WareHouseService", "GetEmptyInPlace", ex.ToString());
return new List();
}
}
}
}
}