更新限额配置时更新缓存
This commit is contained in:
@@ -10,6 +10,14 @@ namespace YLErp.Cache
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool CacheEnable();
|
||||
|
||||
/// <summary>
|
||||
/// 删除缓存
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
bool DeleteKey(string key);
|
||||
|
||||
/// <summary>
|
||||
/// 字符串数据类型的保存
|
||||
/// </summary>
|
||||
|
||||
@@ -44,6 +44,11 @@ namespace YLErp.Cache
|
||||
return _cacheConfig.Value.Enable;
|
||||
}
|
||||
|
||||
public bool DeleteKey(string key)
|
||||
{
|
||||
return db.KeyDelete(key);
|
||||
}
|
||||
|
||||
public bool StringSet(string key, string value)
|
||||
{
|
||||
return db.StringSet(GenerateKey(key), value);
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using YLErp.Enums;
|
||||
|
||||
namespace YLErp.Commons
|
||||
{
|
||||
/// <summary>
|
||||
/// 风控配置 缓存key
|
||||
/// </summary>
|
||||
public class RiskCfgRedisKey
|
||||
{
|
||||
/// <summary>
|
||||
/// 互换维度-名义本金
|
||||
/// </summary>
|
||||
private static string SWAP_PRINCIPAL = "risk:cfg:swap:principal";
|
||||
|
||||
/// <summary>
|
||||
/// 标的维度-名义本金
|
||||
/// </summary>
|
||||
private static string ASSET_PRINCIPAL = "risk:cfg:asset:principal";
|
||||
|
||||
/// <summary>
|
||||
/// 标的维度-轧差集中度
|
||||
/// </summary>
|
||||
private static string ASSET_ROLL = "risk:cfg:asset:roll";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 交易维度-价格偏离度
|
||||
/// </summary>
|
||||
private static string TRADE_PRICE_RATE = "risk:cfg:trade:price_rate";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 客户维度-名义本金
|
||||
/// </summary>
|
||||
private static string CLIENT_PRINCIPAL = "risk:cfg:client:principal";
|
||||
|
||||
|
||||
|
||||
public static string GetKey(QuotaTypeEnum quoteType,string quoteIndex)
|
||||
{
|
||||
switch (quoteType)
|
||||
{
|
||||
case QuotaTypeEnum.GLOBAL_SWAP:
|
||||
return SWAP_PRINCIPAL;
|
||||
case QuotaTypeEnum.UNDERLYING:
|
||||
if ("轧差名义本金".Equals(quoteIndex))
|
||||
{
|
||||
return ASSET_PRINCIPAL;
|
||||
}
|
||||
return ASSET_ROLL;
|
||||
case QuotaTypeEnum.TRADE:
|
||||
return TRADE_PRICE_RATE;
|
||||
case QuotaTypeEnum.CLIENT:
|
||||
return CLIENT_PRINCIPAL;
|
||||
default:
|
||||
throw new Exception("不支持的维度类型");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ using YLErp.BLL.Calculation;
|
||||
using YLErp.BLL.Eod;
|
||||
using YLErp.BLL.EodSettlement;
|
||||
using YLErp.BLL.Hedge;
|
||||
using YLErp.Cache;
|
||||
using YLErp.Commons;
|
||||
using YLErp.DataBase;
|
||||
using YLErp.DBModels;
|
||||
@@ -3789,15 +3790,15 @@ namespace YLErp.Modules.RiskModule
|
||||
return settings;
|
||||
}
|
||||
|
||||
public void ApprovalQuotaSetting(List<ApprovalReqq> req)
|
||||
public void ApprovalQuotaSetting(List<ApprovalReqq> req,IYLCache yLCache)
|
||||
{
|
||||
foreach (var item in req)
|
||||
{
|
||||
ApprovalQuotaSetting(item);
|
||||
ApprovalQuotaSetting(item,yLCache);
|
||||
}
|
||||
}
|
||||
|
||||
public void ApprovalQuotaSetting(ApprovalReqq req)
|
||||
public void ApprovalQuotaSetting(ApprovalReqq req, IYLCache yLCache)
|
||||
{
|
||||
var obj = DbContext.quotaSetting.Where(O => O.id == req.id).FirstOrDefault();
|
||||
if (obj.Status == QuotaSettingApprovalStatus.Pending_Approval)
|
||||
@@ -3847,6 +3848,10 @@ namespace YLErp.Modules.RiskModule
|
||||
CreateTime = DateTime.Now
|
||||
});
|
||||
}
|
||||
|
||||
//删除限额监控设置缓存
|
||||
var redisKey = RiskCfgRedisKey.GetKey(obj.QuotaType,obj.QuotaIndex);
|
||||
yLCache.DeleteKey(redisKey);
|
||||
break;
|
||||
case "reject":
|
||||
obj.Status = QuotaSettingApprovalStatus.Rejected;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using YLErp.BLL.Eod;
|
||||
using YLErp.Cache;
|
||||
using YLErp.Enums;
|
||||
using YLErp.Model.HengTaiModel;
|
||||
using YLErp.Modules.ApiModule;
|
||||
@@ -18,6 +19,13 @@ namespace YLErp.Web.Controllers
|
||||
{
|
||||
public class riskController : BaseController
|
||||
{
|
||||
|
||||
private IYLCache _yLCache;
|
||||
public riskController(IYLCache yLCache)
|
||||
{
|
||||
_yLCache = yLCache;
|
||||
}
|
||||
|
||||
[MyAuthorize("风险控制-市场风险")]
|
||||
public ActionResult RiskExposureReport()
|
||||
{
|
||||
@@ -571,7 +579,7 @@ namespace YLErp.Web.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
new QuotaMonitorService(CurUser).ApprovalQuotaSetting(req);
|
||||
new QuotaMonitorService(CurUser).ApprovalQuotaSetting(req,_yLCache);
|
||||
return JsonSuccess("操作成功");
|
||||
}
|
||||
catch (ServiceException ex)
|
||||
|
||||
Reference in New Issue
Block a user