diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index bfe8d8b7..ac04fec1 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -9179,7 +9179,7 @@ 新增编辑船名映射信息 - + 获取船代列表信息 diff --git a/Myshipping.Core/Service/CommonDB/CommonDBService.cs b/Myshipping.Core/Service/CommonDB/CommonDBService.cs index 5294ff9e..1e50201f 100644 --- a/Myshipping.Core/Service/CommonDB/CommonDBService.cs +++ b/Myshipping.Core/Service/CommonDB/CommonDBService.cs @@ -350,11 +350,19 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie /// 获取船代列表信息 /// [HttpGet("/commondb/forwarderlist")] - public async Task ForwarderList([FromQuery] NameQueryDto input) + public async Task ForwarderList([FromQuery] ForwarderListInputDto input) { List list = await _sysCacheService.GetAllCodeForwarder(); var queryList = list.WhereIF(!string.IsNullOrEmpty(input.KeyWord), x => x.Name.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.Code.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)); + + // 如果装货港代码不为空,则根据装货港代码查询装货港与船代的映射关系 + if (!string.IsNullOrEmpty(input.PortLoadCode)) + { + List forwarderCodeList = await _relaPortLoadForwarderRep.AsQueryable().Where(x => x.PortLoadCode == input.PortLoadCode).Select(x => x.ForwarderCode).ToListAsync(); + queryList = queryList.Where(x => forwarderCodeList.Contains(x.Code)).ToList(); + } + if (queryList.Count() > 20) { return queryList.Take(input.Limit).OrderBy(x => x.Sort).ToList(); @@ -522,7 +530,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie var queryList = list.Where(x => x.Module == input.Module) .WhereIF(!string.IsNullOrEmpty(input.KeyWord), x => x.Code.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.MapCode.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.MapName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)) - .WhereIF(!string.IsNullOrEmpty(input.CarrierCode), x => x.CarrierCode==input.CarrierCode); + .WhereIF(!string.IsNullOrEmpty(input.CarrierCode), x => x.CarrierCode == input.CarrierCode); if (queryList.Count() > 20) { return queryList.Take(input.Limit).OrderBy(x => x.Sort).ToList(); diff --git a/Myshipping.Core/Service/CommonDB/Dto/CodeForwarderDto.cs b/Myshipping.Core/Service/CommonDB/Dto/CodeForwarderDto.cs index ee3c86aa..8970842b 100644 --- a/Myshipping.Core/Service/CommonDB/Dto/CodeForwarderDto.cs +++ b/Myshipping.Core/Service/CommonDB/Dto/CodeForwarderDto.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Myshipping.Core.Service.CommonDB.Dto +namespace Myshipping.Core.Service.CommonDB.Dto { public class CodeForwarderDto { @@ -65,4 +59,9 @@ namespace Myshipping.Core.Service.CommonDB.Dto /// public int Sort { get; set; } } + + public class ForwarderListInputDto: NameQueryDto + { + public string PortLoadCode { get; set; } + } }