You've already forked reflex-wms-connector
205 lines
10 KiB
Java
205 lines
10 KiB
Java
<#-- **** input parameters ***** -->
|
|
<#-- input : message HARDIS WMS -->
|
|
<#-- project : projectId in HARDIS SC NETWORK -->
|
|
<#-- organisation : organisationtId in HARDIS SC NETWORK -->
|
|
|
|
<#assign cloudEventMsg = JsonUtil.jsonToMap(input)>
|
|
<#assign projectRP = project>
|
|
<#assign organisationRP = organisation>
|
|
|
|
<#assign aDateTime = .now>
|
|
|
|
<#switch cloudEventMsg.action>
|
|
<#case "C">
|
|
<#-- *********************************************** Action = CREATE ******************** -->
|
|
|
|
<#assign dataRfx = JsonUtil.decodeBase64(cloudEventMsg.data) />
|
|
<#assign receipt = JsonUtil.jsonToMap(dataRfx)>
|
|
<#if receipt.receipt_type?? && receipt.receipt_type = "030" && receipt.line_list?? && receipt.line_list[0]?? > <#-- if reception is a transfer type -->
|
|
[
|
|
{
|
|
<#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowDetected>
|
|
"apiReflexPlatformID" : "${apiReflexPlatformID}",
|
|
"datas" :
|
|
<#include "RFXtoRP_HsrReceiptList_TransfertExecutionflowDetected.ftl">
|
|
|
|
},
|
|
{
|
|
<#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowReceiptExpected>
|
|
"apiReflexPlatformID" : "${apiReflexPlatformID}",
|
|
"datas" :
|
|
<#include "RFXtoRP_HsrReceiptList_TransfertReceiptExpected.ftl">
|
|
}
|
|
]
|
|
<#else>
|
|
<#if receipt.line_list ?? && receipt.line_list[0]??>
|
|
[
|
|
{
|
|
<#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowDetected>
|
|
"apiReflexPlatformID" : "${apiReflexPlatformID}",
|
|
"datas" :
|
|
<#include "RFXtoRP_HsrReceiptList_ExecutionflowDetected.ftl">
|
|
|
|
},
|
|
{
|
|
<#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowReceiptExpected>
|
|
"apiReflexPlatformID" : "${apiReflexPlatformID}",
|
|
"datas" :
|
|
<#include "RFXtoRP_HsrReceiptList_ReceiptExpected.ftl">
|
|
}
|
|
]
|
|
<#else>
|
|
<#stop>
|
|
</#if>
|
|
</#if>
|
|
<#break>
|
|
<#case "U">
|
|
<#-- *********************************************** Action = UPDATE ******************** -->
|
|
<#assign dataRfx = JsonUtil.decodeBase64(cloudEventMsg.data) />
|
|
<#assign receipt = JsonUtil.jsonToMap(dataRfx)>
|
|
[
|
|
<#if receipt.receipt_type?? && receipt.receipt_type == "030" && receipt.receipt_confirmed == "true" && receipt.confirmation_total_level_1==0 && receipt.confirmation_total_level_2==0 && receipt.confirmation_total_level_3==0>
|
|
{
|
|
<#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowCancelled>
|
|
"apiReflexPlatformID" : "${apiReflexPlatformID}",
|
|
"datas" :
|
|
<#include "RFXtoRP_HsrReceiptList_TransfertExecutionflowCancelled.ftl">
|
|
}
|
|
<#else>
|
|
<#if receipt.receipt_type?? && receipt.receipt_type == "030" && receipt.receipt_confirmed == "true">
|
|
<#if receipt.origin_order_line_depot?? && receipt.origin_order_line_depot!="">
|
|
<#assign ID = "${receipt.origin_order_line_depot?trim?json_string}${receipt.activity_code?trim?json_string}${receipt.originator_code?trim?json_string}${receipt.receipt_reference?trim?json_string}"/>
|
|
<#else>
|
|
<#assign ID = "R${receipt.physical_depot_code?trim?json_string}${receipt.activity_code?trim?json_string}${receipt.originator_code?trim?json_string}${receipt.receipt_year}${receipt.receipt_number}"/>
|
|
</#if>
|
|
<#assign payload = '{"Header": {"ProjectID": "${projectRP!""}"},"IDs": [{"RefID": ${ID}"}]}' />
|
|
<#assign queryApiReflexPlatformID = QueryApiReflexPlatformID.ExecutionflowGetByIds>
|
|
<#assign response = QueryApiReflexPlatformCall.call(queryApiReflexPlatformID,payload) />
|
|
<#assign executionflowRP = JsonUtil.jsonToMap(response)>
|
|
<#if executionflowRP?? && executionflowRP.Objects?? && executionflowRP.Objects[0]?? && executionflowRP.Objects[0].ID.RefID?? >
|
|
{
|
|
<#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowReceiptCompleted>
|
|
"apiReflexPlatformID" : "${apiReflexPlatformID}",
|
|
"datas" :
|
|
<#include "RFXtoRP_HsrReceiptList_TransfertExecutionflowReceiptCompleted.ftl">
|
|
}
|
|
<#else>
|
|
{
|
|
<#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowDetected>
|
|
"apiReflexPlatformID" : "${apiReflexPlatformID}",
|
|
"datas" :
|
|
<#include "RFXtoRP_HsrReceiptList_TransfertExecutionflowDetected.ftl">
|
|
},
|
|
{
|
|
<#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowReceiptCompleted>
|
|
"apiReflexPlatformID" : "${apiReflexPlatformID}",
|
|
"datas" :
|
|
<#include "RFXtoRP_HsrReceiptList_TransfertExecutionflowReceiptCompleted.ftl">
|
|
}
|
|
</#if>
|
|
<#else>
|
|
<#if receipt.receipt_confirmed?? && receipt.receipt_confirmed == "true" && receipt.confirmation_total_level_1==0 && receipt.confirmation_total_level_2==0 && receipt.confirmation_total_level_3==0>
|
|
{
|
|
<#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowCancelled>
|
|
"apiReflexPlatformID" : "${apiReflexPlatformID}",
|
|
"datas" :
|
|
<#include "RFXtoRP_HsrReceiptList_ExecutionflowCancelled.ftl">
|
|
}
|
|
<#else>
|
|
<#if receipt.receipt_confirmed ?? && receipt.receipt_confirmed == "true" >
|
|
<#assign ID = "R${receipt.physical_depot_code?trim?json_string}${receipt.activity_code?trim?json_string}${receipt.originator_code?trim?json_string}${receipt.receipt_year}${receipt.receipt_number}"/>
|
|
<#assign payload = '{"Header": {"ProjectID": "${projectRP!""}"},"IDs": [{"RefID": ${ID}"}]}' />
|
|
<#assign queryApiReflexPlatformID = QueryApiReflexPlatformID.ExecutionflowGetByIds>
|
|
<#assign response = QueryApiReflexPlatformCall.call(queryApiReflexPlatformID,payload) />
|
|
<#assign executionflowRP = JsonUtil.jsonToMap(response)>
|
|
<#if executionflowRP?? && executionflowRP.Objects?? && executionflowRP.Objects[0]?? && executionflowRP.Objects[0].ID.RefID?? >
|
|
{
|
|
<#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowReceiptCompleted>
|
|
"apiReflexPlatformID" : "${apiReflexPlatformID}",
|
|
"datas" :
|
|
<#include "RFXtoRP_HsrReceiptList_ExecutionflowReceiptCompleted.ftl">
|
|
}
|
|
<#else>
|
|
{
|
|
<#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowDetected>
|
|
"apiReflexPlatformID" : "${apiReflexPlatformID}",
|
|
"datas" :
|
|
<#include "RFXtoRP_HsrReceiptList_ExecutionflowDetected.ftl">
|
|
},
|
|
{
|
|
<#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowReceiptCompleted>
|
|
"apiReflexPlatformID" : "${apiReflexPlatformID}",
|
|
"datas" :
|
|
<#include "RFXtoRP_HsrReceiptList_ExecutionflowReceiptCompleted.ftl">
|
|
}
|
|
</#if>
|
|
<#else>
|
|
<#if receipt.receipt_type?? && receipt.receipt_type == "030" && receipt.receipt_confirmed == "false" && receipt.line_list?? && receipt.line_list[0]??>
|
|
<#if receipt.receipt_reference?? && receipt.receipt_reference!="">
|
|
[
|
|
{
|
|
<#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowDetected>
|
|
"apiReflexPlatformID" : "${apiReflexPlatformID}",
|
|
"datas" :
|
|
<#include "RFXtoRP_HsrReceiptList_TransfertExecutionflowDetected.ftl">
|
|
},
|
|
{
|
|
<#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowReceiptExpected>
|
|
"apiReflexPlatformID" : "${apiReflexPlatformID}",
|
|
"datas" :
|
|
<#include "RFXtoRP_HsrReceiptList_TransfertReceiptExpected.ftl">
|
|
}
|
|
]
|
|
<#else>
|
|
<#stop> <#-- Receipt reference for transfer is empty-->
|
|
</#if>
|
|
<#else>
|
|
<#if receipt.line_list ?? receipt.line_list[0]??>
|
|
{
|
|
<#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowDetected>
|
|
"apiReflexPlatformID" : "${apiReflexPlatformID}",
|
|
"datas" :
|
|
<#include "RFXtoRP_HsrReceiptList_ExecutionflowDetected.ftl">
|
|
},
|
|
{
|
|
<#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowReceiptExpected>
|
|
"apiReflexPlatformID" : "${apiReflexPlatformID}",
|
|
"datas" :
|
|
<#include "RFXtoRP_HsrReceiptList_ReceiptExpected.ftl">
|
|
}
|
|
<#else>
|
|
<#stop>
|
|
</#if>
|
|
</#if>
|
|
</#if>
|
|
</#if>
|
|
</#if>
|
|
</#if>
|
|
]
|
|
<#break>
|
|
|
|
<#case "D">
|
|
<#-- *********************************************** Action = DELETE ******************** -->
|
|
<#assign dataRfx = JsonUtil.decodeBase64(cloudEventMsg.data) />
|
|
<#assign receipt = JsonUtil.jsonToMap(dataRfx)>
|
|
<#if receipt.line_list ??>
|
|
[
|
|
{
|
|
|
|
<#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowCancelled>
|
|
"apiReflexPlatformID" : "${apiReflexPlatformID}",
|
|
"datas" :
|
|
<#include "RFXtoRP_HsrReceiptList_ExecutionflowCancelled.ftl">
|
|
}
|
|
]
|
|
<#else>
|
|
<#stop> <#-- No line-->
|
|
</#if>
|
|
<#break>
|
|
|
|
|
|
<#default>
|
|
<#stop >
|
|
</#switch>
|
|
|