簿记 刷新冻结资金
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using YLErp.Models;
|
||||
|
||||
namespace YLErp.Modules.SwapModule.Dto
|
||||
{
|
||||
public class RefreshFrozenCashCacheReq
|
||||
{
|
||||
public RefreshFrozenCashCacheReq() { }
|
||||
public RefreshFrozenCashCacheReq(long clientId, List<string> underlyingCodes)
|
||||
{
|
||||
this.clientId = clientId;
|
||||
this.underlyingCodes = underlyingCodes;
|
||||
}
|
||||
public long clientId { get; set; }
|
||||
|
||||
public List<string> underlyingCodes { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class RefreshFrozenCashCacheResp : ApiResponse
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,13 @@ using Confluent.Kafka;
|
||||
using CsvHelper;
|
||||
using Dapper;
|
||||
using DocumentFormat.OpenXml.Drawing;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using MoreLinq;
|
||||
using Newtonsoft.Json;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using Org.BouncyCastle.Asn1.Ocsp;
|
||||
using Qdp.ComputeServiceV2.Data.CommonModels.TradeInfos;
|
||||
using Qdp.Foundation.Utilities;
|
||||
using Qdp.Pricing.Base.Enums;
|
||||
using Qdp.Pricing.Base.Implementations;
|
||||
using System.Linq;
|
||||
@@ -26,6 +29,7 @@ using YLErp.Models;
|
||||
using YLErp.Modules.AppModule;
|
||||
using YLErp.Modules.EodModule.QueryModule;
|
||||
using YLErp.Modules.RiskModule;
|
||||
using YLErp.Modules.SwapModule.Dto;
|
||||
using YLErp.Modules.TradeMsgOutputModule;
|
||||
using YLErp.QdpModule;
|
||||
using static alglib;
|
||||
@@ -461,13 +465,13 @@ namespace YLErp.Modules.SwapModule
|
||||
/// </summary>
|
||||
/// <param name="mergeList"></param>
|
||||
/// <param name="valueDate"></param>
|
||||
public void MergeAvgModeCompose(List<swap_flow_merge> mergeList, DateTime valueDate, Action<int>? action)
|
||||
public Dictionary<long, List<string>> MergeAvgModeCompose(List<swap_flow_merge> mergeList, DateTime valueDate, Action<int>? action)
|
||||
{
|
||||
var flowquery = mergeList.GroupBy(g => g.ClientId);
|
||||
var flowCount = flowquery.Count();
|
||||
if (flowCount == 0)
|
||||
{
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
var swaptrades = DbContext.trade.Where(t => t.TradeType == "收益互换"
|
||||
&& t.TradeDate <= valueDate
|
||||
@@ -479,11 +483,59 @@ namespace YLErp.Modules.SwapModule
|
||||
var floatRatePredicate = PredicateBuilder.Create<SwapFloatRate>(x => x.StartDate <= valueDate && x.EndDate >= matuirityDate);
|
||||
var floatRateQuery = DbContext.swap_float_rate.Where(floatRatePredicate);
|
||||
int dealCount = 0;
|
||||
|
||||
Dictionary<long,List<string>> clientUmsDic = new Dictionary<long, List<string>>();
|
||||
|
||||
foreach (var groupItem in flowquery)
|
||||
{
|
||||
MergeAvgModelItem(groupItem, swaptrades, swapPositions, floatRateQuery, ref dealCount, action);
|
||||
clientUmsDic.Add(groupItem.Key ?? 0, groupItem.Select(p => p.UnderlyingCode).Distinct().ToList());
|
||||
}
|
||||
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)
|
||||
{
|
||||
foreach (var item in swapFlows)
|
||||
|
||||
@@ -75,14 +75,14 @@ namespace YLErp.Web.Hubs
|
||||
currentStep = "正在合成簿记";
|
||||
await client.SendAsync("ReceiveMessage", currentStep);
|
||||
//var dmaFlows = swapFlows.Where(x => dmaClientIds.Contains(x.ClientId)).ToList();
|
||||
|
||||
Dictionary<long, List<string>> clientUmsDic = null;
|
||||
#region DMA合成持仓
|
||||
if (mergeList.Count > 0)
|
||||
{
|
||||
currentStep = $"正在合成簿记:共{mergeList.Count}条合成流水";
|
||||
await client.SendAsync("ReceiveMessage", currentStep);
|
||||
|
||||
service.MergeAvgModeCompose(mergeList, req.tradeDate, (dealCount) =>
|
||||
clientUmsDic = service.MergeAvgModeCompose(mergeList, req.tradeDate, (dealCount) =>
|
||||
{
|
||||
currentStep = $"正在合成簿记:{dealCount}/{mergeList.Count}";
|
||||
client.SendAsync("ReceiveMessage", currentStep);
|
||||
@@ -95,6 +95,7 @@ namespace YLErp.Web.Hubs
|
||||
service.UpdateSwapFlowState(swapFlows);
|
||||
currentStep = "流水簿记完毕";
|
||||
await client.SendAsync("ProcessCompleted", currentStep);
|
||||
service.refreshFrozenCashCache(clientUmsDic);
|
||||
isProcessing = false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace RealTimeCalcPositionService
|
||||
if (_yLCache != null)
|
||||
{
|
||||
_yLCache.StringSet<ClientBalanceForTrsResponse>("ClientBalance:" + cb.ClientId, obj);
|
||||
_yLCache.HashSet<decimal>("risk:cash:balance:amount", cb.ClientId.ToString(), (decimal)obj.AvailableAmount);
|
||||
_yLCache.HashSet<decimal>("risk:cash:balance:amount", cb.ClientId.ToString(), (decimal)obj.AvailableMoney);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in New Issue
Block a user