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
|
||||
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<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$)
|
||||
CurrAlarmDtm = ReactorRec<REACTOR_IQS_ALARM_DTM$>
|
||||
CurrAlarmTest = ReactorRec<REACTOR_IQS_ALARM_TEST$>
|
||||
If ( (CurrAlarmDtm NE '') or (CurrAlarmTest NE '') ) then
|
||||
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
|
||||
|
@ -223,17 +223,27 @@ WRITE_RECORD_PRE:
|
||||
SaveRecord = Record
|
||||
end
|
||||
|
||||
EntryDate = Record<WO_LOG_ENTRY_DATE$>
|
||||
Today = Date()
|
||||
YearsOpen = SRP_Date('YearSpan', EntryDate, Today, True$)
|
||||
ScrapQty = Record<WO_LOG_SCRAP_QTY_STATIC$>
|
||||
ShipQty = Record<WO_LOG_SHIP_QTY_STATIC$>
|
||||
CurrStatus = Record<WO_LOG_CURR_STATUS_STATIC$>
|
||||
CloseDate = Record<WO_LOG_CLOSE_DATE$>
|
||||
If ( ( (CurrStatus NE 'CL') or (CloseDate EQ '') ) and ( ( (ScrapQty + ShipQty) GE NewQty ) or (YearsOpen GE 3) ) ) then
|
||||
// Auto-close the work order
|
||||
Record<WO_LOG_CLOSE_DATE$> = Date()
|
||||
Record<WO_LOG_CURR_STATUS_STATIC$> = 'CL'
|
||||
// Check if we need to auto-close the work order
|
||||
EntryDate = Record<WO_LOG_ENTRY_DATE$>
|
||||
Today = Date()
|
||||
YearsOpen = SRP_Date('YearSpan', EntryDate, Today, True$)
|
||||
ScrapQty = Record<WO_LOG_SCRAP_QTY_STATIC$>
|
||||
ShipQty = Record<WO_LOG_SHIP_QTY_STATIC$>
|
||||
CurrStatus = Record<WO_LOG_CURR_STATUS_STATIC$>
|
||||
CloseDate = Record<WO_LOG_CLOSE_DATE$>
|
||||
LegacyStatus = Record<WO_LOG_STATUS$>
|
||||
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<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
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user