From 6de547d462db8210d9150973ee5ca19609808f5a Mon Sep 17 00:00:00 2001
From: wet <1034391973@qq.com>
Date: Thu, 17 Nov 2022 14:47:02 +0800
Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E5=85=B1=E5=BA=93=E6=8F=90=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Service/Cache/SysCacheService.cs | 15 ++-
.../Service/CommonDB/CommonDBService.cs | 106 +++++++++++-------
.../Myshipping.Report.csproj.user | 2 +-
3 files changed, 78 insertions(+), 45 deletions(-)
diff --git a/Myshipping.Core/Service/Cache/SysCacheService.cs b/Myshipping.Core/Service/Cache/SysCacheService.cs
index 10955145..460eebd6 100644
--- a/Myshipping.Core/Service/Cache/SysCacheService.cs
+++ b/Myshipping.Core/Service/Cache/SysCacheService.cs
@@ -1,5 +1,6 @@
using Furion.DependencyInjection;
using Furion.DynamicApiController;
+using Furion.FriendlyException;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
@@ -447,8 +448,18 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet
///
public Task SetAllCodeVessel(List list)
{
- _logger.LogInformation("接收到缓存船名");
- return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_VESSEL, list.ToJsonString());
+ try
+ {
+ _logger.LogInformation("接收到缓存船名");
+ return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_VESSEL, list.ToJsonString());
+ }
+ catch (Exception ex)
+ {
+
+ _logger.LogError("缓存船名异常:" + ex);
+ throw Oops.Oh(ex);
+ }
+
}
///
diff --git a/Myshipping.Core/Service/CommonDB/CommonDBService.cs b/Myshipping.Core/Service/CommonDB/CommonDBService.cs
index ced6b22b..76728298 100644
--- a/Myshipping.Core/Service/CommonDB/CommonDBService.cs
+++ b/Myshipping.Core/Service/CommonDB/CommonDBService.cs
@@ -88,7 +88,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
_mappingServiceRep = mappingServiceRep;
_codeIssueTypeRep = codeIssueTypeRep;
_logger = logger;
-
+
}
@@ -118,7 +118,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
entity.CreateUser = UserManager.DjyUserId;
await _codeCarrierRep.InsertAsync(entity);
await GetAllCarrier();
-
+
}
///
@@ -128,11 +128,14 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
public async Task MappingCarrierList([FromQuery] MappingQueryDto input)
{
var list = await _sysCacheService.GetAllMappingCarrier();
-
- var queryList = list
+ //数量太多,不允许查询全部
+ if (string.IsNullOrEmpty(input.Module) || input.Module.Length < 1)
+ {
+ throw Oops.Bah("参数过多,请传入模块查询");
+ }
+ var queryList = list.Where(x => x.Module == input.Module)
.WhereIF(!string.IsNullOrEmpty(input.Code), x => x.Code.Contains(input.Code, System.StringComparison.CurrentCultureIgnoreCase))
- .WhereIF(!string.IsNullOrEmpty(input.MapCode), x => x.MapCode.Contains(input.MapCode, System.StringComparison.CurrentCultureIgnoreCase))
- .WhereIF(!string.IsNullOrEmpty(input.Module), x => x.Module == input.Module)
+ .WhereIF(!string.IsNullOrEmpty(input.MapCode), x => x.MapCode.Contains(input.MapCode, System.StringComparison.CurrentCultureIgnoreCase))
.WhereIF(!string.IsNullOrEmpty(input.MapName), x => x.MapName.Contains(input.MapName, System.StringComparison.CurrentCultureIgnoreCase));
return queryList.ToList();
}
@@ -148,7 +151,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
{
entity.GID = Guid.NewGuid().ToString();
entity.CreateTime = DateTime.Now;
- entity.CreateUser =UserManager.DjyUserId;
+ entity.CreateUser = UserManager.DjyUserId;
await _mappingCarrierRep.InsertAsync(entity);
}
else
@@ -174,11 +177,10 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
//数量太多,不允许查询全部
if (string.IsNullOrEmpty(input.Name) || input.Name.Length < 2)
{
- return new List();
+ throw Oops.Bah("参数过多,请传入船名查询");
}
List list = await _sysCacheService.GetAllCodeVessel();
-
var queryList = list.WhereIF(!string.IsNullOrEmpty(input.Name), x => x.Name.Contains(input.Name, System.StringComparison.CurrentCultureIgnoreCase));
return queryList.ToList();
@@ -207,12 +209,12 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
//数量太多,不允许查询全部
if (string.IsNullOrEmpty(input.Module) || input.Module.Length < 1)
{
- return new List();
+ throw Oops.Bah("参数过多,请传入模块查询");
}
List list = await _sysCacheService.GetAllMappingVessel();
- var queryList = list.WhereIF(!string.IsNullOrEmpty(input.Module), x => x.Module == input.Module)
+ var queryList = list.Where(x => x.Module == input.Module)
.WhereIF(!string.IsNullOrEmpty(input.MapName), x => x.MapName.Contains(input.MapName, System.StringComparison.CurrentCultureIgnoreCase));
return queryList.ToList();
@@ -310,12 +312,14 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
//数量太多,不允许查询全部
if (string.IsNullOrEmpty(input.Module) || input.Module.Length < 1)
{
- return new List();
+ throw Oops.Bah("参数过多,请传入模块查询");
}
List list = await _sysCacheService.GetAllMappingYard();
- var queryList = list.WhereIF(!string.IsNullOrEmpty(input.Module), x => x.Module == input.Module)
+ var queryList = list.Where(x => x.Module == input.Module)
+ .WhereIF(!string.IsNullOrEmpty(input.Code), x => x.Code.Contains(input.Code, System.StringComparison.CurrentCultureIgnoreCase))
+ .WhereIF(!string.IsNullOrEmpty(input.MapCode), x => x.MapCode.Contains(input.MapCode, System.StringComparison.CurrentCultureIgnoreCase))
.WhereIF(!string.IsNullOrEmpty(input.MapName), x => x.MapName.Contains(input.MapName, System.StringComparison.CurrentCultureIgnoreCase));
return queryList.ToList();
@@ -386,12 +390,14 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
//数量太多,不允许查询全部
if (string.IsNullOrEmpty(input.Module) || input.Module.Length < 1)
{
- return new List();
+ throw Oops.Bah("参数过多,请传入模块查询");
}
List list = await _sysCacheService.GetAllMappingPortLoad();
- var queryList = list.WhereIF(!string.IsNullOrEmpty(input.Module), x => x.Module == input.Module)
+ var queryList = list.Where(x => x.Module == input.Module)
+ .WhereIF(!string.IsNullOrEmpty(input.Code), x => x.Code.Contains(input.Code, System.StringComparison.CurrentCultureIgnoreCase))
+ .WhereIF(!string.IsNullOrEmpty(input.MapCode), x => x.MapCode.Contains(input.MapCode, System.StringComparison.CurrentCultureIgnoreCase))
.WhereIF(!string.IsNullOrEmpty(input.MapName), x => x.MapName.Contains(input.MapName, System.StringComparison.CurrentCultureIgnoreCase));
return queryList.ToList();
@@ -431,12 +437,6 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
[HttpGet("/commondb/portlist")]
public async Task PortList([FromQuery] NameQueryDto input)
{
- //数量太多,不允许查询全部
- if (string.IsNullOrEmpty(input.Name) || input.Name.Length < 2)
- {
- return new List();
- }
-
List list = await _sysCacheService.GetAllCodePort();
var queryList = list.WhereIF(!string.IsNullOrEmpty(input.Name), x => x.CnName.Contains(input.Name) || x.EnName.Contains(input.Name, System.StringComparison.CurrentCultureIgnoreCase));
@@ -467,12 +467,14 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
//数量太多,不允许查询全部
if (string.IsNullOrEmpty(input.Module) || input.Module.Length < 1)
{
- return new List();
+ throw Oops.Bah("参数过多,请传入模块查询");
}
List list = await _sysCacheService.GetAllMappingPort();
- var queryList = list.WhereIF(!string.IsNullOrEmpty(input.Module), x => x.Module == input.Module)
+ var queryList = list.Where(x => x.Module == input.Module)
+ .WhereIF(!string.IsNullOrEmpty(input.Code), x => x.Code.Contains(input.Code, System.StringComparison.CurrentCultureIgnoreCase))
+ .WhereIF(!string.IsNullOrEmpty(input.MapCode), x => x.MapCode.Contains(input.MapCode, System.StringComparison.CurrentCultureIgnoreCase))
.WhereIF(!string.IsNullOrEmpty(input.MapName), x => x.MapName.Contains(input.MapName, System.StringComparison.CurrentCultureIgnoreCase));
return queryList.ToList();
@@ -538,12 +540,14 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
//数量太多,不允许查询全部
if (string.IsNullOrEmpty(input.Module) || input.Module.Length < 1)
{
- return new List();
+ throw Oops.Bah("参数过多,请传入模块查询");
}
List list = await _sysCacheService.GetAllMappingPackage();
- var queryList = list.WhereIF(!string.IsNullOrEmpty(input.Module), x => x.Module == input.Module)
+ var queryList = list.Where(x => x.Module == input.Module)
+ .WhereIF(!string.IsNullOrEmpty(input.Code), x => x.Code.Contains(input.Code, System.StringComparison.CurrentCultureIgnoreCase))
+ .WhereIF(!string.IsNullOrEmpty(input.MapCode), x => x.MapCode.Contains(input.MapCode, System.StringComparison.CurrentCultureIgnoreCase))
.WhereIF(!string.IsNullOrEmpty(input.MapName), x => x.MapName.Contains(input.MapName, System.StringComparison.CurrentCultureIgnoreCase));
return queryList.ToList();
@@ -610,12 +614,14 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
//数量太多,不允许查询全部
if (string.IsNullOrEmpty(input.Module) || input.Module.Length < 1)
{
- return new List();
+ throw Oops.Bah("参数过多,请传入模块查询");
}
List list = await _sysCacheService.GetAllMappingService();
- var queryList = list.WhereIF(!string.IsNullOrEmpty(input.Module), x => x.Module == input.Module)
+ var queryList = list.Where(x => x.Module == input.Module)
+ .WhereIF(!string.IsNullOrEmpty(input.Code), x => x.Code.Contains(input.Code, System.StringComparison.CurrentCultureIgnoreCase))
+ .WhereIF(!string.IsNullOrEmpty(input.MapCode), x => x.MapCode.Contains(input.MapCode, System.StringComparison.CurrentCultureIgnoreCase))
.WhereIF(!string.IsNullOrEmpty(input.MapName), x => x.MapName.Contains(input.MapName, System.StringComparison.CurrentCultureIgnoreCase));
return queryList.ToList();
@@ -682,14 +688,18 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
[HttpGet("/commondb/mappingctnlist")]
public async Task MappingCtnList([FromQuery] MappingQueryDto input)
{
+ //数量太多,不允许查询全部
+ if (string.IsNullOrEmpty(input.Module) || input.Module.Length < 1)
+ {
+ throw Oops.Bah("参数过多,请传入模块查询");
+ }
var list = await _sysCacheService.GetAllMappingCtn();
- var queryList = list
+ var queryList = list.Where(x => x.Module == input.Module)
.WhereIF(!string.IsNullOrEmpty(input.Code), x => x.Code.Contains(input.Code, System.StringComparison.CurrentCultureIgnoreCase))
- .WhereIF(!string.IsNullOrEmpty(input.MapCode), x => x.MapCode.Contains(input.MapCode, System.StringComparison.CurrentCultureIgnoreCase))
- .WhereIF(!string.IsNullOrEmpty(input.Module), x => x.Module == input.Module)
+ .WhereIF(!string.IsNullOrEmpty(input.MapCode), x => x.MapCode.Contains(input.MapCode, System.StringComparison.CurrentCultureIgnoreCase))
.WhereIF(!string.IsNullOrEmpty(input.MapName), x => x.MapName.Contains(input.MapName, System.StringComparison.CurrentCultureIgnoreCase));
-
+
return queryList.ToList();
}
@@ -754,13 +764,16 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
///
[HttpGet("/commondb/mappingfrtlist")]
public async Task MappingFrtList([FromQuery] MappingQueryDto input)
- {
+ { //数量太多,不允许查询全部
+ if (string.IsNullOrEmpty(input.Module) || input.Module.Length < 1)
+ {
+ throw Oops.Bah("参数过多,请传入模块查询");
+ }
var list = await _sysCacheService.GetAllMappingFrt();
- var queryList = list
+ var queryList = list.Where(x => x.Module == input.Module)
.WhereIF(!string.IsNullOrEmpty(input.Code), x => x.Code.Contains(input.Code, System.StringComparison.CurrentCultureIgnoreCase))
- .WhereIF(!string.IsNullOrEmpty(input.MapCode), x => x.MapCode.Contains(input.MapCode, System.StringComparison.CurrentCultureIgnoreCase))
- .WhereIF(!string.IsNullOrEmpty(input.Module), x => x.Module == input.Module)
+ .WhereIF(!string.IsNullOrEmpty(input.MapCode), x => x.MapCode.Contains(input.MapCode, System.StringComparison.CurrentCultureIgnoreCase))
.WhereIF(!string.IsNullOrEmpty(input.MapName), x => x.MapName.Contains(input.MapName, System.StringComparison.CurrentCultureIgnoreCase));
return queryList.ToList();
@@ -845,11 +858,20 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
[NonAction]
public async Task> GetAllVessel()
{
- _logger.LogInformation("缓存船名!");
- var list = await _codeVesselRep.ToListAsync();
- _logger.LogInformation(list.ToJsonString());
- await _sysCacheService.SetAllCodeVessel(list);
- return list;
+ try
+ {
+ _logger.LogInformation("缓存船名!");
+ var list = await _codeVesselRep.ToListAsync();
+ _logger.LogInformation(list.ToJsonString());
+ await _sysCacheService.SetAllCodeVessel(list);
+ return list;
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError("船名" + ex);
+ throw;
+ }
+
}
[NonAction]
@@ -949,11 +971,11 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
[NonAction]
public async Task> GetAllFrt()
{
-
+
var list = await _codeFrtRep.ToListAsync();
await _sysCacheService.SetAllCodeFrt(list);
return list;
-
+
}
[NonAction]
public async Task> GetAllMappingFrt()
diff --git a/Myshipping.Report/Myshipping.Report.csproj.user b/Myshipping.Report/Myshipping.Report.csproj.user
index 5831b7bf..c54031d1 100644
--- a/Myshipping.Report/Myshipping.Report.csproj.user
+++ b/Myshipping.Report/Myshipping.Report.csproj.user
@@ -8,7 +8,7 @@
- Debug|Any CPU
+ Release|Any CPU