浏览代码

修改标签打印回传中兴参数动态添加

callm 1 月之前
父节点
当前提交
5b4f3f8099
共有 1 个文件被更改,包括 30 次插入27 次删除
  1. 30 27
      UAS_MES_HYSX/PublicMethod/HttpServer.cs

+ 30 - 27
UAS_MES_HYSX/PublicMethod/HttpServer.cs

@@ -360,13 +360,15 @@ namespace UAS_MES_NEW.PublicMethod
         public static void SendBoxData(string iBox)
         {
             string sn = dh.getFieldDataByCondition("packagedetail", "replace(wm_concat(pd_barcode),',','-')", "pd_outboxcode='" + iBox + "'").ToString();
-            DataTable dt = (DataTable)dh.ExecuteSql("select pr_custmachinetype,ms_makecode from makeserial left join product on ms_prodcode=pr_code where ms_outboxcode ='" + iBox + "' order by ms_id desc", "select");
+            DataTable dt = (DataTable)dh.ExecuteSql("select pr_code,pr_custmachinetype,ms_makecode from makeserial left join product on ms_prodcode=pr_code where ms_outboxcode ='" + iBox + "' order by ms_id desc", "select");
             string pr_custmachinetype = "";
             string makecode = "";
+            string pr_code = "";
             if (dt.Rows.Count > 0)
             {
                 pr_custmachinetype = dt.Rows[0]["pr_custmachinetype"].ToString();
                 makecode = dt.Rows[0]["ms_makecode"].ToString();
+                pr_code = dt.Rows[0]["pr_code"].ToString();
             }
             var root = new RootObject
             {
@@ -389,35 +391,36 @@ namespace UAS_MES_NEW.PublicMethod
                 HashKey = ComputeSha256Hash(sn)
             });
             dt = (DataTable)dh.ExecuteSql("select pd_barcode from packagedetail where pd_outboxcode='" + iBox + "'", "select");
+            DataTable dt1 = (DataTable)dh.ExecuteSql("select pid_item,pid_value,pid_valuetype from productitem left join productitemdetail on pid_piid=pi_id where pi_prodcode='" + pr_code + "'", "select");
             for (int i = 0; i < dt.Rows.Count; i++)
             {
-                root.BindList.Add(new BindItem
+                for (int j = 0; j < dt1.Rows.Count; j++)
                 {
-                    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),
-                });
+                    if (dt1.Rows[j]["pid_valuetype"].ToString() == "SHA256")
+                    {
+                        root.BindList.Add(new BindItem
+                        {
+                            BindKey = "mac",
+                            BindValue = dt.Rows[i]["pd_barcode"].ToString(),
+                            KeyType = dt1.Rows[j]["pid_item"].ToString(),
+                            KeyValue = dt1.Rows[j]["pid_item"].ToString(),
+                            HashType = "SHA256",
+                            HashKey = ComputeSha256Hash(sn),
+                        }); ;
+                    }
+                    else
+                    {
+                        root.BindList.Add(new BindItem
+                        {
+                            BindKey = "mac",
+                            BindValue = dt.Rows[i]["pd_barcode"].ToString(),
+                            KeyType = dt1.Rows[j]["pid_item"].ToString(),
+                            KeyValue = dt1.Rows[j]["pid_item"].ToString(),
+                            HashType = "NON-HASH",
+                            HashKey = dt1.Rows[j]["pid_item"].ToString(),
+                        }); ;
+                    }
+                }
             }
             string json = JsonConvert.SerializeObject(root, Formatting.Indented);
             string url = "https://apigwfw.zte.com.cn:2443/mdsdev/api/mds-web-outservice/v1/api/rest/mds/saveDistinctSnBatch";