diff --git a/Myshipping.Application/Entity/BookingLabel.cs b/Myshipping.Application/Entity/BookingLabel.cs new file mode 100644 index 00000000..b93ea890 --- /dev/null +++ b/Myshipping.Application/Entity/BookingLabel.cs @@ -0,0 +1,23 @@ +using Myshipping.Core.Entity; +using SqlSugar; +using System.ComponentModel; +namespace Myshipping.Application.Entity +{ + /// + /// + /// + [SugarTable("booking_label")] + [Description("订舱标签表")] + public class BookingLabel : DBEntityTenant + { + /// + /// 标签名称 + /// + public string Name { get; set; } + + /// + /// 标签使用范围 1-舱位管理台账 + /// + public int Scope { get; set; } + } +} \ No newline at end of file diff --git a/Myshipping.Application/Service/BookingLabel/BookingLabelService.cs b/Myshipping.Application/Service/BookingLabel/BookingLabelService.cs new file mode 100644 index 00000000..22e49869 --- /dev/null +++ b/Myshipping.Application/Service/BookingLabel/BookingLabelService.cs @@ -0,0 +1,97 @@ +using Furion.DependencyInjection; +using Furion.DynamicApiController; +using Mapster; +using Microsoft.AspNetCore.Mvc; +using Myshipping.Application.Entity; +using Myshipping.Application.Service.BookingLabel.Dto; +using Myshipping.Core; +using Myshipping.Core.Service; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + /// + /// 订舱标签服务 + /// + public class BookingLabelService : IBookingLabelService, IDynamicApiController, ITransient + { + private readonly SqlSugarRepository _rep; + + private readonly ISysCacheService _cache; + public BookingLabelService(SqlSugarRepository rep, + ISysCacheService cache) + { + _rep = rep; + _cache = cache; + } + + /// + /// 获取全部或指定范围类型的标签列表 + /// + /// 标签使用范围 空-全部 1-舱位管理台账 + [HttpGet("/BookingLabel/List")] + public async Task> List(int? scope) + { + List cacheList = await _cache.GetAsync>(CommonConst.CACHE_KEY_BOOKING_LABEL + ":" + UserManager.TENANT_ID); + if (cacheList?.Any() != true) + { + cacheList = await Cache(); + } + + var result = scope == null + ? cacheList + : cacheList.Where(x => x.Scope == scope).ToList(); + return result; + } + + /// + /// 新增或修改标签信息 + /// + [HttpPost("/BookingLabel/Save")] + public async Task Save(BookingLabelBaseDto input) + { + var model = input.Adapt(); + if (input.Id is null or 0) + { + await _rep.InsertAsync(model); + await Cache(); + return model.Id; + } + else + { + var oldModel = await _rep.FirstOrDefaultAsync(x => x.Id == input.Id); + if (oldModel != null) + { + input.Adapt(oldModel); + await _rep.UpdateAsync(oldModel); + await Cache(); + } + return (long)input.Id; + } + } + /// + /// 删除标签信息 + /// + [HttpPost("/BookingLabel/Delete")] + public async Task Delete([FromBody] long[] ids) + { + if (ids != null && ids.Length > 0) + { + await _rep.DeleteAsync(x => ids.Contains(x.Id)); + await Cache(); + } + } + [NonAction] + private async Task> Cache() + { + var list = await _rep.AsQueryable().ToListAsync(); + var cacheList = list.Adapt>(); + + await _cache.SetTimeoutAsync(CommonConst.CACHE_KEY_BOOKING_LABEL + ":" + UserManager.TENANT_ID, cacheList, TimeSpan.FromDays(3)); + return cacheList; + } + } +} diff --git a/Myshipping.Application/Service/BookingLabel/Dto/BookingLabelBaseDto.cs b/Myshipping.Application/Service/BookingLabel/Dto/BookingLabelBaseDto.cs new file mode 100644 index 00000000..7648a202 --- /dev/null +++ b/Myshipping.Application/Service/BookingLabel/Dto/BookingLabelBaseDto.cs @@ -0,0 +1,20 @@ +namespace Myshipping.Application.Service.BookingLabel.Dto +{ + public class BookingLabelBaseDto + { + public long? Id { get; set; } + /// + /// 标签名称 + /// + public string Name { get; set; } + + /// + /// 标签使用范围 1-舱位 + /// + public int Scope { get; set; } + } + //public class BookingLabelCacheDto : BookingLabelBaseDto + //{ + // public long TenantId { get; set; } + //} +} diff --git a/Myshipping.Application/Service/BookingLabel/IBookingLabelService.cs b/Myshipping.Application/Service/BookingLabel/IBookingLabelService.cs new file mode 100644 index 00000000..ee4d5789 --- /dev/null +++ b/Myshipping.Application/Service/BookingLabel/IBookingLabelService.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + public class IBookingLabelService + { + } +} diff --git a/Myshipping.Application/Service/BookingVesselInfo/BookingVesselInfoService.cs b/Myshipping.Application/Service/BookingVesselInfo/BookingVesselInfoService.cs index 4f4593a7..17e9797c 100644 --- a/Myshipping.Application/Service/BookingVesselInfo/BookingVesselInfoService.cs +++ b/Myshipping.Application/Service/BookingVesselInfo/BookingVesselInfoService.cs @@ -29,8 +29,8 @@ namespace Myshipping.Application private readonly SqlSugarRepository _order; private readonly ILogger _logger; private readonly IHubContext _chatHubContext; - public BookingVesselInfoService(SqlSugarRepository rep, ILogger logger, SqlSugarRepository order, - ISysCacheService sysCacheService, + public BookingVesselInfoService(SqlSugarRepository rep, ILogger logger, SqlSugarRepository order, + ISysCacheService sysCacheService, IBookingOrderService bookingorderservice, IHubContext chatHubContext) { @@ -153,10 +153,20 @@ namespace Myshipping.Application } - if ((dto.ETA != null || dto.ETD != null || dto.ATD != null) && !string.IsNullOrEmpty(old.Vessel) && !string.IsNullOrEmpty(old.Voyno) && !string.IsNullOrEmpty(old.CARRIERID)) + if ((dto.ETA != null || dto.ETD != null || dto.ATD != null) + && !string.IsNullOrEmpty(old.Vessel) + && !string.IsNullOrEmpty(old.Voyno) + && !string.IsNullOrEmpty(old.CARRIERID)) { - var order = await _order.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID && x.IsDeleted == false && x.VESSEL == old.Vessel && x.VOYNO == old.Voyno - && x.CARRIERID == old.CARRIERID).ToListAsync(); + var order = await _order.AsQueryable() + .Filter(null, true) + .Where(x => x.TenantId == UserManager.TENANT_ID + && x.IsDeleted == false + && x.VESSEL == old.Vessel + && x.VOYNO == old.Voyno + && x.CARRIERID == old.CARRIERID) + .WhereIF(!string.IsNullOrEmpty(old.PortLoadingId), x => x.PORTLOADID == old.PortLoadingId) + .ToListAsync(); bool issend = false; if (order != null) { @@ -213,6 +223,17 @@ namespace Myshipping.Application it.ATD = dto.ATD; } + if (dto.ClosingDate != null && dto.ClosingDate != it.CLOSINGDATE) + { + flag = true; + it.CLOSINGDATE = dto.ClosingDate; + } + if (dto.CloseDocTime != null && dto.CloseDocTime != it.CLOSEDOCDATE) + { + flag = true; + it.CLOSEDOCDATE = dto.CloseDocTime; + } + if (flag) { issend = true; diff --git a/Myshipping.Application/Service/Fee/FeeCodeService.cs b/Myshipping.Application/Service/Fee/FeeCodeService.cs index 492069e1..78b50658 100644 --- a/Myshipping.Application/Service/Fee/FeeCodeService.cs +++ b/Myshipping.Application/Service/Fee/FeeCodeService.cs @@ -141,7 +141,7 @@ namespace Myshipping.Application [HttpGet("/FeeCode/List")] public async Task> List() { - var result = await _cache.GetAsync>(CommonConst.CACHE_KEY_FEE_CODE + "_" + UserManager.TENANT_ID); + var result = await _cache.GetAsync>(CommonConst.CACHE_KEY_FEE_CODE + ":" + UserManager.TENANT_ID); if (result?.Any() != true) { result = await CacheFeeCode(); @@ -165,7 +165,7 @@ namespace Myshipping.Application foreach (var item in groupFeeCodeCache) { var item2 = item.Adapt>(); - await _cache.SetTimeoutAsync(CommonConst.CACHE_KEY_FEE_CODE + "_" + item.Key, item2, new TimeSpan(6, 0, 0)); + await _cache.SetTimeoutAsync(CommonConst.CACHE_KEY_FEE_CODE + ":" + item.Key, item2, new TimeSpan(6, 0, 0)); } var result = groupFeeCodeCache.FirstOrDefault(x => x.Key == UserManager.TENANT_ID)?.Adapt>(); @@ -176,7 +176,7 @@ namespace Myshipping.Application // 否则只缓存当前租户的费用代码 var tenantFeeCode = await _repCode.AsQueryable().Filter(null, true).Where(x => !x.IsDeleted && x.TenantId == UserManager.TENANT_ID).ToListAsync(); - await _cache.SetTimeoutAsync(CommonConst.CACHE_KEY_FEE_CODE + "_" + UserManager.TENANT_ID, tenantFeeCode, new TimeSpan(6, 0, 0)); + await _cache.SetTimeoutAsync(CommonConst.CACHE_KEY_FEE_CODE + ":" + UserManager.TENANT_ID, tenantFeeCode, new TimeSpan(6, 0, 0)); var result = tenantFeeCode.Adapt>(); return result; diff --git a/Myshipping.Application/Service/Fee/FeeCurrencyService.cs b/Myshipping.Application/Service/Fee/FeeCurrencyService.cs index 6cc322f0..2822f15e 100644 --- a/Myshipping.Application/Service/Fee/FeeCurrencyService.cs +++ b/Myshipping.Application/Service/Fee/FeeCurrencyService.cs @@ -155,7 +155,7 @@ namespace Myshipping.Application foreach (var item in groupFeeCurrency) { var item2 = item.Adapt>(); - await _cache.SetTimeoutAsync(CommonConst.CACHE_KEY_FEE_CURRENCY + "_" + item.Key, item2, new TimeSpan(6, 0, 0)); + await _cache.SetTimeoutAsync(CommonConst.CACHE_KEY_FEE_CURRENCY + ":" + item.Key, item2, new TimeSpan(6, 0, 0)); } var result = groupFeeCurrency.FirstOrDefault(x => x.Key == UserManager.TENANT_ID)?.Adapt>(); @@ -166,7 +166,7 @@ namespace Myshipping.Application // 否则只缓存当前租户的费用币别 var tenantFeeCurrency = await _repCode.AsQueryable().Filter(null, true).Where(x => !x.IsDeleted && x.TenantId == UserManager.TENANT_ID).ToListAsync(); - await _cache.SetTimeoutAsync(CommonConst.CACHE_KEY_FEE_CURRENCY + "_" + UserManager.TENANT_ID, tenantFeeCurrency, new TimeSpan(6, 0, 0)); + await _cache.SetTimeoutAsync(CommonConst.CACHE_KEY_FEE_CURRENCY + ":" + UserManager.TENANT_ID, tenantFeeCurrency, new TimeSpan(6, 0, 0)); var result = tenantFeeCurrency.Adapt>(); return result; diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs index e09404ba..601054cb 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs @@ -2632,6 +2632,7 @@ namespace Myshipping.Application if (bcOrder.BOOKING_ORDER_ID != null && bcOrder.BOOKING_ORDER_ID.HasValue && bcOrder.BOOKING_ORDER_ID.Value > 0) { + /* SaveBookingOrderInput bkModel = new SaveBookingOrderInput { MBLNO = bcOrder.MBL_NO.ToUpper().Trim(), @@ -2689,7 +2690,7 @@ namespace Myshipping.Application else { _logger.LogInformation($"taskPKId={taskPKId} 更新订舱详情失败没有对应舱位ID"); - } + }*/ } else { diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageRollingNominationService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageRollingNominationService.cs index 2ea5f233..b83ab3b8 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageRollingNominationService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageRollingNominationService.cs @@ -1120,6 +1120,23 @@ namespace Myshipping.Application if (fromEntity.Count > 0) model.From = fromEntity.Select(p => p.Adapt()).ToList(); + + model.LoadDetailList = list.Select(a => a.Adapt()).ToList(); + + if (model.From != null && model.From.Count > 0) + { + var firstLoadDetail = model.LoadDetailList.FirstOrDefault(); + + if (model.From.Any(t => string.IsNullOrWhiteSpace(t.Port))) + { + model.From = model.From.Where(a => a.Terminal.Contains(firstLoadDetail.LoadPortName?.Trim())).ToList(); + } + else + { + model.From = model.From.Where(a => a.Port.Equals(firstLoadDetail.LoadPortName?.Trim(),StringComparison.OrdinalIgnoreCase)).ToList(); + } + } + var toEntity = shipList.Where(a => Regex.IsMatch(a.SHIP_TYPE, "To(\\s+[0-9]+)?" , RegexOptions.IgnoreCase)).ToList(); @@ -1180,8 +1197,6 @@ namespace Myshipping.Application List> tuples = new List>(); - model.LoadDetailList = list.Select(a => a.Adapt()).ToList(); - model.FromToList = new List(); if (model.LoadDetailList.Count > 0) diff --git a/Myshipping.Core/Const/CommonConst.cs b/Myshipping.Core/Const/CommonConst.cs index 124126a8..c97f7a8a 100644 --- a/Myshipping.Core/Const/CommonConst.cs +++ b/Myshipping.Core/Const/CommonConst.cs @@ -253,6 +253,14 @@ public class CommonConst public const string CACHE_KEY_FEE_CURRENCY = "FeeCurrencyList"; #endregion + #region 标签 + /// + /// 标签缓存键 + /// + public const string CACHE_KEY_BOOKING_LABEL = "BookingLabelList"; + #endregion + + #region 系统运行方式 /// /// 和川(会执行一些和川特有的逻辑) diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index 87d016ef..80c08aed 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -817,6 +817,11 @@ 币别缓存键 + + + 标签缓存键 + + 和川(会执行一些和川特有的逻辑)