From 2ca90a404fa1ab94eb6374f50c6ddd47a2b7f0e6 Mon Sep 17 00:00:00 2001
From: kazelee <1847801760@qq.com>
Date: 星期四, 31 七月 2025 17:23:57 +0800
Subject: [PATCH] 删除有问题的TCP旧代码, 优化事务处理和ERP数据模型

---
 util/Settings.cs |   54 ++++++++++++++++++++++++------------------------------
 1 files changed, 24 insertions(+), 30 deletions(-)

diff --git a/util/Settings.cs b/util/Settings.cs
index 1a2f598..a27282b 100644
--- a/util/Settings.cs
+++ b/util/Settings.cs
@@ -7,9 +7,8 @@
 using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
 
-namespace HH.WCS.Mobox3.DSZSH {
-    public class Settings
-    {
+namespace HH.WCS.Mobox3.DSZSH.util {
+    public class Settings {
         public static string WebApiUrl { get; set; }
         public static string NdcApiUrl { get; set; }
         public static string ErpApiUrl { get; set; } // ERP 鍙嶉鎺ュ彛URL
@@ -17,7 +16,8 @@
         public static int TcpServerPort { get; set; }
         public static Config.ErpRoute ErpRoute { get; set; }
 
-        public static string SqlServer { get; set; }
+        public static SqlSugar.DbType DbType { get; set; } = SqlSugar.DbType.SqlServer;
+        public static string DbConn { get; set; }
         //public static string TcpServerIp { get; set; }
         //public static int TcpServerPort { get; set; }
         public static List<Config.ProductionLine> ProductionLines { get; set; } = new List<Config.ProductionLine>();
@@ -29,10 +29,12 @@
         public static void Init() {
             // 鍔犺浇閰嶇疆鏂囦欢
             LoadJson();
+
+            LoadProdLines();
         }
 
         private static void LoadJson() {
-            LogHelper.Info("鍔犺浇閰嶇疆鏂囦欢淇℃伅 寮�");
+            LogHelper.Info("鍔犺浇閰嶇疆鏂囦欢淇℃伅:寮�!!");
             // JSON 鏂囦欢璺緞
             string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "./config/config.json");
 
@@ -43,49 +45,41 @@
                 // 鍙嶅簭鍒楀寲涓�Config 瀵硅薄
                 var root = JsonConvert.DeserializeObject<Config.Root>(jsonContent);
 
+                #region Config.Root 璧嬪�瀛楁閮ㄥ垎
                 WebApiUrl = root.WebApiUrl;
                 NdcApiUrl = root.NdcApiUrl;
                 ErpApiUrl = root.ErpApiUrl;
                 ErpRoute = root.ErpRoute;
-                TcpServerPort= root.TcpServerPort;
-                SqlServer = root.SqlServer;
+                TcpServerPort = root.TcpServerPort;
+                DbConn = root.SqlServer;
                 //TcpServerIp = root.TcpServerIp;
                 //TcpServerPort = root.TcpServerPort;
                 ProductionLines = root.ProductionLines;
                 TaskInfos = root.TaskInfos;
-
-                for (var i = 0; i < ProductionLines.Count; i++) {
-                    if (ProductionLines[i].OnLoc == null) continue;
-                    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));
-                    }
-                }
+                #endregion
             }   
             catch (FileNotFoundException) {
-                LogHelper.Info("JSON 鏂囦欢鏈壘鍒�);
+                LogHelper.Info("JSON鏂囦欢鏈壘鍒�!", "Exception");
             }
             catch (JsonException ex) {
-                LogHelper.Info($"JSON 瑙f瀽閿欒: {ex.Message}");
+                LogHelper.Info($"JSON瑙f瀽閿欒!!Error:{ex.Message}\n\n{ex.StackTrace}\n", "Exception");
             }
             catch (Exception ex) {
-                LogHelper.Info($"鍙戠敓閿欒: {ex.Message}");
+                LogHelper.InfoEx(ex, "Settings:");
             }
-            LogHelper.Info("鍔犺浇閰嶇疆鏂囦欢淇℃伅 瀹屾垚");
+            LogHelper.Info("鍔犺浇閰嶇疆鏂囦欢淇℃伅:瀹屾垚!!");
         }
 
         private static void LoadProdLines() {
-            //var db = new SqlHelper<object>().GetInstance();
-            //for (int  i = 0;  i < ProductionLines.Count;  i++) {
-            //    var line = ProductionLines[i];
-            //    // 閫氳繃OnLoc OffLoc鎵惧埌AGVsite鐒跺悗鍐欏叆瀛楀吀
-            //}
-        }
-
-        public static Config.TaskInfo GetTaskInfo(ETask eTask) {
-            return TaskInfos[(int)eTask];
+            for (var i = 0; i < ProductionLines.Count; i++) {
+                if (ProductionLines[i].OnLoc == null) continue;
+                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));
+                }
+            }
         }
     }
 

--
Gitblit v1.9.1