From c0ef9090e87dacd60e1724ba64375d5f752372f0 Mon Sep 17 00:00:00 2001 From: zhangxiaofeng <1939543722@qq.com> Date: Thu, 23 May 2024 15:49:17 +0800 Subject: [PATCH] =?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 --- .../BookingOrder/BookingOrderService.cs | 27 ++++++++++++++----- .../Service/BookingSlot/BookingSlotService.cs | 9 ++++++- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 0cb64577..dc571424 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -2038,15 +2038,30 @@ namespace Myshipping.Application _logger.LogWarning($"保存请求[{reqId}],{(input.Id == 0 ? "新增" : "更新")}数据完成"); } + + var Id = entity.Id; + BookingOrderOutput ordOut = new BookingOrderOutput(); + var main = await _rep.AsQueryable().Filter(null, true).FirstAsync(u => u.Id == Id); + + // 【引入舱位】:保存引用信息 if (input.Slots?.Any() == true) { - await bookingSlotService.ImportSlots(input.Slots, entity.Id, false); + var generateDto = new BookingGenerateDto() + { + CustomerId = main.CUSTOMERID, + CustomerName = main.CUSTOMERNAME, + //CustServiceId = main.CUSTSERVICEID, + CustServiceName = main.CUSTSERVICE, + //SaleId = main.SALEID, + SaleName = main.SALE, + GOODSNAME = main.GOODSNAME, + }; + if (long.TryParse(main.CUSTSERVICEID, out long t1)) generateDto.CustServiceId = t1; + if (long.TryParse(main.SALEID, out long t2)) generateDto.SaleId = t2; + await bookingSlotService.ImportSlots(input.Slots, entity.Id, false, generateDto); } - var Id = entity.Id; - BookingOrderOutput ordOut = new BookingOrderOutput(); - var main = await _rep.AsQueryable().Filter(null, true).FirstAsync(u => u.Id == Id); if (!string.IsNullOrEmpty(entity.MBLNO) || !string.IsNullOrEmpty(entity.CUSTNO)) { @@ -12772,7 +12787,7 @@ namespace Myshipping.Application throw Oops.Bah("请求参数不能为空"); } - if(dto.Id.Count == 0) + if (dto.Id.Count == 0) throw Oops.Bah("未选中需要更新的订舱数据,请重新选择"); string version = Guid.NewGuid().ToString(); @@ -12780,7 +12795,7 @@ namespace Myshipping.Application // 记录日志 var oldOrderList = await _rep.AsQueryable().Filter(null, true).Where(x => dto.Id.Contains(x.Id) && x.IsDeleted == false).ToListAsync(); - if(dto.Id.Count != oldOrderList.Count) + if (dto.Id.Count != oldOrderList.Count) throw Oops.Bah("订舱数据获取失败,部分订舱数据未获取到,订舱数据为空或已作废"); //oldOrderList.ForEach() diff --git a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs index dd82cfc0..2513133e 100644 --- a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs +++ b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs @@ -2732,11 +2732,13 @@ namespace Myshipping.Application // 判断是否为拆票的舱位,如果为拆票,提单号需要加上ABCD... var selectNum = generateModel.CtnList.Sum(x => x.CTNNUM); + _logger.LogInformation("根据舱位生成订舱,selectNum:{selectNum}", selectNum); var allNum = await _repCtn.AsQueryable().Where(x => x.SLOT_ID == generateModel.SlotId).SumAsync(x => x.CTNNUM); + _logger.LogInformation("根据舱位生成订舱,allNum:{allNum}", allNum); bkModel.IsSplit = selectNum != allNum; if (bkModel.IsSplit) { - var sql = _repBookingOrder.AsQueryable().Where(" MBLNO like @mblno ", new { mblno = custNo + '_' }).OrderByDescending(x => x.Id).Select(x => x.MBLNO).ToSqlString(); + //var sql = _repBookingOrder.AsQueryable().Where(" MBLNO like @mblno ", new { mblno = custNo + '_' }).OrderByDescending(x => x.Id).Select(x => x.MBLNO).ToSqlString(); var currentMblno = await _repBookingOrder.AsQueryable().Where(" MBLNO like @mblno ", new { mblno = custNo + '_' }) .OrderByDescending(x => x.Id) .Select(x => x.MBLNO) @@ -2752,6 +2754,7 @@ namespace Myshipping.Application bkModel.MBLNO = newMblno; } } + _logger.LogInformation("根据舱位生成订舱,得到MBLNO:{MBLNO}", bkModel.MBLNO); var ctnCodeList = _cache.GetAllCodeCtn().GetAwaiter().GetResult().ToList(); @@ -2784,7 +2787,10 @@ namespace Myshipping.Application } var bookingOrderService = _namedBookingOrderServiceProvider.GetService(nameof(BookingOrderService)); + + _logger.LogInformation("根据舱位生成订舱,开始调用Save保存订舱"); var bkRlt = await bookingOrderService.Save(bkModel); + _logger.LogInformation("根据舱位生成订舱,调用Save保存订舱完成,id:{id}", bkRlt.Id); id = bkRlt.Id; @@ -2794,6 +2800,7 @@ namespace Myshipping.Application { ////对应订舱和舱位关系 var allocRlt = await ImportSlots(importSlots, id, false, generateModel); + _logger.LogInformation("根据舱位生成订舱,引入订舱关系完成"); //这里如果指定了委托单位的邮件联系人,则推送订舱联系人 if (generateModel.CustomerContactList != null && generateModel.CustomerContactList.Count > 0)