Updated WO_LOG_ACTIONS to also set the legacy status field in the WO_LOG table. Updated GetIQSViolationData to only update the Reactor record if something has changed.
This commit is contained in:
@ -3754,12 +3754,16 @@ Service UpdateReactorIQSViolations()
|
|||||||
// Clear last active alarm
|
// Clear last active alarm
|
||||||
HaveLock = Database_Services('GetKeyIDLock', 'REACTOR', ReactNo, True$)
|
HaveLock = Database_Services('GetKeyIDLock', 'REACTOR', ReactNo, True$)
|
||||||
If HaveLock then
|
If HaveLock then
|
||||||
ReactorRec = Database_Services('ReadDataRow', 'REACTOR', ReactNo)
|
ReactorRec = Database_Services('ReadDataRow', 'REACTOR', ReactNo)
|
||||||
If Error_Services('NoError') then
|
If Error_Services('NoError') then
|
||||||
ReactorRec<REACTOR_IQS_ALARM_DTM$> = ''
|
CurrAlarmDtm = ReactorRec<REACTOR_IQS_ALARM_DTM$>
|
||||||
ReactorRec<REACTOR_IQS_ALARM_TEST$> = ''
|
CurrAlarmTest = ReactorRec<REACTOR_IQS_ALARM_TEST$>
|
||||||
// WriteDataRow will clear the lock as long as "IgnoreAllLocks" is false
|
If ( (CurrAlarmDtm NE '') or (CurrAlarmTest NE '') ) then
|
||||||
Database_Services('WriteDataRow', 'REACTOR', ReactNo, ReactorRec, True$, False$, False$)
|
ReactorRec<REACTOR_IQS_ALARM_DTM$> = ''
|
||||||
|
ReactorRec<REACTOR_IQS_ALARM_TEST$> = ''
|
||||||
|
// WriteDataRow will clear the lock as long as "IgnoreAllLocks" is false
|
||||||
|
Database_Services('WriteDataRow', 'REACTOR', ReactNo, ReactorRec, True$, False$, False$)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -223,17 +223,27 @@ WRITE_RECORD_PRE:
|
|||||||
SaveRecord = Record
|
SaveRecord = Record
|
||||||
end
|
end
|
||||||
|
|
||||||
EntryDate = Record<WO_LOG_ENTRY_DATE$>
|
// Check if we need to auto-close the work order
|
||||||
Today = Date()
|
EntryDate = Record<WO_LOG_ENTRY_DATE$>
|
||||||
YearsOpen = SRP_Date('YearSpan', EntryDate, Today, True$)
|
Today = Date()
|
||||||
ScrapQty = Record<WO_LOG_SCRAP_QTY_STATIC$>
|
YearsOpen = SRP_Date('YearSpan', EntryDate, Today, True$)
|
||||||
ShipQty = Record<WO_LOG_SHIP_QTY_STATIC$>
|
ScrapQty = Record<WO_LOG_SCRAP_QTY_STATIC$>
|
||||||
CurrStatus = Record<WO_LOG_CURR_STATUS_STATIC$>
|
ShipQty = Record<WO_LOG_SHIP_QTY_STATIC$>
|
||||||
CloseDate = Record<WO_LOG_CLOSE_DATE$>
|
CurrStatus = Record<WO_LOG_CURR_STATUS_STATIC$>
|
||||||
If ( ( (CurrStatus NE 'CL') or (CloseDate EQ '') ) and ( ( (ScrapQty + ShipQty) GE NewQty ) or (YearsOpen GE 3) ) ) then
|
CloseDate = Record<WO_LOG_CLOSE_DATE$>
|
||||||
// Auto-close the work order
|
LegacyStatus = Record<WO_LOG_STATUS$>
|
||||||
Record<WO_LOG_CLOSE_DATE$> = Date()
|
If ( ( (CurrStatus NE 'CL') or (CloseDate EQ '') or (LegacyStatus NE 'C') ) and ( ( (ScrapQty + ShipQty) GE NewQty ) or (YearsOpen GE 1) ) ) then
|
||||||
Record<WO_LOG_CURR_STATUS_STATIC$> = 'CL'
|
If (CloseDate EQ '') then Record<WO_LOG_CLOSE_DATE$> = Date()
|
||||||
|
If (CurrStatus NE 'CL') then Record<WO_LOG_CURR_STATUS_STATIC$> = 'CL'
|
||||||
|
If (LegacyStatus NE 'C') then Record<WO_LOG_STATUS$> = '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<WO_LOG_CLOSE_DATE$> = Date()
|
||||||
|
If (CurrStatus NE 'CL') then Record<WO_LOG_CURR_STATUS_STATIC$> = 'CL'
|
||||||
|
If (LegacyStatus NE 'C') then Record<WO_LOG_STATUS$> = 'C'
|
||||||
SaveRecord = Record
|
SaveRecord = Record
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user