jianghaiqing 2 years ago
commit e2cdda0ee3

@ -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,9 +137,10 @@ 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;
entity.ModifyUser = UserManager.DjyUserId; entity.ModifyUser = UserManager.DjyUserId;
await _codeCarrierRep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); await _codeCarrierRep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
@ -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>();
@ -223,7 +225,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
{ {
return queryList.Take(input.Limit).OrderBy(x => x.Sort).ToList(); 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> /// <summary>
@ -291,7 +293,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
var list = await _sysCacheService.GetAllMappingVessel(); 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) if (count > 0)
{ {
throw Oops.Bah(ErrorCode.D1006); throw Oops.Bah(ErrorCode.D1006);
@ -344,7 +346,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
public async Task AddForwarder([FromBody] CodeForwarderDto dto) public async Task AddForwarder([FromBody] CodeForwarderDto dto)
{ {
var list = await _sysCacheService.GetAllCodeForwarder(); 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) if (count > 0)
{ {
throw Oops.Bah(ErrorCode.D1006); throw Oops.Bah(ErrorCode.D1006);
@ -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;
@ -450,7 +454,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
{ {
var list = await _sysCacheService.GetAllMappingYard(); 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) if (count > 0)
{ {
throw Oops.Bah(ErrorCode.D1006); throw Oops.Bah(ErrorCode.D1006);
@ -487,13 +491,13 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
public async Task<dynamic> PortloadList([FromQuery] NameQueryDto input) public async Task<dynamic> PortloadList([FromQuery] NameQueryDto input)
{ {
List<CodePortLoad> list = await _sysCacheService.GetAllCodePortLoad(); 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), var queryList = list.WhereIF(!string.IsNullOrEmpty(input.KeyWord),
x => x.Code.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) x => x.Code.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)
|| x.EnName.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)); x.EdiCode.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase));
_logger.LogInformation("起始港2:"+DateTime.Now.ToString()); _logger.LogInformation("起始港2:" + DateTime.Now.ToString());
if (queryList.Count() > 20) if (queryList.Count() > 20)
{ {
return queryList.Take(input.Limit).OrderBy(x => x.Sort).ToList(); return queryList.Take(input.Limit).OrderBy(x => x.Sort).ToList();
@ -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();
@ -565,7 +570,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
public async Task AddOrUpdatePortload([FromBody] MappingPortLoadDto dto) public async Task AddOrUpdatePortload([FromBody] MappingPortLoadDto dto)
{ {
var list = await _sysCacheService.GetAllMappingPortLoad(); 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) if (count > 0)
{ {
throw Oops.Bah(ErrorCode.D1006); throw Oops.Bah(ErrorCode.D1006);
@ -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;
@ -679,7 +710,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
public async Task AddOrUpdatePort([FromBody] MappingPortDto dto) public async Task AddOrUpdatePort([FromBody] MappingPortDto dto)
{ {
var list = await _sysCacheService.GetAllMappingPort(); 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) if (count > 0)
{ {
throw Oops.Bah(ErrorCode.D1006); 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) 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)); || x.EdiCode.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase));
return queryList.OrderBy(x=>x.Sort).ToList(); return queryList.OrderBy(x => x.Sort).ToList();
} }
/// <summary> /// <summary>
/// 新增包装信息 /// 新增包装信息
@ -726,7 +757,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
{ {
var list = await _sysCacheService.GetAllCodePackage(); var list = await _sysCacheService.GetAllCodePackage();
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 ) if (count > 0)
{ {
throw Oops.Bah(ErrorCode.D1006); throw Oops.Bah(ErrorCode.D1006);
} }
@ -782,7 +813,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
public async Task AddOrUpdateMappingPackage([FromBody] MappingPackageDto dto) public async Task AddOrUpdateMappingPackage([FromBody] MappingPackageDto dto)
{ {
var list = await _sysCacheService.GetAllMappingPackage(); 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) if (count > 0)
{ {
throw Oops.Bah(ErrorCode.D1006); throw Oops.Bah(ErrorCode.D1006);
@ -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();
@ -890,7 +922,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
public async Task AddOrUpdateMappingService([FromBody] MappingServiceDto dto) public async Task AddOrUpdateMappingService([FromBody] MappingServiceDto dto)
{ {
var list = await _sysCacheService.GetAllMappingService(); 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) if (count > 0)
{ {
throw Oops.Bah(ErrorCode.D1006); throw Oops.Bah(ErrorCode.D1006);
@ -926,7 +958,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
List<CodeCtn> list = await _sysCacheService.GetAllCodeCtn(); 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) 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(); return queryList.OrderBy(x => x.Sort).ToList();
} }
@ -1009,7 +1041,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
public async Task AddOrUpdateMappingCtn([FromBody] MappingCtnDto dto) public async Task AddOrUpdateMappingCtn([FromBody] MappingCtnDto dto)
{ {
var list = await _sysCacheService.GetAllMappingCtn(); 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) if (count > 0)
{ {
throw Oops.Bah(ErrorCode.D1006); throw Oops.Bah(ErrorCode.D1006);
@ -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();
@ -1118,7 +1151,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
public async Task AddOrUpdateMappingFrt([FromBody] MappingFrtDto dto) public async Task AddOrUpdateMappingFrt([FromBody] MappingFrtDto dto)
{ {
var list = await _sysCacheService.GetAllMappingFrt(); 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) if (count > 0)
{ {
throw Oops.Bah(ErrorCode.D1006); throw Oops.Bah(ErrorCode.D1006);
@ -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;
@ -1217,7 +1251,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
*/ */
var entity = dto.Adapt<CodeLane>(); var entity = dto.Adapt<CodeLane>();
if(!string.IsNullOrWhiteSpace(entity.GID)) if (!string.IsNullOrWhiteSpace(entity.GID))
{ {
var model = _codeLaneRep.AsQueryable().InSingle(entity.GID); var model = _codeLaneRep.AsQueryable().InSingle(entity.GID);
@ -1240,9 +1274,9 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
} }
else 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); throw Oops.Bah(ErrorCode.D1006);
entity.GID = Guid.NewGuid().ToString(); entity.GID = Guid.NewGuid().ToString();

Loading…
Cancel
Save