bug修复

This commit is contained in:
吴方海
2025-04-23 13:58:26 +08:00
parent 9328e6f95f
commit 9f47caa3ed
8 changed files with 47 additions and 17 deletions
@@ -563,14 +563,14 @@ namespace YLErp.BLL.Eod
var multiplier = ConsGlobal.InstrumentType.IsBond(lastPosi.UnderlyingInstrumentType) ? ConsGlobal.bondShowPriceMultiple : 1;
// 计算加权平均价格(区分债券和非债券)
var weightedPrice = positionGroupItems
var weightedPrice = posiQty==0?0: positionGroupItems
.Sum(s => {
decimal price = ConsGlobal.InstrumentType.IsBond(lastPosi.UnderlyingInstrumentType)
? s.PosiGrossPrice * ConsGlobal.bondShowPriceMultiple
: s.PosiGrossPrice;
return s.PosiQuantity * price;
}) / posiQty;
var weightedNetPrice = positionGroupItems
var weightedNetPrice = posiQty==0?0: positionGroupItems
.Sum(s => {
decimal price = ConsGlobal.InstrumentType.IsBond(lastPosi.UnderlyingInstrumentType)
? s.PosiNetPrice * ConsGlobal.bondShowPriceMultiple
@@ -676,6 +676,10 @@ namespace YLErp.Modules.ClientModule
// 出金金额小于等于 追保账户金额
r.cash_type = CashTypeEnum..ToString();
}
else if (clientbalance.VmFundSum==0)
{
r.cash_type = CashTypeEnum..ToString();
}
else
{
// 出金金额大于 追保账户金额,首先处理 VM 部分
@@ -775,7 +775,7 @@ namespace YLErp.Modules.SwapModule
DealFloatPosition(unwindData);
var flowList = new List<swap_flow_event>(unwindData.FlowEvents);
var eventId = SaveSwapDeal(unwindData, (int)SwapEventTypeEnum., clientCashId, "系统操作_平仓");
if (unwindData.CloseMethod == (int)CloseMethodEnum.)
if (unwindData.CloseMethod == (int)CloseMethodEnum.|| unwindData.ClosePercent==1)
{
td.TradeStatus = "已平仓";
td.trade_extend = DbContext.trade_extend.FirstOrDefault(x => x.TradeId == td.id);
+36 -7
View File
@@ -381,15 +381,44 @@ namespace YLErp.Modules.SwapModule
public void SendAllSwapRateToKafka()
{
var swapRates = DbContext.swap_rate.Where(x => x.TakeEffectDate <= DateTime.Now.Date).GroupBy(g => g.ClientId).Select(g => g.OrderByDescending(o => o.TakeEffectDate).FirstOrDefault()).ToList();
var swapRateAll = DbContext.swap_rate
.Where(x => x.ClientId == 0 && x.TakeEffectDate <= DateTime.Now.Date)
.OrderByDescending(o => o.TakeEffectDate)
.FirstOrDefault();
var monthStart = GetMonthStart();
var posiNotionalValueGroup = DbContext.trade.Where(x => x.TradeDate >= monthStart
&& x.ValidState != ConsGlobal.InValid
&& x.TradeType == "收益互换"
&& ConsTrade.TradeStatusCustomexport.Contains(x.TradeStatus)).ToList().GroupBy(x => x.ClientId);
foreach (var swapRate in swapRates)
// 预计算客户持仓总额(在数据库端完成聚合)
var posiNotionalValues = DbContext.trade
.Where(x => x.TradeDate >= monthStart &&
x.ValidState != ConsGlobal.InValid &&
x.TradeType == "收益互换" &&
ConsTrade.TradeStatusCustomexport.Contains(x.TradeStatus))
.GroupBy(x => x.ClientId)
.Select(g => new
{
ClientId = g.Key,
Total = g.Sum(s => s.OriginalStockEqvNotional ?? 0)
})
.AsNoTracking()
.ToDictionary(x => x.ClientId, x => x.Total);
using ClientDBContext clientDBContext = new ClientDBContext();
var clients = clientDBContext.client.Where(x => x.ProcessStatus == "已开户").AsQueryable().ToList();
foreach (var client in clients)
{
var clientPosiNotional = posiNotionalValueGroup.FirstOrDefault(x => x.Key == swapRate.ClientId).ToList().Sum(s => s.OriginalStockEqvNotional ?? 0);
SendToKafka(swapRate, clientPosiNotional);
SwapRate swapRate = swapRates.FirstOrDefault(s => s.ClientId == client.id);
if (swapRate == null)
{
swapRate = swapRateAll;
}
if (swapRate == null)
{
swapRate = new SwapRate() { ClientId = client.id };
}
else
{
swapRate.ClientId= client.id;
}
posiNotionalValues.TryGetValue(client.id, out var clientPosiNotional);
SendToKafka(swapRate,clientPosiNotional);
}
}
/// <summary>
+1 -4
View File
@@ -141,10 +141,7 @@ namespace YLErp.Web.Controllers
[AllowAnonymous]
public JsonResult SendToKafka()
{
Task.Run(() =>
{
new SwapRateService(OptUserInfo.SystemUser).SendAllSwapRateToKafka();
});
new SwapRateService(OptUserInfo.SystemUser).SendAllSwapRateToKafka();
return JsonSuccess();
}
}
+1 -1
View File
@@ -28,7 +28,7 @@
}
},
"KafkaConfig": {
"BootstrapServers": "122.112.205.57:9092", // Kafka 集群的地址
"BootstrapServers": "139.196.109.225:9092", // Kafka 集群的地址
"Acks": -1, // 消息确认方式,可以是 All(-1)、Leader(1)、None(0) 中的一种
"EnableIdempotence": false, // 开启幂等性,确保消息只被发送一次
"MaxInFlight": 5, // 控制生产者在同一时间最多可以发送的未确认消息数
+1 -1
View File
@@ -28,7 +28,7 @@
}
},
"KafkaConfig": {
"BootstrapServers": "122.112.205.57:9092", // Kafka 集群的地址
"BootstrapServers": "139.196.109.225:9092", // Kafka 集群的地址
"Acks": -1, // 消息确认方式,可以是 All(-1)、Leader(1)、None(0) 中的一种
"EnableAutoCommit": false, //是否自动提交
"EnableIdempotence": false, // 开启幂等性,确保消息只被发送一次
@@ -344,7 +344,7 @@ const vue = new Vue({
}
x.SwapIntervalList.push(interval);
}
if (x.InterestType == 1 && item.interest_rest_days<0) {
if (x.InterestType == 1 && x.interest_rest_days<0) {
main.message("利息端第" + (index + 1) + "重置频率必须大于0");
errorcount++;
return false;