DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DataCaptureHandler_02.cs
@@ -271,7 +271,9 @@ //获取文件夹名称 List<string> directorylist = new List<string>(); string directory = time.ToString("yyyy-MM-dd_HH"); string directoryOther = time.AddSeconds(-30).ToString("yyyy-MM-dd_HH"); //string directoryOther = time.AddSeconds(-30).ToString("yyyy-MM-dd_HH"); //改为调整30分钟前的文件夹 【Editby shaocx,2024-09-02】 string directoryOther = time.AddMinutes(-30).ToString("yyyy-MM-dd_HH"); directorylist.Add(directory); if (!directory.Equals(directoryOther)) {//如果30秒前是另一个文件夹 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DeleteDataHandler.cs
@@ -135,6 +135,34 @@ Log4NetHelper.WriteErrorLog(logType, $"处理OP80的数据(X:\\CA4GC20TD_NoNum)-定时删除数据异常:", ex); } //处理OP30的数据 try { LogTextHelper.BatchDeleteLog(@"U:\NutrunnerData\FO\SEQ_24", 20); Log4NetHelper.WriteInfoLog(logType, $"处理OP30的数据(U:\\NutrunnerData\\FO\\SEQ_24)-定时删除数据:"); } catch (Exception ex) { Log4NetHelper.WriteErrorLog(logType, $"处理OP30的数据(U:\\NutrunnerData\\FO\\SEQ_24)-定时删除数据异常:", ex); } try { LogTextHelper.BatchDeleteLog(@"U:\NutrunnerData\FO\SEQ_04", 20); Log4NetHelper.WriteInfoLog(logType, $"处理OP30的数据(U:\\NutrunnerData\\FO\\SEQ_04)-定时删除数据:"); } catch (Exception ex) { Log4NetHelper.WriteErrorLog(logType, $"处理OP30的数据(U:\\NutrunnerData\\FO\\SEQ_04)-定时删除数据异常:", ex); } try { LogTextHelper.BatchDeleteLog(@"Z:\kistler_crack", 20); Log4NetHelper.WriteInfoLog(logType, $"处理OP30的数据(Z:\\kistler_crack)-定时删除数据:"); } catch (Exception ex) { Log4NetHelper.WriteErrorLog(logType, $"处理OP30的数据(Z:\\kistler_crack)-定时删除数据异常:", ex); } try DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/Utils/SystemBussinessHelper.cs
@@ -3,8 +3,10 @@ using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices.WindowsRuntime; using System.Text; using System.Threading.Tasks; using System.Web.UI.WebControls; namespace iWare_SCADA_BusinessLogical.Utils { @@ -13,6 +15,40 @@ /// </summary> public class SystemBussinessHelper { /// <summary> /// 校验读取的二维码是否正确 /// </summary> /// <param name="workPieceID"></param> /// <returns></returns> public static bool ValidateIsRightWorkPieceID(string workPieceID) { if (string.IsNullOrEmpty(workPieceID)) { return false; } if (workPieceID.Length == 22) { var n_workPieceID = workPieceID.Trim(); if (n_workPieceID.Length == 22) { if (n_workPieceID.IndexOf("ERROR") > -1) { return false; } return true; } else { return false; } } else { return false; } } /// <summary> /// 设置 WorkPieceInfo 的DataCapturePointCname /// </summary> DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_DataCaptureV3/FormMain.cs
@@ -1991,98 +1991,98 @@ } public WorkPieceLogMiddle GetCH5Info(string FullName, WorkPieceLogMiddle wplog) { try { string fileContent = File.ReadAllText(FullName); string[] lines2 = fileContent.Split('\n'); bool IDCodeIndex = false; int Mcount = 0; int i = 0; int count = 0; foreach (string line in lines2) { count++; if (count == 4) {//获取质量结果 var list = line.Split(' '); if (list.Count() > 0) { var str = list[list.Count() - 1].ToString().Trim(); wplog.QualityStateStr = str.Equals("OK") ? "OK" : "NG"; } } // 处理每一行的逻辑 if (line.Contains("ID-Code"))//两个拧紧,每个前面都有ID-Code { i++; IDCodeIndex = true; Mcount = 0; } if (IDCodeIndex) { if (line.Contains(" M "))//第三个M行是拧紧数据 {//最终力矩 Mcount++; if (Mcount == 3) { var str = line.Replace("+", "").Replace("-", ""); var list = str.Split('M'); if (list.Count() == 4) { if (i == 1) {//CH3 wplog.QualityOP30To3 = list[2].ToString().Trim(); } else {//CH4 wplog.QualityOP30To9 = list[2].ToString().Trim(); } } IDCodeIndex = false; } } //public WorkPieceLogMiddle GetCH5Info(string FullName, WorkPieceLogMiddle wplog) //{ // try // { // string fileContent = File.ReadAllText(FullName); // string[] lines2 = fileContent.Split('\n'); // bool IDCodeIndex = false; // int Mcount = 0; // int i = 0; // int count = 0; // foreach (string line in lines2) // { // count++; // if (count == 4) // {//获取质量结果 // var list = line.Split(' '); // if (list.Count() > 0) // { // var str = list[list.Count() - 1].ToString().Trim(); // wplog.QualityStateStr = str.Equals("OK") ? "OK" : "NG"; // } // } // // 处理每一行的逻辑 // if (line.Contains("ID-Code"))//两个拧紧,每个前面都有ID-Code // { // i++; // IDCodeIndex = true; // Mcount = 0; // } // if (IDCodeIndex) // { // if (line.Contains(" M "))//第三个M行是拧紧数据 // {//最终力矩 // Mcount++; // if (Mcount == 3) // { // var str = line.Replace("+", "").Replace("-", ""); // var list = str.Split('M'); // if (list.Count() == 4) // { // if (i == 1) // {//CH3 // wplog.QualityOP30To3 = list[2].ToString().Trim(); // } // else // {//CH4 // wplog.QualityOP30To9 = list[2].ToString().Trim(); // } // } // IDCodeIndex = false; // } // } } if (line.Contains(" MWSP ")) {//终拧紧力矩 终拧紧角度 var list = line.Split(new String[] { " MWS " }, StringSplitOptions.None); if (list.Count() == 2) { if (i == 1) {//CH3 wplog.QualityOP30To4 = list[1].ToString().Trim(); } else {//CH4 wplog.QualityOP30To10 = list[1].ToString().Trim(); } var list2 = list[0].Split(new String[] { " W " }, StringSplitOptions.None); if (list2.Count() == 2) { var str = list2[1].ToString(); if (i == 1) {//CH3 wplog.QualityOP30To5 = str.Substring(0, str.IndexOf("MWSP")).Trim(); } else {//CH4 wplog.QualityOP30To11 = str.Substring(0, str.IndexOf("MWSP")).Trim(); } } } // } // if (line.Contains(" MWSP ")) // {//终拧紧力矩 终拧紧角度 // var list = line.Split(new String[] { " MWS " }, StringSplitOptions.None); // if (list.Count() == 2) // { // if (i == 1) // {//CH3 // wplog.QualityOP30To4 = list[1].ToString().Trim(); // } // else // {//CH4 // wplog.QualityOP30To10 = list[1].ToString().Trim(); // } // var list2 = list[0].Split(new String[] { " W " }, StringSplitOptions.None); // if (list2.Count() == 2) // { // var str = list2[1].ToString(); // if (i == 1) // {//CH3 // wplog.QualityOP30To5 = str.Substring(0, str.IndexOf("MWSP")).Trim(); // } // else // {//CH4 // wplog.QualityOP30To11 = str.Substring(0, str.IndexOf("MWSP")).Trim(); // } // } // } } } } catch (Exception ex) { //Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}CH5工位质量数据异常工件号:{(wplog.WorkPieceID == null ? "" : wplog.WorkPieceID)} 文件名:{FullName}:", ex); } return wplog; // } // } // } // catch (Exception ex) // { // //Log4NetHelper.WriteErrorLog(PLCManger.GetLogTypeForWorkingProcedure(WorkingProcedure), $"读取 {DataCapturePointCode}CH5工位质量数据异常工件号:{(wplog.WorkPieceID == null ? "" : wplog.WorkPieceID)} 文件名:{FullName}:", ex); // } // return wplog; } //} private void button27_Click(object sender, EventArgs e) { try DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_FormTest/Form1.Designer.cs
@@ -39,6 +39,7 @@ this.dateTimePicker_Start = new System.Windows.Forms.DateTimePicker(); this.btn_TongJi = new System.Windows.Forms.Button(); this.button5 = new System.Windows.Forms.Button(); this.button6 = new System.Windows.Forms.Button(); this.SuspendLayout(); // // button1 @@ -73,11 +74,11 @@ // // button4 // this.button4.Location = new System.Drawing.Point(76, 335); this.button4.Location = new System.Drawing.Point(76, 461); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(244, 54); this.button4.TabIndex = 3; this.button4.Text = "统计分析"; this.button4.Text = "读取OP30的质量txt文件"; this.button4.UseVisualStyleBackColor = true; this.button4.Click += new System.EventHandler(this.button4_Click); // @@ -150,11 +151,22 @@ this.button5.UseVisualStyleBackColor = false; this.button5.Click += new System.EventHandler(this.button5_Click); // // button6 // this.button6.Location = new System.Drawing.Point(76, 329); this.button6.Name = "button6"; this.button6.Size = new System.Drawing.Size(244, 54); this.button6.TabIndex = 21; this.button6.Text = "OP30测试删除文件"; this.button6.UseVisualStyleBackColor = true; this.button6.Click += new System.EventHandler(this.button6_Click); // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1307, 688); this.Controls.Add(this.button6); this.Controls.Add(this.button5); this.Controls.Add(this.tb_TongJi); this.Controls.Add(this.checkBox_NowDay); @@ -186,6 +198,7 @@ private System.Windows.Forms.DateTimePicker dateTimePicker_Start; private System.Windows.Forms.Button btn_TongJi; private System.Windows.Forms.Button button5; private System.Windows.Forms.Button button6; } } DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_FormTest/Form1.cs
@@ -1,4 +1,5 @@ using iWare_SCADA_BusinessLogical.Utils; using iWare_SCADA_BusinessLogical; using iWare_SCADA_BusinessLogical.Utils; using iWare_SCADA_Model; using System; using System.Collections.Generic; @@ -102,7 +103,10 @@ private void button4_Click(object sender, EventArgs e) { string paht = "C:\\Users\\Administrator\\Desktop\\临时\\aa\\FO_000006966558.txt"; DataCaptureHandler_02 dataCaptureHandler_02 = new DataCaptureHandler_02(); dataCaptureHandler_02.GetCH5InfoForOP30(paht, new WorkPieceLogMiddle()); } private void btn_TongJi_Click(object sender, EventArgs e) @@ -313,5 +317,29 @@ } return new_strList; } private void button6_Click(object sender, EventArgs e) { try { string path = @"U:\\NutrunnerData\\FO\\SEQ_24"; var newFiles = FileHelper.DetectNewFiles(path, "*.dfq", 300, DateTime.Now.AddDays(-100), DateTime.Now.AddDays(1)); foreach (System.IO.FileInfo file in newFiles) { //MessageBox.Show("找到文件:" + file.FullName); var toPath = file.FullName.Replace("Measuring_Data_df_Test", "Measuring_Data_df_Copy"); //MessageBox.Show("要移动到:" + file.FullName); File.Move(file.FullName, toPath);//移动 } MessageBox.Show("成功"); } catch (Exception ex) { MessageBox.Show("异常:" + ex.Message); } } } } DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/MiddleModel/WorkPieceLogMiddle.cs
@@ -211,29 +211,54 @@ public string QualityOP20To1 { get; set; } /// <summary> /// 涨断力矩 /// </summary> public string QualityOP30To1 { get; set; } /// <summary> /// 预拧紧力矩(CH1) /// </summary> public string QualityOP30To2 { get; set; } /// <summary> /// 最终力矩(CH3) /// </summary> public string QualityOP30To3 { get; set; } /// <summary> /// 终拧紧力矩(CH3) /// </summary> public string QualityOP30To4 { get; set; } /// <summary> /// 终拧紧角度(CH3) /// </summary> public string QualityOP30To5 { get; set; } /// <summary> /// 衬套压装力矩 /// </summary> public string QualityOP30To6 { get; set; } public string QualityOP30To7 { get; set; } /// <summary> /// 预拧紧力矩(CH2) /// </summary> public string QualityOP30To8 { get; set; } /// <summary> /// 最终力矩(CH4) /// </summary> public string QualityOP30To9 { get; set; } /// <summary> /// 终拧紧力矩(CH4) /// </summary> public string QualityOP30To10 { get; set; } /// <summary> /// 终拧紧角度(CH4) /// </summary> public string QualityOP30To11 { get; set; } /// <summary>