|
|
@ -17,6 +17,7 @@ using Myshipping.Core.Service;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
using Myshipping.Application.Helper;
|
|
|
|
using Myshipping.Application.Helper;
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Application.Service.BookingOrder
|
|
|
|
namespace Myshipping.Application.Service.BookingOrder
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -280,6 +281,7 @@ namespace Myshipping.Application.Service.BookingOrder
|
|
|
|
userSecret = App.Configuration["MSKAPIDjyUserSecret"],
|
|
|
|
userSecret = App.Configuration["MSKAPIDjyUserSecret"],
|
|
|
|
operatingEnvironment = App.Configuration["MSKAPIOPEnvironment"],
|
|
|
|
operatingEnvironment = App.Configuration["MSKAPIOPEnvironment"],
|
|
|
|
mskAppKey = webAccountConfig.Account,
|
|
|
|
mskAppKey = webAccountConfig.Account,
|
|
|
|
|
|
|
|
mskAppSecret = webAccountConfig.Password,
|
|
|
|
bookingBody = new MSKAPIBookingBodyDto()
|
|
|
|
bookingBody = new MSKAPIBookingBodyDto()
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -288,6 +290,7 @@ namespace Myshipping.Application.Service.BookingOrder
|
|
|
|
priceReference = model.priceReference,
|
|
|
|
priceReference = model.priceReference,
|
|
|
|
productCode = model.productCode,
|
|
|
|
productCode = model.productCode,
|
|
|
|
sender = model.sender,
|
|
|
|
sender = model.sender,
|
|
|
|
|
|
|
|
bookingOfficeUNLocationCode = "CNTAO"
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
bookingDto.bookingBody.mandatoryParties = new MSKAPIBookingMandatoryParties
|
|
|
|
bookingDto.bookingBody.mandatoryParties = new MSKAPIBookingMandatoryParties
|
|
|
@ -311,7 +314,7 @@ namespace Myshipping.Application.Service.BookingOrder
|
|
|
|
bookingDto.bookingBody.transport = new MSKAPIBookingTransport
|
|
|
|
bookingDto.bookingBody.transport = new MSKAPIBookingTransport
|
|
|
|
{
|
|
|
|
{
|
|
|
|
carrierCode = model.carrierCode,
|
|
|
|
carrierCode = model.carrierCode,
|
|
|
|
earliestDepartureDate = model.earliestDepartureDate,
|
|
|
|
earliestDepartureDate = model.earliestDepartureDate.Value.ToString("yyyy-MM-ddTHH:mm:ss"),
|
|
|
|
exportServiceMode = model.exportServiceMode,
|
|
|
|
exportServiceMode = model.exportServiceMode,
|
|
|
|
importServiceMode = model.importServiceMode,
|
|
|
|
importServiceMode = model.importServiceMode,
|
|
|
|
routeDetails = new MSKAPIBookingRouteDetails
|
|
|
|
routeDetails = new MSKAPIBookingRouteDetails
|
|
|
@ -328,10 +331,11 @@ namespace Myshipping.Application.Service.BookingOrder
|
|
|
|
},
|
|
|
|
},
|
|
|
|
selectedRoute = new MSKAPIBookingRoute
|
|
|
|
selectedRoute = new MSKAPIBookingRoute
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bookingSchedules = new MSKAPIBookingSchedules
|
|
|
|
bookingSchedules = new List<MSKAPIBookingSchedules> {
|
|
|
|
|
|
|
|
new MSKAPIBookingSchedules
|
|
|
|
{
|
|
|
|
{
|
|
|
|
originDepartureDateTimeLocal = model.originDepartureDateTimeLocal.Value.ToString("yyyy-MM-dd"),
|
|
|
|
originDepartureDateTimeLocal = model.originDepartureDateTimeLocal.Value.ToString("yyyy-MM-ddTHH:mm:ss"),
|
|
|
|
destinationArrivalDateTimeLocal = model.destinationArrivalDateTimeLocal.Value.ToString("yyyy-MM-dd"),
|
|
|
|
destinationArrivalDateTimeLocal = model.destinationArrivalDateTimeLocal.Value.ToString("yyyy-MM-ddTHH:mm:ss"),
|
|
|
|
transportMode = new MSKAPIBookingTransportMode
|
|
|
|
transportMode = new MSKAPIBookingTransportMode
|
|
|
|
{
|
|
|
|
{
|
|
|
|
vessel = new MSKAPIBookingTransportModeVessel
|
|
|
|
vessel = new MSKAPIBookingTransportModeVessel
|
|
|
@ -353,6 +357,7 @@ namespace Myshipping.Application.Service.BookingOrder
|
|
|
|
},
|
|
|
|
},
|
|
|
|
transportModeCode = model.transportMode
|
|
|
|
transportModeCode = model.transportMode
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -412,13 +417,14 @@ namespace Myshipping.Application.Service.BookingOrder
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var id = await Save(model);
|
|
|
|
var id = await InnerSave(model, isSendApi: true);
|
|
|
|
|
|
|
|
|
|
|
|
MSKAPIBookingResultDto resultInfo = null;
|
|
|
|
MSKAPIBookingResultDto resultInfo = null;
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"开始请求MSK API订舱,JSON={JSON.Serialize(bookingDto)}");
|
|
|
|
_logger.LogInformation($"开始请求MSK API订舱,JSON={JSON.Serialize(bookingDto)}");
|
|
|
|
|
|
|
|
|
|
|
|
var rlt = await sendUrl.SetBody(bookingDto)
|
|
|
|
var jsonBody = Newtonsoft.Json.JsonConvert.SerializeObject(bookingDto);
|
|
|
|
|
|
|
|
var rlt = await sendUrl.SetBody(jsonBody)
|
|
|
|
.PostAsStringAsync();
|
|
|
|
.PostAsStringAsync();
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"开始请求MSK API订舱,返回结果 JSON={JSON.Serialize(rlt)}");
|
|
|
|
_logger.LogInformation($"开始请求MSK API订舱,返回结果 JSON={JSON.Serialize(rlt)}");
|
|
|
@ -437,14 +443,21 @@ namespace Myshipping.Application.Service.BookingOrder
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MSKAPIBookingResultDataDto resultData = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(resultInfo.code == 200)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
resultData = JSON.Deserialize<MSKAPIBookingResultDataDto>(JSON.Serialize(resultInfo.data));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var entity = _bookingDeliveryRecordRep
|
|
|
|
var entity = _bookingDeliveryRecordRep
|
|
|
|
.FirstOrDefault(a => a.Id == recordInfo.Id);
|
|
|
|
.FirstOrDefault(a => a.Id == recordInfo.Id);
|
|
|
|
|
|
|
|
|
|
|
|
if (resultInfo != null && resultInfo.code == 200
|
|
|
|
if (resultInfo != null && resultInfo.code == 200
|
|
|
|
&& resultInfo.data != null)
|
|
|
|
&& resultData != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
entity.REQUEST_ACKNOWLEDGEMENT_ID = resultInfo.data.requestAcknowledgementId;
|
|
|
|
entity.REQUEST_ACKNOWLEDGEMENT_ID = resultData.requestAcknowledgementId;
|
|
|
|
entity.BOOKING_REFERENCE = resultInfo.data.bookingReference;
|
|
|
|
entity.BOOKING_REFERENCE = resultData.bookingReference;
|
|
|
|
entity.STATUS = "SUCC";
|
|
|
|
entity.STATUS = "SUCC";
|
|
|
|
|
|
|
|
|
|
|
|
await _bookingDeliveryRecordRep.AsUpdateable(entity).UpdateColumns(x => new
|
|
|
|
await _bookingDeliveryRecordRep.AsUpdateable(entity).UpdateColumns(x => new
|
|
|
@ -464,6 +477,9 @@ namespace Myshipping.Application.Service.BookingOrder
|
|
|
|
x.STATUS,
|
|
|
|
x.STATUS,
|
|
|
|
x.NOTES
|
|
|
|
x.NOTES
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw Oops.Bah(resultInfo.msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
@ -500,6 +516,7 @@ namespace Myshipping.Application.Service.BookingOrder
|
|
|
|
12、如果选择了冷冻处理,至少要填个温度
|
|
|
|
12、如果选择了冷冻处理,至少要填个温度
|
|
|
|
13、箱型、箱量、重量必填
|
|
|
|
13、箱型、箱量、重量必填
|
|
|
|
14、总重=箱量*单箱重量
|
|
|
|
14、总重=箱量*单箱重量
|
|
|
|
|
|
|
|
15、预计离港日期必填
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
if (string.IsNullOrWhiteSpace(model.priceReference))
|
|
|
|
if (string.IsNullOrWhiteSpace(model.priceReference))
|
|
|
|
throw Oops.Bah($"订舱合同惟一ID必填");
|
|
|
|
throw Oops.Bah($"订舱合同惟一ID必填");
|
|
|
@ -585,6 +602,9 @@ namespace Myshipping.Application.Service.BookingOrder
|
|
|
|
if (string.IsNullOrWhiteSpace(model.cargoType))
|
|
|
|
if (string.IsNullOrWhiteSpace(model.cargoType))
|
|
|
|
throw Oops.Bah($"货物标志必填");
|
|
|
|
throw Oops.Bah($"货物标志必填");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!model.earliestDepartureDate.HasValue)
|
|
|
|
|
|
|
|
throw Oops.Bah($"预计离港日期必填");
|
|
|
|
|
|
|
|
|
|
|
|
if (model.isReefer)
|
|
|
|
if (model.isReefer)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!model.temperature.HasValue)
|
|
|
|
if (!model.temperature.HasValue)
|
|
|
@ -960,9 +980,9 @@ namespace Myshipping.Application.Service.BookingOrder
|
|
|
|
/// <param name="id">马士基API订舱ID</param>
|
|
|
|
/// <param name="id">马士基API订舱ID</param>
|
|
|
|
/// <returns>返回详情</returns>
|
|
|
|
/// <returns>返回详情</returns>
|
|
|
|
[HttpGet("/BookingMSKAPI/GetInfo")]
|
|
|
|
[HttpGet("/BookingMSKAPI/GetInfo")]
|
|
|
|
public async Task<BookingDeliveryRecordDto> GetInfo(long id)
|
|
|
|
public async Task<MSKBookingDto> GetInfo(long id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
BookingDeliveryRecordDto model = null;
|
|
|
|
MSKBookingDto model = null;
|
|
|
|
|
|
|
|
|
|
|
|
var entity = await _bookingDeliveryRecordRep.AsQueryable()
|
|
|
|
var entity = await _bookingDeliveryRecordRep.AsQueryable()
|
|
|
|
.FirstAsync(a => a.Id == id);
|
|
|
|
.FirstAsync(a => a.Id == id);
|
|
|
@ -970,14 +990,15 @@ namespace Myshipping.Application.Service.BookingOrder
|
|
|
|
if(entity == null)
|
|
|
|
if(entity == null)
|
|
|
|
throw Oops.Oh($"获取马士基API订舱详情失败,不存在或已作废");
|
|
|
|
throw Oops.Oh($"获取马士基API订舱详情失败,不存在或已作废");
|
|
|
|
|
|
|
|
|
|
|
|
model = entity.Adapt<BookingDeliveryRecordDto>();
|
|
|
|
model = entity.Adapt<MSKBookingDto>();
|
|
|
|
|
|
|
|
|
|
|
|
var ctnList = _bookingDeliveryRecordCtnRep.AsQueryable()
|
|
|
|
var ctnList = _bookingDeliveryRecordCtnRep.AsQueryable()
|
|
|
|
.Where(a => a.RECORD_ID == id && a.IsDeleted == false).ToList();
|
|
|
|
.Where(a => a.RECORD_ID == id && a.IsDeleted == false).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
if (ctnList.Count > 0)
|
|
|
|
if (ctnList.Count > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
model.ctns = ctnList.Select(a => new BookingDeliveryRecordCtnDto {
|
|
|
|
model.ctns = ctnList.Select(a => new MSKBookingCtnInfo
|
|
|
|
|
|
|
|
{
|
|
|
|
id = a.Id,
|
|
|
|
id = a.Id,
|
|
|
|
ctnCode = a.CTN_CODE,
|
|
|
|
ctnCode = a.CTN_CODE,
|
|
|
|
carrierCtnCode = a.CARRIER_CTN_CODE,
|
|
|
|
carrierCtnCode = a.CARRIER_CTN_CODE,
|
|
|
@ -1000,6 +1021,18 @@ namespace Myshipping.Application.Service.BookingOrder
|
|
|
|
/// <returns>返回ID</returns>
|
|
|
|
/// <returns>返回ID</returns>
|
|
|
|
[HttpPost("/BookingMSKAPI/Save")]
|
|
|
|
[HttpPost("/BookingMSKAPI/Save")]
|
|
|
|
public async Task<long> Save([FromBody] MSKBookingDto model)
|
|
|
|
public async Task<long> Save([FromBody] MSKBookingDto model)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return await InnerSave(model);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 保存内部方法
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="model">API订舱详情</param>
|
|
|
|
|
|
|
|
/// <param name="isSendApi">是否发送API,true-发送需要校验状态;false-不校验状态</param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
private async Task<long> InnerSave(MSKBookingDto model,bool isSendApi = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DateTime nowDate = DateTime.Now;
|
|
|
|
DateTime nowDate = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
|
@ -1013,10 +1046,20 @@ namespace Myshipping.Application.Service.BookingOrder
|
|
|
|
.Select(a => $"{a.Key}*{a.ToList().Sum(b => b.ctnNum.HasValue ? b.ctnNum.Value : 0)}").ToArray());
|
|
|
|
.Select(a => $"{a.Key}*{a.ToList().Sum(b => b.ctnNum.HasValue ? b.ctnNum.Value : 0)}").ToArray());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (model.id.HasValue && model.id.Value > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var oldInfo = _bookingDeliveryRecordRep.AsQueryable()
|
|
|
|
|
|
|
|
.First(a=>a.Id == model.id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (oldInfo == null)
|
|
|
|
|
|
|
|
throw Oops.Oh("订舱数据不存在或已作废");
|
|
|
|
|
|
|
|
|
|
|
|
if (model.id.HasValue && model.id.Value > 0)
|
|
|
|
if (isSendApi)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if(oldInfo.STATUS == "SUCC")
|
|
|
|
|
|
|
|
throw Oops.Oh("订舱数据已发送成功,不能重复发送");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BookingDeliveryRecord entity = model.Adapt<BookingDeliveryRecord>();
|
|
|
|
BookingDeliveryRecord entity = model.Adapt<BookingDeliveryRecord>();
|
|
|
|
|
|
|
|
|
|
|
|
entity.Id = model.id.Value;
|
|
|
|
entity.Id = model.id.Value;
|
|
|
@ -1140,7 +1183,6 @@ namespace Myshipping.Application.Service.BookingOrder
|
|
|
|
return entity.Id;
|
|
|
|
return entity.Id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 删除
|
|
|
|
#region 删除
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|