From 95ce3a3c8c54ef69feaa0b5d5d778324d099fbed Mon Sep 17 00:00:00 2001 From: hjhan Date: Thu, 16 Apr 2026 16:54:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(swap):=20=E4=BF=AE=E5=A4=8D=E4=BA=92?= =?UTF-8?q?=E6=8D=A2=E5=AE=9E=E6=97=B6=E6=8C=81=E4=BB=93=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86=E5=92=8C=E7=BB=93=E7=AE=97?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E8=AE=A1=E7=AE=97=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加try-catch块包装RealtimeSwapPosition调用以捕获异常 - 记录互换实时持仓服务计算失败的日志 - 修复结算模块金额计算中的空引用问题 - 为unwind百分比、原始名义金额和计数比率添加空值检查 --- .../TradeUnwindReportGenerator.cs | 2 +- .../Modules/SwapModule/SwapDealService.cs | 27 +++++++------------ 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/Plugins/YLErp.Plugins.GuoLian/DocumentGenerator/TradeUnwindReportGenerator.cs b/Plugins/YLErp.Plugins.GuoLian/DocumentGenerator/TradeUnwindReportGenerator.cs index 19d2bda7..6cf6c32d 100644 --- a/Plugins/YLErp.Plugins.GuoLian/DocumentGenerator/TradeUnwindReportGenerator.cs +++ b/Plugins/YLErp.Plugins.GuoLian/DocumentGenerator/TradeUnwindReportGenerator.cs @@ -64,7 +64,7 @@ namespace YLErp.Plugins.GuoLian.DocumentGenerator row["期初价格"] = currentTrade?.TradePrice.OtcFormatMoney() ?? "0.00"; row["结算日期"] = tradeCashItem.ValueDate.ToString("yyyy/MM/dd"); row["结算价格"] = tradeCashItem.FinalPrice.OtcFormatMoney(); - row["结算模块"] = (tradeCashItem.UnwindPercentRate * currentTrade?.OriginalNotional * underlying?.CountRatio).OtcFormatMoney() ?? "0.00"; + row["结算模块"] = ((tradeCashItem.UnwindPercentRate ?? 0) * (currentTrade?.OriginalNotional ?? 0) * (underlying?.CountRatio ?? 0)).OtcFormatMoney() ?? "0.00"; row["结算单价"] = settlementPrice; var amountQrs = -tradeCashItem.Amount; diff --git a/YLErpDAL/Modules/SwapModule/SwapDealService.cs b/YLErpDAL/Modules/SwapModule/SwapDealService.cs index d29f4352..7a9f793f 100644 --- a/YLErpDAL/Modules/SwapModule/SwapDealService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapDealService.cs @@ -1,30 +1,14 @@ -using ClosedXML.Report.Utils; -using CsvHelper; -using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.Extensions.Logging; -using MoreLinq.Extensions; +using MoreLinq.Extensions; using Newtonsoft.Json; -using OfficeOpenXml.Drawing; -using OfficeOpenXml.Drawing.Controls; -using Org.BouncyCastle.Asn1.Ocsp; -using Qdp.Pricing.Base.Implementations; -using Qdp.Pricing.Core.Modules; -using Qdp.Pricing.Library.Base.Utilities; using System.Linq.Expressions; using YLErp.BLL; using YLErp.BLL.Eod; -using YLErp.DBModels; using YLErp.DBModels.Enums; -using YLErp.Model; -using YLErp.Models; using YLErp.Modules.DataProviderModule; using YLErp.Modules.EodModule; -using YLErp.Modules.EodModule.QueryModule; using YLErp.Modules.TradeModule; using YLErp.Modules.TradeModule.DealModule; using YLErp.QdpModule; -using static Microsoft.IO.RecyclableMemoryStreamManager; -using static YLErp.ConsGlobal; namespace YLErp.Modules.SwapModule { @@ -799,7 +783,14 @@ namespace YLErp.Modules.SwapModule { Task.Run(() => { - RealtimePnlCalc.RealtimeSwapPosition(new OptUserInfo(0, "互换实时持仓服务", OptUserFrom.Service)); + try + { + RealtimePnlCalc.RealtimeSwapPosition(new OptUserInfo(0, "互换实时持仓服务", OptUserFrom.Service)); + } + catch (Exception ex) + { + LogFactory.GetLogger().Error("互换实时持仓服务计算失败", ex); + } }); } }