From 59a8c5f0c069a73ba006b205c46e8acefa6e6c40 Mon Sep 17 00:00:00 2001 From: wanghaomei <86whm@163.com> Date: Mon, 20 May 2024 15:25:26 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=88=86=E5=8D=95=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Myshipping.Application/Entity/BookingOrder.cs | 10 ++++++++++ .../Service/BookingOrder/BookingOrderService.cs | 13 +++++++++---- .../Service/BookingOrder/Dto/BookingOrderDto.cs | 10 ++++++++++ .../Service/BookingOrder/Dto/BookingOrderInput.cs | 10 ++++++++++ .../Service/BookingOrder/Dto/PageBookingOrder.cs | 12 ++++++++++++ 5 files changed, 51 insertions(+), 4 deletions(-) diff --git a/Myshipping.Application/Entity/BookingOrder.cs b/Myshipping.Application/Entity/BookingOrder.cs index 5d28a31f..33530a55 100644 --- a/Myshipping.Application/Entity/BookingOrder.cs +++ b/Myshipping.Application/Entity/BookingOrder.cs @@ -1052,5 +1052,15 @@ namespace Myshipping.Application.Entity /// 运输条款代码 /// public string SERVICECODE { 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..b32c192f 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderDto.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderDto.cs @@ -857,6 +857,16 @@ namespace Myshipping.Application /// 扩展状态 /// public BookingExtendState ExtendState { 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; } } } From efa2289cac50462fe003d7d8945fa7c199520ee8 Mon Sep 17 00:00:00 2001 From: wanghaomei <86whm@163.com> Date: Mon, 20 May 2024 15:44:38 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=88=86=E5=8D=95=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/DataSync/Dto/BookingOrderDto.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) 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; } } From 30d0d6d7cb51393e1e299eaf4cc8e01584b036ea Mon Sep 17 00:00:00 2001 From: zhangxiaofeng <1939543722@qq.com> Date: Mon, 20 May 2024 16:52:44 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E8=AE=A2=E8=88=B1=E5=BC=95=E5=85=A5?= =?UTF-8?q?=E8=88=B1=E4=BD=8D=E3=80=81=E8=88=B1=E4=BD=8D=E7=94=9F=E6=88=90?= =?UTF-8?q?=E8=AE=A2=E8=88=B1=E7=9B=B8=E5=85=B3=E9=80=BB=E8=BE=91=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/BookingSlot/BookingSlotService.cs | 152 +++++++++++++++--- .../BookingSlot/IBookingSlotService.cs | 19 +-- 2 files changed, 136 insertions(+), 35 deletions(-) diff --git a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs index 32d3d590..98d9d2cc 100644 --- a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs +++ b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs @@ -1092,12 +1092,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, @@ -1156,6 +1160,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, @@ -1218,6 +1223,78 @@ namespace Myshipping.Application return result; } + + /// + /// 查询指定舱位可用的箱子列表 + /// + /// 舱位主键 + /// 可用的箱子列表 + [HttpGet("/BookingSlot/getAvailableCtnsBySlot")] + public async Task> GetAvailableCtnsBySlot(long slotId) + { + if (await _repBase.IsExistsAsync(x => x.Id == slotId) == 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; + } + /// /// 检查指定订舱记录,是否可以引入舱位列表 /// @@ -1274,9 +1351,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(); @@ -1297,6 +1378,7 @@ namespace Myshipping.Application { var latestSlot = latestSlotList.First(b => b.Id == inSlotItem.Id); + // 保存关联信息 var config = new TypeAdapterConfig(); config.ForType() .Ignore(dest => dest.CreatedTime) @@ -1314,8 +1396,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, @@ -1325,6 +1423,16 @@ namespace Myshipping.Application }); await _repAllocationCtn.InsertAsync(insertCtnList); + // 为订舱保存附件信息 + var lastestBcFile = await _bookingfile.Where(x => x.TypeCode == "bc" || x.TypeCode == "bc_notice").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 { @@ -2109,27 +2217,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/IBookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs index b5278c81..64488273 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); /// /// 批量发送邮件提醒(发送客户) From 53b10d3de9b3c7a593c3f0a224e2118ffa6129a4 Mon Sep 17 00:00:00 2001 From: zhangxiaofeng <1939543722@qq.com> Date: Tue, 21 May 2024 13:41:29 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E8=88=B1=E4=BD=8D=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Myshipping.Application/Entity/BookingOrder.cs | 5 ++ .../BookingOrder/Dto/BookingOrderDto.cs | 9 +- .../Service/BookingSlot/BookingSlotService.cs | 90 ++++++++++++------- .../BookingSlot/Dto/BookingGenerateDto.cs | 8 +- Myshipping.Core/Myshipping.Core.xml | 5 ++ Myshipping.Core/Util/LetterIndexUtil.cs | 13 +++ 6 files changed, 95 insertions(+), 35 deletions(-) create mode 100644 Myshipping.Core/Util/LetterIndexUtil.cs diff --git a/Myshipping.Application/Entity/BookingOrder.cs b/Myshipping.Application/Entity/BookingOrder.cs index 5d28a31f..06f4a68f 100644 --- a/Myshipping.Application/Entity/BookingOrder.cs +++ b/Myshipping.Application/Entity/BookingOrder.cs @@ -1052,5 +1052,10 @@ namespace Myshipping.Application.Entity /// 运输条款代码 /// public string SERVICECODE { get; set; } + + /// + /// 是否为舱位拆票后生成的订舱 + /// + public bool? IsSplit { get; set; } } } \ No newline at end of file diff --git a/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderDto.cs index 1c74b850..20a4b2bc 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,11 @@ namespace Myshipping.Application /// 扩展状态 /// public BookingExtendState ExtendState { get; set; } + + /// + /// 是否为舱位拆票后生成的订舱 + /// + public bool? IsSplit { get; set; } } /// diff --git a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs index 98d9d2cc..9151578d 100644 --- a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs +++ b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs @@ -1232,9 +1232,9 @@ namespace Myshipping.Application [HttpGet("/BookingSlot/getAvailableCtnsBySlot")] public async Task> 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 @@ -1424,7 +1424,9 @@ namespace Myshipping.Application 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) { var file = lastestBcFile.Adapt(); @@ -1532,7 +1534,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>(); @@ -1880,19 +1882,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 = "成功"; @@ -1907,13 +1909,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; @@ -1930,13 +1931,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(), @@ -1963,11 +1967,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)); @@ -1983,6 +2009,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); @@ -1992,19 +2028,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) @@ -2135,6 +2160,7 @@ namespace Myshipping.Application catch (Exception ex) { _logger.LogError($"MBLNO:{bookingSlotBase.SLOT_BOOKING_NO} 生成订舱订单异常,原因:{ex.Message}"); + throw; } 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.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 From 8661d34add27e908256b14132e923a75a42a4abf Mon Sep 17 00:00:00 2001 From: douhandong Date: Tue, 21 May 2024 13:50:29 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E8=BD=AC=E7=A7=BB=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=BA=E6=89=B9=E9=87=8F=E8=BD=AC=E7=A7=BB?= =?UTF-8?q?,=E8=B0=83=E6=95=B4=E4=BB=BB=E5=8A=A1=E5=AE=9E=E9=99=85?= =?UTF-8?q?=E6=93=8D=E4=BA=BA=E8=B5=8B=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TaskManagePlat/TaskManageBCService.cs | 86 ++++++++++--------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs index ffce2d1b..999ed553 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs @@ -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.UpdatedTime = DateTime.Now; - bcTaskInfo.UpdatedUserId = targetUserId.Id; - bcTaskInfo.UpdatedUserName = targetUserId.Name; + bcTaskInfo.RealUserId = targetUserId.Id; + bcTaskInfo.RealUserName = targetUserId.Name; - await _taskBaseRepository.AsUpdateable(bcTaskInfo).IgnoreColumns(it => new + 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(); + } + 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; From 9f8a72c2e0ee02b3af2a4fbeffff8127aeb6227b Mon Sep 17 00:00:00 2001 From: douhandong Date: Tue, 21 May 2024 13:52:49 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=A4=87=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/TaskManagePlat/TaskManageBCService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs index 999ed553..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")]