Parcourir la source

修改上传mes逻辑只上传单条峰值功率

mengshunguo il y a 2 semaines
Parent
commit
b5b0aca8ec

+ 41 - 20
SCADA_DAQ/Customer/CustomerEnv_MES.cs

@@ -24,26 +24,47 @@ namespace SCADA_DAQ.Customer
         {
             var MesUploadData = new MESUploadData();
             var url = $"{CustomerConfig.MESInfo.MesDataUrl}";
-            for (int i = 0; i < productData.ProcessDatas.Count; i++)
+            //for (int i = 0; i < productData.ProcessDatas.Count; i++) ///每一秒的数据进行上传
+            //{
+            //    var result = "FAIL";
+            //    var value = new List<ProductProcessData>();
+            //    if (productData.ProcessDatas[i].Power >= CustomerConfig.SetPower.MinPower && productData.ProcessDatas[i].Power <= CustomerConfig.SetPower.MaxPower)
+            //    {
+            //        result = "PASS";
+            //    }
+            //    for (int j = 0; j < 3; j++)
+            //    {
+            //        value.Add(SplitSecondData(productData.ProcessDatas[i], j, result));
+            //    }
+            //    MesUploadData.DETAIL.Add(new ProductData
+            //    {
+            //        stepNum = (i + 1).ToString(),
+            //        stepResult = result,
+            //        Args = value
+            //    });
+            //}
+            
+            //只上传单条峰值功率数据
+            var value = productData.ProcessDatas.Max(i=>i.Power);
+            var result = "FAIL";
+            string errCode = "0625";
+            if(value >= CustomerConfig.SetPower.MinPower && value <= CustomerConfig.SetPower.MaxPower)
             {
-                var result = "FAIL";
-                var value = new List<ProductProcessData>();
-                if (productData.ProcessDatas[i].Power >= CustomerConfig.SetPower.MinPower && productData.ProcessDatas[i].Power <= CustomerConfig.SetPower.MaxPower)
-                {
-                    result = "PASS";
-                }
-                for (int j = 0; j < 3; j++)
-                {
-                    value.Add(SplitSecondData(productData.ProcessDatas[i], j, result));
-                }
-                MesUploadData.DETAIL.Add(new ProductData
-                {
-                    stepNum = (i + 1).ToString(),
-                    stepResult = result,
-                    Args = value
-                });
+                result = "PASS";
+                errCode = "";
             }
-
+            MesUploadData.DETAIL.Add(new ProductData
+            {
+                stepNum = "1",
+                stepResult = result,
+                errCode = errCode,
+                Args = new List<ProductProcessData> { new ProductProcessData {
+                    Comment = "功率",
+                    Result = result,
+                    Value = Math.Round(value,2),
+                    UOM = "W"
+                }}         
+            });
             MesUploadData.DATATIME_ACQUISITION = productData.CreateTime;
             MesUploadData.TEST_STATUS = productData.TestResult == SCADA.CommonLib.TestResult.OK ? "PASS" : "FAIL";
             MesUploadData.BarCode = productData.Barcode;
@@ -227,12 +248,12 @@ namespace SCADA_DAQ.Customer
 
         public string stepResult { get; set; }
 
-        public string errCode { get; set; } = "";
+        public string errCode { get; set; }
 
         /// <summary>
         /// 产品测试过程数据明细
         /// </summary>
-        public List<ProductProcessData> Args { get; set; } = new List<ProductProcessData>();
+        public List<ProductProcessData> Args { get; set; }
     }
 
     public class ProductProcessData

+ 6 - 9
SCADA_DAQ/Customer/Machines/RFIDBindingMachine.cs

@@ -608,16 +608,13 @@ namespace SCADA_DAQ.Customer.Machines
                     {
                         var points = new List<ProcessData>();
                         data = data.Skip(6).Take(data.Count - 8).ToList();
-                        if (data.Count >= 90 && !CustomerEnv.CustomerConfig.SetPower.IsSimulationDta)
+                        for (int i = 0; i < data.Count; i += 6)
                         {
-                            for (int i = 0; i < data.Count; i += 6)
-                            {
-                                var model = new ProcessData();
-                                model.DataDecode(data.ToArray(), i);
-                                points.Add(model);
-                            }
+                            var model = new ProcessData();
+                            model.DataDecode(data.ToArray(), i);
+                            points.Add(model);
                         }
-                        else
+                        if (points.Count <= 90 && CustomerEnv.CustomerConfig.SetPower.IsSimulationDta)
                         {
                             points = ProcessData.SimulationData();
                         }
@@ -649,7 +646,7 @@ namespace SCADA_DAQ.Customer.Machines
                             RunTimeStr = $"{points.Count} S",
                         };
 
-                        if (rfidInfo.Barcode != null && rfidInfo.Barcode != "" &&
+                        if (rfidInfo.Barcode != null && rfidInfo.Barcode != "" && product.ProcessDatas.Count > 0 &&
                             CustomerEnv.MESServerConnectStatus && CustomerEnv.MESAPIToken != null && CustomerEnv.CustomerConfig.SetPower.MESUpload)
                         {
                             var result = CustomerEnv.MESUploadProductData(product);