Browse Source

接口完善

callm 2 tháng trước cách đây
mục cha
commit
1d1314fcc5
1 tập tin đã thay đổi với 39 bổ sung7 xóa
  1. 39 7
      UAS_MES_HYSX/PublicMethod/HttpServer.cs

+ 39 - 7
UAS_MES_HYSX/PublicMethod/HttpServer.cs

@@ -5,11 +5,8 @@ using System.Dynamic;
 using System.Net.Sockets;
 using System.Security.Cryptography;
 using System.Text;
-using HslCommunication;
-using System.Threading;
 using Newtonsoft.Json;
 using UAS_MES_NEW.DataOperate;
-using System.IO;
 
 namespace UAS_MES_NEW.PublicMethod
 {
@@ -62,6 +59,35 @@ namespace UAS_MES_NEW.PublicMethod
         public List<BindItem> BindList { get; set; }
     }
 
+    public class ZteData
+    {
+        public string tool_name { get; set; }
+        public string response { get; set; }
+        public int status { get; set; }
+        public string product_name { get; set; }
+        public string product_mode { get; set; }
+        public string material_code { get; set; }
+        public string batch_no { get; set; }
+        public string production_date { get; set; }
+        public string big_box_no { get; set; }
+        public string box_no { get; set; }
+        public string reserve10 { get; set; }
+        public int packing_num { get; set; }
+        public string soft_version { get; set; }
+        public string hd_version { get; set; }
+        public string voltage { get; set; }
+        public string power { get; set; }
+        public string order_no { get; set; }
+
+        public string[] d_sn { get; set; }
+        public string[] mac_start { get; set; }
+        public string[] mac_end { get; set; }
+        public string[] DeviceId { get; set; }
+        public string[] dev_en_no { get; set; }
+        public string[] reserve3 { get; set; }
+        public string[] reserve4 { get; set; }
+    }
+
     class HttpServer
     {
         static DataHelper dh = new DataHelper();
@@ -81,7 +107,6 @@ namespace UAS_MES_NEW.PublicMethod
                 return builder.ToString().ToUpper();
             }
         }
-
         public static void SendBoxData(string iBox)
         {
             string sn = dh.getFieldDataByCondition("packagedetail", "replace(wm_concat(pd_barcode),',','-')", "pd_outboxcode='" + iBox + "'").ToString();
@@ -137,6 +162,7 @@ namespace UAS_MES_NEW.PublicMethod
                 }); ;
             }
             string json = JsonConvert.SerializeObject(root, Formatting.Indented);
+            string returnstr = SendData(json);
             Console.WriteLine(json);
         }
 
@@ -161,6 +187,9 @@ namespace UAS_MES_NEW.PublicMethod
             }
 
             string json = JsonConvert.SerializeObject(obj, Formatting.Indented);
+            string returnstr = SendData(json);
+            ZteData zteData = JsonConvert.DeserializeObject<ZteData>(returnstr);
+
             Console.WriteLine(json);
         }
 
@@ -183,6 +212,7 @@ namespace UAS_MES_NEW.PublicMethod
                 expandoDict[enNoKey] = enNoValue;
             }
             string json = JsonConvert.SerializeObject(obj, Formatting.Indented);
+            string returnstr = SendData(json);
             Console.WriteLine(json);
         }
 
@@ -202,10 +232,11 @@ namespace UAS_MES_NEW.PublicMethod
             obj.isn = iSN;
 
             string json = JsonConvert.SerializeObject(obj, Formatting.Indented);
+            string returnstr = SendData(json);
             Console.WriteLine(json);
         }
 
-        public static void SendData(string json)
+        public static string SendData(string json)
         {
             string serverIP = "192.168.1.160";
             int port = 21610;
@@ -236,6 +267,7 @@ namespace UAS_MES_NEW.PublicMethod
                 // 关闭流和连接
                 stream.Close();
                 client.Close();
+                return responseMessage;
             }
             catch (SocketException ex)
             {
@@ -245,7 +277,7 @@ namespace UAS_MES_NEW.PublicMethod
             {
                 Console.WriteLine($"错误: {ex.Message}");
             }
-
+            return "";
         }
     }
-}
+}