|
|
@@ -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; }
|
|
|
}
|
|
|
}
|
|
|
}
|