feat(kafka): 添加实时资金计算topic配置

- 在多个环境配置文件中新增RealtimeCalcAccountBalance配置项
- 移除ClientBalanceForTrsResponse中的冗余字段
- 更新Kafka任务和控制器中相关字段引用
- 修改Producer发送的目标topic为新的实时计算topic
This commit is contained in:
hjhan
2025-12-17 10:05:57 +08:00
parent a032c09cec
commit d3e576b0e5
9 changed files with 14 additions and 34 deletions
@@ -8,10 +8,7 @@ namespace YLErp.Model
{
public class ClientBalanceForTrsResponse
{
/// <summary>
/// 总资产
/// </summary>
public double TotalAmountTotal { get; set; }
/// <summary>
/// 可用资金
/// </summary>
@@ -24,11 +21,7 @@ namespace YLErp.Model
/// 持仓盈亏
/// </summary>
public double PositionPnl { get; set; }
/// <summary>
/// 当日盈亏
/// </summary>
public double DaliyPnl { get; set; }
public int ClientId { get; set; }
/// <summary>
/// 互换交易类别(0:非DMA,1;DMA)
@@ -74,11 +74,9 @@ namespace YLErp.Web.App
var AvailableMoney = cb.AvailableAmount + cb.FrozenMarginMoney;
var obj = new ClientBalanceForTrsResponse
{
TotalAmountTotal = cb.RoundedTotalAmountTotal,
AvailableAmount = Math.Round(cb.AvailableAmount, 2),
PositionPv = cb.RoundedPositionPv,
PositionPnl = cb.RoundedPositionPnl,
DaliyPnl = Math.Round(cb.DaliyPnl, 2),
ClientId = req.clientId,
ClientType = cb.ClientType,
Credit = cb.TotalCredit,
+2 -2
View File
@@ -138,11 +138,11 @@ namespace YLErp.Web.Controllers
var cb = ClientAssetDataService.GetClientLatestBalance(null, DateTime.Now.Date, clientId, false, false, false);
var obj = new ClientBalanceForTrsResponse
{
TotalAmountTotal = cb.RoundedTotalAmountTotal,
AvailableAmount = Math.Round(cb.AvailableAmount,2),
PositionPv = cb.RoundedPositionPv,
PositionPnl = cb.RoundedPositionPnl,
DaliyPnl = Math.Round(cb.DaliyPnl, 2),
Credit =cb.TotalCredit
};
return JsonSuccess("", obj);
+1
View File
@@ -37,6 +37,7 @@
"HedgingAccountTopic": "ylHedgingAccountTopic", //对冲账户生产topic
"ReqAccountCapitalTopic": "ReqAccountCapital", //账户资金请求topic
"OnRspAccountCapitalTopic": "OnRspAccountCapital", //账户资金请求返回topic
"RealtimeCalcAccountBalance": "RealtimeCalcAccountBalance", //实时资金计算topic
"AccountCapitalTopicGroupId": "YiLian_OnRspAccountCapitalConsumer", //账户资金消费组
"AutoOffsetReset": 1, //Latest(0),Earliest(1),Error(2)
"EnableCalcBongd": false, //是否启用kafka计算
+1
View File
@@ -40,6 +40,7 @@
"AccountCapitalTopicGroupId": "YiLian_OnRspAccountCapitalConsumer", //账户资金消费组
"ReqAccountCapitalTopic": "ReqAccountCapital", //账户资金请求topic
"OnRspAccountCapitalTopic": "OnRspAccountCapital", //账户资金请求返回topic
"RealtimeCalcAccountBalance": "RealtimeCalcAccountBalance", //实时资金计算topic
"AutoOffsetReset": 1, //Latest(0),Earliest(1),Error(2)
"EnableCalcBongd": false, //是否启用kafka计算
"ReqClientRiskCheckTopic": "YiLian_ReqClientRiskCheck", //客户风控检查
+1
View File
@@ -40,6 +40,7 @@
"AccountCapitalTopicGroupId": "YiLian_OnRspAccountCapitalConsumer", //账户资金消费组
"ReqAccountCapitalTopic": "ReqAccountCapital", //账户资金请求topic
"OnRspAccountCapitalTopic": "OnRspAccountCapital", //账户资金请求返回topic
"RealtimeCalcAccountBalance": "RealtimeCalcAccountBalance", //实时资金计算topic
"AutoOffsetReset": 1, //Latest(0),Earliest(1),Error(2)
"EnableCalcBongd": false, //是否启用kafka计算
"ReqClientRiskCheckTopic": "YiLian_ReqClientRiskCheck", //客户风控检查
+1
View File
@@ -40,6 +40,7 @@
"AccountCapitalTopicGroupId": "YiLian_OnRspAccountCapitalConsumer", //账户资金消费组
"ReqAccountCapitalTopic": "ReqAccountCapital", //账户资金请求topic
"OnRspAccountCapitalTopic": "OnRspAccountCapital", //账户资金请求返回topic
"RealtimeCalcAccountBalance": "RealtimeCalcAccountBalance", //实时资金计算topic
"AutoOffsetReset": 1, //Latest(0),Earliest(1),Error(2)
"EnableCalcBongd": false, //是否启用kafka计算
"ReqClientRiskCheckTopic": "YiLian_ReqClientRiskCheck", //客户风控检查
@@ -1,26 +1,11 @@
using BaseOUDAL;
using DocumentFormat.OpenXml.Drawing.Charts;
using Newtonsoft.Json;
using Org.BouncyCastle.Ocsp;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Linq;
using Newtonsoft.Json;
using YLErp;
using YLErp.Abstract;
using YLErp.BLL;
using YLErp.BLL.Eod;
using YLErp.Cache;
using YLErp.DBModels;
using YLErp.Helpers;
using YLErp.Model;
using YLErp.Modules;
using YLErp.Modules.ClientModule;
using YLErp.Modules.EodModule.QueryModule;
namespace RealTimeCalcPositionService
{
@@ -29,13 +14,13 @@ namespace RealTimeCalcPositionService
private readonly IYcLogger _logger;
private readonly CancellationTokenSource _cts = new CancellationTokenSource();
private IKafkaProduce kafkaProduceHelper;
private string onRspAccountCapitalTopicTopic = string.Empty;
private string RealtimeCalcAccountBalance = string.Empty;
private Dictionary<int, string> clientDic = new Dictionary<int, string>();
private IYLCache _yLCache;
public ClientNoDMABalanceTask(IKafkaProduce kafkaProduce, IYLCache yLCache)
{
_logger = LogFactory.GetLogger("ClientNoDMABalanceTask");
onRspAccountCapitalTopicTopic = Environment.GetEnvironmentVariable("KafkaConfig_OnRspAccountCapitalTopic");
RealtimeCalcAccountBalance = Environment.GetEnvironmentVariable("KafkaConfig_RealtimeCalcAccountBalance");
kafkaProduceHelper = kafkaProduce;
_yLCache = yLCache;
}
@@ -66,11 +51,10 @@ namespace RealTimeCalcPositionService
{
var obj = new ClientBalanceForTrsResponse
{
TotalAmountTotal = cb.RoundedTotalAmount,
AvailableAmount = Math.Round(cb.AvailableAmount, 2),
PositionPv = cb.RoundedPositionPv,
PositionPnl = cb.RoundedPositionPnl,
DaliyPnl = Math.Round(cb.DaliyPnl, 2),
ClientId = cb.ClientId,
ClientType = cb.ClientType,
Credit = cb.TotalCredit,
@@ -107,7 +91,7 @@ namespace RealTimeCalcPositionService
}
if (needProduce)
{
kafkaProduceHelper.Produce(onRspAccountCapitalTopicTopic, resultStr);
kafkaProduceHelper.Produce(RealtimeCalcAccountBalance, resultStr);
}
}
Thread.Sleep(3000);
@@ -36,6 +36,7 @@
"HedgingAccountTopic": "ylHedgingAccountTopic", //对冲账户生产topic
"ReqAccountCapitalTopic": "ReqAccountCapital", //账户资金请求topic
"OnRspAccountCapitalTopic": "OnRspAccountCapital", //账户资金请求返回topic
"RealtimeCalcAccountBalance": "RealtimeCalcAccountBalance", //实时资金计算topic
"AccountCapitalTopicGroupId": "YiLian_OnRspAccountCapitalConsumer", //账户资金消费组
"ReqCalcBondTopic": "ReqCalcBond", //互换成交收益率计算器topic
"OnRspCalcBondTopic": "OnRspCalcBond", //互换成交收益率计算器消费topic