From b3ddc1c898103cebf601ad9af22f3c0547efaec9 Mon Sep 17 00:00:00 2001
From: yexuzhong <120511780@qq.com>
Date: Tue, 19 Aug 2025 15:55:52 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=99=90=E9=A2=9D=E9=85=8D?=
=?UTF-8?q?=E7=BD=AE=E6=97=B6=E6=9B=B4=E6=96=B0=E7=BC=93=E5=AD=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Framework/YLErp.Cache/IYLCache.cs | 8 +++
Framework/YLErp.Cache/YLRedisCache.cs | 5 ++
.../YLErp.Core/Commons/RiskCfgRedisKey.cs | 66 +++++++++++++++++++
.../Modules/RiskModule/QuotaMonitorService.cs | 11 +++-
YLErpWeb/Controllers/riskController.cs | 10 ++-
5 files changed, 96 insertions(+), 4 deletions(-)
create mode 100644 Framework/YLErp.Core/Commons/RiskCfgRedisKey.cs
diff --git a/Framework/YLErp.Cache/IYLCache.cs b/Framework/YLErp.Cache/IYLCache.cs
index d3aa202d..dc37752c 100644
--- a/Framework/YLErp.Cache/IYLCache.cs
+++ b/Framework/YLErp.Cache/IYLCache.cs
@@ -10,6 +10,14 @@ namespace YLErp.Cache
///
///
bool CacheEnable();
+
+ ///
+ /// 删除缓存
+ ///
+ ///
+ ///
+ bool DeleteKey(string key);
+
///
/// 字符串数据类型的保存
///
diff --git a/Framework/YLErp.Cache/YLRedisCache.cs b/Framework/YLErp.Cache/YLRedisCache.cs
index 6097729a..93c9d3f0 100644
--- a/Framework/YLErp.Cache/YLRedisCache.cs
+++ b/Framework/YLErp.Cache/YLRedisCache.cs
@@ -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);
diff --git a/Framework/YLErp.Core/Commons/RiskCfgRedisKey.cs b/Framework/YLErp.Core/Commons/RiskCfgRedisKey.cs
new file mode 100644
index 00000000..aff0be48
--- /dev/null
+++ b/Framework/YLErp.Core/Commons/RiskCfgRedisKey.cs
@@ -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
+{
+ ///
+ /// 风控配置 缓存key
+ ///
+ public class RiskCfgRedisKey
+ {
+ ///
+ /// 互换维度-名义本金
+ ///
+ private static string SWAP_PRINCIPAL = "risk:cfg:swap:principal";
+
+ ///
+ /// 标的维度-名义本金
+ ///
+ private static string ASSET_PRINCIPAL = "risk:cfg:asset:principal";
+
+ ///
+ /// 标的维度-轧差集中度
+ ///
+ private static string ASSET_ROLL = "risk:cfg:asset:roll";
+
+
+ ///
+ /// 交易维度-价格偏离度
+ ///
+ private static string TRADE_PRICE_RATE = "risk:cfg:trade:price_rate";
+
+
+ ///
+ /// 客户维度-名义本金
+ ///
+ 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("不支持的维度类型");
+
+ }
+ }
+ }
+}
diff --git a/YLErpDAL/Modules/RiskModule/QuotaMonitorService.cs b/YLErpDAL/Modules/RiskModule/QuotaMonitorService.cs
index 1546ff3b..0dbb23d9 100644
--- a/YLErpDAL/Modules/RiskModule/QuotaMonitorService.cs
+++ b/YLErpDAL/Modules/RiskModule/QuotaMonitorService.cs
@@ -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 req)
+ public void ApprovalQuotaSetting(List 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;
diff --git a/YLErpWeb/Controllers/riskController.cs b/YLErpWeb/Controllers/riskController.cs
index 19b6faa8..3ffac39b 100644
--- a/YLErpWeb/Controllers/riskController.cs
+++ b/YLErpWeb/Controllers/riskController.cs
@@ -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)