소스 검색

Merge repos.ubtob.net:usoft/mes-client

callm 3 달 전
부모
커밋
b3655f719e

+ 24 - 2
UAS_MES_BG/FunctionCode/Make/Make_ParseLog.cs

@@ -916,6 +916,7 @@ namespace UAS_MES_NEW.Make
                     if (string.IsNullOrEmpty(item)) continue;
                     string[] currItem = item.Split(',');
                     string res = "",wo = "",detail = "",line = "",sn = "";
+                    bool hasSn = false;
                     sn = currItem[0];
                     if (string.IsNullOrEmpty(sn))
                     {
@@ -973,8 +974,24 @@ namespace UAS_MES_NEW.Make
                         Result = res,
                         Details = detail
                     };
-                    logArr.Add(itemLog);
 
+                    foreach (var appendItem in logArr)
+                    {
+                        if(appendItem.SN == sn)
+                        {
+                            if(itemLog.Result.ToUpper() != "PASS")
+                            {
+                                appendItem.Result = itemLog.Result;
+                                appendItem.Details = itemLog.Details;
+                            }
+                            hasSn = true;
+                        }
+                    }
+
+                    if (!hasSn) 
+                    {
+                        logArr.Add(itemLog);
+                    }
                 }
                 if (InsertDb(logArr, PathName, fileNum))
                 {
@@ -1023,7 +1040,12 @@ namespace UAS_MES_NEW.Make
                     {
                         if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, User.UserSourceCode, item.SN, User.UserCode, out omakeCode, out oMsid, out oErrorMessage))
                         {
-                            if (LogicHandler.SetStepResult(omakeCode, User.UserSourceCode, item.SN, "日志解析", "OK", User.UserCode, out oErrorMessage))
+                            string passStationRes = "OK";
+                            if (equiType == "AOI")
+                            {
+                                passStationRes = item.Result == "PASS" ? "OK" : "NG";
+                            }
+                            if (LogicHandler.SetStepResult(omakeCode, User.UserSourceCode, item.SN, "日志解析", passStationRes, User.UserCode, out oErrorMessage))
                             {
                                 string sqlStr = $@"select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,ma_qty - nvl(mcd_okqty, 0) remain_qty 
                                         from make left join makecraftdetail on mcd_maid=ma_id left join product on pr_code = ma_prodcode 

+ 293 - 0
UAS_MES_XZC/FunctionCode/Make/Make_ParseLog.Designer.cs

@@ -0,0 +1,293 @@
+namespace UAS_MES_NEW.Make
+{
+    partial class Make_ParseLog
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows Form Designer generated code
+
+        /// <summary>
+        /// Required method for Designer support - do not modify
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.Device = new System.Windows.Forms.ComboBox();
+            this.label1 = new System.Windows.Forms.Label();
+            this.label2 = new System.Windows.Forms.Label();
+            this.txtPath = new System.Windows.Forms.TextBox();
+            this.Choose = new System.Windows.Forms.Button();
+            this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
+            this.panel1 = new System.Windows.Forms.Panel();
+            this.onWatch = new System.Windows.Forms.Button();
+            this.claerBtn = new System.Windows.Forms.Button();
+            this.allParse = new System.Windows.Forms.Button();
+            this.label3 = new System.Windows.Forms.Label();
+            this.lstOk = new System.Windows.Forms.ListBox();
+            this.lstFiles = new System.Windows.Forms.ListBox();
+            this.openFileDialog2 = new System.Windows.Forms.OpenFileDialog();
+            this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
+            this.LockMakeCode = new UAS_MES_NEW.CustomControl.CustomCheckBox.LockCheckBox();
+            this.ma_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.MaCodeSearchTextBox();
+            this.panel1.SuspendLayout();
+            this.tableLayoutPanel1.SuspendLayout();
+            this.SuspendLayout();
+            // 
+            // Device
+            // 
+            this.Device.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.Device.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.Device.FormattingEnabled = true;
+            this.Device.Items.AddRange(new object[] {
+            "测试设备"});
+            this.Device.Location = new System.Drawing.Point(193, 88);
+            this.Device.Name = "Device";
+            this.Device.Size = new System.Drawing.Size(328, 32);
+            this.Device.TabIndex = 2;
+            this.Device.SelectedIndexChanged += new System.EventHandler(this.Device_SelectedIndexChanged);
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label1.Location = new System.Drawing.Point(61, 86);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(101, 30);
+            this.label1.TabIndex = 0;
+            this.label1.Text = "设备选择";
+            // 
+            // label2
+            // 
+            this.label2.AutoSize = true;
+            this.label2.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label2.Location = new System.Drawing.Point(61, 159);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(123, 30);
+            this.label2.TabIndex = 4;
+            this.label2.Text = "文件夹选择";
+            // 
+            // txtPath
+            // 
+            this.txtPath.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.txtPath.Location = new System.Drawing.Point(193, 154);
+            this.txtPath.Name = "txtPath";
+            this.txtPath.Size = new System.Drawing.Size(474, 39);
+            this.txtPath.TabIndex = 3;
+            // 
+            // Choose
+            // 
+            this.Choose.Cursor = System.Windows.Forms.Cursors.Hand;
+            this.Choose.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.Choose.Location = new System.Drawing.Point(693, 152);
+            this.Choose.Name = "Choose";
+            this.Choose.Size = new System.Drawing.Size(122, 38);
+            this.Choose.TabIndex = 4;
+            this.Choose.Text = "选择";
+            this.Choose.UseVisualStyleBackColor = true;
+            this.Choose.Click += new System.EventHandler(this.Choose_Click);
+            // 
+            // openFileDialog1
+            // 
+            this.openFileDialog1.FileName = "openFileDialog1";
+            this.openFileDialog1.RestoreDirectory = true;
+            // 
+            // panel1
+            // 
+            this.panel1.BackColor = System.Drawing.SystemColors.Control;
+            this.panel1.Controls.Add(this.onWatch);
+            this.panel1.Controls.Add(this.claerBtn);
+            this.panel1.Controls.Add(this.LockMakeCode);
+            this.panel1.Controls.Add(this.ma_code);
+            this.panel1.Controls.Add(this.allParse);
+            this.panel1.Controls.Add(this.label3);
+            this.panel1.Controls.Add(this.Device);
+            this.panel1.Controls.Add(this.label1);
+            this.panel1.Controls.Add(this.Choose);
+            this.panel1.Controls.Add(this.label2);
+            this.panel1.Controls.Add(this.txtPath);
+            this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
+            this.panel1.Location = new System.Drawing.Point(0, 0);
+            this.panel1.Name = "panel1";
+            this.panel1.Size = new System.Drawing.Size(1304, 296);
+            this.panel1.TabIndex = 7;
+            // 
+            // onWatch
+            // 
+            this.onWatch.Cursor = System.Windows.Forms.Cursors.Hand;
+            this.onWatch.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.onWatch.Location = new System.Drawing.Point(66, 232);
+            this.onWatch.Name = "onWatch";
+            this.onWatch.Size = new System.Drawing.Size(122, 38);
+            this.onWatch.TabIndex = 8;
+            this.onWatch.Text = "开启解析";
+            this.onWatch.UseVisualStyleBackColor = true;
+            this.onWatch.Click += new System.EventHandler(this.onWatch_Click);
+            // 
+            // claerBtn
+            // 
+            this.claerBtn.Cursor = System.Windows.Forms.Cursors.Hand;
+            this.claerBtn.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.claerBtn.Location = new System.Drawing.Point(391, 231);
+            this.claerBtn.Name = "claerBtn";
+            this.claerBtn.Size = new System.Drawing.Size(122, 38);
+            this.claerBtn.TabIndex = 7;
+            this.claerBtn.Text = "清除";
+            this.claerBtn.UseVisualStyleBackColor = true;
+            this.claerBtn.Click += new System.EventHandler(this.claerBtn_Click);
+            // 
+            // allParse
+            // 
+            this.allParse.Cursor = System.Windows.Forms.Cursors.Hand;
+            this.allParse.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.allParse.Location = new System.Drawing.Point(230, 232);
+            this.allParse.Name = "allParse";
+            this.allParse.Size = new System.Drawing.Size(122, 38);
+            this.allParse.TabIndex = 5;
+            this.allParse.Text = "批量解析";
+            this.allParse.UseVisualStyleBackColor = true;
+            this.allParse.Click += new System.EventHandler(this.allParse_Click);
+            // 
+            // label3
+            // 
+            this.label3.AutoSize = true;
+            this.label3.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label3.Location = new System.Drawing.Point(61, 23);
+            this.label3.Name = "label3";
+            this.label3.Size = new System.Drawing.Size(57, 30);
+            this.label3.TabIndex = 6;
+            this.label3.Text = "工单";
+            this.label3.Visible = false;
+            // 
+            // lstOk
+            // 
+            this.lstOk.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.lstOk.FormattingEnabled = true;
+            this.lstOk.HorizontalScrollbar = true;
+            this.lstOk.ItemHeight = 18;
+            this.lstOk.Location = new System.Drawing.Point(655, 3);
+            this.lstOk.Name = "lstOk";
+            this.lstOk.Size = new System.Drawing.Size(646, 524);
+            this.lstOk.TabIndex = 1;
+            // 
+            // lstFiles
+            // 
+            this.lstFiles.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.lstFiles.FormattingEnabled = true;
+            this.lstFiles.HorizontalScrollbar = true;
+            this.lstFiles.ItemHeight = 18;
+            this.lstFiles.Location = new System.Drawing.Point(3, 3);
+            this.lstFiles.Name = "lstFiles";
+            this.lstFiles.Size = new System.Drawing.Size(646, 524);
+            this.lstFiles.TabIndex = 0;
+            this.lstFiles.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.lstFiles_DrawItem_1);
+            // 
+            // openFileDialog2
+            // 
+            this.openFileDialog2.FileName = "openFileDialog2";
+            // 
+            // tableLayoutPanel1
+            // 
+            this.tableLayoutPanel1.ColumnCount = 2;
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
+            this.tableLayoutPanel1.Controls.Add(this.lstOk, 1, 0);
+            this.tableLayoutPanel1.Controls.Add(this.lstFiles, 0, 0);
+            this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 296);
+            this.tableLayoutPanel1.Name = "tableLayoutPanel1";
+            this.tableLayoutPanel1.RowCount = 1;
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
+            this.tableLayoutPanel1.Size = new System.Drawing.Size(1304, 530);
+            this.tableLayoutPanel1.TabIndex = 8;
+            // 
+            // LockMakeCode
+            // 
+            this.LockMakeCode.AutoSize = true;
+            this.LockMakeCode.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.LockMakeCode.LeaveEvent = false;
+            this.LockMakeCode.Location = new System.Drawing.Point(520, 25);
+            this.LockMakeCode.Margin = new System.Windows.Forms.Padding(4);
+            this.LockMakeCode.Name = "LockMakeCode";
+            this.LockMakeCode.Size = new System.Drawing.Size(72, 28);
+            this.LockMakeCode.TabIndex = 1;
+            this.LockMakeCode.Text = "锁定";
+            this.LockMakeCode.UseVisualStyleBackColor = true;
+            this.LockMakeCode.Visible = false;
+            // 
+            // ma_code
+            // 
+            this.ma_code.AllPower = null;
+            this.ma_code.BackColor = System.Drawing.SystemColors.Control;
+            this.ma_code.Caller = null;
+            this.ma_code.Condition = null;
+            this.ma_code.DBTitle = null;
+            this.ma_code.FormName = null;
+            this.ma_code.Location = new System.Drawing.Point(193, 25);
+            this.ma_code.Margin = new System.Windows.Forms.Padding(4);
+            this.ma_code.Name = "ma_code";
+            this.ma_code.Power = null;
+            this.ma_code.ReturnData = null;
+            this.ma_code.SelectField = null;
+            this.ma_code.SetValueField = null;
+            this.ma_code.Size = new System.Drawing.Size(224, 32);
+            this.ma_code.TabIndex = 0;
+            this.ma_code.TableName = null;
+            this.ma_code.TextBoxEnable = true;
+            this.ma_code.Visible = false;
+            // 
+            // Make_ParseLog
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.BackColor = System.Drawing.SystemColors.Window;
+            this.ClientSize = new System.Drawing.Size(1304, 826);
+            this.Controls.Add(this.tableLayoutPanel1);
+            this.Controls.Add(this.panel1);
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+            this.Name = "Make_ParseLog";
+            this.Text = "Make_ParseLog";
+            this.Load += new System.EventHandler(this.Make_ParseLog_Load);
+            this.panel1.ResumeLayout(false);
+            this.panel1.PerformLayout();
+            this.tableLayoutPanel1.ResumeLayout(false);
+            this.ResumeLayout(false);
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.ComboBox Device;
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.TextBox txtPath;
+        private System.Windows.Forms.Button Choose;
+        private System.Windows.Forms.OpenFileDialog openFileDialog1;
+        private System.Windows.Forms.Panel panel1;
+        private System.Windows.Forms.Label label3;
+        private System.Windows.Forms.Button allParse;
+        private CustomControl.TextBoxWithIcon.MaCodeSearchTextBox ma_code;
+        private CustomControl.CustomCheckBox.LockCheckBox LockMakeCode;
+        private System.Windows.Forms.OpenFileDialog openFileDialog2;
+        private System.Windows.Forms.ListBox lstFiles;
+        private System.Windows.Forms.Button claerBtn;
+        private System.Windows.Forms.Button onWatch;
+        private System.Windows.Forms.ListBox lstOk;
+        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
+    }
+}

+ 481 - 0
UAS_MES_XZC/FunctionCode/Make/Make_ParseLog.cs

@@ -0,0 +1,481 @@
+using BarTender;
+using DevExpress.Utils.OAuth.Provider;
+using DevExpress.Xpo.Logger;
+using DevExpress.XtraEditors.Controls;
+using DevExpress.XtraExport;
+using DevExpress.XtraPrinting;
+using NPOI.SS.Formula.Functions;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Security;
+using System.Security.AccessControl;
+using System.Security.Principal;
+using System.Text;
+using System.Threading.Tasks;
+using System.Web.Services.Description;
+using System.Web.UI.WebControls;
+using System.Windows.Forms;
+using System.Xml;
+using UAS_MES_NEW.CustomControl.ButtonUtil;
+using UAS_MES_NEW.CustomControl.TextBoxWithIcon;
+using UAS_MES_NEW.DataOperate;
+using UAS_MES_NEW.Entity;
+using UAS_MES_NEW.PublicMethod;
+using static DevExpress.Xpo.DB.DataStoreLongrunnersWatch;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.Tab;
+
+namespace UAS_MES_NEW.Make
+{
+    public partial class Make_ParseLog : Form
+    {
+        public Make_ParseLog()
+        {
+            InitializeComponent();
+        }
+
+        FileSystemWatcher watcher;
+
+        LogStringBuilder sql = new LogStringBuilder();
+        DataTable Dbfind;
+        DataTable dt;
+
+        DataHelper dh;
+        string currFileType = "",equiType = "";
+
+        string SN, omakeCode, oMsid, oErrorMessage = "";
+        List<string> fileList = new List<string>();
+
+        Timer formsTimer;
+
+        string Board, Module;
+
+        private void Make_ParseLog_Load(object sender, EventArgs e)
+        {
+            dh = SystemInf.dh;
+
+            fileList.Add("C:\\Users\\MI\\Desktop");
+
+            formsTimer = new Timer();
+            formsTimer.Interval = 10000;
+            formsTimer.Tick += timer1_Tick;
+            //formsTimer.Start();
+            //formsTimer.Stop();
+
+            watcher = new FileSystemWatcher();
+            watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite;
+            watcher.Created += OnFileCreated;
+            watcher.Changed += OnFileChanged;
+            /*watcher.Deleted += OnFileChanged;
+            watcher.Renamed += OnFileChanged;*/
+
+            //设置锁定工单
+            LockMakeCode.GetMakeCodeCtl(ma_code);
+            ma_code.SetLockCheckBox(LockMakeCode);
+            //工单号放大镜配置
+            ma_code.TableName = "make left join product on ma_prodcode=pr_code";
+            ma_code.SelectField = "ma_code # 工单号,pr_code # 产品编号,pr_detail # 产品名称";
+            ma_code.FormName = Name;
+            ma_code.SetValueField = new string[] { "ma_code", "pr_code", "pr_detail" };
+            ma_code.Condition = "ma_statuscode='STARTED'";
+            ma_code.DbChange += Ma_code_DbChange;
+        }
+
+        private void Ma_code_DbChange(object sender, EventArgs e)
+        {
+            Dbfind = ma_code.ReturnData;
+            BaseUtil.SetFormValue(this.Controls, Dbfind);
+            //获取工单的其他信息
+            sql.Clear();
+            sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode as pr_code ,pr_detail,");
+            sql.Append("pr_spec,ma_qty - nvl(mcd_inqty, 0) mcd_remainqty from make left join makecraftdetail on ");
+            sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + ma_code.Text + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
+            dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+            if (dt.Rows.Count > 0)
+            {
+                BaseUtil.SetFormValue(this.Controls, dt);
+            }
+        }
+
+        private void Device_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            if (Device.SelectedIndex == -1) return;
+
+            switch (Device.SelectedIndex)
+            {
+                case 0:
+                    currFileType = "ini";
+                    equiType = "贴片设备";
+                    break;
+            }
+            /*if (string.IsNullOrEmpty(ma_code.Text))
+            {
+                Device.SelectedIndex = -1;
+                txtPath.Text = "";
+                MessageBox.Show(this.ParentForm, "请选择工单", "提示");
+                return;
+            }*/
+
+            txtPath.Text = fileList[Device.SelectedIndex];
+            txtPath.Focus();
+            txtPath.SelectAll();
+            //ma_code.Enabled = true;
+            txtPath.Enabled = false;
+        }
+
+        private void Choose_Click(object sender, EventArgs e)
+        {
+            using (var dialog = new FolderBrowserDialog())
+            {
+                switch (Device.SelectedIndex)
+                {
+                    case 0:
+                        dialog.Description = "请选择读取设备文件夹";
+                        currFileType = "ini";
+                        equiType = "贴片设备";
+                        break;
+                }
+                if (dialog.ShowDialog() == DialogResult.OK)
+                {
+                    txtPath.Text = dialog.SelectedPath;
+                    txtPath.Enabled = false;
+                    Device.Enabled = false;
+                    watcher.EnableRaisingEvents = false;
+                }
+            }
+        }
+
+        private void claerBtn_Click(object sender, EventArgs e)
+        {
+            lstFiles.Items.Clear();
+        }
+
+        private void allParse_Click(object sender, EventArgs e)
+        {
+            /*if (Device.SelectedIndex == 0)
+            {
+                if (string.IsNullOrEmpty(ma_code.Text))
+                {
+                    MessageBox.Show(this.ParentForm, "请选择工单", "提示");
+                    return;
+                }
+            }*/
+            if (Device.SelectedIndex == -1)
+            {
+                Device.Focus();
+                Device.SelectAll();
+                MessageBox.Show(this.ParentForm, "请选择设备", "提示");
+                return;
+            }
+            if (String.IsNullOrEmpty(txtPath.Text))
+            {
+                txtPath.Focus();
+                txtPath.SelectAll();
+                return;
+            }
+            string[] txtFiles = Directory.GetFiles(txtPath.Text, $"*.{currFileType}");
+            if (txtFiles.Length == 0)
+            {
+                LogMessage($"当前{txtPath.Text},没有{equiType}设备输出的{currFileType.ToLower()}文件");
+                return;
+            }
+            RefreshFileList();
+        }
+
+        private void onWatch_Click(object sender, EventArgs e)
+        {
+            /*if (Device.SelectedIndex == 0)
+            {
+                if (string.IsNullOrEmpty(ma_code.Text))
+                {
+                    MessageBox.Show(this.ParentForm, "请选择工单", "提示");
+                    return;
+                }
+            }*/
+            if (Device.SelectedIndex == -1)
+            {
+                Device.Focus();
+                Device.SelectAll();
+                MessageBox.Show(this.ParentForm, "请选择设备", "提示");
+                return;
+            }
+            if (String.IsNullOrEmpty(txtPath.Text))
+            {
+                txtPath.Focus();
+                txtPath.SelectAll();
+                return;
+            }
+            try
+            {
+                watcher.Path = txtPath.Text;
+                watcher.Filter = $"*.{currFileType}";
+                if (onWatch.Text == "开启解析")
+                {
+                    watcher.EnableRaisingEvents = true;
+                    onWatch.Text = "关闭解析";
+                }
+                else
+                {
+                    watcher.EnableRaisingEvents = false;
+                    onWatch.Text = "开启解析";
+                }
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(this.ParentForm, ex.Message, "警告");
+            }
+        }
+
+        private void OnFileCreated(object sender, FileSystemEventArgs e)
+        {
+            RefreshFileList();
+        }
+
+        private void OnFileChanged(object sender, FileSystemEventArgs e)
+        {
+            if (e.ChangeType == WatcherChangeTypes.Changed)
+            {
+                RefreshFileList();
+            }
+        }
+
+        private void RefreshFileList()
+        {
+            if (lstFiles.InvokeRequired)
+            {
+                lstFiles.Invoke(new Action(RefreshFileList));
+                lstFiles.BeginInvoke(new Action(RefreshFileList));
+                return;
+            }
+
+            try
+            {
+                if (!Directory.Exists(txtPath.Text))
+                {
+                    LogMessage($"目录不存在: {txtPath.Text}");
+                    return;
+                }
+
+                string[] txtFiles = Directory.GetFiles(txtPath.Text, $"*.{currFileType}");
+                if (txtFiles.Length == 0)
+                {
+                    return;
+                }
+                else
+                {
+                    foreach (string file in txtFiles)
+                    {
+                        if (!File.Exists(file))
+                        {
+                            LogMessage($"文件不存在: {file}");
+                        }
+
+                        string outFileMsg = CheckFileAccess(file);
+                        if (outFileMsg != "OK")
+                        {
+                            LogMessage(outFileMsg);
+                            continue;
+                        }
+
+                        if(File.ReadAllText(file).Length == 0)
+                        {
+                            continue;
+                        }
+
+                        if (Device.SelectedIndex == 0)
+                        {
+                            ParseLogInsert(file);
+                        }
+                        
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+                LogMessage($"Error: 解析文件列表失败: {ex.Message}");
+            }
+        }
+
+        private void ParseLogInsert(string PathName)
+        {
+            try
+            {
+                StreamReader SR = File.OpenText(PathName);
+                string restOfStream = SR.ReadToEnd();
+                SR.Close();
+                SR.Dispose();
+
+                string[] lines = restOfStream.Split(new string[] { "\r\n" }, StringSplitOptions.None);
+                for (int i = 0; i < lines.Length; i++)
+                {
+                    if (string.IsNullOrEmpty(lines[i])) continue;
+                    if (equiType == "贴片设备")
+                    {
+                        if (lines[i].Trim() == "[General.Count]")
+                        {
+                            if(string.IsNullOrEmpty(lines[i + 1]))
+                            {
+                                LogMessage($"文件: {PathName},更新[General.Count]下无Board数据NG");
+                            }
+
+                            if(lines[i + 1].Split('=')[0].ToUpper() != "BOARD")
+                            {
+                                LogMessage($"文件: {PathName},更新[General.Count]下无Board数据NG");
+                            }
+
+                            Board = lines[i + 1].Split('=')[1];
+                            break;
+                        }
+                    }
+                }
+                if (string.IsNullOrEmpty(Board))
+                {
+                    LogMessage($"文件: {PathName},更新[General.Count]下Board数据NG: 未找到");
+                    return;
+                }
+                else
+                {
+                    LogMessage($"文件: {PathName},[General.Count]下Board已更新: {Board}");
+                }
+
+                if (ConsoleLog(restOfStream, PathName))
+                {
+                    File.WriteAllText(PathName, string.Empty);
+                    File.Delete(PathName);
+                }
+
+            }
+            catch (Exception ex)
+            {
+                LogMessage($"Error: 文件 {PathName}, {ex.Message}");
+            }
+        }
+
+        private void timer1_Tick(object sender, EventArgs e)
+        {
+            try
+            {
+
+            }
+            catch (Exception ex)
+            {
+                LogMessage($"定时器异常: {ex.Message}");
+            }
+        }
+
+        private bool ConsoleLog(string Content, string PathName)
+        {
+            try
+            {
+                string sourceDir = Path.GetDirectoryName(PathName);
+                string newFolderName = "Logs";
+                string newFolderPath = Path.Combine(sourceDir, newFolderName);
+
+                if (!Directory.Exists(newFolderPath))
+                {
+                    Directory.CreateDirectory(newFolderPath);
+                }
+                string newFileName = "Log_" + Path.GetFileName(PathName);
+                string newFilePath = Path.Combine(newFolderPath, newFileName);
+
+                File.AppendAllText(newFilePath, Content + Environment.NewLine);
+                return true;
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(this.ParentForm, ex.Message, "警告");
+                return false;
+            }
+        }
+
+        private void LogMessage(string message)
+        {
+            bool isNg;
+            if (message.ToUpper().Contains("NG"))
+            {
+                isNg = true;
+            }
+            else if (message.ToUpper().Contains("ERROR"))
+            {
+                isNg = true;
+            }
+            else
+            {
+                isNg = false;
+            }
+
+            if (isNg) 
+            {
+                if (lstOk.InvokeRequired)
+                {
+                    lstOk.Invoke(new Action<string>(LogMessage), message);
+                    return;
+                }
+                lstOk.Items.Add($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] {message}");
+                lstOk.TopIndex = lstFiles.Items.Count - 1;
+            }
+            else
+            {
+                if (lstFiles.InvokeRequired)
+                {
+                    lstFiles.Invoke(new Action<string>(LogMessage), message);
+                    return;
+                }
+                lstFiles.Items.Add($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] {message}");
+                lstFiles.TopIndex = lstFiles.Items.Count - 1;
+                lstFiles.DrawMode = DrawMode.OwnerDrawFixed;
+            }
+        }
+
+        private void lstFiles_DrawItem_1(object sender, DrawItemEventArgs e)
+        {
+            e.DrawBackground();
+            Brush mybsh = Brushes.Black;
+            if (lstFiles.Items[e.Index].ToString().Contains("NG"))
+            {
+                mybsh = Brushes.Red;
+            }
+            else if (lstFiles.Items[e.Index].ToString().Contains("ERROR"))
+            {
+                mybsh = Brushes.Red;
+            }
+            e.DrawFocusRectangle();
+            e.Graphics.DrawString(lstFiles.Items[e.Index].ToString(), e.Font, mybsh, e.Bounds, StringFormat.GenericDefault);
+        }
+
+        public string CheckFileAccess(string filePath)
+        {
+            try
+            {
+                using (FileStream fileStream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.None))
+                {
+                    return "OK";
+                }
+            }
+            catch (IOException ex)
+            {
+                return "Error文件被占用: " + ex.Message;
+            }
+            catch (UnauthorizedAccessException ex)
+            {
+                return "Error权限不足,无法访问文件: " + ex.Message;
+            }
+            catch (Exception ex)
+            {
+                return ex.Message;
+            }
+        }
+
+        private class Log
+        {
+            public string SN { set; get; }
+
+            public string Result { set; get; }
+        }
+    }
+}

+ 126 - 0
UAS_MES_XZC/FunctionCode/Make/Make_ParseLog.resx

@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 23</value>
+  </metadata>
+  <metadata name="openFileDialog2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>224, 23</value>
+  </metadata>
+</root>

+ 9 - 0
UAS_MES_XZC/UAS_MES_XZC.csproj

@@ -764,6 +764,12 @@
     <Compile Include="FunctionCode\OQC\OQC_SamplingDataCollection_OffLine.Designer.cs">
       <DependentUpon>OQC_SamplingDataCollection_OffLine.cs</DependentUpon>
     </Compile>
+    <Compile Include="FunctionCode\Make\Make_ParseLog.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="FunctionCode\Make\Make_ParseLog.Designer.cs">
+      <DependentUpon>Make_ParseLog.cs</DependentUpon>
+    </Compile>
     <Compile Include="FunctionCode\Packing\Packing_BigBoxCollection.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -1690,6 +1696,9 @@
     <EmbeddedResource Include="FunctionCode\OQC\OQC_SamplingDataCollection_OffLine.resx">
       <DependentUpon>OQC_SamplingDataCollection_OffLine.cs</DependentUpon>
     </EmbeddedResource>
+    <EmbeddedResource Include="FunctionCode\Make\Make_ParseLog.resx">
+      <DependentUpon>Make_ParseLog.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="FunctionCode\Packing\Packing_BigBoxCollection.resx">
       <DependentUpon>Packing_BigBoxCollection.cs</DependentUpon>
     </EmbeddedResource>