diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 0cb64577..97c61b20 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)) { @@ -10728,6 +10743,7 @@ namespace Myshipping.Application extModel.TxxpEndTime = date; await _repextendstate.InsertAsync(extModel); } + await SendBookingOrder(new long[] { bookId }); } #endregion @@ -12772,7 +12788,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 +12796,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 4ed4ace7..31ee45d5 100644 --- a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs +++ b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs @@ -619,16 +619,22 @@ namespace Myshipping.Application var portEnName = dto.DataObj.PLACERECEIPT.Split(',')[0]?.Trim(); if (!string.IsNullOrWhiteSpace(portEnName)) { - var portInfo = (await _cache.GetAllCodePortLoad()).FirstOrDefault(x => x.EnName.Equals(portEnName, StringComparison.OrdinalIgnoreCase)); - if (portInfo != null) + var cachePort = await _cache.GetAllCodePort(); + + var portInfo = cachePort.FirstOrDefault(x => x.EnName.StartsWith(portEnName, StringComparison.OrdinalIgnoreCase)); + if (portInfo == null) { - dto.DataObj.PORTLOAD = portInfo.EnName; - dto.DataObj.PORTLOADID = portInfo.EdiCode; + portInfo = cachePort.FirstOrDefault(x => x.EnName.Contains(portEnName, StringComparison.OrdinalIgnoreCase)); } - else + if (portInfo == null) { _logger.LogInformation("通过收货地城市名称未匹配到港口信息,订舱编号:{SLOT_BOOKING_NO}", dto.DataObj.SLOT_BOOKING_NO); } + else + { + dto.DataObj.PORTLOAD = portInfo.EnName; + dto.DataObj.PORTLOADID = portInfo.EdiCode; + } } else { @@ -646,10 +652,10 @@ namespace Myshipping.Application if (!string.IsNullOrWhiteSpace(portEnName)) { var cachePort = await _cache.GetAllCodePort(); - var portInfo = cachePort.FirstOrDefault(x => x.EnName.StartsWith(portEnName + ',')); + var portInfo = cachePort.FirstOrDefault(x => x.EnName.StartsWith(portEnName + ',', StringComparison.OrdinalIgnoreCase)); if (portInfo == null) { - portInfo = cachePort.FirstOrDefault(x => x.EnName.Contains(portEnName)); + portInfo = cachePort.FirstOrDefault(x => x.EnName.Contains(portEnName, StringComparison.OrdinalIgnoreCase)); } if (portInfo == null) @@ -1084,7 +1090,7 @@ namespace Myshipping.Application [HttpPost("/BookingSlot/refreshAllStock")] public async Task RefreshAllStock([FromBody] long telentId) { - await _repBase.DeleteAsync(x => x.TenantId == UserManager.TENANT_ID); + await _repStock.DeleteAsync(x => x.TenantId == telentId); var logger = App.GetService>(); BookingSlotStockSubscriber subscriber = new BookingSlotStockSubscriber(logger); @@ -2641,6 +2647,16 @@ namespace Myshipping.Application { TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + if (model.CustomerId == null || string.IsNullOrWhiteSpace(model.CustomerName)) + { + throw Oops.Oh($"请选择委托单位"); + } + + if (model.CtnList == null || !model.CtnList.Any()) + { + throw Oops.Oh($"请选择要使用的箱信息"); + } + if (!model.SlotId.HasValue || model.SlotId.Value < 1) throw Oops.Oh($"舱位ID不能为空"); @@ -2706,43 +2722,56 @@ namespace Myshipping.Application { CUSTOMERID = generateModel.CustomerId, CUSTOMERNAME = generateModel.CustomerName, - CARRIERID = carrierInfo.Code?.Trim(), - CARRIER = carrierInfo.CnName?.Trim(), + CARRIERID = carrierInfo?.Code?.Trim(), + CARRIER = carrierInfo?.CnName?.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(), - VOYNOINNER = bookingSlotBase.VOYNO.ToUpper().Trim(), + VESSEL = bookingSlotBase.VESSEL?.ToUpper()?.Trim(), + VOYNO = bookingSlotBase.VOYNO?.ToUpper()?.Trim(), + VOYNOINNER = bookingSlotBase.VOYNO?.ToUpper()?.Trim(), ETD = bookingSlotBase.ETD, ETA = bookingSlotBase.ETA, - SALEID = generateModel.SaleId.ToString(), + SALEID = generateModel.SaleId?.ToString(), SALE = generateModel.SaleName, - OPID = generateModel.OpId.ToString(), + OPID = generateModel.OpId?.ToString(), OP = generateModel.OpName, - DOCID = generateModel.DocId.ToString(), + DOCID = generateModel.DocId?.ToString(), DOC = generateModel.DocName, - ROUTEID = generateModel.RouteID.ToString(), + ROUTEID = generateModel.RouteID?.ToString(), ROUTE = generateModel.Route, CZRemark = generateModel.CZRemark, ShenQingXiangShi = generateModel.ShenQingXiangShi, - LineManageID = generateModel.LineManageID.ToString(), + LineManageID = generateModel.LineManageID?.ToString(), LineName = generateModel.LineManage, CLOSEVGMDATE = bookingSlotBase.VGM_SUBMISSION_CUT_DATE, CLOSINGDATE = bookingSlotBase.CY_CUT_DATE, CLOSEDOCDATE = bookingSlotBase.SI_CUT_DATE, - CUSTSERVICEID = generateModel.CustServiceId.HasValue ? generateModel.CustServiceId.Value.ToString() : null, + CUSTSERVICEID = generateModel.CustServiceId?.ToString(), CUSTSERVICE = generateModel.CustServiceName, + + PORTLOAD = bookingSlotBase.PORTLOAD, + PORTLOADID = bookingSlotBase.PORTLOADID, + PORTDISCHARGE = bookingSlotBase.PORTDISCHARGE, + PORTDISCHARGEID = bookingSlotBase.PORTDISCHARGEID, + + PLACEDELIVERY = bookingSlotBase.PLACEDELIVERY, + PLACEDELIVERYID = bookingSlotBase.PLACEDELIVERYID, + PLACERECEIPT = bookingSlotBase.PLACERECEIPT, + PLACERECEIPTID = bookingSlotBase.PLACERECEIPTID, + ctnInputs = new List() }; // 判断是否为拆票的舱位,如果为拆票,提单号需要加上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) @@ -2758,6 +2787,11 @@ namespace Myshipping.Application bkModel.MBLNO = newMblno; } } + else + { + bkModel.MBLNO = bookingSlotBase.SLOT_BOOKING_NO.Trim(); + } + _logger.LogInformation("根据舱位生成订舱,得到MBLNO:{MBLNO}", bkModel.MBLNO); var ctnCodeList = _cache.GetAllCodeCtn().GetAwaiter().GetResult().ToList(); @@ -2790,7 +2824,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; @@ -2800,6 +2837,7 @@ namespace Myshipping.Application { ////对应订舱和舱位关系 var allocRlt = await ImportSlots(importSlots, id, false, generateModel); + _logger.LogInformation("根据舱位生成订舱,引入订舱关系完成"); //这里如果指定了委托单位的邮件联系人,则推送订舱联系人 if (generateModel.CustomerContactList != null && generateModel.CustomerContactList.Count > 0) @@ -3060,9 +3098,9 @@ namespace Myshipping.Application if (bcSrcDto.CarrierId.Equals("MSK", StringComparison.OrdinalIgnoreCase)) { var bookingSlotAllocList = _repBase.AsQueryable().Filter(null, true) - .LeftJoin((slot,alloc)=> slot.Id == alloc.BOOKING_SLOT_ID) + .LeftJoin((slot, alloc) => slot.Id == alloc.BOOKING_SLOT_ID) .Where((slot, alloc) => slot.Id == slotId && slot.IsDeleted == false && slot.TenantId == UserManager.TENANT_ID && alloc.IsDeleted == false) - .Select((slot, alloc) => new { Slot = slot,Alloc = alloc }).ToList(); + .Select((slot, alloc) => new { Slot = slot, Alloc = alloc }).ToList(); List bookingOrderList = new List(); List userList = new List(); @@ -3115,7 +3153,7 @@ namespace Myshipping.Application { bookingSlotAllocList.ForEach(async ca => { - var bookingInfo = _repBookingOrder.AsQueryable().Filter(null, true).First(x => x.Id == ca.Alloc.BOOKING_ID && x.IsDeleted == false + var bookingInfo = _repBookingOrder.AsQueryable().Filter(null, true).First(x => x.Id == ca.Alloc.BOOKING_ID && x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID); var notice = new CautionNoticeTaskDto @@ -3419,7 +3457,7 @@ namespace Myshipping.Application DateTime targeVGMCutDate = DateTime.Parse(targeVGMCut); //如果新给的VGM截止时间,需要推送通知 - if(srcVGMCutDate > targeVGMCutDate) + if (srcVGMCutDate > targeVGMCutDate) { if (bookingSlotAllocList.Count > 0) { @@ -3502,7 +3540,7 @@ namespace Myshipping.Application /// 联系用户ID /// 提单号 /// 重要通知类型 - private void CreateContact(List notifyList, List userList,long contactId,string mblNo, CautionNoticeTaskEnum cautionNoticeType) + private void CreateContact(List notifyList, List userList, long contactId, string mblNo, CautionNoticeTaskEnum cautionNoticeType) { if (!notifyList.Any(p => p.notifyUserId == contactId)) { diff --git a/Myshipping.Core/Service/Auth/AuthService.cs b/Myshipping.Core/Service/Auth/AuthService.cs index 4dd42b82..ea119fad 100644 --- a/Myshipping.Core/Service/Auth/AuthService.cs +++ b/Myshipping.Core/Service/Auth/AuthService.cs @@ -476,10 +476,16 @@ public class AuthService : IAuthService, IDynamicApiController, ITransient /// /// 默认用户名/密码:admin/admin /// - [HttpPost("/GetAuthorizationKye")] - [AllowAnonymous] + [HttpPost("/GetAuthorizationKey")] + [AllowAnonymous,ApiUser(ApiCode = "GetAuthorizationKey")] public async Task GetAuthorizationKey([Required] GetAuthorizationKeyInput input) { + //验证用户ID有效性 + var user= _sysUserRep.AsQueryable().Filter(null, true).First(u => u.DjyUserId == _cache.Get(input.UserId)); + if (user is null) + { + throw Oops.Bah("用户Id不存在"); + } //将key写入到redis 并指定五秒过期 string key = Guid.NewGuid().ToString(); await _cache.SetTimeoutAsync( key, input.UserId, TimeSpan.FromSeconds(5));