From 3ce6c91e5325d0067596b5a571a4faa74d067289 Mon Sep 17 00:00:00 2001
From: kazelee <1847801760@qq.com>
Date: 星期一, 07 七月 2025 16:48:07 +0800
Subject: [PATCH] 修复满箱下线入库相关问题,优化日志和测试接口

---
 util/Settings.cs |  147 +++++++++++++++++++++++++-----------------------
 1 files changed, 76 insertions(+), 71 deletions(-)

diff --git a/util/Settings.cs b/util/Settings.cs
index aee5018..1a2f598 100644
--- a/util/Settings.cs
+++ b/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,32 +12,23 @@
     {
         public static string WebApiUrl { get; set; }
         public static string NdcApiUrl { get; set; }
-        public static string SqlServer { get; set; }
-        public static string TcpServerIp { get; set; }
+        public static string ErpApiUrl { get; set; } // ERP 鍙嶉鎺ュ彛URL
+
         public static int TcpServerPort { get; set; }
-        public static List<Config.Area> Areas { get; set; }
-        public static List<Config.Task> Tasks { get; set; }
-        public static List<Config.ProductionLine> ProductionLines { get; set; }
+        public static Config.ErpRoute ErpRoute { get; set; }
 
-        /// <summary>
-        /// 搴撳尯瀛楀吀锛堝姞杞藉悗灏变笉鍙橈級
-        /// </summary>
-        public static Dictionary<string, List<string>> AreaMap { get; set; } = new Dictionary<string, List<string>>();
+        public static string SqlServer { 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>();
 
-        /// <summary>
-        /// 浠诲姟瀛楀吀锛堝姞杞藉悗灏变笉鍙橈級
-        /// </summary>
-        public static Dictionary<string, Config.Task> TaskMap { get; set; } = new Dictionary<string, Config.Task>();
+        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();
-
-            // 閽堝 Tasks 杩涜杞崲
-            LoadTasks();
         }
 
         private static void LoadJson() {
@@ -52,13 +45,24 @@
 
                 WebApiUrl = root.WebApiUrl;
                 NdcApiUrl = root.NdcApiUrl;
+                ErpApiUrl = root.ErpApiUrl;
+                ErpRoute = root.ErpRoute;
+                TcpServerPort= root.TcpServerPort;
                 SqlServer = root.SqlServer;
-                TcpServerIp = root.TcpServerIp;
-                TcpServerPort = root.TcpServerPort;
-                Areas = root.Areas;
-                Tasks = root.Tasks;
+                //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));
+                    }
+                }
             }   
             catch (FileNotFoundException) {
                 LogHelper.Info("JSON 鏂囦欢鏈壘鍒�);
@@ -72,25 +76,26 @@
             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++) {
+            //    var line = ProductionLines[i];
+            //    // 閫氳繃OnLoc OffLoc鎵惧埌AGVsite鐒跺悗鍐欏叆瀛楀吀
+            //}
         }
 
-        private static void LoadTasks() {
-            foreach (var task in Tasks) {
-                TaskMap.Add(task.Name, task);
-            }
+        public static Config.TaskInfo GetTaskInfo(ETask eTask) {
+            return TaskInfos[(int)eTask];
         }
     }
 
-    public class Config {
+    // [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 ErpRoute {
+            public string CreateTaskReturn { get; set; }
+            public string PickUpReturn { get; set; }
         }
 
         public class ProductionLine {
@@ -106,53 +111,53 @@
         public class Root {
             public string WebApiUrl { get; set; }
             public string NdcApiUrl { get; set; }
-            public string SqlServer { get; set; }
-            public string TcpServerIp { get; set; }
+            public string ErpApiUrl { get; set; }
             public int TcpServerPort { get; set; }
-            public List<Area> Areas { get; set; }
-            public List<Task> Tasks { get; set; }
+            public ErpRoute ErpRoute { get; set; }
+            public string SqlServer { get; set; }
+            public List<TaskInfo> TaskInfos { get; set; }
             public List<ProductionLine> ProductionLines { get; set; }
         }
 
-        public class Task {
-            public string Name { 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 鍖呰鍖�= "鍖呰鍖�;
-        public const string 鎿嶄綔鍖�= "鎿嶄綔鍖�;
-
-        public const string 绌烘墭瀛樻斁鍖�= "绌烘墭瀛樻斁鍖�;
-
-        public const string 璐ф灦鍖�= "璐ф灦鍖�;
-        public const string 绌虹瀛樻斁鍖�= "绌虹瀛樻斁鍖�;
-        public const string 婊℃墭瀛樻斁鍖�= "婊℃墭瀛樻斁鍖�;
-        public const string 婊$瀛樻斁鍖�= "婊$瀛樻斁鍖�;
-
-        public const string 浜哄伐_AGV鎺ラ┏鍖�= "浜哄伐-AGV鎺ラ┏鍖�;
-        public const string 绌烘墭鐩樻帴椹冲尯 = "绌烘墭鐩樻帴椹冲尯";
-        public const string 绌虹鎺ラ┏鍖�= "绌虹鎺ラ┏鍖�;
+    public enum ETask {
+        M婊℃墭涓嬬嚎鍏ュ簱,
+        M婊$涓嬬嚎鍏ュ簱,
+        C鎴愬搧鑳跺嚭搴�
+        K绌烘墭涓婄嚎鍑哄簱,
+        K绌虹涓婄嚎鍑哄簱,
+        K绌烘墭鍏ュ簱,
+        K绌虹鍏ュ簱,
+        C鎶芥鍑哄簱,
+        C鎶芥鍚堟牸鍥炲簱,
+        C鎶芥涓嶅悎鏍肩Щ搴�
+        W灏炬枡鍥炲簱,
+        Y绉诲簱,
     }
 
-    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 static class ETaskExtensions {
+        public static string Name(this ETask eTask) {
+            return Settings.TaskInfos[(int)eTask].TaskName;
+        }
 
+        public static Config.TaskInfo Info(this ETask eTask) {
+            return Settings.TaskInfos[(int)eTask];
+        }
+
+        public static List<string> StartAreas(this ETask eTask) {
+            return Settings.TaskInfos[(int)(eTask)].StartAreas;
+        }
+
+        public static List<string> EndAreas(this ETask eTask) {
+            return Settings.TaskInfos[((int)eTask)].EndAreas;
+        }
     }
-
 }

--
Gitblit v1.9.1