Merged PR 20879: Initial commit.

Initial commit.
This commit is contained in:
Ouellette Jonathan (CSC FI SPS MESLEO)
2025-07-14 20:55:07 +02:00
parent 804b590773
commit b53e805929
9 changed files with 339 additions and 223 deletions

View File

@ -46,15 +46,16 @@ $insert COMPANY_EQUATES
$Insert NOTIFICATION_EQUATES
$Insert WM_IN_EQUATES
$Insert WM_OUT_EQUATES
$Insert VOIDED_LOT_EQUATES
Declare subroutine Error_Services, Work_Order_Services, Memory_Services, RList, Database_Services, SRP_JSON
Declare subroutine Btree.Extract, Set_Status, obj_WO_Log, obj_Notes, Print_Wo_Mat_In_Labels, Print_Wo_Mat_Out_Labels
Declare subroutine Print_Wmi_Labels, Print_Wmo_Labels, ErrMsg, Print_Cass_Labels, Logging_Services, Service_Services
Declare subroutine obj_WO_Mat_Log, WO_Mat_Services, Work_Order_Services, Transaction_Services, Extract_Si_Keys
Declare subroutine Mona_Services
Declare subroutine Mona_Services, Lot_Event_Services, RDS_Services, Lot_Services, WM_In_Services, WM_Out_Services
Declare function SRP_Array, Work_Order_Services, Memory_Services, Database_Services, SRP_Sort_Array, SRP_JSON
Declare function Company_Services, obj_Prod_Spec, Schedule_Services, Datetime, obj_WO_Log, obj_WO_Step, Memberof
Declare function Environment_Services, Logging_Services, Hold_Services, Signature_Services
Declare function Environment_Services, Logging_Services, Hold_Services, Signature_Services, Lot_Services, RTI_CreateGUID
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\WO_LOG'
LogDate = Oconv(Date(), 'D4/')
@ -1296,78 +1297,222 @@ Service RemoveWoMatCassetteFromWO(WoMatKey, Username)
end service
Service CreateVoidedLotRecord(LotId, LegacyLotId, LegacyLotType, WoMatKey, UserId)
//Todo: Move to Lot_Services
ErrorMessage = ''
Service SignVoidNonEpp(WOMatKey, Username)
If LotId NE '' OR LegacyLotId NE '' then
If LotId EQ '' then
//Determine NG Lot id if none was passed to routine.
if LegacyLotType NE '' then
if LegacyLotType EQ 'RDS' OR LegacyLotType EQ 'WM_IN' OR LegacyLotType EQ 'WM_OUT' then
LotId = Lot_Services('GetLotIdByLegacyLotIdAndType', LegacyLotId, LegacyLotType)
If Error_Services('NoError') then
If LotID EQ '' then
//No Lot ID was found, lets create one.
LotId = Lot_Services('CreateNewLot', 'RDS', '', '', '', '', '', UserId, '', LegacyLotId)
If Error_Services('HasError') then
ErrorMessage = Error_Services('GetMessage')
end
end
end else
ErrorMessage = Error_Services('GetMessage')
end
end else
ErrorMessage = 'Invalid Legacy Lot Type passed to routine.'
end
end else
ErrorMessage = 'A Legacy lot ID was passed to the routine, but the legacy lot type was null.'
end
end
If ErrorMessage NE '' then
If RowExists('LOT', LotId) then
NewVoidedLotId = RTI_CreateGUID()
NewVoidedLotRec = ''
NewVoidedLotRec<VOIDED_LOT_WORK_ORDER_LOG_ID$> = Field(WoMatKey, '*', 1)
NewVoidedLotRec<VOIDED_LOT_VOID_BY$> = UserId
NewVoidedLotRec<VOIDED_LOT_VOID_DTM$> = Datetime()
NewVoidedLotRec<VOIDED_LOT_ENTITY_TYPE$> = LegacyLotType
NewVoidedLotRec<VOIDED_LOT_LOT_ID$> = LotId
NewVoidedLotRec<VOIDED_LOT_LEGACY_LOT_ID$> = LegacyLotId
NewVoidedLotRec<VOIDED_LOT_WO_MAT_KEY$> = WoMatKey
Database_Services('WriteDataRow', 'VOIDED_LOT', NewVoidedLotId, NewVoidedLotRec)
If Error_Services('HasError') then
ErrorMessage = Error_Services('GetMessage')
end
end else
ErrorMessage = 'Unable to find lot record.'
end
end
end else
ErrorMessage = 'Both the lot id and the legacy lot id were null.'
end
If ErrorMessage NE '' then
Error_Services('Add', ErrorMessage)
end
end service
Service IsLotVoided(LotId)
//Todo: Move to Lot_Services
ErrorMessage = ''
VoidLotRecords = ''
Open 'DICT.VOIDED_LOT' to hVoidTable then
SearchString = 'LOT_ID':@VM:LotId:@FM
Btree.Extract(SearchString, 'VOIDED_LOTS', hVoidTable, VoidLotRecord)
end else
ErrorMessage = 'Unable to open VOIDED_LOT table.'
end
If ErrorMessage NE '' then
Error_Services('Add', ErrorMessage)
end
Response = VoidLotRecords
end service
Service SignVoidNonEpp(WOMatKeys, WONo, Username)
ErrorMessage = ''
WONo = Field(WOMatKey, '*', 1)
CassNo = Field(WoMatKey, '*', 2)
ReactType = XLATE('WO_LOG', WONo, WO_LOG_REACT_TYPE$, 'X')
If ReactType EQ 'ASM' OR ReactType EQ 'ASM+' OR ReactType EQ 'HTR' then
RDSNo = Database_Services('ReadDataColumn', 'WO_MAT', WoMatKey, WO_MAT_RDS_NO$, True$, 0, False$)
If Error_Services('NoError') then
WoMatRec = Database_Services('ReadDataRow', 'WO_MAT', WoMatKey, True$, 0, False$)
IsVoided = WoMatRec<WO_MAT_VOID$>
If Not(IsVoided) then
IsOnHold = Hold_Services('CheckForHold', WoMatKey)
If Not(IsOnHold) then
Service_Services('PostProcedure', 'WORK_ORDER_SERVICES', 'RemoveWoMatCassetteFromWO':@vm:WOMatKey:@vm:Username)
If Error_Services('NoError') then
Service_Services('PostProcedure', 'WO_MAT_SERVICES', 'SetWoMatVoidFlag':@vm:WOMatKey:@VM:Username)
if Error_Services('NoError') then
Service_Services('PostProcedure', 'RDS_SERVICES', 'DetachRDSFromWO':@vm:RDSNo)
If Error_Services('NoError') then
LotEventParams = ''
LotEventParams<1,1> = 'CreateLotEvent' ; //Service Module
LotEventParams<1,2> = ''; //Legacy Lot Id, set below
LotEventParams<1,3> = DateTime(); //Datetime
LotEventParams<1,4> = 'VOID'; //Event Type
LotEventParams<1,5> = 'Lot voided by ' : Username; //Event Note
LotEventParams<1,6> = ''; //Equipment id
LotEventParams<1,7> = Username ;//User Id
LotEventParams<1,8> = True$; //IsLegacyLotId
LotEventParams<1,9> = ''; //Legacy Lot Type, set below
If RDSNo NE '' then
LotEventParams<1,2> = RDSNo
LotEventParams<1,9> = 'RDS'; //Legacy Lot Type
Service_Services('PostProcedure', 'LOT_EVENT_SERVICES', LotEventParams)
WOLogRecord = Database_Services('ReadDataRow', 'WO_LOG', WONo, True$, 0, False$)
if Error_Services('NoError') then
for each WoMatKey in WOMatKeys using @VM
if WoMatKey NE '' then
CassNo = Field(WoMatKey, '*', 2)
ReactType = XLATE('WO_LOG', WONo, WO_LOG_REACT_TYPE$, 'X')
If ReactType EQ 'ASM' OR ReactType EQ 'ASM+' OR ReactType EQ 'HTR' then
RDSNo = Database_Services('ReadDataColumn', 'WO_MAT', WoMatKey, WO_MAT_RDS_NO$, True$, 0, False$)
If Error_Services('NoError') then
If WoLogRecord<WO_LOG_WO_MAT_KEY$> NE '' then
Locate WoMatKey in WoLogRecord<WO_LOG_WO_MAT_KEY$> using @VM setting CassPos then
WoLogRecord<WO_LOG_WO_MAT_KEY$> = Delete(WOLogRecord<WO_LOG_WO_MAT_KEY$>, 1, CassPos, 0)
WO_Mat_Services('SetWoMatVoidFlag', WOMatKey, Username)
if Error_Services('NoError') then
RDS_Services('DetachRDSFromWO', RDSNo)
If Error_Services('NoError') then
//Create a voided LOT record then record an event.
Work_Order_Services('CreateVoidedLotRecord', '', RDSNo, 'RDS', WoMatKey, Username)
Lot_Event_Services('CreateLotEvent', RDSNo, DateTime, 'VOID', 'Lot voided by ' : Username, '', Username, True$, 'RDS')
end else
ErrorMessage = Error_Services('GetMessage')
end
end else
LotEventParams<1,2> = WoMatKey
LotEventParams<1,9> = 'WO_MAT'
Service_Services('PostProcedure', 'LOT_EVENT_SERVICES', LotEventParams)
ErrorMessage = Error_Services('GetMessage')
end
If Error_Services('NoError') then
//Add inventory transaction
end else
ErrorMessage = 'WO_MAT key not found in WO_LOG record.'
end
end else
ErrorMessage = 'No WO_MAT keys exist in WO_LOG record.'
end
end else
ErrorMessage = Error_Services('GetMessage')
end
end else
ErrorMessage = 'Cannot use this routine to void EpiPro lots.'
end
end
Next WoMatKey
end else
ErrorMessage = Error_Services('GetMessage')
end
If ErrorMessage EQ '' then
//Commit work order changes all at once here.
Database_Services('WriteDataRow', 'WO_LOG', WONo, WoLogRecord)
if Error_Services('NoError') then
Work_Order_Services('UpdateReceivedQty', WONo)
Work_Order_Services('UpdateReleasedQty', WONo)
Work_Order_Services('UpdateUnscheduledQuantities')
end else
Error_Services('Add', ErrorMessage)
end
end else
Error_Services('Add', ErrorMessage)
end
end service
Service SignVoidWMI(WMInKeys, WONo, Username)
ErrorMessage = ''
WOLogRecord = Database_Services('ReadDataRow', 'WO_LOG', WONo, True$, 0, False$)
if Error_Services('NoError') then
for each WmInKey in WMInKeys using @VM
if WmInKey NE '' then
WONo = Field(WMInKey, '*', 1)
CassNo = Field(WMInKey, '*', 3)
WoStepKey = Xlate('WO_LOG', WONo, WO_LOG_WO_STEP_KEY$, 'X')
WoMatKey = WONo : '*' : CassNo
ReactType = WOLogRecord<WO_LOG_REACT_TYPE$>
If ReactType EQ 'EPP' then
WMInRec = Database_Services('ReadDataRow', 'WM_IN', WMInKey, True$, 0, False$)
IsVoided = WMInRec<WM_IN_VOID$>
If Not(IsVoided) then
IsOnHold = Hold_Services('CheckForHold', WoMatKey)
If Not(IsOnHold) then
WM_In_Services('SetVoidFlag', WmInKey, Username)
If Error_Services('NoError') then
Lot_Event_Services('CreateLotEvent', WmInKey, DateTime(), 'VOID', 'Lot voided by ' : Username, '', Username, True$, 'WM_IN')
Work_Order_Services('CreateVoidedLotRecord', '', WmInKey, 'WM_IN', WoMatKey, Username)
if Error_Services('NoError') then
//Check if WMO is also voided. If it is, remove it from the WO_MAT_KEY field in WO_LOG, and void the WO_MAT record
WMOKey = WMInKey; //the paired WMO key is the same as the WMIKey
IsWMOVoided = Database_Services('ReadDataColumn', 'WM_OUT', WMOKey, WM_OUT_VOID$)
If IsWMOVoided then
Locate WoMatKey in WoLogRecord<WO_LOG_WO_MAT_KEY$> using @VM setting CassPos then
WoLogRecord<WO_LOG_WO_MAT_KEY$> = Delete(WOLogRecord<WO_LOG_WO_MAT_KEY$>, 1, CassPos, 0)
WO_Mat_Services('SetWoMatVoidFlag', WoMatKey, Username)
end else
ErrorMessage = 'Unable to locate WO_MAT key in WO_LOG record.'
end
end
end else
ErrorMessage = Error_Services('GetMessage')
end
end else
ErrorMessage = Error_Services('GetMessage')
end
end else
ErrorMessage = Error_Services('GetMessage')
end
end else
ErrorMessage = Error_Services('GetMessage')
end
end
end else
ErrorMessage = 'Unable to void lot as it is already voided.'
end
end else
ErrorMessage = Error_Services('GetMessage')
end
end
end
end else
ErrorMessage = 'Unable to void lot as it is already voided.'
end
end else
ErrorMessage = 'Cannot use this routine to void non EpiPro lots.'
end
end
Next WoMatKey
end else
ErrorMessage = 'Cannot use this routine to void EpiPro lots.'
ErrorMessage = Error_Services('GetMessage')
end
If ErrorMessage EQ '' then
//Commit work order changes all at once here.
Database_Services('WriteDataRow', 'WO_LOG', WONo, WoLogRecord)
if Error_Services('NoError') then
Work_Order_Services('UpdateReceivedQty', WONo)
Work_Order_Services('UpdateReleasedQty', WONo)
Work_Order_Services('UpdateUnscheduledQuantities')
end else
Error_Services('Add', ErrorMessage)
end
end else
Error_Services('Add', ErrorMessage)
end
If ErrorMessage NE '' then
LogData = ''
LogData<1> = LoggingDTM
LogData<2> = Username
LogData<3> = WOMatKey
LogData<3> = WoNo
LogData<4> = ErrorMessage
Logging_Services('AppendLog', objReleaseLog, LogData, @RM, @FM, False$)
Error_Services('Add', ErrorMessage)
@ -1375,84 +1520,7 @@ Service SignVoidNonEpp(WOMatKey, Username)
LogData = ''
LogData<1> = LoggingDTM
LogData<2> = Username
LogData<3> = WOMatKey
LogData<4> = 'Void queued successfully.'
Logging_Services('AppendLog', objReleaseLog, LogData, @RM, @FM, False$)
Error_Services('Add', ErrorMessage)
end
end service
Service SignVoidWMI(WMInKey, Username)
ErrorMessage = ''
WONo = Field(WMInKey, '*', 1)
CassNo = Field(WMInKey, '*', 3)
WoStepKey = Xlate('WO_LOG', WONo, WO_LOG_WO_STEP_KEY$, 'X')
WoMatKey = WONo : '*' : CassNo
ReactType = XLATE('WO_LOG', WONo, WO_LOG_REACT_TYPE$, 'X')
If ReactType EQ 'EPP' then
WMInRec = Database_Services('ReadDataRow', 'WM_IN', WMInKey, True$, 0, False$)
IsVoided = WMInRec<WM_IN_VOID$>
If Not(IsVoided) then
IsOnHold = Hold_Services('CheckForHold', WoMatKey)
If Not(IsOnHold) then
Service_Services('PostProcedure', 'WM_IN_SERVICES', 'SetVoidFlag':@vm:WMInKey:@VM:Username)
If Error_Services('NoError') then
LotEventParams = ''
LotEventParams<1,1> = 'CreateLotEvent'
LotEventParams<1,2> = WMInKey
LotEventParams<1,3> = DateTime()
LotEventParams<1,4> = 'VOID'
LotEventParams<1,5> = 'Lot voided by ' : Username
LotEventParams<1,6> = ''
LotEventParams<1,7> = Username
LotEventParams<1,8> = True$
LotEventParams<1,9> = 'WM_IN'
Service_Services('PostProcedure', 'LOT_EVENT_SERVICES', LotEventParams)
If Error_Services('NoError') then
//Check if WMO is also voided. If it is, remove it from the WO_MAT_KEY field in WO_LOG, and void the WO_MAT record
WMOKey = WMInKey; //the paired WMO key is the same as the WMIKey
IsWMOVoided = Database_Services('ReadDataColumn', 'WM_OUT', WMOKey, WM_OUT_VOID$)
If IsWMOVoided then
Service_Services('PostProcedure', 'WO_MAT_SERVICES', 'SetWoMatVoidFlag':@VM:WoMatKey:@VM:Username)
If Error_Services('NoError') then
Service_Services('PostProcedure', 'WORK_ORDER_SERVICES','RemoveWoMatCassetteFromWO':@VM:WoMatKey:@VM:Username)
If Error_Services('HasError') then
ErrorMessage = Error_Services('GetMessage')
end
end else
ErrorMessage = Error_Services('GetMessage')
end
end
end else
ErrorMessage = Error_Services('GetMessage')
end
end else
ErrorMessage = Error_Services('GetMessage')
end
end
end else
ErrorMessage = 'Unable to void lot as it is already voided.'
end
end else
ErrorMessage = 'Cannot use this routine to void EpiPro lots.'
end
If ErrorMessage NE '' then
LogData = ''
LogData<1> = LoggingDTM
LogData<2> = Username
LogData<3> = WMInKey
LogData<4> = ErrorMessage
Logging_Services('AppendLog', objReleaseLog, LogData, @RM, @FM, False$)
Error_Services('Add', ErrorMessage)
end else
LogData = ''
LogData<1> = LoggingDTM
LogData<2> = Username
LogData<3> = WMInKey
LogData<3> = WoNo
LogData<4> = 'Void queued successfully.'
Logging_Services('AppendLog', objReleaseLog, LogData, @RM, @FM, False$)
Error_Services('Add', ErrorMessage)
@ -1461,67 +1529,89 @@ Service SignVoidWMI(WMInKey, Username)
end service
Service SignVoidWMO(WMOutKey, Username)
Service SignVoidWMO(WMOutKeys, WONo, Username)
ErrorMessage = ''
WONo = Field(WMOutKey, '*', 1)
CassNo = Field(WMOutKey, '*', 3)
WoStepKey = Xlate('WO_LOG', WONo, WO_LOG_WO_STEP_KEY$, 'X')
WoMatKey = WONo : '*' : CassNo
ReactType = XLATE('WO_LOG', WONo, WO_LOG_REACT_TYPE$, 'X')
If ReactType EQ 'EPP' then
WMOutRec = Database_Services('ReadDataRow', 'WM_OUT', WMOutKey, True$, 0, False$)
IsVoided = WMOutRec<WM_OUT_VOID$>
If Not(IsVoided) then
IsOnHold = Hold_Services('CheckForHold', WoMatKey)
If Not(IsOnHold) then
Service_Services('PostProcedure', 'WM_OUT_SERVICES', 'SetVoidFlag':@vm:WMOutKey:@VM:Username)
If Error_Services('NoError') then
LotEventParams = ''
LotEventParams<1,1> = 'CreateLotEvent'
LotEventParams<1,2> = WMOutKey
LotEventParams<1,3> = DateTime()
LotEventParams<1,4> = 'VOID'
LotEventParams<1,5> = 'Lot voided by ' : Username
LotEventParams<1,6> = ''
LotEventParams<1,7> = Username
LotEventParams<1,8> = True$
LotEventParams<1,9> = 'WM_OUT'
Service_Services('PostProcedure', 'LOT_EVENT_SERVICES', LotEventParams)
If Error_Services('NoError') then
//Check if WMI is also voided. If it is, remove it from the WO_MAT_KEY field in WO_LOG, and void the WO_MAT record
WMIKey = WMOutKey; //the paired WMO key is the same as the WMIKey
IsWMIVoided = Database_Services('ReadDataColumn', 'WM_IN', WMIKey, WM_IN_VOID$)
If IsWMIVoided then
Service_Services('PostProcedure', 'WO_MAT_SERVICES', 'SetWoMatVoidFlag':@VM:WoMatKey:@VM:Username)
WOLogRecord = Database_Services('ReadDataRow', 'WO_LOG', WONo, True$, 0, False$)
if Error_Services('NoError') then
for each WmOutKey in WMOutKeys using @VM
if WmOutKey NE '' then
WONo = Field(WmOutKey, '*', 1)
CassNo = Field(WmOutKey, '*', 3)
WoStepKey = Xlate('WO_LOG', WONo, WO_LOG_WO_STEP_KEY$, 'X')
WoMatKey = WONo : '*' : CassNo
ReactType = WOLogRecord<WO_LOG_REACT_TYPE$>
If ReactType EQ 'EPP' then
WMOutRec = Database_Services('ReadDataRow', 'WM_OUT', WmOutKey, True$, 0, False$)
IsVoided = WMInRec<WM_OUT_VOID$>
If Not(IsVoided) then
IsOnHold = Hold_Services('CheckForHold', WoMatKey)
If Not(IsOnHold) then
WM_Out_Services('SetVoidFlag', WmOutKey, Username)
If Error_Services('NoError') then
If Error_Services('NoError') then
Service_Services('PostProcedure', 'WORK_ORDER_SERVICES','RemoveWoMatCassetteFromWO':@VM:WoMatKey:@VM:Username)
If Error_Services('HasError') then
If Error_Services('NoError') then
Lot_Event_Services('CreateLotEvent', WmOutKey, DateTime(), 'VOID', 'Lot voided by ' : Username, '', Username, True$, 'WM_OUT')
Work_Order_Services('CreateVoidedLotRecord', '', WmOutKey, 'WM_OUT', WoMatKey, Username)
if Error_Services('NoError') then
//Check if WMI is also voided. If it is, remove it from the WO_MAT_KEY field in WO_LOG, and void the WO_MAT record
WMIKey = WmOutKey; //the paired WMO key is the same as the WMIKey
IsWMIVoided = Database_Services('ReadDataColumn', 'WM_IN', WMOKey, WM_IN_VOID$)
If IsWMIVoided then
Locate WoMatKey in WoLogRecord<WO_LOG_WO_MAT_KEY$> using @VM setting CassPos then
WoLogRecord<WO_LOG_WO_MAT_KEY$> = Delete(WOLogRecord<WO_LOG_WO_MAT_KEY$>, 1, CassPos, 0)
WO_Mat_Services('SetWoMatVoidFlag', WoMatKey, Username)
end else
ErrorMessage = 'Unable to locate WO_MAT key in WO_LOG record.'
end
end
end else
ErrorMessage = Error_Services('GetMessage')
end
end else
ErrorMessage = Error_Services('GetMessage')
end
end else
ErrorMessage = Error_Services('GetMessage')
end
end
end else
ErrorMessage = Error_Services('GetMessage')
end
end else
ErrorMessage = Error_Services('GetMessage')
end
end
end else
ErrorMessage = 'Unable to void lot as it is already voided.'
end
end else
ErrorMessage = Error_Services('GetMessage')
end
end
end else
ErrorMessage = 'Unable to void lot as it is already voided.'
end
end else
ErrorMessage = 'Cannot use this routine to void non EpiPro lots.'
end
end
Next WoMatKey
end else
ErrorMessage = 'Cannot use this routine to void EpiPro lots.'
ErrorMessage = Error_Services('GetMessage')
end
If ErrorMessage EQ '' then
//Commit work order changes all at once here.
Database_Services('WriteDataRow', 'WO_LOG', WONo, WoLogRecord)
if Error_Services('NoError') then
Work_Order_Services('UpdateReceivedQty', WONo)
Work_Order_Services('UpdateReleasedQty', WONo)
Work_Order_Services('UpdateUnscheduledQuantities')
end else
Error_Services('Add', ErrorMessage)
end
end else
Error_Services('Add', ErrorMessage)
end
If ErrorMessage NE '' then
LogData = ''
LogData<1> = LoggingDTM
LogData<2> = Username
LogData<3> = WMOutKey
LogData<3> = WONo
LogData<4> = ErrorMessage
Logging_Services('AppendLog', objReleaseLog, LogData, @RM, @FM, False$)
Error_Services('Add', ErrorMessage)
@ -1529,8 +1619,8 @@ Service SignVoidWMO(WMOutKey, Username)
LogData = ''
LogData<1> = LoggingDTM
LogData<2> = Username
LogData<3> = WMOutKey
LogData<4> = 'Void queued successfully.'
LogData<3> = ''
LogData<4> = 'Void processed successfully.'
Logging_Services('AppendLog', objReleaseLog, LogData, @RM, @FM, False$)
Error_Services('Add', ErrorMessage)
end
@ -1836,3 +1926,4 @@ ClearCursors:
return