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 { /// /// 货位帮助类(包含货位-容器关系的处理) /// public class LocationHelper { private static Dictionary _locationDict = null; static LocationHelper() { try { //初始化Location加入到字典缓存 _locationDict = new Dictionary(); 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(); //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); } } /// /// 获取所有货位信息 /// /// internal static List GetAllLocList() { var db = new SqlHelper().GetInstance(); return db.Queryable().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 ) /// /// 获取货位站点信息 /// /// /// 是否属于人工空托区到空托缓存库区 /// 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().GetInstance(); return db.Queryable().Where(a => a.S_CODE.Trim() == code).First(); } } }