diff --git a/RFXtoRP_HliPrepaL.ftl b/RFXtoRP_HliPrepaL.ftl index e643caa..1756f5e 100644 --- a/RFXtoRP_HliPrepaL.ftl +++ b/RFXtoRP_HliPrepaL.ftl @@ -3,6 +3,7 @@ <#-- project : projectId in ReflexPlatform --> <#-- organisation : organisationtId in ReflexPlatform --> <#include "ReflexUtils.ftl"> +<#include "HfRpConfig.ftl"> <#assign cloudEventMsg = JsonUtil.jsonToMap(input)> <#assign projectRP = project> <#assign organisationRP = organisation> @@ -13,17 +14,79 @@ <#switch cloudEventMsg.action> <#case "C"> <#--<#case "U"> - <#-- *********************************************** Action = CREATE or UPDATE ******************** --> - <#assign dataRfx = JsonUtil.decodeBase64(cloudEventMsg.data) /> - <#assign preparationOrderLines = JsonUtil.jsonToMap(dataRfx)> - <#stop "no generic FTL file available yet for preparationOrderLines"> - <#break> +<#-- *********************************************** Action = CREATE or UPDATE ******************** --> +<#assign dataRfx = JsonUtil.decodeBase64(cloudEventMsg.data) /> +<#assign preparationOrder = JsonUtil.jsonToMap(dataRfx)> + + <#if preparationOrder.total_lv_validated !=0> + <#if preparationOrder.preparation_line_lst??> + [ + <#assign first = true> + <#assign refIDHmap ={}> + <#assign hd_numberHmap ={}> + <#assign hd_numberHmapHUadded ={}> + <#list preparationOrder.preparation_line_lst?filter(l ->l.despatched_ipg_list?? && l.preparation_order_originator_reference!="") as preparation_line> + <#list preparation_line.despatched_ipg_list as despatched_ipg> + <#assign HUadded_packing_datetime = RfxDateTimetoUTCWithTimezone(preparation_line.confirmation_datetime,time_zone_rfx) /> + <#if (!hd_numberHmap[despatched_ipg.hd_number]?? || !hd_numberHmap[despatched_ipg.carton_number]??) && (trackingNumberSource==2 || trackingNumberSource==3 || (despatched_ipg.consignment_unit_id!="" && trackingNumberSource==1))> + <#if !first > + <#assign first = false> + , + + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.TrackingHULabeled> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_HsrPrepa_TrackingHuLabelled.ftl"> + } + + <#if despatched_ipg.carton_number != "000000000000000000" && despatched_ipg.carton_number!=despatched_ipg.hd_number > + <#if !first > + <#assign first = false> + , + + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.HandlingunitHUsAdded> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_HsrPrepa_HandlingunitHUsAdded.ftl"> + }, + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.HandlingunitDispatched> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_HsrPrepa_HUsAdded_HandlingUnitDispatched.ftl"> + } + <#if !hd_numberHmapHUadded[despatched_ipg.hd_number]?? && (trackingNumberSource==2 || trackingNumberSource==3 )> + <#assign hd_numberHmapHUadded += {despatched_ipg.hd_number,despatched_ipg.hd_number}> + , + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.TrackingHULabeled> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_HsrPrepa_HUsAdded_TrackingHuLabelled.ftl"> + } + + + + + + <#assign refIDHmap ={}> + ] + <#else> + <#-- No line--> + <#stop > + + <#else> + <#-- no confirmed quantity for the preparation - preparation closed--> + <#stop > + + + +<#break> <#case "D"> - <#-- *********************************************** Action = DELETE ******************** --> - <#assign dataRfx = JsonUtil.decodeBase64(cloudEventMsg.data) /> - <#assign preparationOrderLines = JsonUtil.jsonToMap(dataRfx)> - <#stop "no generic FTL file available yet for preparationOrderLines"> - <#break> +<#-- *********************************************** Action = DELETE ******************** --> +<#stop> <#break> <#default> diff --git a/RFXtoRP_HliReceiptLr.ftl b/RFXtoRP_HliReceiptLr.ftl index 61cdef6..f2c6601 100644 --- a/RFXtoRP_HliReceiptLr.ftl +++ b/RFXtoRP_HliReceiptLr.ftl @@ -11,22 +11,118 @@ <#switch cloudEventMsg.action> <#case "C"> - <#case "U"> <#-- *********************************************** Action = CREATE ******************** --> - <#assign dataRfx = JsonUtil.decodeBase64(cloudEventMsg.data) /> - <#assign receiptLines = JsonUtil.jsonToMap(dataRfx)> + <#assign dataRfx = JsonUtil.decodeBase64(cloudEventMsg.data) /> + <#assign receipt = JsonUtil.jsonToMap(dataRfx)> + <#if receipt.receipt_reference ?? && receipt.receipt_reference!=""> + <#if receipt.receipt_type == "030"> + <#stop "ignored message because receipt type = transfert"> + <#else> + <#if receipt.line_list ??> + [ + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowLinesAdded> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_HsrReceiptList_ExecutionflowLinesAdded.ftl"> - <#stop "no generic FTL file available yet for receiptLines"> - <#break> + }, + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowReceiptExpected> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_HsrReceiptList_ReceiptExpected.ftl"> + + } + ] + <#else> + <#-- No line--> + <#stop> + + + <#else> + <#-- "Receipt reference is empty"--> + <#stop> + + <#break> + <#case "U"> + <#-- *********************************************** Action = UPDATE ******************** --> + <#assign dataRfx = JsonUtil.decodeBase64(cloudEventMsg.data) /> + <#assign receipt = JsonUtil.jsonToMap(dataRfx)> + [ + <#if receipt.receipt_reference?? && receipt.receipt_reference!=""> + <#if 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 == "true" > + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowReceiptCompleted> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_HsrReceiptList_ExecutionflowReceiptCompleted.ftl"> + } + <#else> + <#if receipt.receipt_type == "030"> + <#stop "ignored message because receipt type = transfert"> + <#else> + <#if receipt.line_list ??> + { + <#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> + <#-- No line--> + <#stop> + + + + + <#else> + <#-- Receipt reference is empty--> + <#stop > + + ] + <#break> <#case "D"> <#-- *********************************************** Action = DELETE ******************** --> <#assign dataRfx = JsonUtil.decodeBase64(cloudEventMsg.data) /> - <#assign receiptLines = JsonUtil.jsonToMap(dataRfx)> + <#assign receipt = JsonUtil.jsonToMap(dataRfx)> + [ + <#if receipt.receipt_reference?? && receipt.receipt_reference!=""> + <#if receipt.line_list ??> + { + + <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowCancelled> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_HsrReceiptList_ExecutionflowCancelled.ftl"> + } + <#else> + <#-- No line--> + <#stop> + + <#else> + <#-- Receipt reference is empty--> + <#stop > + + ] + <#break> - <#stop "no generic FTL file available yet for receiptLines"> - <#break> <#default> <#stop > diff --git a/RFXtoRP_HliReceiptLr_ExecutionflowLinesAdded.ftl b/RFXtoRP_HliReceiptLr_ExecutionflowLinesAdded.ftl new file mode 100644 index 0000000..5a805a0 --- /dev/null +++ b/RFXtoRP_HliReceiptLr_ExecutionflowLinesAdded.ftl @@ -0,0 +1,60 @@ +<#include "HfRpConfig.ftl"> +<#include "ReflexUtils.ftl"> +<#include "ActorPrefix.ftl"> +[ + { + <#assign receipt_datetime = RfxDateTimetoUTCWithTimezone(receipt.receipt_datetime,time_zone_rfx) /> + <#assign receipt_creation_datetime = RfxDateTimetoUTCWithTimezone(receipt.creation_datetime,time_zone_rfx) /> + "Header": { + "ProjectID": "${projectRP}" + }, + "ID": { + "RefID": "${receipt.receipt_reference?trim?json_string}", + "RefDate": { + "DateTime": "${receipt_creation_datetime}", + "AuthorTimeZone": "${time_zone_rfx}" + } + }, + "Payload": { + <#if receipt.line_list??> + "Lines" : [ + <#list receipt.line_list as line> + { + "LineID": "${line.receipt_line_number}", + <#-- Line Metadata inclusion --> + <#include "RFXtoRP_HsrReceiptList_ExecutionflowDetected_LineMetadata.ftl">, + "RequestedContent": + { + "Goods": + { + "ItemID": "${line.item_code?trim?json_string!"0"}", + "LVBranchID": "${line.item_lv_code?json_string!"0"}", + <#if (line.line_without_detail?? && line.line_without_detail.priority_date?length != 0) && (line.line_without_detail.priority_date?starts_with("00") == false)> + <#assign line_without_detail_priority_date = line.line_without_detail.priority_date?datetime(rfx_date_format_default)?iso_utc /> + "PriorityDate": "${line_without_detail_priority_date}", + <#else> + <#if (line.line_detail?? && line.line_detail?size == 1 && line.line_detail[0].priority_date?length != 0) && (line.line_detail[0].priority_date?starts_with("00") == false)> + <#assign line_detail_priority_date = line.line_detail[0].priority_date?datetime(rfx_date_format_default)?iso_utc /> + "PriorityDate": "${line_detail_priority_date}", + <#else> + "PriorityDate": "1970-01-01T00:00:00Z", + + + <#-- Segmentation Keys inclusion --> + <#include "RFXtoRP_HsrReceiptList_ExecutionflowDetected_SegmentationKeys.ftl"> + }, + "Quantity" : + { + "LVID": "${quantity_in_base_lv_RP_Cst}", + "Value": "${line.order_quantity_in_lv!0}" + } + } + + } + <#sep>, + + ] + + } + } +] diff --git a/RFXtoRP_HlrProL.ftl b/RFXtoRP_HlrProL.ftl index 7b4504b..ce907a7 100644 --- a/RFXtoRP_HlrProL.ftl +++ b/RFXtoRP_HlrProL.ftl @@ -12,20 +12,60 @@ <#switch cloudEventMsg.action> <#case "C"> <#case "U"> - <#-- *********************************************** Action = CREATE or UPDATE ******************** --> + <#-- *********************************************** Action = CREATE or UPDATE ******************** --> <#assign dataRfx = JsonUtil.decodeBase64(cloudEventMsg.data) /> - <#assign preparationOrderLines = JsonUtil.jsonToMap(dataRfx)> - - <#stop "no generic FTL file available yet for preparationOrderLines"> - <#break> + <#assign preparation_order = JsonUtil.jsonToMap(dataRfx)> + [ + <#if preparation_order.originator_reference?? && preparation_order.originator_reference!=""> + <#-- check preparation type code (internal order and reservation are ignored) --> + <#if preparation_order.preparation_type_code?? && (preparation_order.preparation_type_code == "010" || preparation_order.preparation_type_code == "030")> + <#if preparation_order.line_list??> + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowLinesAdded> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_HlrProL_ExecutionflowLinesAdded.ftl"> + } + <#else> + <#-- No line --> + <#stop> + + <#else> + <#-- preparation order type not supported --> + <#stop> + + <#else> + <#-- PRO reference is empty --> + <#stop> + + ] + <#break> <#case "D"> <#-- *********************************************** Action = DELETE ******************** --> - <#assign dataRfx = JsonUtil.decodeBase64(cloudEventMsg.data) /> - <#assign preparationOrderLines = JsonUtil.jsonToMap(dataRfx)> + <#assign dataRfx = JsonUtil.decodeBase64(cloudEventMsg.data) /> + <#assign preparation_order = JsonUtil.jsonToMap(dataRfx)> + [ + <#if preparation_order.originator_reference?? && preparation_order.originator_reference!=""> + <#if preparation_order.line_list??> + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowCancelled> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_HsrPro_ExecutionflowCancelled.ftl"> + } + <#else> + <#-- No line --> + <#stop> + + <#else> + <#-- PRO reference is empty --> + <#stop> + + ] + <#break> + - <#stop "no generic FTL file available yet for preparationOrderLines"> - <#break> <#default> <#stop > diff --git a/RFXtoRP_HlrProL_ExecutionflowLinesAdded.ftl b/RFXtoRP_HlrProL_ExecutionflowLinesAdded.ftl new file mode 100644 index 0000000..d80e0ca --- /dev/null +++ b/RFXtoRP_HlrProL_ExecutionflowLinesAdded.ftl @@ -0,0 +1,55 @@ +<#include "HfRpConfig.ftl"> +<#include "ReflexUtils.ftl"> +<#include "ActorPrefix.ftl"> +[ + { + <#assign planned_final_delivery_start_datetime = RfxDateTimetoUTCWithTimezone(preparation_order.planned_final_delivery_start_datetime,time_zone_rfx) /> + <#assign pro_creation_datetime = RfxDateTimetoUTCWithTimezone(preparation_order.creation_datetime,time_zone_rfx) /> + "Header": { + "ProjectID": "${projectRP}" + }, + "ID": { + "RefID": "${preparation_order.originator_reference?trim?json_string}", + "RefDate": { + "DateTime": "${pro_creation_datetime}", + "AuthorTimeZone": "${time_zone_rfx}" + } + }, + "Payload": { + <#if preparation_order.line_list??> + "Lines" : [ + <#list preparation_order.line_list as preparation_order_line > + { + <#if (preparation_order_line.originator_reference_line_number!0) != 0> + "LineID": "${preparation_order_line.originator_reference_line_number}", + <#else> + "LineID": "${preparation_order_line.preparation_order_line_number!0}", + + <#-- Line Metadata inclusion --> + <#include "RFXtoRP_HsrPro_ExecutionflowDetected_LineMetadata.ftl">, + "RequestedContent": + { + "Goods": + { + "ItemID": "${preparation_order_line.item_code?trim?json_string!"0"}", + "LVBranchID": "${preparation_order_line.item_lv_code?json_string!"0"}", + <#if (preparation_order_line.optional_attributes.forced_priority_date?length != 0) && (preparation_order_line.optional_attributes.forced_priority_date?starts_with("00") == false)> + <#assign forced_priority_date = preparation_order_line.optional_attributes.forced_priority_date?datetime(rfx_date_format_default)?iso_utc /> + "PriorityDate": "${forced_priority_date}", + + <#-- Segmentation Keys inclusion --> + <#include "RFXtoRP_HsrPro_ExecutionflowDetected_SegmentationKeys.ftl"> + }, + "Quantity" : + { + "LVID": "${quantity_in_base_lv_RP_Cst}", + "Value": "${preparation_order_line.base_lv_quantity_to_prepare!0}" + } + } + }<#sep>, + + ] + + } + } +]