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 _rep.UpdateAsync(x => x.Id == Id, x => new BookingOrderSFExpressDelivery { IsDeleted = true });
await _detail.DeleteAsync(x => x.PId == Id); await _detail.DeleteAsync(x => x.PId == Id);
await _business.DeleteAsync(x => x.PId == Id); await _business.DeleteAsync(x => x.PId == Id);
} }
} }
else else
{ {
throw Oops.Bah("请上传正确参数"); throw Oops.Bah("请上传正确参数");
} }
} }
/// <summary> /// <summary>

@ -198,6 +198,14 @@ public class CommonConst
/// </summary> /// </summary>
public const string DJY_CONST = "DJY_CONST"; 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 #endregion
public const string API_USER_HEADER_KEY = "USER_KEY"; 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>().GetAllCountry(true);
//城市
await App.GetService<ICommonDBService>().GetAllCity(true);
//省份
await App.GetService<ICommonDBService>().GetAllProvince(true);
Log.Information($"缓存公共库完成 {DateTime.Now}"); Log.Information($"缓存公共库完成 {DateTime.Now}");
} }

@ -386,5 +386,35 @@ public interface ISysCacheService
/// <returns></returns> /// <returns></returns>
Task SetAllSysConfig(List<SysConfig> list); 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 #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 #endregion
} }

@ -49,6 +49,8 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
private readonly SqlSugarRepository<RelaPortCarrierLane> _relaPortCarrierLaneRep; private readonly SqlSugarRepository<RelaPortCarrierLane> _relaPortCarrierLaneRep;
private readonly SqlSugarRepository<CodeCountry> _codeCountryRep; private readonly SqlSugarRepository<CodeCountry> _codeCountryRep;
private readonly SqlSugarRepository<MappingForwarder> _mappingForwarder; private readonly SqlSugarRepository<MappingForwarder> _mappingForwarder;
private readonly SqlSugarRepository<CodeCity> _codeCityRep;
private readonly SqlSugarRepository<CodeProvince> _codeProvinceRep;
public CommonDBService(SqlSugarRepository<CodeCarrier> codeCarrierRep, public CommonDBService(SqlSugarRepository<CodeCarrier> codeCarrierRep,
SqlSugarRepository<CodeVessel> codeVesselRep, SqlSugarRepository<CodeVessel> codeVesselRep,
SqlSugarRepository<CodeForwarder> codeForwarderRep, SqlSugarRepository<CodeForwarder> codeForwarderRep,
@ -65,19 +67,22 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
SqlSugarRepository<MappingFrt> mappingFrtRep, SqlSugarRepository<MappingFrt> mappingFrtRep,
SqlSugarRepository<MappingYard> mappingYardRep, SqlSugarRepository<MappingYard> mappingYardRep,
SqlSugarRepository<MappingPortLoad> mappingPortLoadRep, SqlSugarRepository<MappingPortLoad> mappingPortLoadRep,
SqlSugarRepository<MappingPort> mappingPortRep, SqlSugarRepository<MappingPort> mappingPortRep,
SqlSugarRepository<MappingPackage> mappingPackageRep, SqlSugarRepository<MappingPackage> mappingPackageRep,
SqlSugarRepository<MappingService> mappingServiceRep, SqlSugarRepository<MappingService> mappingServiceRep,
SqlSugarRepository<CodeIssueType> codeIssueTypeRep, SqlSugarRepository<CodeIssueType> codeIssueTypeRep,
SqlSugarRepository<CommonModule> commonModuleRep, SqlSugarRepository<CommonModule> commonModuleRep,
ILogger<CommonDBService> logger, ILogger<CommonDBService> logger,
ISysCacheService sysCacheService, ISysCacheService sysCacheService,
SqlSugarRepository<CodeLane> codeLaneRep, SqlSugarRepository<CodeLane> codeLaneRep,
SqlSugarRepository<RelaPortCarrierLane> relaPortCarrierLaneRep, SqlSugarRepository<RelaPortCarrierLane> relaPortCarrierLaneRep,
SqlSugarRepository<MappingIssueType> mappingIssueTypeRep, SqlSugarRepository<MappingIssueType> mappingIssueTypeRep,
SqlSugarRepository<CodeCountry> codeCountryRep, SqlSugarRepository<CodeCountry> codeCountryRep,
SqlSugarRepository<MappingForwarder> mappingForwarder) SqlSugarRepository<MappingForwarder> mappingForwarder,
{ SqlSugarRepository<CodeCity> codeCityRep,
SqlSugarRepository<CodeProvince> codeProvinceRep
)
{
_codeCarrierRep = codeCarrierRep; _codeCarrierRep = codeCarrierRep;
_codeVesselRep = codeVesselRep; _codeVesselRep = codeVesselRep;
_codeForwarderRep = codeForwarderRep; _codeForwarderRep = codeForwarderRep;
@ -106,6 +111,9 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
_codeCountryRep = codeCountryRep; _codeCountryRep = codeCountryRep;
_mappingIssueTypeRep = mappingIssueTypeRep; _mappingIssueTypeRep = mappingIssueTypeRep;
_mappingForwarder = mappingForwarder; _mappingForwarder = mappingForwarder;
_codeCityRep = codeCityRep;
_codeProvinceRep = codeProvinceRep;
} }
#endregion #endregion
@ -1357,7 +1365,36 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
#endregion #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 模块列表 #region 模块列表
/// <summary> /// <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 #endregion

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

Loading…
Cancel
Save