diff --git a/RFXtoRP_HsrCarrierApt.ftl b/RFXtoRP_HsrCarrierApt.ftl index b8a39b8..ff2a9e1 100644 --- a/RFXtoRP_HsrCarrierApt.ftl +++ b/RFXtoRP_HsrCarrierApt.ftl @@ -2,7 +2,9 @@ <#-- input : message RFX --> <#-- project : projectId in ReflexPlatform --> <#-- organisation : organisationtId in ReflexPlatform --> -<#-- site : siteID in ReflexPlatform --> +<#include "ActorPrefix.ftl"> +<#include "HfRpConfig.ftl"> +<#include "ReflexUtils.ftl"> <#assign cloudEventMsg = JsonUtil.jsonToMap(input)> <#assign projectRP = project> diff --git a/RFXtoRP_HsrCarrierApt_AppointmentCarrierExpected.ftl b/RFXtoRP_HsrCarrierApt_AppointmentCarrierExpected.ftl index a3c6dae..c2ee7d6 100644 --- a/RFXtoRP_HsrCarrierApt_AppointmentCarrierExpected.ftl +++ b/RFXtoRP_HsrCarrierApt_AppointmentCarrierExpected.ftl @@ -1,5 +1,3 @@ -<#include "HfRpConfig.ftl"> -<#include "ReflexUtils.ftl"> [ <#assign ref_datetime = RfxDateTimetoUTCWithTimezone(carrier_apt.metadata.creation_datetime,time_zone_rfx) /> { diff --git a/RFXtoRP_HsrCarrierApt_ForceUpdateAppointment.ftl b/RFXtoRP_HsrCarrierApt_ForceUpdateAppointment.ftl index 3ef8dad..a6d9622 100644 --- a/RFXtoRP_HsrCarrierApt_ForceUpdateAppointment.ftl +++ b/RFXtoRP_HsrCarrierApt_ForceUpdateAppointment.ftl @@ -1,23 +1,12 @@ -<#include "HfRpConfig.ftl"> -<#include "ReflexUtils.ftl"> - - -<#-- à quoi correspond ID du transporteur dans l'API a voir avec Vincent--> - - [ { - <#assign appointment_reception_start_datetime = RfxDateTimetoUTCWithTimezone(carrier_apt.planned_unloading_start_datetime,time_zone_rfx) /> - <#assign appointment_expedition_start_datetime = RfxDateTimetoUTCWithTimezone(carrier_apt.planned_load_start_datetime,time_zone_rfx) /> - <#assign creation_datetime = RfxDateTimetoUTCWithTimezone(carrier_apt.metadata.creation_datetime,time_zone_rfx) /> - - "Header":{ + "Header":{ "ProjectID": "${projectRP}" }, "ActorID": "${carrier_apt.physical_depot}", <#if carrier_apt.unloading_appointment == "true" && carrier_apt.load_appointment == "false"> <#assign appointmentType = AppointmentType.APPOINTMENT_TYPE_RECEPTION> - <#assign duration = (carrier_apt.planned_unloading_start_datetime,carrier_apt.planned_unloading_end_datetime,time_zone_rfx) /> + <#assign duration = DurationBetweenTwoDatetimeInSeconds(carrier_apt.planned_unloading_start_datetime,carrier_apt.planned_unloading_end_datetime,time_zone_rfx) /> <#else> <#if carrier_apt.unloading_appointment == "false" && carrier_apt.load_appointment == "true" > <#assign appointmentType = AppointmentType.APPOINTMENT_TYPE_EXPEDITION> diff --git a/RFXtoRP_HsrCarrierApt_SiteCancelAppointment.ftl b/RFXtoRP_HsrCarrierApt_SiteCancelAppointment.ftl index cb8256b..f29573d 100644 --- a/RFXtoRP_HsrCarrierApt_SiteCancelAppointment.ftl +++ b/RFXtoRP_HsrCarrierApt_SiteCancelAppointment.ftl @@ -1,8 +1,4 @@ -<#include "HfRpConfig.ftl"> -<#include "ReflexUtils.ftl"> - <#assign ref_datetime = RfxDateTimetoUTCWithTimezone(carrier_apt.metadata.last_update_datetime,time_zone_rfx) /> - [ { "AppointmentID": "${carrier_apt.appointment_reference?trim?json_string}", diff --git a/RFXtoRP_HsrCarrierApt_SiteForceBookAppointment.ftl b/RFXtoRP_HsrCarrierApt_SiteForceBookAppointment.ftl index c240f5c..a107ef8 100644 --- a/RFXtoRP_HsrCarrierApt_SiteForceBookAppointment.ftl +++ b/RFXtoRP_HsrCarrierApt_SiteForceBookAppointment.ftl @@ -1,13 +1,9 @@ -<#include "HfRpConfig.ftl"> -<#include "ReflexUtils.ftl"> -<#-- à quoi correspond ID du transporteur dans l'API a voir avec Vincent--> - [ { "Header":{ "ProjectID": "${projectRP}" }, - "ActorID": "${RFXtoRPprefixDepot(carrier_apt.physical_depot?json_string)}", + "ActorID": "${RPtoRFXprefixDepot("DPF")}", "AppointmentID": "${carrier_apt.appointment_reference?json_string}", "TimeZone":"${time_zone_rfx}", <#if carrier_apt.unloading_appointment == "true" && carrier_apt.load_appointment == "false"> diff --git a/RFXtoRP_HsrCarrierApt_SiteForceUpdateAppointment.ftl b/RFXtoRP_HsrCarrierApt_SiteForceUpdateAppointment.ftl index 39f7bbe..f10c7e5 100644 --- a/RFXtoRP_HsrCarrierApt_SiteForceUpdateAppointment.ftl +++ b/RFXtoRP_HsrCarrierApt_SiteForceUpdateAppointment.ftl @@ -1,8 +1,3 @@ -<#include "HfRpConfig.ftl"> -<#include "ReflexUtils.ftl"> - - - [ { <#assign appointment_reception_start_datetime = RfxDateTimetoUTCWithTimezone(carrier_apt.planned_unloading_start_datetime,time_zone_rfx) /> diff --git a/RFXtoRP_RestResponse.ftl b/RFXtoRP_RestResponse.ftl index 5276881..6faa7a8 100644 --- a/RFXtoRP_RestResponse.ftl +++ b/RFXtoRP_RestResponse.ftl @@ -200,6 +200,88 @@ ] <#break> + <#case "appointment_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}" /> + + <#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" > + [ + { + <# stop "Création rdz OK" > + + <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowDeleted> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_Receipt_ExecutionflowDeleted.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"> + } + ] + + + <#break> + <#default> + [ + { + <#if restResponsetMsg.body?? > + <#assign restResponseBody = JsonUtil.decodeBase64(restResponsetMsg.body) /> + <#else> + <#assign restResponseBody = "${restResponsetMsg?trim?json_string}" /> + + <#assign apiReflexPlatformID = ApiReflexPlatformID.PlatformLogCreate> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_PlatformLogCreate.ftl"> + }, + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowAllocationError> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_RestResponseAllocationError.ftl"> + } + ] + + <#break> + <#default> <#stop> diff --git a/RPtoRFX_CarrierAppointment.ftl b/RPtoRFX_CarrierAppointment.ftl index 27a7663..ecd0794 100644 --- a/RPtoRFX_CarrierAppointment.ftl +++ b/RPtoRFX_CarrierAppointment.ftl @@ -1,12 +1,9 @@ -<#include "ActorPrefix.ftl"> -<#include "HfRpConfig.ftl"> - { "id" : {"refid" : "${eventRP.refid?json_string}"}, "route" : "rest/public/v1/physical_depots/{physical_depot_code}/carrier_appointments", "method" : "POST", "uri_substitutions": { - "physical_depot_code": "DPF" <#-- "${RPtoRFXprefixDepot(appointment.ActorID)}" --> + "physical_depot_code": "${RPtoRFXprefixDepot("DPF")}" <#-- "${RPtoRFXprefixDepot(appointment.ActorID)}" --> }, "payload" : { @@ -25,11 +22,11 @@ <#case "APPOINTMENT_TYPE_RECEPTION"> "unloading_appointment" : "true", "load_appointment" : "false", - "planned_unloading_start_datetime : "${appointment.Slot.StartDateTime?iso_nz(time_zone_rfx))}", + "planned_unloading_start_datetime : "${appointment.Slot.StartDateTime?iso_nz(time_zone_rfx)}", "planned_unloading_end_datetime": "${AddSecondsToDatetime(appointment.Slot.StartDateTime,appointment.Slot.DurationInSeconds)?iso_nz(time_zone_rfx)}" <#break> <#default> - <#stop "appointment.AppointmentType not implemented> + <#stop "appointment.AppointmentType not implemented" > "planned_carrier" : "${appointment.CarrierName?json_string}", @@ -37,8 +34,8 @@ <#if appointment.Commissions??> "physical_receipt_list": [ <#list appointment.Commissions as commission> - { - "receipt_activity": "str", + <#-- { + "receipt_activity": "str", "originator_code": "string", "physical_receipt_reference": "string", "receipt_year": 0, @@ -65,6 +62,7 @@ "ExecutionflowID": "DPFALIDEPT ALIMSPA-121125-02" } } + --> <#sep>, ], diff --git a/ReflexUtils.ftl b/ReflexUtils.ftl index 9103c0a..4199deb 100644 --- a/ReflexUtils.ftl +++ b/ReflexUtils.ftl @@ -19,9 +19,9 @@ <#-- -------------------------------------------------------------------------------------------- --> -<#-- duration between two datetime in second --> +<#-- Duration between two datetimes in second --> <#-- -------------------------------------------------------------------------------------------- --> -<#function DurationBetweenTwoDatetimeInsecond startDate endDate> +<#function DurationBetweenTwoDatetimeInSeconds startDate endDate> <#return (endDate?long - startDate?long) / 1000 >