Jelajahi Sumber

添加首件日志记录

callm 2 minggu lalu
induk
melakukan
0cbf658fe2

+ 161 - 0
UAS_MES_STW/FunctionCode/Make/Make_FirstCheck.Designer.cs

@@ -0,0 +1,161 @@
+namespace UAS_MES_NEW.Make
+{
+    partial class Make_FirstCheck
+    {
+        /// <summary>
+        /// 必需的设计器变量。
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// 清理所有正在使用的资源。
+        /// </summary>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows 窗体设计器生成的代码
+
+        private void InitializeComponent()
+        {
+            this.Date_label = new System.Windows.Forms.Label();
+            this.Date_picker = new System.Windows.Forms.DateTimePicker();
+            this.Import_button = new System.Windows.Forms.Button();
+            this.Save_button = new System.Windows.Forms.Button();
+            this.Query_button = new System.Windows.Forms.Button();
+            this.Info_label = new System.Windows.Forms.Label();
+            this.OperateResult = new UAS_MES_NEW.CustomControl.RichText.RichTextAutoBottom();
+            this.LabelDataGridView = new System.Windows.Forms.DataGridView();
+            ((System.ComponentModel.ISupportInitialize)(this.LabelDataGridView)).BeginInit();
+            this.SuspendLayout();
+            // 
+            // Date_label
+            // 
+            this.Date_label.AutoSize = true;
+            this.Date_label.Location = new System.Drawing.Point(30, 29);
+            this.Date_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.Date_label.Name = "Date_label";
+            this.Date_label.Size = new System.Drawing.Size(58, 24);
+            this.Date_label.TabIndex = 2;
+            this.Date_label.Text = "日期";
+            // 
+            // Date_picker
+            // 
+            this.Date_picker.Format = System.Windows.Forms.DateTimePickerFormat.Short;
+            this.Date_picker.Location = new System.Drawing.Point(126, 21);
+            this.Date_picker.Margin = new System.Windows.Forms.Padding(6);
+            this.Date_picker.Name = "Date_picker";
+            this.Date_picker.Size = new System.Drawing.Size(236, 35);
+            this.Date_picker.TabIndex = 3;
+            // 
+            // Import_button
+            // 
+            this.Import_button.Location = new System.Drawing.Point(422, 15);
+            this.Import_button.Margin = new System.Windows.Forms.Padding(6);
+            this.Import_button.Name = "Import_button";
+            this.Import_button.Size = new System.Drawing.Size(192, 60);
+            this.Import_button.TabIndex = 4;
+            this.Import_button.Text = "选择文件";
+            this.Import_button.UseVisualStyleBackColor = true;
+            this.Import_button.Click += new System.EventHandler(this.Import_button_Click);
+            // 
+            // Save_button
+            // 
+            this.Save_button.Location = new System.Drawing.Point(634, 15);
+            this.Save_button.Margin = new System.Windows.Forms.Padding(6);
+            this.Save_button.Name = "Save_button";
+            this.Save_button.Size = new System.Drawing.Size(192, 60);
+            this.Save_button.TabIndex = 5;
+            this.Save_button.Text = "保存入库";
+            this.Save_button.UseVisualStyleBackColor = true;
+            this.Save_button.Click += new System.EventHandler(this.Save_button_Click);
+            // 
+            // Query_button
+            // 
+            this.Query_button.Location = new System.Drawing.Point(846, 15);
+            this.Query_button.Margin = new System.Windows.Forms.Padding(6);
+            this.Query_button.Name = "Query_button";
+            this.Query_button.Size = new System.Drawing.Size(192, 60);
+            this.Query_button.TabIndex = 6;
+            this.Query_button.Text = "查询";
+            this.Query_button.UseVisualStyleBackColor = true;
+            this.Query_button.Click += new System.EventHandler(this.Query_button_Click);
+            // 
+            // Info_label
+            // 
+            this.Info_label.AutoSize = true;
+            this.Info_label.Location = new System.Drawing.Point(28, 104);
+            this.Info_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.Info_label.Name = "Info_label";
+            this.Info_label.Size = new System.Drawing.Size(106, 24);
+            this.Info_label.TabIndex = 7;
+            this.Info_label.Text = "报告信息";
+            // 
+            // OperateResult
+            // 
+            this.OperateResult.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+            this.OperateResult.BackColor = System.Drawing.Color.White;
+            this.OperateResult.Location = new System.Drawing.Point(1760, 168);
+            this.OperateResult.Margin = new System.Windows.Forms.Padding(6);
+            this.OperateResult.Name = "OperateResult";
+            this.OperateResult.Size = new System.Drawing.Size(676, 356);
+            this.OperateResult.TabIndex = 8;
+            this.OperateResult.Text = "";
+            // 
+            // LabelDataGridView
+            // 
+            this.LabelDataGridView.AllowUserToAddRows = false;
+            this.LabelDataGridView.AllowUserToDeleteRows = false;
+            this.LabelDataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
+            | System.Windows.Forms.AnchorStyles.Left) 
+            | System.Windows.Forms.AnchorStyles.Right)));
+            this.LabelDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+            this.LabelDataGridView.Location = new System.Drawing.Point(24, 168);
+            this.LabelDataGridView.Margin = new System.Windows.Forms.Padding(6);
+            this.LabelDataGridView.Name = "LabelDataGridView";
+            this.LabelDataGridView.ReadOnly = true;
+            this.LabelDataGridView.RowHeadersWidth = 82;
+            this.LabelDataGridView.RowTemplate.Height = 23;
+            this.LabelDataGridView.Size = new System.Drawing.Size(1700, 1292);
+            this.LabelDataGridView.TabIndex = 9;
+            // 
+            // Make_FirstCheck
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(2480, 1490);
+            this.Controls.Add(this.LabelDataGridView);
+            this.Controls.Add(this.OperateResult);
+            this.Controls.Add(this.Info_label);
+            this.Controls.Add(this.Query_button);
+            this.Controls.Add(this.Save_button);
+            this.Controls.Add(this.Import_button);
+            this.Controls.Add(this.Date_picker);
+            this.Controls.Add(this.Date_label);
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+            this.Margin = new System.Windows.Forms.Padding(6);
+            this.Name = "Make_FirstCheck";
+            this.Text = "首件检测";
+            this.Load += new System.EventHandler(this.Make_FirstCheck_Load);
+            ((System.ComponentModel.ISupportInitialize)(this.LabelDataGridView)).EndInit();
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+        private System.Windows.Forms.Label Date_label;
+        private System.Windows.Forms.DateTimePicker Date_picker;
+        private System.Windows.Forms.Button Import_button;
+        private System.Windows.Forms.Button Save_button;
+        private System.Windows.Forms.Button Query_button;
+        private System.Windows.Forms.Label Info_label;
+        private UAS_MES_NEW.CustomControl.RichText.RichTextAutoBottom OperateResult;
+        private System.Windows.Forms.DataGridView LabelDataGridView;
+    }
+}

+ 547 - 0
UAS_MES_STW/FunctionCode/Make/Make_FirstCheck.cs

@@ -0,0 +1,547 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Drawing;
+using System.Globalization;
+using System.IO;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Windows.Forms;
+using UAS_MES_NEW.DataOperate;
+using UAS_MES_NEW.Entity;
+using UAS_MES_NEW.PublicMethod;
+
+namespace UAS_MES_NEW.Make
+{
+    /// <summary>
+    /// 首件检测(Make_FirstCheck)
+    /// 数据来源:首件检测报告 .txt(GBK 编码、制表符分隔,个别文件可能是 UTF-8)。
+    ///   头部:结论 / 通过率 / 样品型号 / 检测员 / 公司名称 / 订单编号 / 客户名称 /
+    ///         批次数量 / BOM版本 / 生产线别 / 测试时间 / 用时 / 生产日期 /
+    ///         检测总数 / 通过 / NF空贴 / 未检测
+    ///   明细:NO / 安装位置 / 元件料号 / 元件规格 / LCR测试值 / 测试结果
+    /// 上传方式:界面手动选择文件(OpenFileDialog),解析预览后保存入库;
+    ///   同一机台同一文件名只允许上传一次(数据库 UK_FIRSTCHECK_MAC_FILE 唯一索引)。
+    /// </summary>
+    public partial class Make_FirstCheck : Form
+    {
+        private const int BATCH_SIZE = 100;
+
+        private DataHelper dh;
+
+        // 当前解析出的报告头信息
+        private FirstCheckReport report;
+
+        // 明细预览数据:列 FI_NO / FI_LOCATION / FI_PARTNO / FI_SPEC / FI_LCRVALUE / FI_RESULT
+        private DataTable preview;
+
+        // 当前选择的报告文件(保存时作为 FC_FILE)
+        private string currentFile = "";
+
+        public Make_FirstCheck()
+        {
+            InitializeComponent();
+            try { UAS_MES_NEW.I18n.LanguageManager.Localize(this); } catch { }
+        }
+
+        private void Make_FirstCheck_Load(object sender, EventArgs e)
+        {
+            try
+            {
+                dh = SystemInf.dh;
+
+                Date_picker.Value = DateTime.Today;
+
+                BuildPreviewTable();
+                BindGrid(preview);
+                QueryData();
+            }
+            catch (Exception ex)
+            {
+                OperateResult.AppendText(">> 初始化失败:" + ex.Message + "\n", Color.Red);
+            }
+        }
+
+        // ---------------- 选择文件(手动上传) ----------------
+
+        private void Import_button_Click(object sender, EventArgs e)
+        {
+            using (OpenFileDialog ofd = new OpenFileDialog())
+            {
+                ofd.Filter = "报告文件(*.txt)|*.txt|所有文件(*.*)|*.*";
+                ofd.Title = "选择首件检测报告文件";
+                if (ofd.ShowDialog(this) != DialogResult.OK) return;
+
+                try
+                {
+                    string text = ReadAllTextAuto(ofd.FileName);
+                    FirstCheckReport rep = new FirstCheckReport();
+                    DataTable items = ParseReport(text, rep);
+
+                    if ((rep.Model == "" && rep.OrderNo == "" && items.Rows.Count == 0))
+                    {
+                        OperateResult.AppendText(">> 未解析到首件检测报告内容,请确认选择的是报告 txt 文件\n", Color.Red);
+                        return;
+                    }
+
+                    currentFile = Path.GetFileName(ofd.FileName);
+                    report = rep;
+                    report.Machine = "";
+                    report.File = currentFile;
+                    report.ItemCount = items.Rows.Count;
+
+                    preview = items;
+                    BindGrid(preview);
+
+                    Info_label.Text = "样品型号:" + rep.Model
+                        + "    结论:" + rep.Result
+                        + "    通过率:" + rep.PassRate
+                        + "    订单:" + rep.OrderNo
+                        + (rep.ProdDate.HasValue ? "    生产日期:" + rep.ProdDate.Value.ToString("yyyy-MM-dd") : "")
+                        + "    明细 " + rep.ItemCount + " 行";
+
+                    OperateResult.AppendText(">> 解析成功:" + currentFile
+                        + "(结论 " + rep.Result + ",通过率 " + rep.PassRate
+                        + ",明细 " + rep.ItemCount + " 行),请核对后点「保存入库」\n", Color.Green);
+                }
+                catch (Exception ex)
+                {
+                    OperateResult.AppendText(">> 解析失败:" + ex.Message + "\n", Color.Red);
+                }
+            }
+        }
+
+        // ---------------- 保存入库 ----------------
+
+        private void Save_button_Click(object sender, EventArgs e)
+        {
+            if (report == null || preview == null || preview.Rows.Count == 0 || currentFile == "")
+            {
+                OperateResult.AppendText(">> 没有可保存的数据,请先选择报告文件\n", Color.Red);
+                return;
+            }
+
+            string machine ="首件";
+            if (machine == "")
+            {
+                OperateResult.AppendText(">> 请先选择机台\n", Color.Red);
+                return;
+            }
+
+            try
+            {
+                // 同一机台同一文件只允许上传一次
+                object cnt = dh.getFieldDataByCondition("FIRSTCHECK", "count(1)",
+                    "FC_MACHINE='" + machine.Replace("'", "''") + "'"
+                    + " AND FC_FILE='" + currentFile.Replace("'", "''") + "'");
+                if (cnt != null && Convert.ToInt32(cnt) > 0)
+                {
+                    OperateResult.AppendText(">> 该文件已入库(" + machine + " " + currentFile + "),不能重复上传\n", Color.Blue);
+                    QueryData();
+                    return;
+                }
+
+                report.Machine = machine;
+                int items = InsertReport(report, preview);
+
+                OperateResult.AppendText(">> 保存成功:" + machine + " " + currentFile
+                    + "(明细 " + items + " 行)\n", Color.Green);
+
+                LogicHandler.DoCommandLog(Tag == null ? "Make!FirstCheck" : Tag.ToString(), User.UserCode, "",
+                    User.UserLineCode, User.UserSourceCode, "首件检测上传",
+                    currentFile + " 明细" + items + "行", machine, "");
+
+                QueryData();
+            }
+            catch (Exception ex)
+            {
+                OperateResult.AppendText(">> 保存失败:" + ex.Message + "\n", Color.Red);
+            }
+        }
+
+        /// <summary>
+        /// 入库:先取号(序列不允许出现在 union all 查询里,ORA-02287),
+        /// 主表一条 insert,从表按 100 行一批 union all 插入。返回明细行数。
+        /// </summary>
+        private int InsertReport(FirstCheckReport rep, DataTable items)
+        {
+            // 1) 主表
+            string[] masterIds = dh.GetSEQ("FIRSTCHECK_SEQ", 1);
+            if (masterIds.Length < 1)
+                throw new Exception("取序列号失败");
+            string masterId = masterIds[0];
+
+            StringBuilder sb = new StringBuilder();
+            sb.Append("insert into FIRSTCHECK(FC_ID,FC_MACHINE,FC_FILE,FC_RESULT,FC_PASSRATE,");
+            sb.Append("FC_MODEL,FC_INSPECTOR,FC_COMPANY,FC_ORDERNO,FC_CUSTNAME,FC_LOTQTY,");
+            sb.Append("FC_BOMVER,FC_LINE,FC_TESTTIME,FC_USEDTIME,FC_PRODDATE,");
+            sb.Append("FC_TOTAL,FC_PASS,FC_NFCOUNT,FC_NFPASS,FC_UNCHECK,FC_ITEMCOUNT,");
+            sb.Append("FC_INDATE,FC_INMAN) select ");
+            sb.Append(masterId).Append(",'").Append(rep.Machine.Replace("'", "''")).Append("','");
+            sb.Append(rep.File.Replace("'", "''")).Append("',");
+            sb.Append(StrLiteral(rep.Result)).Append(",").Append(StrLiteral(rep.PassRate)).Append(",");
+            sb.Append(StrLiteral(rep.Model)).Append(",").Append(StrLiteral(rep.Inspector)).Append(",");
+            sb.Append(StrLiteral(rep.Company)).Append(",").Append(StrLiteral(rep.OrderNo)).Append(",");
+            sb.Append(StrLiteral(rep.CustName)).Append(",").Append(StrLiteral(rep.LotQty)).Append(",");
+            sb.Append(StrLiteral(rep.BomVer)).Append(",").Append(StrLiteral(rep.Line)).Append(",");
+            sb.Append(StrLiteral(rep.TestTime)).Append(",").Append(StrLiteral(rep.UsedTime)).Append(",");
+            sb.Append(DateLiteral(rep.ProdDate)).Append(",");
+            sb.Append(NumLiteral(rep.Total)).Append(",").Append(NumLiteral(rep.Pass)).Append(",");
+            sb.Append(NumLiteral(rep.NfCount)).Append(",").Append(NumLiteral(rep.NfPass)).Append(",");
+            sb.Append(NumLiteral(rep.Uncheck)).Append(",").Append(items.Rows.Count).Append(",");
+            sb.Append("sysdate,'").Append(User.UserCode.Replace("'", "''")).Append("' from dual");
+            dh.ExecuteSql(sb.ToString(), "insert");
+
+            // 2) 明细:先一次性取号,再按批次 union all
+            int n = items.Rows.Count;
+            if (n == 0) return 0;
+
+            string[] ids = dh.GetSEQ("FIRSTCHECKITEM_SEQ", n);
+            if (ids.Length < n)
+                throw new Exception("取序列号失败(需要 " + n + " 个,实际 " + ids.Length + " 个)");
+
+            sb.Clear();
+            int inBatch = 0;
+            int saved = 0;
+
+            for (int i = 0; i < n; i++)
+            {
+                DataRow row = items.Rows[i];
+
+                if (inBatch == 0)
+                {
+                    sb.Append("insert into FIRSTCHECKITEM(FI_ID,FC_ID,FI_NO,FI_LOCATION,FI_PARTNO,FI_SPEC,FI_LCRVALUE,FI_RESULT) ");
+                }
+                else
+                {
+                    sb.Append(" union all ");
+                }
+
+                sb.Append("select ").Append(ids[i]).Append(",").Append(masterId).Append(",");
+                sb.Append(NumLiteral(row["FI_NO"] == DBNull.Value ? (int?)null : Convert.ToInt32(row["FI_NO"]))).Append(",");
+                sb.Append(StrLiteral(row["FI_LOCATION"].ToString())).Append(",");
+                sb.Append(StrLiteral(row["FI_PARTNO"].ToString())).Append(",");
+                sb.Append(StrLiteral(row["FI_SPEC"].ToString())).Append(",");
+                sb.Append(StrLiteral(row["FI_LCRVALUE"].ToString())).Append(",");
+                sb.Append(StrLiteral(row["FI_RESULT"].ToString())).Append(" from dual");
+
+                inBatch++;
+                if (inBatch >= BATCH_SIZE)
+                {
+                    dh.ExecuteSql(sb.ToString(), "insert");
+                    saved += inBatch;
+                    sb.Clear();
+                    inBatch = 0;
+                }
+            }
+
+            if (inBatch > 0)
+            {
+                dh.ExecuteSql(sb.ToString(), "insert");
+                saved += inBatch;
+            }
+
+            return saved;
+        }
+
+        // ---------------- 查询 ----------------
+
+        private void Query_button_Click(object sender, EventArgs e)
+        {
+            QueryData();
+        }
+
+        private void QueryData()
+        {
+            try
+            {
+                string machine = "首件";
+                if (machine == "") return;
+
+                DateTime day = Date_picker.Value.Date;
+                // 生产日期缺失的报告按录入日期归入当天
+                string sql = "select * from (select FC_ID,";
+                sql += "to_char(nvl(FC_PRODDATE,trunc(FC_INDATE)),'yyyy-mm-dd') FC_PRODDATE,";
+                sql += "FC_MODEL,FC_RESULT,FC_PASSRATE,FC_ORDERNO,FC_CUSTNAME,FC_LOTQTY,";
+                sql += "FC_BOMVER,FC_LINE,FC_TESTTIME,FC_USEDTIME,FC_INSPECTOR,";
+                sql += "FC_TOTAL,FC_PASS,FC_NFCOUNT,FC_NFPASS,FC_UNCHECK,FC_ITEMCOUNT,FC_FILE";
+                sql += " from FIRSTCHECK where FC_MACHINE='" + machine.Replace("'", "''") + "'";
+                sql += " and nvl(FC_PRODDATE,trunc(FC_INDATE)) >= to_date('" + day.ToString("yyyy-MM-dd") + "','yyyy-mm-dd')";
+                sql += " and nvl(FC_PRODDATE,trunc(FC_INDATE)) < to_date('" + day.AddDays(1).ToString("yyyy-MM-dd") + "','yyyy-mm-dd')";
+                sql += " order by FC_ID desc) where rownum <= 500";
+
+                DataTable dt = (DataTable)dh.ExecuteSql(sql, "select");
+                BindGrid(dt);
+                OperateResult.AppendText(">> 查询到 " + dt.Rows.Count + " 份报告(" + machine + " " + day.ToString("yyyy-MM-dd") + ")\n", Color.Blue);
+            }
+            catch (Exception ex)
+            {
+                OperateResult.AppendText(">> 查询失败:" + ex.Message + "\n", Color.Red);
+            }
+        }
+
+        // ---------------- 解析 ----------------
+
+        /// <summary>
+        /// 解析报告文本:头部标签行 + 明细行。
+        /// 明细表头行形如:NO	安装位置	元件料号	元件规格	LCR测试值	测试结果
+        /// </summary>
+        private DataTable ParseReport(string text, FirstCheckReport rep)
+        {
+            DataTable items = BuildPreviewTable();
+
+            bool inDetail = false;
+
+            string[] lines = text.Replace("\r\n", "\n").Replace("\r", "\n").Split('\n');
+            foreach (string line in lines)
+            {
+                string[] cells = line.Split('\t');
+
+                // 明细表头行:第一个非空单元格是 NO,且包含「安装位置」
+                if (!inDetail)
+                {
+                    int firstNonEmpty = FirstNonEmptyIndex(cells);
+                    if (firstNonEmpty >= 0 && cells[firstNonEmpty].Trim() == "NO"
+                        && LineContains(cells, "安装位置"))
+                    {
+                        inDetail = true;
+                        continue;
+                    }
+                    // 头部信息行:逐个单元格解析「标签:值」
+                    foreach (string raw in cells)
+                        ParseHeaderCell(raw, rep);
+                }
+                else
+                {
+                    // 明细数据行:NO 为数字才接受,遇到非数据行自动跳过
+                    int firstNonEmpty = FirstNonEmptyIndex(cells);
+                    if (firstNonEmpty < 0) continue;
+
+                    int no;
+                    if (!int.TryParse(cells[firstNonEmpty].Trim(), out no)) continue;
+                    if (cells.Length < firstNonEmpty + 6) continue;
+
+                    DataRow row = items.NewRow();
+                    row["FI_NO"] = no;
+                    row["FI_LOCATION"] = cells[firstNonEmpty + 1].Trim();
+                    row["FI_PARTNO"] = cells[firstNonEmpty + 2].Trim();
+                    row["FI_SPEC"] = cells[firstNonEmpty + 3].Trim();
+                    row["FI_LCRVALUE"] = cells[firstNonEmpty + 4].Trim();
+                    row["FI_RESULT"] = cells[firstNonEmpty + 5].Trim();
+                    items.Rows.Add(row);
+                }
+            }
+
+            return items;
+        }
+
+        /// <summary>解析头部单个单元格「标签:值」。</summary>
+        private void ParseHeaderCell(string raw, FirstCheckReport rep)
+        {
+            if (raw == null) return;
+            string cell = raw.Trim();
+            if (cell == "") return;
+
+            Match m = Regex.Match(cell, @"^(.+?)[::]\s*(.*)$");
+            if (!m.Success) return;
+
+            // 标签里的全角空格/普通空格统一去掉,兼容「结    论」「通 过 率」等写法
+            string label = Regex.Replace(m.Groups[1].Value, "[\u3000\\s]", "");
+            string value = m.Groups[2].Value.Trim();
+            if (label == "" || value == "") return;
+
+            switch (label)
+            {
+                case "结论": rep.Result = value; break;
+                case "通过率": rep.PassRate = value; break;
+                case "样品型号": rep.Model = value; break;
+                case "检测员": rep.Inspector = value; break;
+                case "公司名称": rep.Company = value; break;
+                case "订单编号": rep.OrderNo = value; break;
+                case "客户名称": rep.CustName = value; break;
+                case "批次数量": rep.LotQty = value; break;
+                case "BOM版本": rep.BomVer = value; break;
+                case "生产线别": rep.Line = value; break;
+                case "测试时间":
+                    // 同一单元格:测试时间:11:13  用时:3分 52秒
+                    Match mu = Regex.Match(value, @"用时\s*[::]\s*(.+)$");
+                    if (mu.Success)
+                    {
+                        rep.UsedTime = mu.Groups[1].Value.Trim();
+                        rep.TestTime = value.Substring(0, mu.Index).Trim();
+                    }
+                    else rep.TestTime = value;
+                    break;
+                case "生产日期":
+                    DateTime d;
+                    if (DateTime.TryParse(value, CultureInfo.InvariantCulture, DateTimeStyles.None, out d)
+                        || DateTime.TryParse(value, out d))
+                        rep.ProdDate = d;
+                    break;
+                case "检测总数":
+                    rep.Total = ToInt(value);
+                    break;
+                case "通过":
+                    rep.Pass = ToInt(value);
+                    break;
+                case "未检测":
+                    rep.Uncheck = ToInt(value);
+                    break;
+                case "NF空贴":
+                    // 同一单元格:NF空贴:5 通过:5
+                    rep.NfCount = ToInt(value);
+                    Match mp = Regex.Match(value, @"通过\s*[::]\s*(\d+)");
+                    if (mp.Success) rep.NfPass = ToInt(mp.Groups[1].Value);
+                    break;
+            }
+        }
+
+        // ---------------- 预览表格 ----------------
+
+        private DataTable BuildPreviewTable()
+        {
+            DataTable dt = new DataTable();
+            dt.Columns.Add("FI_NO", typeof(int));
+            dt.Columns.Add("FI_LOCATION", typeof(string));
+            dt.Columns.Add("FI_PARTNO", typeof(string));
+            dt.Columns.Add("FI_SPEC", typeof(string));
+            dt.Columns.Add("FI_LCRVALUE", typeof(string));
+            dt.Columns.Add("FI_RESULT", typeof(string));
+            return dt;
+        }
+
+        /// <summary>把 DataTable 绑定到表格,并设置中文列头。</summary>
+        private void BindGrid(DataTable dt)
+        {
+            LabelDataGridView.DataSource = null;
+            LabelDataGridView.AutoGenerateColumns = true;
+            LabelDataGridView.DataSource = dt;
+            LabelDataGridView.ReadOnly = true;
+            LabelDataGridView.AllowUserToAddRows = false;
+            LabelDataGridView.RowHeadersVisible = false;
+            LabelDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
+
+            if (dt == null || LabelDataGridView.Columns.Count == 0) return;
+
+            var headers = new Dictionary<string, string>
+            {
+                { "FI_NO", "序号" },
+                { "FI_LOCATION", "安装位置" },
+                { "FI_PARTNO", "元件料号" },
+                { "FI_SPEC", "元件规格" },
+                { "FI_LCRVALUE", "LCR测试值" },
+                { "FI_RESULT", "测试结果" },
+                { "FC_ID", "ID" },
+                { "FC_PRODDATE", "生产日期" },
+                { "FC_MODEL", "样品型号" },
+                { "FC_RESULT", "结论" },
+                { "FC_PASSRATE", "通过率" },
+                { "FC_ORDERNO", "订单编号" },
+                { "FC_CUSTNAME", "客户名称" },
+                { "FC_LOTQTY", "批次数量" },
+                { "FC_BOMVER", "BOM版本" },
+                { "FC_LINE", "线别" },
+                { "FC_TESTTIME", "测试时间" },
+                { "FC_USEDTIME", "用时" },
+                { "FC_INSPECTOR", "检测员" },
+                { "FC_TOTAL", "检测总数" },
+                { "FC_PASS", "通过" },
+                { "FC_NFCOUNT", "NF空贴" },
+                { "FC_NFPASS", "NF通过" },
+                { "FC_UNCHECK", "未检测" },
+                { "FC_ITEMCOUNT", "明细行数" },
+                { "FC_FILE", "文件名" }
+            };
+            foreach (var kv in headers)
+            {
+                if (LabelDataGridView.Columns.Contains(kv.Key))
+                    LabelDataGridView.Columns[kv.Key].HeaderText = kv.Value;
+            }
+        }
+
+        // ---------------- 工具方法 ----------------
+
+        /// <summary>按 UTF8 → GBK 顺序尝试读取,兼容两种编码的导出文件。</summary>
+        private static string ReadAllTextAuto(string path)
+        {
+            byte[] bytes = File.ReadAllBytes(path);
+            try
+            {
+                var strictUtf8 = new UTF8Encoding(false, true);
+                return strictUtf8.GetString(bytes);
+            }
+            catch
+            {
+                return Encoding.GetEncoding(936).GetString(bytes);
+            }
+        }
+
+        private static int FirstNonEmptyIndex(string[] cells)
+        {
+            for (int i = 0; i < cells.Length; i++)
+                if (cells[i].Trim() != "") return i;
+            return -1;
+        }
+
+        private static bool LineContains(string[] cells, string text)
+        {
+            foreach (string c in cells)
+                if (c.Contains(text)) return true;
+            return false;
+        }
+
+        private static int ToInt(string value)
+        {
+            int v;
+            Match m = Regex.Match(value ?? "", @"-?\d+");
+            return (m.Success && int.TryParse(m.Value, out v)) ? v : -1;
+        }
+
+        /// <summary>字符串转 SQL 字面量,空值写 null。</summary>
+        private static string StrLiteral(string s)
+        {
+            if (string.IsNullOrEmpty(s)) return "null";
+            return "'" + s.Replace("'", "''") + "'";
+        }
+
+        /// <summary>整数转 SQL 字面量,无效值写 to_number(null)。</summary>
+        private static string NumLiteral(int? v)
+        {
+            return v.HasValue && v.Value >= 0 ? v.Value.ToString() : "to_number(null)";
+        }
+
+        /// <summary>日期转 SQL 字面量,空值写 null。</summary>
+        private static string DateLiteral(DateTime? d)
+        {
+            return d.HasValue
+                ? "to_date('" + d.Value.ToString("yyyy-MM-dd") + "','yyyy-mm-dd')"
+                : "null";
+        }
+
+        /// <summary>报告头信息。</summary>
+        private class FirstCheckReport
+        {
+            public string Machine = "";
+            public string File = "";
+            public string Result = "";
+            public string PassRate = "";
+            public string Model = "";
+            public string Inspector = "";
+            public string Company = "";
+            public string OrderNo = "";
+            public string CustName = "";
+            public string LotQty = "";
+            public string BomVer = "";
+            public string Line = "";
+            public string TestTime = "";
+            public string UsedTime = "";
+            public DateTime? ProdDate;
+            public int Total = -1;
+            public int Pass = -1;
+            public int NfCount = -1;
+            public int NfPass = -1;
+            public int Uncheck = -1;
+            public int ItemCount;
+        }
+    }
+}

+ 120 - 0
UAS_MES_STW/FunctionCode/Make/Make_FirstCheck.resx

@@ -0,0 +1,120 @@
+<?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>
+</root>

+ 27 - 0
UAS_MES_STW/UAS_MES_STW.csproj

@@ -559,6 +559,24 @@
     <Compile Include="FunctionCode\Make\Make_Aging.Designer.cs">
       <DependentUpon>Make_Aging.cs</DependentUpon>
     </Compile>
+    <Compile Include="FunctionCode\Make\Make_OvenTemp.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="FunctionCode\Make\Make_OvenTemp.Designer.cs">
+      <DependentUpon>Make_OvenTemp.cs</DependentUpon>
+    </Compile>
+    <Compile Include="FunctionCode\Make\Make_SPIData.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="FunctionCode\Make\Make_SPIData.Designer.cs">
+      <DependentUpon>Make_SPIData.cs</DependentUpon>
+    </Compile>
+    <Compile Include="FunctionCode\Make\Make_FirstCheck.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="FunctionCode\Make\Make_FirstCheck.Designer.cs">
+      <DependentUpon>Make_FirstCheck.cs</DependentUpon>
+    </Compile>
     <Compile Include="FunctionCode\Make\Make_CollectElec.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -1641,6 +1659,15 @@
     <EmbeddedResource Include="FunctionCode\Make\Make_Aging.resx">
       <DependentUpon>Make_Aging.cs</DependentUpon>
     </EmbeddedResource>
+    <EmbeddedResource Include="FunctionCode\Make\Make_OvenTemp.resx">
+      <DependentUpon>Make_OvenTemp.cs</DependentUpon>
+    </EmbeddedResource>
+    <EmbeddedResource Include="FunctionCode\Make\Make_SPIData.resx">
+      <DependentUpon>Make_SPIData.cs</DependentUpon>
+    </EmbeddedResource>
+    <EmbeddedResource Include="FunctionCode\Make\Make_FirstCheck.resx">
+      <DependentUpon>Make_FirstCheck.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="FunctionCode\Make\Make_CollectElec.resx">
       <DependentUpon>Make_CollectElec.cs</DependentUpon>
     </EmbeddedResource>