|
|
@ -1232,9 +1232,9 @@ namespace Myshipping.Application
|
|
|
|
[HttpGet("/BookingSlot/getAvailableCtnsBySlot")]
|
|
|
|
[HttpGet("/BookingSlot/getAvailableCtnsBySlot")]
|
|
|
|
public async Task<List<BookingSlotCtnDto>> GetAvailableCtnsBySlot(long slotId)
|
|
|
|
public async Task<List<BookingSlotCtnDto>> GetAvailableCtnsBySlot(long slotId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (await _repBase.IsExistsAsync(x => x.Id == slotId) == false)
|
|
|
|
if (await _repBase.IsExistsAsync(x => x.Id == slotId && x.IS_CANCELLATION == false) == false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw Oops.Oh($"获取舱位失败,舱位不存在或已作废,请刷新页面后重试");
|
|
|
|
throw Oops.Oh($"获取舱位失败,舱位不存在或已作废");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 1. 【舱位基础表】与【箱子表】做关联,并根据【舱位主键】、【箱型】做分组,统计出【总的箱量】,作为queryable1
|
|
|
|
// 1. 【舱位基础表】与【箱子表】做关联,并根据【舱位主键】、【箱型】做分组,统计出【总的箱量】,作为queryable1
|
|
|
@ -1424,7 +1424,9 @@ namespace Myshipping.Application
|
|
|
|
await _repAllocationCtn.InsertAsync(insertCtnList);
|
|
|
|
await _repAllocationCtn.InsertAsync(insertCtnList);
|
|
|
|
|
|
|
|
|
|
|
|
// 为订舱保存附件信息
|
|
|
|
// 为订舱保存附件信息
|
|
|
|
var lastestBcFile = await _bookingfile.Where(x => x.TypeCode == "bc" || x.TypeCode == "bc_notice").OrderByDescending(x => x.Id).FirstAsync();
|
|
|
|
var lastestBcFile = await _bookingfile.Where(x => (x.TypeCode == "bc" || x.TypeCode == "bc_notice") && x.BookingId == latestSlot.Id)
|
|
|
|
|
|
|
|
.OrderByDescending(x => x.Id)
|
|
|
|
|
|
|
|
.FirstAsync();
|
|
|
|
if (lastestBcFile != null)
|
|
|
|
if (lastestBcFile != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var file = lastestBcFile.Adapt<BookingFile>();
|
|
|
|
var file = lastestBcFile.Adapt<BookingFile>();
|
|
|
@ -1532,7 +1534,7 @@ namespace Myshipping.Application
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//var sql = select.OrderByDescending(u => u.CreatedTime).ToSqlString();
|
|
|
|
//var sql = select.OrderByDescending(u => u.CreatedTime).ToSqlString();
|
|
|
|
|
|
|
|
|
|
|
|
var entities = await select.OrderByDescending(u => u.CreatedTime)
|
|
|
|
var entities = await select.OrderByDescending(u => u.Id)
|
|
|
|
.ToPagedListAsync(input.PageNo, input.PageSize);
|
|
|
|
.ToPagedListAsync(input.PageNo, input.PageSize);
|
|
|
|
|
|
|
|
|
|
|
|
var result = entities.Adapt<SqlSugarPagedList<BookingSlotBaseListOutput>>();
|
|
|
|
var result = entities.Adapt<SqlSugarPagedList<BookingSlotBaseListOutput>>();
|
|
|
@ -1880,19 +1882,19 @@ namespace Myshipping.Application
|
|
|
|
throw Oops.Oh($"舱位信息不存在或已作废");
|
|
|
|
throw Oops.Oh($"舱位信息不存在或已作废");
|
|
|
|
|
|
|
|
|
|
|
|
// 判断是否已存在引用关系
|
|
|
|
// 判断是否已存在引用关系
|
|
|
|
if (_repAllocation.IsExists(a => a.BOOKING_SLOT_ID == slotInfo.Id
|
|
|
|
//if (_repAllocation.IsExists(a => a.BOOKING_SLOT_ID == slotInfo.Id
|
|
|
|
&& a.BOOKING_ID > 0 && a.IsDeleted == false))
|
|
|
|
// && a.BOOKING_ID > 0 && a.IsDeleted == false))
|
|
|
|
{
|
|
|
|
//{
|
|
|
|
throw Oops.Oh($"舱位已有对应的订舱订单,不能重复执行");
|
|
|
|
// throw Oops.Oh($"舱位已有对应的订舱订单,不能重复执行");
|
|
|
|
}
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
var ctnList = _repCtn.AsQueryable().Where(a => a.SLOT_ID == slotInfo.Id && a.IsDeleted == false)
|
|
|
|
//var ctnList = _repCtn.AsQueryable().Where(a => a.SLOT_ID == slotInfo.Id && a.IsDeleted == false)
|
|
|
|
.ToList();
|
|
|
|
// .ToList();
|
|
|
|
|
|
|
|
|
|
|
|
var fileList = await _bookingfile.AsQueryable().Filter(null, true)
|
|
|
|
var fileList = await _bookingfile.AsQueryable().Filter(null, true)
|
|
|
|
.Where(u => u.BookingId == slotInfo.Id && u.Moudle == "BookingSlot").ToListAsync();
|
|
|
|
.Where(u => u.BookingId == slotInfo.Id && u.Moudle == "BookingSlot").ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
var bookingOrderId = await GenerateBookingOrder(slotInfo, ctnList, fileList, model);
|
|
|
|
var bookingOrderId = await GenerateBookingOrder(slotInfo, fileList, model);
|
|
|
|
|
|
|
|
|
|
|
|
result.succ = true;
|
|
|
|
result.succ = true;
|
|
|
|
result.msg = "成功";
|
|
|
|
result.msg = "成功";
|
|
|
@ -1907,11 +1909,10 @@ namespace Myshipping.Application
|
|
|
|
/// 生成订舱
|
|
|
|
/// 生成订舱
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="bookingSlotBase">舱位详情</param>
|
|
|
|
/// <param name="bookingSlotBase">舱位详情</param>
|
|
|
|
/// <param name="bookingSlotCtnList">舱位集装箱列表</param>
|
|
|
|
|
|
|
|
/// <param name="bookingSlotFileList">舱位附件列表</param>
|
|
|
|
/// <param name="bookingSlotFileList">舱位附件列表</param>
|
|
|
|
/// <param name="generateModel">订舱请求详情</param>
|
|
|
|
/// <param name="generateModel">订舱请求详情</param>
|
|
|
|
/// <returns>返回订舱ID</returns>
|
|
|
|
/// <returns>返回订舱ID</returns>
|
|
|
|
private async Task<long> GenerateBookingOrder(BookingSlotBase bookingSlotBase, List<BookingSlotCtn> bookingSlotCtnList,
|
|
|
|
private async Task<long> GenerateBookingOrder(BookingSlotBase bookingSlotBase,
|
|
|
|
List<BookingFile> bookingSlotFileList,
|
|
|
|
List<BookingFile> bookingSlotFileList,
|
|
|
|
BookingGenerateDto generateModel)
|
|
|
|
BookingGenerateDto generateModel)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1930,13 +1931,16 @@ namespace Myshipping.Application
|
|
|
|
|| t.EnName.Equals(bookingSlotBase.CARRIERID, StringComparison.OrdinalIgnoreCase)
|
|
|
|
|| t.EnName.Equals(bookingSlotBase.CARRIERID, StringComparison.OrdinalIgnoreCase)
|
|
|
|
|| t.CnName.Equals(bookingSlotBase.CARRIERID, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
|
|
|
|
|| t.CnName.Equals(bookingSlotBase.CARRIERID, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var custNo = bookingSlotBase.SLOT_BOOKING_NO.Trim();
|
|
|
|
|
|
|
|
|
|
|
|
SaveBookingOrderInput bkModel = new SaveBookingOrderInput
|
|
|
|
SaveBookingOrderInput bkModel = new SaveBookingOrderInput
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CUSTOMERID = generateModel.CustomerId,
|
|
|
|
CUSTOMERID = generateModel.CustomerId,
|
|
|
|
CUSTOMERNAME = generateModel.CustomerName,
|
|
|
|
CUSTOMERNAME = generateModel.CustomerName,
|
|
|
|
CARRIERID = carrierInfo.Code?.Trim(),
|
|
|
|
CARRIERID = carrierInfo.Code?.Trim(),
|
|
|
|
CARRIER = carrierInfo.CnName?.Trim(),
|
|
|
|
CARRIER = carrierInfo.CnName?.Trim(),
|
|
|
|
MBLNO = bookingSlotBase.SLOT_BOOKING_NO.Trim(),
|
|
|
|
CUSTNO = custNo,
|
|
|
|
|
|
|
|
//MBLNO = bookingSlotBase.SLOT_BOOKING_NO.Trim(),
|
|
|
|
CONTRACTNO = !string.IsNullOrWhiteSpace(bookingSlotBase.CONTRACT_NO) ? bookingSlotBase.CONTRACT_NO : "",
|
|
|
|
CONTRACTNO = !string.IsNullOrWhiteSpace(bookingSlotBase.CONTRACT_NO) ? bookingSlotBase.CONTRACT_NO : "",
|
|
|
|
VESSEL = bookingSlotBase.VESSEL.ToUpper().Trim(),
|
|
|
|
VESSEL = bookingSlotBase.VESSEL.ToUpper().Trim(),
|
|
|
|
VOYNO = bookingSlotBase.VOYNO.ToUpper().Trim(),
|
|
|
|
VOYNO = bookingSlotBase.VOYNO.ToUpper().Trim(),
|
|
|
@ -1963,11 +1967,33 @@ namespace Myshipping.Application
|
|
|
|
ctnInputs = new List<BookingCtnDto>()
|
|
|
|
ctnInputs = new List<BookingCtnDto>()
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 判断是否为拆票的舱位,如果为拆票,提单号需要加上ABCD...
|
|
|
|
|
|
|
|
var selectNum = generateModel.CtnList.Sum(x => x.CTNNUM);
|
|
|
|
|
|
|
|
var allNum = await _repCtn.AsQueryable().Where(x => x.SLOT_ID == generateModel.SlotId).SumAsync(x => x.CTNNUM);
|
|
|
|
|
|
|
|
bkModel.IsSplit = selectNum != allNum;
|
|
|
|
|
|
|
|
if (bkModel.IsSplit == true)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var sql = _repBookingOrder.AsQueryable().Where(" MBLNO like @mblno+'_' ", new { mblno = custNo }).ToSqlString();
|
|
|
|
|
|
|
|
var currentOrder = await _repBookingOrder.AsQueryable().Where(" MBLNO like @mblno+'_' ", new { mblno = custNo })
|
|
|
|
|
|
|
|
.OrderByDescending(x => x.Id)
|
|
|
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
|
|
|
if (currentOrder == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bkModel.MBLNO = custNo + "A";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var lastLetter = currentOrder.MBLNO.Substring(currentOrder.MBLNO.Length - 1, 1)[0];
|
|
|
|
|
|
|
|
var newMblno = custNo + LetterIndexUtil.GetNextLetter(lastLetter);
|
|
|
|
|
|
|
|
bkModel.MBLNO = newMblno;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var ctnCodeList = _cache.GetAllCodeCtn().GetAwaiter().GetResult().ToList();
|
|
|
|
var ctnCodeList = _cache.GetAllCodeCtn().GetAwaiter().GetResult().ToList();
|
|
|
|
|
|
|
|
|
|
|
|
if (bookingSlotCtnList.Count > 0)
|
|
|
|
if (generateModel.CtnList != null && generateModel.CtnList.Count > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bookingSlotCtnList.ForEach(t =>
|
|
|
|
generateModel.CtnList.ForEach(t =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var ctnCode = ctnCodeList.FirstOrDefault(a => !string.IsNullOrWhiteSpace(a.Name) &&
|
|
|
|
var ctnCode = ctnCodeList.FirstOrDefault(a => !string.IsNullOrWhiteSpace(a.Name) &&
|
|
|
|
a.Name.Equals(t.CTNALL, StringComparison.OrdinalIgnoreCase));
|
|
|
|
a.Name.Equals(t.CTNALL, StringComparison.OrdinalIgnoreCase));
|
|
|
@ -1983,6 +2009,16 @@ namespace Myshipping.Application
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 验证舱位是否可用
|
|
|
|
|
|
|
|
var slotInfo = bookingSlotBase.Adapt<BookingSlotBaseWithCtnDto>();
|
|
|
|
|
|
|
|
slotInfo.CtnList = generateModel.CtnList;
|
|
|
|
|
|
|
|
var importSlots = new List<BookingSlotBaseWithCtnDto>() { slotInfo };
|
|
|
|
|
|
|
|
var checkResult = await CheckImportSlots(importSlots, 0);
|
|
|
|
|
|
|
|
if (!checkResult.isEnough)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh(checkResult.message);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var bookingOrderService = _namedBookingOrderServiceProvider.GetService<ITransient>(nameof(BookingOrderService));
|
|
|
|
var bookingOrderService = _namedBookingOrderServiceProvider.GetService<ITransient>(nameof(BookingOrderService));
|
|
|
|
var bkRlt = await bookingOrderService.Save(bkModel);
|
|
|
|
var bkRlt = await bookingOrderService.Save(bkModel);
|
|
|
|
|
|
|
|
|
|
|
@ -1992,19 +2028,8 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
|
|
if (id > 0)
|
|
|
|
if (id > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
List<BookingSlotBaseWithCtnDto> slots = new List<BookingSlotBaseWithCtnDto>();
|
|
|
|
////对应订舱和舱位关系
|
|
|
|
|
|
|
|
var allocRlt = await ImportSlots(importSlots, id, false, generateModel);
|
|
|
|
//检索舱位信息
|
|
|
|
|
|
|
|
var slotInfo = Detail(bookingSlotBase.Id).GetAwaiter().GetResult();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BookingSlotBaseWithCtnDto baseInfo = slotInfo.Adapt<BookingSlotBaseWithCtnDto>();
|
|
|
|
|
|
|
|
baseInfo.Id = bookingSlotBase.Id;
|
|
|
|
|
|
|
|
baseInfo.CtnList = slotInfo.CtnList.Adapt<List<BookingSlotCtnDto>>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
slots.Add(baseInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//对应订舱和舱位关系
|
|
|
|
|
|
|
|
var allocRlt = await ImportSlots(slots, id, false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//这里如果指定了委托单位的邮件联系人,则推送订舱联系人
|
|
|
|
//这里如果指定了委托单位的邮件联系人,则推送订舱联系人
|
|
|
|
if (generateModel.CustomerContactList != null && generateModel.CustomerContactList.Count > 0)
|
|
|
|
if (generateModel.CustomerContactList != null && generateModel.CustomerContactList.Count > 0)
|
|
|
@ -2135,6 +2160,7 @@ namespace Myshipping.Application
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.LogError($"MBLNO:{bookingSlotBase.SLOT_BOOKING_NO} 生成订舱订单异常,原因:{ex.Message}");
|
|
|
|
_logger.LogError($"MBLNO:{bookingSlotBase.SLOT_BOOKING_NO} 生成订舱订单异常,原因:{ex.Message}");
|
|
|
|
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|