|
|
|
@ -25,6 +25,8 @@ using Myshipping.Application.ConfigOption;
|
|
|
|
|
using Myshipping.Core.Service;
|
|
|
|
|
using Myshipping.Application.Service.BookingSlot.Dto;
|
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
|
using Furion.EventBus;
|
|
|
|
|
using Myshipping.Application.Event;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
@ -40,17 +42,22 @@ namespace Myshipping.Application
|
|
|
|
|
private readonly ILogger<BookingSlotService> _logger;
|
|
|
|
|
private readonly ISysCacheService _cache;
|
|
|
|
|
|
|
|
|
|
private readonly IEventPublisher _publisher;
|
|
|
|
|
|
|
|
|
|
public BookingSlotService(SqlSugarRepository<BookingSlotBase> repBase,
|
|
|
|
|
SqlSugarRepository<BookingSlotCtn> repCtn,
|
|
|
|
|
SqlSugarRepository<BookingSlotStock> repStock,
|
|
|
|
|
ILogger<BookingSlotService> logger,
|
|
|
|
|
ISysCacheService cache)
|
|
|
|
|
ISysCacheService cache,
|
|
|
|
|
IEventPublisher publisher)
|
|
|
|
|
{
|
|
|
|
|
_repBase = repBase;
|
|
|
|
|
_repCtn = repCtn;
|
|
|
|
|
_repStock = repStock;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_cache = cache;
|
|
|
|
|
|
|
|
|
|
_publisher = publisher;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 舱位
|
|
|
|
@ -123,6 +130,16 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//更新库存
|
|
|
|
|
await _publisher.PublishAsync(new ChannelEventSource("BookingSlotStock:Update", new BookingSlotStockUpdateModel
|
|
|
|
|
{
|
|
|
|
|
BOOKING_SLOT_TYPE = model.BOOKING_SLOT_TYPE,
|
|
|
|
|
CARRIERID = model.CARRIERID,
|
|
|
|
|
CONTRACT_NO = model.CONTRACT_NO,
|
|
|
|
|
VESSEL = model.VESSEL,
|
|
|
|
|
VOYNO = model.VOYNO
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
return await Detail(model.Id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -145,6 +162,16 @@ namespace Myshipping.Application
|
|
|
|
|
item.IsDeleted = true;
|
|
|
|
|
}
|
|
|
|
|
await _repCtn.UpdateAsync(ctns);
|
|
|
|
|
|
|
|
|
|
//更新库存
|
|
|
|
|
await _publisher.PublishAsync(new ChannelEventSource("BookingSlotStock:Update", new BookingSlotStockUpdateModel
|
|
|
|
|
{
|
|
|
|
|
BOOKING_SLOT_TYPE = entity.BOOKING_SLOT_TYPE,
|
|
|
|
|
CARRIERID = entity.CARRIERID,
|
|
|
|
|
CONTRACT_NO = entity.CONTRACT_NO,
|
|
|
|
|
VESSEL = entity.VESSEL,
|
|
|
|
|
VOYNO = entity.VOYNO
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -165,17 +192,40 @@ namespace Myshipping.Application
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 库存
|
|
|
|
|
///// <summary>
|
|
|
|
|
///// 库存查询
|
|
|
|
|
///// </summary>
|
|
|
|
|
///// <param name="input"></param>
|
|
|
|
|
///// <returns></returns>
|
|
|
|
|
//[HttpGet("/BookingSlot/pageStock")]
|
|
|
|
|
//public async Task<dynamic> PageStock([FromQuery] BookingSlotBasePageInput input)
|
|
|
|
|
//{
|
|
|
|
|
// var query = await _repStock.AsQueryable()
|
|
|
|
|
// .ToListAsync();
|
|
|
|
|
//}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 库存查询
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/BookingSlot/pageStock")]
|
|
|
|
|
public async Task<dynamic> PageStock(BookingSlotStockPageInput input)
|
|
|
|
|
{
|
|
|
|
|
var entities = await _repStock.AsQueryable()
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.VESSEL), u => u.VESSEL.Contains(input.VESSEL))
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.VOYNO), u => u.VOYNO.Contains(input.VOYNO))
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.CARRIER), u => u.CARRIER.Contains(input.CARRIER))
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.CTN_STAT), u => u.CTN_STAT.Contains(input.CTN_STAT))
|
|
|
|
|
.WhereIF(input.ETD_START.HasValue, u => u.ETD >= input.ETD_START.Value)
|
|
|
|
|
.WhereIF(input.ETD_END.HasValue, u => u.ETD < input.ETD_END.Value.AddDays(1))
|
|
|
|
|
.WhereIF(input.ETA_START.HasValue, u => u.ETA >= input.ETA_START.Value)
|
|
|
|
|
.WhereIF(input.ETA_END.HasValue, u => u.ETA < input.ETA_END.Value.AddDays(1))
|
|
|
|
|
.ToPagedListAsync(input.PageNo, input.PageSize);
|
|
|
|
|
|
|
|
|
|
var result = entities.Adapt<SqlSugarPagedList<BookingSlotStockListOutput>>();
|
|
|
|
|
|
|
|
|
|
return result.XnPagedResult();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 刷新库存统计
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/BookingSlot/refreshStock")]
|
|
|
|
|
public async Task RefreshStock(BookingSlotStockUpdateModel input)
|
|
|
|
|
{
|
|
|
|
|
//更新库存
|
|
|
|
|
await _publisher.PublishAsync(new ChannelEventSource("BookingSlotStock:Update", input));
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|