目的港,增加航线数据返回

optimize
wanghaomei 2 years ago
parent 937f2381a2
commit 4cccc9085b

@ -62,8 +62,11 @@ namespace Myshipping.Core.Entity
/// </summary> /// </summary>
public string Remark { get; set; } public string Remark { get; set; }
/// <summary>
/// 航线名称,非数据库列
/// </summary>
[SugarColumn(IsIgnore = false)]
public dynamic LineName { get; set; }
} }

@ -1192,6 +1192,11 @@
备注 备注
</summary> </summary>
</member> </member>
<member name="P:Myshipping.Core.Entity.CodePort.LineName">
<summary>
航线名称,非数据库列
</summary>
</member>
<member name="P:Myshipping.Core.Entity.MappingPort.Code"> <member name="P:Myshipping.Core.Entity.MappingPort.Code">
<summary> <summary>
代码 代码

@ -137,7 +137,8 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
entity.CreateUser = UserManager.DjyUserId; entity.CreateUser = UserManager.DjyUserId;
await _codeCarrierRep.InsertAsync(entity); await _codeCarrierRep.InsertAsync(entity);
} }
else { else
{
entity.CreateTime = list.Where(x => x.GID == dto.GID).Select(x => x.CreateTime).FirstOrDefault(); entity.CreateTime = list.Where(x => x.GID == dto.GID).Select(x => x.CreateTime).FirstOrDefault();
entity.CreateUser = list.Where(x => x.GID == dto.GID).Select(x => x.CreateUser).FirstOrDefault(); entity.CreateUser = list.Where(x => x.GID == dto.GID).Select(x => x.CreateUser).FirstOrDefault();
entity.ModifyTime = DateTime.Now; entity.ModifyTime = DateTime.Now;
@ -179,7 +180,8 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
{ {
var list = await _sysCacheService.GetAllMappingCarrier(); var list = await _sysCacheService.GetAllMappingCarrier();
var count = list.Where(x => x.Module == dto.Module && x.Code == dto.Code && x.GID != dto.GID).Count(); var count = list.Where(x => x.Module == dto.Module && x.Code == dto.Code && x.GID != dto.GID).Count();
if (count>0) { if (count > 0)
{
throw Oops.Bah(ErrorCode.D1006); throw Oops.Bah(ErrorCode.D1006);
} }
var entity = dto.Adapt<MappingCarrier>(); var entity = dto.Adapt<MappingCarrier>();
@ -357,7 +359,8 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
entity.CreateUser = UserManager.DjyUserId; entity.CreateUser = UserManager.DjyUserId;
await _codeForwarderRep.InsertAsync(entity); await _codeForwarderRep.InsertAsync(entity);
} }
else { else
{
entity.CreateTime = list.Where(x => x.GID == dto.GID).Select(x => x.CreateTime).FirstOrDefault(); entity.CreateTime = list.Where(x => x.GID == dto.GID).Select(x => x.CreateTime).FirstOrDefault();
entity.CreateUser = list.Where(x => x.GID == dto.GID).Select(x => x.CreateUser).FirstOrDefault(); entity.CreateUser = list.Where(x => x.GID == dto.GID).Select(x => x.CreateUser).FirstOrDefault();
@ -406,7 +409,8 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
await _codeYardRep.InsertAsync(entity); await _codeYardRep.InsertAsync(entity);
} }
else { else
{
entity.CreateTime = list.Where(x => x.GID == dto.GID).Select(x => x.CreateTime).FirstOrDefault(); entity.CreateTime = list.Where(x => x.GID == dto.GID).Select(x => x.CreateTime).FirstOrDefault();
entity.CreateUser = list.Where(x => x.GID == dto.GID).Select(x => x.CreateUser).FirstOrDefault(); entity.CreateUser = list.Where(x => x.GID == dto.GID).Select(x => x.CreateUser).FirstOrDefault();
entity.ModifyTime = DateTime.Now; entity.ModifyTime = DateTime.Now;
@ -520,7 +524,8 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
entity.CreateUser = UserManager.DjyUserId; entity.CreateUser = UserManager.DjyUserId;
await _codePortLoadrRep.InsertAsync(entity); await _codePortLoadrRep.InsertAsync(entity);
} }
else { else
{
entity.CreateTime = list.Where(x => x.GID == dto.GID).Select(x => x.CreateTime).FirstOrDefault(); entity.CreateTime = list.Where(x => x.GID == dto.GID).Select(x => x.CreateTime).FirstOrDefault();
entity.CreateUser = list.Where(x => x.GID == dto.GID).Select(x => x.CreateUser).FirstOrDefault(); entity.CreateUser = list.Where(x => x.GID == dto.GID).Select(x => x.CreateUser).FirstOrDefault();
@ -601,17 +606,42 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
public async Task<dynamic> PortList([FromQuery] NameQueryDto input) public async Task<dynamic> PortList([FromQuery] NameQueryDto input)
{ {
List<CodePort> list = await _sysCacheService.GetAllCodePort(); List<CodePort> list = await _sysCacheService.GetAllCodePort();
if (string.IsNullOrWhiteSpace(input.KeyWord)) { var listLineRela = await _sysCacheService.GetAllRelaPortCarrierLane();
var listLine = await _sysCacheService.GetAllCodeLane();
return list.Take(10); List<CodePort> result = null;
if (string.IsNullOrWhiteSpace(input.KeyWord))
{
result = list.Take(10).ToList();
} }
else
{
var queryList = list.WhereIF(!string.IsNullOrEmpty(input.KeyWord), x => x.Code.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) var queryList = list.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)); || x.EnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.CnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || x.EdiCode.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase));
if (queryList.Count()>20) { if (queryList.Count() > 20)
return queryList.Take(input.Limit).OrderBy(x => x.Sort).ToList(); {
result = queryList.Take(input.Limit).OrderBy(x => x.Sort).ToList();
} }
else
{
return queryList.OrderBy(x => x.Sort).ToList(); result = queryList.OrderBy(x => x.Sort).ToList();
}
}
result.ForEach(x =>
{
var query = from line in listLine
join lineRel in listLineRela on line.Code equals lineRel.LaneCode
where lineRel.PortCode == x.Code
select new { line, lineRel };
x.LineName = query.Select(x => new
{
x.line.CnName,
x.lineRel.CarrierCode
}).ToList();
});
return result;
} }
@ -636,7 +666,8 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
await _codePortRep.InsertAsync(entity); await _codePortRep.InsertAsync(entity);
} }
else { else
{
entity.CreateTime = list.Where(x => x.GID == dto.GID).Select(x => x.CreateTime).FirstOrDefault(); entity.CreateTime = list.Where(x => x.GID == dto.GID).Select(x => x.CreateTime).FirstOrDefault();
entity.CreateUser = list.Where(x => x.GID == dto.GID).Select(x => x.CreateUser).FirstOrDefault(); entity.CreateUser = list.Where(x => x.GID == dto.GID).Select(x => x.CreateUser).FirstOrDefault();
entity.ModifyTime = DateTime.Now; entity.ModifyTime = DateTime.Now;
@ -846,7 +877,8 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
await _codeServiceRep.InsertAsync(entity); await _codeServiceRep.InsertAsync(entity);
} }
else { else
{
entity.CreateTime = list.Where(x => x.GID == dto.GID).Select(x => x.CreateTime).FirstOrDefault(); entity.CreateTime = list.Where(x => x.GID == dto.GID).Select(x => x.CreateTime).FirstOrDefault();
entity.CreateUser = list.Where(x => x.GID == dto.GID).Select(x => x.CreateUser).FirstOrDefault(); entity.CreateUser = list.Where(x => x.GID == dto.GID).Select(x => x.CreateUser).FirstOrDefault();
@ -1077,7 +1109,8 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
entity.CreateUser = UserManager.DjyUserId; entity.CreateUser = UserManager.DjyUserId;
await _codeFrtRep.InsertAsync(entity); await _codeFrtRep.InsertAsync(entity);
} }
else { else
{
entity.CreateTime = list.Where(x => x.GID == dto.GID).Select(x => x.CreateTime).FirstOrDefault(); entity.CreateTime = list.Where(x => x.GID == dto.GID).Select(x => x.CreateTime).FirstOrDefault();
entity.CreateUser = list.Where(x => x.GID == dto.GID).Select(x => x.CreateUser).FirstOrDefault(); entity.CreateUser = list.Where(x => x.GID == dto.GID).Select(x => x.CreateUser).FirstOrDefault();
@ -1178,7 +1211,8 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
entity.CreateUser = UserManager.DjyUserId; entity.CreateUser = UserManager.DjyUserId;
await _codeIssueTypeRep.InsertAsync(entity); await _codeIssueTypeRep.InsertAsync(entity);
} }
else { else
{
entity.CreateTime = list.Where(x => x.GID == dto.GID).Select(x => x.CreateTime).FirstOrDefault(); entity.CreateTime = list.Where(x => x.GID == dto.GID).Select(x => x.CreateTime).FirstOrDefault();
entity.CreateUser = list.Where(x => x.GID == dto.GID).Select(x => x.CreateUser).FirstOrDefault(); entity.CreateUser = list.Where(x => x.GID == dto.GID).Select(x => x.CreateUser).FirstOrDefault();
entity.ModifyTime = DateTime.Now; entity.ModifyTime = DateTime.Now;

Loading…
Cancel
Save