yhluo 1 mesiac pred
rodič
commit
1bf9779d42

+ 14 - 14
UAS_MES_HYSX/FunctionCode/Make/Make_ParseLog.Designer.cs

@@ -56,7 +56,8 @@
             this.Device.FormattingEnabled = true;
             this.Device.Items.AddRange(new object[] {
             "AOI设备",
-            "CCD相机"});
+            "X-ray设备",
+            "CCD设备"});
             this.Device.Location = new System.Drawing.Point(193, 88);
             this.Device.Name = "Device";
             this.Device.Size = new System.Drawing.Size(387, 39);
@@ -211,13 +212,12 @@
             // lstOk
             // 
             this.lstOk.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.lstOk.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
             this.lstOk.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.lstOk.FormattingEnabled = true;
-            this.lstOk.ItemHeight = 22;
-            this.lstOk.Location = new System.Drawing.Point(655, 3);
+            this.lstOk.ItemHeight = 28;
+            this.lstOk.Location = new System.Drawing.Point(3, 3);
             this.lstOk.Name = "lstOk";
-            this.lstOk.Size = new System.Drawing.Size(646, 524);
+            this.lstOk.Size = new System.Drawing.Size(1298, 206);
             this.lstOk.TabIndex = 1;
             // 
             // lstFiles
@@ -227,9 +227,9 @@
             this.lstFiles.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.lstFiles.FormattingEnabled = true;
             this.lstFiles.ItemHeight = 22;
-            this.lstFiles.Location = new System.Drawing.Point(3, 3);
+            this.lstFiles.Location = new System.Drawing.Point(3, 215);
             this.lstFiles.Name = "lstFiles";
-            this.lstFiles.Size = new System.Drawing.Size(646, 524);
+            this.lstFiles.Size = new System.Drawing.Size(1298, 312);
             this.lstFiles.TabIndex = 0;
             this.lstFiles.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.lstFiles_DrawItem);
             // 
@@ -239,16 +239,16 @@
             // 
             // 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.ColumnCount = 1;
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
+            this.tableLayoutPanel1.Controls.Add(this.lstOk, 0, 0);
+            this.tableLayoutPanel1.Controls.Add(this.lstFiles, 0, 1);
             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.RowCount = 2;
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 40F));
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 60F));
             this.tableLayoutPanel1.Size = new System.Drawing.Size(1304, 530);
             this.tableLayoutPanel1.TabIndex = 8;
             // 

+ 95 - 54
UAS_MES_HYSX/FunctionCode/Make/Make_ParseLog.cs

@@ -1,5 +1,7 @@
 using DevExpress.Utils.CodedUISupport;
+using DevExpress.Xpo.Logger;
 using HslCommunication;
+using NPOI.POIFS.NIO;
 using NPOI.SS.Formula.Functions;
 using System;
 using System.Collections.Generic;
@@ -11,6 +13,7 @@ using System.Linq;
 using System.Net;
 using System.Text;
 using System.Web.Services.Description;
+using System.Web.UI.WebControls;
 using System.Windows.Forms;
 using UAS_MES_NEW.CustomControl.ButtonUtil;
 using UAS_MES_NEW.DataOperate;
@@ -94,12 +97,17 @@ namespace UAS_MES_NEW.Make
                 case 0:
                     currFileType = "Txt";
                     equiType = "AOI";
-                    ChangeWoTimer.Start();
+                    //ChangeWoTimer.Start();
                     break;
                 case 1:
+                    currFileType = "jpg";
+                    equiType = "Xray";
+                    //ChangeWoTimer.Stop();
+                    break;
+                case 2:
                     currFileType = "jpg";
                     equiType = "CCD";
-                    ChangeWoTimer.Stop();
+                    //ChangeWoTimer.Stop();
                     break;
             }
             if (string.IsNullOrEmpty(ma_code.Text))
@@ -271,44 +279,55 @@ namespace UAS_MES_NEW.Make
 
                     if (equiType == "AOI")
                     {
-                        StreamReader SR = File.OpenText(file);
-                        string restOfStream = SR.ReadToEnd();
-                        SR.Close();
-                        SR.Dispose();
-
-                        List<Log> logArr = new List<Log>() { };
-                        string[] lines = restOfStream.Split(new string[] { "\r\n" }, StringSplitOptions.None);
-                        int fileNum = string.IsNullOrEmpty(lines[lines.Length - 1]) ? lines.Length - 1 : lines.Length;
-
-                        foreach (var item in lines)
+                        using (StreamReader SR = new StreamReader(file, Encoding.GetEncoding("GBK")))
                         {
-                            if (string.IsNullOrEmpty(item)) break;
-
+                            string Content = SR.ReadToEnd();
+                            SR.Close();
+                            SR.Dispose();
+                            List<Log> logArr = new List<Log>() { };
+                            string[] lines = Content.Split(new string[] { "\r\n" }, StringSplitOptions.None);
+                            int fileNum = string.IsNullOrEmpty(lines[lines.Length - 1]) ? lines.Length - 1 : lines.Length;
                             Log itemLog = new Log() { };
-
-                            if (Array.IndexOf(lines, item) == 1) itemLog.SN = item.Split(':')[1].ToString().Trim();
-
-                            if (Array.IndexOf(lines, item) == 2) itemLog.TestTime = item.Split(':')[1].Split('.')[0].ToString().Trim();
-
-                            if (Array.IndexOf(lines, item) == 3) itemLog.Result = item.Split(':')[1].ToString().Trim();
-
-                            if (Array.IndexOf(lines, item) == 4) itemLog.Side = item.Split(':')[1].ToString().Trim();
-
+                            foreach (var item in lines)
+                            {
+                                if (string.IsNullOrEmpty(item)) continue;
+
+                                if (Array.IndexOf(lines, item) == 1) itemLog.SN = item.Split(':')[1].ToString().Trim();
+                                if (Array.IndexOf(lines, item) == 2) itemLog.TestTime = item.Split(':')[1].Split('.')[0].ToString().Trim();
+                                if (Array.IndexOf(lines, item) == 3) itemLog.Result = item.Split(':')[1].ToString().Trim();
+                                if (Array.IndexOf(lines, item) == 4) itemLog.Side = item.Split(':')[1].ToString().Trim();
+
+                                if (item.IndexOf("元件位置") > -1)
+                                {
+                                    LogItem list = new LogItem();
+                                    int ind = Array.IndexOf(lines, item);
+                                    list.Location = lines[ind].Split(':')[1].ToString().Trim();
+                                    list.ReelNo = lines[ind + 1].Split(':')[1].ToString().Trim();
+                                    list.FirstType = lines[ind + 2].Split(':')[1].ToString().Trim();
+                                    list.SceondType = lines[ind + 3].Split(':')[1].ToString().Trim();
+                                    list.Name = lines[ind + 4].Split(':')[1].ToString().Trim();
+                                    itemLog.LogItemList.Add(list);
+                                }
+                            }
                             logArr.Add(itemLog);
-                        }
-                        if (logArr.Count == 0)
-                        {
-                            break;
-                        }
+                            if (logArr.Count == 0)
+                            {
+                                break;
+                            }
 
-                        if (InsertDb(logArr, file, fileNum))
-                        {
-                            if (ConsoleLog(restOfStream, file))
+                            if (InsertDb(logArr, file, fileNum))
                             {
-                                File.WriteAllText(file, string.Empty);
-                                File.Delete(file);
+                                if (ConsoleLog(Content, file, logArr[0].SN))
+                                {
+                                    File.WriteAllText(file, string.Empty);
+                                    File.Delete(file);
+                                }
                             }
                         }
+                    }
+                    else if (equiType == "Xray")
+                    {
+
                     }
                     else if(equiType == "CCD")
                     {
@@ -335,33 +354,46 @@ namespace UAS_MES_NEW.Make
             try
             {
                 StringBuilder sql = new StringBuilder();
+                StringBuilder details = new StringBuilder();
                 List<string> param = new List<string>() { };
                 foreach (var item in logs)
                 {
-                    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 
-                                        where ma_code='{ma_code.Text}' and mcd_stepcode='" + User.CurrentStepCode + "'";
-                    dt = (DataTable)dh.ExecuteSql(sqlStr, "select");
-                    BaseUtil.SetFormValue(Controls, dt);
-                    //记录操作日志
-                    LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "日志解析", "日志解析过站成功", item.SN, "");
+                    //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 
+                    //                    where ma_code='{ma_code.Text}' and mcd_stepcode='" + User.CurrentStepCode + "'";
+                    //dt = (DataTable)dh.ExecuteSql(sqlStr, "select");
+                    //BaseUtil.SetFormValue(Controls, dt);
 
                     string outMsg = "";
-                    param.Add(item.SN); 
                     param.Add(ma_code.Text);
+                    param.Add(item.SN); 
                     param.Add(User.UserSourceCode);
-                    param.Add(item.Result);
+                    param.Add(item.Result.ToUpper());
                     param.Add(item.TestTime);
                     param.Add(item.Side);
+                    param.Add(equiType);
+                    details.Clear();
+                    foreach (LogItem LI in item.LogItemList)
+                    {
+                        details.Append($"{LI.Location}/{LI.ReelNo}/{LI.FirstType}/{LI.SceondType}/{LI.Name};");
+                    }
+                    param.Add(details.ToString());
                     param.Add(outMsg);
-
                     string[] paramList = param.ToArray();
-                    dh.CallProcedure("CS_INSERT_TESTDETAIL", ref paramList);
-                    LogMessage(1, $"文件: {PathName},共{fileNum}条记录SN: {item.SN}解析已过站");
+                    dh.CallProcedure("cs_insert_testrejects", ref paramList);
+                    if(paramList[8].Substring(0, 2) == "OK")
+                    {
+                        LogMessage(1, $"文件: {item.SN} 采集成功, 测试结果为{item.Result},共{item.LogItemList.Count}条信息");
+                    }
+                    else
+                    {
+                        LogMessage(1, paramList[8]);
+                    }
                     param.Clear();
 
                     if (logs.IndexOf(item) == logs.Count - 1)
                     {
+                        LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "日志解析", "日志解析过站成功", item.SN, "");
                         return true;
                     }
                    /* if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, User.UserSourceCode, item.SN, User.UserCode, false, out omakeCode, out oMsid, out oErrorMessage))
@@ -435,19 +467,22 @@ namespace UAS_MES_NEW.Make
             }
         }
 
-        private bool ConsoleLog(string Content, string PathName)
+        private bool ConsoleLog(string Content, string PathName,string SN)
         {
             try
             {
-                string sourceDir = Path.GetDirectoryName(PathName);
+                string sourcePaht = Path.GetDirectoryName(PathName);
+                string changeName = Path.Combine(sourcePaht, $"{SN}.{currFileType}");
+
                 string newFolderName = "Logs";
-                string newFolderPath = Path.Combine(sourceDir, newFolderName);
+                string newFolderPath = Path.Combine(sourcePaht, newFolderName);
 
                 if (!Directory.Exists(newFolderPath))
                 {
                     Directory.CreateDirectory(newFolderPath);
                 }
-                string newFileName = "Log_" + Path.GetFileName(PathName);
+
+                string newFileName = "Log_" + Path.GetFileName(changeName);
                 string newFilePath = Path.Combine(newFolderPath, newFileName);
 
                 File.AppendAllText(newFilePath, Content + Environment.NewLine);
@@ -462,7 +497,6 @@ namespace UAS_MES_NEW.Make
 
         private void LogMessage(int type, string message)
         {
-
             if (type == 0)
             {
                 if (lstFiles.InvokeRequired)
@@ -624,15 +658,22 @@ namespace UAS_MES_NEW.Make
             }
         }
 
-        private class Log
+        public class Log
         {
             public string SN { set; get; }
-
             public string Result { set; get; }
-
             public string TestTime { set; get; }
-
             public string Side { set; get; }
+            public List<LogItem> LogItemList { set; get; } = new List<LogItem>();
+        }
+
+        public class LogItem
+        {
+            public string Location { set; get; }
+            public string ReelNo { set; get; }
+            public string FirstType { set; get; }
+            public string SceondType { set; get; }
+            public string Name { set; get; }
         }
     }
 }

+ 9 - 0
UAS_MES_HYSX/UAS_MES_HYSX.csproj

@@ -641,6 +641,12 @@
     <Compile Include="FunctionCode\Make\Make_OutBoxSnCheckPa.Designer.cs">
       <DependentUpon>Make_OutBoxSnCheckPa.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\Make\Make_ReadWriteInfo.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -1656,6 +1662,9 @@
     <EmbeddedResource Include="FunctionCode\Make\Make_OutBoxSnCheckPa.resx">
       <DependentUpon>Make_OutBoxSnCheckPa.cs</DependentUpon>
     </EmbeddedResource>
+    <EmbeddedResource Include="FunctionCode\Make\Make_ParseLog.resx">
+      <DependentUpon>Make_ParseLog.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="FunctionCode\Make\Make_ReadWriteInfo.resx">
       <DependentUpon>Make_ReadWriteInfo.cs</DependentUpon>
     </EmbeddedResource>