删除定义文件类型,删除所有判断山西固收的地方
This commit is contained in:
@@ -52,11 +52,9 @@ namespace RealTimeCalcPositionService
|
||||
var clients= clientDb.client.Where(x=>x.SwapTradeType==0).ToList();
|
||||
//系统交易日
|
||||
var valuedate = valuedateBLL.ValueDate;
|
||||
//获取根据系统时间
|
||||
var lastBalanceDate = EodOperationBase.GetLastSettlementDate(valuedate);
|
||||
foreach (var client in clients)
|
||||
{
|
||||
var cb = ClientAssetDataService.GetClientLatestBalance(null, lastBalanceDate, client.id, false, false, false);
|
||||
var cb = ClientAssetDataService.GetClientLatestBalance(null, valuedate, client.id, false, false, false);
|
||||
cb.AvailableAmount = cb.AmountFund + cb.TotalCredit + cb.PayableMargin + cb.GuaranteesTotalAmount;
|
||||
var obj = new ClientBalanceForTrsResponse
|
||||
{
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
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 YLErp;
|
||||
using YLErp.Abstract;
|
||||
using YLErp.BLL.Eod;
|
||||
using YLErp.Cache;
|
||||
using YLErp.Helpers;
|
||||
using YLErp.Model;
|
||||
using YLErp.Modules;
|
||||
using YLErp.Modules.ClientModule;
|
||||
|
||||
namespace RealTimeCalcPositionService
|
||||
{
|
||||
public class ClientRealBalanceTask : IHostedService, IDisposable
|
||||
{
|
||||
private readonly IYcLogger _logger;
|
||||
private IKafkaProduce kafkaProduceHelper;
|
||||
private string onRspAccountCapitalTopicTopic = string.Empty;
|
||||
private readonly CancellationTokenSource _cts = new CancellationTokenSource();
|
||||
private Dictionary<int,string> clientDic=new Dictionary<int, string>();
|
||||
private IYLCache _yLCache;
|
||||
public ClientRealBalanceTask(IKafkaProduce kafkaProduce, IYLCache yLCache)
|
||||
{
|
||||
_logger = LogFactory.GetLogger("ClientRealBalanceTask");
|
||||
onRspAccountCapitalTopicTopic = Environment.GetEnvironmentVariable("KafkaConfig_OnRspAccountCapitalTopic");
|
||||
kafkaProduceHelper = kafkaProduce;
|
||||
_yLCache= yLCache;
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
_cts.Dispose();
|
||||
}
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
_logger.Info("ClientBalanceTask task is starting.");
|
||||
Task.Run(() => ExecuteTask(_cts.Token), _cts.Token);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
private void ExecuteTask(CancellationToken stoppingToken)
|
||||
{
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
try
|
||||
{
|
||||
var clientSettles = new RealTimeClientBanlanceService(new OptUserInfo(0, "实时客户资金服务", OptUserFrom.Service)).GetDMABalances();
|
||||
foreach (var cb in clientSettles)
|
||||
{
|
||||
cb.AvailableAmount = cb.AmountFund + cb.TotalCredit + cb.PayableMargin + cb.GuaranteesTotalAmount;
|
||||
Result result = new Result();
|
||||
try
|
||||
{
|
||||
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
|
||||
};
|
||||
result.success = true;
|
||||
result.obj = obj;
|
||||
if (_yLCache!=null)
|
||||
{
|
||||
_yLCache.StringSet<ClientBalanceForTrsResponse>("ClientBalance:"+ cb.ClientId,obj);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.msg = ex.Message;
|
||||
result.success = false;
|
||||
}
|
||||
string resultStr = JsonConvert.SerializeObject(result);
|
||||
string newEncryStr= DataProtectHelper.Encrypt(resultStr);
|
||||
bool needProduce= false;
|
||||
if (clientDic.TryGetValue(cb.ClientId,out string encryStr))
|
||||
{
|
||||
if (encryStr!= newEncryStr)
|
||||
{
|
||||
needProduce = true;
|
||||
clientDic[cb.ClientId]= newEncryStr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
clientDic.Add(cb.ClientId, newEncryStr);
|
||||
needProduce = true;
|
||||
}
|
||||
if (needProduce)
|
||||
{
|
||||
kafkaProduceHelper.Produce(onRspAccountCapitalTopicTopic, resultStr);
|
||||
}
|
||||
}
|
||||
Thread.Sleep(3000);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(ex, "实时客户资金服务异常:" + ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public async Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
_logger.Info("ClientBalanceTask task is stopping.");
|
||||
_cts.Cancel();
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,6 @@ internal class Program
|
||||
services.AddHostedService<ClientPosiTask>();
|
||||
services.AddHostedService<Worker>();
|
||||
services.AddHostedService<ClientNoDMABalanceTask>();
|
||||
services.AddHostedService<ClientRealBalanceTask>();
|
||||
}).ConfigureLogging(logging =>
|
||||
{
|
||||
logging.ClearProviders();
|
||||
|
||||
Reference in New Issue
Block a user