optimize
wet 1 year ago
parent 52bf2d1554
commit 231958908b

@ -251,16 +251,12 @@ namespace Myshipping.Application
await _rep.UpdateAsync(x => x.Id == Id, x => new BookingOrderSFExpressDelivery { IsDeleted = true });
await _detail.DeleteAsync(x => x.PId == Id);
await _business.DeleteAsync(x => x.PId == Id);
}
}
else
{
throw Oops.Bah("请上传正确参数");
}
}
/// <summary>

@ -198,6 +198,14 @@ public class CommonConst
/// </summary>
public const string DJY_CONST = "DJY_CONST";
/// <summary>
/// 城市信息
/// </summary>
public const string CACHE_KEY_COMMON_DB_CITY= "CommonDbCodeCity";
/// <summary>
/// 省份信息
/// </summary>
public const string CACHE_KEY_COMMON_DB_PROVINCE = "CommonDbCodeProvince";
#endregion
public const string API_USER_HEADER_KEY = "USER_KEY";

@ -104,9 +104,11 @@ namespace Myshipping.Core.Job
//国家
await App.GetService<ICommonDBService>().GetAllCountry(true);
//城市
await App.GetService<ICommonDBService>().GetAllCity(true);
//省份
await App.GetService<ICommonDBService>().GetAllProvince(true);
Log.Information($"缓存公共库完成 {DateTime.Now}");
}

@ -386,5 +386,35 @@ public interface ISysCacheService
/// <returns></returns>
Task SetAllSysConfig(List<SysConfig> list);
/// <summary>
/// 获取公共库城市信息
/// </summary>
/// <returns></returns>
Task<List<CodeCity>> GetAllCodeCity();
/// <summary>
/// 获取公共库 省份信息
/// </summary>
/// <returns></returns>
Task<List<CodeProvince>> GetAllCodeProvince();
/// <summary>
/// 设置公共库城市信息
/// </summary>
/// <returns></returns>
Task SetAllCodeCity(List<CodeCity> list);
/// <summary>
/// 设置公共库省份信息
/// </summary>
/// <returns></returns>
Task SetAllCodeProvince(List<CodeProvince> list);
#endregion
}

@ -829,5 +829,39 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet
}
/// <summary>
/// 获取公共库 城市信息
/// </summary>
/// <returns></returns>
public Task<List<CodeCity>> GetAllCodeCity()
{
return _cache.GetAsync<List<CodeCity>>(CommonConst.CACHE_KEY_COMMON_DB_CITY);
}
/// <summary>
/// 获取公共库 城市信息
/// </summary>
/// <returns></returns>
public Task<List<CodeProvince>> GetAllCodeProvince()
{
return _cache.GetAsync<List<CodeProvince>>(CommonConst.CACHE_KEY_COMMON_DB_PROVINCE);
}
/// <summary>
/// 设置公共库 城市信息
/// </summary>
/// <returns></returns>
public Task SetAllCodeCity(List<CodeCity> list)
{
return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_CITY, list);
}
/// <summary>
/// 设置公共库 城市信息
/// </summary>
/// <returns></returns>
public Task SetAllCodeProvince(List<CodeProvince> list)
{
return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_PROVINCE, list);
}
#endregion
}

@ -49,6 +49,8 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
private readonly SqlSugarRepository<RelaPortCarrierLane> _relaPortCarrierLaneRep;
private readonly SqlSugarRepository<CodeCountry> _codeCountryRep;
private readonly SqlSugarRepository<MappingForwarder> _mappingForwarder;
private readonly SqlSugarRepository<CodeCity> _codeCityRep;
private readonly SqlSugarRepository<CodeProvince> _codeProvinceRep;
public CommonDBService(SqlSugarRepository<CodeCarrier> codeCarrierRep,
SqlSugarRepository<CodeVessel> codeVesselRep,
SqlSugarRepository<CodeForwarder> codeForwarderRep,
@ -65,19 +67,22 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
SqlSugarRepository<MappingFrt> mappingFrtRep,
SqlSugarRepository<MappingYard> mappingYardRep,
SqlSugarRepository<MappingPortLoad> mappingPortLoadRep,
SqlSugarRepository<MappingPort> mappingPortRep,
SqlSugarRepository<MappingPackage> mappingPackageRep,
SqlSugarRepository<MappingService> mappingServiceRep,
SqlSugarRepository<CodeIssueType> codeIssueTypeRep,
SqlSugarRepository<CommonModule> commonModuleRep,
ILogger<CommonDBService> logger,
ISysCacheService sysCacheService,
SqlSugarRepository<CodeLane> codeLaneRep,
SqlSugarRepository<RelaPortCarrierLane> relaPortCarrierLaneRep,
SqlSugarRepository<MappingIssueType> mappingIssueTypeRep,
SqlSugarRepository<CodeCountry> codeCountryRep,
SqlSugarRepository<MappingForwarder> mappingForwarder)
{
SqlSugarRepository<MappingPort> mappingPortRep,
SqlSugarRepository<MappingPackage> mappingPackageRep,
SqlSugarRepository<MappingService> mappingServiceRep,
SqlSugarRepository<CodeIssueType> codeIssueTypeRep,
SqlSugarRepository<CommonModule> commonModuleRep,
ILogger<CommonDBService> logger,
ISysCacheService sysCacheService,
SqlSugarRepository<CodeLane> codeLaneRep,
SqlSugarRepository<RelaPortCarrierLane> relaPortCarrierLaneRep,
SqlSugarRepository<MappingIssueType> mappingIssueTypeRep,
SqlSugarRepository<CodeCountry> codeCountryRep,
SqlSugarRepository<MappingForwarder> mappingForwarder,
SqlSugarRepository<CodeCity> codeCityRep,
SqlSugarRepository<CodeProvince> codeProvinceRep
)
{
_codeCarrierRep = codeCarrierRep;
_codeVesselRep = codeVesselRep;
_codeForwarderRep = codeForwarderRep;
@ -106,6 +111,9 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
_codeCountryRep = codeCountryRep;
_mappingIssueTypeRep = mappingIssueTypeRep;
_mappingForwarder = mappingForwarder;
_codeCityRep = codeCityRep;
_codeProvinceRep = codeProvinceRep;
}
#endregion
@ -1357,7 +1365,36 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
#endregion
#region 获取省市
/// <summary>
/// 获取城市信息
/// </summary>
[HttpGet("/commondb/CodeCityList")]
public async Task<dynamic> CodeCityList(string Provincecode,string name)
{
List<CodeCity> list = await _sysCacheService.GetAllCodeCity();
var queryList = list.WhereIF(!string.IsNullOrEmpty(Provincecode), x => x.ProvinceCode == Provincecode).WhereIF(!string.IsNullOrEmpty(name), x => x.CNName.Contains(name)).ToList();
return queryList.OrderBy(x => x.Sort).ToList();
}
/// <summary>
/// 获取省份信息
/// </summary>
[HttpGet("/commondb/CodeProvinceList")]
public async Task<dynamic> CodeProvinceList(string name)
{
List<CodeProvince> list = await _sysCacheService.GetAllCodeProvince();
var queryList = list.Where( x => x.Country == "CN").WhereIF(!string.IsNullOrEmpty(name), x => x.CNName.Contains(name)).ToList();
return queryList.OrderBy(x => x.Sort).ToList();
}
#endregion
#region 模块列表
/// <summary>
@ -2100,6 +2137,57 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
}
}
/// <summary>
/// 获取城市信息
/// </summary>
/// <param name="flag"></param>
/// <returns></returns>
[NonAction]
public async Task GetAllCity(bool flag = false)
{
if (flag)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_CITY))
{
var list = await _codeCityRep.AsQueryable().OrderBy(x => x.Sort).ToListAsync();
await _sysCacheService.SetAllCodeCity(list);
}
}
else
{
var list = await _codeCityRep.AsQueryable().OrderBy(x => x.Sort).ToListAsync();
await _sysCacheService.SetAllCodeCity(list);
}
}
/// <summary>
/// 获取省份信息
/// </summary>
/// <param name="flag"></param>
/// <returns></returns>
[NonAction]
public async Task GetAllProvince(bool flag = false)
{
if (flag)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_PROVINCE))
{
var list = await _codeProvinceRep.AsQueryable().OrderBy(x => x.Sort).ToListAsync();
await _sysCacheService.SetAllCodeProvince(list);
}
}
else
{
var list = await _codeProvinceRep.AsQueryable().OrderBy(x => x.Sort).ToListAsync();
await _sysCacheService.SetAllCodeProvince(list);
}
}
#endregion

@ -143,6 +143,8 @@ public interface ICommonDBService
Task GetAllMappingIssueType(bool flag);
Task GetAllMappingForwarder(bool flag = false);
Task GetAllCity(bool flag = false);
Task GetAllProvince(bool flag = false);
/// <summary>
/// 保存航线信息

Loading…
Cancel
Save