فهرست منبع

添加慧眼中兴接口对接

callm 2 ماه پیش
والد
کامیت
b51c6b4ff2
2فایلهای تغییر یافته به همراه110 افزوده شده و 0 حذف شده
  1. 109 0
      UAS_MES_HYSX/PublicMethod/HttpServer.cs
  2. 1 0
      UAS_MES_HYSX/UAS_MES_HYSX.csproj

+ 109 - 0
UAS_MES_HYSX/PublicMethod/HttpServer.cs

@@ -0,0 +1,109 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using UAS_MES_NEW.DataOperate;
+
+namespace UAS_MES_NEW.PublicMethod
+{
+
+
+    public class BindItem
+    {
+        [JsonProperty("bindKey")]
+        public string BindKey { get; set; }
+
+        [JsonProperty("bindValue")]
+        public string BindValue { get; set; }
+
+        [JsonProperty("keyType")]
+        public string KeyType { get; set; }
+
+        [JsonProperty("keyValue")]
+        public string KeyValue { get; set; }
+
+        [JsonProperty("hashType")]
+        public string HashType { get; set; }
+
+        [JsonProperty("hashKey")]
+        public string HashKey { get; set; }
+    }
+
+    public class RootObject
+    {
+        [JsonProperty("productModuleType")]
+        public string ProductModuleType { get; set; }
+
+        [JsonProperty("productMainClass")]
+        public string ProductMainClass { get; set; }
+
+        [JsonProperty("productMediumClass")]
+        public string ProductMediumClass { get; set; }
+
+        [JsonProperty("productSubClass")]
+        public string ProductSubClass { get; set; }
+
+        [JsonProperty("task")]
+        public string Task { get; set; }
+
+        [JsonProperty("processType")]
+        public string ProcessType { get; set; }
+
+        [JsonProperty("userId")]
+        public string UserId { get; set; }
+
+        [JsonProperty("bindList")]
+        public List<BindItem> BindList { get; set; }
+    }
+    class HttpServer
+    {
+        static DataHelper dh = new DataHelper();
+        static string ComputeSha256Hash(string input)
+        {
+            using (SHA256 sha256 = SHA256.Create())
+            {
+                byte[] bytes = Encoding.UTF8.GetBytes(input);
+                byte[] hashBytes = sha256.ComputeHash(bytes);
+
+                StringBuilder builder = new StringBuilder();
+                for (int i = 0; i < hashBytes.Length; i++)
+                {
+                    builder.Append(hashBytes[i].ToString("x2"));
+                }
+
+                return builder.ToString().ToUpper();
+            }
+        }
+        public static void SendBoxData(string iBox)
+        {
+            string sn = dh.getFieldDataByCondition("", "", "").ToString();
+            var root = new RootObject
+            {
+                ProductModuleType = "整机",
+                ProductMainClass = "固网_CPE",
+                ProductMediumClass = "CPE",
+                ProductSubClass = "ZXSLC SC50L",
+                Task = "2025070006",
+                ProcessType = "生产过程",
+                UserId = "邓帝森",
+                BindList = new List<BindItem>()
+            };
+
+
+            root.BindList.Add(new BindItem
+            {
+                BindKey = "cartonSn",
+                BindValue = "4Y12R93C0001",
+                KeyType = "macbox",
+                KeyValue = sn,
+                HashType = "SHA256",
+                HashKey = ComputeSha256Hash(sn)
+            }); ;
+
+            string json = JsonConvert.SerializeObject(root, Formatting.Indented);
+        }
+    }
+}

+ 1 - 0
UAS_MES_HYSX/UAS_MES_HYSX.csproj

@@ -1455,6 +1455,7 @@
     <Compile Include="PublicMethod\ExceptionHandler.cs" />
     <Compile Include="PublicMethod\ftpOperater.cs" />
     <Compile Include="PublicMethod\GlobalEventsHandler.cs" />
+    <Compile Include="PublicMethod\HttpServer.cs" />
     <Compile Include="PublicMethod\LogicHandler.cs" />
     <Compile Include="PublicMethod\LogManager.cs" />
     <Compile Include="PublicMethod\LogStringBuilder.cs" />