jianghaiqing 6 months ago
commit 022369660c

@ -1052,5 +1052,20 @@ namespace Myshipping.Application.Entity
/// 运输条款代码 /// 运输条款代码
/// </summary> /// </summary>
public string SERVICECODE { get; set; } public string SERVICECODE { get; set; }
/// <summary>
/// 是否为舱位拆票后生成的订舱
/// </summary>
public bool? IsSplit { get; set; }
/// <summary>
/// 分单操作ID
/// </summary>
public long? SubOpId { get; set; }
/// <summary>
/// 分单操作
/// </summary>
public string SubOp { get; set; }
} }
} }

@ -300,7 +300,7 @@ namespace Myshipping.Application
var query = _rep.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID) var query = _rep.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID)
.WhereIF(!input.ISDel, x => x.IsDeleted == false) .WhereIF(!input.ISDel, x => x.IsDeleted == false)
.WhereIF(input.ISDel, x => x.IsDeleted == true) .WhereIF(input.ISDel, x => x.IsDeleted == true)
.WhereIF(input.firstFlag, x => (x.ETD <= etoday && x.ETD >= ftoday || x.ETD == null) && (x.CreatedUserId == UserManager.UserId || x.OPID == UserManager.UserId.ToString() || x.DOCID == UserManager.UserId.ToString() || x.ROUTEID == UserManager.UserId.ToString() || x.LineManageID == UserManager.UserId.ToString() || x.CUSTSERVICEID == UserManager.UserId.ToString() || x.SALEID == UserManager.UserId.ToString())) //首次加载数据ETD前后15天且创建人、操作是当前人 .WhereIF(input.firstFlag, x => (x.ETD <= etoday && x.ETD >= ftoday || x.ETD == null) && (x.CreatedUserId == UserManager.UserId || x.OPID == UserManager.UserId.ToString() || x.SubOpId == UserManager.UserId || x.DOCID == UserManager.UserId.ToString() || x.ROUTEID == UserManager.UserId.ToString() || x.LineManageID == UserManager.UserId.ToString() || x.CUSTSERVICEID == UserManager.UserId.ToString() || x.SALEID == UserManager.UserId.ToString())) //首次加载数据ETD前后15天且创建人、操作是当前人
.Where(x => x.ParentId == 0 || x.ParentId == null) //台账只查询主单!! .Where(x => x.ParentId == 0 || x.ParentId == null) //台账只查询主单!!
.WhereIF(input.Id != 0, x => x.Id == input.Id) .WhereIF(input.Id != 0, x => x.Id == input.Id)
.WhereIF(pidlist != null && pidlist.Count > 0, x => pidlist.Contains(x.Id)) .WhereIF(pidlist != null && pidlist.Count > 0, x => pidlist.Contains(x.Id))
@ -407,8 +407,10 @@ namespace Myshipping.Application
.WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTYTEL), u => u.NOTIFYPARTYTEL == input.NOTIFYPARTYTEL) .WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTYTEL), u => u.NOTIFYPARTYTEL == input.NOTIFYPARTYTEL)
.WhereIF(!string.IsNullOrWhiteSpace(input.PONO), u => u.PONO.Contains(input.PONO)) .WhereIF(!string.IsNullOrWhiteSpace(input.PONO), u => u.PONO.Contains(input.PONO))
.WhereIF(!string.IsNullOrWhiteSpace(input.OPID), u => u.OPID == input.OPID) .WhereIF(!string.IsNullOrWhiteSpace(input.OPID), u => u.OPID == input.OPID)
.WhereIF(input.SubOpId.HasValue, u => u.SubOpId == input.SubOpId)
.WhereIF(!string.IsNullOrWhiteSpace(input.DOCID), u => u.DOCID == input.DOCID) .WhereIF(!string.IsNullOrWhiteSpace(input.DOCID), u => u.DOCID == input.DOCID)
.WhereIF(!string.IsNullOrWhiteSpace(input.OP), u => u.OP == input.OP) .WhereIF(!string.IsNullOrWhiteSpace(input.OP), u => u.OP == input.OP)
.WhereIF(!string.IsNullOrWhiteSpace(input.SubOp), u => u.SubOp == input.SubOp)
.WhereIF(!string.IsNullOrWhiteSpace(input.DOC), u => u.DOC == input.DOC) .WhereIF(!string.IsNullOrWhiteSpace(input.DOC), u => u.DOC == input.DOC)
.WhereIF(!string.IsNullOrWhiteSpace(input.SALEID), u => u.SALEID == input.SALEID) .WhereIF(!string.IsNullOrWhiteSpace(input.SALEID), u => u.SALEID == input.SALEID)
.WhereIF(!string.IsNullOrWhiteSpace(input.SALE), u => u.SALE.Contains(input.SALE)) .WhereIF(!string.IsNullOrWhiteSpace(input.SALE), u => u.SALE.Contains(input.SALE))
@ -455,7 +457,7 @@ namespace Myshipping.Application
UserManager.UserId.ToString() == u.ROUTEID || UserManager.Name.ToString() == u.ROUTE || UserManager.UserId.ToString() == u.ROUTEID || UserManager.Name.ToString() == u.ROUTE ||
UserManager.UserId.ToString() == u.LineManageID || UserManager.Name.ToString() == u.LineManage || UserManager.UserId.ToString() == u.LineManageID || UserManager.Name.ToString() == u.LineManage ||
UserManager.UserId.ToString() == u.SALEID || UserManager.Name.ToString() == u.SALE || UserManager.UserId.ToString() == u.SALEID || UserManager.Name.ToString() == u.SALE ||
userlistString.Contains(u.OPID) || UserManager.Name.ToString() == u.OP || userlistString.Contains(u.OPID) || (u.SubOpId.HasValue && userlistString.Contains(u.SubOpId.ToString())) || UserManager.Name.ToString() == u.OP || UserManager.Name.ToString() == u.SubOp ||
userlistString.Contains(u.DOCID) || UserManager.Name.ToString() == u.DOC || userlistString.Contains(u.DOCID) || UserManager.Name.ToString() == u.DOC ||
UserManager.UserId.ToString() == u.CUSTSERVICEID || UserManager.Name.ToString() == u.CUSTSERVICE); UserManager.UserId.ToString() == u.CUSTSERVICEID || UserManager.Name.ToString() == u.CUSTSERVICE);
@ -890,7 +892,7 @@ namespace Myshipping.Application
var query = _rep.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID) var query = _rep.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID)
.WhereIF(!input.ISDel, x => x.IsDeleted == false) .WhereIF(!input.ISDel, x => x.IsDeleted == false)
.WhereIF(input.ISDel, x => x.IsDeleted == true) .WhereIF(input.ISDel, x => x.IsDeleted == true)
.WhereIF(input.firstFlag, x => (x.ETD <= etoday && x.ETD >= ftoday || x.ETD == null) && (x.CreatedUserId == UserManager.UserId || x.OPID == UserManager.UserId.ToString() || x.DOCID == UserManager.UserId.ToString() || x.ROUTEID == UserManager.UserId.ToString() || x.LineManageID == UserManager.UserId.ToString() || x.CUSTSERVICEID == UserManager.UserId.ToString() || x.SALEID == UserManager.UserId.ToString())) //首次加载数据ETD前后15天且创建人、操作是当前人 .WhereIF(input.firstFlag, x => (x.ETD <= etoday && x.ETD >= ftoday || x.ETD == null) && (x.CreatedUserId == UserManager.UserId || x.OPID == UserManager.UserId.ToString() || x.SubOpId == UserManager.UserId || x.DOCID == UserManager.UserId.ToString() || x.ROUTEID == UserManager.UserId.ToString() || x.LineManageID == UserManager.UserId.ToString() || x.CUSTSERVICEID == UserManager.UserId.ToString() || x.SALEID == UserManager.UserId.ToString())) //首次加载数据ETD前后15天且创建人、操作是当前人
.Where(x => x.ParentId == 0 || x.ParentId == null) //台账只查询主单!! .Where(x => x.ParentId == 0 || x.ParentId == null) //台账只查询主单!!
.WhereIF(input.Id != 0, x => x.Id == input.Id) .WhereIF(input.Id != 0, x => x.Id == input.Id)
.WhereIF(pidlist != null && pidlist.Count > 0, x => pidlist.Contains(x.Id)) .WhereIF(pidlist != null && pidlist.Count > 0, x => pidlist.Contains(x.Id))
@ -997,8 +999,10 @@ namespace Myshipping.Application
.WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTYTEL), u => u.NOTIFYPARTYTEL == input.NOTIFYPARTYTEL) .WhereIF(!string.IsNullOrWhiteSpace(input.NOTIFYPARTYTEL), u => u.NOTIFYPARTYTEL == input.NOTIFYPARTYTEL)
.WhereIF(!string.IsNullOrWhiteSpace(input.PONO), u => u.PONO.Contains(input.PONO)) .WhereIF(!string.IsNullOrWhiteSpace(input.PONO), u => u.PONO.Contains(input.PONO))
.WhereIF(!string.IsNullOrWhiteSpace(input.OPID), u => u.OPID == input.OPID) .WhereIF(!string.IsNullOrWhiteSpace(input.OPID), u => u.OPID == input.OPID)
.WhereIF(input.SubOpId.HasValue, u => u.SubOpId == input.SubOpId)
.WhereIF(!string.IsNullOrWhiteSpace(input.DOCID), u => u.DOCID == input.DOCID) .WhereIF(!string.IsNullOrWhiteSpace(input.DOCID), u => u.DOCID == input.DOCID)
.WhereIF(!string.IsNullOrWhiteSpace(input.OP), u => u.OP == input.OP) .WhereIF(!string.IsNullOrWhiteSpace(input.OP), u => u.OP == input.OP)
.WhereIF(!string.IsNullOrWhiteSpace(input.SubOp), u => u.SubOp == input.SubOp)
.WhereIF(!string.IsNullOrWhiteSpace(input.DOC), u => u.DOC == input.DOC) .WhereIF(!string.IsNullOrWhiteSpace(input.DOC), u => u.DOC == input.DOC)
.WhereIF(!string.IsNullOrWhiteSpace(input.SALEID), u => u.SALEID == input.SALEID) .WhereIF(!string.IsNullOrWhiteSpace(input.SALEID), u => u.SALEID == input.SALEID)
.WhereIF(!string.IsNullOrWhiteSpace(input.SALE), u => u.SALE.Contains(input.SALE)) .WhereIF(!string.IsNullOrWhiteSpace(input.SALE), u => u.SALE.Contains(input.SALE))
@ -1045,7 +1049,7 @@ namespace Myshipping.Application
UserManager.UserId.ToString() == u.ROUTEID || UserManager.Name.ToString() == u.ROUTE || UserManager.UserId.ToString() == u.ROUTEID || UserManager.Name.ToString() == u.ROUTE ||
UserManager.UserId.ToString() == u.LineManageID || UserManager.Name.ToString() == u.LineManage || UserManager.UserId.ToString() == u.LineManageID || UserManager.Name.ToString() == u.LineManage ||
UserManager.UserId.ToString() == u.SALEID || UserManager.Name.ToString() == u.SALE || UserManager.UserId.ToString() == u.SALEID || UserManager.Name.ToString() == u.SALE ||
userlistString.Contains(u.OPID) || UserManager.Name.ToString() == u.OP || userlistString.Contains(u.OPID) || (u.SubOpId.HasValue && userlistString.Contains(u.SubOpId.ToString())) || UserManager.Name.ToString() == u.OP || UserManager.Name.ToString() == u.SubOp ||
userlistString.Contains(u.DOCID) || UserManager.Name.ToString() == u.DOC || userlistString.Contains(u.DOCID) || UserManager.Name.ToString() == u.DOC ||
UserManager.UserId.ToString() == u.CUSTSERVICEID || UserManager.Name.ToString() == u.CUSTSERVICE); UserManager.UserId.ToString() == u.CUSTSERVICEID || UserManager.Name.ToString() == u.CUSTSERVICE);
@ -1817,6 +1821,7 @@ namespace Myshipping.Application
//除现有配置权限外 创建人本人、操作、单证、客服 具有编辑权限 //除现有配置权限外 创建人本人、操作、单证、客服 具有编辑权限
if (rightlist != null && !( if (rightlist != null && !(
mlist.OPID == UserManager.UserId.ToString() || mlist.OP == UserManager.Name.ToString() || mlist.OPID == UserManager.UserId.ToString() || mlist.OP == UserManager.Name.ToString() ||
mlist.SubOpId == UserManager.UserId || mlist.SubOp == UserManager.Name.ToString() ||
mlist.DOCID == UserManager.UserId.ToString() || mlist.DOC == UserManager.Name.ToString() || mlist.DOCID == UserManager.UserId.ToString() || mlist.DOC == UserManager.Name.ToString() ||
mlist.CUSTSERVICEID == UserManager.UserId.ToString() || mlist.CUSTSERVICE == UserManager.Name.ToString() || mlist.CUSTSERVICEID == UserManager.UserId.ToString() || mlist.CUSTSERVICE == UserManager.Name.ToString() ||
UserManager.UserId == 400234750476357 || UserManager.UserId == 400234750476357 ||

@ -9,7 +9,7 @@ namespace Myshipping.Application
/// <summary> /// <summary>
/// 订舱主表输出参数 /// 订舱主表输出参数
/// </summary> /// </summary>
public class BookingOrderDto public class BookingOrderDto
{ {
/// <summary> /// <summary>
/// 主键 /// 主键
@ -718,7 +718,7 @@ namespace Myshipping.Application
public string SourceName { get; set; } public string SourceName { get; set; }
#region 船舶日期相关 #region 船舶日期相关
@ -857,6 +857,21 @@ namespace Myshipping.Application
/// 扩展状态 /// 扩展状态
/// </summary> /// </summary>
public BookingExtendState ExtendState { get; set; } public BookingExtendState ExtendState { get; set; }
/// <summary>
/// 是否为舱位拆票后生成的订舱
/// </summary>
public bool? IsSplit { get; set; }
/// <summary>
/// 分单操作ID
/// </summary>
public long? SubOpId { get; set; }
/// <summary>
/// 分单操作
/// </summary>
public string SubOp { get; set; }
} }
/// <summary> /// <summary>

@ -848,6 +848,16 @@ namespace Myshipping.Application
/// 删除时间截止 /// 删除时间截止
/// </summary> /// </summary>
public DateTime? EDELETETIME { get; set; } public DateTime? EDELETETIME { get; set; }
/// <summary>
/// 分单操作ID
/// </summary>
public long? SubOpId { get; set; }
/// <summary>
/// 分单操作
/// </summary>
public string SubOp { get; set; }
} }
public class BookingOrderInputNew : BookingOrderInput public class BookingOrderInputNew : BookingOrderInput

@ -988,5 +988,17 @@ namespace Myshipping.Application.Service.BookingOrder.Dto
/// </summary> /// </summary>
[Description("删除时间")] [Description("删除时间")]
public DateTime? DeleteTime { get; set; } public DateTime? DeleteTime { get; set; }
/// <summary>
/// 分单操作ID
/// </summary>
[Description("分单操作ID")]
public long? SubOpId { get; set; }
/// <summary>
/// 分单操作
/// </summary>
[Description("分单操作")]
public string SubOp { get; set; }
} }
} }

@ -1099,12 +1099,16 @@ namespace Myshipping.Application
#region 舱位引入 #region 舱位引入
/// <summary> /// <summary>
/// 查询可用的舱位及箱子 /// 分页查询可用的舱位及箱子列表
/// </summary> /// </summary>
/// <param name="input">可选:舱位查询条件</param>
/// <param name="pageInfo">可选:分页信息</param>
[HttpGet("/BookingSlot/getAvailableSlots")] [HttpGet("/BookingSlot/getAvailableSlots")]
public async Task<SqlSugarPagedList<BookingSlotBaseWithCtnDto>> GetAvailableSlots([FromQuery] BookingSlotBaseDto input, [FromQuery] PageWithTotal pageInfo) public async Task<SqlSugarPagedList<BookingSlotBaseWithCtnDto>> GetAvailableSlots([FromQuery] BookingSlotBaseDto input,
[FromQuery] PageWithTotal pageInfo)
{ {
var result = await GetAvailableSlots(input, null, pageInfo); var result = await GetAvailableSlots(input, null, pageInfo);
SqlSugarPagedList<BookingSlotBaseWithCtnDto> pageResult = new() SqlSugarPagedList<BookingSlotBaseWithCtnDto> pageResult = new()
{ {
PageIndex = pageInfo.PageNo, PageIndex = pageInfo.PageNo,
@ -1163,6 +1167,7 @@ namespace Myshipping.Application
// 2. 【已引入舱位表】与【已使用的箱子表】做关联并根据【舱位主键】、【箱型】做分组统计出【已使用的箱量】作为queryable2 // 2. 【已引入舱位表】与【已使用的箱子表】做关联并根据【舱位主键】、【箱型】做分组统计出【已使用的箱量】作为queryable2
var queryable2 = _repBase.Context.Queryable<BookingSlotAllocation, BookingSlotAllocationCtn>((alc, ctn) => alc.Id == ctn.SLOT_ALLOC_ID) var queryable2 = _repBase.Context.Queryable<BookingSlotAllocation, BookingSlotAllocationCtn>((alc, ctn) => alc.Id == ctn.SLOT_ALLOC_ID)
.WhereIF(slotIdListInput.Any(), (alc, ctn) => slotIdListInput.Contains(alc.BOOKING_SLOT_ID))
.GroupBy((alc, ctn) => new .GroupBy((alc, ctn) => new
{ {
alc.BOOKING_SLOT_ID, alc.BOOKING_SLOT_ID,
@ -1225,6 +1230,78 @@ namespace Myshipping.Application
return result; return result;
} }
/// <summary>
/// 查询指定舱位可用的箱子列表
/// </summary>
/// <param name="slotId">舱位主键</param>
/// <returns>可用的箱子列表</returns>
[HttpGet("/BookingSlot/getAvailableCtnsBySlot")]
public async Task<List<BookingSlotCtnDto>> GetAvailableCtnsBySlot(long slotId)
{
if (await _repBase.IsExistsAsync(x => x.Id == slotId && x.IS_CANCELLATION == false) == false)
{
throw Oops.Oh($"获取舱位失败,舱位不存在或已作废");
}
// 1. 【舱位基础表】与【箱子表】做关联并根据【舱位主键】、【箱型】做分组统计出【总的箱量】作为queryable1
var queryable1 = _repBase.Context.Queryable<BookingSlotBase, BookingSlotCtn>((bas, ctn) => bas.Id == ctn.SLOT_ID)
.Where(bas => bas.IS_CANCELLATION == false && bas.Id == slotId)
.GroupBy((bas, ctn) => new
{
bas.Id,
ctn.CTNCODE
})
.Select((bas, ctn) => new
{
id = bas.Id,
ctnCode = ctn.CTNCODE,
numAll = SqlFunc.AggregateSum(ctn.CTNNUM)
})
.MergeTable();
// 2. 【已引入舱位表】与【已使用的箱子表】做关联并根据【舱位主键】、【箱型】做分组统计出【已使用的箱量】作为queryable2
var queryable2 = _repBase.Context.Queryable<BookingSlotAllocation, BookingSlotAllocationCtn>((alc, ctn) => alc.Id == ctn.SLOT_ALLOC_ID)
.Where((alc, ctn) => alc.BOOKING_SLOT_ID == slotId)
.GroupBy((alc, ctn) => new
{
alc.BOOKING_SLOT_ID,
ctn.CTNCODE
})
.Select((alc, ctn) => new
{
id = alc.BOOKING_SLOT_ID,
ctnCode = ctn.CTNCODE,
numUse = SqlFunc.AggregateSum(ctn.CTNNUM)
})
.MergeTable();
// 3. 将queryable1 左连接 queryable2使用【总的箱量】减去【已使用的箱量】得到【剩余的箱量】添加【剩余的箱量】> 0 的条件作为queryable3
var queryable3 = queryable1.LeftJoin(queryable2, (q1, q2) => q1.id == q2.id && q1.ctnCode == q2.ctnCode)
.Select((q1, q2) => new
{
q1.id,
q1.ctnCode,
numResidue = SqlFunc.IsNull(q1.numAll - q2.numUse, q1.numAll)
})
.MergeTable()
.Where(r => r.numResidue > 0);
// 4. 执行ToList(),得到可用的【舱位主键】、【箱型】、【箱量】列表
var canUselist = await queryable3.ToListAsync();
List<Core.Entity.CodeCtn> ctnCodeCache = await _cache.GetAllCodeCtn();
List<BookingSlotCtnDto> result = canUselist.Select(c => new BookingSlotCtnDto()
{
CTNCODE = c.ctnCode,
CTNNUM = c.numResidue,
CTNALL = ctnCodeCache.FirstOrDefault(e => e.Code == c.ctnCode)?.Name ?? throw new Exception($"舱位信息中存在未收录的箱型:{c.ctnCode},需要在箱型字典中补充"),
}).ToList();
return result;
}
/// <summary> /// <summary>
/// 检查指定订舱记录,是否可以引入舱位列表 /// 检查指定订舱记录,是否可以引入舱位列表
/// </summary> /// </summary>
@ -1281,9 +1358,13 @@ namespace Myshipping.Application
/// <param name="slots">待引入的舱位列表</param> /// <param name="slots">待引入的舱位列表</param>
/// <param name="bookingOrderId">待关联的订舱记录</param> /// <param name="bookingOrderId">待关联的订舱记录</param>
/// <param name="isCheck">是否进行剩余量检查</param> /// <param name="isCheck">是否进行剩余量检查</param>
/// <param name="generateModel">额外的用于生成管理记录的信息</param>
/// <returns>isSuccess检查余量及已引用检查是否成功通过message提示信息</returns> /// <returns>isSuccess检查余量及已引用检查是否成功通过message提示信息</returns>
[NonAction] [NonAction]
public async Task<(bool isSuccess, string message)> ImportSlots(List<BookingSlotBaseWithCtnDto> slots, long bookingOrderId, bool isCheck) public async Task<(bool isSuccess, string message)> ImportSlots(List<BookingSlotBaseWithCtnDto> slots,
long bookingOrderId,
bool isCheck,
BookingGenerateDto generateModel = null)
{ {
slots ??= new List<BookingSlotBaseWithCtnDto>(); slots ??= new List<BookingSlotBaseWithCtnDto>();
@ -1304,6 +1385,7 @@ namespace Myshipping.Application
{ {
var latestSlot = latestSlotList.First(b => b.Id == inSlotItem.Id); var latestSlot = latestSlotList.First(b => b.Id == inSlotItem.Id);
// 保存关联信息
var config = new TypeAdapterConfig(); var config = new TypeAdapterConfig();
config.ForType<BookingSlotBase, BookingSlotAllocation>() config.ForType<BookingSlotBase, BookingSlotAllocation>()
.Ignore(dest => dest.CreatedTime) .Ignore(dest => dest.CreatedTime)
@ -1321,8 +1403,24 @@ namespace Myshipping.Application
newSlotAllocation.BOOKING_ID = bookingOrderId; newSlotAllocation.BOOKING_ID = bookingOrderId;
newSlotAllocation.ALLO_BILL_NO = latestSlot.SLOT_BOOKING_NO; newSlotAllocation.ALLO_BILL_NO = latestSlot.SLOT_BOOKING_NO;
newSlotAllocation.FINAL_BILL_NO = latestSlot.SLOT_BOOKING_NO; newSlotAllocation.FINAL_BILL_NO = latestSlot.SLOT_BOOKING_NO;
if (generateModel != null)
{
newSlotAllocation.CUSTOMERID = generateModel.CustomerId;
newSlotAllocation.CUSTOMERNAME = generateModel.CustomerName;
newSlotAllocation.CUSTSERVICEID = generateModel.CustServiceId?.ToString();
newSlotAllocation.CUSTSERVICE = generateModel.CustServiceName;
newSlotAllocation.SALEID = generateModel.SaleId?.ToString();
newSlotAllocation.SALE = generateModel.SaleName;
newSlotAllocation.SALE_TIME = generateModel.SALE_TIME;
newSlotAllocation.SHIPPER = generateModel.SHIPPER;
newSlotAllocation.GOODSNAME = generateModel.GOODSNAME;
newSlotAllocation.SELLING_PRICE = generateModel.SELLING_PRICE;
}
await _repAllocation.InsertAsync(newSlotAllocation); await _repAllocation.InsertAsync(newSlotAllocation);
// 保存关联的箱信息
var insertCtnList = inSlotItem.CtnList.Select(c => new BookingSlotAllocationCtn() var insertCtnList = inSlotItem.CtnList.Select(c => new BookingSlotAllocationCtn()
{ {
SLOT_ALLOC_ID = newSlotAllocation.Id, SLOT_ALLOC_ID = newSlotAllocation.Id,
@ -1332,6 +1430,18 @@ namespace Myshipping.Application
}); });
await _repAllocationCtn.InsertAsync(insertCtnList); await _repAllocationCtn.InsertAsync(insertCtnList);
// 为订舱保存附件信息
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)
{
var file = lastestBcFile.Adapt<BookingFile>();
file.Id = 0;
file.BookingId = bookingOrderId;
await _bookingfile.InsertAsync(file);
}
// 更新库存 // 更新库存
await _publisher.PublishAsync(new ChannelEventSource("BookingSlotStock:Update", new Event.BookingSlotStockUpdateModel await _publisher.PublishAsync(new ChannelEventSource("BookingSlotStock:Update", new Event.BookingSlotStockUpdateModel
{ {
@ -1431,7 +1541,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>>();
@ -1779,19 +1889,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 = "成功";
@ -1806,13 +1916,12 @@ 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)
{ {
long id = 0; long id = 0;
@ -1829,13 +1938,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(),
@ -1862,11 +1974,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));
@ -1882,6 +2016,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);
@ -1891,19 +2035,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)
@ -2034,6 +2167,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;
} }
@ -2116,27 +2250,23 @@ namespace Myshipping.Application
} }
#endregion #endregion
/// <summary> ///// <summary>
/// 校验是否可以生成订舱订单 ///// 校验是否可以生成订舱订单
/// </summary> ///// </summary>
/// <param name="id">舱位主键</param> ///// <param name="id">舱位主键</param>
/// <returns></returns> ///// <returns></returns>
[HttpGet("/BookingSlot/ValidateCreateBookingOrder")] //[HttpGet("/BookingSlot/ValidateCreateBookingOrder")]
public async Task<TaskManageOrderResultDto> ValidateCreateBookingOrder(long id) //public async Task<TaskManageOrderResultDto> ValidateCreateBookingOrder(long id)
{ //{
TaskManageOrderResultDto result = new TaskManageOrderResultDto(); // TaskManageOrderResultDto result = new TaskManageOrderResultDto();
// var slotInfo = await _repBase.AsQueryable().FirstAsync(a => a.Id == id);
var slotInfo = await _repBase.AsQueryable().FirstAsync(a => a.Id == id); // if (slotInfo == null)
// {
if (slotInfo == null) // throw Oops.Oh($"获取舱位失败,舱位不存在或已作废");
{ // }
throw Oops.Oh($"获取舱位失败,舱位不存在或已作废"); // //if(so)
} // return result;
//}
//if(so)
return result;
}
/// <summary> /// <summary>
/// 批量发送邮件提醒(发送客户) /// 批量发送邮件提醒(发送客户)

@ -1,4 +1,5 @@
using System; using Myshipping.Application.Service.BookingSlot.Dto;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -126,5 +127,10 @@ namespace Myshipping.Application
/// 卖价 /// 卖价
/// </summary> /// </summary>
public decimal? SELLING_PRICE { get; set; } public decimal? SELLING_PRICE { get; set; }
/// <summary>
/// 舱位箱信息
/// </summary>
public List<BookingSlotCtnDto> CtnList { get; set; }
} }
} }

@ -22,10 +22,6 @@ namespace Myshipping.Application
Task<TaskManageOrderResultDto> ApiReceive(string jsonData, IFormFile file = null, IFormFile modifyFile = null); Task<TaskManageOrderResultDto> ApiReceive(string jsonData, IFormFile file = null, IFormFile modifyFile = null);
Task<BookingSlotBaseSaveOutput> Detail(long id); Task<BookingSlotBaseSaveOutput> Detail(long id);
/// <summary>
/// 查询可用的舱位及箱子
/// </summary>
Task<SqlSugarPagedList<BookingSlotBaseWithCtnDto>> GetAvailableSlots(BookingSlotBaseDto input, PageWithTotal pageInfo);
/// <summary> /// <summary>
/// 查询可用的舱位及箱子列表 /// 查询可用的舱位及箱子列表
@ -52,8 +48,9 @@ namespace Myshipping.Application
/// <param name="slots">待引入的舱位列表</param> /// <param name="slots">待引入的舱位列表</param>
/// <param name="bookingOrderId">待关联的订舱记录</param> /// <param name="bookingOrderId">待关联的订舱记录</param>
/// <param name="isCheck">是否进行剩余量检查</param> /// <param name="isCheck">是否进行剩余量检查</param>
/// <param name="generateModel">额外的用于生成管理记录的信息</param>
/// <returns>(是否成功,提示消息)</returns> /// <returns>(是否成功,提示消息)</returns>
Task<(bool isSuccess, string message)> ImportSlots(List<BookingSlotBaseWithCtnDto> slots, long bookingOrderId, bool isCheck); Task<(bool isSuccess, string message)> ImportSlots(List<BookingSlotBaseWithCtnDto> slots, long bookingOrderId, bool isCheck, BookingGenerateDto generateModel = null);
Task<dynamic> PageStock(BookingSlotStockPageInput input); Task<dynamic> PageStock(BookingSlotStockPageInput input);
Task RefreshStock(BookingSlotStockUpdateModel input); Task RefreshStock(BookingSlotStockUpdateModel input);
@ -122,12 +119,12 @@ namespace Myshipping.Application
Task<BookingSlotWithOrderDto> SearchBookingSlotWithOrderByNo(string slotBookingNo, long tenantId); Task<BookingSlotWithOrderDto> SearchBookingSlotWithOrderByNo(string slotBookingNo, long tenantId);
/// <summary> ///// <summary>
/// 校验是否可以生成订舱订单 ///// 校验是否可以生成订舱订单
/// </summary> ///// </summary>
/// <param name="id">舱位主键</param> ///// <param name="id">舱位主键</param>
/// <returns>返回回执</returns> ///// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> ValidateCreateBookingOrder(long id); //Task<TaskManageOrderResultDto> ValidateCreateBookingOrder(long id);
/// <summary> /// <summary>
/// 批量发送邮件提醒(发送客户) /// 批量发送邮件提醒(发送客户)

@ -845,6 +845,16 @@ namespace Myshipping.Application.Service.DataSync.Dto
/// 运踪详情 /// 运踪详情
/// </summary> /// </summary>
public List<BookingStatusLogSyncDto> StatusLogs { get; set; } public List<BookingStatusLogSyncDto> StatusLogs { get; set; }
/// <summary>
/// 分单操作ID
/// </summary>
public long? SubOpId { get; set; }
/// <summary>
/// 分单操作
/// </summary>
public string SubOp { get; set; }
} }
@ -1629,6 +1639,16 @@ namespace Myshipping.Application.Service.DataSync.Dto
/// 航线管理ID /// 航线管理ID
/// </summary> /// </summary>
public string LineManageID { get; set; } public string LineManageID { get; set; }
/// <summary>
/// 分单操作ID
/// </summary>
public long? SubOpId { get; set; }
/// <summary>
/// 分单操作
/// </summary>
public string SubOp { get; set; }
} }

@ -595,7 +595,7 @@ namespace Myshipping.Application
/// <summary> /// <summary>
/// 转移任务(将任务指定给其他人) /// 转移任务(将任务指定给其他人)
/// </summary> /// </summary>
/// <param name="taskPKId">BC任务主键</param> /// <param name="taskPKId">BC任务主键,若多条以逗号分隔</param>
/// <param name="userId">用户ID</param> /// <param name="userId">用户ID</param>
/// <returns>返回回执</returns> /// <returns>返回回执</returns>
[HttpGet("/TaskManageBC/TransferTask")] [HttpGet("/TaskManageBC/TransferTask")]
@ -605,16 +605,8 @@ namespace Myshipping.Application
try try
{ {
/* //判断用户信息有效性
1 if (userId < 0)
*/
var bcTaskInfo = await _taskBaseRepository.AsQueryable().FirstAsync(u => u.PK_ID == taskPKId);
if (bcTaskInfo == null)
{
throw Oops.Oh($"任务主键{taskPKId}无法获取业务信息");
}
if(userId < 0)
throw Oops.Oh($"指定用户ID不能为空"); throw Oops.Oh($"指定用户ID不能为空");
var targetUserId = _sysUserRepository.AsQueryable().First(u => u.Id == userId); var targetUserId = _sysUserRepository.AsQueryable().First(u => u.Id == userId);
@ -622,46 +614,56 @@ namespace Myshipping.Application
if (targetUserId == null) if (targetUserId == null)
throw Oops.Oh($"指定用户不存在"); throw Oops.Oh($"指定用户不存在");
string[] strings = taskPKId.Split(',');
if (bcTaskInfo.IS_PUBLIC == 1) foreach (var item in strings)
{ {
bcTaskInfo.IS_PUBLIC = 0; var bcTaskInfo = await _taskBaseRepository.AsQueryable().FirstAsync(u => u.PK_ID == item);
if (bcTaskInfo == null)
{
throw Oops.Oh($"任务主键{item}无法获取业务信息");
}
bcTaskInfo.CreatedUserId = targetUserId.Id; if (bcTaskInfo.IS_PUBLIC == 1)
bcTaskInfo.CreatedUserName = targetUserId.Name; {
bcTaskInfo.IS_PUBLIC = 0;
bcTaskInfo.RealUserId = targetUserId.Id;
bcTaskInfo.RealUserName = targetUserId.Name;
bcTaskInfo.UpdatedTime = DateTime.Now; bcTaskInfo.UpdatedTime = DateTime.Now;
bcTaskInfo.UpdatedUserId = targetUserId.Id; bcTaskInfo.UpdatedUserId = targetUserId.Id;
bcTaskInfo.UpdatedUserName = targetUserId.Name; bcTaskInfo.UpdatedUserName = targetUserId.Name;
await _taskBaseRepository.AsUpdateable(bcTaskInfo).IgnoreColumns(it => new await _taskBaseRepository.AsUpdateable(bcTaskInfo).IgnoreColumns(it => new
{
it.TenantId,
it.CreatedTime,
it.IsDeleted,
it.TASK_NO,
it.TASK_TYPE,
it.TASK_SOURCE
}).ExecuteCommandAsync();
}
else
{ {
it.TenantId, bcTaskInfo.RealUserId = targetUserId.Id;
it.CreatedTime, bcTaskInfo.RealUserName = targetUserId.Name;
it.IsDeleted,
it.TASK_NO,
it.TASK_TYPE,
it.TASK_SOURCE
}).ExecuteCommandAsync();
}
else
{
bcTaskInfo.CreatedUserId = targetUserId.Id;
bcTaskInfo.CreatedUserName = targetUserId.Name;
bcTaskInfo.UpdatedTime = DateTime.Now; bcTaskInfo.UpdatedTime = DateTime.Now;
bcTaskInfo.UpdatedUserId = targetUserId.Id; bcTaskInfo.UpdatedUserId = targetUserId.Id;
bcTaskInfo.UpdatedUserName = targetUserId.Name; bcTaskInfo.UpdatedUserName = targetUserId.Name;
await _taskBaseRepository.AsUpdateable(bcTaskInfo).IgnoreColumns(it => new await _taskBaseRepository.AsUpdateable(bcTaskInfo).IgnoreColumns(it => new
{ {
it.TenantId, it.TenantId,
it.CreatedTime, it.CreatedTime,
it.IsDeleted, it.IsDeleted,
it.TASK_NO, it.TASK_NO,
it.TASK_TYPE, it.TASK_TYPE,
it.TASK_SOURCE it.TASK_SOURCE
}).ExecuteCommandAsync(); }).ExecuteCommandAsync();
}
} }
result.succ = true; result.succ = true;

@ -19836,6 +19836,11 @@
长TAB键的识别替换空格 长TAB键的识别替换空格
</summary> </summary>
</member> </member>
<member name="M:Myshipping.Core.LetterIndexUtil.GetNextLetter(System.Char)">
<summary>
根据当前字母获取它在26个英文字母中的下一个字母
</summary>
</member>
<member name="T:Myshipping.Core.MachineUtil"> <member name="T:Myshipping.Core.MachineUtil">
<summary> <summary>
获取服务器信息 获取服务器信息

@ -0,0 +1,13 @@
namespace Myshipping.Core;
public static class LetterIndexUtil
{
/// <summary>
/// 根据当前字母获取它在26个英文字母中的下一个字母
/// </summary>
public static char GetNextLetter(char currentLetter)
{
if (currentLetter == 'z') return 'a';
if (currentLetter == 'Z') return 'A';
return (char)(currentLetter + 1);
}
}
Loading…
Cancel
Save