瀏覽代碼

Merge branch 'master' into dev20250225_5060设备改造

# Conflicts:
#	MainForm/ClassFile/ProjectClass/GlobalContext.cs
#	MainForm/FaForm/Form_Home.cs
WIN-GH9CEESPLTB\Administrator 1 月之前
父節點
當前提交
a917ffaebe

+ 4 - 1
MainForm/ClassFile/Inovance_EIP.cs

@@ -140,7 +140,7 @@ namespace EIP_Protocol
         [MarshalAs(UnmanagedType.I2)]       //节拍返回 1:OK   2:NG   
         public short beatReturn;
 
-        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]   //一个单独的位代表一个报警32*10=320
+        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)]   //一个单独的位代表一个报警32*10=320
         public uint[] fault_codes;
     }
 
@@ -152,6 +152,9 @@ namespace EIP_Protocol
 
         [MarshalAs(UnmanagedType.I4)]
         public int nRemainCount;                             //上盖余料数
+        
+        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
+        public float[] nCeJuData;           //测距
     }
 
     [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 8)]

+ 18 - 1
MainForm/ClassFile/ProjectClass/GlobalContext.cs

@@ -75,6 +75,14 @@ namespace MainForm
         public static string S5_work_station;   // [S5] ⼯站
         public static string S5_device_code;    // [S5] 装备编码
         public static string S5_station;        // [S5] ⼯位Id
+        public static string S6_device_code;    // [S5] 装备编码
+        public static string S6_station;        // [S5] ⼯位Id
+        public static string S7_device_code;    // [S5] 装备编码
+        public static string S7_station;        // [S5] ⼯位Id
+        public static string S8_device_code;    // [S5] 装备编码
+        public static string S8_station;        // [S5] ⼯位Id
+        public static string S9_device_code;    // [S5] 装备编码
+        public static string S9_station;        // [S5] ⼯位Id
 
         // 设备
         //public static string PCAddress="192.168.1.244";
@@ -141,6 +149,9 @@ namespace MainForm
         public static bool IsSendAlarmData;      // 启用上传报警
         public static bool IsUseMESRoute;   // 启用边线MES软件
         public static bool MESIsConnect;  // MES是否正常连接
+        public static string MESLaserLPath;   // 三点激光数据本地存放地址
+        public static string MESLaserRPath;   // 三点激光数据本地存放地址
+
         public static string UpFileUrl;  // 文档库地址
         public static string UpFilePath;  // 本地文件路径
         public static bool IsSendUpFile;    // 启用上传文件
@@ -157,6 +168,8 @@ namespace MainForm
         public static bool IsMqttOperateLog;         // 上传操作记录
         public static bool IsMqttEquiConfig;         // 上传装备配置
         public static bool IsMqttProcConfig;         // 上传⼯艺配置
+        public static string MQTTAppId;            // IOT应用ID
+        public static string MQTTAppPwd;           // IOT登录密码
 
         // IOT-AGV
         public static bool IsUseAGV;  // 是否 启用AGV
@@ -266,6 +279,8 @@ namespace MainForm
                 LineCode = IniFile.INIGetStringValue(FilePath, "Product", "LineCode", ConstLineCode);
                 LineName = IniFile.INIGetStringValue(FilePath, "Product", "LineName", ConstLineName);
                 ProgramName = IniFile.INIGetStringValue(FilePath, "Product", "ProgramName", ConstProgramName);
+                MESLaserLPath = IniFile.INIGetStringValue(FilePath, "MES", "MESLaserLPath", "");
+                MESLaserRPath = IniFile.INIGetStringValue(FilePath, "MES", "MESLaserRPath", "");
 
                 WorkOrderCode = IniFile.INIGetStringValue(FilePath, "Product", "WorkOrderCode", ConstWorkOrderCode);  // 车间订单号
                 BatchNumber = IniFile.INIGetStringValue(FilePath, "Product", "BatchNumber", ConstBatchNumber);        // 批次号(splcode)
@@ -382,7 +397,7 @@ namespace MainForm
                 IsUseMESRoute = bool.Parse(IniFile.INIGetStringValue(FilePath, "MES", "IsUseMESRoute", ConstIsSend));
 
                 // MQTT
-                IsUseIot = bool.Parse(IniFile.INIGetStringValue(FilePath, "MES", "IsUseIot", "false"));
+                IsUseIot = bool.Parse(IniFile.INIGetStringValue(FilePath, "MQTT", "IsUseIot", "false"));
                 MQTTServerHost = IniFile.INIGetStringValue(FilePath, "MQTT", "MQTTServerHost", "127.0.0.1");
                 MQTTServerPort = int.Parse(IniFile.INIGetStringValue(FilePath, "MQTT", "MQTTServerPort", "80"));
                 IsMqttSendProcessData = bool.Parse(IniFile.INIGetStringValue(FilePath, "MQTT", "IsMqttSendProcessData", ConstIsSend));
@@ -393,6 +408,8 @@ namespace MainForm
                 IsMqttOperateLog = bool.Parse(IniFile.INIGetStringValue(FilePath, "MQTT", "IsMqttOperateLog", ConstIsSend));
                 IsMqttEquiConfig = bool.Parse(IniFile.INIGetStringValue(FilePath, "MQTT", "IsMqttEquiConfig", ConstIsSend));
                 IsMqttProcConfig = bool.Parse(IniFile.INIGetStringValue(FilePath, "MQTT", "IsMqttProcConfig", ConstIsSend));
+                MQTTAppId = IniFile.INIGetStringValue(FilePath, "MQTT", "MQTTAppId", "AKPKTSQAS46NKE4NHY");
+                MQTTAppPwd = IniFile.INIGetStringValue(FilePath, "MQTT", "MQTTAppPwd", "pwd");
 
                 // AGV配置
                 IsUseAGV = bool.Parse(IniFile.INIGetStringValue(FilePath, "AGV", "IsUseAGV", "false"));  // 是否 启用AGV

+ 24 - 24
MainForm/FaForm/Form_Home.Designer.cs

@@ -30,10 +30,10 @@
         {
             this.components = new System.ComponentModel.Container();
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form_Home));
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
             this.panel1 = new System.Windows.Forms.Panel();
             this.groupBox3 = new System.Windows.Forms.GroupBox();
             this.txt_CurSupplierCode = new System.Windows.Forms.TextBox();
@@ -571,14 +571,14 @@
             this.systemLog.AllowUserToResizeRows = false;
             this.systemLog.BackgroundColor = System.Drawing.Color.White;
             this.systemLog.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
-            dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
-            dataGridViewCellStyle1.BackColor = System.Drawing.Color.WhiteSmoke;
-            dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
-            dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
-            dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
-            dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
-            this.systemLog.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
+            dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+            dataGridViewCellStyle5.BackColor = System.Drawing.Color.WhiteSmoke;
+            dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            dataGridViewCellStyle5.ForeColor = System.Drawing.SystemColors.WindowText;
+            dataGridViewCellStyle5.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+            dataGridViewCellStyle5.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+            dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
+            this.systemLog.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle5;
             this.systemLog.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
             this.systemLog.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
             this.colDate,
@@ -590,19 +590,19 @@
             this.systemLog.Location = new System.Drawing.Point(3, 32);
             this.systemLog.Name = "systemLog";
             this.systemLog.ReadOnly = true;
-            dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
-            dataGridViewCellStyle3.BackColor = System.Drawing.Color.WhiteSmoke;
-            dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText;
-            dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight;
-            dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
-            dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
-            this.systemLog.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
+            dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+            dataGridViewCellStyle7.BackColor = System.Drawing.Color.WhiteSmoke;
+            dataGridViewCellStyle7.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            dataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.WindowText;
+            dataGridViewCellStyle7.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+            dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+            dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
+            this.systemLog.RowHeadersDefaultCellStyle = dataGridViewCellStyle7;
             this.systemLog.RowHeadersVisible = false;
             this.systemLog.RowHeadersWidth = 51;
             this.systemLog.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
-            dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.systemLog.RowsDefaultCellStyle = dataGridViewCellStyle4;
+            dataGridViewCellStyle8.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.systemLog.RowsDefaultCellStyle = dataGridViewCellStyle8;
             this.systemLog.RowTemplate.Height = 27;
             this.systemLog.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
             this.systemLog.Size = new System.Drawing.Size(1533, 435);
@@ -610,8 +610,8 @@
             // 
             // colDate
             // 
-            dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.colDate.DefaultCellStyle = dataGridViewCellStyle2;
+            dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.colDate.DefaultCellStyle = dataGridViewCellStyle6;
             this.colDate.HeaderText = "日期";
             this.colDate.MinimumWidth = 6;
             this.colDate.Name = "colDate";

+ 212 - 43
MainForm/FaForm/Form_Home.cs

@@ -36,7 +36,7 @@ using Org.BouncyCastle.Asn1.IsisMtt;
 using System.Web.Services.Description;
 using System.Numerics;
 using MathNet.Numerics.RootFinding;
-using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.Tab;
 
 /*
  * 注:本源码对外提供,所以有些地方使用中文命名方法及变量
@@ -283,14 +283,85 @@ namespace MainForm
                     {
                         string addr = GlobalContext.MQTTServerHost;
                         int port = GlobalContext.MQTTServerPort;
-                        int qmttResult = XiaomiMqttClient_Extend.OpenWithMqttServer(addr, port, GlobalContext.MqttServerPath, GlobalContext.MqttServerName);
+                        //生产环境需要修改
+                        int qmttResult = XiaomiMqttClient_Extend.OpenWithMqttServer("127.0.0.1", 6666, GlobalContext.MqttServerPath, GlobalContext.MqttServerName);
                         XiaomiMqttResponse_ErrCode response_ErrCode = (XiaomiMqttResponse_ErrCode)qmttResult;
                         if (response_ErrCode == XiaomiMqttResponse_ErrCode.OK)
                         {
                             picIot.Image = imageListState.Images[1];
                             AddMessage(LogType.Info, "小米IOT MQTT初始连接成功!");
 
-                            XiaomiMqttClient_Extend.SetCallbackWithDataId(CallbackWithDataId);
+                            // 设置回调函数
+                            //XiaomiMqttClient_Extend.SetCallbackWithDataId(CallbackWithDataId);
+                            // 配置参数
+                            XiaomiMqttLoginFunAndParam param = new XiaomiMqttLoginFunAndParam();
+                            // fds
+                            param.parameter.fds.address = "http://file-cm.be.mi.com/file/x5/file/upload/mqtt";
+                            param.parameter.fds.appId = "Auto-Soft";
+                            param.parameter.fds.appKey = "d11ec2b9-0e7a-4086-a80c-a1ec716e0896";
+                            // mes
+                            param.parameter.mes.address = GlobalContext.ServerIp;
+                            param.parameter.mes.appId = GlobalContext.MESAppId;
+                            param.parameter.mes.appKey = GlobalContext.MESAppKey;
+                            // mqtt
+                            param.parameter.mqtt.address = GlobalContext.MQTTServerHost;
+                            param.parameter.mqtt.port = GlobalContext.MQTTServerPort;
+                            param.parameter.mqtt.username = GlobalContext.MQTTAppId;
+                            param.parameter.mqtt.password = GlobalContext.MQTTAppPwd;
+                            // 设备配置
+                            param.parameter.equipment.factoryCode = GlobalContext.Factory_Code;
+                            if (GlobalContext.IsUsePLC1)
+                            {
+                                param.parameter.equipment.deviceCode = GlobalContext.S1_device_code;  // 装备编码
+                                param.parameter.equipment.stationCode = GlobalContext.S1_station;     // ⼯位Id
+                            }
+                            if (GlobalContext.IsUsePLC2)
+                            {
+                                param.parameter.equipment.deviceCode = GlobalContext.S2_device_code;  // 装备编码
+                                param.parameter.equipment.stationCode = GlobalContext.S2_station;     // ⼯位Id
+                            }
+                            if (GlobalContext.IsUsePLC3)
+                            {
+                                param.parameter.equipment.deviceCode = GlobalContext.S3_device_code;  // 装备编码
+                                param.parameter.equipment.stationCode = GlobalContext.S3_station;     // ⼯位Id
+                            }
+                            if (GlobalContext.IsUsePLC4)
+                            {
+                                param.parameter.equipment.deviceCode = GlobalContext.S4_1_device_code;  // 装备编码
+                                param.parameter.equipment.stationCode = GlobalContext.S4_1_station;     // ⼯位Id
+                            }
+                            if (GlobalContext.IsUsePLC5)
+                            {
+                                param.parameter.equipment.deviceCode = GlobalContext.S5_device_code;  // 装备编码
+                                param.parameter.equipment.stationCode = GlobalContext.S5_station;     // ⼯位Id
+                            }
+                            if (GlobalContext.IsUsePLC6)
+                            {
+                                param.parameter.equipment.deviceCode = GlobalContext.S6_device_code;  // 装备编码
+                                param.parameter.equipment.stationCode = GlobalContext.S6_station;     // ⼯位Id
+                            }
+                            if (GlobalContext.IsUsePLC7)
+                            {
+                                param.parameter.equipment.deviceCode = GlobalContext.S7_device_code;  // 装备编码
+                                param.parameter.equipment.stationCode = GlobalContext.S7_station;     // ⼯位Id
+                            }
+                            if (GlobalContext.IsUsePLC8)
+                            {
+                                param.parameter.equipment.deviceCode = GlobalContext.S8_device_code;  // 装备编码
+                                param.parameter.equipment.stationCode = GlobalContext.S8_station;     // ⼯位Id
+                            }
+                            if (GlobalContext.IsUsePLC9)
+                            {
+                                param.parameter.equipment.deviceCode = GlobalContext.S9_device_code;  // 装备编码
+                                param.parameter.equipment.stationCode = GlobalContext.S9_station;     // ⼯位Id
+                            }
+
+                            param.parameter.equipment.project = GlobalContext.Project_Code;
+                            param.parameter.equipment.productMode = "debug";
+                            // 
+                            param.parameter.other.logLevel = 0;
+                            param.parameter.other.LogPath = "D:\\Test";
+                            XiaomiMqttClient_Extend.ParameterConfig(param);
                         }
                         else
                         {
@@ -1097,6 +1168,73 @@ namespace MainForm
             }
         }
 
+
+        public Dictionary<string, string> GetLastLineCompensation(string path,string direction,string sn)
+        {
+            // 创建字典存储补偿点及其对应的值
+            Dictionary<string, string> compensationDict = new Dictionary<string, string>();
+
+            try
+            {
+                //string path = GlobalContext.MESLaserRPath;
+                // 获取当前日期并格式化为 "yyyy-MM-dd" 格式
+                string currentDate = DateTime.Now.ToString("yyyy-MM-dd");
+                string filename = $"Laser-{currentDate}-W0.txt";
+                // 拼接完整路径
+                string fullPath = Path.Combine(path, filename);
+                string lastNonEmptyLine = "";
+
+                // 判断文件是否存在
+                if (File.Exists(fullPath))
+                {
+                    //读取文件内容
+                    string[] lines = File.ReadAllLines(fullPath);
+
+                    // 获取最后一行数据(忽略标题行)
+                    if (lines.Length > 1)
+                    {
+                        string lastLine = "";
+                        for (int i = lines.Length - 1; i > 0; i--)
+                        {
+                            if (!string.IsNullOrEmpty(lines[i]))
+                            {
+                                lastLine = lines[i];
+                                break;
+                            }
+                        }
+
+                        // 将最后一行按逗号分隔
+                        string[] values = lastLine.Split(',');
+                        values[1] = sn;
+
+                        string key = "三点激光_"+ direction; // 构造键名
+                        string value = string.Join(",", values); // 获取值并去除多余空格
+                        compensationDict[key] = value;
+
+                        //// 提取“1点补偿”到“6点补偿”的值
+                        //for (int i = 2; i <= 7 && i < values.Length; i++) // 从索引2开始,最多提取6个值
+                        //{
+                        //    string key = $"{i - 1}点补偿"; // 构造键名
+                        //    string value = values[i].Trim(); // 获取值并去除多余空格
+                        //    compensationDict[key] = value;
+                        //}
+                    }
+                }
+                else
+                {
+                    Console.WriteLine($"文件不存在: {fullPath}");
+                }
+            }
+            catch (Exception ex)
+            {
+                // 捕获异常并输出错误信息
+                Console.WriteLine($"发生错误: {ex.Message}");
+            }
+
+            return compensationDict;
+        }
+
+
         /// <summary>
         /// 调用进站接口并保存进站数据
         /// </summary>
@@ -1143,11 +1281,15 @@ namespace MainForm
                 try
                 {
                     XmMES_StationInResponse response = new XmMES_StationInResponse();
+                    string resultJson = "";
                     string mesRet = string.Empty;
                     int i = 0;
                     while (i < 2)  // 1009会多次尝试上传
                     {
                         response = XiaomiMESHttp_StationInbound.StationIn(inRequest_Body);
+
+                        resultJson = JsonConvert.SerializeObject(response);
+
                         if (response != null && response.header.code == "200")
                             break;
                         else if (!mesRet.Contains("1009"))  // 1009是未知错误
@@ -1157,21 +1299,20 @@ namespace MainForm
 
                         mesRet = $"[{response?.header?.code}]{response?.header?.desc}";
                         // 记录失败原因
-                        OnMessage(LogType.Error, "上传出站数据到MES服务器---失败!正在重新上传!接口报错信息:" + mesRet + "参数:" + json_Body);
+                        OnMessage(LogType.Error, $"上传出站数据到MES服务器---失败!正在重新上传!请求参数:{json_Body},接口报错信息:" + mesRet);
                     }
-
      
                     if (response?.header?.code == "200")
                     {
                         string sql_Upd = stationIn.ToStringUpdateStatusByID(1);
                         string ret_Upd = SQLHelper_New.ExecuteNonQuery(sql_Upd, null);
                         result = ret_Upd == "成功" ? 1 : 6;
-                        AddMessage( LogType.Info, $"【进站数据 SN {stationIn.Sn}】上传MES服务器---成功");
+                        AddMessage( LogType.Info, $"【进站数据 SN {stationIn.Sn}】上传MES服务器---成功,请求参数:{json_Body},返回参数:{resultJson}");
                     }
                     else
                     {
                         result = 5;
-                        AddMessage(LogType.Info, $"【进站数据 SN {stationIn.Sn}】上传MES服务器---失败!接口报错信息:" + mesRet);
+                        AddMessage(LogType.Info, $"【进站数据 SN {stationIn.Sn}】上传MES服务器---失败!请求参数:{json_Body},接口报错信息:" + mesRet);
                     }
                      string sql_response = stationIn.ToStringUpdateStationInReturn_body(JsonConvert.SerializeObject(response));
                      SQLHelper_New.ExecuteNonQuery(sql_response, null);
@@ -1202,10 +1343,10 @@ namespace MainForm
         /// <returns>上传成功时返回1;失败返回0</returns>
         private int SwitctProcessData(string stationNameStr, List<TestItem> items, string equipmentCode, string processItem,
             string workorder_code, string batch_num, string mtltmrk, string proDate,
-            string supplierCode, string sn, bool pass, string vehicleSn, string vehicleSlot, string MachineId, string StationId, string PartBarcode)
+            string supplierCode, string sn, bool pass, string vehicleSn, string vehicleSlot, string MachineId, string StationId, string PartBarcode,string jsonParm, string direction="")
         {
             return SaveProcessDataByDB(stationNameStr, items, equipmentCode, processItem, workorder_code, batch_num, mtltmrk,
-                proDate, supplierCode, sn, pass, vehicleSn, vehicleSlot, MachineId, StationId, PartBarcode);
+                proDate, supplierCode, sn, pass, vehicleSn, vehicleSlot, MachineId, StationId, PartBarcode, jsonParm, direction);
         }
 
         /// <summary>
@@ -1223,7 +1364,7 @@ namespace MainForm
         /// <returns>上传成功时返回1;失败返回0</returns>
         public int SaveProcessDataByDB(string stationNameStr, List<TestItem> items, string equipmentCode,
             string processItem, string workorder_code, string batch_num, string mtltmrk,
-            string proDate, string supplierCode, string sn, bool pass, string vehicleSn, string vehicleSlot, string machineId, string stationId, string partBarcode)
+            string proDate, string supplierCode, string sn, bool pass, string vehicleSn, string vehicleSlot, string machineId, string stationId, string partBarcode,string jsonParm,string direction="")
         {
             int upload = 0;
             int result = 0;
@@ -1273,6 +1414,27 @@ namespace MainForm
                         });  // 设备数据 - 部件码
                     }
 
+                    //OP30站读txt数据
+                    if (stationNameStr.Contains("OP30"))
+                    {
+                        string path = "";
+                        if (direction == "Left")
+                            path = GlobalContext.MESLaserLPath;
+                        else
+                            path= GlobalContext.MESLaserRPath;  
+                        //字典存储数据
+                        Dictionary<string, string> compensationDict = GetLastLineCompensation(path, direction,sn);
+                        foreach (var kvp in compensationDict)
+                        {
+                            outRequest_Body.unitData.processData.Add(
+                                new XmMES_StationOutRequest_Body.XmStationOut_ProcessData()
+                                {
+                                    dataName = kvp.Key.ToString(),
+                                    dataValue = kvp.Value.ToString()
+                                });
+                        }
+                    }
+
                     string jsonstr1 = JsonConvert.SerializeObject(outRequest_Body);
 
                     if (GlobalContext.IsSendProcessData)
@@ -1284,7 +1446,10 @@ namespace MainForm
                         {
                             response = XiaomiMESHttp_StationOutbound.StationOut(outRequest_Body);
                             if (response != null && response.header.code == "200")
+                            {
+                                OnMessage(LogType.Error, "上传出站数据到MES服务器---成功!请求信息:" + jsonstr1 + "返回信息:" + JsonConvert.SerializeObject(response.body));
                                 break;
+                            }
                             else if (!mesRet.Contains("1009"))  // 1009是未知错误
                                 i++;
 
@@ -1926,10 +2091,10 @@ namespace MainForm
                     Parameter_value = sn,
                     Parameter_unit = ""
                 });
-
+                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, "");
+    , workorder_code, batch_num, mtltmrk, plcDate_YMD, supplierCode, sn, pass, CarrierBarcode, "1", MachineId, StationId, "", paramJson);
 
                 byte mesResultFrmWeb = (byte)(result1 == 1 ? 1 : 110);
 
@@ -2222,10 +2387,10 @@ namespace MainForm
                     Parameter_unit = ""
                 });
 
-
+                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);
+   , workorder_code, batch_num, mtltmrk, plcDate_YMD, supplierCode, sn, pass, CarrierBarcode, "1", MachineId, StationId, PartBarcode, paramJson);
 
                 byte mesResultFrmWeb = (byte)(result1 == 1 ? 1 : 110);
 
@@ -2611,11 +2776,13 @@ namespace MainForm
                 });
 
                 int result1 = 1;
-                if (direction == "Right")
-                { 
-                     result1 = SwitctProcessData(stationNameStr, items, equipmentCode, processItem
-   , workorder_code, batch_num, mtltmrk, plcDate_YMD, supplierCode, sn, pass, CarrierBarcode, "1", MachineId, StationId, "");
-                }
+                //if (direction == "Right")
+                //{ 
+                string paramJson = JsonConvert.SerializeObject(stPLC_MesData.mesData);
+                result1 = SwitctProcessData(stationNameStr, items, equipmentCode, processItem
+   , workorder_code, batch_num, mtltmrk, plcDate_YMD, supplierCode, sn, pass, CarrierBarcode, "1", MachineId, StationId, "", paramJson, direction);
+                //}
+
 
                 byte mesResultFrmWeb = (byte)(result1 == 1 ? 1 : 110);
 
@@ -2911,9 +3078,9 @@ namespace MainForm
                     Parameter_value = sn,
                     Parameter_unit = ""
                 });
-
+                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, "");
+   , workorder_code, batch_num, mtltmrk, plcDate_YMD, supplierCode, sn, pass, CarrierBarcode, "1", MachineId, StationId, "", paramJson);
 
                 byte mesResultFrmWeb = (byte)(result1 == 1 ? 1 : 110);
 
@@ -3207,9 +3374,9 @@ namespace MainForm
                     Parameter_value = sn,
                     Parameter_unit = ""
                 });
-
+                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);
+   , workorder_code, batch_num, mtltmrk, plcDate_YMD, supplierCode, sn, pass, CarrierBarcode, "1", MachineId, StationId, PartBarcode, paramJson);
 
                 byte mesResultFrmWeb = (byte)(result1 == 1 ? 1 : 110);
 
@@ -3515,9 +3682,9 @@ namespace MainForm
                     Parameter_value = sn,
                     Parameter_unit = ""
                 });
-
+                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, "");
+    , workorder_code, batch_num, mtltmrk, plcDate_YMD, supplierCode, sn, pass, CarrierBarcode, "1", MachineId, StationId, "", paramJson);
 
                 byte mesResultFrmWeb = (byte)(result1 == 1 ? 1 : 110);
 
@@ -3893,12 +4060,13 @@ namespace MainForm
                 });
 
                 int result1 = 1;
-                if (direction == "Right")
-                { 
-                    SwitctProcessData(stationNameStr, items, equipmentCode, processItem
-   , workorder_code, batch_num, mtltmrk, plcDate_YMD, supplierCode, sn, pass, CarrierBarcode, "1", MachineId, StationId, "");
+                //if (direction == "Right")
+                //{ 
+                string paramJson = JsonConvert.SerializeObject(stPLC_MesData.mesData);
+                SwitctProcessData(stationNameStr, items, equipmentCode, processItem , workorder_code, batch_num, mtltmrk, plcDate_YMD, supplierCode
+                    , sn, pass, CarrierBarcode, "1", MachineId, StationId, "", paramJson);
                    
-                }
+                //}
 
                 //if (direction == "Left")
                 //{
@@ -4211,8 +4379,9 @@ namespace MainForm
                     Parameter_unit = ""
                 });
 
+                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, "");
+   , workorder_code, batch_num, mtltmrk, plcDate_YMD, supplierCode, sn, pass, CarrierBarcode, "1", MachineId, StationId, "", paramJson);
 
                 byte mesResultFrmWeb = (byte)(result1 == 1 ? 1 : 110);
 
@@ -4491,9 +4660,9 @@ namespace MainForm
                     Parameter_value = sn,
                     Parameter_unit = ""
                 });
-
+                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, "");
+   , workorder_code, batch_num, mtltmrk, plcDate_YMD, supplierCode, sn, pass, CarrierBarcode, "1", MachineId, StationId, "", paramJson);
 
                 byte mesResultFrmWeb = (byte)(result1 == 1 ? 1 : 110);
 
@@ -5203,7 +5372,7 @@ namespace MainForm
                     Parameter_value = a1Result == 1 ? "OK" : "NG",
                     Parameter_unit = ""
                 });
-                int result1 = SwitctProcessData(stationNameStr, items, equipmentCode, processItem
+                int result1 = SwitctProcessData_old(stationNameStr, items, equipmentCode, processItem
                     , workorder_code, mtltmrk, partNo1, pass, sn, "1");
 
                 // 产品2
@@ -5226,7 +5395,7 @@ namespace MainForm
                     Parameter_value = a1Result == 1 ? "OK" : "NG",
                     Parameter_unit = ""
                 });
-                int result2 = SwitctProcessData(stationNameStr, items, equipmentCode, processItem
+                int result2 = SwitctProcessData_old(stationNameStr, items, equipmentCode, processItem
                     , workorder_code, mtltmrk, partNo2, pass, sn, "2");
 
                 short result = 0;
@@ -6273,7 +6442,7 @@ namespace MainForm
                         Parameter_value = b1Part1Result == 1 ? "OK" : "NG",
                         Parameter_unit = ""
                     });
-                    result1 = SwitctProcessData(stationNameStr, items1, equipmentCode, processItem
+                    result1 = SwitctProcessData_old(stationNameStr, items1, equipmentCode, processItem
                    , workorder_code, mtltmrk, b1ProductSN1, pass1, b1ProductSN, "1");
                 }
                 // 产品2
@@ -6301,7 +6470,7 @@ namespace MainForm
                         Parameter_value = b1Part2Result == 1 ? "OK" : "NG",
                         Parameter_unit = ""
                     });
-                    result2 = SwitctProcessData(stationNameStr, items2, equipmentCode, processItem
+                    result2 = SwitctProcessData_old(stationNameStr, items2, equipmentCode, processItem
                         , workorder_code, mtltmrk, b1ProductSN2, pass2, b1ProductSN, "2");
                 }
 
@@ -7164,7 +7333,7 @@ namespace MainForm
                     Parameter_unit = ""
                 });
 
-                int result1 = SwitctProcessData(stationNameStr, items, equipmentCode, processItem
+                int result1 = SwitctProcessData_old(stationNameStr, items, equipmentCode, processItem
                         , workorder_code, mtltmrk, productSN, pass, sn, "1");
                 short result = (short)result1;
                 stopwatch2.Stop();
@@ -8263,7 +8432,7 @@ namespace MainForm
                             Parameter_unit = ""
                         });
 
-                        int result1 = SwitctProcessData(stationNameStr, items1, equipmentCode, processItem
+                        int result1 = SwitctProcessData_old(stationNameStr, items1, equipmentCode, processItem
                             , workorder_code, mtltmrk, partNos[i], pass, sn, index);
 
                         results.Add(result1);
@@ -8793,7 +8962,7 @@ namespace MainForm
                             Parameter_unit = ""
                         });
 
-                        int result1 = SwitctProcessData(stationNameStr, items1, equipmentCode, processItem
+                        int result1 = SwitctProcessData_old(stationNameStr, items1, equipmentCode, processItem
                             , workorder_code, mtltmrk, partNos[i], isPass, sn, index);
 
                         results.Add(result1);
@@ -9135,7 +9304,7 @@ namespace MainForm
                             Parameter_unit = ""
                         });
 
-                        int result1 = SwitctProcessData(stationNameStr, items1, equipmentCode, processItem
+                        int result1 = SwitctProcessData_old(stationNameStr, items1, equipmentCode, processItem
                             , workorder_code, mtltmrk, partNos[i], isPass, sn, index);
 
                         results.Add(result1);
@@ -9509,7 +9678,7 @@ namespace MainForm
                             Parameter_unit = ""
                         });
 
-                        int result1 = SwitctProcessData(stationNameStr, items1, equipmentCode, processItem
+                        int result1 = SwitctProcessData_old(stationNameStr, items1, equipmentCode, processItem
                             , workorder_code, mtltmrk, partNos[i], pass, sn, index);
                         results.Add(result1);
                     }
@@ -10142,7 +10311,7 @@ namespace MainForm
                     Parameter_unit = ""
                 });
 
-                int result1 = SwitctProcessData(stationNameStr, items, equipmentCode, processItem
+                int result1 = SwitctProcessData_old(stationNameStr, items, equipmentCode, processItem
                     , workorder_code, mtltmrk, partNo, pass, sn, "1");
                 //int result = result1 == 1 ? 1 : (GlobalContext.IsSendProcessData ? 4 : 1);
                 short result = result1 == 1 ? (short)1 : (short)3;

File diff suppressed because it is too large
+ 8316 - 8028
MainForm/FaForm/Form_Home.resx


+ 1 - 1
MainForm/FaForm/Form_Home_SaveData.cs

@@ -167,7 +167,7 @@ namespace MainForm
         /// <param name="vehicleSn">载具SN</param>
         /// <param name="vehicleSlot">载具穴号</param>
         /// <returns>上位机发送1代表OK;2代表上传客户MES失败;3代表上位机保存数据失败;4代表上位机报警;</returns>
-        private int SwitctProcessData(string stationNameStr, List<TestItem> items, string equipmentCode, string processItem,
+        private int SwitctProcessData_old(string stationNameStr, List<TestItem> items, string equipmentCode, string processItem,
             string workorder_code, string mtltmrk, string sn, bool pass, string vehicleSn, string vehicleSlot)
         {
             //if (DataSwitch == 1)