瀏覽代碼

日志函数、遗漏bug修改

WIN-GH9CEESPLTB\Administrator 1 月之前
父節點
當前提交
e6d451ad72

+ 2 - 1
MainForm/ClassFile/XiaomiAPI_IOT/Extend/XiaomiMqttClient_StationInputBegin.cs

@@ -1,6 +1,7 @@
 using BZFAStandardLib;
 using Newtonsoft.Json;
 using System;
+using System.IO;
 using System.Threading.Tasks;
 
 namespace MainForm.ClassFile.XiaomiAPI
@@ -61,7 +62,7 @@ namespace MainForm.ClassFile.XiaomiAPI
             else
                 resultStr = XiaomiMqttResponse_ErrCode.ERR_UNKOWN.ToString();
             string logPath = GlobalContext.MqttInputBeginDir + "beatType" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
-            FileOperate.NewTxtFile(logPath, DateTime.Now+"===>MQTT【节拍日志】提交:" + msg + "\r\n==>提交结果:" + resultStr + "");
+            File.WriteAllText(logPath, "\r\n" + DateTime.Now + "===>MQTT【节拍日志】提交:" + msg + "\r\n==>提交结果:" + resultStr + "");
             return (result, resultStr);
         }
 

+ 30 - 14
MainForm/FaForm/Form_Home.cs

@@ -54,6 +54,7 @@ using System.Drawing.Imaging;
 using System.Drawing;
 using ICSharpCode.SharpZipLib.Zip;
 using System.Text.RegularExpressions;
+using System.Text;
 
 /*
  * 注:本源码对外提供,所以有些地方使用中文命名方法及变量
@@ -1979,13 +1980,19 @@ namespace MainForm
                     }
 
                     //OP30站读txt数据
-                    if (stationNameStr.Contains("OP30"))
+                    if (stationNameStr.Contains("OP31") || stationNameStr.Contains("OP32"))
                     {
                         string path = "";
                         if (direction == "Left")
-                            path = GlobalContext.MESLaserLPath;
-                        else
-                            path = GlobalContext.MESLaserRPath;
+                        {
+                            string pathStr = GlobalContext.MESLaserLPath;
+                            path = DecFileName(pathStr);
+                        }
+                        else {
+                            string pathStr = GlobalContext.MESLaserRPath;
+                            path = DecFileName(pathStr);
+                        }
+
                         //字典存储数据
                         Dictionary<string, string> compensationDict = GetLastLineCompensation(path, direction, sn);
                         foreach (var kvp in compensationDict)
@@ -2322,6 +2329,17 @@ namespace MainForm
         //    } 
         //}
 
+        /// <summary>
+        ///字符串中文乱码解决
+        /// </summary>
+        /// <param name="str"></param>
+        /// <returns></returns>
+        public static string DecFileName(string str)
+        {
+            Encoding utf8 = Encoding.GetEncoding("gbk");
+            byte[] btArr = utf8.GetBytes(str);
+            return Encoding.UTF8.GetString(btArr);
+        }
 
         private void CollectAndProcessDataLeft(AtlasScrew atlasScrew, string sn, string direction)
         {
@@ -5189,8 +5207,8 @@ namespace MainForm
                         {
                             //测试数据
                             //stPLC_MesData.mesCommFrmPLC.cmd = 2;
-                            stPLC_MesData.BarcodeSet.strCarrierBarcode = "A235461";
-                            stPLC_MesData.BarcodeSet.strPCBBarcode = "A1507V000239";
+                            //stPLC_MesData.BarcodeSet.strCarrierBarcode = "A235461";
+                            //stPLC_MesData.BarcodeSet.strPCBBarcode = "A1507V000239";
                             //stPLC_MesData.iotData.beatAction = 1;
                             //stPLC_MesData.iotData.beatAction = 2;
                             //stPLC_MesData.iotData.beatAction = 3;
@@ -5420,16 +5438,16 @@ namespace MainForm
                 stopwatch2.Stop();
 
                 //指令执行结果 1:OK   110:失败
-                byte mesResultFrmWeb = (byte)(result == 1 ? 1 : 110);
+                byte mesResultFrmWeb = (byte)(result == 1 ? 2 : 120);
                 if (mesResultFrmWeb == 1)
                 {
                     if (a1Result == 1)
                     {
-                        mesResultFrmWeb = 1;
+                        mesResultFrmWeb = 2;
                     }
                     else
                     {
-                        mesResultFrmWeb = 110;
+                        mesResultFrmWeb = 120;
                         AddMessage(LogType.Info, stationNameStr + "_进站检测结果:FAIL");
                     }
                 }
@@ -5451,7 +5469,7 @@ namespace MainForm
                 CommandFromPLC resultToPlC = new CommandFromPLC();
                 resultToPlC.cmd = 0;
                 resultToPlC.cmdParam = 0; //指令参数
-                resultToPlC.cmdResult = 110;
+                resultToPlC.cmdResult = 120;
                 WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, resultToPlC);
             }
 
@@ -5562,10 +5580,7 @@ namespace MainForm
 
 
                 string paramJson = JsonConvert.SerializeObject(stPLC_MesData.mesData);
-                int result1 = SwitctProcessData(stationNameStr, items, equipmentCode, processItem
-                    , workorder_code, batch_num, mtltmrk, plcDate_YMD, supplierCode, sn, pass, CarrierBarcode, "1",
-                    MachineId, StationId, PartBarcode, paramJson);
-
+                int result1 = 0;
                 byte mesResultFrmWeb = 0;
                 if (stPLC_MesData.mesCommFrmPLC.cmdParam == 2)
                 {
@@ -6255,6 +6270,7 @@ namespace MainForm
                             CarrierBarcode_Right = stPLC_MesData.Right.BarcodeSet.strCarrierBarcode;
                             // 节拍
                             s7PLCData["a7OEEType"] = stPLC_MesData.Left.iotData.beatAction;
+                            s7PLCData["a7OEEType_left"] = stPLC_MesData.Left .iotData.beatAction;
                             s7PLCData["a7OEEType_right"] = stPLC_MesData.Right.iotData.beatAction;
 
                             //报警信息