| | |
| | | public static string SqlServer { get; set; } |
| | | public static string TcpServerIp { get; set; } |
| | | public static int TcpServerPort { get; set; } |
| | | public static List<Config.Area> Areas { get; set; } = new List<Config.Area>(); |
| | | public static List<Config.ProductionLine> ProductionLines { get; set; } = new List<Config.ProductionLine>(); |
| | | public static List<Config.ProdAgvSite> ProdAgvSites { get; set; } = new List<Config.ProdAgvSite>(); |
| | | /// <summary> |
| | | /// 库区字典(加载后就不变) |
| | | /// </summary> |
| | | public static Dictionary<string, List<string>> AreaMap { get; set; } = new Dictionary<string, List<string>>(); |
| | | |
| | | public static Dictionary<string, int> AgvSite_ProdLineCodeMap { get; set; } = new Dictionary<string, int>(); |
| | | public static List<Config.TaskInfo> TaskInfos { get; set; } = new List<Config.TaskInfo> { }; |
| | | |
| | | public static Dictionary<string, int> LocProdIdMap { get; set; } = new Dictionary<string, int> { }; |
| | | |
| | | public static void Init() { |
| | | // 加载配置文件 |
| | | LoadJson(); |
| | | |
| | | // 针对 Areas 进行转换:将 Config 的 List 加载到 Dict 中 |
| | | LoadAreas(); |
| | | } |
| | | |
| | | private static void LoadJson() { |
| | |
| | | SqlServer = root.SqlServer; |
| | | TcpServerIp = root.TcpServerIp; |
| | | TcpServerPort = root.TcpServerPort; |
| | | Areas = root.Areas; |
| | | ProductionLines = root.ProductionLines; |
| | | TaskInfos = root.TaskInfos; |
| | | |
| | | ProdAgvSites = root.ProdAgvSite; |
| | | foreach (var item in ProdAgvSites) { |
| | | AgvSite_ProdLineCodeMap.Add(item.Code, item.ProdId); |
| | | for (var i = 0; i < ProductionLines.Count; i++) { |
| | | foreach (var onLoc in ProductionLines[i].OnLoc) { |
| | | LocProdIdMap.Add(onLoc, int.Parse(ProductionLines[i].Id)); |
| | | } |
| | | foreach (var offLoc in ProductionLines[i].OffLoc) { |
| | | LocProdIdMap.Add(offLoc, int.Parse(ProductionLines[i].Id)); |
| | | } |
| | | } |
| | | |
| | | } |
| | | catch (FileNotFoundException) { |
| | | LogHelper.Info("JSON 文件未找到"); |
| | |
| | | LogHelper.Info("加载配置文件信息 完成"); |
| | | } |
| | | |
| | | private static void LoadAreas() { |
| | | foreach (var area in Areas) { |
| | | AreaMap.Add(area.Name, area.Codes); |
| | | } |
| | | } |
| | | |
| | | private static void LoadProdLines() { |
| | | //var db = new SqlHelper<object>().GetInstance(); |
| | | //for (int i = 0; i < ProductionLines.Count; i++) { |
| | |
| | | //} |
| | | } |
| | | |
| | | public static Config.TaskInfo GetTaskInfo(ETask eTask) { |
| | | return TaskInfos[(int)eTask]; |
| | | } |
| | | } |
| | | |
| | | // [Convert JSON to C# Classes Online - Json2CSharp Toolkit](https://json2csharp.com/) |
| | |
| | | public class Config { |
| | | |
| | | // Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse); |
| | | public class Area { |
| | | public string Name { get; set; } |
| | | public List<string> Codes { get; set; } |
| | | } |
| | | |
| | | public class ProdAgvSite { |
| | | public string Code { get; set; } |
| | | public int ProdId { get; set; } |
| | | } |
| | | |
| | | public class ProductionLine { |
| | | public string Id { get; set; } |
| | | public string Name { get; set; } |
| | |
| | | public string SqlServer { get; set; } |
| | | public string TcpServerIp { get; set; } |
| | | public int TcpServerPort { get; set; } |
| | | public List<Area> Areas { get; set; } |
| | | |
| | | public List<TaskInfo> TaskInfos { get; set; } |
| | | public List<ProductionLine> ProductionLines { get; set; } |
| | | public List<ProdAgvSite> ProdAgvSite { get; set; } |
| | | } |
| | | |
| | | public class TaskInfo { |
| | | public string TaskName { get; set; } |
| | | public List<string> StartAreas { get; set; } |
| | | public List<string> EndAreas { get; set; } |
| | | public List<string> EndAreas_Pallet { get; set; } |
| | | public List<string> EndAreas_Goodpack { get; set; } |
| | | } |
| | | } |
| | | |
| | | |
| | | public class AreaName { |
| | | public const string B包装区 = "包装区"; |
| | | public const string K空箱操作区 = "空箱操作区"; |
| | | public const string M满箱操作区 = "满箱操作区"; |
| | | |
| | | public const string K空托存放区 = "空托存放区"; |
| | | public const string K空箱货架区 = "空箱货架区"; |
| | | public const string M满托货架区 = "满托货架区"; |
| | | public const string M满箱货架区 = "满箱货架区"; |
| | | |
| | | public const string C抽检区 = "抽检区"; |
| | | public const string C抽检异常区 = "抽检异常区"; |
| | | |
| | | public const string K空托入库接驳区 = "空托入库接驳区"; |
| | | public const string K空箱入库接驳区 = "空箱入库接驳区"; |
| | | |
| | | public const string Q汽车出库区 = "汽车出库区"; |
| | | public const string H火车出库区 = "火车出库区"; |
| | | public const string Q汽车备货区 = "汽车备货区"; |
| | | public const string H火车备货区 = "火车备货区"; |
| | | public enum ETask { |
| | | M满托下线入库, |
| | | M满箱下线入库, |
| | | C成品胶出库, |
| | | K空托上线出库, |
| | | K空箱上线出库, |
| | | K空托入库, |
| | | K空箱入库, |
| | | C抽检出库, |
| | | C抽检合格回库, |
| | | C抽检不合格移库, |
| | | W尾料回库, |
| | | Y移库, |
| | | } |
| | | |
| | | public class TaskName { |
| | | public const string H好运箱_满箱下线入库 = "好运箱-满箱下线入库"; |
| | | public const string H好运箱_空箱上线 = "好运箱-空箱上线"; |
| | | public const string H好运箱_空箱入库 = "好运箱-空箱入库"; |
| | | |
| | | public const string C成品胶出库 = "成品胶出库"; |
| | | |
| | | public const string T托盘_满托下线入库 = "托盘-满托下线入库"; |
| | | public const string T托盘_空托上线 = "托盘-空托上线"; |
| | | public const string T托盘_空托入库 = "托盘-空托入库"; |
| | | |
| | | public const string C抽检_不合格移库 = "抽检-不合格移库"; |
| | | public const string C抽检_出库 = "抽检-出库"; |
| | | public const string C抽检_合格回库 = "抽检-合格回库"; |
| | | |
| | | public const string Y移库 = "移库"; |
| | | public const string W尾箱回库 = "尾箱回库"; |
| | | public static class ETaskExtensions { |
| | | public static string Name(this ETask eTask) { |
| | | return Settings.TaskInfos[(int)eTask].TaskName; |
| | | } |
| | | } |
| | | |
| | | } |