Browse Source

添加慧眼获取数据接口

callm 2 months ago
parent
commit
893b3d1d0e
1 changed files with 104 additions and 5 deletions
  1. 104 5
      UAS_MES_HYSX/PublicMethod/HttpServer.cs

+ 104 - 5
UAS_MES_HYSX/PublicMethod/HttpServer.cs

@@ -1,5 +1,7 @@
 using System;
 using System.Collections.Generic;
+using System.Data;
+using System.Dynamic;
 using System.Linq;
 using System.Security.Cryptography;
 using System.Text;
@@ -58,6 +60,7 @@ namespace UAS_MES_NEW.PublicMethod
         [JsonProperty("bindList")]
         public List<BindItem> BindList { get; set; }
     }
+
     class HttpServer
     {
         static DataHelper dh = new DataHelper();
@@ -77,9 +80,10 @@ namespace UAS_MES_NEW.PublicMethod
                 return builder.ToString().ToUpper();
             }
         }
+
         public static void SendBoxData(string iBox)
         {
-            string sn = dh.getFieldDataByCondition("", "", "").ToString();
+            string sn = dh.getFieldDataByCondition("packagedetail", "replace(wm_concat(pd_barcode),',','-')", "pd_outboxcode='" + iBox + "'").ToString();
             var root = new RootObject
             {
                 ProductModuleType = "整机",
@@ -92,18 +96,113 @@ namespace UAS_MES_NEW.PublicMethod
                 BindList = new List<BindItem>()
             };
 
-
             root.BindList.Add(new BindItem
             {
                 BindKey = "cartonSn",
-                BindValue = "4Y12R93C0001",
+                BindValue = iBox,
                 KeyType = "macbox",
                 KeyValue = sn,
                 HashType = "SHA256",
                 HashKey = ComputeSha256Hash(sn)
-            }); ;
-
+            });
+            DataTable dt = (DataTable)dh.ExecuteSql("select pd_barcode from packagedetail pd_outboxcode='" + iBox + "'", "select");
+            for (int i = 0; i < dt.Rows.Count; i++)
+            {
+                root.BindList.Add(new BindItem
+                {
+                    BindKey = "mac",
+                    BindValue = dt.Rows[i]["pd_barcode"].ToString(),
+                    KeyType = "EN",
+                    KeyValue = "4Y12R9300001",
+                    HashType = "NON-HASH",
+                    HashKey = "4Y12R9300001"
+                });
+                root.BindList.Add(new BindItem
+                {
+                    BindKey = "mac",
+                    BindValue = dt.Rows[i]["pd_barcode"].ToString(),
+                    KeyType = "电源条码",
+                    KeyValue = "1U1Y2505100013640",
+                    HashType = "NON-HASH",
+                    HashKey = "1U1Y2505100013640"
+                });
+                root.BindList.Add(new BindItem
+                {
+                    BindKey = "mac",
+                    BindValue = dt.Rows[i]["pd_barcode"].ToString(),
+                    KeyType = "JY-License",
+                    KeyValue = "Qk1K4rmuowTDl+NEtSIeHx1td6Tzzm0wDrw/AMCvJ6mrXQ5wsSgoxia+T5Cj+uH4xrGUrjGrZvh/WUQN88iDrPO7kuTA0mvo/Ay+AsFJYnn00JQYQkN9ul+a+Qh0EPBqCVa4ikllHcD1Pqq4Eubs6XXNFhKOtK7F7FMotfGzzAVg7RhKVoVRVFcK6ubSVWXW+SnGx5muH+WZPaiHLjt+kxBR8tZJuBl1LQvMWP74JSWKkcFWwcWlARnCJePvRTvKTDd5e7q9rpBpAc7Z79XYQ6Fs4eXM44O6/hA88YW/BK0TZq3AaaMxH8BpJnwZt4lIyuqXispeaB2eieFBR0JwWg==",
+                    HashType = "SHA256",
+                    HashKey = ComputeSha256Hash(sn),
+                }); ;
+            }
             string json = JsonConvert.SerializeObject(root, Formatting.Indented);
+            Console.WriteLine(json);
+        }
+
+        public static void GetOutBoxInfo(string iBox)
+        {
+            dynamic obj = new ExpandoObject();
+            obj.request = "Q_wai_xiang";
+            obj.packing_num = 20;
+            obj.User = "mes";
+            obj.po_sn = "250908001001";
+            obj.password = "258456";
+            obj.tool_name = "zte";
+            obj.noType = 0;
+
+            var expandoDict = obj as IDictionary<string, object>;
+            DataTable dt = (DataTable)dh.ExecuteSql("select pd_barcode from packagedetail where pd_outboxcode='" + iBox + "'", "select");
+            for (int i = 0; i < dt.Rows.Count; i++)
+            {
+                string enNoKey = $"en_no{i}";
+                string enNoValue = dt.Rows[i]["pd_barcode"].ToString();
+                expandoDict[enNoKey] = enNoValue;
+            }
+
+            string json = JsonConvert.SerializeObject(obj, Formatting.Indented);
+            Console.WriteLine(json);
+        }
+
+        public static void GetPalletInfo(string iBox)
+        {
+            dynamic obj = new ExpandoObject();
+            obj.request = "pallet";
+            obj.packing_num = 20;
+            obj.User = "mes";
+            obj.po_sn = "250908001001";
+            obj.password = "258456";
+            obj.tool_name = "zte";
+
+            var expandoDict = obj as IDictionary<string, object>;
+            DataTable dt = (DataTable)dh.ExecuteSql("select pa_outboxcode from package where  pa_mothercode='" + iBox + "'", "select");
+            for (int i = 0; i < dt.Rows.Count; i++)
+            {
+                string enNoKey = $"big_box_no{i}";
+                string enNoValue = dt.Rows[i]["pa_outboxcode"].ToString();
+                expandoDict[enNoKey] = enNoValue;
+            }
+            string json = JsonConvert.SerializeObject(obj, Formatting.Indented);
+            Console.WriteLine(json);
+        }
+
+        public static void GetEN(string iSN)
+        {
+            dynamic obj = new ExpandoObject();
+            obj.tool_name = "zte";
+            obj.request = "Storage2";
+            obj.User = "mes";
+            obj.password = "258456";
+            obj.po_sn = "";
+            obj.wholeDeviceCode = "";
+            obj.reg_code = "6400-6134-3346-8166";
+            obj.prefix_en_no = "4N6FH4T";
+            obj.prefix_big_box = "";
+            obj.packing_num = "";
+            obj.isn = iSN;
+
+            string json = JsonConvert.SerializeObject(obj, Formatting.Indented);
+            Console.WriteLine(json);
         }
     }
 }