修改MSK SPOT

master
jianghaiqing 5 months ago
parent eb6b496fd6
commit dfcb74f6fe

@ -0,0 +1,54 @@
using Myshipping.Core.Entity;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application.Entity
{
/// <summary>
/// 订舱递送记录表船期记录
/// </summary>
[SugarTable("booking_delivery_record_ship_schedule")]
[Description("订舱递送记录表船期记录")]
public class BookingDeliveryRecordShipSchedule : DBEntityTenant
{
/// <summary>
/// 主记录ID
/// </summary>
public long RECORD_ID { get; set; }
/// <summary>
/// 船期金额
/// </summary>
public Nullable<decimal> SHIP_RATE_TOTAL_AMOUNT { get; set; }
/// <summary>
/// 船期币别
/// </summary>
public string SHIP_RATE_TOTAL_CURRENCY { get; set; }
/// <summary>
/// 船期PID
/// </summary>
public Nullable<long> SHIP_RATE_PID { get; set; }
/// <summary>
/// 船期MD5
/// </summary>
public string SHIP_RATE_MD5 { get; set; }
/// <summary>
/// 价格IDSPOT专用对应单个船期
/// </summary>
public string PRICE_ID { get; set; }
/// <summary>
/// 船期JSON
/// </summary>
public string SHIP_JSON { get; set; }
}
}

@ -32,6 +32,8 @@ namespace Myshipping.Application.Service.BookingOrder
{
private readonly SqlSugarRepository<BookingDeliveryRecord> _bookingDeliveryRecordRep;
private readonly SqlSugarRepository<BookingDeliveryRecordCtn> _bookingDeliveryRecordCtnRep;
private readonly SqlSugarRepository<BookingDeliveryRecordShipSchedule> _bookingDeliveryRecordShipScheduleRep;
private readonly ISysCacheService _cache;
private readonly IDjyWebsiteAccountConfigService _webAccountConfig;
private readonly ILogger<BookingMSKSPOTAPIService> _logger;
@ -47,6 +49,7 @@ namespace Myshipping.Application.Service.BookingOrder
IDjyWebsiteAccountConfigService webAccountConfig, SqlSugarRepository<BookingDeliveryRecord> bookingDeliveryRecordRep,
ISysDataUserMenu sysDataUserMenuService,
IDjyTenantParamService djyTenantParamService,
SqlSugarRepository<BookingDeliveryRecordShipSchedule> bookingDeliveryRecordShipScheduleRep,
SqlSugarRepository<BookingDeliveryRecordCtn> bookingDeliveryRecordCtnRep)
{
_logger = logger;
@ -56,6 +59,7 @@ namespace Myshipping.Application.Service.BookingOrder
_bookingDeliveryRecordCtnRep = bookingDeliveryRecordCtnRep;
_sysDataUserMenuService = sysDataUserMenuService;
_djyTenantParamService = djyTenantParamService;
_bookingDeliveryRecordShipScheduleRep = bookingDeliveryRecordShipScheduleRep;
}
#region 检索始发地、目的港口信息
@ -518,6 +522,16 @@ namespace Myshipping.Application.Service.BookingOrder
}
#endregion
private MSKAPISPOTSearchScheduleRateResultDataDto GetCacheShipSailingSchedule(long pid, string busiType = "MSKSPOT")
{
if (_cache.Exists($"{pid}_{busiType}"))
{
return _cache.Get<MSKAPISPOTSearchScheduleRateResultDataDto>($"{pid}_{busiType}");
}
return null;
}
#region 发送马士基订舱请求
/// <summary>
/// 发送马士基订舱请求
@ -1126,6 +1140,19 @@ namespace Myshipping.Application.Service.BookingOrder
}).ToList();
}
MSKAPISPOTSearchScheduleRateResultDataDto 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<MSKAPISPOTSearchScheduleRateResultDataDto>(shipScheduleRecord.SHIP_JSON);
}
}
return model;
}
#endregion
@ -1158,6 +1185,26 @@ namespace Myshipping.Application.Service.BookingOrder
_logger.LogInformation($"获取请求马士基API订舱报文JSON={JSON.Serialize(model)}");
MSKAPISPOTSearchScheduleRateResultDataDto 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 = GetCacheShipSailingSchedule(model.PId);
}
else
{
selectedShipSchedule = JSON.Deserialize<MSKAPISPOTSearchScheduleRateResultDataDto>(shipScheduleRecord.SHIP_JSON);
}
if (selectedShipSchedule == null)
throw Oops.Oh("船期数据校验失败,请重新查询船期信息");
}
if (model.ctns != null && model.ctns.Count > 0)
{
ctnStat = string.Join(",", model.ctns.GroupBy(a => a.ctnName)
@ -1287,6 +1334,8 @@ namespace Myshipping.Application.Service.BookingOrder
{
BookingDeliveryRecord entity = model.Adapt<BookingDeliveryRecord>();
entity.CreatedTime = nowDate;
entity.UpdatedTime = nowDate;
entity.CreatedUserId = UserManager.UserId;

@ -449,5 +449,35 @@ namespace Myshipping.Application
/// 预计航行天数
/// </summary>
public Nullable<int> estSailingDays { get; set; }
// <summary>
/// 主键ID
/// </summary>
public Nullable<long> PId { get; set; }
/// <summary>
/// 价格id, 可进一步通过API进行其他操作
/// </summary>
public string priceID { get; set; }
/// <summary>
/// 船期价格
/// </summary>
public Nullable<decimal> ShipRateTotalAmount { get; set; }
/// <summary>
/// 船期币别
/// </summary>
public string ShipRateTotalCurrency { get; set; }
/// <summary>
/// 订舱通道类型 CON_API-合约APISPOT_API-SPOT订舱EDI-EDI订舱
/// </summary>
public string bookingChannelType { get; set; }
/// <summary>
/// 订舱通道类型 CON_API-合约APISPOT_API-SPOT订舱EDI-EDI订舱
/// </summary>
public string bookingChannelTypeName { get; set; }
}
}

@ -388,7 +388,13 @@ namespace Myshipping.Application
.Map(dest => dest.isRecvBKCancel, src => src.IS_RECV_BK_CANCEL)
.Map(dest => dest.LstRecvBKCancelDate, src => src.LST_RECV_BK_CANCEL_DATE)
.Map(dest => dest.bookingReference, src => src.BOOKING_REFERENCE)
.Map(dest => dest.estSailingDays, src => src.EST_SAILING_DAYS);
.Map(dest => dest.estSailingDays, src => src.EST_SAILING_DAYS)
.Map(dest => dest.PId, src => src.SHIP_RATE_PID)
.Map(dest => dest.priceID, src => src.PRICE_ID)
.Map(dest => dest.ShipRateTotalAmount, src => src.SHIP_RATE_TOTAL_AMOUNT)
.Map(dest => dest.ShipRateTotalCurrency, src => src.SHIP_RATE_TOTAL_CURRENCY)
.Map(dest => dest.bookingChannelType, src => src.BOOKING_CHANNEL_TYPE)
.Map(dest => dest.bookingChannelTypeName, src => src.BOOKING_CHANNEL_TYPE_NAME);
}
}
}

Loading…
Cancel
Save