reflex-wms-connector/RFXtoRP_RestResponse.ftl
2024-12-04 08:08:26 +01:00

207 lines
7.2 KiB
Java

<#-- **** input parameters ***** -->
<#-- input : Response message from Reflex -->
<#-- project : projectId in ReflexPlatform -->
<#-- organisation : organisationtId in ReflexPlatform -->
<#assign restResponsetMsg = JsonUtil.jsonToMap(input)>
<#assign id = JsonUtil.jsonToMap(restResponsetMsg.id!"{}")>
<#assign projectRP = project>
<#assign organisationRP = organisation>
<#assign aDateTime = .now>
<#assign no_apiRestReflexID = "no apiRestReflexID">
<#assign no_status = -99999>
<#switch id.apiRestReflexID!no_apiRestReflexID>
<#case no_apiRestReflexID>
[
{
<#if restResponsetMsg.body?? >
<#assign restResponseBody = JsonUtil.decodeBase64(restResponsetMsg.body) />
<#else>
<#assign restResponseBody = "${restResponsetMsg?trim?json_string}" />
</#if>
<#assign apiReflexPlatformID = ApiReflexPlatformID.PlatformLogCreate>
"apiReflexPlatformID" : "${apiReflexPlatformID}",
"datas" :
<#include "RFXtoRP_PlatformLogCreate.ftl">
}
]
<#break>
<#case "preparation_orders_post">
<#switch restResponsetMsg.status!no_status>
<#case no_status>
[
{
<#if restResponsetMsg.body?? >
<#assign restResponseBody = JsonUtil.decodeBase64(restResponsetMsg.body) />
<#else>
<#assign restResponseBody = "${restResponsetMsg?trim?json_string}" />
</#if>
<#assign apiReflexPlatformID = ApiReflexPlatformID.PlatformLogCreate>
"apiReflexPlatformID" : "${apiReflexPlatformID}",
"datas" :
<#include "RFXtoRP_PlatformLogCreate.ftl">
},
{
<#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowAllocationError>
"apiReflexPlatformID" : "${apiReflexPlatformID}",
"datas" :
<#include "RFXtoRP_RestResponseAllocationError.ftl">
}
]
<#break>
<#case 200>
<#case 201>
<#-- *********************************************** ApiRestID = preparation_orders_post ******************** -->
<#assign restResponseBody = JsonUtil.decodeBase64(restResponsetMsg.body) />
<#assign preparationOrderPostResponse = JsonUtil.jsonToMap(restResponseBody)>
<#if preparationOrderPostResponse.status?? && preparationOrderPostResponse.status == "SUCCESS" >
[
{
<#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowShipFromAcked>
"apiReflexPlatformID" : "${apiReflexPlatformID}",
"datas" :
<#include "RFXtoRP_PrepOrder_ShipFromAcked.ftl">
}
]
<#else>
<#if preparationOrderPostResponse.status?? && preparationOrderPostResponse.status == "WARN">
[
{
<#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowShipFromAcked>
"apiReflexPlatformID" : "${apiReflexPlatformID}",
"datas" :
<#include "RFXtoRP_PrepOrder_ShipFromAcked.ftl">
}
]
<#else>
[
{
<#assign restResponseBody = JsonUtil.decodeBase64(restResponsetMsg.body) />
<#assign apiReflexPlatformID = ApiReflexPlatformID.PlatformLogCreate>
"apiReflexPlatformID" : "${apiReflexPlatformID}",
"datas" :
<#include "RFXtoRP_PlatformLogCreate.ftl">
},
{
<#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowAllocationError>
"apiReflexPlatformID" : "${apiReflexPlatformID}",
"datas" :
<#include "RFXtoRP_RestResponseAllocationError.ftl">
}
]
</#if>
</#if>
<#break>
<#default>
[
{
<#if restResponsetMsg.body?? >
<#assign restResponseBody = JsonUtil.decodeBase64(restResponsetMsg.body) />
<#else>
<#assign restResponseBody = "${restResponsetMsg?trim?json_string}}" />
</#if>
<#assign apiReflexPlatformID = ApiReflexPlatformID.PlatformLogCreate>
"apiReflexPlatformID" : "${apiReflexPlatformID}",
"datas" :
<#include "RFXtoRP_PlatformLogCreate.ftl">
},
{
<#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowAllocationError>
"apiReflexPlatformID" : "${apiReflexPlatformID}",
"datas" :
<#include "RFXtoRP_RestResponseAllocationError.ftl">
}
]
</#switch>
<#break>
<#case "receipts_post">
<#switch restResponsetMsg.status!no_status>
<#case no_status>
[
{
<#if restResponsetMsg.body?? >
<#assign restResponseBody = JsonUtil.decodeBase64(restResponsetMsg.body) />
<#else>
<#assign restResponseBody = "${restResponsetMsg?trim?json_string}" />
</#if>
<#assign apiReflexPlatformID = ApiReflexPlatformID.PlatformLogCreate>
"apiReflexPlatformID" : "${apiReflexPlatformID}",
"datas" :
<#include "RFXtoRP_PlatformLogCreate.ftl">
},
{
<#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowAllocationError>
"apiReflexPlatformID" : "${apiReflexPlatformID}",
"datas" :
<#include "RFXtoRP_RestResponseAllocationError.ftl">
}
]
<#break>
<#case 200>
<#case 201>
<#-- *********************************************** ApiRestID = receipts_post ******************** -->
<#assign restResponseBody = JsonUtil.decodeBase64(restResponsetMsg.body) />
<#assign preparationOrderPostResponse = JsonUtil.jsonToMap(restResponseBody)>
<#if preparationOrderPostResponse.status?? && preparationOrderPostResponse.status == "SUCCESS" >
[
{
<#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowShipToAcked>
"apiReflexPlatformID" : "${apiReflexPlatformID}",
"datas" :
<#include "RFXtoRP_Receipt_ShipToAcked.ftl">
}
]
<#else>
[
{
<#assign restResponseBody = JsonUtil.decodeBase64(restResponsetMsg.body) />
<#assign apiReflexPlatformID = ApiReflexPlatformID.PlatformLogCreate>
"apiReflexPlatformID" : "${apiReflexPlatformID}",
"datas" :
<#include "RFXtoRP_PlatformLogCreate.ftl">
},
{
<#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowAllocationError>
"apiReflexPlatformID" : "${apiReflexPlatformID}",
"datas" :
<#include "RFXtoRP_RestResponseAllocationError.ftl">
}
]
</#if>
<#break>
<#default>
[
{
<#if restResponsetMsg.body?? >
<#assign restResponseBody = JsonUtil.decodeBase64(restResponsetMsg.body) />
<#else>
<#assign restResponseBody = "${restResponsetMsg?trim?json_string}" />
</#if>
<#assign apiReflexPlatformID = ApiReflexPlatformID.PlatformLogCreate>
"apiReflexPlatformID" : "${apiReflexPlatformID}",
"datas" :
<#include "RFXtoRP_PlatformLogCreate.ftl">
},
{
<#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowAllocationError>
"apiReflexPlatformID" : "${apiReflexPlatformID}",
"datas" :
<#include "RFXtoRP_RestResponseAllocationError.ftl">
}
]
</#switch>
<#break>
<#default>
<#stop>
</#switch>