Added in Current Step Calculation, Current Step Action Validation, User Permission validation, additional TODO logging, code cleanup
This commit is contained in:
parent
29f0cb1c10
commit
8f4048a68a
@ -4,7 +4,7 @@ Compile function RETURN_TO_FAB_Services(@Service, @Params)
|
||||
Declare subroutine Error_Services, Database_Services, Btree.Extract, Logging_Services, SRP_JSON
|
||||
|
||||
Declare function Rti_Createguid, Database_Services, Return_To_Fab_Services, Datetime, Error_Services
|
||||
Declare function Logging_Services, Environment_Services, SRP_JSON
|
||||
Declare function Logging_Services, Environment_Services, SRP_JSON, MemberOf
|
||||
Declare subroutine obj_notes, SRP_Run_Command
|
||||
|
||||
$insert LOGICAL
|
||||
@ -123,38 +123,10 @@ Service CreateReturnToFabRecord(CassId, UserId)
|
||||
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
|
||||
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'
|
||||
@ -173,15 +145,17 @@ Service GetReturnToFabResultOptions()
|
||||
If ErrorMessage EQ '' then
|
||||
Response = RTFResultOptions
|
||||
end else
|
||||
//Todo Log error message
|
||||
LogData = ''
|
||||
LogData<1> = LoggingDTM;//Defined at entry of subroutine
|
||||
LogData<2> = ''
|
||||
LogData<3> = ''
|
||||
LogData<4> = ''
|
||||
LogData<5> = ErrorMessage
|
||||
Logging_Services('AppendLog', objReturnToFabLog, LogData, @RM, @FM, False$)
|
||||
Error_Services('Add', ErrorMessage)
|
||||
end
|
||||
end service
|
||||
|
||||
Service GetReturnToFabRecordById(RTFId)
|
||||
|
||||
end service
|
||||
|
||||
Service ConvertReturnToFabRecordToJSON(RTFId)
|
||||
ErrorMessage = ''
|
||||
JsonString = ''
|
||||
@ -212,6 +186,8 @@ Service ConvertReturnToFabRecordToJSON(RTFId)
|
||||
SRP_JSON(objRTF, 'SetValue', 'Completed', RTFRecord<RETURN_TO_FAB_LOTS_COMPLETED$>, 'Boolean')
|
||||
SRP_JSON(objRTF, 'SetValue', 'CompletedDtm', OConv(RTFRecord<RETURN_TO_FAB_LOTS_COMPLETED_DTM$>,'DT'))
|
||||
SRP_JSON(objRTF, 'SetValue', 'Reason', RTFRecord<RETURN_TO_FAB_LOTS_REASON$>)
|
||||
CurrStepId = Return_To_Fab_Services('GetRTFCurrStep', RTFId)
|
||||
SRP_Json(objRTF, 'SetValue', 'CurrStepId', CurrStepId, 'Number')
|
||||
Notes = RTFRecord<RETURN_TO_FAB_LOTS_NOTES$>
|
||||
NotesUser = RTFRecord<RETURN_TO_FAB_LOTS_NOTES_USER$>
|
||||
If Notes NE '' then
|
||||
@ -248,6 +224,16 @@ Service ConvertReturnToFabRecordToJSON(RTFId)
|
||||
end else
|
||||
ErrorMessage = 'Error Converting RTF record to JSON. RTFId not found in database.'
|
||||
end
|
||||
If ErrorMessage NE '' then
|
||||
LogData = ''
|
||||
LogData<1> = LoggingDTM;//Defined at entry of subroutine
|
||||
LogData<2> = ''
|
||||
LogData<3> = ''
|
||||
LogData<4> = ''
|
||||
LogData<5> = ErrorMessage
|
||||
Logging_Services('AppendLog', objReturnToFabLog, LogData, @RM, @FM, False$)
|
||||
Error_Services('Add', ErrorMessage)
|
||||
end
|
||||
Response = JsonString
|
||||
end service
|
||||
|
||||
@ -282,6 +268,8 @@ Service CreateReturnToFabReportJson(ShowOpenReport)
|
||||
SRP_JSON(hRTFJsonSingle, 'SetValue', 'FinalCompleteDtm', OConv(RTFRecord<RETURN_TO_FAB_LOTS_FINAL_COMPLETE_DTM$>, 'DT'))
|
||||
SRP_JSON(hRTFJsonSingle, 'SetValue', 'Completed', RTFRecord<RETURN_TO_FAB_LOTS_COMPLETED$>, 'Boolean')
|
||||
SRP_JSON(hRTFJsonSingle, 'SetValue', 'CompletedDtm', OConv(RTFRecord<RETURN_TO_FAB_LOTS_COMPLETED_DTM$>,'DT'))
|
||||
CurrStepId = Return_To_Fab_Services('GetRTFCurrStep', RTFId)
|
||||
SRP_Json(hRTFJsonSingle, 'SetValue', 'CurrStepId', CurrStepId, 'Number')
|
||||
SRP_Json(objReturnToFabReport, 'Add', hRTFJsonSingle)
|
||||
SRP_Json(hRTFJsonSingle, 'Release')
|
||||
end
|
||||
@ -297,6 +285,16 @@ Service CreateReturnToFabReportJson(ShowOpenReport)
|
||||
end else
|
||||
ErrorMessage = 'Error creating root JSON object.'
|
||||
end
|
||||
If ErrorMessage NE '' then
|
||||
LogData = ''
|
||||
LogData<1> = LoggingDTM;//Defined at entry of subroutine
|
||||
LogData<2> = ''
|
||||
LogData<3> = ''
|
||||
LogData<4> = ''
|
||||
LogData<5> = ErrorMessage
|
||||
Logging_Services('AppendLog', objReturnToFabLog, LogData, @RM, @FM, False$)
|
||||
Error_Services('Add', ErrorMessage)
|
||||
end
|
||||
Response = JsonString
|
||||
end service
|
||||
|
||||
@ -320,6 +318,13 @@ Service GetReturnToFabRecordIdByCassId(CassId)
|
||||
If ErrorMessage EQ '' then
|
||||
Response = RTFRecords
|
||||
end else
|
||||
LogData = ''
|
||||
LogData<1> = LoggingDTM;//Defined at entry of subroutine
|
||||
LogData<2> = CassId
|
||||
LogData<3> = ''
|
||||
LogData<4> = ''
|
||||
LogData<5> = ErrorMessage
|
||||
Logging_Services('AppendLog', objReturnToFabLog, LogData, @RM, @FM, False$)
|
||||
Error_Services('Add', ErrorMessage)
|
||||
end
|
||||
End Service
|
||||
@ -343,6 +348,13 @@ Service GetAllReturnToFabRecords(ShowOnlyOpen)
|
||||
If ErrorMessage EQ '' then
|
||||
Response = RTFRecords
|
||||
end else
|
||||
LogData = ''
|
||||
LogData<1> = LoggingDTM;//Defined at entry of subroutine
|
||||
LogData<2> = ''
|
||||
LogData<3> = ''
|
||||
LogData<4> = ''
|
||||
LogData<5> = ErrorMessage
|
||||
Logging_Services('AppendLog', objReturnToFabLog, LogData, @RM, @FM, False$)
|
||||
Error_Services('Add', ErrorMessage)
|
||||
end
|
||||
end service
|
||||
@ -367,6 +379,13 @@ Service GetOpenReturnToFabRecordIdByCassId(CassId)
|
||||
If ErrorMessage EQ '' then
|
||||
Response = OpenRTFRecords
|
||||
end else
|
||||
LogData = ''
|
||||
LogData<1> = LoggingDTM;//Defined at entry of subroutine
|
||||
LogData<2> = ''
|
||||
LogData<3> = ''
|
||||
LogData<4> = ''
|
||||
LogData<5> = ErrorMessage
|
||||
Logging_Services('AppendLog', objReturnToFabLog, LogData, @RM, @FM, False$)
|
||||
Error_Services('Add', ErrorMessage)
|
||||
end
|
||||
End Service
|
||||
@ -375,6 +394,8 @@ Service SetReasonForReturn(RTFId, UserId, Reason)
|
||||
ErrorMessage = ''
|
||||
If RTFId NE '' then
|
||||
If RowExists('RETURN_TO_FAB_LOTS', RTFId) then
|
||||
RTFCurrStep = Return_To_Fab_Services('GetRTFCurrStep', RTFId)
|
||||
If RTFCurrStep EQ LE 3 AND RTFCurrStep GE 1 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
|
||||
@ -395,10 +416,12 @@ Service SetReasonForReturn(RTFId, UserId, Reason)
|
||||
end else
|
||||
ErrorMessage = 'Error setting return to fab reason. User ID 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. Form is currently at step ': RTFCurrStep :'.'
|
||||
end
|
||||
end else
|
||||
ErrorMessage = 'Error setting return to fab reason. Return to fab record did not exists'
|
||||
end
|
||||
@ -429,11 +452,14 @@ Service SetBinToBin(RTFId, MHUserId)
|
||||
ErrorMessage = ''
|
||||
If RTFId NE '' then
|
||||
If RowExists('RETURN_TO_FAB_LOTS', RTFId) then
|
||||
RTFCurrStep = Return_To_Fab_Services('GetRTFCurrStep', RTFId)
|
||||
If RTFCurrStep EQ 3 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
|
||||
If MemberOf(MHUserId, 'MATERIAL HANDLER') 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$)
|
||||
@ -445,7 +471,6 @@ Service SetBinToBin(RTFId, MHUserId)
|
||||
Message := 'Initial Bin to Bin has been marked as completed.' : CRLF$
|
||||
Message := 'Link to Return To Fab form: https://goto.infineon.com/oiwizard/ReturnToFab'
|
||||
Recipients = XLATE('NOTIFICATION','SHIPPING',NOTIFICATION_USER_ID$,'X')
|
||||
|
||||
Recipients<1, -1> = RTFOrigUser
|
||||
SentFrom = 'OI_ADMIN'
|
||||
Subject = 'Return To Fab Form Updated'
|
||||
@ -457,16 +482,21 @@ Service SetBinToBin(RTFId, MHUserId)
|
||||
end else
|
||||
ErrorMessage = Error_Services('GetMessage')
|
||||
end
|
||||
end else
|
||||
ErrorMessage = 'Error setting Initial SAP Bin-to-Bin. User does not have permissions to perform this function. User must be apart of OI Security Group "MATERIAL HANDLER"'
|
||||
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. Form is currently at step ': RTFCurrStep :'.'
|
||||
end
|
||||
end else
|
||||
ErrorMessage = 'Error setting Initial SAP Bin-to-Bin. Return to fab record did not exists'
|
||||
end
|
||||
@ -527,7 +557,6 @@ Service SetRTFCompleted(RTFId, CompleteUserId)
|
||||
end else
|
||||
ErrorMessage = 'Error setting Return To Fab form as complete. User ID was not found in OpenInsight.'
|
||||
end
|
||||
|
||||
end else
|
||||
ErrorMessage = 'Error setting Return To Fab form as complete. User ID was null.'
|
||||
end
|
||||
@ -564,6 +593,8 @@ Service SetEvalInfo(RTFId, EvalUserId, ResultId)
|
||||
ErrorMessage = ''
|
||||
If RTFId NE '' then
|
||||
if RowExists('RETURN_TO_FAB_LOTS', RTFId) then
|
||||
RTFCurrStep = Return_To_Fab_Services('GetRTFCurrStep', RTFId)
|
||||
If RTFCurrStep EQ 4 AND RTFCurrStep LE 5 then
|
||||
If EvalUserId NE '' then
|
||||
if RowExists('LSL_USERS', EvalUserId) then
|
||||
If ResultId NE '' then
|
||||
@ -612,6 +643,9 @@ Service SetEvalInfo(RTFId, EvalUserId, ResultId)
|
||||
end else
|
||||
ErrorMessage = 'Error setting Eval. info. Evaluation user id was null.'
|
||||
end
|
||||
end else
|
||||
ErrorMessage = 'Error setting Eval. info. Form is currently at step ': RTFCurrStep :'.'
|
||||
end
|
||||
end else
|
||||
ErrorMessage = 'Error setting Eval. info. Return to fab record was not found.'
|
||||
end
|
||||
@ -642,34 +676,41 @@ Service SetFinalBinToBin(RTFId, MHUserId)
|
||||
ErrorMessage = ''
|
||||
If RTFId NE '' then
|
||||
If RowExists('RETURN_TO_FAB_LOTS', RTFId) then
|
||||
RTFCurrStep = Return_To_Fab_Services('GetRTFCurrStep', RTFId)
|
||||
If RTFCurrStep EQ 5 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
|
||||
If MemberOf(MHUserId, 'MATERIAL HANDLER') 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.'
|
||||
ErrorMessage = 'Error setting Final SAP Bin-to-Bin. User does not have permissions to perform this function. User must be apart of OI Security Group "MATERIAL HANDLER"'
|
||||
end
|
||||
end else
|
||||
ErrorMessage = 'Error setting Final 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.'
|
||||
ErrorMessage = 'Error setting Final 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.'
|
||||
ErrorMessage = 'Error setting Final 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'
|
||||
ErrorMessage = 'Error setting Final SAP Bin-to-Bin. Form is currently at step ': RTFCurrStep :'.'
|
||||
end
|
||||
end else
|
||||
ErrorMessage = 'Error setting Initial SAP Bin-to-Bin. Return to fab record id was null'
|
||||
ErrorMessage = 'Error setting Final SAP Bin-to-Bin. Return to fab record did not exists'
|
||||
end
|
||||
end else
|
||||
ErrorMessage = 'Error setting Final SAP Bin-to-Bin. Return to fab record id was null'
|
||||
end
|
||||
If ErrorMessage EQ '' then
|
||||
LogData = ''
|
||||
@ -709,7 +750,6 @@ Service AddMiscNote(RTFId, Note, UserId)
|
||||
end else
|
||||
ErrorMessage = 'Error adding note to RTF Record. User ID was not found in OpenInsight.'
|
||||
end
|
||||
|
||||
end else
|
||||
ErrorMessage = 'Error adding note to RTF Record. User ID was null.'
|
||||
end
|
||||
@ -742,6 +782,28 @@ Service AddMiscNote(RTFId, Note, UserId)
|
||||
end
|
||||
end service
|
||||
|
||||
Service GetRTFCurrStep(RTFId)
|
||||
CurrStep = 0
|
||||
RTFRecord = Database_Services('ReadDataRow', 'RETURN_TO_FAB_LOTS', RTFId, True$, 0, False$)
|
||||
If RTFRecord NE '' then
|
||||
CurrStep = 1
|
||||
If RTFRecord<RETURN_TO_FAB_LOTS_REASON$> NE '' then
|
||||
//Skip 2 because step 2 is an adhoc step(printing a label)
|
||||
CurrStep = 3
|
||||
If RTFRecord<RETURN_TO_FAB_LOTS_MH_INIT_USER_ID$> NE '' then
|
||||
CurrStep = 4
|
||||
If RTFRecord<RETURN_TO_FAB_LOTS_EVAL_RESULT_ID$> NE '' AND RTFRecord<RETURN_TO_FAB_LOTS_EVAL_RESULT_ID$> NE 0 then
|
||||
CurrStep = 5
|
||||
If RTFRecord<RETURN_TO_FAB_LOTS_FINAL_COMPLETE_USER_ID$> NE '' then
|
||||
CurrStep = 6
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Response = CurrStep
|
||||
end service
|
||||
|
||||
Service OpenOIWizardReturnToFabInBrowser(RTFId)
|
||||
Command = 'explorer https://goto.infineon.com/oiwizard/returntofab/' : RTFId
|
||||
SRP_Run_Command(Command)
|
||||
@ -750,3 +812,4 @@ end service
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user