diff --git a/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs b/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs
new file mode 100644
index 00000000..11aa5428
--- /dev/null
+++ b/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs
@@ -0,0 +1,667 @@
+using Furion.FriendlyException;
+using Furion.JsonSerialization;
+using Furion.RemoteRequest.Extensions;
+using Furion;
+using Mapster;
+using Microsoft.AspNetCore.Mvc;
+using Myshipping.Application.Entity;
+using Myshipping.Core;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Furion.DynamicApiController;
+using Furion.DependencyInjection;
+using Myshipping.Core.Service;
+using Microsoft.Extensions.Logging;
+
+namespace Myshipping.Application.Service.BookingOrder
+{
+ ///
+ /// 马士基API订舱
+ ///
+ [ApiDescriptionSettings("Application", Name = "BookingMSKAPI", Order = 10)]
+ public class BookingMSKAPIService: IBookingMSKAPIService, IDynamicApiController, ITransient
+ {
+ private readonly SqlSugarRepository _bookingDeliveryRecordRep;
+ private readonly SqlSugarRepository _bookingDeliveryRecordCtnRep;
+ private readonly ISysCacheService _cache;
+ private readonly IDjyWebsiteAccountConfigService _webAccountConfig;
+ private readonly ILogger _logger;
+
+ const string CONST_MSK_API_COMMODITY_URL = "MSKApiCommodity";
+ const string CONST_MSK_API_BOOKING_URL = "MSKApiBooking";
+ const string CONST_MSK_API_Poing2P_SECD_URL = "MSKApiSailingSchedulePoint2Point";
+ const string CONST_MSK_API_LOCATION_URL = "MSKApilocation";
+
+ public BookingMSKAPIService(ILogger logger, ISysCacheService cache,
+ IDjyWebsiteAccountConfigService webAccountConfig, SqlSugarRepository bookingDeliveryRecordRep,
+ SqlSugarRepository bookingDeliveryRecordCtnRep)
+ {
+ _logger = logger;
+ _cache = cache;
+ _webAccountConfig = webAccountConfig;
+ _bookingDeliveryRecordRep = bookingDeliveryRecordRep;
+ _bookingDeliveryRecordCtnRep = bookingDeliveryRecordCtnRep;
+
+ }
+
+ #region 检索海运船期详情
+ ///
+ /// 检索海运船期详情
+ ///
+ /// 请求船期详情
+ /// 返回船期结果
+ [HttpPost("/BookingOrder/SearchShipSailingSchedule")]
+ public async Task> SearchShipSailingSchedule(QueryShipSailingScheduleDto model)
+ {
+ List list = new List();
+
+ /*
+ MSKApiSailingSchedulePoint2Point
+ */
+ try
+ {
+ if (string.IsNullOrWhiteSpace(model.collectionOriginCityName))
+ throw Oops.Oh($"始发地不能为空");
+
+ if (string.IsNullOrWhiteSpace(model.deliveryDestinationCityName))
+ throw Oops.Oh($"目的地不能为空");
+
+ if (string.IsNullOrWhiteSpace(model.vesselOperatorCarrierCode))
+ throw Oops.Oh($"服务船公司不能为空");
+
+ if (string.IsNullOrWhiteSpace(model.carrierId))
+ throw Oops.Oh("船公司代码不能为空");
+
+ if (string.IsNullOrWhiteSpace(model.startDate))
+ throw Oops.Oh($"预计离港日期不能为空");
+
+ DateTime etd = DateTime.MinValue;
+
+ if (!DateTime.TryParse(model.startDate, out etd))
+ throw Oops.Oh($"预计离港日期格式错误");
+
+ string queryUrl = string.Empty;
+
+ if (model.carrierId.Equals("MSK", StringComparison.OrdinalIgnoreCase))
+ {
+ queryUrl = _cache.GetAllDictData().GetAwaiter().GetResult()
+ .FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == CONST_MSK_API_Poing2P_SECD_URL)?.Value;
+ }
+ else
+ {
+ throw Oops.Oh($"当前船公司 {model.carrierId} 未配置相应的请求接口");
+ }
+
+ if (string.IsNullOrWhiteSpace(queryUrl))
+ throw Oops.Oh("未配置查询船期请求接口地址,请联系管理员");
+
+ var webAccountConfig = _webAccountConfig
+ .GetAccountConfig("MSKApi", UserManager.UserId).GetAwaiter().GetResult();
+
+ if (webAccountConfig == null)
+ throw Oops.Oh("未配置个人账户,请先配置个人账户 类型-MSKApi");
+
+ MSKAPISearchPoint2PointScheduleDto queryInfo = new MSKAPISearchPoint2PointScheduleDto
+ {
+ userKey = App.Configuration["MSKAPIDjyUserKey"],
+ userSecret = App.Configuration["MSKAPIDjyUserSecret"],
+ operatingEnvironment = App.Configuration["MSKAPIOPEnvironment"],
+ mskAppKey = webAccountConfig.Account,
+ collectionOriginCityName = model.collectionOriginCityName,
+ collectionOriginCountryCode = model.collectionOriginCountryCode,
+ deliveryDestinationCityName = model.deliveryDestinationCityName,
+ deliveryDestinationCountryCode = model.deliveryDestinationCountryCode,
+ cargoType = model.cargoType,
+ exportServiceMode = model.exportServiceMode,
+ importServiceMode = model.importServiceMode,
+ vesselOperatorCarrierCode = model.vesselOperatorCarrierCode,
+ startDate = etd.ToString("yyyy-MM-dd"),
+ startDateType = "D",
+ };
+
+ MSKAPISearchPoint2PointScheduleResultDto resultInfo = null;
+
+ var rlt = await queryUrl.SetBody(queryInfo)
+ .PostAsStringAsync();
+
+ if (!string.IsNullOrWhiteSpace(rlt))
+ {
+ try
+ {
+ resultInfo = JSON.Deserialize(rlt);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogInformation($"请求MSK API查询船期异常,原因:{ex.Message}");
+
+ throw Oops.Bah($"请求MSK API查询船期异常,原因:{ex.Message}");
+ }
+ }
+
+ if (resultInfo != null && resultInfo.code == 200
+ && resultInfo.data != null && resultInfo.data.Count > 0)
+ {
+ resultInfo.data.ForEach(a =>
+ {
+ a.transportSchedules.ForEach(b =>
+ {
+ SearchShipSailingScheduleResultDto info = new SearchShipSailingScheduleResultDto
+ {
+ carrierProductId = a.carrierProductId,
+ carrierProductSequenceId = a.carrierProductSequenceId,
+ ETD = b.departureDateTime,
+ ATD = b.arrivalDateTime,
+ vesselOperatorCarrierCode = b.vesselOperatorCarrierCode
+ };
+
+ if (b.departureDateTime.HasValue && b.arrivalDateTime.HasValue)
+ {
+ TimeSpan ts = b.arrivalDateTime.Value.Subtract(b.departureDateTime.Value);
+ var timeDiff = ts.TotalHours;
+
+ info.days = (int)Math.Ceiling(timeDiff / 24.0);
+ }
+
+ if (b.facilities != null)
+ {
+ info.orignCityName = b.facilities.collectionOrigin?.cityName;
+ info.orignCarrierSiteGeoID = b.facilities.collectionOrigin?.carrierSiteGeoID;
+ info.orignLocationName = b.facilities.collectionOrigin?.locationName;
+ info.orignCountryCode = b.facilities.collectionOrigin?.countryCode;
+ info.orignLocationType = b.facilities.collectionOrigin?.locationType;
+ info.orignUNLocationCode = b.facilities.collectionOrigin?.UNLocationCode;
+ info.orignUNRegionCode = b.facilities.collectionOrigin?.UNRegionCode;
+
+ info.deliveryCityName = b.facilities.deliveryDestination?.cityName;
+ info.deliveryCarrierSiteGeoID = b.facilities.deliveryDestination?.carrierSiteGeoID;
+ info.deliveryLocationName = b.facilities.deliveryDestination?.locationName;
+ info.deliveryCountryCode = b.facilities.deliveryDestination?.countryCode;
+ info.deliveryLocationType = b.facilities.deliveryDestination?.locationType;
+ info.deliveryUNLocationCode = b.facilities.deliveryDestination?.UNLocationCode;
+ info.deliveryUNRegionCode = b.facilities.deliveryDestination?.UNRegionCode;
+ }
+
+ info.vesselIMONumber = b.firstDepartureVessel?.vesselIMONumber;
+ info.carrierVesselCode = b.firstDepartureVessel?.carrierVesselCode;
+ info.vesselName = b.firstDepartureVessel?.vesselName;
+
+ if (b.transportLegs != null && b.transportLegs.Count > 0)
+ {
+ var firstTransportLegs = b.transportLegs.FirstOrDefault();
+
+ if (firstTransportLegs.transport != null)
+ {
+ info.transportMode = firstTransportLegs.transport.transportMode;
+ info.carrierDepartureVoyageNumber = firstTransportLegs.transport.carrierDepartureVoyageNumber;
+ }
+
+ }
+
+ list.Add(info);
+ });
+ });
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError($"检索海运船期详情异常,req={JSON.Serialize(model)} 原因:{ex.Message}");
+
+ throw Oops.Bah($"检索海运船期详情失败,{ex.Message}");
+ }
+
+ return list;
+ }
+ #endregion
+
+ #region 发送马士基订舱请求
+ ///
+ /// 发送马士基订舱请求
+ ///
+ /// 请求订舱详情
+ ///
+ [HttpPost("/BookingOrder/SendMSKBooking")]
+ public async Task SendMSKBooking(MSKBookingDto model)
+ {
+ MSKBookingResultDto result = new MSKBookingResultDto();
+
+ /*
+ MSKApiBooking
+ */
+ try
+ {
+ if (string.IsNullOrWhiteSpace(model.carrierCode))
+ throw Oops.Oh($"服务船公司不能为空");
+
+ if (string.IsNullOrWhiteSpace(model.carrierId))
+ throw Oops.Oh("船公司代码不能为空");
+
+ string sendUrl = string.Empty;
+
+ if (model.carrierId.Equals("MSK", StringComparison.OrdinalIgnoreCase))
+ {
+ sendUrl = _cache.GetAllDictData().GetAwaiter().GetResult()
+ .FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == CONST_MSK_API_BOOKING_URL)?.Value;
+ }
+ else
+ {
+ throw Oops.Oh($"当前船公司 {model.carrierId} 未配置相应的请求接口");
+ }
+
+ if (string.IsNullOrWhiteSpace(sendUrl))
+ throw Oops.Oh("未配置发送订舱请求接口地址,请联系管理员");
+
+ var webAccountConfig = _webAccountConfig
+ .GetAccountConfig("MSKApi", UserManager.UserId).GetAwaiter().GetResult();
+
+ if (webAccountConfig == null)
+ throw Oops.Oh("未配置个人账户,请先配置个人账户 类型-MSKApi");
+
+ DateTime nowDate = DateTime.Now;
+
+ var recordInfo = model.Adapt();
+ var recordCtnList = model.ctns.Adapt>();
+
+ MSKAPIBookingDto bookingDto = new MSKAPIBookingDto
+ {
+ userKey = App.Configuration["MSKAPIDjyUserKey"],
+ userSecret = App.Configuration["MSKAPIDjyUserSecret"],
+ operatingEnvironment = App.Configuration["MSKAPIOPEnvironment"],
+ mskAppKey = webAccountConfig.Account,
+ bookingBody = new MSKAPIBookingBodyDto()
+ };
+
+ bookingDto.bookingBody.references = new MSKAPIBookingReferenceDto
+ {
+ priceReference = model.priceReference,
+ productCode = model.productCode,
+ sender = model.sender,
+ };
+
+ bookingDto.bookingBody.mandatoryParties = new MSKAPIBookingMandatoryParties
+ {
+ bookedByCompanyName = model.bookedByCompanyName,
+ bookedByMaerskPartyCode = model.bookedByMaerskPartyCode,
+ bookedByPartyContact = new MSKAPIBookingMandatoryPartyContact
+ {
+ name = model.bookedByCompanyContactName,
+ email = model.bookedByCompanyContactEmail
+ },
+ priceOwnerCompanyName = model.priceOwnerCompanyName,
+ priceOwnerMaerskPartyCode = model.priceOwnerMaerskPartyCode,
+ priceOwnerPartyContact = new MSKAPIBookingMandatoryPartyContact
+ {
+ name = model.priceOwnerContactName,
+ email = model.priceOwnerContactEmail
+ },
+ };
+
+ bookingDto.bookingBody.transport = new MSKAPIBookingTransport
+ {
+ carrierCode = model.carrierCode,
+ earliestDepartureDate = model.earliestDepartureDate,
+ exportServiceMode = model.exportServiceMode,
+ importServiceMode = model.importServiceMode,
+ routeDetails = new MSKAPIBookingRouteDetails
+ {
+ placeOfReceipt = new MSKAPIBookingRouteDetailsBase
+ {
+ UNLocationCode = model.placeOfReceiptUnLocCode,
+ cityName = model.placeOfReceiptCityName,
+ },
+ placeOfDelivery = new MSKAPIBookingRouteDetailsBase
+ {
+ UNLocationCode = model.placeOfDeliveryUnLocCode,
+ cityName = model.placeOfDeliveryCityName,
+ },
+ selectedRoute = new MSKAPIBookingRoute
+ {
+ bookingSchedules = new MSKAPIBookingSchedules
+ {
+ originDepartureDateTimeLocal = model.originDepartureDateTimeLocal.Value.ToString("yyyy-MM-dd"),
+ destinationArrivalDateTimeLocal = model.destinationArrivalDateTimeLocal.Value.ToString("yyyy-MM-dd"),
+ transportMode = new MSKAPIBookingTransportMode
+ {
+ vessel = new MSKAPIBookingTransportModeVessel
+ {
+ name = model.vesselName,
+ maerskVesselCode = model.carrierVesselCode,
+ },
+ exportVoyageNumber = model.exportVoyageNumber,
+ },
+ startLocation = new MSKAPIBookingRouteDetailsBase
+ {
+ cityName = model.placeOfReceiptCityName,
+ UNLocationCode = model.placeOfReceiptUnLocCode
+ },
+ endLocation = new MSKAPIBookingRouteDetailsBase
+ {
+ cityName = model.placeOfDeliveryCityName,
+ UNLocationCode = model.placeOfDeliveryUnLocCode
+ },
+ transportModeCode = model.transportMode
+ }
+ },
+ }
+ };
+
+ bookingDto.bookingBody.cargo = new MSKAPIBookingCargo
+ {
+ commodityCode = model.commodityCode,
+ commodityCodeType = "MaerskCode",
+ cargoType = model.cargoType,
+ totalCargoWeight = model.totalCargoWeight
+ };
+
+ //是否冷冻处理
+ if (model.isReefer)
+ {
+ bookingDto.bookingBody.cargo.reeferSettings = new MSKAPIBookingCargoReeferSettings();
+
+ bookingDto.bookingBody.cargo.reeferSettings.temperatureDetails = model.temperature;
+ bookingDto.bookingBody.cargo.reeferSettings.temperatureMeasureUnit = "C";
+
+ bookingDto.bookingBody.cargo.reeferSettings.noOfProbes = model.noOfProbes;
+
+ //每小时需要的通风量,单位为立方米(0-285)
+ bookingDto.bookingBody.cargo.reeferSettings.ventilation = model.ventilation;
+
+ bookingDto.bookingBody.cargo.reeferSettings.humidity = model.humidity;
+ }
+
+ bookingDto.bookingBody.equipmentAndHaulage = new List();
+
+ if (model.ctns != null && model.ctns.Count > 0)
+ {
+ model.ctns.ForEach(ctn =>
+ {
+ MSKAPIBookingEquipmentAndHaulage haulage = new MSKAPIBookingEquipmentAndHaulage
+ {
+ equipmentDetails = new MSKAPIBookingEquipmentAndHaulageItem(),
+ stuffingDetails = new List()
+ };
+
+ haulage.equipmentDetails.ISOEquipmentCode = ctn.ctnCode;
+ haulage.equipmentDetails.equipmentQuantity = ctn.ctnNum;
+
+ haulage.stuffingDetails.Add(new MSKAPIBookingStuffingdetails
+ {
+ stuffingValue = (int)ctn.ctnSufferWeight.Value,
+ stuffingMeasurementType = "WEIGHT",
+ stuffingMeasurementUnit = "KGS"
+ });
+
+ bookingDto.bookingBody.equipmentAndHaulage.Add(haulage);
+ });
+ }
+
+ recordInfo.CreatedTime = nowDate;
+ recordInfo.UpdatedTime = nowDate;
+ recordInfo.CreatedUserId = UserManager.UserId;
+ recordInfo.CreatedUserName = UserManager.Name;
+
+ _bookingDeliveryRecordRep.Insert(recordInfo);
+
+ if (recordCtnList.Count > 0)
+ {
+ recordCtnList.ForEach(async x =>
+ {
+ x.RECORD_ID = recordInfo.Id;
+ x.CreatedTime = nowDate;
+ x.UpdatedTime = nowDate;
+ x.CreatedUserId = UserManager.UserId;
+ x.CreatedUserName = UserManager.Name;
+
+ await _bookingDeliveryRecordCtnRep.InsertAsync(x);
+ });
+ }
+
+ MSKAPIBookingResultDto resultInfo = null;
+
+ var rlt = await sendUrl.SetBody(bookingDto)
+ .PostAsStringAsync();
+
+ if (!string.IsNullOrWhiteSpace(rlt))
+ {
+ try
+ {
+ resultInfo = JSON.Deserialize(rlt);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogInformation($"请求MSK API订舱异常,原因:{ex.Message}");
+
+ throw Oops.Bah($"请求MSK API订舱异常,原因:{ex.Message}");
+ }
+ }
+
+ var entity = _bookingDeliveryRecordRep
+ .FirstOrDefault(a => a.Id == recordInfo.Id);
+
+ if (resultInfo != null && resultInfo.code == 200
+ && resultInfo.data != null)
+ {
+ entity.REQUEST_ACKNOWLEDGEMENT_ID = resultInfo.data.requestAcknowledgementId;
+ entity.BOOKING_REFERENCE = resultInfo.data.bookingReference;
+ entity.STATUS = "SUCC";
+
+ await _bookingDeliveryRecordRep.AsUpdateable(entity).UpdateColumns(x => new
+ {
+ x.REQUEST_ACKNOWLEDGEMENT_ID,
+ x.BOOKING_REFERENCE,
+ x.STATUS
+ }).ExecuteCommandAsync();
+ }
+ else
+ {
+ entity.STATUS = "SUCC";
+ entity.NOTES = resultInfo.msg.Length > 500 ? resultInfo.msg.Substring(0, 500) : resultInfo.msg;
+
+ await _bookingDeliveryRecordRep.AsUpdateable(entity).UpdateColumns(x => new
+ {
+ x.STATUS,
+ x.NOTES
+ }).ExecuteCommandAsync();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError($"MSK API订舱异常,req={JSON.Serialize(model)} 原因:{ex.Message}");
+
+ throw Oops.Bah($"MSK API订舱失败,{ex.Message}");
+ }
+
+ return result;
+ }
+ #endregion
+
+ #region 检索商品名称
+ ///
+ /// 检索商品名称
+ ///
+ /// 请求详情
+ /// 返回检索结果
+ [HttpPost("/BookingOrder/SearchCommodities")]
+ public async Task> SearchCommodities(QueryCommoditiesDto model)
+ {
+ List list = new List();
+
+ /*
+ MSKApiCommodity
+ */
+ try
+ {
+ if (string.IsNullOrWhiteSpace(model.commodityName))
+ throw Oops.Oh("商品名称不能为空");
+
+ if (string.IsNullOrWhiteSpace(model.carrierId))
+ throw Oops.Oh("船公司代码不能为空");
+
+ if (model.commodityName.Length < 3)
+ throw Oops.Oh("商品名称至少输入3个以上字符");
+
+ string queryUrl = string.Empty;
+
+ if (model.carrierId.Equals("MSK", StringComparison.OrdinalIgnoreCase))
+ {
+ queryUrl = _cache.GetAllDictData().GetAwaiter().GetResult()
+ .FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == CONST_MSK_API_COMMODITY_URL)?.Value;
+ }
+ else
+ {
+ throw Oops.Oh($"当前船公司 {model.carrierId} 未配置相应的请求接口");
+ }
+
+ if (string.IsNullOrWhiteSpace(queryUrl))
+ throw Oops.Oh("未配置商品请求接口地址,请联系管理员");
+
+ var webAccountConfig = _webAccountConfig
+ .GetAccountConfig("MSKApi", UserManager.UserId).GetAwaiter().GetResult();
+
+ if (webAccountConfig == null)
+ throw Oops.Oh("未配置个人账户,请先配置个人账户 类型-MSKApi");
+
+ MSKAPISearchCommodityDto queryInfo = new MSKAPISearchCommodityDto
+ {
+ userKey = App.Configuration["MSKAPIDjyUserKey"],
+ userSecret = App.Configuration["MSKAPIDjyUserSecret"],
+ operatingEnvironment = App.Configuration["MSKAPIOPEnvironment"],
+ commodityName = model.commodityName,
+ mskAppKey = webAccountConfig.Account
+ };
+
+ MSKAPISearchCommodityResultDto resultInfo = null;
+
+ var rlt = await queryUrl.SetBody(queryInfo)
+ .PostAsStringAsync();
+
+ if (!string.IsNullOrWhiteSpace(rlt))
+ {
+ try
+ {
+ resultInfo = JSON.Deserialize(rlt);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogInformation($"请求MSK API检索商品异常,原因:{ex.Message}");
+
+ throw Oops.Bah($"请求MSK API检索商品异常,原因:{ex.Message}");
+ }
+ }
+
+ if (resultInfo != null && resultInfo.code == 200
+ && resultInfo.data != null && resultInfo.data.Count > 0)
+ {
+ list = resultInfo.data.Adapt>();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError($"检索商品名称异常,req={JSON.Serialize(model)} 原因:{ex.Message}");
+
+ throw Oops.Bah($"检索商品名称失败,{ex.Message}");
+ }
+
+ return list;
+ }
+ #endregion
+
+ #region 检索始发地、目的港口信息
+ ///
+ /// 检索始发地、目的港口信息
+ ///
+ /// 请求详情
+ /// 返回检索结果
+ [HttpPost("/BookingOrder/SearchLocations")]
+ public async Task> SearchLocations(QueryLocationsDto model)
+ {
+ List list = new List();
+
+ /*
+ MSKApiCommodity
+ */
+ try
+ {
+ if (string.IsNullOrWhiteSpace(model.cityName))
+ throw Oops.Oh("港口或城市名称不能为空");
+
+ if (string.IsNullOrWhiteSpace(model.carrierCode))
+ throw Oops.Oh("服务船公司不能为空");
+
+ if (string.IsNullOrWhiteSpace(model.carrierId))
+ throw Oops.Oh("船公司代码不能为空");
+
+ if (model.cityName.Length < 3)
+ throw Oops.Oh("港口或城市名称至少输入3个以上字符");
+
+
+ string queryUrl = string.Empty;
+
+ if (model.carrierId.Equals("MSK", StringComparison.OrdinalIgnoreCase))
+ {
+ queryUrl = _cache.GetAllDictData().GetAwaiter().GetResult()
+ .FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == CONST_MSK_API_LOCATION_URL)?.Value;
+ }
+ else
+ {
+ throw Oops.Oh($"当前船公司 {model.carrierId} 未配置相应的请求接口");
+ }
+
+ if (string.IsNullOrWhiteSpace(queryUrl))
+ throw Oops.Oh("未配置商品请求接口地址,请联系管理员");
+
+ var webAccountConfig = _webAccountConfig
+ .GetAccountConfig("MSKApi", UserManager.UserId).GetAwaiter().GetResult();
+
+ if (webAccountConfig == null)
+ throw Oops.Oh("未配检索始发地、目的港口,请先配置个人账户 类型-MSKApi");
+
+ MSKAPISearchLocationDto queryInfo = new MSKAPISearchLocationDto
+ {
+ userKey = App.Configuration["MSKAPIDjyUserKey"],
+ userSecret = App.Configuration["MSKAPIDjyUserSecret"],
+ operatingEnvironment = App.Configuration["MSKAPIOPEnvironment"],
+ name = model.cityName,
+ mskAppKey = webAccountConfig.Account,
+ carrierCode = model.carrierCode
+ };
+
+ MSKAPISearchLocationResultDto resultInfo = null;
+
+ var rlt = await queryUrl.SetBody(queryInfo)
+ .PostAsStringAsync();
+
+ if (!string.IsNullOrWhiteSpace(rlt))
+ {
+ try
+ {
+ resultInfo = JSON.Deserialize(rlt);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogInformation($"请求MSK API检索始发地、目的港口异常,原因:{ex.Message}");
+
+ throw Oops.Bah($"请求MSK API检索始发地、目的港口异常,原因:{ex.Message}");
+ }
+ }
+
+ if (resultInfo != null && resultInfo.code == 200
+ && resultInfo.data != null && resultInfo.data.Count > 0)
+ {
+ list = resultInfo.data.Adapt>();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError($"检索始发地、目的港口异常,req={JSON.Serialize(model)} 原因:{ex.Message}");
+
+ throw Oops.Bah($"检索始发地、目的港口失败,{ex.Message}");
+ }
+
+ return list;
+ }
+ #endregion
+ }
+}
diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs
index 7785da5b..065aab2b 100644
--- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs
+++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs
@@ -140,8 +140,7 @@ namespace Myshipping.Application
private readonly SqlSugarRepository _repBookingStatusSubscribe;
private readonly SqlSugarRepository _repextendstate;
- private readonly SqlSugarRepository _bookingDeliveryRecordRep;
- private readonly SqlSugarRepository _bookingDeliveryRecordCtnRep;
+
private readonly IServiceWorkFlowManageService _serviceWorkFlowManageService;
private readonly IDjyUserConfigService _djyUserConfigService;
@@ -162,10 +161,7 @@ namespace Myshipping.Application
const string CONST_ONE_SOFILE_CATE_CODE = "one_so_file_template";
const string PRINT_DATASOURCE_KEY = "booking_order";
- const string CONST_MSK_API_COMMODITY_URL = "MSKApiCommodity";
- const string CONST_MSK_API_BOOKING_URL = "MSKApiBooking";
- const string CONST_MSK_API_Poing2P_SECD_URL = "MSKApiSailingSchedulePoint2Point";
- const string CONST_MSK_API_LOCATION_URL = "MSKApilocation";
+
public BookingOrderService(SqlSugarRepository rep, SqlSugarRepository repCtn, SqlSugarRepository ctndetailrep,
SqlSugarRepository bookinglog, SqlSugarRepository bookinglogdetail, SqlSugarRepository bookingremark,
@@ -181,8 +177,7 @@ namespace Myshipping.Application
ISysOrgService orgService, SqlSugarRepository repLineOpMgrConfig, SqlSugarRepository repSysEmp, SqlSugarRepository repAutoYard,
IServiceWorkFlowManageService serviceWorkFlowManageService, IDjyUserConfigService djyUserConfigService, IEventPublisher publisher, SqlSugarRepository repSlotBase,
SqlSugarRepository repSlotAllocation, SqlSugarRepository repSlotAllocationCtn, IBookingSlotService bookingSlotService,
- SqlSugarRepository repBookingStatusSubscribe, SqlSugarRepository repTenantParamValue,
- SqlSugarRepository bookingDeliveryRecordRep, SqlSugarRepository bookingDeliveryRecordCtnRep)
+ SqlSugarRepository repBookingStatusSubscribe, SqlSugarRepository repTenantParamValue)
{
this._logger = logger;
this._rep = rep;
@@ -236,8 +231,6 @@ namespace Myshipping.Application
this.bookingSlotService = bookingSlotService;
_repBookingStatusSubscribe = repBookingStatusSubscribe;
_repTenantParamValue = repTenantParamValue;
- _bookingDeliveryRecordRep = bookingDeliveryRecordRep;
- _bookingDeliveryRecordCtnRep = bookingDeliveryRecordCtnRep;
}
#region 主表和箱信息
@@ -11895,622 +11888,7 @@ namespace Myshipping.Application
#endregion
- #region 检索海运船期详情
- ///
- /// 检索海运船期详情
- ///
- /// 请求船期详情
- /// 返回船期结果
- [HttpPost("/BookingOrder/SearchShipSailingSchedule")]
- public async Task> SearchShipSailingSchedule(QueryShipSailingScheduleDto model)
- {
- List list = new List();
-
- /*
- MSKApiSailingSchedulePoint2Point
- */
- try
- {
- if (string.IsNullOrWhiteSpace(model.collectionOriginCityName))
- throw Oops.Oh($"始发地不能为空");
-
- if (string.IsNullOrWhiteSpace(model.deliveryDestinationCityName))
- throw Oops.Oh($"目的地不能为空");
-
- if (string.IsNullOrWhiteSpace(model.vesselOperatorCarrierCode))
- throw Oops.Oh($"服务船公司不能为空");
-
- if (string.IsNullOrWhiteSpace(model.carrierId))
- throw Oops.Oh("船公司代码不能为空");
-
- if (string.IsNullOrWhiteSpace(model.startDate))
- throw Oops.Oh($"预计离港日期不能为空");
-
- DateTime etd = DateTime.MinValue;
-
- if (!DateTime.TryParse(model.startDate, out etd))
- throw Oops.Oh($"预计离港日期格式错误");
-
- string queryUrl = string.Empty;
-
- if (model.carrierId.Equals("MSK", StringComparison.OrdinalIgnoreCase))
- {
- queryUrl = _cache.GetAllDictData().GetAwaiter().GetResult()
- .FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == CONST_MSK_API_Poing2P_SECD_URL)?.Value;
- }
- else
- {
- throw Oops.Oh($"当前船公司 {model.carrierId} 未配置相应的请求接口");
- }
-
- if (string.IsNullOrWhiteSpace(queryUrl))
- throw Oops.Oh("未配置查询船期请求接口地址,请联系管理员");
-
- var webAccountConfig = _webAccountConfig
- .GetAccountConfig("MSKApi", UserManager.UserId).GetAwaiter().GetResult();
-
- if (webAccountConfig == null)
- throw Oops.Oh("未配置个人账户,请先配置个人账户 类型-MSKApi");
-
- MSKAPISearchPoint2PointScheduleDto queryInfo = new MSKAPISearchPoint2PointScheduleDto
- {
- userKey = App.Configuration["MSKAPIDjyUserKey"],
- userSecret = App.Configuration["MSKAPIDjyUserSecret"],
- operatingEnvironment = App.Configuration["MSKAPIOPEnvironment"],
- mskAppKey = webAccountConfig.Account,
- collectionOriginCityName = model.collectionOriginCityName,
- collectionOriginCountryCode = model.collectionOriginCountryCode,
- deliveryDestinationCityName = model.deliveryDestinationCityName,
- deliveryDestinationCountryCode = model.deliveryDestinationCountryCode,
- cargoType = model.cargoType,
- exportServiceMode = model.exportServiceMode,
- importServiceMode = model.importServiceMode,
- vesselOperatorCarrierCode = model.vesselOperatorCarrierCode,
- startDate = etd.ToString("yyyy-MM-dd"),
- startDateType = "D",
- };
-
- MSKAPISearchPoint2PointScheduleResultDto resultInfo = null;
-
- var rlt = await queryUrl.SetBody(queryInfo)
- .PostAsStringAsync();
-
- if (!string.IsNullOrWhiteSpace(rlt))
- {
- try
- {
- resultInfo = JSON.Deserialize(rlt);
- }
- catch (Exception ex)
- {
- _logger.LogInformation($"请求MSK API查询船期异常,原因:{ex.Message}");
-
- throw Oops.Bah($"请求MSK API查询船期异常,原因:{ex.Message}");
- }
- }
-
- if (resultInfo != null && resultInfo.code == 200
- && resultInfo.data != null && resultInfo.data.Count > 0)
- {
- resultInfo.data.ForEach(a =>
- {
- a.transportSchedules.ForEach(b =>
- {
- SearchShipSailingScheduleResultDto info = new SearchShipSailingScheduleResultDto
- {
- carrierProductId = a.carrierProductId,
- carrierProductSequenceId = a.carrierProductSequenceId,
- ETD = b.departureDateTime,
- ATD = b.arrivalDateTime,
- vesselOperatorCarrierCode = b.vesselOperatorCarrierCode
- };
-
- if (b.departureDateTime.HasValue && b.arrivalDateTime.HasValue)
- {
- TimeSpan ts = b.arrivalDateTime.Value.Subtract(b.departureDateTime.Value);
- var timeDiff = ts.TotalHours;
-
- info.days = (int)Math.Ceiling(timeDiff / 24.0);
- }
-
- if (b.facilities != null)
- {
- info.orignCityName = b.facilities.collectionOrigin?.cityName;
- info.orignCarrierSiteGeoID = b.facilities.collectionOrigin?.carrierSiteGeoID;
- info.orignLocationName = b.facilities.collectionOrigin?.locationName;
- info.orignCountryCode = b.facilities.collectionOrigin?.countryCode;
- info.orignLocationType = b.facilities.collectionOrigin?.locationType;
- info.orignUNLocationCode = b.facilities.collectionOrigin?.UNLocationCode;
- info.orignUNRegionCode = b.facilities.collectionOrigin?.UNRegionCode;
-
- info.deliveryCityName = b.facilities.deliveryDestination?.cityName;
- info.deliveryCarrierSiteGeoID = b.facilities.deliveryDestination?.carrierSiteGeoID;
- info.deliveryLocationName = b.facilities.deliveryDestination?.locationName;
- info.deliveryCountryCode = b.facilities.deliveryDestination?.countryCode;
- info.deliveryLocationType = b.facilities.deliveryDestination?.locationType;
- info.deliveryUNLocationCode = b.facilities.deliveryDestination?.UNLocationCode;
- info.deliveryUNRegionCode = b.facilities.deliveryDestination?.UNRegionCode;
- }
-
- info.vesselIMONumber = b.firstDepartureVessel?.vesselIMONumber;
- info.carrierVesselCode = b.firstDepartureVessel?.carrierVesselCode;
- info.vesselName = b.firstDepartureVessel?.vesselName;
-
- if (b.transportLegs != null && b.transportLegs.Count > 0)
- {
- var firstTransportLegs = b.transportLegs.FirstOrDefault();
-
- if (firstTransportLegs.transport != null)
- {
- info.transportMode = firstTransportLegs.transport.transportMode;
- info.carrierDepartureVoyageNumber = firstTransportLegs.transport.carrierDepartureVoyageNumber;
- }
-
- }
-
- list.Add(info);
- });
- });
- }
- }
- catch (Exception ex)
- {
- _logger.LogError($"检索海运船期详情异常,req={JSON.Serialize(model)} 原因:{ex.Message}");
-
- throw Oops.Bah($"检索海运船期详情失败,{ex.Message}");
- }
-
- return list;
- }
- #endregion
-
- #region 发送马士基订舱请求
- ///
- /// 发送马士基订舱请求
- ///
- /// 请求订舱详情
- ///
- [HttpPost("/BookingOrder/SendMSKBooking")]
- public async Task SendMSKBooking(MSKBookingDto model)
- {
- MSKBookingResultDto result = new MSKBookingResultDto();
-
- /*
- MSKApiBooking
- */
- try
- {
- if (string.IsNullOrWhiteSpace(model.carrierCode))
- throw Oops.Oh($"服务船公司不能为空");
-
- if (string.IsNullOrWhiteSpace(model.carrierId))
- throw Oops.Oh("船公司代码不能为空");
-
- string sendUrl = string.Empty;
-
- if (model.carrierId.Equals("MSK", StringComparison.OrdinalIgnoreCase))
- {
- sendUrl = _cache.GetAllDictData().GetAwaiter().GetResult()
- .FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == CONST_MSK_API_BOOKING_URL)?.Value;
- }
- else
- {
- throw Oops.Oh($"当前船公司 {model.carrierId} 未配置相应的请求接口");
- }
-
- if (string.IsNullOrWhiteSpace(sendUrl))
- throw Oops.Oh("未配置发送订舱请求接口地址,请联系管理员");
-
- var webAccountConfig = _webAccountConfig
- .GetAccountConfig("MSKApi", UserManager.UserId).GetAwaiter().GetResult();
-
- if (webAccountConfig == null)
- throw Oops.Oh("未配置个人账户,请先配置个人账户 类型-MSKApi");
-
- DateTime nowDate = DateTime.Now;
-
- var recordInfo = model.Adapt();
- var recordCtnList = model.ctns.Adapt>();
-
- MSKAPIBookingDto bookingDto = new MSKAPIBookingDto
- {
- userKey = App.Configuration["MSKAPIDjyUserKey"],
- userSecret = App.Configuration["MSKAPIDjyUserSecret"],
- operatingEnvironment = App.Configuration["MSKAPIOPEnvironment"],
- mskAppKey = webAccountConfig.Account,
- bookingBody = new MSKAPIBookingBodyDto()
- };
-
- bookingDto.bookingBody.references = new MSKAPIBookingReferenceDto
- {
- priceReference = model.priceReference,
- productCode = model.productCode,
- sender = model.sender,
- };
-
- bookingDto.bookingBody.mandatoryParties = new MSKAPIBookingMandatoryParties
- {
- bookedByCompanyName = model.bookedByCompanyName,
- bookedByMaerskPartyCode = model.bookedByMaerskPartyCode,
- bookedByPartyContact = new MSKAPIBookingMandatoryPartyContact
- {
- name = model.bookedByCompanyContactName,
- email = model.bookedByCompanyContactEmail
- },
- priceOwnerCompanyName = model.priceOwnerCompanyName,
- priceOwnerMaerskPartyCode = model.priceOwnerMaerskPartyCode,
- priceOwnerPartyContact = new MSKAPIBookingMandatoryPartyContact
- {
- name = model.priceOwnerContactName,
- email = model.priceOwnerContactEmail
- },
- };
-
- bookingDto.bookingBody.transport = new MSKAPIBookingTransport
- {
- carrierCode = model.carrierCode,
- earliestDepartureDate = model.earliestDepartureDate,
- exportServiceMode = model.exportServiceMode,
- importServiceMode = model.importServiceMode,
- routeDetails = new MSKAPIBookingRouteDetails
- {
- placeOfReceipt = new MSKAPIBookingRouteDetailsBase
- {
- UNLocationCode = model.placeOfReceiptUnLocCode,
- cityName = model.placeOfReceiptCityName,
- },
- placeOfDelivery = new MSKAPIBookingRouteDetailsBase
- {
- UNLocationCode = model.placeOfDeliveryUnLocCode,
- cityName = model.placeOfDeliveryCityName,
- },
- selectedRoute = new MSKAPIBookingRoute
- {
- bookingSchedules = new MSKAPIBookingSchedules
- {
- originDepartureDateTimeLocal = model.originDepartureDateTimeLocal.Value.ToString("yyyy-MM-dd"),
- destinationArrivalDateTimeLocal = model.destinationArrivalDateTimeLocal.Value.ToString("yyyy-MM-dd"),
- transportMode = new MSKAPIBookingTransportMode
- {
- vessel = new MSKAPIBookingTransportModeVessel
- {
- name = model.vesselName,
- maerskVesselCode = model.carrierVesselCode,
- },
- exportVoyageNumber = model.exportVoyageNumber,
- },
- startLocation = new MSKAPIBookingRouteDetailsBase
- {
- cityName = model.placeOfReceiptCityName,
- UNLocationCode = model.placeOfReceiptUnLocCode
- },
- endLocation = new MSKAPIBookingRouteDetailsBase
- {
- cityName = model.placeOfDeliveryCityName,
- UNLocationCode = model.placeOfDeliveryUnLocCode
- },
- transportModeCode = model.transportMode
- }
- },
- }
- };
-
- bookingDto.bookingBody.cargo = new MSKAPIBookingCargo
- {
- commodityCode = model.commodityCode,
- commodityCodeType = "MaerskCode",
- cargoType = model.cargoType,
- totalCargoWeight = model.totalCargoWeight
- };
-
- //是否冷冻处理
- if (model.isReefer)
- {
- bookingDto.bookingBody.cargo.reeferSettings = new MSKAPIBookingCargoReeferSettings();
-
- bookingDto.bookingBody.cargo.reeferSettings.temperatureDetails = model.temperature;
- bookingDto.bookingBody.cargo.reeferSettings.temperatureMeasureUnit = "C";
-
- bookingDto.bookingBody.cargo.reeferSettings.noOfProbes = model.noOfProbes;
-
- //每小时需要的通风量,单位为立方米(0-285)
- bookingDto.bookingBody.cargo.reeferSettings.ventilation = model.ventilation;
-
- bookingDto.bookingBody.cargo.reeferSettings.humidity = model.humidity;
- }
-
- bookingDto.bookingBody.equipmentAndHaulage = new List();
-
- if (model.ctns != null && model.ctns.Count > 0)
- {
- model.ctns.ForEach(ctn =>
- {
- MSKAPIBookingEquipmentAndHaulage haulage = new MSKAPIBookingEquipmentAndHaulage
- {
- equipmentDetails = new MSKAPIBookingEquipmentAndHaulageItem(),
- stuffingDetails = new List()
- };
-
- haulage.equipmentDetails.ISOEquipmentCode = ctn.ctnCode;
- haulage.equipmentDetails.equipmentQuantity = ctn.ctnNum;
-
- haulage.stuffingDetails.Add(new MSKAPIBookingStuffingdetails
- {
- stuffingValue = (int)ctn.ctnSufferWeight.Value,
- stuffingMeasurementType = "WEIGHT",
- stuffingMeasurementUnit = "KGS"
- });
-
- bookingDto.bookingBody.equipmentAndHaulage.Add(haulage);
- });
- }
-
- recordInfo.CreatedTime = nowDate;
- recordInfo.UpdatedTime = nowDate;
- recordInfo.CreatedUserId = UserManager.UserId;
- recordInfo.CreatedUserName = UserManager.Name;
-
- _bookingDeliveryRecordRep.Insert(recordInfo);
-
- if (recordCtnList.Count > 0)
- {
- recordCtnList.ForEach(async x =>
- {
- x.RECORD_ID = recordInfo.Id;
- x.CreatedTime = nowDate;
- x.UpdatedTime = nowDate;
- x.CreatedUserId = UserManager.UserId;
- x.CreatedUserName = UserManager.Name;
-
- await _bookingDeliveryRecordCtnRep.InsertAsync(x);
- });
- }
-
- MSKAPIBookingResultDto resultInfo = null;
-
- var rlt = await sendUrl.SetBody(bookingDto)
- .PostAsStringAsync();
-
- if (!string.IsNullOrWhiteSpace(rlt))
- {
- try
- {
- resultInfo = JSON.Deserialize(rlt);
- }
- catch (Exception ex)
- {
- _logger.LogInformation($"请求MSK API订舱异常,原因:{ex.Message}");
-
- throw Oops.Bah($"请求MSK API订舱异常,原因:{ex.Message}");
- }
- }
-
- var entity = _bookingDeliveryRecordRep
- .FirstOrDefault(a => a.Id == recordInfo.Id);
-
- if (resultInfo != null && resultInfo.code == 200
- && resultInfo.data != null)
- {
- entity.REQUEST_ACKNOWLEDGEMENT_ID = resultInfo.data.requestAcknowledgementId;
- entity.BOOKING_REFERENCE = resultInfo.data.bookingReference;
- entity.STATUS = "SUCC";
-
- await _bookingDeliveryRecordRep.AsUpdateable(entity).UpdateColumns(x => new
- {
- x.REQUEST_ACKNOWLEDGEMENT_ID,
- x.BOOKING_REFERENCE,
- x.STATUS
- }).ExecuteCommandAsync();
- }
- else
- {
- entity.STATUS = "SUCC";
- entity.NOTES = resultInfo.msg.Length > 500 ? resultInfo.msg.Substring(0, 500) : resultInfo.msg;
-
- await _bookingDeliveryRecordRep.AsUpdateable(entity).UpdateColumns(x => new
- {
- x.STATUS,
- x.NOTES
- }).ExecuteCommandAsync();
- }
- }
- catch (Exception ex)
- {
- _logger.LogError($"MSK API订舱异常,req={JSON.Serialize(model)} 原因:{ex.Message}");
-
- throw Oops.Bah($"MSK API订舱失败,{ex.Message}");
- }
-
- return result;
- }
- #endregion
-
- #region 检索商品名称
- ///
- /// 检索商品名称
- ///
- /// 请求详情
- /// 返回检索结果
- [HttpPost("/BookingOrder/SearchCommodities")]
- public async Task> SearchCommodities(QueryCommoditiesDto model)
- {
- List list = new List();
-
- /*
- MSKApiCommodity
- */
- try
- {
- if (string.IsNullOrWhiteSpace(model.commodityName))
- throw Oops.Oh("商品名称不能为空");
-
- if (string.IsNullOrWhiteSpace(model.carrierId))
- throw Oops.Oh("船公司代码不能为空");
-
- if (model.commodityName.Length < 3)
- throw Oops.Oh("商品名称至少输入3个以上字符");
-
- string queryUrl = string.Empty;
-
- if (model.carrierId.Equals("MSK", StringComparison.OrdinalIgnoreCase))
- {
- queryUrl = _cache.GetAllDictData().GetAwaiter().GetResult()
- .FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == CONST_MSK_API_COMMODITY_URL)?.Value;
- }
- else
- {
- throw Oops.Oh($"当前船公司 {model.carrierId} 未配置相应的请求接口");
- }
-
- if (string.IsNullOrWhiteSpace(queryUrl))
- throw Oops.Oh("未配置商品请求接口地址,请联系管理员");
-
- var webAccountConfig = _webAccountConfig
- .GetAccountConfig("MSKApi", UserManager.UserId).GetAwaiter().GetResult();
-
- if (webAccountConfig == null)
- throw Oops.Oh("未配置个人账户,请先配置个人账户 类型-MSKApi");
-
- MSKAPISearchCommodityDto queryInfo = new MSKAPISearchCommodityDto
- {
- userKey = App.Configuration["MSKAPIDjyUserKey"],
- userSecret = App.Configuration["MSKAPIDjyUserSecret"],
- operatingEnvironment = App.Configuration["MSKAPIOPEnvironment"],
- commodityName = model.commodityName,
- mskAppKey = webAccountConfig.Account
- };
-
- MSKAPISearchCommodityResultDto resultInfo = null;
-
- var rlt = await queryUrl.SetBody(queryInfo)
- .PostAsStringAsync();
-
- if (!string.IsNullOrWhiteSpace(rlt))
- {
- try
- {
- resultInfo = JSON.Deserialize(rlt);
- }
- catch (Exception ex)
- {
- _logger.LogInformation($"请求MSK API检索商品异常,原因:{ex.Message}");
-
- throw Oops.Bah($"请求MSK API检索商品异常,原因:{ex.Message}");
- }
- }
-
- if (resultInfo != null && resultInfo.code == 200
- && resultInfo.data != null && resultInfo.data.Count > 0)
- {
- list = resultInfo.data.Adapt>();
- }
- }
- catch (Exception ex)
- {
- _logger.LogError($"检索商品名称异常,req={JSON.Serialize(model)} 原因:{ex.Message}");
-
- throw Oops.Bah($"检索商品名称失败,{ex.Message}");
- }
-
- return list;
- }
- #endregion
-
- #region 检索始发地、目的港口信息
- ///
- /// 检索始发地、目的港口信息
- ///
- /// 请求详情
- /// 返回检索结果
- [HttpPost("/BookingOrder/SearchLocations")]
- public async Task> SearchLocations(QueryLocationsDto model)
- {
- List list = new List();
-
- /*
- MSKApiCommodity
- */
- try
- {
- if (string.IsNullOrWhiteSpace(model.cityName))
- throw Oops.Oh("港口或城市名称不能为空");
-
- if (string.IsNullOrWhiteSpace(model.carrierCode))
- throw Oops.Oh("服务船公司不能为空");
-
- if (string.IsNullOrWhiteSpace(model.carrierId))
- throw Oops.Oh("船公司代码不能为空");
-
- if (model.cityName.Length < 3)
- throw Oops.Oh("港口或城市名称至少输入3个以上字符");
-
-
- string queryUrl = string.Empty;
-
- if (model.carrierId.Equals("MSK", StringComparison.OrdinalIgnoreCase))
- {
- queryUrl = _cache.GetAllDictData().GetAwaiter().GetResult()
- .FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == CONST_MSK_API_LOCATION_URL)?.Value;
- }
- else
- {
- throw Oops.Oh($"当前船公司 {model.carrierId} 未配置相应的请求接口");
- }
-
- if (string.IsNullOrWhiteSpace(queryUrl))
- throw Oops.Oh("未配置商品请求接口地址,请联系管理员");
-
- var webAccountConfig = _webAccountConfig
- .GetAccountConfig("MSKApi", UserManager.UserId).GetAwaiter().GetResult();
-
- if (webAccountConfig == null)
- throw Oops.Oh("未配检索始发地、目的港口,请先配置个人账户 类型-MSKApi");
-
- MSKAPISearchLocationDto queryInfo = new MSKAPISearchLocationDto
- {
- userKey = App.Configuration["MSKAPIDjyUserKey"],
- userSecret = App.Configuration["MSKAPIDjyUserSecret"],
- operatingEnvironment = App.Configuration["MSKAPIOPEnvironment"],
- name = model.cityName,
- mskAppKey = webAccountConfig.Account,
- carrierCode = model.carrierCode
- };
-
- MSKAPISearchLocationResultDto resultInfo = null;
-
- var rlt = await queryUrl.SetBody(queryInfo)
- .PostAsStringAsync();
-
- if (!string.IsNullOrWhiteSpace(rlt))
- {
- try
- {
- resultInfo = JSON.Deserialize(rlt);
- }
- catch (Exception ex)
- {
- _logger.LogInformation($"请求MSK API检索始发地、目的港口异常,原因:{ex.Message}");
-
- throw Oops.Bah($"请求MSK API检索始发地、目的港口异常,原因:{ex.Message}");
- }
- }
-
- if (resultInfo != null && resultInfo.code == 200
- && resultInfo.data != null && resultInfo.data.Count > 0)
- {
- list = resultInfo.data.Adapt>();
- }
- }
- catch (Exception ex)
- {
- _logger.LogError($"检索始发地、目的港口异常,req={JSON.Serialize(model)} 原因:{ex.Message}");
-
- throw Oops.Bah($"检索始发地、目的港口失败,{ex.Message}");
- }
-
- return list;
- }
- #endregion
+
}
}
diff --git a/Myshipping.Application/Service/BookingOrder/IBookingMSKAPIService.cs b/Myshipping.Application/Service/BookingOrder/IBookingMSKAPIService.cs
new file mode 100644
index 00000000..5711b30b
--- /dev/null
+++ b/Myshipping.Application/Service/BookingOrder/IBookingMSKAPIService.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Myshipping.Application
+{
+ public interface IBookingMSKAPIService
+ {
+ ///
+ /// 检索海运船期详情
+ ///
+ /// 请求船期详情
+ /// 返回船期结果
+ Task> SearchShipSailingSchedule(QueryShipSailingScheduleDto model);
+
+ ///
+ /// 发送马士基订舱请求
+ ///
+ /// 请求订舱详情
+ /// 返回检索结果
+ Task SendMSKBooking(MSKBookingDto model);
+
+ ///
+ /// 检索商品名称
+ ///
+ /// 请求详情
+ /// 返回检索结果
+ Task> SearchCommodities(QueryCommoditiesDto model);
+
+ ///
+ /// 检索始发地、目的港口信息
+ ///
+ /// 请求详情
+ /// 返回检索结果
+ Task> SearchLocations(QueryLocationsDto model);
+
+
+ }
+}
diff --git a/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs
index b759989e..3aa6b038 100644
--- a/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs
+++ b/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs
@@ -146,32 +146,6 @@ namespace Myshipping.Application
/// 返回回执
Task Save(SaveBookingOrderInput input);
- ///
- /// 检索海运船期详情
- ///
- /// 请求船期详情
- /// 返回船期结果
- Task> SearchShipSailingSchedule(QueryShipSailingScheduleDto model);
-
- ///
- /// 发送马士基订舱请求
- ///
- /// 请求订舱详情
- /// 返回检索结果
- Task SendMSKBooking(MSKBookingDto model);
-
- ///
- /// 检索商品名称
- ///
- /// 请求详情
- /// 返回检索结果
- Task> SearchCommodities(QueryCommoditiesDto model);
-
- ///
- /// 检索始发地、目的港口信息
- ///
- /// 请求详情
- /// 返回检索结果
- Task> SearchLocations(QueryLocationsDto model);
+
}
}
\ No newline at end of file