diff --git a/YLErpDAL/Modules/SwapModule/RiskCacheService.cs b/YLErpDAL/Modules/SwapModule/RiskCacheService.cs
new file mode 100644
index 00000000..a41051e6
--- /dev/null
+++ b/YLErpDAL/Modules/SwapModule/RiskCacheService.cs
@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using YLErp.Helpers;
+using YLErp.Modules.SwapModule.Dto;
+
+namespace YLErp.Modules.SwapModule
+{
+ public class RiskCacheService
+ {
+ public RiskCacheService() { }
+
+ ///
+ /// 刷新风控缓存
+ ///
+ ///
+ public void refreshRiskCache(Dictionary> clientUmsDic)
+ {
+ if (clientUmsDic == null || clientUmsDic.Count == 0)
+ {
+ return;
+ }
+ Task.Run(() => {
+ try
+ {
+ //发送http请求
+ var baseUrl = Environment.GetEnvironmentVariable("BondOmsInterface_BaseUrl");
+
+ if (!string.IsNullOrEmpty(baseUrl))
+ {
+ var httpHelper = new HttpHelper(baseUrl, null);
+ var url = $"{baseUrl}/riskJob/refreshClientRiskCache";
+ foreach (var item in clientUmsDic)
+ {
+ var clientId = item.Key;
+ var underlyingCodes = item.Value;
+ //请求参数
+ RefreshFrozenCashCacheReq req = new RefreshFrozenCashCacheReq(clientId, underlyingCodes);
+ // http 请求 Web项目接口
+ var result = httpHelper.PostRequestNoAuth(url, req).Result;
+ if (result != null && !result.success)
+ {
+ LogFactory.GetLogger("刷新风控缓存").Info("刷新风控缓存:" + result.message);
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ LogFactory.GetLogger("刷新风控缓存").Error("刷新风控缓存:" + ex.Message);
+ }
+ });
+ }
+ }
+}
diff --git a/YLErpDAL/Modules/SwapModule/SwapFlowImportService.cs b/YLErpDAL/Modules/SwapModule/SwapFlowImportService.cs
index 5a39abbe..3246277b 100644
--- a/YLErpDAL/Modules/SwapModule/SwapFlowImportService.cs
+++ b/YLErpDAL/Modules/SwapModule/SwapFlowImportService.cs
@@ -79,6 +79,7 @@ namespace YLErp.Modules.SwapModule
var reader = new DataRowReaderHelper(table);
rowIndex = 1;
totalNum = table.Rows.Count - rowIndex;
+ Dictionary> clientUmsDic = new Dictionary>();
foreach (var row in table.Rows.Cast().Skip(rowIndex))
{
rowIndex++;
@@ -134,6 +135,17 @@ namespace YLErp.Modules.SwapModule
swap_flow.OptName = UserName;
swap_flow.OptTime = DateTime.Now;
DbContext.swap_flow.Add(swap_flow);
+ if (!clientUmsDic.ContainsKey(swap_flow.ClientId ?? 0))
+ {
+ clientUmsDic.Add(swap_flow.ClientId ?? 0, new List { swap_flow.UnderlyingCode });
+ }
+ else
+ {
+ if (!clientUmsDic[swap_flow.ClientId ?? 0].Contains(swap_flow.UnderlyingCode))
+ {
+ clientUmsDic[swap_flow.ClientId ?? 0].Add(swap_flow.UnderlyingCode);
+ }
+ }
successNum++;
}
DbContext.SaveChanges();
@@ -141,6 +153,7 @@ namespace YLErp.Modules.SwapModule
{
RealtimePnlCalc.RealtimeSwapPosition(new OptUserInfo(0, "互换实时持仓服务", OptUserFrom.Service));
});
+ new RiskCacheService().refreshRiskCache(clientUmsDic);
}
catch (Exception ex)
{
diff --git a/YLErpDAL/Modules/SwapModule/SwapFlowService.cs b/YLErpDAL/Modules/SwapModule/SwapFlowService.cs
index dff60649..7f10aabe 100644
--- a/YLErpDAL/Modules/SwapModule/SwapFlowService.cs
+++ b/YLErpDAL/Modules/SwapModule/SwapFlowService.cs
@@ -484,6 +484,10 @@ namespace YLErp.Modules.SwapModule
RealtimePnlCalc.RealtimeSwapPosition(new OptUserInfo(0, "互换实时持仓服务", OptUserFrom.Service));
});
DbContext.SaveChanges();
+
+ Dictionary> clientUmsDic = new Dictionary>();
+ clientUmsDic.Add(swap_Flow.ClientId ?? 0, new List { swap_Flow.UnderlyingCode });
+ new RiskCacheService().refreshRiskCache(clientUmsDic);
}
///
@@ -554,6 +558,9 @@ namespace YLErp.Modules.SwapModule
{
RealtimePnlCalc.RealtimeSwapPosition(new OptUserInfo(0, "互换实时持仓服务", OptUserFrom.Service));
});
+ Dictionary> clientUmsDic = new Dictionary>();
+ clientUmsDic.Add(capitalAccount.ClientId ?? 0, new List { capitalAccount.UnderlyingCode });
+ new RiskCacheService().refreshRiskCache(clientUmsDic);
}
///
/// 删除流水
diff --git a/YLErpDAL/Modules/SwapModule/SwapTradeAutoService.cs b/YLErpDAL/Modules/SwapModule/SwapTradeAutoService.cs
index 479d5c39..b3966c9a 100644
--- a/YLErpDAL/Modules/SwapModule/SwapTradeAutoService.cs
+++ b/YLErpDAL/Modules/SwapModule/SwapTradeAutoService.cs
@@ -502,47 +502,7 @@ namespace YLErp.Modules.SwapModule
return clientUmsDic;
}
- ///
- /// 刷新冻结资金缓存
- ///
- ///
- public void refreshFrozenCashCache(Dictionary> clientUmsDic)
- {
- if (clientUmsDic == null || clientUmsDic.Count == 0)
- {
- return;
- }
- Task.Run(() => {
- try
- {
- //发送http请求
- var baseUrl = Environment.GetEnvironmentVariable("BondOmsInterface_BaseUrl");
-
- if (!string.IsNullOrEmpty(baseUrl))
- {
- var httpHelper = new HttpHelper(baseUrl, null);
- var url = $"{baseUrl}/riskJob/refreshClientFrozenCash";
- foreach (var item in clientUmsDic)
- {
- var clientId = item.Key;
- var underlyingCodes = item.Value;
- //请求参数
- RefreshFrozenCashCacheReq req = new RefreshFrozenCashCacheReq(clientId, underlyingCodes);
- // http 请求 Web项目接口
- var result = httpHelper.PostRequestNoAuth(url, req).Result;
- if (result != null && !result.success)
- {
- LogFactory.GetLogger("刷新冻结资金").Info("刷新冻结资金:" + result.message);
- }
- }
- }
- }
- catch (Exception ex)
- {
- LogFactory.GetLogger("刷新冻结资金").Error("刷新冻结资金:" + ex.Message);
- }
- });
- }
+
public void UpdateSwapFlowState(List swapFlows)
{
diff --git a/YLErpWeb/Hubs/SwapFlowCombookingHub.cs b/YLErpWeb/Hubs/SwapFlowCombookingHub.cs
index 9b3cd3be..3183b55b 100644
--- a/YLErpWeb/Hubs/SwapFlowCombookingHub.cs
+++ b/YLErpWeb/Hubs/SwapFlowCombookingHub.cs
@@ -95,7 +95,7 @@ namespace YLErp.Web.Hubs
service.UpdateSwapFlowState(swapFlows);
currentStep = "流水簿记完毕";
await client.SendAsync("ProcessCompleted", currentStep);
- service.refreshFrozenCashCache(clientUmsDic);
+ new RiskCacheService().refreshRiskCache(clientUmsDic);
isProcessing = false;
}
catch (Exception ex)
diff --git a/YLErpWeb/Hubs/SwapFlowResetHub.cs b/YLErpWeb/Hubs/SwapFlowResetHub.cs
index db5474f6..3328d068 100644
--- a/YLErpWeb/Hubs/SwapFlowResetHub.cs
+++ b/YLErpWeb/Hubs/SwapFlowResetHub.cs
@@ -54,7 +54,7 @@ namespace YLErp.Web.Hubs
}, tradeIds);
isProcessing = false;
await client.SendAsync("ProcessCompleted", "");
- service.refreshFrozenCashCache(clientUmsDic);
+ new RiskCacheService().refreshRiskCache(clientUmsDic);
}
catch (Exception ex)
{