From 76018572f71d4f7d7feceec07816819a4b0b0482 Mon Sep 17 00:00:00 2001 From: zhangxiaofeng <1939543722@qq.com> Date: Mon, 24 Jun 2024 15:57:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E8=A3=85=E8=B4=A7=E6=B8=AF?= =?UTF-8?q?=E7=AD=9B=E9=80=89=E8=88=B9=E4=BB=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Myshipping.Core/Myshipping.Core.xml | 2 +- Myshipping.Core/Service/CommonDB/CommonDBService.cs | 12 ++++++++++-- .../Service/CommonDB/Dto/CodeForwarderDto.cs | 13 ++++++------- 3 files changed, 17 insertions(+), 10 deletions(-) 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; } + } }