|
|
@@ -334,6 +334,28 @@ namespace UAS_MES_NEW.PublicMethod
|
|
|
Console.WriteLine(json);
|
|
|
}
|
|
|
|
|
|
+ private string HandleWebException(WebException ex)
|
|
|
+ {
|
|
|
+ if (ex.Response != null)
|
|
|
+ {
|
|
|
+ using (HttpWebResponse response = (HttpWebResponse)ex.Response)
|
|
|
+ using (Stream stream = response.GetResponseStream())
|
|
|
+ using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
|
|
|
+ {
|
|
|
+ string errorResponse = reader.ReadToEnd();
|
|
|
+ Console.WriteLine($"HTTP错误状态码: {(int)response.StatusCode} {response.StatusCode}");
|
|
|
+ Console.WriteLine($"错误响应: {errorResponse}");
|
|
|
+ return errorResponse;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ string errorMsg = $"网络错误: {ex.Message}";
|
|
|
+ Console.WriteLine(errorMsg);
|
|
|
+ return errorMsg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//发送外箱号数据,打印前获取
|
|
|
public static void SendBoxData(string iBox)
|
|
|
{
|
|
|
@@ -366,7 +388,7 @@ namespace UAS_MES_NEW.PublicMethod
|
|
|
HashType = "SHA256",
|
|
|
HashKey = ComputeSha256Hash(sn)
|
|
|
});
|
|
|
- dt = (DataTable)dh.ExecuteSql("select pd_barcode from packagedetail pd_outboxcode='" + iBox + "'", "select");
|
|
|
+ dt = (DataTable)dh.ExecuteSql("select pd_barcode from packagedetail where pd_outboxcode='" + iBox + "'", "select");
|
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
{
|
|
|
root.BindList.Add(new BindItem
|
|
|
@@ -395,11 +417,35 @@ namespace UAS_MES_NEW.PublicMethod
|
|
|
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);
|
|
|
- string returnstr = ToServerReq(json);
|
|
|
- Console.WriteLine(json);
|
|
|
+ string url = "https://apigwfw.zte.com.cn:2443/mdsdev/api/mds-web-outservice/v1/api/rest/mds/saveDistinctSnBatch";
|
|
|
+ try
|
|
|
+ {
|
|
|
+ // 忽略SSL证书验证
|
|
|
+ ServicePointManager.ServerCertificateValidationCallback =
|
|
|
+ (sender, certificate, chain, sslPolicyErrors) => true;
|
|
|
+ ServicePointManager.Expect100Continue = false;
|
|
|
+ using (WebClient client = new WebClient())
|
|
|
+ {
|
|
|
+ // 设置请求头
|
|
|
+ client.Headers.Add("appcode", "91678314583d4c2bbf185bc5573ac73d");
|
|
|
+ client.Headers.Add("Content-Type", "application/json; charset=utf-8");
|
|
|
+ client.Encoding = Encoding.UTF8;
|
|
|
+ // 发送POST请求
|
|
|
+ string response = client.UploadString(url, "POST", json);
|
|
|
+ Console.WriteLine($"请求成功!");
|
|
|
+ Console.WriteLine($"响应内容: {response}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ Console.WriteLine($"发生错误: {ex.Message}");
|
|
|
+ throw;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//获取外箱号信息
|
|
|
@@ -407,12 +453,12 @@ namespace UAS_MES_NEW.PublicMethod
|
|
|
{
|
|
|
dynamic obj = new ExpandoObject();
|
|
|
var expandoDict = obj as IDictionary<string, object>;
|
|
|
- DataTable dt = (DataTable)dh.ExecuteSql("select pd_barcode,pd_makecode from packagedetail where pd_outboxcode='" + iBox + "'", "select");
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql("select pd_barcode,pd_makecode,ZD_DEV_EN_NO from packagedetail left join ZTEDATA on zd_makecode=pd_makecode and pd_barcode=zd_sn where pd_outboxcode='" + iBox + "'", "select");
|
|
|
string makecode = "";
|
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
{
|
|
|
string enNoKey = $"en_no{i}";
|
|
|
- string enNoValue = dt.Rows[i]["pd_barcode"].ToString();
|
|
|
+ string enNoValue = dt.Rows[i]["ZD_DEV_EN_NO"].ToString();
|
|
|
expandoDict[enNoKey] = enNoValue;
|
|
|
makecode = dt.Rows[i]["pd_makecode"].ToString();
|
|
|
}
|