From 04ab768a5ff4b362f45a7b807679e4c303f2dde6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE=E7=94=B7?= <446507344@qq.com> Date: Mon, 11 Mar 2024 15:10:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=90=AA=E5=A1=91=E7=A7=B0?= =?UTF-8?q?=E9=87=8D=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Basic/ProcessParameterDAL.cs | 8 +- .../DataValidators/BFRecordValidator.cs | 108 +++++++++++++++++- .../DataValidators/ProductTimeValidator.cs | 2 + .../SlushMoldingPrintForOldNewForm.cs | 19 ++- 4 files changed, 125 insertions(+), 12 deletions(-) diff --git a/APPQ5/QMAPP.FJC.DAL/Basic/ProcessParameterDAL.cs b/APPQ5/QMAPP.FJC.DAL/Basic/ProcessParameterDAL.cs index bda3819..00742fa 100644 --- a/APPQ5/QMAPP.FJC.DAL/Basic/ProcessParameterDAL.cs +++ b/APPQ5/QMAPP.FJC.DAL/Basic/ProcessParameterDAL.cs @@ -785,7 +785,7 @@ namespace QMAPP.FJC.DAL.Basic } } - public bool BFParameterRecord(string productcode) + public DataTable BFParameterRecord(string productcode) { try { @@ -802,12 +802,12 @@ namespace QMAPP.FJC.DAL.Basic var record = session.GetTable(sql.ToString(), parameters.ToArray()); if (record.Rows.Count > 0) { - var sql2 = $"select * from T_AW_MAINOPERATION where PRODUCTCODE = '{record.Rows[0]["MainCode"].ToString() }' and WORKCELL_CODE = 'PRESS_FIT_BC316'"; + var sql2 = $"select * from T_AW_MAINOPERATION where PRODUCTCODE = '{record.Rows[0]["MainCode"].ToString() }' and WORKCELL_CODE = 'PRESS_FIT_BC316'"; var record2 = session.GetTable(sql2.ToString(), new List().ToArray()); - return record2.Rows.Count > 0; + return record2; } - return false; + return new DataTable(); } } catch (Exception ex) diff --git a/APPQ5/QMAPP.FJC.TRACING/DataValidators/BFRecordValidator.cs b/APPQ5/QMAPP.FJC.TRACING/DataValidators/BFRecordValidator.cs index f2816f1..d5dfb57 100644 --- a/APPQ5/QMAPP.FJC.TRACING/DataValidators/BFRecordValidator.cs +++ b/APPQ5/QMAPP.FJC.TRACING/DataValidators/BFRecordValidator.cs @@ -6,6 +6,9 @@ using QMAPP.FJC.TRACING.DAInterface; using QMAPP.FJC.Entity.InterfaceData; using System.Text.RegularExpressions; using QMAPP.FJC.Entity.Operation; +using QMAPP.FJC.DAL.CheckTime; +using QMAPP.FJC.Entity.CheckTime; +using System.Data; namespace QMAPP.FJC.TRACING.DataValidators { @@ -43,17 +46,47 @@ namespace QMAPP.FJC.TRACING.DataValidators productCodes.Add(product.PRODUCTCODE); var parmDAL = new DAL.Basic.ProcessParameterDAL(); - bool record = false; + var record_table = new DataTable(); + var ispass = false; foreach (var barcode in productCodes) { - record = parmDAL.BFParameterRecord(product.PRODUCTCODE); - if (record) + var record_table2 = parmDAL.BFParameterRecord(product.PRODUCTCODE); + if (record_table2.Rows.Count>0) { + record_table = record_table2; + ispass = true; break; } } - if (record) + if (ispass) { + + ProductTimeDAL dal = new ProductTimeDAL(); + ProductTime timeCheck = dal.GetTimeCheckCfg(data.WorkLocState.WORKLOC_CODE, data.DAI.DA_CODE); + if (timeCheck == null) return new ValidateResult(true, ""); + //DataTable checkTable = dal.GetConfigValue(timeCheck, data.DAValue.ToString()); + + DataRow dataRow = record_table.Rows[0]; + + var ispass3 = TimeOutCompare(dataRow["CheckColumnValue"].ToString(), timeCheck.Operator, timeCheck.Check_Value, timeCheck.Check_ValueTo, timeCheck.Check_Type); + + if (ispass3) return new ValidateResult(true, ""); + else + { + var preStatTime = DateTime.Now; + if (!DateTime.TryParse(dataRow["CheckColumnValue"].ToString(), out preStatTime)) + { + return new ValidateResult(false, $"检测值CheckColumnValue必须是DateTime类型"); + } + DateTime serviceTime = dal.GetServiceDateTime(); + TimeSpan ts = serviceTime.Subtract(preStatTime); + + return new ValidateResult(false, $"未达到{timeCheck.Operator}{(Convert.ToDecimal(timeCheck.Check_Value) / 3600).ToString("#0.0")}小时验证标准,条码时间{(Convert.ToDecimal(ts.TotalSeconds) / 3600).ToString("#0.0")}小时"); + + } + + + return new ValidateResult(true, ""); } else @@ -64,5 +97,72 @@ namespace QMAPP.FJC.TRACING.DataValidators return new ValidateResult(true, ""); } + + /// + /// 比较字符串相等 + /// + /// + /// + /// + /// + public static bool StringEqual(string pCheckColumnValue, string pOperator, string pCheck_Value) + { + return pCheckColumnValue == pCheck_Value; + } + + /// + /// 比较时间是否满足条码 + /// + /// 校验字段配置的值 + /// 操作符 + /// 验证值 + /// + public static bool TimeOutCompare(string pCheckColumnValue, string pOperator, string pCheck_Value, string pCheck_ValueTo, string pCheck_Type) + { + var preStatTime = DateTime.Now; + if (!DateTime.TryParse(pCheckColumnValue, out preStatTime)) + { + throw new Exception("检测值CheckColumnValue必须是DateTime类型"); + } + int len = 0; + if (!int.TryParse(pCheck_Value, out len)) + { + throw new Exception("验证值Check_Value必须是int类型"); + } + + int len2 = 0; + if (!string.IsNullOrEmpty(pCheck_ValueTo)) + { + if (!int.TryParse(pCheck_ValueTo, out len2)) + { + throw new Exception("验证值pCheck_ValueTo必须是int类型"); + } + } + ProductTimeDAL dal = new ProductTimeDAL(); + DateTime serviceTime = dal.GetServiceDateTime(); + TimeSpan ts = serviceTime.Subtract(preStatTime); + if (pCheck_Type == "1") + { + switch (pOperator) + { + case ">": return ts.TotalSeconds > len; + case "<": return ts.TotalSeconds < len; + case "=": return ts.TotalSeconds == len; + case ">=": return ts.TotalSeconds >= len; + case "<=": return ts.TotalSeconds <= len; + } + } + else if (pCheck_Type == "2") + { + return pCheckColumnValue == pCheck_Value; + } + else if (pCheck_Type == "3") + { + if (ts.TotalSeconds > len && ts.TotalSeconds < len2) return true; + else return false; + } + return true; + } + } } diff --git a/APPQ5/QMAPP.FJC.TRACING/DataValidators/ProductTimeValidator.cs b/APPQ5/QMAPP.FJC.TRACING/DataValidators/ProductTimeValidator.cs index cac0c7e..9c76686 100644 --- a/APPQ5/QMAPP.FJC.TRACING/DataValidators/ProductTimeValidator.cs +++ b/APPQ5/QMAPP.FJC.TRACING/DataValidators/ProductTimeValidator.cs @@ -27,6 +27,7 @@ namespace QMAPP.FJC.TRACING.DataValidators else { var pCheckColumnValue = data.DAValue.ToString().Substring(Convert.ToInt32(checktime.CodeTimeStart), Convert.ToInt32(checktime.CodeTimeNumber)); + pCheckColumnValue = pCheckColumnValue.Replace("-", "").Replace(":", ""); pCheckColumnValue = datetime(pCheckColumnValue); var gettime = string.Empty; var IsCheck = TimeOutCompare(pCheckColumnValue, checktime.Operator, checktime.Check_Value, checktime.Check_ValueTo, checktime.Check_Type,ref gettime); @@ -35,6 +36,7 @@ namespace QMAPP.FJC.TRACING.DataValidators { if (checktime.Check_Type == "1") { + gettime = (Convert.ToDouble(gettime) / 3600).ToString("0.0"); return new ValidateResult(false, string.Format("未达到时间验证标准!,设置为{0}{1}小时,当前时间为{2:0.0}小时!", checktime.Operator, time, gettime)); } else diff --git a/APPQ5/QMAPP.WinForm/Forms/Injection/SlushMoldingPrintForOldNewForm.cs b/APPQ5/QMAPP.WinForm/Forms/Injection/SlushMoldingPrintForOldNewForm.cs index c92f087..f068281 100644 --- a/APPQ5/QMAPP.WinForm/Forms/Injection/SlushMoldingPrintForOldNewForm.cs +++ b/APPQ5/QMAPP.WinForm/Forms/Injection/SlushMoldingPrintForOldNewForm.cs @@ -846,10 +846,21 @@ namespace QMAPP.WinForm.Forms.Injection WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffff") + "--预警区间--" + cfgSlushMolding2_STR); if ((SP_End2 <= Weigh_Num || Weigh_Num <= SP_Begin2) && state == true) { - this.TBRCV.Text = $"重量{Weigh_Num}!到达{SP_End2},{SP_End}预警区间!请尽快调整重量!"; - infolabel.Text = $"重量{Weigh_Num}!到达{SP_End2},{SP_End}预警区间 \r\n请尽快调整重量!"; - infolabel.ForeColor = Color.Coral; - state2 = false; + if (SP_End2 <= Weigh_Num) + { + this.TBRCV.Text = $"重量{Weigh_Num}!到达{SP_End2},{SP_End}预警区间!请尽快调整重量!"; + infolabel.Text = $"重量{Weigh_Num}!到达{SP_End2},{SP_End}预警区间 \r\n请尽快调整重量!"; + infolabel.ForeColor = Color.Coral; + state2 = false; + } + else if (Weigh_Num <= SP_Begin2) + { + this.TBRCV.Text = $"重量{Weigh_Num}!到达{SP_Begin},{SP_Begin2}预警区间!请尽快调整重量!"; + infolabel.Text = $"重量{Weigh_Num}!到达{SP_Begin},{SP_Begin2}预警区间 \r\n请尽快调整重量!"; + infolabel.ForeColor = Color.Coral; + state2 = false; + } + } if (state == true && state2 == true) {