新增 起始港和目的港合并查询

修改SITC 港口映射
master^2
jianghaiqing 3 days ago
parent 9314ae8638
commit abbcbed49b

@ -8252,27 +8252,11 @@ namespace Myshipping.Application
//一程装货港
if (!string.IsNullOrWhiteSpace(multiline.FstPortLoadCode))
{
var sameList = portList.Where(a =>
!string.IsNullOrWhiteSpace(a.EdiCode)
&& a.EdiCode.Equals(multiline.FstPortLoadCode, StringComparison.OrdinalIgnoreCase))
.Select(a => a.Code).ToList();
if (sameList == null || sameList.Count == 0)
throw Oops.Bah($"一程装货港{multiline.FstPortLoadCode}基础港口代码未找到");
var currPortInfo = ediPortList.FirstOrDefault(a =>
sameList.Contains(a.Code)
&& !string.IsNullOrWhiteSpace(a.CarrierCode)
&& a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase));
if (currPortInfo == null)
{
currPortInfo = ediPortList.FirstOrDefault(a =>
sameList.Contains(a.Code));
}
var currPortInfo = ediLoadPortList.FirstOrDefault(a =>
a.Code.Equals(multiline.FstPortLoadCode, StringComparison.OrdinalIgnoreCase));
if (currPortInfo == null)
throw Oops.Bah($"一程装货港{multiline.FstPortLoadCode}的映射EDI代码未找到");
throw Oops.Bah($"一程装货港{multiline.FstPortLoadCode}的EDI代码未找到");
multiline.FstPortLoadCode = currPortInfo.MapCode?.Trim();
multiline.FstPortLoad = currPortInfo.MapName?.Trim();
@ -8309,27 +8293,11 @@ namespace Myshipping.Application
//二程装货港
if (!string.IsNullOrWhiteSpace(multiline.SecPortLoadCode))
{
var sameList = portList.Where(a =>
!string.IsNullOrWhiteSpace(a.EdiCode)
&& a.EdiCode.Equals(multiline.SecPortLoadCode, StringComparison.OrdinalIgnoreCase))
.Select(a => a.Code).ToList();
if (sameList == null || sameList.Count == 0)
throw Oops.Bah($"二程装货港{multiline.SecPortLoadCode}基础港口代码未找到");
var currPortInfo = ediPortList.FirstOrDefault(a =>
sameList.Contains(a.Code)
&& !string.IsNullOrWhiteSpace(a.CarrierCode)
&& a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase));
if (currPortInfo == null)
{
currPortInfo = ediPortList.FirstOrDefault(a =>
sameList.Contains(a.Code));
}
var currPortInfo = ediLoadPortList.FirstOrDefault(a =>
a.Code.Equals(multiline.SecPortLoadCode, StringComparison.OrdinalIgnoreCase));
if (currPortInfo == null)
throw Oops.Bah($"二程装货港{multiline.SecPortLoadCode}的映射EDI代码未找到");
throw Oops.Bah($"二程装货港{multiline.SecPortLoadCode}的EDI代码未找到");
multiline.SecPortLoadCode = currPortInfo.MapCode?.Trim();
multiline.SecPortLoad = currPortInfo.MapName?.Trim();
@ -8366,27 +8334,11 @@ namespace Myshipping.Application
//三程装货港
if (!string.IsNullOrWhiteSpace(multiline.ThdPortLoadCode))
{
var sameList = portList.Where(a =>
!string.IsNullOrWhiteSpace(a.EdiCode)
&& a.EdiCode.Equals(multiline.FstPortLoadCode, StringComparison.OrdinalIgnoreCase))
.Select(a => a.Code).ToList();
if (sameList == null || sameList.Count == 0)
throw Oops.Bah($"三程装货港{multiline.ThdPortLoadCode}基础港口代码未找到");
var currPortInfo = ediPortList.FirstOrDefault(a =>
sameList.Contains(a.Code)
&& !string.IsNullOrWhiteSpace(a.CarrierCode)
&& a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase));
if (currPortInfo == null)
{
currPortInfo = ediPortList.FirstOrDefault(a =>
sameList.Contains(a.Code));
}
var currPortInfo = ediLoadPortList.FirstOrDefault(a =>
a.Code.Equals(multiline.ThdPortLoadCode, StringComparison.OrdinalIgnoreCase));
if (currPortInfo == null)
throw Oops.Bah($"三程装货港{multiline.ThdPortLoadCode}的映射EDI代码未找到");
throw Oops.Bah($"三程装货港{multiline.ThdPortLoadCode}的EDI代码未找到");
multiline.ThdPortLoadCode = currPortInfo.MapCode?.Trim();
multiline.ThdPortLoad = currPortInfo.MapName?.Trim();

@ -14,6 +14,7 @@ using Microsoft.Extensions.Logging;
using Myshipping.Core.Entity.CommonDB;
using Microsoft.AspNetCore.Authorization;
using System.Reflection.Metadata.Ecma335;
using StackExchange.Profiling.Internal;
namespace Myshipping.Core.Service;
/// <summary>
@ -2430,4 +2431,53 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
}
#endregion
#region 起始港和目的港合并查询
/// <summary>
/// 起始港和目的港合并查询
/// </summary>
[HttpGet("/commondb/portmixlist")]
public async Task<dynamic> PortMixList([FromQuery] NameQueryDto input)
{
List<CodePort> resultList = new List<CodePort>();
List<CodePortLoad> codePortLoadlist = await _sysCacheService.GetAllCodePortLoad();
List<CodePort> codePortDischargelist = await _sysCacheService.GetAllCodePort();
var queryList = codePortLoadlist.WhereIF(!string.IsNullOrEmpty(input.KeyWord),
x => x.Code.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)
|| x.EnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) ||
x.CnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) ||
x.EdiCode.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase))
.Take(input.Limit).OrderBy(x => x.Sort).ToList();
if (queryList.Count > 0)
{
resultList = queryList.Select(a => new CodePort
{
Code = a.Code,
CnName = a.CnName,
EnName = a.EnName,
EdiCode = a.EdiCode,
}).ToList();
}
if (queryList.Count < input.Limit)
{
int lessNum = input.Limit - queryList.Count;
var queryList2 = codePortDischargelist
.WhereIF(!string.IsNullOrEmpty(input.KeyWord), x => x.Code.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)
|| x.EnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)
|| x.CnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)
|| x.EdiCode.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase))
.Take(lessNum).OrderBy(x => x.Sort).ToList();
if (queryList2.Count > 0)
resultList.AddRange(queryList2);
}
return resultList;
}
#endregion
}

Loading…
Cancel
Save