using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
|
using HH.WCS.Mobox3.DSZSH.models;
|
using HH.WCS.Mobox3.DSZSH.util;
|
|
using Newtonsoft.Json;
|
|
using SqlSugar;
|
|
namespace HH.WCS.Mobox3.DSZSH.wms {
|
/// <summary>
|
/// 货位帮助类(包含货位-容器关系的处理)
|
/// </summary>
|
public class LocationHelper
|
{
|
private static Dictionary<string, TN_Location> _locationDict = null;
|
|
static LocationHelper()
|
{
|
try
|
{
|
//初始化Location加入到字典缓存
|
_locationDict = new Dictionary<string, TN_Location>();
|
var list = GetAllLocList();
|
if (list.Count > 0)
|
{
|
list.ForEach(a =>
|
{
|
if (!_locationDict.ContainsKey(a.S_CODE))
|
{
|
_locationDict.Add(a.S_CODE, a);
|
}
|
});
|
}
|
//初始化LocationExt加入到集合缓存
|
//LocationExts = new Dictionary<string, LocationExt>();
|
//var exts = GetAllLocExtList();
|
//if (exts.Count > 0) {
|
// exts.ForEach(a => {
|
// LocationExts.Add($"{a.S_LOC_CODE.Trim()}_{a.S_PICKUP_POINT.Trim()}", a);
|
// });
|
//}
|
}
|
catch (Exception ex)
|
{
|
Console.WriteLine(ex.Message);
|
}
|
}
|
|
/// <summary>
|
/// 获取所有货位信息
|
/// </summary>
|
/// <returns></returns>
|
internal static List<TN_Location> GetAllLocList()
|
{
|
var db = new SqlHelper<object>().GetInstance();
|
return db.Queryable<TN_Location>().ToList();
|
}
|
|
|
internal static TN_Location GetLocation(string loc)
|
{
|
if (_locationDict.Keys.Contains(loc))
|
{
|
return _locationDict[loc.Trim()];
|
}
|
return null;
|
}
|
|
//public static bool IsStartLocFound(string startLocCode, ref )
|
|
/// <summary>
|
/// 获取货位站点信息
|
/// </summary>
|
/// <param name="loc"></param>
|
/// <param name="isEmpty">是否属于人工空托区到空托缓存库区</param>
|
/// <returns></returns>
|
internal static string GetAgvSite(string loc, bool isEmpty = false) {
|
var site = "0";
|
if (_locationDict.Keys.Contains(loc.Trim()) && !isEmpty) {
|
var Location = _locationDict[loc.Trim()];
|
site = Location.S_AGV_SITE;
|
}
|
else {
|
var Location = GetLoc(loc.Trim());
|
if (Location != null) {
|
site = Location.S_AGV_SITE;
|
|
if (isEmpty) {
|
if (Location.N_CURRENT_NUM == 0) {
|
site = Location.S_AGV_SITE;
|
}
|
}
|
}
|
}
|
return site;
|
}
|
|
internal static TN_Location GetLoc(string code) {
|
var db = new SqlHelper<object>().GetInstance();
|
return db.Queryable<TN_Location>().Where(a => a.S_CODE.Trim() == code).First();
|
}
|
|
|
}
|
}
|