修改 删除 导入 流水 更新风控缓存
This commit is contained in:
@@ -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() { }
|
||||
|
||||
/// <summary>
|
||||
/// 刷新风控缓存
|
||||
/// </summary>
|
||||
/// <param name="clientUmsDic"></param>
|
||||
public void refreshRiskCache(Dictionary<long, List<string>> 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<RefreshFrozenCashCacheReq, RefreshFrozenCashCacheResp>(url, req).Result;
|
||||
if (result != null && !result.success)
|
||||
{
|
||||
LogFactory.GetLogger("刷新风控缓存").Info("刷新风控缓存:" + result.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogFactory.GetLogger("刷新风控缓存").Error("刷新风控缓存:" + ex.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,6 +79,7 @@ namespace YLErp.Modules.SwapModule
|
||||
var reader = new DataRowReaderHelper(table);
|
||||
rowIndex = 1;
|
||||
totalNum = table.Rows.Count - rowIndex;
|
||||
Dictionary<long, List<string>> clientUmsDic = new Dictionary<long, List<string>>();
|
||||
foreach (var row in table.Rows.Cast<DataRow>().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<string> { 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)
|
||||
{
|
||||
|
||||
@@ -484,6 +484,10 @@ namespace YLErp.Modules.SwapModule
|
||||
RealtimePnlCalc.RealtimeSwapPosition(new OptUserInfo(0, "互换实时持仓服务", OptUserFrom.Service));
|
||||
});
|
||||
DbContext.SaveChanges();
|
||||
|
||||
Dictionary<long, List<string>> clientUmsDic = new Dictionary<long, List<string>>();
|
||||
clientUmsDic.Add(swap_Flow.ClientId ?? 0, new List<string> { swap_Flow.UnderlyingCode });
|
||||
new RiskCacheService().refreshRiskCache(clientUmsDic);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -554,6 +558,9 @@ namespace YLErp.Modules.SwapModule
|
||||
{
|
||||
RealtimePnlCalc.RealtimeSwapPosition(new OptUserInfo(0, "互换实时持仓服务", OptUserFrom.Service));
|
||||
});
|
||||
Dictionary<long, List<string>> clientUmsDic = new Dictionary<long, List<string>>();
|
||||
clientUmsDic.Add(capitalAccount.ClientId ?? 0, new List<string> { capitalAccount.UnderlyingCode });
|
||||
new RiskCacheService().refreshRiskCache(clientUmsDic);
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除流水
|
||||
|
||||
@@ -502,47 +502,7 @@ namespace YLErp.Modules.SwapModule
|
||||
return clientUmsDic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 刷新冻结资金缓存
|
||||
/// </summary>
|
||||
/// <param name="clientUmsDic"></param>
|
||||
public void refreshFrozenCashCache(Dictionary<long, List<string>> 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<RefreshFrozenCashCacheReq, RefreshFrozenCashCacheResp>(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<swap_flow> swapFlows)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user