Production tracing bug fix : Previous workstep result was not checked, mere existence of a record was sufficient for a WM to pass
This commit is contained in:
parent
b56f712c71
commit
23f9331460
@ -35,6 +35,7 @@ namespace TBF.Rig.Output.DB.ProductionTracing
|
||||
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
|
||||
|
||||
public const string WorkstepName = "Test_bench";
|
||||
public const int WorkstepRsltOK = 0;
|
||||
|
||||
MonitoringCfg tracingCfg;
|
||||
string workplace
|
||||
@ -394,22 +395,23 @@ namespace TBF.Rig.Output.DB.ProductionTracing
|
||||
Workstep workstep = null;
|
||||
|
||||
ProjectionList projections = Projections.ProjectionList();
|
||||
projections.Add(Projections.Property(() => refRecord.Id)); /// rslt[0] = reference record ID
|
||||
projections.Add(Projections.Property(() => workstep.Id)); /// rslt[1] = workstep ID
|
||||
projections.Add(Projections.Property(() => refRecord.Process.Id)); /// rslt[2] = process ID
|
||||
projections.Add(Projections.Property(() => refRecord.TimeStamp)); /// rslt[3] = reference record time stamp
|
||||
projections.Add(Projections.Property(() => refRecord.Id)); /// rcrd[0] = reference record ID
|
||||
projections.Add(Projections.Property(() => workstep.Id)); /// rcrd[1] = workstep ID
|
||||
projections.Add(Projections.Property(() => refRecord.Process.Id)); /// rcrd[2] = process ID
|
||||
projections.Add(Projections.Property(() => refRecord.TimeStamp)); /// rcrd[3] = reference record time stamp
|
||||
projections.Add(Projections.Property(() => refRecord.Result)); /// rcrd[4] = result: =0...OK, >0...error code
|
||||
|
||||
///
|
||||
/// Get all reference records with Code == SerialNr from all worksteps different from 'Test_bench'
|
||||
///
|
||||
IList<object[]> results = session.QueryOver<ReferenceRecord>(() => refRecord)
|
||||
IList<object[]> records = session.QueryOver<ReferenceRecord>(() => refRecord)
|
||||
.Where(rr => (rr.Code == wm.SerialNr))
|
||||
.JoinQueryOver<Workstep>(rr => rr.Workstep, () => workstep)
|
||||
.And(ws => (ws.Name != WorkstepName))
|
||||
.Select(projections)
|
||||
.List<object[]>();
|
||||
|
||||
if (results.Count == 0)
|
||||
if (records.Count == 0)
|
||||
{
|
||||
/// No records found
|
||||
wm.ProcessId = 0;
|
||||
@ -422,27 +424,29 @@ namespace TBF.Rig.Output.DB.ProductionTracing
|
||||
///
|
||||
/// Get processId of the last record
|
||||
///
|
||||
int processId = 0;
|
||||
int lastProcessId = 0;
|
||||
int lastResult = 0;
|
||||
DateTime lastTimeStamp = DateTime.MinValue;
|
||||
foreach (var rslt in results)
|
||||
foreach (var rcrd in records)
|
||||
{
|
||||
if (DateTime.Compare((DateTime)rslt[3], lastTimeStamp) > 0)
|
||||
if (DateTime.Compare((DateTime)rcrd[3], lastTimeStamp) > 0)
|
||||
{
|
||||
lastTimeStamp = (DateTime)rslt[3];
|
||||
processId = (int)rslt[2];
|
||||
lastTimeStamp = (DateTime)rcrd[3];
|
||||
lastProcessId = (int)rcrd[2];
|
||||
lastResult = (int)rcrd[4];
|
||||
}
|
||||
}
|
||||
|
||||
if (processId == 0) return Retv.Error; /// This should never happen
|
||||
if (lastProcessId == 0) return Retv.Error; /// This should never happen
|
||||
|
||||
|
||||
if ((currentProcess == null) || (currentProcess.Id != processId))
|
||||
if ((currentProcess == null) || (currentProcess.Id != lastProcessId))
|
||||
{
|
||||
///
|
||||
/// Process changed ==> update currentProcess / currentWorkstep / verifiedWorkstep / verifiedPart / verifyReferencePart
|
||||
///
|
||||
var processes = session.QueryOver<Process>()
|
||||
.Where(p => (p.Id == processId))
|
||||
.Where(p => (p.Id == lastProcessId))
|
||||
.List();
|
||||
|
||||
if (processes.Count != 1) return Retv.Error;
|
||||
@ -472,9 +476,9 @@ namespace TBF.Rig.Output.DB.ProductionTracing
|
||||
wm.ProcessId = currentProcess.Id;
|
||||
wm.SessionId = sessionId;
|
||||
wm.LastRecordIsNok = true; /// NOK (=default if no matching record found)
|
||||
foreach (var rslt in results)
|
||||
foreach (var rcrd in records)
|
||||
{
|
||||
if ((verifiedWorkstep.Id == (int)rslt[1]) && (processId == (int)rslt[2]))
|
||||
if ((verifiedWorkstep.Id == (int)rcrd[1]) && (lastProcessId == (int)rcrd[2]) && (int)rcrd[4] == WorkstepRsltOK)
|
||||
{
|
||||
/// This record fits verification requirements
|
||||
wm.LastRecordIsNok = false; /// OK
|
||||
|
||||
Loading…
Reference in New Issue
Block a user