diff --git a/Myshipping.Application/Entity/BookingOrder.cs b/Myshipping.Application/Entity/BookingOrder.cs
index 5d28a31f..c172e6f6 100644
--- a/Myshipping.Application/Entity/BookingOrder.cs
+++ b/Myshipping.Application/Entity/BookingOrder.cs
@@ -1052,5 +1052,20 @@ namespace Myshipping.Application.Entity
/// 运输条款代码
///
public string SERVICECODE { get; set; }
+
+ ///
+ /// 是否为舱位拆票后生成的订舱
+ ///
+ public bool? IsSplit { get; set; }
+
+ ///
+ /// 分单操作ID
+ ///
+ public long? SubOpId { get; set; }
+
+ ///
+ /// 分单操作
+ ///
+ public string SubOp { get; set; }
}
}
\ No newline at end of file
diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs
index e6be4079..ab89e6f8 100644
--- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs
+++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs
@@ -300,7 +300,7 @@ namespace Myshipping.Application
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 == 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) //台账只查询主单!!
.WhereIF(input.Id != 0, x => x.Id == input.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.PONO), u => u.PONO.Contains(input.PONO))
.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.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.SALEID), u => u.SALEID == input.SALEID)
.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.LineManageID || UserManager.Name.ToString() == u.LineManage ||
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 ||
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)
.WhereIF(!input.ISDel, x => x.IsDeleted == false)
.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) //台账只查询主单!!
.WhereIF(input.Id != 0, x => x.Id == input.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.PONO), u => u.PONO.Contains(input.PONO))
.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.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.SALEID), u => u.SALEID == input.SALEID)
.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.LineManageID || UserManager.Name.ToString() == u.LineManage ||
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 ||
UserManager.UserId.ToString() == u.CUSTSERVICEID || UserManager.Name.ToString() == u.CUSTSERVICE);
@@ -1817,6 +1821,7 @@ namespace Myshipping.Application
//除现有配置权限外 创建人本人、操作、单证、客服 具有编辑权限
if (rightlist != null && !(
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.CUSTSERVICEID == UserManager.UserId.ToString() || mlist.CUSTSERVICE == UserManager.Name.ToString() ||
UserManager.UserId == 400234750476357 ||
diff --git a/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderDto.cs
index 1c74b850..1b2c7fd1 100644
--- a/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderDto.cs
+++ b/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderDto.cs
@@ -9,7 +9,7 @@ namespace Myshipping.Application
///
/// 订舱主表输出参数
///
- public class BookingOrderDto
+ public class BookingOrderDto
{
///
/// 主键
@@ -718,7 +718,7 @@ namespace Myshipping.Application
public string SourceName { get; set; }
-
+
#region 船舶日期相关
@@ -857,6 +857,21 @@ namespace Myshipping.Application
/// 扩展状态
///
public BookingExtendState ExtendState { get; set; }
+
+ ///
+ /// 是否为舱位拆票后生成的订舱
+ ///
+ public bool? IsSplit { get; set; }
+
+ ///
+ /// 分单操作ID
+ ///
+ public long? SubOpId { get; set; }
+
+ ///
+ /// 分单操作
+ ///
+ public string SubOp { get; set; }
}
///
diff --git a/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderInput.cs b/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderInput.cs
index bef28c13..937d5ae6 100644
--- a/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderInput.cs
+++ b/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderInput.cs
@@ -848,6 +848,16 @@ namespace Myshipping.Application
/// 删除时间截止
///
public DateTime? EDELETETIME { get; set; }
+
+ ///
+ /// 分单操作ID
+ ///
+ public long? SubOpId { get; set; }
+
+ ///
+ /// 分单操作
+ ///
+ public string SubOp { get; set; }
}
public class BookingOrderInputNew : BookingOrderInput
diff --git a/Myshipping.Application/Service/BookingOrder/Dto/PageBookingOrder.cs b/Myshipping.Application/Service/BookingOrder/Dto/PageBookingOrder.cs
index 06e49743..49d3abf0 100644
--- a/Myshipping.Application/Service/BookingOrder/Dto/PageBookingOrder.cs
+++ b/Myshipping.Application/Service/BookingOrder/Dto/PageBookingOrder.cs
@@ -988,5 +988,17 @@ namespace Myshipping.Application.Service.BookingOrder.Dto
///
[Description("删除时间")]
public DateTime? DeleteTime { get; set; }
+
+ ///
+ /// 分单操作ID
+ ///
+ [Description("分单操作ID")]
+ public long? SubOpId { get; set; }
+
+ ///
+ /// 分单操作
+ ///
+ [Description("分单操作")]
+ public string SubOp { get; set; }
}
}
diff --git a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs
index 821d2a71..2799deaf 100644
--- a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs
+++ b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs
@@ -1099,12 +1099,16 @@ namespace Myshipping.Application
#region 舱位引入
///
- /// 查询可用的舱位及箱子
+ /// 分页查询可用的舱位及箱子列表
///
+ /// 可选:舱位查询条件
+ /// 可选:分页信息
[HttpGet("/BookingSlot/getAvailableSlots")]
- public async Task> GetAvailableSlots([FromQuery] BookingSlotBaseDto input, [FromQuery] PageWithTotal pageInfo)
+ public async Task> GetAvailableSlots([FromQuery] BookingSlotBaseDto input,
+ [FromQuery] PageWithTotal pageInfo)
{
var result = await GetAvailableSlots(input, null, pageInfo);
+
SqlSugarPagedList pageResult = new()
{
PageIndex = pageInfo.PageNo,
@@ -1163,6 +1167,7 @@ namespace Myshipping.Application
// 2. 【已引入舱位表】与【已使用的箱子表】做关联,并根据【舱位主键】、【箱型】做分组,统计出【已使用的箱量】,作为queryable2
var queryable2 = _repBase.Context.Queryable((alc, ctn) => alc.Id == ctn.SLOT_ALLOC_ID)
+ .WhereIF(slotIdListInput.Any(), (alc, ctn) => slotIdListInput.Contains(alc.BOOKING_SLOT_ID))
.GroupBy((alc, ctn) => new
{
alc.BOOKING_SLOT_ID,
@@ -1225,6 +1230,78 @@ namespace Myshipping.Application
return result;
}
+
+ ///
+ /// 查询指定舱位可用的箱子列表
+ ///
+ /// 舱位主键
+ /// 可用的箱子列表
+ [HttpGet("/BookingSlot/getAvailableCtnsBySlot")]
+ public async Task> 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((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((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 ctnCodeCache = await _cache.GetAllCodeCtn();
+
+ List 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;
+ }
+
///
/// 检查指定订舱记录,是否可以引入舱位列表
///
@@ -1281,9 +1358,13 @@ namespace Myshipping.Application
/// 待引入的舱位列表
/// 待关联的订舱记录
/// 是否进行剩余量检查
+ /// 额外的用于生成管理记录的信息
/// isSuccess:检查(余量及已引用检查)是否成功通过,message:提示信息
[NonAction]
- public async Task<(bool isSuccess, string message)> ImportSlots(List slots, long bookingOrderId, bool isCheck)
+ public async Task<(bool isSuccess, string message)> ImportSlots(List slots,
+ long bookingOrderId,
+ bool isCheck,
+ BookingGenerateDto generateModel = null)
{
slots ??= new List();
@@ -1304,6 +1385,7 @@ namespace Myshipping.Application
{
var latestSlot = latestSlotList.First(b => b.Id == inSlotItem.Id);
+ // 保存关联信息
var config = new TypeAdapterConfig();
config.ForType()
.Ignore(dest => dest.CreatedTime)
@@ -1321,8 +1403,24 @@ namespace Myshipping.Application
newSlotAllocation.BOOKING_ID = bookingOrderId;
newSlotAllocation.ALLO_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);
+ // 保存关联的箱信息
var insertCtnList = inSlotItem.CtnList.Select(c => new BookingSlotAllocationCtn()
{
SLOT_ALLOC_ID = newSlotAllocation.Id,
@@ -1332,6 +1430,18 @@ namespace Myshipping.Application
});
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();
+ file.Id = 0;
+ file.BookingId = bookingOrderId;
+ await _bookingfile.InsertAsync(file);
+ }
+
// 更新库存
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 entities = await select.OrderByDescending(u => u.CreatedTime)
+ var entities = await select.OrderByDescending(u => u.Id)
.ToPagedListAsync(input.PageNo, input.PageSize);
var result = entities.Adapt>();
@@ -1779,19 +1889,19 @@ namespace Myshipping.Application
throw Oops.Oh($"舱位信息不存在或已作废");
// 判断是否已存在引用关系
- if (_repAllocation.IsExists(a => a.BOOKING_SLOT_ID == slotInfo.Id
- && a.BOOKING_ID > 0 && a.IsDeleted == false))
- {
- throw Oops.Oh($"舱位已有对应的订舱订单,不能重复执行");
- }
+ //if (_repAllocation.IsExists(a => a.BOOKING_SLOT_ID == slotInfo.Id
+ // && a.BOOKING_ID > 0 && a.IsDeleted == false))
+ //{
+ // throw Oops.Oh($"舱位已有对应的订舱订单,不能重复执行");
+ //}
- var ctnList = _repCtn.AsQueryable().Where(a => a.SLOT_ID == slotInfo.Id && a.IsDeleted == false)
- .ToList();
+ //var ctnList = _repCtn.AsQueryable().Where(a => a.SLOT_ID == slotInfo.Id && a.IsDeleted == false)
+ // .ToList();
var fileList = await _bookingfile.AsQueryable().Filter(null, true)
.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.msg = "成功";
@@ -1806,13 +1916,12 @@ namespace Myshipping.Application
/// 生成订舱
///
/// 舱位详情
- /// 舱位集装箱列表
/// 舱位附件列表
/// 订舱请求详情
/// 返回订舱ID
- private async Task GenerateBookingOrder(BookingSlotBase bookingSlotBase, List bookingSlotCtnList,
- List bookingSlotFileList,
- BookingGenerateDto generateModel)
+ private async Task GenerateBookingOrder(BookingSlotBase bookingSlotBase,
+ List bookingSlotFileList,
+ BookingGenerateDto generateModel)
{
long id = 0;
@@ -1829,13 +1938,16 @@ namespace Myshipping.Application
|| t.EnName.Equals(bookingSlotBase.CARRIERID, StringComparison.OrdinalIgnoreCase)
|| t.CnName.Equals(bookingSlotBase.CARRIERID, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
+ var custNo = bookingSlotBase.SLOT_BOOKING_NO.Trim();
+
SaveBookingOrderInput bkModel = new SaveBookingOrderInput
{
CUSTOMERID = generateModel.CustomerId,
CUSTOMERNAME = generateModel.CustomerName,
CARRIERID = carrierInfo.Code?.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 : "",
VESSEL = bookingSlotBase.VESSEL.ToUpper().Trim(),
VOYNO = bookingSlotBase.VOYNO.ToUpper().Trim(),
@@ -1862,11 +1974,33 @@ namespace Myshipping.Application
ctnInputs = new List()
};
+ // 判断是否为拆票的舱位,如果为拆票,提单号需要加上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();
- 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) &&
a.Name.Equals(t.CTNALL, StringComparison.OrdinalIgnoreCase));
@@ -1882,6 +2016,16 @@ namespace Myshipping.Application
});
}
+ // 验证舱位是否可用
+ var slotInfo = bookingSlotBase.Adapt();
+ slotInfo.CtnList = generateModel.CtnList;
+ var importSlots = new List() { slotInfo };
+ var checkResult = await CheckImportSlots(importSlots, 0);
+ if (!checkResult.isEnough)
+ {
+ throw Oops.Oh(checkResult.message);
+ }
+
var bookingOrderService = _namedBookingOrderServiceProvider.GetService(nameof(BookingOrderService));
var bkRlt = await bookingOrderService.Save(bkModel);
@@ -1891,19 +2035,8 @@ namespace Myshipping.Application
if (id > 0)
{
- List slots = new List();
-
- //检索舱位信息
- var slotInfo = Detail(bookingSlotBase.Id).GetAwaiter().GetResult();
-
- BookingSlotBaseWithCtnDto baseInfo = slotInfo.Adapt();
- baseInfo.Id = bookingSlotBase.Id;
- baseInfo.CtnList = slotInfo.CtnList.Adapt>();
-
- slots.Add(baseInfo);
-
- //对应订舱和舱位关系
- var allocRlt = await ImportSlots(slots, id, false);
+ ////对应订舱和舱位关系
+ var allocRlt = await ImportSlots(importSlots, id, false, generateModel);
//这里如果指定了委托单位的邮件联系人,则推送订舱联系人
if (generateModel.CustomerContactList != null && generateModel.CustomerContactList.Count > 0)
@@ -2034,6 +2167,7 @@ namespace Myshipping.Application
catch (Exception ex)
{
_logger.LogError($"MBLNO:{bookingSlotBase.SLOT_BOOKING_NO} 生成订舱订单异常,原因:{ex.Message}");
+ throw;
}
@@ -2116,27 +2250,23 @@ namespace Myshipping.Application
}
#endregion
- ///
- /// 校验是否可以生成订舱订单
- ///
- /// 舱位主键
- ///
- [HttpGet("/BookingSlot/ValidateCreateBookingOrder")]
- public async Task ValidateCreateBookingOrder(long id)
- {
- TaskManageOrderResultDto result = new TaskManageOrderResultDto();
-
- var slotInfo = await _repBase.AsQueryable().FirstAsync(a => a.Id == id);
-
- if (slotInfo == null)
- {
- throw Oops.Oh($"获取舱位失败,舱位不存在或已作废");
- }
-
- //if(so)
-
- return result;
- }
+ /////
+ ///// 校验是否可以生成订舱订单
+ /////
+ ///// 舱位主键
+ /////
+ //[HttpGet("/BookingSlot/ValidateCreateBookingOrder")]
+ //public async Task ValidateCreateBookingOrder(long id)
+ //{
+ // TaskManageOrderResultDto result = new TaskManageOrderResultDto();
+ // var slotInfo = await _repBase.AsQueryable().FirstAsync(a => a.Id == id);
+ // if (slotInfo == null)
+ // {
+ // throw Oops.Oh($"获取舱位失败,舱位不存在或已作废");
+ // }
+ // //if(so)
+ // return result;
+ //}
///
/// 批量发送邮件提醒(发送客户)
diff --git a/Myshipping.Application/Service/BookingSlot/Dto/BookingGenerateDto.cs b/Myshipping.Application/Service/BookingSlot/Dto/BookingGenerateDto.cs
index 6dd3f4f1..02e12ef8 100644
--- a/Myshipping.Application/Service/BookingSlot/Dto/BookingGenerateDto.cs
+++ b/Myshipping.Application/Service/BookingSlot/Dto/BookingGenerateDto.cs
@@ -1,4 +1,5 @@
-using System;
+using Myshipping.Application.Service.BookingSlot.Dto;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -126,5 +127,10 @@ namespace Myshipping.Application
/// 卖价
///
public decimal? SELLING_PRICE { get; set; }
+
+ ///
+ /// 舱位箱信息
+ ///
+ public List CtnList { get; set; }
}
}
diff --git a/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs
index 902d179d..fcb48617 100644
--- a/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs
+++ b/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs
@@ -22,10 +22,6 @@ namespace Myshipping.Application
Task ApiReceive(string jsonData, IFormFile file = null, IFormFile modifyFile = null);
Task Detail(long id);
- ///
- /// 查询可用的舱位及箱子
- ///
- Task> GetAvailableSlots(BookingSlotBaseDto input, PageWithTotal pageInfo);
///
/// 查询可用的舱位及箱子列表
@@ -52,8 +48,9 @@ namespace Myshipping.Application
/// 待引入的舱位列表
/// 待关联的订舱记录
/// 是否进行剩余量检查
+ /// 额外的用于生成管理记录的信息
/// (是否成功,提示消息)
- Task<(bool isSuccess, string message)> ImportSlots(List slots, long bookingOrderId, bool isCheck);
+ Task<(bool isSuccess, string message)> ImportSlots(List slots, long bookingOrderId, bool isCheck, BookingGenerateDto generateModel = null);
Task PageStock(BookingSlotStockPageInput input);
Task RefreshStock(BookingSlotStockUpdateModel input);
@@ -122,12 +119,12 @@ namespace Myshipping.Application
Task SearchBookingSlotWithOrderByNo(string slotBookingNo, long tenantId);
- ///
- /// 校验是否可以生成订舱订单
- ///
- /// 舱位主键
- /// 返回回执
- Task ValidateCreateBookingOrder(long id);
+ /////
+ ///// 校验是否可以生成订舱订单
+ /////
+ ///// 舱位主键
+ ///// 返回回执
+ //Task ValidateCreateBookingOrder(long id);
///
/// 批量发送邮件提醒(发送客户)
diff --git a/Myshipping.Application/Service/DataSync/Dto/BookingOrderDto.cs b/Myshipping.Application/Service/DataSync/Dto/BookingOrderDto.cs
index 31fcb4fb..689c130b 100644
--- a/Myshipping.Application/Service/DataSync/Dto/BookingOrderDto.cs
+++ b/Myshipping.Application/Service/DataSync/Dto/BookingOrderDto.cs
@@ -845,6 +845,16 @@ namespace Myshipping.Application.Service.DataSync.Dto
/// 运踪详情
///
public List StatusLogs { get; set; }
+
+ ///
+ /// 分单操作ID
+ ///
+ public long? SubOpId { get; set; }
+
+ ///
+ /// 分单操作
+ ///
+ public string SubOp { get; set; }
}
@@ -1629,6 +1639,16 @@ namespace Myshipping.Application.Service.DataSync.Dto
/// 航线管理ID
///
public string LineManageID { get; set; }
+
+ ///
+ /// 分单操作ID
+ ///
+ public long? SubOpId { get; set; }
+
+ ///
+ /// 分单操作
+ ///
+ public string SubOp { get; set; }
}
diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs
index ffce2d1b..4868f792 100644
--- a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs
+++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs
@@ -595,7 +595,7 @@ namespace Myshipping.Application
///
/// 转移任务(将任务指定给其他人)
///
- /// BC任务主键
+ /// BC任务主键,若多条以逗号分隔
/// 用户ID
/// 返回回执
[HttpGet("/TaskManageBC/TransferTask")]
@@ -605,16 +605,8 @@ namespace Myshipping.Application
try
{
- /*
- 1、如果当前任务是公共任务,则更新为相关人后,变更任务为个人。
- */
- var bcTaskInfo = await _taskBaseRepository.AsQueryable().FirstAsync(u => u.PK_ID == taskPKId);
- if (bcTaskInfo == null)
- {
- throw Oops.Oh($"任务主键{taskPKId}无法获取业务信息");
- }
-
- if(userId < 0)
+ //判断用户信息有效性
+ if (userId < 0)
throw Oops.Oh($"指定用户ID不能为空");
var targetUserId = _sysUserRepository.AsQueryable().First(u => u.Id == userId);
@@ -622,46 +614,56 @@ namespace Myshipping.Application
if (targetUserId == null)
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;
- bcTaskInfo.CreatedUserName = targetUserId.Name;
+ if (bcTaskInfo.IS_PUBLIC == 1)
+ {
+ bcTaskInfo.IS_PUBLIC = 0;
+
+ bcTaskInfo.RealUserId = targetUserId.Id;
+ bcTaskInfo.RealUserName = targetUserId.Name;
- bcTaskInfo.UpdatedTime = DateTime.Now;
- bcTaskInfo.UpdatedUserId = targetUserId.Id;
- bcTaskInfo.UpdatedUserName = targetUserId.Name;
+ bcTaskInfo.UpdatedTime = DateTime.Now;
+ bcTaskInfo.UpdatedUserId = targetUserId.Id;
+ 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,
- it.CreatedTime,
- it.IsDeleted,
- it.TASK_NO,
- it.TASK_TYPE,
- it.TASK_SOURCE
- }).ExecuteCommandAsync();
- }
- else
- {
- bcTaskInfo.CreatedUserId = targetUserId.Id;
- bcTaskInfo.CreatedUserName = targetUserId.Name;
+ bcTaskInfo.RealUserId = targetUserId.Id;
+ bcTaskInfo.RealUserName = targetUserId.Name;
- bcTaskInfo.UpdatedTime = DateTime.Now;
- bcTaskInfo.UpdatedUserId = targetUserId.Id;
- bcTaskInfo.UpdatedUserName = targetUserId.Name;
+ bcTaskInfo.UpdatedTime = DateTime.Now;
+ bcTaskInfo.UpdatedUserId = targetUserId.Id;
+ bcTaskInfo.UpdatedUserName = targetUserId.Name;
- await _taskBaseRepository.AsUpdateable(bcTaskInfo).IgnoreColumns(it => new
- {
- it.TenantId,
- it.CreatedTime,
- it.IsDeleted,
- it.TASK_NO,
- it.TASK_TYPE,
- it.TASK_SOURCE
- }).ExecuteCommandAsync();
+ await _taskBaseRepository.AsUpdateable(bcTaskInfo).IgnoreColumns(it => new
+ {
+ it.TenantId,
+ it.CreatedTime,
+ it.IsDeleted,
+ it.TASK_NO,
+ it.TASK_TYPE,
+ it.TASK_SOURCE
+ }).ExecuteCommandAsync();
+ }
}
result.succ = true;
diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml
index 66cf7389..3c491d6a 100644
--- a/Myshipping.Core/Myshipping.Core.xml
+++ b/Myshipping.Core/Myshipping.Core.xml
@@ -19836,6 +19836,11 @@
长TAB键的识别替换空格
+
+
+ 根据当前字母获取它在26个英文字母中的下一个字母
+
+
获取服务器信息
diff --git a/Myshipping.Core/Util/LetterIndexUtil.cs b/Myshipping.Core/Util/LetterIndexUtil.cs
new file mode 100644
index 00000000..65642e32
--- /dev/null
+++ b/Myshipping.Core/Util/LetterIndexUtil.cs
@@ -0,0 +1,13 @@
+namespace Myshipping.Core;
+public static class LetterIndexUtil
+{
+ ///
+ /// 根据当前字母获取它在26个英文字母中的下一个字母
+ ///
+ public static char GetNextLetter(char currentLetter)
+ {
+ if (currentLetter == 'z') return 'a';
+ if (currentLetter == 'Z') return 'A';
+ return (char)(currentLetter + 1);
+ }
+}
\ No newline at end of file