added service to get nicaBaseInstructionId from NicaIntegrationService based on name of instruction/document
added UpdateNicaChecklistBaseInstructionIds call to GetOrderUpdates service
This commit is contained in:
committed by
Stieber Daniel (CSC FI SPS MESLEO)
parent
03e85359d1
commit
7b7f501145
@ -171,6 +171,7 @@ Service GetOrderUpdates()
|
||||
|
||||
hSysLists = Database_Services('GetTableHandle', 'SYSLISTS')
|
||||
Lock hSysLists, ServiceKeyID then
|
||||
Nica_Orders_Services('UpdateNicaChecklistBaseInstructionIds')
|
||||
ActiveOrderIds = Nica_Orders_Services('GetActiveOrders')
|
||||
For each OrderId in ActiveOrderIds using @VM
|
||||
Nica_Orders_Services('GetOrderStatusUpdate', OrderId)
|
||||
@ -1120,6 +1121,143 @@ Service GetChecklistIds(Priorities, NicaBaseInstructionIds, NicaOrderFlowIds, Ni
|
||||
|
||||
end service
|
||||
|
||||
|
||||
Service UpdateNicaChecklistBaseInstructionIds()
|
||||
|
||||
MonaResource = 'GRP_OPENINSIGHT_MES_OP_FE_NICAINTEGRATIONSERVICE'
|
||||
StatusName = Service
|
||||
StatusState = 'OK'
|
||||
Machine = Environment_Services('GetServer')
|
||||
Headers = 'Logging DTM' : @FM : 'Machine' : @FM : 'Log'
|
||||
ColumnWidths = 20 : @FM : 15 : @FM : 300
|
||||
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\NicaOrders'
|
||||
makeDirSuccess = Utility("MAKEDIR", LogPath)
|
||||
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : '_UpdateBaseInstructionIds.csv'
|
||||
objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ' ', Headers, ColumnWidths, False$, False$)
|
||||
|
||||
LogData = ''
|
||||
LogData<1> = OConv(Datetime(), 'DT/^S')
|
||||
LogData<2> = Machine
|
||||
LogData<3> = 'Begin ':Service
|
||||
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
|
||||
|
||||
ErrorMsg = ''
|
||||
BaseNicaIntegrationServiceApiUrl = Environment_Services('GetProveInApiUrl')
|
||||
If BaseNicaIntegrationServiceApiUrl NE '' then
|
||||
Prod = Environment_Services('IsProd')
|
||||
IgnoreCertErrors = Not(Prod)
|
||||
AllChecklistsUrl = BaseNicaIntegrationServiceApiUrl:'/checklists/all'
|
||||
AllChecklistsJson = Httpclient_Services('SendHTTPRequest', 'GET', AllChecklistsUrl, '', '', '', '', '', '', '', IgnoreCertErrors)
|
||||
If Error_Services('NoError') then
|
||||
If AllChecklistsJson NE '' then
|
||||
objAllChecklistsJsonArray = ''
|
||||
If (SRP_Json(objAllChecklistsJsonArray, 'Parse', AllChecklistsJson) EQ '') then
|
||||
NumJsonChecklists = SRP_Json(objAllChecklistsJsonArray, 'GetCount')
|
||||
Open 'NICA_CHECKLISTS' to hNicaChecklists then
|
||||
EOF = False$
|
||||
Select hNicaChecklists
|
||||
Loop
|
||||
ReadNext NicaChecklistId else EOF = True$
|
||||
Until EOF
|
||||
Lock hNicaChecklists, NicaChecklistId then
|
||||
LogData<1> = OConv(Datetime(), 'DT/^S')
|
||||
LogData<2> = Machine
|
||||
LogData<3> = 'Successfully locked NICA_CHECKLISTS ':NicaChecklistId:' for update.'
|
||||
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
|
||||
Read NicaChecklistRec from hNicaChecklists, NicaChecklistId then
|
||||
InstructionNameKey = NicaChecklistRec<NICA_CHECKLISTS.INTRUCTION_NAME_KEY$>
|
||||
If InstructionNameKey NE '' then
|
||||
Done = False$
|
||||
For InstructionIndex = 1 to NumJsonChecklists
|
||||
InstructionName = SRP_Json(objAllChecklistsJsonArray, 'GetValue', '[':InstructionIndex:'].name')
|
||||
If (IndexC(InstructionName, InstructionNameKey, 1) GT 0) then
|
||||
// Found matching json object
|
||||
BaseInstructionId = SRP_Json(objAllChecklistsJsonArray, 'GetValue', '[':InstructionIndex:'].baseInstructionId')
|
||||
WriteV BaseInstructionId on hNicaChecklists, NicaChecklistId, NICA_CHECKLISTS.NICA_BASE_INSTRUCTION_ID$ then
|
||||
LogData<1> = OConv(Datetime(), 'DT/^S')
|
||||
LogData<2> = Machine
|
||||
LogData<3> = 'Successfully updated NICA_BASE_INSTRUCTION_ID ':BaseInstructionId:' on NICA_CHECKLISTS ':NicaChecklistId:'.'
|
||||
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
|
||||
Done = True$
|
||||
end else
|
||||
ErrorMsg = 'Error in ':Service:' service. Error updating NICA_CHECKLISTS record ':NicaChecklistId:'.'
|
||||
LogData<1> = OConv(Datetime(), 'DT/^S')
|
||||
LogData<2> = Machine
|
||||
LogData<3> = 'Failed to write NICA_BASE_INSTRUCTION_ID ':BaseInstructionId:' on NICA_CHECKLISTS ':NicaChecklistId:'.'
|
||||
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
|
||||
StatusState = 'CRITICAL'
|
||||
end
|
||||
end
|
||||
Until Done
|
||||
Next InstructionIndex
|
||||
end else
|
||||
LogData<1> = OConv(Datetime(), 'DT/^S')
|
||||
LogData<2> = Machine
|
||||
LogData<3> = 'Failed to update NICA_BASE_INSTRUCTION_ID. Null INSTRUCTION_NAME_KEY in NICA_CHECKLISTS ':NicaChecklistId:'.'
|
||||
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
|
||||
StatusState = 'CRITICAL'
|
||||
end
|
||||
end else
|
||||
LogData<1> = OConv(Datetime(), 'DT/^S')
|
||||
LogData<2> = Machine
|
||||
LogData<3> = 'Failed to update NICA_BASE_INSTRUCTION_ID. Error reading NICA_CHECKLISTS ':NicaChecklistId:'.'
|
||||
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
|
||||
StatusState = 'CRITICAL'
|
||||
end
|
||||
Unlock hNicaChecklists, NicaChecklistId then
|
||||
LogData<1> = OConv(Datetime(), 'DT/^S')
|
||||
LogData<2> = Machine
|
||||
LogData<3> = 'Successfully unlocked NICA_CHECKLISTS ':NicaChecklistId:'.'
|
||||
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
|
||||
end else
|
||||
LogData<1> = OConv(Datetime(), 'DT/^S')
|
||||
LogData<2> = Machine
|
||||
LogData<3> = 'Failed to unlock NICA_CHECKLISTS ':NicaChecklistId:'.'
|
||||
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
|
||||
StatusState = 'CRITICAL'
|
||||
end
|
||||
end else
|
||||
LogData<1> = OConv(Datetime(), 'DT/^S')
|
||||
LogData<2> = Machine
|
||||
LogData<3> = 'Failed to lock NICA_CHECKLISTS ':NicaChecklistId:' for update.'
|
||||
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
|
||||
end
|
||||
Repeat
|
||||
end else
|
||||
ErrorMsg = 'Error in ':Service:' service. Error opening NICA_CHECKLISTS table.'
|
||||
end
|
||||
end else
|
||||
ErrorMsg = 'Error in ':Service:' service. Error parsing Checklist JSON returned from NicaIntegrationServiceApi.'
|
||||
end
|
||||
end else
|
||||
ErrorMsg = 'Error in ':Service:' service. Null Checklist JSON returned from NicaIntegrationServiceApi.'
|
||||
end
|
||||
end else
|
||||
ErrorMsg = 'Error in ':Service:' service. Error getting Checklist JSON from NicaIntegrationServiceApi.'
|
||||
end
|
||||
end else
|
||||
ErrorMsg = 'Error in ':Service:' service. Null BaseNicaIntegrationServiceApiUrl.'
|
||||
end
|
||||
|
||||
If ErrorMsg NE '' then
|
||||
LogData<1> = OConv(Datetime(), 'DT/^S')
|
||||
LogData<2> = Machine
|
||||
LogData<3> = ErrorMsg
|
||||
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
|
||||
StatusState = 'CRITICAL'
|
||||
end
|
||||
|
||||
Mona_Services('PostStatus', MonaResource, StatusName, StatusState)
|
||||
|
||||
LogData<1> = OConv(Datetime(), 'DT/^S')
|
||||
LogData<2> = Machine
|
||||
LogData<3> = 'End ':Service
|
||||
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
|
||||
|
||||
If ErrorMsg NE '' then Error_Services('Add', ErrorMsg)
|
||||
|
||||
end service
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Internal GoSubs
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1,7 +1,7 @@
|
||||
compile insert NICA_CHECKLISTS_EQUATES
|
||||
/*----------------------------------------
|
||||
Author : Table Create Insert Routine
|
||||
Written : 03/06/2025
|
||||
Written : 27/06/2025
|
||||
Description : Insert for Table NICA_CHECKLISTS
|
||||
----------------------------------------*/
|
||||
#ifndef __NICA_CHECKLISTS_EQUATES__
|
||||
@ -14,5 +14,6 @@ compile insert NICA_CHECKLISTS_EQUATES
|
||||
equ NICA_CHECKLISTS.REACTOR_TYPES$ to 5
|
||||
equ NICA_CHECKLISTS.REMOVE_IF_COMPLETE$ to 6
|
||||
equ NICA_CHECKLISTS.REMOVE_IF_INTRUSIVE$ to 7
|
||||
equ NICA_CHECKLISTS.INTRUCTION_NAME_KEY$ to 8
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user