From 16d2162a833cebeae72c363962917bb9da8145ef Mon Sep 17 00:00:00 2001 From: 杨前锦 <1010338399@qq.com> Date: 星期五, 06 六月 2025 17:34:47 +0800 Subject: [PATCH] 福建佳通优化 --- HH.WCS.Mobox3/HH.WCS.Mobox3.FJJT/util/Settings.cs | 176 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 176 insertions(+), 0 deletions(-) diff --git a/HH.WCS.Mobox3/HH.WCS.Mobox3.FJJT/util/Settings.cs b/HH.WCS.Mobox3/HH.WCS.Mobox3.FJJT/util/Settings.cs new file mode 100644 index 0000000..7520040 --- /dev/null +++ b/HH.WCS.Mobox3/HH.WCS.Mobox3.FJJT/util/Settings.cs @@ -0,0 +1,176 @@ +锘縰sing Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Linq; +using static HH.WCS.Mobox3.FJJT.util.Settings; + +namespace HH.WCS.Mobox3.FJJT.util { + public class Settings { + public static string HostToAgvServerUrl { get; set; } + public static string HASeverUrl { get; set; } + public static string SqlServer { get; set; } + public static string SqlServer1 { get; set; } + public static string OracleServer { get; set; } + public static List<deviceInfo> deviceInfos { get; set; } + public static List<LinePlcInfo> linePlcInfo { get; set; } + public static List<PlcValue> plcValue { get; set; } + public static List<AreaProperty> areaPropertyList { get; set; } + public static List<AreaRelevance> areaRelevanceList { get; set; } + public static int port { get; set; } + public static string WHCode { get; set; } + public static string FacCode { get; set; } + public static string NDCApiUrl { get; set; } + + + + public static void Init() { + LogHelper.Info("鍔犺浇閰嶇疆鏂囦欢淇℃伅 寮�"); + try { + var jsonFile = System.AppDomain.CurrentDomain.BaseDirectory + "/config/config.json"; + using (System.IO.StreamReader file = System.IO.File.OpenText(jsonFile)) { + using (JsonTextReader reader = new JsonTextReader(file)) { + JObject o = (JObject)JToken.ReadFrom(reader); + foreach (Newtonsoft.Json.Linq.JProperty keyValue in o.Properties()) { + Console.WriteLine(keyValue.Name); + if (keyValue.Name == "HostToAgvServerUrl") { + HostToAgvServerUrl = keyValue.Value.ToString(); + } + if (keyValue.Name == "NDCApiUrl") { + NDCApiUrl = keyValue.Value.ToString(); + } + if (keyValue.Name == "HASeverUrl") { + HASeverUrl = keyValue.Value.ToString(); + } + if (keyValue.Name == "SqlServer") { + SqlServer = keyValue.Value.ToString(); + } + if (keyValue.Name == "SqlServer1") { + SqlServer1 = keyValue.Value.ToString(); + } + if (keyValue.Name == "OracleServer") + { + OracleServer = keyValue.Value.ToString(); + } + if (keyValue.Name == "WHCode") { + WHCode = keyValue.Value.ToString(); + } + if (keyValue.Name == "FacCode") { + FacCode = keyValue.Value.ToString(); + } + if (keyValue.Name == "ApiPort") { + port = int.Parse(keyValue.Value.ToString()); + } + if (keyValue.Name == "DeviceInfo") { + deviceInfos = JsonConvert.DeserializeObject<List<deviceInfo>>(keyValue.Value.ToString()); + } + if (keyValue.Name == "linePlcInfo") { + linePlcInfo = JsonConvert.DeserializeObject<List<LinePlcInfo>>(keyValue.Value.ToString()); + } + if (keyValue.Name == "PlcValue") { + plcValue = JsonConvert.DeserializeObject<List<PlcValue>>(keyValue.Value.ToString()); + } + if (keyValue.Name == "AreaProperty") + { + areaPropertyList = JsonConvert.DeserializeObject<List<AreaProperty>>(keyValue.Value.ToString()); + } + if (keyValue.Name == "AreaRelevance") + { + areaRelevanceList = JsonConvert.DeserializeObject<List<AreaRelevance>>(keyValue.Value.ToString()); + } + } + } + } + LogHelper.Info("鍔犺浇閰嶇疆鏂囦欢淇℃伅 瀹屾垚"); + } + catch (Exception ex) { + LogHelper.Error("鍔犺浇閰嶇疆鏂囦欢澶辫触锛� + ex.Message, ex); + } + } + + /// <summary> + /// 鏌ヨ涓嶅悓瀹瑰櫒鐨勫瓨鍌ㄥ簱鍖�+ /// </summary> + /// <param name="cntrType"></param> + /// <returns></returns> + public static List<string> getCntrAreaList(int cntrType) { + return areaPropertyList.Where(a => a.cntrType.Contains(cntrType)).Select(a => a.areaCode).ToList(); + } + + /// <summary> + /// 鏌ヨ瀛樺偍搴撳尯 + /// </summary> + /// <param name="areaCode"></param> + /// <returns></returns> + public static List<string> getRelAreaCodes(string areaCode) + { + List<string> areaCodes = new List<string>(); + var areaRelevance = areaRelevanceList.Where(a => a.areaCode == areaCode).FirstOrDefault(); + if (areaRelevance != null) + { + areaCodes = areaRelevance.relAreaCode; + } + return areaCodes; + } + + public class AreaRelevance + { + public string areaCode { get; set; } + public List<string> relAreaCode { get; set; } + } + + public class AreaProperty + { + public string areaName { get; set; } + public string areaCode { get; set; } + public List<int> cntrType { get; set; } // 瀹瑰櫒绫诲瀷 1.鑳庨潰锛�.鑳庝晶锛�.鍐呰‖锛�.甯樺竷锛�.鐜甫锛�.鍐犲甫锛�.閽㈠寘 + } + + public class deviceInfo { + public string address { get; set; } + public string deviceName { get; set; } + public string deviceNo { get; set; } + public int enable { get; set; } + } + public class TableName { + public string name { get; set; } + public string code { get; set; } + } + + public class LinePlcInfo { + public string code { get; set; } + public string location { get; set; } + public string deviceNo { get; set; } + public string address { get; set; } + public int writeAddr { get; set; } + public int readAddr { get; set; } + public string[] useAddrNo { get; set; } + public string inLoca { get; set; } + public string outLoca { get; set; } + public int enable { get; set; } + } + public class PlcValue { + public string address { get; set; } + public List<S7Model> read { get; set; } + public List<S7Model> write { get; set; } + } + public class S7Model { + /// <summary> + /// 鍋忕Щ閲�+ /// </summary> + public int addr { get; set; } + /// <summary> + /// 绫诲瀷 + /// </summary> + public string type { get; set; } + /// <summary> + /// 闀垮害 + /// </summary> + public int length { get; set; } + /// <summary> + /// 鍊�+ /// </summary> + public string value { get; set; } + } + } +} -- Gitblit v1.9.1