From 2d9d5763c42c3a735a502bf16b9376e72eeaf8ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=96=B9=E6=B5=B7?= Date: Tue, 11 Jun 2024 10:35:57 +0800 Subject: [PATCH] =?UTF-8?q?group=20by=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs | 6 +++--- YLErpDAL/BLL/EodSettlement/RealtimePnlCalc.cs | 6 +++--- YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs | 2 +- YLErpDAL/Modules/SwapModule/SwapFlowEventService.cs | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs b/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs index 09c828d1..20cd440a 100644 --- a/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs +++ b/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs @@ -218,10 +218,10 @@ namespace YLErp.BLL.Eod var latestRecord = DbContext.intraday_trade_position.OrderByDescending(x => x.OptDate).FirstOrDefault(); //SetDebugSqlLog(); - Dictionary dicIntradayTradePosition = DbContext.intraday_trade_position.Where(x => clientIds.Contains(x.ClientId)).GroupBy(p => p.ClientId).Select(p => new { p.Key, OptDate = p.Max(d => d.OptDate) }) + Dictionary dicIntradayTradePosition = DbContext.intraday_trade_position.Where(x => clientIds.Contains(x.ClientId)).AsEnumerable().GroupBy(p => p.ClientId).Select(p => new { p.Key, OptDate = p.Max(d => d.OptDate) }) .ToDictionary(p => p.Key, p => p.OptDate); - Dictionary dicCashInOut = DbContext.ClientCashInCashOut.Where(x => clientIds.Contains((int)x.ClientId)).GroupBy(p => (int)p.ClientId).Select(p => new { p.Key, OptDate = p.Max(d => d.OptDate) }).ToDictionary(p => p.Key, p => p.OptDate); + Dictionary dicCashInOut = DbContext.ClientCashInCashOut.Where(x => clientIds.Contains((int)x.ClientId)).AsEnumerable().GroupBy(p => (int)p.ClientId).Select(p => new { p.Key, OptDate = p.Max(d => d.OptDate) }).ToDictionary(p => p.Key, p => p.OptDate); foreach (var item in _clientBalanceDic.Values) { @@ -1387,7 +1387,7 @@ namespace YLErp.BLL.Eod balance.PositionCount= tradeIds.Count(); balance.PositionNotionalPrincipal = Convert.ToDouble(positions.Sum(s=>s.PosiNotionalValue));//实时 } - var eodSwapQuery = DbContext.eod_swap.Where(x => clientIds.Contains(x.ClientId) && x.ValueDate >= lastSettletDate && x.ValueDate <= startDate).GroupBy(x => x.SwapTradeId) + var eodSwapQuery = DbContext.eod_swap.Where(x => clientIds.Contains(x.ClientId) && x.ValueDate >= lastSettletDate && x.ValueDate <= startDate).AsEnumerable().GroupBy(x => x.SwapTradeId) .Select(g => g.OrderByDescending(x => x.ValueDate).FirstOrDefault()).ToList(); var eodTradeIds = eodSwapQuery.Select(s => s.SwapTradeId).ToList(); var eodTrades = DbContext.trade.Where(t => (ConsTrade.TradeStatusAfterConfirmed.Contains(t.TradeStatus)) && tradeIds.Contains(t.id) && t.ValidState != "InValid" && startDate >= t.StartDate); diff --git a/YLErpDAL/BLL/EodSettlement/RealtimePnlCalc.cs b/YLErpDAL/BLL/EodSettlement/RealtimePnlCalc.cs index 10f9cb7c..af1b278e 100644 --- a/YLErpDAL/BLL/EodSettlement/RealtimePnlCalc.cs +++ b/YLErpDAL/BLL/EodSettlement/RealtimePnlCalc.cs @@ -514,7 +514,7 @@ namespace YLErp.BLL.Eod var swapFlows = db.swap_flow.Where(x => x.DataState == (int)SwapFlowDateStateEnum.等待完成).ToList(); using var bondDb = new BondOmsDBContext(); var clientPositions = bondDb.client_position.AsEnumerable(); - var eodSwaps = db.eod_swap_position.Where(x => tradeIdList.Contains(x.SwapTradeId) && x.PosiDirection > 0).GroupBy(p => p.SwapTradeId) + var eodSwaps = db.eod_swap_position.Where(x => tradeIdList.Contains(x.SwapTradeId) && x.PosiDirection > 0).AsEnumerable().GroupBy(p => p.SwapTradeId) .Select(g => g.OrderByDescending(p => p.ValueDate).First()).ToList(); #endregion @@ -533,7 +533,7 @@ namespace YLErp.BLL.Eod td, p }; - var positionGroup = query.GroupBy(x => new { x.p.UnderlyingCode, x.td.ClientId,x.p.PosiDirection}); + var positionGroup = query.AsEnumerable().GroupBy(x => new { x.p.UnderlyingCode, x.td.ClientId,x.p.PosiDirection}); var dealSwapFlowIds = new List(); SwapTradeAutoService swapTradeAutoService = new SwapTradeAutoService(optUser); var datenow = DateTime.Now; @@ -599,7 +599,7 @@ namespace YLErp.BLL.Eod var nodealSwapFlows = swapFlows.Where(x => !dealSwapFlowIds.Contains(x.id)); if (nodealSwapFlows.Any()) { - var nodealSwapFlowGroup = nodealSwapFlows.GroupBy(g => new { g.ClientId, g.UnderlyingCode }); + var nodealSwapFlowGroup = nodealSwapFlows.AsEnumerable().GroupBy(g => new { g.ClientId, g.UnderlyingCode }); foreach (var swapFlowGroup in nodealSwapFlowGroup) { var client = DataCacheProvider.GetClientDataSource().GetData(swapFlowGroup.Key.ClientId ?? 0); diff --git a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs index 0352cfc1..4e8abb8c 100644 --- a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs @@ -56,7 +56,7 @@ namespace YLErp.Modules.SwapModule public void SwapFlowEventCompose(DateTime tradeDate) { new SysJobService(UserInfo).UpdateJob("互换流水合成持仓", 41, "互换流水合成持仓进行中"); - var eventQueryGroup = DbContext.swap_flow_event.Where(n => n.DataState == (int)SwapFlowDateStateEnum.等待完成 && n.EventDate == tradeDate).GroupBy(g => g.SwapTradeId); + var eventQueryGroup = DbContext.swap_flow_event.Where(n => n.DataState == (int)SwapFlowDateStateEnum.等待完成 && n.EventDate == tradeDate).AsEnumerable().GroupBy(g => g.SwapTradeId); foreach (var eventQueryGroupItem in eventQueryGroup) { ComposePage(eventQueryGroupItem.Key, eventQueryGroupItem.ToList(), tradeDate); diff --git a/YLErpDAL/Modules/SwapModule/SwapFlowEventService.cs b/YLErpDAL/Modules/SwapModule/SwapFlowEventService.cs index a5a857b5..52ec00c8 100644 --- a/YLErpDAL/Modules/SwapModule/SwapFlowEventService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapFlowEventService.cs @@ -37,7 +37,7 @@ namespace YLErp.Modules.SwapModule new SysJobService(UserInfo).UpdateJob("互换流水合成持仓", 31, "互换流水开平仓事件进行中"); //同一交易代码、交易日期、标的、买卖方向 最多存在2条记录 - var flowqueryGroup = DbContext.swap_flow_merge.Where(n => n.DataState == (int)SwapFlowDateStateEnum.等待完成 && n.OccurTime == tradeDate).GroupBy(g => g.SwapTradeId); + var flowqueryGroup = DbContext.swap_flow_merge.Where(n => n.DataState == (int)SwapFlowDateStateEnum.等待完成 && n.OccurTime == tradeDate).AsEnumerable().GroupBy(g => g.SwapTradeId); foreach (var flowMergeGroupItem in flowqueryGroup) { MergePageEvent(flowMergeGroupItem.Key ?? 0, flowMergeGroupItem.ToList(), tradeDate);