kazelee
2025-05-29 e2303b1125817cb7887e36d5905c8f1661d685a3
util/Settings.cs
@@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.IO;
using HH.WCS.Mobox3.DSZSH.util;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@@ -10,22 +12,17 @@
    {
        public static string WebApiUrl { get; set; }
        public static string NdcApiUrl { get; set; }
        public static string ErpApiUrl { get; set; } // ERP 反馈接口URL
        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.Task> Tasks { get; set; } = new List<Config.Task>();
        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>>();
        /// <summary>
        /// 任务字典(加载后就不变)
        /// </summary>
        public static Dictionary<string, Config.Task> TaskMap { get; set; } = new Dictionary<string, Config.Task>();
        public static Dictionary<string, int> AgvSite_ProdLineCodeMap { get; set; } = new Dictionary<string, int>();
@@ -35,9 +32,6 @@
            // 针对 Areas 进行转换:将 Config 的 List 加载到 Dict 中
            LoadAreas();
            // 针对 Tasks 进行转换
            LoadTasks();
        }
        private static void LoadJson() {
@@ -54,12 +48,17 @@
                WebApiUrl = root.WebApiUrl;
                NdcApiUrl = root.NdcApiUrl;
                ErpApiUrl = root.ErpApiUrl;
                SqlServer = root.SqlServer;
                TcpServerIp = root.TcpServerIp;
                TcpServerPort = root.TcpServerPort;
                Areas = root.Areas;
                Tasks = root.Tasks;
                ProductionLines = root.ProductionLines;
                ProdAgvSites = root.ProdAgvSite;
                foreach (var item in ProdAgvSites) {
                    AgvSite_ProdLineCodeMap.Add(item.Code, item.ProdId);
                }
            }   
            catch (FileNotFoundException) {
@@ -80,19 +79,17 @@
            }
        }
        private static void LoadTasks() {
            foreach (var task in Tasks) {
                TaskMap.Add(task.Name, task);
            }
        }
        private static void LoadProdLines() {
            foreach (var prod in ProductionLines) {
            }
            //var db = new SqlHelper<object>().GetInstance();
            //for (int  i = 0;  i < ProductionLines.Count;  i++) {
            //    var line = ProductionLines[i];
            //    // 通过OnLoc OffLoc找到AGVsite然后写入字典
            //}
        }
    }
    // [Convert JSON to C# Classes Online - Json2CSharp Toolkit](https://json2csharp.com/)
    public class Config {
@@ -100,6 +97,11 @@
        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 {
@@ -115,53 +117,57 @@
        public class Root {
            public string WebApiUrl { get; set; }
            public string NdcApiUrl { get; set; }
            public string ErpApiUrl { 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<Task> Tasks { get; set; }
            public List<ProductionLine> ProductionLines { get; set; }
        }
        public class Task {
            public string Name { get; set; }
            public List<string> StartAreas { get; set; }
            public List<string> EndAreas { get; set; }
            public List<ProductionLine> ProductionLines { get; set; }
            public List<ProdAgvSite> ProdAgvSite { get; set; }
        }
    }
    public class AreaName {
        public const string 包装区 = "包装区";
        public const string 操作区 = "操作区";
        public const string B包装区 = "包装区";
        public const string K空箱操作区 = "空箱操作区";
        public const string M满箱操作区 = "满箱操作区";
        public const string 空托存放区 = "空托存放区";
        public const string K空托存放区 = "空托存放区";
        public const string K空箱货架区 = "空箱货架区";
        public const string M满托货架区 = "满托货架区";
        public const string M满箱货架区 = "满箱货架区";
        public const string 货架区 = "货架区";
        public const string 空箱存放区 = "空箱存放区";
        public const string 满托存放区 = "满托存放区";
        public const string 满箱存放区 = "满箱存放区";
        public const string C抽检区 = "抽检区";
        public const string C抽检异常区 = "抽检异常区";
        public const string 人工_AGV接驳区 = "人工-AGV接驳区";
        public const string 空托盘接驳区 = "空托盘接驳区";
        public const string 空箱接驳区 = "空箱接驳区";
        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 class TaskName {
        public const string 好运箱_满箱下线入库 = "好运箱-满箱下线入库";
        public const string 好运箱_空箱上线 = "好运箱-空箱上线";
        public const string 好运箱_空箱入库 = "好运箱-空箱入库";
        public const string 好运箱_空箱绑定 = "好运箱-空箱绑定";
        public const string 成品胶出库 = "成品胶出库";
        public const string 托盘_满托下线入库 = "托盘-满托下线入库";
        public const string 托盘_空托上线 = "托盘-空托上线";
        public const string 托盘_空托入库 = "托盘-空托入库";
        public const string 托盘_空托绑定 = "托盘-空托绑定";
        public const string 抽检_不合格移库 = "抽检-不合格移库";
        public const string 抽检_出库 = "抽检-出库";
        public const string 抽检_合格回库 = "抽检-合格回库";
        public const string 移库 = "移库";
        public const string 尾箱回库 = "尾箱回库";
        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尾箱回库 = "尾箱回库";
    }
}