Initial Backend functionality

This commit is contained in:
Infineon\Ouellette 2025-01-10 17:33:46 -07:00 committed by Ouellette Jonathan (CSC FI SPS MESLEO)
parent 24261d918b
commit 0eac3839ea
4 changed files with 407 additions and 0 deletions

View File

@ -0,0 +1,355 @@
Compile function RETURN_TO_FAB_Services(@Service, @Params)
#pragma precomp SRP_PreCompiler
Declare subroutine Error_Services, Database_Services, Btree.Extract
Declare function Rti_Createguid, Database_Services, Return_To_Fab_Services, Datetime, Error_Services
$insert LOGICAL
$Insert RETURN_TO_FAB_LOTS_EQUATES
$Insert RETURN_TO_FAB_RESULT_OPTION_EQUATES
$Insert WO_MAT_EQUATES
$Insert RDS_EQUATES
GoToService
Return Response or ""
//-----------------------------------------------------------------------------
// SERVICES
//-----------------------------------------------------------------------------
Service CreateReturnToFabRecord(CassId, UserId)
ErrorMessage = ''
NewRTFId = ''
If CassId NE '' then
CassType = ''
Begin Case
Case RowExists('RDS', CassId)
CassType = 'RDS'
Case RowExists('WM_OUT', CassId)
CassType = 'WM_OUT'
Case Otherwise$
ErrorMessage = 'Error creating return to fab record, Cassette ID not found.'
End Case
If ErrorMessage EQ '' then
OpenRTFRecordExists = Return_To_Fab_Services('GetOpenReturnToFabRecordIdByCassId', CassId) NE ''
If Not(OpenRTFRecordExists) then
If RowExists('LSL_USERS', UserId) then
//Validation: Need to ensure the lot has a batch number to ensure it "Has Left The Fab"
SAPBatchNo = ''
Begin Case
Case CassType EQ 'RDS'
WONo = Database_Services('ReadDataColumn', 'RDS', CassId, RDS_WO$, True$, 0, False$)
CassNo = Database_Services('ReadDataColumn', 'RDS', CassId, RDS_CASS_NO$, True$, 0, False$)
WOMatKeyId = WONo : '*' : CassNo
SAPBatchNo = Database_Services('ReadDataColumn', 'WO_MAT', WOMatKeyId, WO_MAT_SAP_BATCH_NO$, True$, 0, False$)
Case CassType EQ 'WM_OUT'
WONo = Field(CassId, '*', 1)
CassNo = Field(CassId, '*', 3)
WOMatKeyId = WONo : '*' : CassNo
SAPBatchNo = Database_Services('ReadDataColumn', 'WO_MAT', WOMatKeyId, WO_MAT_SAP_BATCH_NO$, True$, 0, False$)
End Case
If SAPBatchNo NE '' then
NewRTFId = Rti_Createguid()
RTFRecord = ''
RTFRecord<RETURN_TO_FAB_LOTS_CASS_ID$> = CassId
RTFRecord<RETURN_TO_FAB_LOTS_LOT_TYPE$> = CassType
RTFRecord<RETURN_TO_FAB_LOTS_REQUESTOR_USER_ID$> = UserId
RTFRecord<RETURN_TO_FAB_LOTS_START_DTM$> = Datetime()
RTFRecord<RETURN_TO_FAB_LOTS_COMPLETED$> = False$
Database_Services('WriteDataRow', 'RETURN_TO_FAB_LOTS', NewRTFId, RTFRecord, True$, False$, True$)
end else
ErrorMessage = 'Error creating return to fab record, Cassette ID is not currently in SAP and cannot be returned to fab.'
end
end else
ErrorMessage = 'Error creating return to fab record, User not found.'
end
end else
ErrorMessage = 'Error creating return to fab record, an active return to fab for this lot already exists.'
end
end
end else
ErrorMessage = 'Error creating return to fab record, Cassette ID was null'
end
If ErrorMessage EQ '' AND NewRTFId NE '' then
Response = NewRTFId
end else
//Todo Log error message
Error_Services('Add', ErrorMessage)
end
End Service
Service GetReturnToFabReasonOptions()
ErrorMessage = ''
RTFReasons = ''
RTFReasonKeys = ''
table = "RETURN_TO_FAB_REASON"
Open "DICT ":table To @DICT Else
ErrorMessage = 'Error opening RETURN_TO_FAB_REASON dictionary'
End
If ErrorMessage EQ '' then
srch_strng = "ACTIVE":@VM:True$:@FM
option = ""
flag = ""
Btree.Extract(srch_strng, table, @DICT, RTFReasonKeys, option, flag)
for each RTFReasonID in RTFReasonKeys using @VM setting rPos
RTFReasons<1, rPos> = RTFReasonId
ReasonDesc = Database_Services('ReadDataColumn', table, RTFReasonID, RETURN_TO_FAB_REASON_REASON_DESCRIPTION$, True$, 0, False$)
RTFReasons<2, rPos> = ReasonDesc
Next RTFReasonID
end
If ErrorMessage EQ '' then
Response = RTFReasons
end else
//Todo Log error message
Error_Services('Add', ErrorMessage)
end
end service
Service GetReturnToFabResultOptions()
ErrorMessage = ''
RTFResultOptions = ''
RTFResultOptionKeys = ''
table = "RETURN_TO_FAB_RESULT_OPTION"
Open "DICT ":table To @DICT Else
ErrorMessage = 'Error opening RETURN_TO_FAB_RESULT_OPTION dictionary'
End
If ErrorMessage EQ '' then
srch_strng = "ACTIVE":@VM:True$:@FM
option = ""
flag = ""
Btree.Extract(srch_strng, table, @DICT, RTFResultOptionKeys, option, flag)
for each RTFOptionID in RTFResultOptionKeys using @VM setting rPos
RTFResultOptions<1, rPos> = RTFOptionID
ResultDesc = Database_Services('ReadDataColumn', table, RTFOptionID, RETURN_TO_FAB_RESULT_OPTION_RESULT$, True$, 0, False$)
RTFResultOptions<2, rPos> = ResultDesc
Next RTFReasonID
end
If ErrorMessage EQ '' then
Response = RTFResultOptions
end else
//Todo Log error message
Error_Services('Add', ErrorMessage)
end
end service
Service GetReturnToFabRecordById(RTFId)
end service
Service ConvertReturnToFabRecordToJSON(RTFId)
end service
Service GetReturnToFabRecordIdByCassId(CassId)
ErrorMessage = ''
RTFRecords = ''
If CassId NE '' then
table = "RETURN_TO_FAB_LOTS"
Open "DICT ":table To @DICT Else
ErrorMessage = 'Error opening RETURN_TO_FAB_LOTS dictionary'
End
If ErrorMessage EQ '' then
srch_strng = "CASS_ID":@VM:CassId:@FM
option = ""
flag = ""
Btree.Extract(srch_strng, table, @DICT, RTFRecords, option, flag)
end
end else
ErrorMessage = 'Error getting return to fab record by cass. ID. Cassette ID was null'
end
If ErrorMessage EQ '' then
Response = RTFRecords
end else
//Todo Log error message
Error_Services('Add', ErrorMessage)
end
End Service
Service GetOpenReturnToFabRecordIdByCassId(CassId)
ErrorMessage = ''
OpenRTFRecords = ''
If CassId NE '' then
table = "RETURN_TO_FAB_LOTS"
Open "DICT ":table To @DICT Else
ErrorMessage = 'Error opening RETURN_TO_FAB_LOTS dictionary'
End
If ErrorMessage EQ '' then
srch_strng = "CASS_ID":@VM:CassId:@FM:"COMPLETED":@VM:"#1":@FM
option = ""
flag = ""
Btree.Extract(srch_strng, table, @DICT, OpenRTFRecords, option, flag)
end
end else
ErrorMessage = 'Error getting return to fab record by cass. ID. Cassette ID was null'
end
If ErrorMessage EQ '' then
Response = OpenRTFRecords
end else
//Todo Log error message
Error_Services('Add', ErrorMessage)
end
End Service
Service SetReasonForReturn(RTFId, Reason)
ErrorMessage = ''
If RTFId NE '' then
If RowExists('RETURN_TO_FAB_LOTS', RTFId) then
RTFRecord = Database_Services('ReadDataRow', 'RETURN_TO_FAB_LOTS', RTFId, True$, 0, False$)
RTFRecordComplete = RTFRecord<RETURN_TO_FAB_LOTS_COMPLETED$>
If RTFRecordComplete NE True$ then
If Reason NE '' then
RTFRecord<RETURN_TO_FAB_LOTS_REASON$> = Reason
Database_Services('WriteDataRow', 'RETURN_TO_FAB_LOTS', RTFId, RTFRecord, True$, False$, False$)
If Error_Services('HasError') then
ErrorMessage = Error_Services('GetMessage')
end
end else
ErrorMessage = 'Error setting return to fab reason. Reason was null.'
end
end else
ErrorMessage = 'Error setting return to fab reason. Return to fab record has already been completed.'
end
end else
ErrorMessage = 'Error setting return to fab reason. Return to fab record did not exists'
end
end else
ErrorMessage = 'Error setting return to fab reason. Return to fab record id was null'
end
if ErrorMessage NE '' then
//Todo Add loggging
Error_Services('Add', ErrorMessage)
end
end service
Service SetBinToBin(RTFId, MHUserId)
ErrorMessage = ''
If RTFId NE '' then
If RowExists('RETURN_TO_FAB_LOTS', RTFId) then
RTFRecord = Database_Services('ReadDataRow', 'RETURN_TO_FAB_LOTS', RTFId, True$, 0, False$)
RTFRecordComplete = RTFRecord<RETURN_TO_FAB_LOTS_COMPLETED$>
If RTFRecordComplete NE True$ then
If MHUserId NE '' then
If RowExists('LSL_USERS', MHUserId) then
RTFRecord<RETURN_TO_FAB_LOTS_MH_INIT_USER_ID$> = MHUserId
RTFRecord<RETURN_TO_FAB_LOTS_MH_INIT_DTM$> = Datetime()
Database_Services('WriteDataRow', 'RETURN_TO_FAB_LOTS', RTFId, RTFRecord, True$, False$, False$)
If Error_Services('HasError') then
ErrorMessage = Error_Services('GetMessage')
end
end else
ErrorMessage = 'Error setting Initial SAP Bin-to-Bin. Material Handler User ID was not found in OpenInsight.'
end
end else
ErrorMessage = 'Error setting Initial SAP Bin-to-Bin. Material Handler User ID was null.'
end
end else
ErrorMessage = 'Error setting Initial SAP Bin-to-Bin. Return to fab record has already been completed.'
end
end else
ErrorMessage = 'Error setting Initial SAP Bin-to-Bin. Return to fab record did not exists'
end
end else
ErrorMessage = 'Error setting Initial SAP Bin-to-Bin. Return to fab record id was null'
end
if ErrorMessage NE '' then
//Todo Add loggging
Error_Services('Add', ErrorMessage)
end
end service
Service SetEvalInfo(RTFId, EvalUserId, ResultId)
ErrorMessage = ''
If RTFId NE '' then
if RowExists('RETURN_TO_FAB_LOTS', RTFId) then
If EvalUserId NE '' then
if RowExists('LSL_USERS', EvalUserId) then
If ResultId NE '' then
If RowExists('RETURN_TO_FAB_RESULT_OPTION', ResultId) then
RTFRecord = Database_Services('ReadDataRow', 'RETURN_TO_FAB_LOTS', RTFId, True$, 0, False$)
RTFRecordComplete = RTFRecord<RETURN_TO_FAB_LOTS_COMPLETED$>
If RTFRecordComplete NE True$ then
RTFRecord<RETURN_TO_FAB_LOTS_EVAL_USER_ID$> = EvalUserId
RTFRecord<RETURN_TO_FAB_LOTS_EVAL_RESULT_ID$> = ResultId
RTFRecord<RETURN_TO_FAB_LOTS_EVAL_DTM$> = Datetime()
Database_Services('WriteDataRow', 'RETURN_TO_FAB_LOTS', RTFId, RTFRecord, True$, False$, False$)
If Error_Services('HasError') then
ErrorMessage = Error_Services('GetMessage')
end
end else
ErrorMessage = 'Error setting Eval. info. Return to fab record has already been completed.'
end
//Possbile to add auto-closing logic here.
end else
ErrorMessage = 'Error setting Eval. info. Result was an invalid result option.'
end
end else
ErrorMessage = 'Error setting Eval. info. Result was null.'
end
end else
ErrorMessage = 'Error setting Eval. info. Evaluation user is not a valid OpenInsight user.'
end
end else
ErrorMessage = 'Error setting Eval. info. Evaluation user id was null.'
end
end else
ErrorMessage = 'Error setting Eval. info. Return to fab record was not found.'
end
end else
ErrorMessage = 'Error setting Eval. info. Return to fab id was null.'
end
If ErrorMessage NE '' then
//Todo add logging
Error_Services('Add', ErrorMessage)
end
end service
Service SetFinalBinToBin(RTFId, MHUserId)
ErrorMessage = ''
If RTFId NE '' then
If RowExists('RETURN_TO_FAB_LOTS', RTFId) then
RTFRecord = Database_Services('ReadDataRow', 'RETURN_TO_FAB_LOTS', RTFId, True$, 0, False$)
RTFRecordComplete = RTFRecord<RETURN_TO_FAB_LOTS_COMPLETED$>
If RTFRecordComplete NE True$ then
If MHUserId NE '' then
If RowExists('LSL_USERS', MHUserId) then
RTFRecord<RETURN_TO_FAB_LOTS_FINAL_COMPLETE_USER_ID$> = MHUserId
RTFRecord<RETURN_TO_FAB_LOTS_FINAL_COMPLETE_DTM$> = Datetime()
RTFRecord<RETURN_TO_FAB_LOTS_COMPLETED$> = True$
RTFRecord<RETURN_TO_FAB_LOTS_COMPLETED_DTM$> = Datetime()
Database_Services('WriteDataRow', 'RETURN_TO_FAB_LOTS', RTFId, RTFRecord, True$, False$, False$)
If Error_Services('HasError') then
ErrorMessage = Error_Services('GetMessage')
end
end else
ErrorMessage = 'Error setting Initial SAP Bin-to-Bin. Material Handler User ID was not found in OpenInsight.'
end
end else
ErrorMessage = 'Error setting Initial SAP Bin-to-Bin. Material Handler User ID was null.'
end
end else
ErrorMessage = 'Error setting Initial SAP Bin-to-Bin. Return to fab record has already been completed.'
end
end else
ErrorMessage = 'Error setting Initial SAP Bin-to-Bin. Return to fab record did not exists'
end
end else
ErrorMessage = 'Error setting Initial SAP Bin-to-Bin. Return to fab record id was null'
end
if ErrorMessage NE '' then
//Todo Add loggging
Error_Services('Add', ErrorMessage)
end
end service
Service AddMiscNote(RTFId, Note)
end service

View File

@ -0,0 +1,26 @@
compile insert RETURN_TO_FAB_LOTS_EQUATES
/*----------------------------------------
Author : Table Create Insert Routine
Written : 10/01/2025
Description : Insert for Table RETURN_TO_FAB_LOTS
----------------------------------------*/
#ifndef __RETURN_TO_FAB_LOTS_EQUATES__
#define __RETURN_TO_FAB_LOTS_EQUATES__
equ RETURN_TO_FAB_LOTS_CASS_ID$ to 1
equ RETURN_TO_FAB_LOTS_LOT_TYPE$ to 2
equ RETURN_TO_FAB_LOTS_REQUESTOR_USER_ID$ to 3
equ RETURN_TO_FAB_LOTS_START_DTM$ to 4
equ RETURN_TO_FAB_LOTS_MH_INIT_USER_ID$ to 5
equ RETURN_TO_FAB_LOTS_MH_INIT_DTM$ to 6
equ RETURN_TO_FAB_LOTS_EVAL_USER_ID$ to 7
equ RETURN_TO_FAB_LOTS_EVAL_RESULT_ID$ to 8
equ RETURN_TO_FAB_LOTS_EVAL_DTM$ to 9
equ RETURN_TO_FAB_LOTS_FINAL_COMPLETE_USER_ID$ to 10
equ RETURN_TO_FAB_LOTS_FINAL_COMPLETE_DTM$ to 12
equ RETURN_TO_FAB_LOTS_COMPLETED$ to 13
equ RETURN_TO_FAB_LOTS_COMPLETED_DTM$ to 14
equ RETURN_TO_FAB_LOTS_REASON$ to 15
equ RETURN_TO_FAB_LOTS_NOTES$ to 16
#endif

View File

@ -0,0 +1,13 @@
compile insert RETURN_TO_FAB_REASON_EQUATES
/*----------------------------------------
Author : Table Create Insert Routine
Written : 10/01/2025
Description : Insert for Table RETURN_TO_FAB_REASON
----------------------------------------*/
#ifndef __RETURN_TO_FAB_REASON_EQUATES__
#define __RETURN_TO_FAB_REASON_EQUATES__
equ RETURN_TO_FAB_REASON_REASON_DESCRIPTION$ to 1
equ RETURN_TO_FAB_REASON_ACTIVE$ to 2
#endif

View File

@ -0,0 +1,13 @@
compile insert RETURN_TO_FAB_RESULT_OPTION_EQUATES
/*----------------------------------------
Author : Table Create Insert Routine
Written : 10/01/2025
Description : Insert for Table RETURN_TO_FAB_RESULT_OPTION
----------------------------------------*/
#ifndef __RETURN_TO_FAB_RESULT_OPTION_EQUATES__
#define __RETURN_TO_FAB_RESULT_OPTION_EQUATES__
equ RETURN_TO_FAB_RESULT_OPTION_RESULT$ to 1
equ RETURN_TO_FAB_RESULT_OPTION_ACTIVE$ to 2
#endif