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

optimize
wanghaomei 2 years ago
parent 937f2381a2
commit 4cccc9085b

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

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

@ -69,7 +69,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
SqlSugarRepository<CodeIssueType> codeIssueTypeRep,
SqlSugarRepository<CommonModule> commonModuleRep,
ILogger<CommonDBService> logger,
ISysCacheService sysCacheService,
ISysCacheService sysCacheService,
SqlSugarRepository<CodeLane> codeLaneRep,
SqlSugarRepository<RelaPortCarrierLane> relaPortCarrierLaneRep,
SqlSugarRepository<CodeCountry> codeCountryRep)
@ -137,14 +137,15 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
entity.CreateUser = UserManager.DjyUserId;
await _codeCarrierRep.InsertAsync(entity);
}
else {
else
{
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.ModifyUser = UserManager.DjyUserId;
await _codeCarrierRep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
}
await GetAllCarrier();
}
@ -179,7 +180,8 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
{
var list = await _sysCacheService.GetAllMappingCarrier();
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);
}
var entity = dto.Adapt<MappingCarrier>();
@ -216,14 +218,14 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
//数量太多,不允许查询全部
if (string.IsNullOrEmpty(input.KeyWord))
{
return list.Take(10);
return list.Take(10);
}
var queryList = list.WhereIF(!string.IsNullOrEmpty(input.KeyWord), x => x.Name.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase));
if (queryList.Count() > 20)
{
return queryList.Take(input.Limit).OrderBy(x => x.Sort).ToList();
}
return queryList.OrderBy(x=>x.Sort).Take(10).ToList();
return queryList.OrderBy(x => x.Sort).Take(10).ToList();
}
/// <summary>
@ -272,7 +274,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
List<MappingVessel> list = await _sysCacheService.GetAllMappingVessel();
var queryList = list.Where(x => x.Module == input.Module)
.WhereIF(!string.IsNullOrEmpty(input.KeyWord), x => x.MapName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)
|| x.Name.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase));
if (queryList.Count() > 20)
@ -291,7 +293,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
var list = await _sysCacheService.GetAllMappingVessel();
var count = list.Where(x => x.Name == dto.Name.Trim()&&x.Module==dto.Module && x.GID != dto.GID).Count();
var count = list.Where(x => x.Name == dto.Name.Trim() && x.Module == dto.Module && x.GID != dto.GID).Count();
if (count > 0)
{
throw Oops.Bah(ErrorCode.D1006);
@ -344,7 +346,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
public async Task AddForwarder([FromBody] CodeForwarderDto dto)
{
var list = await _sysCacheService.GetAllCodeForwarder();
var count = list.Where(x =>x.Code == dto.Code && x.GID != dto.GID).Count();
var count = list.Where(x => x.Code == dto.Code && x.GID != dto.GID).Count();
if (count > 0)
{
throw Oops.Bah(ErrorCode.D1006);
@ -357,7 +359,8 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
entity.CreateUser = UserManager.DjyUserId;
await _codeForwarderRep.InsertAsync(entity);
}
else {
else
{
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();
@ -366,7 +369,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
await _codeForwarderRep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
}
await GetAllForwarder();
}
#endregion
@ -391,7 +394,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
{
var list = await _sysCacheService.GetAllCodeYard();
var count = list.Where(x => x.Code == dto.Code && x.GID != dto.GID).Count();
var count = list.Where(x => x.Code == dto.Code && x.GID != dto.GID).Count();
if (count > 0)
{
throw Oops.Bah(ErrorCode.D1006);
@ -406,7 +409,8 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
await _codeYardRep.InsertAsync(entity);
}
else {
else
{
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.ModifyTime = DateTime.Now;
@ -414,7 +418,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
await _codeYardRep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
}
await GetAllYard();
}
@ -450,7 +454,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
{
var list = await _sysCacheService.GetAllMappingYard();
var count = list.Where(x => x.Code == dto.Code&&x.Module==dto.Module && x.GID != dto.GID).Count();
var count = list.Where(x => x.Code == dto.Code && x.Module == dto.Module && x.GID != dto.GID).Count();
if (count > 0)
{
throw Oops.Bah(ErrorCode.D1006);
@ -487,13 +491,13 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
public async Task<dynamic> PortloadList([FromQuery] NameQueryDto input)
{
List<CodePortLoad> list = await _sysCacheService.GetAllCodePortLoad();
_logger.LogInformation("起始港1:"+DateTime.Now.ToString());
_logger.LogInformation("起始港1:" + DateTime.Now.ToString());
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.CnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) ||
x.EdiCode.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase));
_logger.LogInformation("起始港2:"+DateTime.Now.ToString());
_logger.LogInformation("起始港2:" + DateTime.Now.ToString());
if (queryList.Count() > 20)
{
return queryList.Take(input.Limit).OrderBy(x => x.Sort).ToList();
@ -520,7 +524,8 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
entity.CreateUser = UserManager.DjyUserId;
await _codePortLoadrRep.InsertAsync(entity);
}
else {
else
{
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();
@ -529,7 +534,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
await _codePortLoadrRep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
}
await GetAllPortload();
}
@ -565,7 +570,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
public async Task AddOrUpdatePortload([FromBody] MappingPortLoadDto dto)
{
var list = await _sysCacheService.GetAllMappingPortLoad();
var count = list.Where(x => x.Code == dto.Code&&x.Module==dto.Module&&x.CarrierCode==dto.CarrierCode && x.GID != dto.GID).Count();
var count = list.Where(x => x.Code == dto.Code && x.Module == dto.Module && x.CarrierCode == dto.CarrierCode && x.GID != dto.GID).Count();
if (count > 0)
{
throw Oops.Bah(ErrorCode.D1006);
@ -601,17 +606,42 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
public async Task<dynamic> PortList([FromQuery] NameQueryDto input)
{
List<CodePort> list = await _sysCacheService.GetAllCodePort();
if (string.IsNullOrWhiteSpace(input.KeyWord)) {
return list.Take(10);
var listLineRela = await _sysCacheService.GetAllRelaPortCarrierLane();
var listLine = await _sysCacheService.GetAllCodeLane();
List<CodePort> result = null;
if (string.IsNullOrWhiteSpace(input.KeyWord))
{
result = list.Take(10).ToList();
}
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));
if (queryList.Count()>20) {
return queryList.Take(input.Limit).OrderBy(x => x.Sort).ToList();
else
{
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));
if (queryList.Count() > 20)
{
result = queryList.Take(input.Limit).OrderBy(x => x.Sort).ToList();
}
else
{
result = queryList.OrderBy(x => x.Sort).ToList();
}
}
return 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);
}
else {
else
{
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.ModifyTime = DateTime.Now;
@ -644,7 +675,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
await _codePortRep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
}
await GetAllPort();
}
/// <summary>
@ -679,7 +710,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
public async Task AddOrUpdatePort([FromBody] MappingPortDto dto)
{
var list = await _sysCacheService.GetAllMappingPort();
var count = list.Where(x => x.Code == dto.Code && x.Module == dto.Module&&x.CarrierCode==dto.CarrierCode && x.GID != dto.GID).Count();
var count = list.Where(x => x.Code == dto.Code && x.Module == dto.Module && x.CarrierCode == dto.CarrierCode && x.GID != dto.GID).Count();
if (count > 0)
{
throw Oops.Bah(ErrorCode.D1006);
@ -716,7 +747,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
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)
|| x.EdiCode.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase));
return queryList.OrderBy(x=>x.Sort).ToList();
return queryList.OrderBy(x => x.Sort).ToList();
}
/// <summary>
/// 新增包装信息
@ -726,7 +757,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
{
var list = await _sysCacheService.GetAllCodePackage();
var count = list.Where(x => x.Code == dto.Code && x.GID != dto.GID).Count();
if (count > 0 )
if (count > 0)
{
throw Oops.Bah(ErrorCode.D1006);
}
@ -782,7 +813,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
public async Task AddOrUpdateMappingPackage([FromBody] MappingPackageDto dto)
{
var list = await _sysCacheService.GetAllMappingPackage();
var count = list.Where(x => x.Code == dto.Code && x.Module == dto.Module &&x.CarrierCode==dto.CarrierCode && x.GID != dto.GID).Count();
var count = list.Where(x => x.Code == dto.Code && x.Module == dto.Module && x.CarrierCode == dto.CarrierCode && x.GID != dto.GID).Count();
if (count > 0)
{
throw Oops.Bah(ErrorCode.D1006);
@ -846,7 +877,8 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
await _codeServiceRep.InsertAsync(entity);
}
else {
else
{
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();
@ -854,7 +886,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
entity.ModifyUser = UserManager.DjyUserId;
await _codeServiceRep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
}
await GetAllService();
}
@ -890,7 +922,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
public async Task AddOrUpdateMappingService([FromBody] MappingServiceDto dto)
{
var list = await _sysCacheService.GetAllMappingService();
var count = list.Where(x => x.Code == dto.Code && x.Module == dto.Module&&x.CarrierCode==dto.CarrierCode && x.GID != dto.GID).Count();
var count = list.Where(x => x.Code == dto.Code && x.Module == dto.Module && x.CarrierCode == dto.CarrierCode && x.GID != dto.GID).Count();
if (count > 0)
{
throw Oops.Bah(ErrorCode.D1006);
@ -926,7 +958,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
List<CodeCtn> list = await _sysCacheService.GetAllCodeCtn();
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)
|| x.EdiCode.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)).OrderByDescending(x=>x.CreateTime);
|| x.EdiCode.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)).OrderByDescending(x => x.CreateTime);
return queryList.OrderBy(x => x.Sort).ToList();
}
@ -1009,7 +1041,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
public async Task AddOrUpdateMappingCtn([FromBody] MappingCtnDto dto)
{
var list = await _sysCacheService.GetAllMappingCtn();
var count = list.Where(x => x.Code == dto.Code && x.Module == dto.Module&&x.CarrierCode==dto.CarrierCode && x.GID != dto.GID).Count();
var count = list.Where(x => x.Code == dto.Code && x.Module == dto.Module && x.CarrierCode == dto.CarrierCode && x.GID != dto.GID).Count();
if (count > 0)
{
throw Oops.Bah(ErrorCode.D1006);
@ -1077,7 +1109,8 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
entity.CreateUser = UserManager.DjyUserId;
await _codeFrtRep.InsertAsync(entity);
}
else {
else
{
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();
@ -1085,7 +1118,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
entity.ModifyUser = UserManager.DjyUserId;
await _codeFrtRep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
}
await GetAllFrt();
}
@ -1118,7 +1151,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
public async Task AddOrUpdateMappingFrt([FromBody] MappingFrtDto dto)
{
var list = await _sysCacheService.GetAllMappingFrt();
var count = list.Where(x => x.Code == dto.Code && x.Module == dto.Module&&x.CarrierCode==dto.CarrierCode &&x.GID!=dto.GID).Count();
var count = list.Where(x => x.Code == dto.Code && x.Module == dto.Module && x.CarrierCode == dto.CarrierCode && x.GID != dto.GID).Count();
if (count > 0)
{
throw Oops.Bah(ErrorCode.D1006);
@ -1178,14 +1211,15 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
entity.CreateUser = UserManager.DjyUserId;
await _codeIssueTypeRep.InsertAsync(entity);
}
else {
else
{
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.ModifyTime = DateTime.Now;
entity.ModifyUser = UserManager.DjyUserId;
await _codeIssueTypeRep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
}
await GetAllCodeIssueType();
}
#endregion
@ -1217,7 +1251,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
*/
var entity = dto.Adapt<CodeLane>();
if(!string.IsNullOrWhiteSpace(entity.GID))
if (!string.IsNullOrWhiteSpace(entity.GID))
{
var model = _codeLaneRep.AsQueryable().InSingle(entity.GID);
@ -1240,9 +1274,9 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
}
else
{
var model = _codeLaneRep.AsQueryable().First(t=>t.Code == entity.Code);
var model = _codeLaneRep.AsQueryable().First(t => t.Code == entity.Code);
if(model != null)
if (model != null)
throw Oops.Bah(ErrorCode.D1006);
entity.GID = Guid.NewGuid().ToString();
@ -1266,7 +1300,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
{
List<CodeLane> list = await _sysCacheService.GetAllCodeLane();
var queryList = list.WhereIF(!string.IsNullOrEmpty(input.KeyWord),
var queryList = list.WhereIF(!string.IsNullOrEmpty(input.KeyWord),
x => (!string.IsNullOrWhiteSpace(x.Code) && x.Code.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase))
|| (!string.IsNullOrWhiteSpace(x.EnName) && x.EnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase))
|| (!string.IsNullOrWhiteSpace(x.CnName) && x.CnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase))
@ -1308,8 +1342,8 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
}
else
{
var model = _relaPortCarrierLaneRep.AsQueryable().Where(t => t.LaneCode == entity.LaneCode
&& t.Module == entity.Module
var model = _relaPortCarrierLaneRep.AsQueryable().Where(t => t.LaneCode == entity.LaneCode
&& t.Module == entity.Module
&& t.CarrierCode == entity.CarrierCode
&& t.PortCode == entity.PortCode).First();

Loading…
Cancel
Save