From d1a36940d423095691f96143a9c6bce7b5f20147 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Fri, 5 Jul 2024 14:27:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9MSK=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingMSKAPIService.cs | 133 ++++++++++++++++++ .../Service/BookingOrder/Dto/MSKBookingDto.cs | 5 + 2 files changed, 138 insertions(+) diff --git a/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs b/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs index a6b1a9f9..2b37c6bb 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs @@ -686,6 +686,120 @@ namespace Myshipping.Application.Service.BookingOrder // bookingDto.bookingBody.transport.routeDetails.selectedRoute.routeScheduleId = model.carrierProductId; //} + for (int i = 0; i < selectedShipSchedule.transportLegs.Count; i++) + { + var detail = selectedShipSchedule.transportLegs[i]; + + var currDto = new MSKAPIBookingSchedules(); + + + //ETD + if (detail.departureDateTime.HasValue) + { + currDto.originDepartureDateTimeLocal = detail.departureDateTime.Value.ToString("yyyy-MM-ddTHH:mm:ss"); + } + else + { + throw Oops.Bah($"查询船期错误,pid={model.PId} 预计离港日期departureDate 格式解析错误"); + } + + //ETA + if (detail.arrivalDateTime.HasValue) + { + currDto.destinationArrivalDateTimeLocal = detail.arrivalDateTime.Value.ToString("yyyy-MM-ddTHH:mm:ss"); + } + else + { + throw Oops.Bah($"查询船期错误,pid={model.PId} 预计到港日期arrivalDateTime 格式解析错误"); + } + + currDto.transportMode = new MSKAPIBookingTransportMode + { + vessel = new MSKAPIBookingTransportModeVessel + { + name = detail.transport.vessel.vesselName, + maerskVesselCode = detail.transport.vessel.carrierVesselCode, + vesselIMONumber = detail.transport.vessel.vesselIMONumber + }, + exportVoyageNumber = detail.transport.carrierDepartureVoyageNumber, + }; + + currDto.serviceCode = detail.transport.carrierServiceCode; + currDto.transportModeCode = detail.transport.transportMode; + + //首个 + if (i == 0) + { + currDto.startLocation = new MSKAPIBookingRouteDetailsBase + { + cityName = detail.facilities.startLocation.cityName, + ISOcountryCode = detail.facilities.startLocation.countryCode, + UNLocationCode = detail.facilities.startLocation.UNLocationCode, + maerskCityGeoId = selectedShipSchedule.originGeoId, + }; + + if (i == selectedShipSchedule.transportLegs.Count - 1) + { + currDto.endLocation = new MSKAPIBookingRouteDetailsBase + { + cityName = detail.facilities.endLocation.cityName, + ISOcountryCode = detail.facilities.endLocation.countryCode, + UNLocationCode = detail.facilities.endLocation.UNLocationCode, + maerskCityGeoId = selectedShipSchedule.destinationGeoId, + }; + } + else + { + currDto.endLocation = new MSKAPIBookingRouteDetailsBase + { + cityName = detail.facilities.endLocation.cityName, + ISOcountryCode = detail.facilities.endLocation.countryCode, + UNLocationCode = detail.facilities.endLocation.UNLocationCode, + maerskSiteGeoId = detail.facilities.endLocation.carrierSiteGeoID, + }; + } + } + else if (i == selectedShipSchedule.transportLegs.Count - 1) + { + currDto.startLocation = new MSKAPIBookingRouteDetailsBase + { + cityName = detail.facilities.startLocation.cityName, + ISOcountryCode = detail.facilities.startLocation.countryCode, + UNLocationCode = detail.facilities.startLocation.UNLocationCode, + maerskSiteGeoId = detail.facilities.startLocation.carrierSiteGeoID, + }; + + currDto.endLocation = new MSKAPIBookingRouteDetailsBase + { + cityName = detail.facilities.endLocation.cityName, + ISOcountryCode = detail.facilities.endLocation.countryCode, + UNLocationCode = detail.facilities.endLocation.UNLocationCode, + maerskCityGeoId = selectedShipSchedule.destinationGeoId, + }; + } + else + { + currDto.startLocation = new MSKAPIBookingRouteDetailsBase + { + cityName = detail.facilities.startLocation.cityName, + ISOcountryCode = detail.facilities.startLocation.countryCode, + UNLocationCode = detail.facilities.startLocation.UNLocationCode, + maerskSiteGeoId = detail.facilities.startLocation.carrierSiteGeoID, + }; + + currDto.endLocation = new MSKAPIBookingRouteDetailsBase + { + cityName = detail.facilities.endLocation.cityName, + ISOcountryCode = detail.facilities.endLocation.countryCode, + UNLocationCode = detail.facilities.endLocation.UNLocationCode, + maerskSiteGeoId = detail.facilities.endLocation.carrierSiteGeoID, + }; + } + + bookingDto.bookingBody.transport.routeDetails.selectedRoute.bookingSchedules.Add(currDto); + } + + bookingDto.bookingBody.cargo = new MSKAPIBookingCargo { commodityCode = model.commodityCode, @@ -1392,6 +1506,25 @@ namespace Myshipping.Application.Service.BookingOrder }).ToList(); } + MSKAPISearchTransportSchedules selectedShipSchedule = null; + + if (model.PId > 0) + { + var shipScheduleRecord = await _bookingDeliveryRecordShipScheduleRep.AsQueryable() + .FirstAsync(a => a.SHIP_RATE_PID != null && a.SHIP_RATE_PID.Value == model.PId); + + if (shipScheduleRecord != null) + { + selectedShipSchedule = JSON.Deserialize(shipScheduleRecord.SHIP_JSON); + + if (selectedShipSchedule != null) + { + model.selectedShipScheduleShow = GetShipScheduleShow(selectedShipSchedule); + } + + } + } + return model; } #endregion diff --git a/Myshipping.Application/Service/BookingOrder/Dto/MSKBookingDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/MSKBookingDto.cs index 73463198..2381f9c9 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/MSKBookingDto.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/MSKBookingDto.cs @@ -380,6 +380,11 @@ namespace Myshipping.Application /// 交货地定位ID /// public string carrierDeliveryDestinationGeoID { get; set; } + + /// + /// 选择的船期详情 + /// + public SearchShipSailingScheduleResultDto selectedShipScheduleShow { get; set; } } public class MSKBookingCtnInfo