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;
|
|
/// <summary>
|
/// 获取单例的方法
|
/// </summary>
|
/// <returns>单例实体</returns>
|
public static WareHouseService GetInstance()
|
{
|
if (Instance == null)
|
{
|
lock (Lock)
|
{
|
if (Instance == null)
|
{
|
Instance = new WareHouseService();
|
}
|
}
|
}
|
return Instance;
|
}
|
/// <summary>
|
/// 获取辅助不实际使用的库位号
|
/// </summary>
|
/// <param name="layer"></param>
|
/// <returns></returns>
|
public List<string> 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<string>();
|
}
|
}
|
}
|
|
|
|
/// <summary>
|
/// 获取所有库位号
|
/// </summary>
|
/// <param name="layer"></param>
|
/// <returns></returns>
|
public List<string> GetALlPlace()
|
{
|
using (DbModelCore context = new DbModelCore())
|
{
|
try
|
{
|
string sql = "select code from [dbo].[BASEPlace] where typeid={0} ";
|
return context.Database.SqlQuery<string>(sql, (int)EPlaceType.普通库位).ToList();
|
}
|
catch (Exception ex)
|
{
|
LogTextHelper.WriteLine("WareHouseService", "GetALlPlace", ex.ToString());
|
return new List<string>();
|
}
|
}
|
}
|
|
/// <summary>
|
/// 获取有物料的库位名称
|
/// </summary>
|
/// <returns></returns>
|
public List<string> 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<string>(sql, (int)EPlaceType.普通库位).ToList();
|
}
|
catch (Exception ex)
|
{
|
LogTextHelper.WriteLine("WareHouseService", "GetItemInPlace", ex.ToString());
|
return new List<string>();
|
}
|
}
|
}
|
|
/// <summary>
|
/// 获取锁定库位
|
/// </summary>
|
/// <returns></returns>
|
public List<string> GetLockedPlace()
|
{
|
using (DbModelCore context = new DbModelCore())
|
{
|
try
|
{
|
string sql = "select code from [dbo].[BASEPlace] where islock = 1 and typeid={0}";
|
return context.Database.SqlQuery<string>(sql, (int)EPlaceType.普通库位).ToList();
|
}
|
catch (Exception ex)
|
{
|
LogTextHelper.WriteLine("WareHouseService", "GetLockedPlace", ex.ToString());
|
return new List<string>();
|
}
|
}
|
}
|
|
/// <summary>
|
/// 获取空库位库位号
|
/// </summary>
|
/// <returns></returns>
|
public List<string> 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<string>(sql, (int)EPlaceType.普通库位).ToList();
|
}
|
catch (Exception ex)
|
{
|
LogTextHelper.WriteLine("WareHouseService", "GetEmptyInPlace", ex.ToString());
|
return new List<string>();
|
}
|
}
|
}
|
|
}
|
}
|