From 2af1ea9d625cedf1d6cb4562957818be7fdcb60a Mon Sep 17 00:00:00 2001 From: zhangxiaofeng <1939543722@qq.com> Date: Mon, 6 May 2024 11:10:48 +0800 Subject: [PATCH 1/3] =?UTF-8?q?Excel=E6=89=93=E5=8D=B0=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AD=97=E6=AE=B5=EF=BC=9A=E5=88=86=E5=8D=95?= =?UTF-8?q?=E6=89=80=E6=9C=89=E5=AD=97=E6=AE=B5=E3=80=81=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E3=80=81=E5=BD=95=E5=85=A5=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingOrderService.cs | 105 ++++++++++++++---- 1 file changed, 83 insertions(+), 22 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index c168ff55..3e8aa8f1 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -4256,25 +4256,25 @@ namespace Myshipping.Application { string value = null; - var fieldType = item.Field.Split('.')[0].ToLower(); - var fieldProperty = item.Field.Split('.')[1]; - if (fieldType == "order") + var destName = item.Field.Split('.')[0].ToLower(); + var fieldName = item.Field.Split('.')[1]; + if (destName == "order" || destName == "suborder") { if (order != null) { - value = typeof(BookingOrder).GetProperty(fieldProperty).GetValue(order)?.ToString(); + value = typeof(BookingOrder).GetProperty(fieldName).GetValue(order)?.ToString(); } } - else if (fieldType == "edi") + else if (destName == "edi") { if (edi != null) { - value = typeof(BookingEDIExt).GetProperty(fieldProperty).GetValue(edi)?.ToString(); + value = typeof(BookingEDIExt).GetProperty(fieldName).GetValue(edi)?.ToString(); } } - else if (fieldType == "userinfo") + else if (destName == "userinfo") { - var propertyLower = fieldProperty.ToLower(); + var propertyLower = fieldName.ToLower(); switch (propertyLower) { case "username": @@ -4291,6 +4291,18 @@ namespace Myshipping.Application value = null; break; }; } + else if (destName == "other") + { + var propertyLower = fieldName.ToLower(); + switch (propertyLower) + { + case "printdate": + value = DateTime.Now.ToString("yyyy-MM-dd"); + break; + default: + value = null; break; + } + } if (!string.IsNullOrWhiteSpace(value)) { foreach (var itemTemp in group) @@ -4320,13 +4332,15 @@ namespace Myshipping.Application { var name = entity.Where(x => x.Row == _row && x.Column == _cellNum).Select(x => x.Field).FirstOrDefault(); - if (name.Split('.')[0].ToLower() == "order") + var destName = name.Split('.')[0].ToLower(); + + if (destName == "order" || destName == "suborder") { foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(order)) { var _name = descriptor.Name.ToLower(); - if (name.Split('.')[0].ToLower() == "order" && name.Split('.')[1].ToLower() == _name) + if (name.Split('.')[1].ToLower() == _name) { var value = descriptor.GetValue(order) != null ? descriptor.GetValue(order).ToString() : ""; ICell cell = row.GetCell(_cellNum - 1); @@ -4344,7 +4358,7 @@ namespace Myshipping.Application } } - if (name.Split('.')[0].ToLower() == "order" && name.Split('.')[1].ToLower() == "_pkgs" && _name == "pkgs") + if (name.Split('.')[1].ToLower() == "_pkgs" && _name == "pkgs") { var value = string.Empty; if (order.PKGS != null) @@ -4371,7 +4385,7 @@ namespace Myshipping.Application } } - if (name.Split('.')[0].ToLower() == "order" && name.Split('.')[1].ToLower() == "_kgs" && _name == "kgs") + if (name.Split('.')[1].ToLower() == "_kgs" && _name == "kgs") { var value = string.Empty; if (order.KGS != null) @@ -4399,7 +4413,7 @@ namespace Myshipping.Application } - if (name.Split('.')[0].ToLower() == "order" && name.Split('.')[1].ToLower() == "_cbm" && _name == "cbm") + if (name.Split('.')[1].ToLower() == "_cbm" && _name == "cbm") { var value = string.Empty; if (order.CBM != null) @@ -4430,7 +4444,7 @@ namespace Myshipping.Application } - if (name.Split('.')[0].ToLower() == "edi") + if (destName == "edi") { foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(edi)) @@ -4458,7 +4472,7 @@ namespace Myshipping.Application } - if (name.Split('.')[0].ToLower() == "userinfo") + if (destName == "userinfo") { ICell cell = row.GetCell(_cellNum - 1); var value = string.Empty; @@ -4491,6 +4505,26 @@ namespace Myshipping.Application row.CreateCell(_cellNum - 1).SetCellValue(value); } } + + if (destName == "other") + { + ICell cell = row.GetCell(_cellNum - 1); + var fieldName = name.Split('.')[1].ToLower(); + var value = fieldName switch + { + "printdate" => DateTime.Now.ToString("yyyy-MM-dd"), + _ => "", + }; + + if (cell != null) + { + row.Cells[_cellNum - 1].SetCellValue(value); + } + else + { + row.CreateCell(_cellNum - 1).SetCellValue(value); + } + } } } } @@ -4504,13 +4538,13 @@ namespace Myshipping.Application if (entity.Where(x => x.Row == _row && x.Column == _cellNum).Count() > 0) { var name = entity.Where(x => x.Row == _row && x.Column == _cellNum).Select(x => x.Field).FirstOrDefault(); - - if (name.Split('.')[0].ToLower() == "order") + var destName = name.Split('.')[0].ToLower(); + if (destName == "order" || destName == "suborder") { foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(order)) { var _name = descriptor.Name.ToLower(); - if (name.Split('.')[1].ToLower() == _name && name.Split('.')[0].ToLower() == "order") + if (name.Split('.')[1].ToLower() == _name) { var value = descriptor.GetValue(order) != null ? descriptor.GetValue(order).ToString() : ""; if (descriptor.PropertyType.FullName.Contains("DateTime")) @@ -4522,7 +4556,7 @@ namespace Myshipping.Application } } - if (name.Split('.')[0].ToLower() == "edi") + if (destName == "edi") { foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(edi)) { @@ -4539,7 +4573,7 @@ namespace Myshipping.Application } } - if (name.Split('.')[0].ToLower() == "userinfo") + if (destName == "userinfo") { var value = string.Empty; @@ -4567,6 +4601,18 @@ namespace Myshipping.Application srow.CreateCell(_cellNum - 1).SetCellValue(value); } + + if (destName == "other") + { + var fieldName = name.Split('.')[1].ToLower(); + var value = fieldName switch + { + "printdate" => DateTime.Now.ToString("yyyy-MM-dd"), + _ => "", + }; + + srow.CreateCell(_cellNum - 1).SetCellValue(value); + } } } } @@ -9680,16 +9726,24 @@ namespace Myshipping.Application BookingCtn ctn = new BookingCtn(); BookingEDIExt edi = new BookingEDIExt(); Dictionary dic = new Dictionary(); + Dictionary dic4 = new Dictionary(); foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(order)) { string name = descriptor.Name; - if (name == "TenantId" || name == "CreatedTime" || name == "UpdatedTime" || name == "CreatedUserId" || name == "CreatedUserName") + if (name == "TenantId" || name == "CreatedTime" || name == "UpdatedTime" || name == "CreatedUserId") { continue; } + if (name == "CreatedUserName") + { + dic.Add("order.CreatedUserName", "录入人"); + dic4.Add("suborder.CreatedUserName", "录入人"); + continue; + } if (!string.IsNullOrWhiteSpace(descriptor.Description)) { dic.Add("order." + descriptor.Name, descriptor.Description); + dic4.Add("suborder." + descriptor.Name, descriptor.Description); } } @@ -9735,12 +9789,19 @@ namespace Myshipping.Application dic3.Add("userinfo.useremail", "当前登录人邮箱"); dic3.Add("userinfo.usertenant", "当前登录人所在公司"); + Dictionary dic5 = new Dictionary() + { + {"other.PrintDate", "打印日期" } + }; + var dynamic = new { order = dic, ctn = dic1, edi = dic2, - userinfo = dic3 + userinfo = dic3, + suborder = dic4, + other = dic5 }; return dynamic; } From eb5030560d40ecc6afa5434b1b4957e042583c61 Mon Sep 17 00:00:00 2001 From: zhangxiaofeng <1939543722@qq.com> Date: Mon, 6 May 2024 14:48:54 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=AE=A2=E8=88=B1=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=88=A0=E9=99=A4=E5=B7=B2=E5=BC=95=E5=85=A5?= =?UTF-8?q?=E7=9A=84=E8=88=B1=E4=BD=8D=E7=9A=84=E5=85=B3=E8=81=94=E5=85=B3?= =?UTF-8?q?=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingOrderService.cs | 79 +++++++++++++------ 1 file changed, 54 insertions(+), 25 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 3e8aa8f1..0608cb35 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -2296,7 +2296,7 @@ namespace Myshipping.Application var tenantParamList = await _cache.GetAllTenantParam(); var isAskDs = tenantParamList.FirstOrDefault(x => x.TenantId == UserManager.TENANT_ID && x.ParaCode == TenantParamCode.ASK_DS_BEFORE_DELETE_BOOKING_ORDER); - + foreach (var ar in arr) { long Id = Convert.ToInt64(ar); @@ -2306,6 +2306,10 @@ namespace Myshipping.Application { continue; } + + // 通过租户参数判断这一票的租户是否启用了舱位引入功能 + var isCancelAllocationSlot = tenantParamList.FirstOrDefault(x => x.TenantId == order.TenantId && x.ParaCode == TenantParamCode.ENABLE_SLOT_ABILITY)?.ItemCode; + var mblno = order.MBLNO; // 将待删除的订舱单id存放到Cache中。目的:使用SendBookingOrder()推送订舱单数据前通过Cache判断是否正在走删除逻辑,来决定是否推送(如果是正在处理删除逻辑的数据,则不推送) @@ -2349,6 +2353,12 @@ namespace Myshipping.Application // 取消订阅运踪 waitUnsubscribeBilltrace.Add(new BillTraceUnsubscribeList(Id.ToString(), mblno)); + if (isCancelAllocationSlot == "YES") + { + // 取消关联舱位 + await CancelAllocationSlot(Id); + } + // 记录日志 var newOrder = order.Adapt(); newOrder.IsDeleted = true; @@ -2379,6 +2389,12 @@ namespace Myshipping.Application // 取消订阅运踪 waitUnsubscribeBilltrace.Add(new BillTraceUnsubscribeList(Id.ToString(), mblno)); + if (isCancelAllocationSlot == "YES") + { + // 取消关联舱位 + await CancelAllocationSlot(Id); + } + // 记录日志 var newOrder = order.Adapt(); newOrder.IsDeleted = true; @@ -11866,10 +11882,22 @@ namespace Myshipping.Application [HttpPost("/BookingOrder/CancelAllocationSlot")] public async Task CancelAllocationSlot(long id) { - var slotList = await _repSlotAllocation.AsQueryable().Where(a => a.BOOKING_ID == id).ToListAsync(); - var slotIdList = slotList.Select(s => s.Id); + var slotList = await _repSlotAllocation.AsQueryable().Where(a => a.BOOKING_ID == id).Select(x => new + { + x.Id, + x.BOOKING_SLOT_TYPE, + x.CARRIERID, + x.CONTRACT_NO, + x.VESSEL, + x.VOYNO, + x.PLACERECEIPT, + x.PLACEDELIVERY + }).ToListAsync(); - await _repSlotAllocation.Context.Updateable() + if (slotList.Count > 0) + { + var slotIdList = slotList.Select(s => s.Id); + await _repSlotAllocation.Context.Updateable() .SetColumns(a => a.IsDeleted == true) .SetColumns(a => a.UpdatedTime == DateTime.Now) .SetColumns(a => a.UpdatedUserId == UserManager.UserId) @@ -11877,27 +11905,28 @@ namespace Myshipping.Application .Where(a => slotIdList.Contains(a.Id)) .ExecuteCommandAsync(); - await _repSlotAllocationCtn.Context.Updateable() - .SetColumns(a => a.IsDeleted == true) - .SetColumns(a => a.UpdatedTime == DateTime.Now) - .SetColumns(a => a.UpdatedUserId == UserManager.UserId) - .SetColumns(a => a.UpdatedUserName == UserManager.Name) - .Where(a => slotIdList.Contains(a.SLOT_ALLOC_ID)) - .ExecuteCommandAsync(); - - // 更新库存 - foreach (var item in slotList) - { - await _publisher.PublishAsync(new ChannelEventSource("BookingSlotStock:Update", new Event.BookingSlotStockUpdateModel - { - BOOKING_SLOT_TYPE = item.BOOKING_SLOT_TYPE, - CARRIERID = item.CARRIERID, - CONTRACT_NO = item.CONTRACT_NO, - VESSEL = item.VESSEL, - VOYNO = item.VOYNO, - PLACERECEIPT = item.PLACERECEIPT, - PLACEDELIVERY = item.PLACEDELIVERY - })); + await _repSlotAllocationCtn.Context.Updateable() + .SetColumns(a => a.IsDeleted == true) + .SetColumns(a => a.UpdatedTime == DateTime.Now) + .SetColumns(a => a.UpdatedUserId == UserManager.UserId) + .SetColumns(a => a.UpdatedUserName == UserManager.Name) + .Where(a => slotIdList.Contains(a.SLOT_ALLOC_ID)) + .ExecuteCommandAsync(); + + // 更新库存 + foreach (var item in slotList) + { + await _publisher.PublishAsync(new ChannelEventSource("BookingSlotStock:Update", new Event.BookingSlotStockUpdateModel + { + BOOKING_SLOT_TYPE = item.BOOKING_SLOT_TYPE, + CARRIERID = item.CARRIERID, + CONTRACT_NO = item.CONTRACT_NO, + VESSEL = item.VESSEL, + VOYNO = item.VOYNO, + PLACERECEIPT = item.PLACERECEIPT, + PLACEDELIVERY = item.PLACEDELIVERY + })); + } } } #endregion From c2dd329be51ba89a2b85c90a2c368f8e97e7bd6a Mon Sep 17 00:00:00 2001 From: wanghaomei <86whm@163.com> Date: Mon, 6 May 2024 15:29:13 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingCustomerOrderService.cs | 31 ++++++++++++++++++- .../Entity/DJY/DjyCustomerParamValue.cs | 7 +++++ Myshipping.Core/Myshipping.Core.xml | 10 ++++++ .../DjyCustomerParamService.cs | 22 +------------ .../Dto/DjyTenantParamValueDto.cs | 5 +++ 5 files changed, 53 insertions(+), 22 deletions(-) diff --git a/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs b/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs index 67cf725e..f1ad06cd 100644 --- a/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs +++ b/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs @@ -61,6 +61,8 @@ namespace Myshipping.Application private readonly SqlSugarRepository _repApiAuth; private readonly SqlSugarRepository _repMessage; private readonly IBookingOrderService bookingOrderService; + private readonly SqlSugarRepository _repCustomer; + private readonly SqlSugarRepository _repCustomerParamValue; public BookingCustomerOrderService(SqlSugarRepository rep, SqlSugarRepository repCtn, ILogger logger, ISysCacheService cache, SqlSugarRepository repFile, @@ -68,7 +70,8 @@ namespace Myshipping.Application SqlSugarRepository repOrder, SqlSugarRepository repStatuslogDetail, SqlSugarRepository repOrderTempl, SqlSugarRepository repEdiExt, SqlSugarRepository goodsStatus, SqlSugarRepository goodsStatusConfig, - IEventPublisher publisher, SqlSugarRepository repApiAuth, SqlSugarRepository repMessage, IBookingOrderService bookingOrderService) + IEventPublisher publisher, SqlSugarRepository repApiAuth, SqlSugarRepository repMessage, IBookingOrderService bookingOrderService, + SqlSugarRepository repCustomer, SqlSugarRepository repCustomerParamValue) { this._logger = logger; this._rep = rep; @@ -87,6 +90,8 @@ namespace Myshipping.Application this._repApiAuth = repApiAuth; this._repMessage = repMessage; this.bookingOrderService = bookingOrderService; + this._repCustomer = repCustomer; + this._repCustomerParamValue = repCustomerParamValue; } #region 订舱草稿及附件 @@ -1582,6 +1587,7 @@ namespace Myshipping.Application var rtnList = new List(); + var ordIdList = new List(); foreach (var item in list) { var strId = item.Id.ToString(); @@ -1618,6 +1624,8 @@ namespace Myshipping.Application await _rep.UpdateAsync(order); } + ordIdList.Add(order.Id); + //箱信息 await _repCtn.DeleteAsync(x => x.BILLID == order.Id); foreach (var ctn in item.CtnList) @@ -1661,6 +1669,27 @@ namespace Myshipping.Application SaveAuditLog($"待审核", order.Id); } + //全部成功后,才能自动订舱和审核 + if (rtnList.Count(x => x.Success == false) == 0) + { + var tCustId = list.First().BookingTenantId; + + //自动订舱和自动审核 + var cust = await _repCustomer.AsQueryable().FirstAsync(x => x.CustSysId == tCustId); + if (cust != null) + { + var paraCallApiAuditAuto = await _repCustomerParamValue.AsQueryable().FirstAsync(x => x.CustomerId == cust.Id && x.ParaCode == "BookingCallApiAndAuditAuto"); + if (paraCallApiAuditAuto != null && paraCallApiAuditAuto.ItemCode == "YES") + { + foreach (var ordId in ordIdList) + { + await PostApiSO(ordId); + await AuditBooking(ordId, true, "系统自动审核"); + } + } + } + } + return rtnList; } diff --git a/Myshipping.Core/Entity/DJY/DjyCustomerParamValue.cs b/Myshipping.Core/Entity/DJY/DjyCustomerParamValue.cs index ba119937..ee884e1c 100644 --- a/Myshipping.Core/Entity/DJY/DjyCustomerParamValue.cs +++ b/Myshipping.Core/Entity/DJY/DjyCustomerParamValue.cs @@ -39,6 +39,13 @@ namespace Myshipping.Core.Entity [Description("客户id")] public long? CustomerId { get; set; } + /// + /// 客户名称 + /// + [SugarColumn(ColumnName = "CustomerName")] + [Description("客户名称")] + public string CustomerName { get; set; } + /// /// 选项代码 /// diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index 3315dfd9..b67b277a 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -2259,6 +2259,11 @@ 客户id + + + 客户名称 + + 选项代码 @@ -11654,6 +11659,11 @@ 客户id + + + 客户名称 + + 选项代码 diff --git a/Myshipping.Core/Service/DjyCustomerParam/DjyCustomerParamService.cs b/Myshipping.Core/Service/DjyCustomerParam/DjyCustomerParamService.cs index 8b05e4b2..11225054 100644 --- a/Myshipping.Core/Service/DjyCustomerParam/DjyCustomerParamService.cs +++ b/Myshipping.Core/Service/DjyCustomerParam/DjyCustomerParamService.cs @@ -80,27 +80,7 @@ namespace Myshipping.Core.Service .OrderBy(x => x.Sort) .ToPagedListAsync(input.PageNo, input.PageSize); - - var rtn = list.Adapt>(); - var listParam = await _repParam.AsQueryable().ToListAsync(); - var listParamItem = await _repParamItem.AsQueryable().ToListAsync(); - var listCustomer = await _repCustomer.AsQueryable().Select(x => new { x.Id, x.ShortName }).ToListAsync(); - foreach (var item in rtn.Items) - { - var p = listParam.FirstOrDefault(x => x.ParaCode == item.ParaCode); - item.ParaName = p.ParaName; - - var t = listCustomer.FirstOrDefault(x => x.Id == item.CustomerId); - item.CustomerName = t.ShortName; - - var it = listParamItem.FirstOrDefault(x => x.ParaCode == item.ParaCode && x.ItemCode == item.ItemCode); - if (it != null) - { - item.ItemCodeName = it.ItemName; - } - } - - return rtn; + return list.Adapt>(); } diff --git a/Myshipping.Core/Service/DjyCustomerParam/Dto/DjyTenantParamValueDto.cs b/Myshipping.Core/Service/DjyCustomerParam/Dto/DjyTenantParamValueDto.cs index c204d654..84a6342b 100644 --- a/Myshipping.Core/Service/DjyCustomerParam/Dto/DjyTenantParamValueDto.cs +++ b/Myshipping.Core/Service/DjyCustomerParam/Dto/DjyTenantParamValueDto.cs @@ -42,6 +42,11 @@ namespace Myshipping.Core.Service /// public long? CustomerId { get; set; } + /// + /// 客户名称 + /// + public string CustomerName { get; set; } + /// /// 选项代码 ///