From bd7b24fed755b8dc582e0981d38a4adc106faeb5 Mon Sep 17 00:00:00 2001 From: Francis Reat Date: Wed, 12 Nov 2025 17:10:56 +0100 Subject: [PATCH] modif sur les rdz --- ...P_HsrCarrierApt_ForceUpdateAppointment.ftl | 6 +- ...HsrCarrierApt_SiteForceBookAppointment.ftl | 6 +- ...rCarrierApt_SiteForceUpdateAppointment.ftl | 6 +- RPtoRFX_AppointmentEvent.ftl | 21 +++-- RPtoRFX_CarrierAppointment.ftl | 76 +++++++++++++++++++ ReflexUtils.ftl | 20 ++++- 6 files changed, 119 insertions(+), 16 deletions(-) create mode 100644 RPtoRFX_CarrierAppointment.ftl diff --git a/RFXtoRP_HsrCarrierApt_ForceUpdateAppointment.ftl b/RFXtoRP_HsrCarrierApt_ForceUpdateAppointment.ftl index d951834..3ef8dad 100644 --- a/RFXtoRP_HsrCarrierApt_ForceUpdateAppointment.ftl +++ b/RFXtoRP_HsrCarrierApt_ForceUpdateAppointment.ftl @@ -17,11 +17,11 @@ "ActorID": "${carrier_apt.physical_depot}", <#if carrier_apt.unloading_appointment == "true" && carrier_apt.load_appointment == "false"> <#assign appointmentType = AppointmentType.APPOINTMENT_TYPE_RECEPTION> - <#assign duration = RfxDurationBetweenTwoDateTimetoInSeconds(carrier_apt.planned_unloading_start_datetime,carrier_apt.planned_unloading_end_datetime,time_zone_rfx) /> + <#assign duration = (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> - <#assign duration = RfxDurationBetweenTwoDateTimetoInSeconds(carrier_apt.planned_load_start_datetime,carrier_apt.planned_load_end_datetime,time_zone_rfx) /> + <#assign duration = DurationBetweenTwoDatetimeInSeconds(carrier_apt.planned_load_start_datetime?datetime.iso,carrier_apt.planned_load_end_datetime?datetime.iso,time_zone_rfx) /> <#else> <#if carrier_apt.unloading_appointment == "true" && carrier_apt.load_appointment == "true"> <#assign appointmentType = AppointmentType.APPOINTMENT_TYPE_BOTH> @@ -62,7 +62,7 @@ <#if carrier_apt.unloading_appointment == "false" && carrier_apt.load_appointment == "true"> "StartDateTime": "${carrier_apt.planned_load_start_datetime}" <#else> - <#assign duration = RfxDurationBetweenTwoDateTimetoInSeconds(carrier_apt.planned_unloading_start_datetime,carrier_apt.planned_load_start_datetime,time_zone_rfx) /> + <#assign duration = DurationBetweenTwoDatetimeInSeconds(carrier_apt.planned_unloading_start_datetime,carrier_apt.planned_load_start_datetime,time_zone_rfx) /> <#if carrier_apt.unloading_appointment == "true" && carrier_apt.load_appointment == "true"> <#if duration >= 0> "StartDateTime": "${carrier_apt.planned_unloading_start_datetime}" diff --git a/RFXtoRP_HsrCarrierApt_SiteForceBookAppointment.ftl b/RFXtoRP_HsrCarrierApt_SiteForceBookAppointment.ftl index 1a08474..01b5643 100644 --- a/RFXtoRP_HsrCarrierApt_SiteForceBookAppointment.ftl +++ b/RFXtoRP_HsrCarrierApt_SiteForceBookAppointment.ftl @@ -17,11 +17,11 @@ "ActorID": "${carrier_apt.physical_depot}", <#if carrier_apt.unloading_appointment == "true" && carrier_apt.load_appointment == "false"> <#assign appointmentType = AppointmentType.APPOINTMENT_TYPE_RECEPTION> - <#assign duration = RfxDurationBetweenTwoDateTimetoInSeconds(carrier_apt.planned_unloading_start_datetime,carrier_apt.planned_unloading_end_datetime,time_zone_rfx) /> + <#assign duration = DurationBetweenTwoDatetimeInSeconds(carrier_apt.planned_unloading_start_datetime?datetime.iso,carrier_apt.planned_unloading_end_datetime?datetime.iso,time_zone_rfx) /> <#else> <#if carrier_apt.unloading_appointment == "false" && carrier_apt.load_appointment == "true" > <#assign appointmentType = AppointmentType.APPOINTMENT_TYPE_EXPEDITION> - <#assign duration = RfxDurationBetweenTwoDateTimetoInSeconds(carrier_apt.planned_load_start_datetime,carrier_apt.planned_load_end_datetime,time_zone_rfx) /> + <#assign duration = DurationBetweenTwoDatetimeInSeconds(carrier_apt.planned_load_start_datetime?datetime.iso,carrier_apt.planned_load_end_datetime?datetime.iso,time_zone_rfx) /> <#else> <#if carrier_apt.unloading_appointment == "true" && carrier_apt.load_appointment == "true"> <#assign appointmentType = AppointmentType.APPOINTMENT_TYPE_BOTH> @@ -47,7 +47,7 @@ <#if carrier_apt.unloading_appointment == "false" && carrier_apt.load_appointment == "true"> "StartDateTime": "${carrier_apt.planned_load_start_datetime}" <#else> - <#assign duration = RfxDurationBetweenTwoDateTimetoInSeconds(carrier_apt.planned_unloading_start_datetime,carrier_apt.planned_load_start_datetime,time_zone_rfx) /> + <#assign duration = DurationBetweenTwoDatetimeInSeconds(carrier_apt.planned_unloading_start_datetime?datetime.iso,carrier_apt.planned_load_start_datetime?datetime.iso,time_zone_rfx) /> <#if carrier_apt.unloading_appointment == "true" && carrier_apt.load_appointment == "true"> <#if duration >= 0> "StartDateTime": "${carrier_apt.planned_unloading_start_datetime}" diff --git a/RFXtoRP_HsrCarrierApt_SiteForceUpdateAppointment.ftl b/RFXtoRP_HsrCarrierApt_SiteForceUpdateAppointment.ftl index 571bfc4..39f7bbe 100644 --- a/RFXtoRP_HsrCarrierApt_SiteForceUpdateAppointment.ftl +++ b/RFXtoRP_HsrCarrierApt_SiteForceUpdateAppointment.ftl @@ -15,11 +15,11 @@ "ActorID": "${carrier_apt.physical_depot}", <#if carrier_apt.unloading_appointment == "true" && carrier_apt.load_appointment == "false"> <#assign appointmentType = AppointmentType.APPOINTMENT_TYPE_RECEPTION> - <#assign duration = RfxDurationBetweenTwoDateTimetoInSeconds(carrier_apt.planned_unloading_start_datetime,carrier_apt.planned_unloading_end_datetime,time_zone_rfx) /> + <#assign duration = DurationBetweenTwoDatetimeInSeconds(carrier_apt.planned_unloading_start_datetime?datetime.iso,carrier_apt.planned_unloading_end_datetime?datetime.iso,time_zone_rfx) /> <#else> <#if carrier_apt.unloading_appointment == "false" && carrier_apt.load_appointment == "true" > <#assign appointmentType = AppointmentType.APPOINTMENT_TYPE_EXPEDITION> - <#assign duration = RfxDurationBetweenTwoDateTimetoInSeconds(carrier_apt.planned_load_start_datetime,carrier_apt.planned_load_end_datetime,time_zone_rfx) /> + <#assign duration = DurationBetweenTwoDatetimeInSeconds(carrier_apt.planned_load_start_datetime?datetime.iso,carrier_apt.planned_load_end_datetime?datetime.iso,time_zone_rfx) /> <#else> <#if carrier_apt.unloading_appointment == "true" && carrier_apt.load_appointment == "true"> <#assign appointmentType = AppointmentType.APPOINTMENT_TYPE_BOTH> @@ -60,7 +60,7 @@ <#if carrier_apt.unloading_appointment == "false" && carrier_apt.load_appointment == "true"> "StartDateTime": "${carrier_apt.planned_load_start_datetime}" <#else> - <#assign duration = RfxDurationBetweenTwoDateTimetoInSeconds(carrier_apt.planned_unloading_start_datetime,carrier_apt.planned_load_start_datetime,time_zone_rfx) /> + <#assign duration = DurationBetweenTwoDatetimeInSeconds(carrier_apt.planned_unloading_start_datetime?datetime.iso,carrier_apt.planned_load_start_datetime?datetime.iso,time_zone_rfx) /> <#if carrier_apt.unloading_appointment == "true" && carrier_apt.load_appointment == "true"> <#if duration >= 0> "StartDateTime": "${carrier_apt.planned_unloading_start_datetime}" diff --git a/RPtoRFX_AppointmentEvent.ftl b/RPtoRFX_AppointmentEvent.ftl index 3ba3fb1..2647599 100644 --- a/RPtoRFX_AppointmentEvent.ftl +++ b/RPtoRFX_AppointmentEvent.ftl @@ -9,12 +9,23 @@ <#assign projectRP = project> <#assign organisationRP = organisation> -<#-- initialisation map for SegmentationKey and MetaData --> -<#assign Header_MetaData_Map = {} /> -<#assign SegmentationKeys_Map = {} /> -<#assign Line_MetaData_Map = {} /> - +<#switch eventRP.event> + <#case "Created"> + <#-- *********************************************** Action = CREATE or UPDATE ******************** --> + <#assign appointment = eventRP.data /> + [ + { + <#assign apiRestReflexID = ApiRestReflexID.appointment_post> + "apiRestReflexID" : "${apiRestReflexID}", + "datas" : + <#include "RPtoRFX_CarrierAppointment.ftl"> + } + ] + <#break> + <#default> + <#stop > + <#switch eventRP.event> <#case "Created"> <#assign appointment = eventRP.data /> diff --git a/RPtoRFX_CarrierAppointment.ftl b/RPtoRFX_CarrierAppointment.ftl new file mode 100644 index 0000000..27a7663 --- /dev/null +++ b/RPtoRFX_CarrierAppointment.ftl @@ -0,0 +1,76 @@ +<#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)}" --> + }, + "payload" : + { + "appointment_reference": "${appointment.a_defnir?json_string}", + + <#switch appointment.AppointmentType> + <#case "APPOINTMENT_TYPE_EXPEDITION"> + + "unloading_appointment" : "false", + "load_appointment" : "true", + "planned_load_start_datetime : "${appointment.Slot.StartDateTime?iso_nz(time_zone_rfx)}", + "planned_load_end_datetime": "${AddSecondsToDatetime(appointment.Slot.StartDateTime,appointment.Slot.DurationInSeconds)?iso_nz(time_zone_rfx)}" + + <#break> + + <#case "APPOINTMENT_TYPE_RECEPTION"> + "unloading_appointment" : "true", + "load_appointment" : "false", + "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> + + + "planned_carrier" : "${appointment.CarrierName?json_string}", + + <#if appointment.Commissions??> + "physical_receipt_list": [ + <#list appointment.Commissions as commission> + { + "receipt_activity": "str", + "originator_code": "string", + "physical_receipt_reference": "string", + "receipt_year": 0, + "receipt_number": 0, + "comment_list": [ + { + "line_number": 999, + "group_code": "str", + "text": "string" + } + ] + + { + "ProjectID": "recette-rfxdev", + "OrderID": "SPA-121125-02", + "Quantities": [ + { + "UnitID": "PAL", + "Value": 1.0 + } + ], + "OrganisationID": "recette", + "PartnerAppID": "recette-rfxdev-rfxdev", + "ExecutionflowID": "DPFALIDEPT ALIMSPA-121125-02" + } + } + <#sep>, + + ], + + "constant_appointment": "false" + + + } + } diff --git a/ReflexUtils.ftl b/ReflexUtils.ftl index fbe48c5..9103c0a 100644 --- a/ReflexUtils.ftl +++ b/ReflexUtils.ftl @@ -1,6 +1,6 @@ -<#-- --------------------------------------------------------------------------------------- --> +<#-- -------------------------------------------------------------------------------------------- --> <#-- Concat HARDIS WMS timestamp with HARDIS WMS time zone and format this date in ISO UTC format --> -<#-- --------------------------------------------------------------------------------------- --> +<#-- -------------------------------------------------------------------------------------------- --> <#function RfxDateTimetoUTC rfxdatetime offset > <#return ((rfxdatetime + offset)?datetime.iso?iso_utc)> @@ -9,6 +9,22 @@ <#return dateutc?datetime.iso?iso_nz(locale)> +<#-- -------------------------------------------------------------------------------------------- --> +<#-- Add second to dateTime ex: AddSecondsToDatetime("2025-11-17T09:15:00Z"?datetime.iso, 61) --> +<#-- -------------------------------------------------------------------------------------------- --> +<#function AddSecondsToDatetime date seconds> + <#assign timeInMilliseconds = (1000 * seconds) > + <#assign aDate = date?long + timeInMilliseconds?long> + <#return aDate?number_to_datetime> + + +<#-- -------------------------------------------------------------------------------------------- --> +<#-- duration between two datetime in second --> +<#-- -------------------------------------------------------------------------------------------- --> +<#function DurationBetweenTwoDatetimeInsecond startDate endDate> + <#return (endDate?long - startDate?long) / 1000 > + + <#-- --------------------------------------------------------------------------------------- --> <#-- Split email HARDIS WMS into json array string --> <#-- Example : splitemail "john.doe@hardis-group.com,; name@hardis-group.com" -->