Parcourir la source

MES接口异常处理,定时删除设备状态表

mengshunguo il y a 2 semaines
Parent
commit
a11e5c5918
1 fichiers modifiés avec 21 ajouts et 12 suppressions
  1. 21 12
      SCADA_DAQ/Customer/Machines/RFIDBindingMachine.cs

+ 21 - 12
SCADA_DAQ/Customer/Machines/RFIDBindingMachine.cs

@@ -652,10 +652,29 @@ namespace SCADA_DAQ.Customer.Machines
                             RunTimeStr = $"{points.Count} S",
                         };
 
-                        if (rfidInfo.Barcode != null && rfidInfo.Barcode != "" && product.ProcessDatas.Count > 0 &&
+                        Env.DAL.Insert(product);
+                        foreach (var item in points)
+                        {
+                            item.ReportId = product.ID;
+                        }
+                        Env.DAL.Insert(points);
+
+                        Log.Info($"RFID{uid},产品条码{rfidInfo.Barcode},收到{product?.ProcessDatas?.Count}");
+                        TestFinish?.Invoke(this, new TestFinishEventArgs() { Product = product });
+
+                        if (rfidInfo.Barcode != null && rfidInfo.Barcode != "" && product.ProcessDatas.Count > 0 && CustomerEnv.MESAPITokenExpired > DateTime.Now &&
                             CustomerEnv.MESServerConnectStatus && CustomerEnv.MESAPIToken != null && CustomerEnv.CustomerConfig.SetPower.MESUpload)
                         {
-                            var result = CustomerEnv.MESUploadProductData(product);
+                            MESResultMsg result;
+                            try
+                            {
+                                result = CustomerEnv.MESUploadProductData(product);
+                            }
+                            catch (Exception)
+                            {
+
+                                throw;
+                            }
                             if (result.IsError)
                             {
                                 Log.Info($"产品{product.Barcode}过程数据上传MES失败,报错信息:{result.Message}");
@@ -666,16 +685,6 @@ namespace SCADA_DAQ.Customer.Machines
                                 Log.Info($"产品{product.Barcode}过程数据上传成功");
                             }
                         }
-
-                        Env.DAL.Insert(product);
-                        foreach (var item in points)
-                        {
-                            item.ReportId = product.ID;
-                        }
-                        Env.DAL.Insert(points);
-
-                        Log.Info($"RFID{uid},产品条码{rfidInfo.Barcode},收到{product?.ProcessDatas?.Count}");
-                        TestFinish?.Invoke(this, new TestFinishEventArgs() { Product = product });
                     }
                 }
                 else