diff --git a/LSL2/STPROC/REACTOR_SERVICES.txt b/LSL2/STPROC/REACTOR_SERVICES.txt index 1a815cc..425fa98 100644 --- a/LSL2/STPROC/REACTOR_SERVICES.txt +++ b/LSL2/STPROC/REACTOR_SERVICES.txt @@ -3754,12 +3754,16 @@ Service UpdateReactorIQSViolations() // Clear last active alarm HaveLock = Database_Services('GetKeyIDLock', 'REACTOR', ReactNo, True$) If HaveLock then - ReactorRec = Database_Services('ReadDataRow', 'REACTOR', ReactNo) + ReactorRec = Database_Services('ReadDataRow', 'REACTOR', ReactNo) If Error_Services('NoError') then - ReactorRec = '' - ReactorRec = '' - // WriteDataRow will clear the lock as long as "IgnoreAllLocks" is false - Database_Services('WriteDataRow', 'REACTOR', ReactNo, ReactorRec, True$, False$, False$) + CurrAlarmDtm = ReactorRec + CurrAlarmTest = ReactorRec + If ( (CurrAlarmDtm NE '') or (CurrAlarmTest NE '') ) then + ReactorRec = '' + ReactorRec = '' + // WriteDataRow will clear the lock as long as "IgnoreAllLocks" is false + Database_Services('WriteDataRow', 'REACTOR', ReactNo, ReactorRec, True$, False$, False$) + end end end end diff --git a/LSL2/STPROC/WO_LOG_ACTIONS.txt b/LSL2/STPROC/WO_LOG_ACTIONS.txt index 79f3056..3a7d6e1 100644 --- a/LSL2/STPROC/WO_LOG_ACTIONS.txt +++ b/LSL2/STPROC/WO_LOG_ACTIONS.txt @@ -223,17 +223,27 @@ WRITE_RECORD_PRE: SaveRecord = Record end - EntryDate = Record - Today = Date() - YearsOpen = SRP_Date('YearSpan', EntryDate, Today, True$) - ScrapQty = Record - ShipQty = Record - CurrStatus = Record - CloseDate = Record - If ( ( (CurrStatus NE 'CL') or (CloseDate EQ '') ) and ( ( (ScrapQty + ShipQty) GE NewQty ) or (YearsOpen GE 3) ) ) then - // Auto-close the work order - Record = Date() - Record = 'CL' + // Check if we need to auto-close the work order + EntryDate = Record + Today = Date() + YearsOpen = SRP_Date('YearSpan', EntryDate, Today, True$) + ScrapQty = Record + ShipQty = Record + CurrStatus = Record + CloseDate = Record + LegacyStatus = Record + If ( ( (CurrStatus NE 'CL') or (CloseDate EQ '') or (LegacyStatus NE 'C') ) and ( ( (ScrapQty + ShipQty) GE NewQty ) or (YearsOpen GE 1) ) ) then + If (CloseDate EQ '') then Record = Date() + If (CurrStatus NE 'CL') then Record = 'CL' + If (LegacyStatus NE 'C') then Record = 'C' + SaveRecord = Record + end + + // For work orders already closed, ensure CurrStatus, LegacyStatus, and Close date are consistent + If ( (CurrStatus EQ 'CL') or (CloseDate NE '') or (LegacyStatus EQ 'C') ) then + If (CloseDate EQ '') then Record = Date() + If (CurrStatus NE 'CL') then Record = 'CL' + If (LegacyStatus NE 'C') then Record = 'C' SaveRecord = Record end