diff --git a/RFXtoRP_HsrCarrierApt.ftl b/RFXtoRP_HsrCarrierApt.ftl index 374e96e..00fefdc 100644 --- a/RFXtoRP_HsrCarrierApt.ftl +++ b/RFXtoRP_HsrCarrierApt.ftl @@ -29,7 +29,13 @@ "apiReflexPlatformID" : "${apiReflexPlatformID}", "datas" : <#include "RFXtoRP_HsrCarrierApt_AppointmentCarrierExpected.ftl"> - } + }, + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.AppointmentCustomFieldsUpdated> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_HsrCarrierApt_AppointmentCustomFieldsUpdated.ftl"> + }, ] <#break> <#case "U"> diff --git a/RFXtoRP_HsrCarrierApt_AppointmentCustomFieldsUpdated.ftl b/RFXtoRP_HsrCarrierApt_AppointmentCustomFieldsUpdated.ftl new file mode 100644 index 0000000..4cd5972 --- /dev/null +++ b/RFXtoRP_HsrCarrierApt_AppointmentCustomFieldsUpdated.ftl @@ -0,0 +1,48 @@ +[ + <#assign ref_datetime = RfxDateTimetoUTCWithTimezone(carrier_apt.metadata.creation_datetime,time_zone_rfx) /> + { + "Header": { + "ProjectID": "${projectRP}" + }, + "ID": { + <#if carrier_apt.appointment_reference?? && carrier_apt.appointment_reference!=""> + "RefID": "${carrier_apt.appointment_reference?json_string}", + <#else> + <#if carrier_apt.constant_appointment?? && carrier_apt.constant_appointment== "true"> + "RefID": "${carrier_apt.appointment_reference?json_string}${carrier_apt.physical_depot?json_string}${carrier_apt.year_number}${carrier_apt.appointment_number}", + <#else> + "RefID": "${carrier_apt.physical_depot?json_string}${carrier_apt.year_number}${carrier_apt.appointment_number}", + + + "RefDate": { + "DateTime": "${ref_datetime}", + "AuthorTimeZone": "${time_zone_rfx}" + }, + "CustomFields": [ + { + "Key": "depot", + "Value": "${carrier_apt.physical_depot?json_string}" + }, + { + "Key": "year", + "Value": "${carrier_apt.year_number?json_string}" + }, + { + "Key": "number", + "Value": "${carrier_apt.appointment_number?json_string}" + }, + { + "Key": "reference", + "Value": "${carrier_apt.appointment_reference?json_string}" + }, + { + "Key": "carrier", + "Value": "${carrier_apt.planned_carrier?json_string}" + } + ] + }, + "Payload":{ + "ActorID": "${RFXtoRPprefixDepot(carrier_apt.physical_depot?json_string)}" + } + } +] \ No newline at end of file diff --git a/RPtoRFX_AppointmentEvent.ftl b/RPtoRFX_AppointmentEvent.ftl index 3cf19d9..d46ee24 100644 --- a/RPtoRFX_AppointmentEvent.ftl +++ b/RPtoRFX_AppointmentEvent.ftl @@ -27,38 +27,65 @@ <#case "CommissionsUpdated"> <#assign appointment = eventRP.data /> [ + <#if appointment.appointmentCustomFields?? && appointment.appointmentCustomFields?has_content> { - <#assign apiRestReflexID = ApiRestReflexID.appointment_post_physical_receipt_association> + <#assign apiRestReflexID = ApiRestReflexID.appointment_post_physical_receipt_associations_by_number> "apiRestReflexID" : "${apiRestReflexID}", "datas" : - <#include "RPtoRFX_CarrierAppointmentPhysicalReceiptAssociation.ftl"> + <#include "RPtoRFX_CarrierAppointmentPhysicalReceiptAssociationByNumber.ftl"> } + <#else> + { + <#assign apiRestReflexID = ApiRestReflexID.appointment_post_physical_receipt_associations_by_ref> + "apiRestReflexID" : "${apiRestReflexID}", + "datas" : + <#include "RPtoRFX_CarrierAppointmentPhysicalReceiptAssociationByRefID.ftl"> + } + ] <#break> <#-- *********************************************** Action = SlotUpdated ******************** --> <#case "SlotUpdated"> - <#assign appointment = eventRP.data /> - [ - { - <#assign apiRestReflexID = ApiRestReflexID.appointment_put_update> - "apiRestReflexID" : "${apiRestReflexID}", - "datas" : - <#include "RPtoRFX_CarrierAppointmentSlotUpdated.ftl"> - } - ] - <#break> + <#assign appointment = eventRP.data /> + [ + <#if appointment.appointmentCustomFields?? && appointment.appointmentCustomFields?has_content> + { + <#assign apiRestReflexID = ApiRestReflexID.appointment_put_update_by_number> + "apiRestReflexID" : "${apiRestReflexID}", + "datas" : + <#include "RPtoRFX_CarrierAppointmentSlotUpdatedByNumber.ftl"> + } + <#else> + { + <#assign apiRestReflexID = ApiRestReflexID.appointment_put_update_by_ref> + "apiRestReflexID" : "${apiRestReflexID}", + "datas" : + <#include "RPtoRFX_CarrierAppointmentSlotUpdatedByRef.ftl"> + } + + ] + <#break> <#-- *********************************************** Action = SlotUpdated ******************** --> <#case "Canceled"> - <#assign appointment = eventRP.data /> - [ - { - <#assign apiRestReflexID = ApiRestReflexID.appointment_put_update> - "apiRestReflexID" : "${apiRestReflexID}", - "datas" : - <#include "RPtoRFX_CarrierAppointmentCanceled.ftl"> - } - ] - <#break> + <#assign appointment = eventRP.data /> + [ + <#if appointment.appointmentCustomFields?? && appointment.appointmentCustomFields?has_content> + { + <#assign apiRestReflexID = ApiRestReflexID.appointment_put_status_by_number> + "apiRestReflexID" : "${apiRestReflexID}", + "datas" : + <#include "RPtoRFX_CarrierAppointmentCanceledByNumber.ftl"> + } + <#else> + { + <#assign apiRestReflexID = ApiRestReflexID.appointment_put_status_by_ref> + "apiRestReflexID" : "${apiRestReflexID}", + "datas" : + <#include "RPtoRFX_CarrierAppointmentCanceledByRef.ftl"> + } + + ] + <#break> <#default> <#stop > diff --git a/RPtoRFX_CarrierAppointmentCanceled.ftl b/RPtoRFX_CarrierAppointmentCanceled.ftl deleted file mode 100644 index db7711b..0000000 --- a/RPtoRFX_CarrierAppointmentCanceled.ftl +++ /dev/null @@ -1,32 +0,0 @@ -{ - "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_LOADING"> - "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_UNLOADING"> - "unloading_appointment" : "true", - "load_appointment" : "false", - "planned_unloading_start_datetime" : "${DateTimeUTCtoRfxLocale(appointment.Slot.StartDateTime,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" > - - "status": { - "status_code": "999", - "cancellation_reason_code": "ACS" - } - } - } \ No newline at end of file diff --git a/RPtoRFX_CarrierAppointmentCanceledByNumberftl b/RPtoRFX_CarrierAppointmentCanceledByNumberftl new file mode 100644 index 0000000..d663b92 --- /dev/null +++ b/RPtoRFX_CarrierAppointmentCanceledByNumberftl @@ -0,0 +1,17 @@ +{ + "id" : {"refid" : "${eventRP.refid?json_string}"}, + "route" : "rest/public/v1/physical_depots/{physical_depot_code}/appointment_years/{appointment_year}/appointment_numbers/{appointment_number}/status", + "method" : "PUT", + "uri_substitutions": { + "physical_depot_code": "${RPtoRFXprefixDepot(eventRP.actor)}", + "appointment_year":"${appointment.appointmentCustomFields.year?json_string}", + "appointment_number":"${appointment.appointmentCustomFields.number?json_string}" + }, + "payload" : + { + "status": { + "status_code": "999", + "cancellation_reason_code": "ACS" + } + } + } \ No newline at end of file diff --git a/RPtoRFX_CarrierAppointmentCanceledByRef.ftl b/RPtoRFX_CarrierAppointmentCanceledByRef.ftl new file mode 100644 index 0000000..34f783e --- /dev/null +++ b/RPtoRFX_CarrierAppointmentCanceledByRef.ftl @@ -0,0 +1,16 @@ +{ + "id" : {"refid" : "${eventRP.refid?json_string}"}, + "route" : "rest/public/v1/physical_depots/{physical_depot_code}/carrier_appointments/{appointment_reference}/status", + "method" : "PUT", + "uri_substitutions": { + "physical_depot_code": "${RPtoRFXprefixDepot(eventRP.actor)}", + "appointment_reference":"${eventRP.refid?json_string}" + }, + "payload" : + { + "status": { + "status_code": "999", + "cancellation_reason_code": "ACS" + } + } + } \ No newline at end of file diff --git a/RPtoRFX_CarrierAppointmentPhysicalReceiptAssociationByNumber.ftl b/RPtoRFX_CarrierAppointmentPhysicalReceiptAssociationByNumber.ftl new file mode 100644 index 0000000..8c129e5 --- /dev/null +++ b/RPtoRFX_CarrierAppointmentPhysicalReceiptAssociationByNumber.ftl @@ -0,0 +1,33 @@ +{ + "id" : {"refid" : "${eventRP.refid?json_string}"}, + "route" : "rest/public/v1/physical_depots/{physical_depot_code}/appointment_years/{appointment_year}/appointment_numbers/{appointment_number}/physical_receipt_associations", + "method" : "POST", + "uri_substitutions": { + "physical_depot_code": "${RPtoRFXprefixDepot(eventRP.actor)}", + "appointment_year":"${appointment.appointmentCustomFields.year?json_string}", + "appointment_number":"${appointment.appointmentCustomFields.number?json_string}" + }, + "payload" : + { + <#if appointment.Commissions??> + <#if appointment.AppointmentType == "APPOINTMENT_TYPE_UNLOADING"> + "physical_receipt_list": [ + <#list eventRP.executionflowCustomFields.entrySet() as custom> + { + "receipt_activity": "${custom.value.activity_code?json_string}", + "originator_code": "${custom.value.originator_code?json_string}", + "physical_receipt_reference": "${custom.value.reference?json_string}", + "receipt_year": "${custom.value.order_year?json_string}", + "receipt_number": "${custom.value.order_number?json_string}" + } + <#sep>, + + ] + <#else> + <#if appointment.AppointmentType == "APPOINTMENT_TYPE_LOADING"> + "appointment_designation":"LOADING" + + + + } + } diff --git a/RPtoRFX_CarrierAppointmentPhysicalReceiptAssociation.ftl b/RPtoRFX_CarrierAppointmentPhysicalReceiptAssociationByRef.ftl similarity index 100% rename from RPtoRFX_CarrierAppointmentPhysicalReceiptAssociation.ftl rename to RPtoRFX_CarrierAppointmentPhysicalReceiptAssociationByRef.ftl diff --git a/RPtoRFX_CarrierAppointmentSlotUpdatedByNumber.ftl b/RPtoRFX_CarrierAppointmentSlotUpdatedByNumber.ftl new file mode 100644 index 0000000..dfcac35 --- /dev/null +++ b/RPtoRFX_CarrierAppointmentSlotUpdatedByNumber.ftl @@ -0,0 +1,32 @@ +{ + "id" : {"refid" : "${eventRP.refid?json_string}"}, + "route" : "rest/public/v1/physical_depots/{physical_depot_code}/appointment_years/{appointment_year}/appointment_numbers/{appointment_number}, + "method" : "PUT", + "uri_substitutions": { + "physical_depot_code": "${RPtoRFXprefixDepot(eventRP.actor)}", + "appointment_year":"${appointment.appointmentCustomFields.year?json_string}", + "appointment_number":"${appointment.appointmentCustomFields.number?json_string}" + }, + "payload" : + { + <#switch appointment.AppointmentType> + <#case "APPOINTMENT_TYPE_LOADING"> + + "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_UNLOADING"> + "unloading_appointment" : "true", + "load_appointment" : "false", + "planned_unloading_start_datetime" : "${DateTimeUTCtoRfxLocale(appointment.Slot.StartDateTime,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" > + + } + } diff --git a/RPtoRFX_CarrierAppointmentSlotUpdated.ftl b/RPtoRFX_CarrierAppointmentSlotUpdatedByRef.ftl similarity index 100% rename from RPtoRFX_CarrierAppointmentSlotUpdated.ftl rename to RPtoRFX_CarrierAppointmentSlotUpdatedByRef.ftl