Added calls to verify indexes and update indexes right after receiving and releasing material. Refactored codebase to adjust work order quantities instead of recalculate quantities.

Removing reliance on transaction queue for receive and releaase

Added unlock call in case write fails
This commit is contained in:
Infineon\StieberD
2025-09-30 13:45:55 -07:00
parent a2f61d11c9
commit beaac0d38a
17 changed files with 1272 additions and 778 deletions

View File

@ -3719,6 +3719,226 @@ Service SendRefreshMessage()
end service
Service AdjustWorkOrderScheduleQty(WONo, ModifyQty)
ErrorMsg = ''
Begin Case
Case (WONo EQ '')
ErrorMsg = 'Error in ':Service:' service. WONo cannot be null.'
Case (ModifyQty EQ '')
ErrorMsg = 'Error in ':Service:' service. ModifyQty cannot be null.'
End Case
If (ErrorMsg EQ '') then
WOQty = Xlate('WO_LOG', WONo, 'WO_QTY', 'X')
OrigQty = WOQty - ModifyQty
NewQty = WOQty + ModifyQty
SchedDetNGKey = ''
Begin Case
Case ModifyQty GT 0
LogData = ''
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<2> = 'WO_LOG_ACTIONS'
LogData<3> = 'Work order ':WONo:' quantity increased from ':OrigQty:' to ':NewQty:'.'
Schedule_Services('LogActivity', '', LogData, False$)
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Searching for a scheduled event to increase the quantity.'
Schedule_Services('LogActivity', '', LogData, False$)
// Search schedule for most recent event and increase that event quantity by the difference.
Query = 'SELECT SCHED_DET_NG WITH WO_NO EQ ':WONo:' BY-DSND STOP_DTM'
GoSub ClearCursors
Set_Status(0)
RList(Query, TARGET_ACTIVELIST$, '', '', False$)
errCode = ''
If Get_Status(errCode) then
ErrorMsg = 'Error retrieving event list in WO_LOG_Actions. RList error code ':errCode:'.'
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = ErrorMsg
Schedule_Services('LogActivity', '', LogData, False$)
Error_Services('Add', ErrorMsg)
end else
EOF = False$
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Query successful. Number of keys found: ':@RecCount:'.'
Schedule_Services('LogActivity', '', LogData, False$)
ReadNext SchedDetNGKey else EOF = True$
If SchedDetNGKey NE '' then
EventRec = Database_Services('ReadDataRow', 'SCHED_DET_NG', SchedDetNGKey)
StopDTM = EventRec<SCHED_DET_NG.STOP_DTM$>
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Work order record ':WONo:' quantity increased from ':OrigQty:' to ':NewQty:'.'
Schedule_Services('LogActivity', EventRec<SCHED_DET_NG.REACT_NO$>, LogData, False$)
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Scheduled event ':SchedDetNGKey:' found.'
Schedule_Services('LogActivity', EventRec<SCHED_DET_NG.REACT_NO$>, LogData, False$)
// Only modify the event if it is still running or is scheduled in the future.
If StopDTM GT Datetime() then
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Event stop DTM ':OConv(StopDtm, 'DT2/^H'):' less than current DTM, so increasing event quantity.'
Schedule_Services('LogActivity', EventRec<SCHED_DET_NG.REACT_NO$>, LogData, False$)
ReactNo = EventRec<SCHED_DET_NG.REACT_NO$>
WONo = EventRec<SCHED_DET_NG.WO_NO$>
StartDTM = EventRec<SCHED_DET_NG.START_DTM$>
Desc = EventRec<SCHED_DET_NG.DESC$>
EventQty = EventRec<SCHED_DET_NG.EVENT_TOTAL_WFRS$>
NewEventQty = EventQty + ModifyQty
Schedule_Services('ModifySchedEvent', SchedDetNGKey, ReactNo, WONo, StartDTM, StopDTM, Desc, NewEventQty)
// Adjust reactor events as needed.
Schedule_Services('AdjustScheduleEvents', ReactNo)
end else
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Event stop DTM ':OConv(StopDtm, 'DT2/^H'):' greater than current DTM.'
Schedule_Services('LogActivity', EventRec<SCHED_DET_NG.REACT_NO$>, LogData, False$)
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Event quantity not increased.'
Schedule_Services('LogActivity', EventRec<SCHED_DET_NG.REACT_NO$>, LogData, False$)
end
end
end
GoSub ClearCursors
Case ModifyQty LT 0
LogData = ''
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<2> = 'WO_LOG_ACTIONS'
LogData<3> = 'Work order ':WONo:' quantity decreased from ':OrigQty:' to ':NewQty:'.'
Schedule_Services('LogActivity', '', LogData, False$)
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Searching for a scheduled event to decrease the quantity.'
Schedule_Services('LogActivity', '', LogData, False$)
// Search schedule for most recent events and decrease/delete those events as needed.
Query = 'SELECT SCHED_DET_NG WITH WO_NO EQ ':WONo:' BY-DSND STOP_DTM'
GoSub ClearCursors
Set_Status(0)
RList(Query, TARGET_ACTIVELIST$, '', '', False$)
errCode = ''
If Get_Status(errCode) then
ErrorMsg = 'Error retrieving event list in WO_LOG_Actions. RList error code ':errCode:'.'
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = ErrorMsg
Schedule_Services('LogActivity', '', LogData, False$)
Error_Services('Add', ErrorMsg)
end else
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Query successful. Number of keys found: ':@RecCount:'.'
Schedule_Services('LogActivity', '', LogData, False$)
EOF = False$
Done = False$
UpdateReq = False$
Loop
ReadNext SchedDetNGKey else EOF = True$
Until EOF EQ True$
If SchedDetNGKey NE '' then
EventRec = Database_Services('ReadDataRow', 'SCHED_DET_NG', SchedDetNGKey)
StopDTM = EventRec<SCHED_DET_NG.STOP_DTM$>
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Work order record ':WONo:' quantity decreased from ':OrigQty:' to ':NewQty:'.'
Schedule_Services('LogActivity', EventRec<SCHED_DET_NG.REACT_NO$>, LogData, False$)
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Scheduled event ':SchedDetNGKey:' found.'
Schedule_Services('LogActivity', EventRec<SCHED_DET_NG.REACT_NO$>, LogData, False$)
// Only modify the event if it is still running or is scheduled in the future.
If StopDTM GT Datetime() then
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Event stop DTM ':OConv(StopDtm, 'DT2/^H'):' less than current DTM, so decreasing event quantity.'
Schedule_Services('LogActivity', EventRec<SCHED_DET_NG.REACT_NO$>, LogData, False$)
UpdateReq = True$
ReactNo = EventRec<SCHED_DET_NG.REACT_NO$>
WONo = EventRec<SCHED_DET_NG.WO_NO$>
StartDTM = EventRec<SCHED_DET_NG.START_DTM$>
Desc = EventRec<SCHED_DET_NG.DESC$>
EventQty = EventRec<SCHED_DET_NG.EVENT_TOTAL_WFRS$>
If EventQty GT Abs(ModifyQty) then
// This event has enough wafers, so just reduce the quantity.
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Event quantity ':EventQty:' greater than quantity reduction ':ModifyQty:', so decreasing event quantity.'
Schedule_Services('LogActivity', EventRec<SCHED_DET_NG.REACT_NO$>, LogData, False$)
Done = True$
NewEventQty = EventQty + ModifyQty
Schedule_Services('ModifySchedEvent', SchedDetNGKey, ReactNo, WONo, StartDTM, StopDTM, Desc, NewEventQty)
end else
// This event has fewer wafers than are being removed. Delete this event and continue
// onto the next event.
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Event quantity ':EventQty:' less than quantity reduction ':ModifyQty:', so canceling event.'
Schedule_Services('LogActivity', EventRec<SCHED_DET_NG.REACT_NO$>, LogData, False$)
Schedule_Services('CancelScheduleEvent', SchedDetNGKey, True$)
ModifyQty += EventQty
end
end else
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Event stop DTM ':OConv(StopDtm, 'DT2/^H'):' greater than current DTM.'
Schedule_Services('LogActivity', EventRec<SCHED_DET_NG.REACT_NO$>, LogData, False$)
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Event quantity not decreased.'
Schedule_Services('LogActivity', EventRec<SCHED_DET_NG.REACT_NO$>, LogData, False$)
end
end
Until Done EQ True$
Repeat
If UpdateReq then
// Adjust reactor events as needed.
Schedule_Services('AdjustScheduleEvents', ReactNo)
end
end
GoSub ClearCursors
Case Otherwise$
Null
End Case
end
If ErrorMsg NE '' then Error_Services('Add', ErrorMsg)
end service
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Internal GoSubs
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////