From df49304c05344cf79ed278400c00b228e97346a8 Mon Sep 17 00:00:00 2001 From: Francis Reat Date: Fri, 21 Nov 2025 14:45:29 +0100 Subject: [PATCH] modif sur les rdz --- RFXtoRP_RestResponse.ftl | 78 ++++++++++++++++++- RPtoRFX_AppointmentEvent.ftl | 20 +++-- ...l => RPtoRFX_CarrierAppointmentCreated.ftl | 10 +-- RPtoRFX_CarrierAppointmentUpdated.ftl | 71 +++++++++++++++++ ReflexUtils.ftl | 2 +- 5 files changed, 163 insertions(+), 18 deletions(-) rename RPtoRFX_CarrierAppointment.ftl => RPtoRFX_CarrierAppointmentCreated.ftl (81%) create mode 100644 RPtoRFX_CarrierAppointmentUpdated.ftl diff --git a/RFXtoRP_RestResponse.ftl b/RFXtoRP_RestResponse.ftl index 6faa7a8..fb2f318 100644 --- a/RFXtoRP_RestResponse.ftl +++ b/RFXtoRP_RestResponse.ftl @@ -232,7 +232,7 @@ <#if preparationOrderPostResponse.status?? && preparationOrderPostResponse.status == "SUCCESS" > [ { - <# stop "Création rdz OK" > + <#stop "Création rdz OK" > <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowDeleted> "apiReflexPlatformID" : "${apiReflexPlatformID}", @@ -281,6 +281,82 @@ ] <#break> + <#case "appointment_put"> + <#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 "Mise à jour rdz OK" > + ] + <#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_AppointmentEvent.ftl b/RPtoRFX_AppointmentEvent.ftl index ae27a77..23a2c15 100644 --- a/RPtoRFX_AppointmentEvent.ftl +++ b/RPtoRFX_AppointmentEvent.ftl @@ -20,21 +20,19 @@ <#assign apiRestReflexID = ApiRestReflexID.appointment_post> "apiRestReflexID" : "${apiRestReflexID}", "datas" : - <#include "RPtoRFX_CarrierAppointment.ftl"> - } + <#include "RPtoRFX_CarrierAppointmentCreated.ftl"> + }, + { + + <#assign apiRestReflexID = ApiRestReflexID.appointment_put> + "apiRestReflexID" : "${apiRestReflexID}", + "datas" : + <#include "RPtoRFX_CarrierAppointmentUpdated.ftl"> + } ] <#break> <#default> <#stop > -<#switch eventRP.event> - <#case "Created"> - <#assign appointment = eventRP.data /> - <#stop "Appointment creation event"> - - <#break> - <#default> - <#stop > - diff --git a/RPtoRFX_CarrierAppointment.ftl b/RPtoRFX_CarrierAppointmentCreated.ftl similarity index 81% rename from RPtoRFX_CarrierAppointment.ftl rename to RPtoRFX_CarrierAppointmentCreated.ftl index eb0c5e2..6c2f2db 100644 --- a/RPtoRFX_CarrierAppointment.ftl +++ b/RPtoRFX_CarrierAppointmentCreated.ftl @@ -14,22 +14,22 @@ "unloading_appointment" : "false", "load_appointment" : "true", - "planned_load_start_datetime : "${DateTimeUTCtoRfxLocale(appointment.Slot.StartDateTime,time_zone_rfx)}", - "planned_load_end_datetime": "${AddSecondsToDatetime(appointment.Slot.StartDateTime?datetime.iso,appointment.Slot.DurationInSeconds?long)?iso_nz(time_zone_rfx)}" + "planned_load_start_datetime" : "${DateTimeUTCtoRfxLocale(appointment.Slot.StartDateTime,time_zone_rfx)}", + "planned_load_end_datetime": "${AddSecondsToDatetime(appointment.Slot.StartDateTime?datetime.iso,appointment.Slot.DurationInSeconds?number)?iso_nz(time_zone_rfx)}", <#break> <#case "APPOINTMENT_TYPE_RECEPTION"> "unloading_appointment" : "true", "load_appointment" : "false", - "planned_unloading_start_datetime : "${DateTimeUTCtoRfxLocale(appointment.Slot.StartDateTime?iso_nz(time_zone_rfx))}", - "planned_unloading_end_datetime": "${AddSecondsToDatetime(appointment.Slot.StartDateTime?datetime.iso,appointment.Slot.DurationInSeconds?long)?iso_nz(time_zone_rfx)}" + "planned_unloading_start_datetime" : "${DateTimeUTCtoRfxLocale(appointment.Slot.StartDateTime?iso_nz(time_zone_rfx))}", + "planned_unloading_end_datetime": "${AddSecondsToDatetime(appointment.Slot.StartDateTime?datetime.iso,appointment.Slot.DurationInSeconds?number)?iso_nz(time_zone_rfx)}", <#break> <#default> <#stop "appointment.AppointmentType not implemented" > - "planned_carrier" : "${appointment.CarrierName?json_string}", + "planned_carrier" : "ABAN", <#-- "${appointment.CarrierName?json_string}", --> <#if appointment.Commissions??> "physical_receipt_list": [ diff --git a/RPtoRFX_CarrierAppointmentUpdated.ftl b/RPtoRFX_CarrierAppointmentUpdated.ftl new file mode 100644 index 0000000..4d092ad --- /dev/null +++ b/RPtoRFX_CarrierAppointmentUpdated.ftl @@ -0,0 +1,71 @@ +{ + "id" : {"refid" : "${eventRP.refid?json_string}"}, + "route" : "rest/public/v1/physical_depots/{physical_depot_code}/carrier_appointments/{appointment_reference}", + "method" : "PUT", + "uri_substitutions": { + "physical_depot_code": "${RPtoRFXprefixDepot(eventRP.actor)}", + "appointment_reference":"${eventRP.refid?json_string}" + }, + "payload" : + { + <#switch appointment.AppointmentType> + <#case "APPOINTMENT_TYPE_EXPEDITION"> + + "unloading_appointment" : "false", + "load_appointment" : "true", + "planned_load_start_datetime" : "${DateTimeUTCtoRfxLocale(appointment.Slot.StartDateTime,time_zone_rfx)}", + "planned_load_end_datetime": "${AddSecondsToDatetime(appointment.Slot.StartDateTime?datetime.iso,appointment.Slot.DurationInSeconds?number)?iso_nz(time_zone_rfx)}", + + <#break> + + <#case "APPOINTMENT_TYPE_RECEPTION"> + "unloading_appointment" : "true", + "load_appointment" : "false", + "planned_unloading_start_datetime" : "${DateTimeUTCtoRfxLocale(appointment.Slot.StartDateTime?iso_nz(time_zone_rfx))}", + "planned_unloading_end_datetime": "${AddSecondsToDatetime(appointment.Slot.StartDateTime?datetime.iso,appointment.Slot.DurationInSeconds?number)?iso_nz(time_zone_rfx)}", + <#break> + <#default> + <#stop "appointment.AppointmentType not implemented" > + + + "planned_carrier" : "ABAN", <#-- "${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>, + --> + + ] + + } + } diff --git a/ReflexUtils.ftl b/ReflexUtils.ftl index 4199deb..6b4231a 100644 --- a/ReflexUtils.ftl +++ b/ReflexUtils.ftl @@ -14,7 +14,7 @@ <#-- -------------------------------------------------------------------------------------------- --> <#function AddSecondsToDatetime date seconds> <#assign timeInMilliseconds = (1000 * seconds) > - <#assign aDate = date?long + timeInMilliseconds?long> + <#assign aDate = date?long + timeInMilliseconds> <#return aDate?number_to_datetime>