|
|
@ -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, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 比较字符串相等
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="pCheckColumnValue"></param>
|
|
|
|
/// <param name="pOperator"></param>
|
|
|
|
/// <param name="pCheck_Value"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public static bool StringEqual(string pCheckColumnValue, string pOperator, string pCheck_Value) |
|
|
|
{ |
|
|
|
return pCheckColumnValue == pCheck_Value; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 比较时间是否满足条码
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="pCheckColumnValue">校验字段配置的值</param>
|
|
|
|
/// <param name="pOperator">操作符</param>
|
|
|
|
/// <param name="pCheck_Value">验证值</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
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; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|