From 68758b839b4df1143c844924a858d73d8013868b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AC=B4=E6=94=BF=20=E6=97=B6?= Date: Tue, 10 Jun 2025 18:59:03 +0800 Subject: [PATCH] =?UTF-8?q?#TRS-ZS-532=20=E4=BA=A4=E6=98=93=E7=A1=AE?= =?UTF-8?q?=E8=AE=A4=E4=B9=A6=E5=90=88=E5=B9=B6=E7=94=9F=E6=88=90=E7=9A=84?= =?UTF-8?q?=E7=BB=B4=E5=BA=A6=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TradeContractGenerateService.cs | 41 ++++++++----------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/YLErpDAL/Modules/TradeModule/DealModule/TradeContractGenerateService.cs b/YLErpDAL/Modules/TradeModule/DealModule/TradeContractGenerateService.cs index 6b5c4636..2132535d 100644 --- a/YLErpDAL/Modules/TradeModule/DealModule/TradeContractGenerateService.cs +++ b/YLErpDAL/Modules/TradeModule/DealModule/TradeContractGenerateService.cs @@ -195,14 +195,6 @@ namespace YLErp.Modules.TradeModule.DealModule public bool GJGenerateConfirmBook(List tradeIds, string docType, out IEnumerable errors, out IEnumerable files, DateTime? startDate = null, DateTime? endDate = null) { - if (PS.Config.Company == CompanyEnum.国信金阳) - { - if (!GXJY_CorrespondingConfirmationTemplate(tradeIds, out string Msg)) - { - - throw new ServiceException(Msg); - } - } Func getUnderlyingInstrumentType = new Func((underlyingId) => { return DataCacheProvider.GetUnderlyingDataSource().GetData(underlyingId)?.UnderlyingInstrumentType; @@ -213,9 +205,9 @@ namespace YLErp.Modules.TradeModule.DealModule if (PS.Config.Company == CompanyEnum.浙商) { LogFactory.GetLogger("生成确认书").Error("浙商生成确认书"); - var trades = DbContext.trade.Where(x=>tradeIds.Contains(x.id)).AsNoTracking().ToList(); - var clientIds= trades.Select(x=>x.ClientId).Distinct().ToList(); - var allTrades= DbContext.trade.Where(x => clientIds.Contains(x.ClientId)&&x.ValidState!=ConsGlobal.InValid); + var trades = DbContext.trade.Where(x => tradeIds.Contains(x.id)).AsNoTracking().ToList(); + var clientIds = trades.Select(x => x.ClientId).Distinct().ToList(); + var allTrades = DbContext.trade.Where(x => clientIds.Contains(x.ClientId) && x.ValidState != ConsGlobal.InValid); if (startDate.HasValue) { allTrades = allTrades.Where(x => x.TradeDate >= startDate); @@ -227,14 +219,14 @@ namespace YLErp.Modules.TradeModule.DealModule var Ids = allTrades.Select(o => o.id).Distinct().ToArray(); var swapPositions = DbContext.swap_position.Where(s => Ids.Contains(s.SwapTradeId) && s.IsInitial && s.PositionType > 0 && !s.Invalid) .Distinct().ToList(); - var allTradeList= allTrades.AsNoTracking().ToList(); + var allTradeList = allTrades.AsNoTracking().ToList(); foreach (var item in allTradeList) { item.swap_positions.Add(swapPositions.FirstOrDefault(o => o.SwapTradeId == item.id)); } allTradeList = allTradeList.Where(x => x.swap_positions.Any()).ToList(); // 按照客户ID、交易日期、多空头进行分组 - var group = allTradeList.GroupBy(O => new { O.ClientId, O.TradeDate, O.swap_positions.FirstOrDefault().PositionType }) + var group = allTradeList.GroupBy(O => new { O.ClientId, O.StartDate, O.swap_positions.FirstOrDefault().PositionType }) .ToDictionary(K => K.Key, V => V.Select(O => O.id).ToList()); foreach (var item in group) @@ -547,6 +539,7 @@ namespace YLErp.Modules.TradeModule.DealModule { t.id, t.TradeDate, + t.StartDate, tcr.ContractCode, t.ClientId, t.ClientNumber, @@ -584,14 +577,14 @@ namespace YLErp.Modules.TradeModule.DealModule query = query.Where(o => o.ContractCode.Contains(req.ContractCode)); } - if (req.PositionTypes!= null && req.PositionTypes.Count() > 0) + if (req.PositionTypes != null && req.PositionTypes.Count() > 0) { - query = query.Where(o => req.PositionTypes.Contains(o.PositionType)); + query = query.Where(o => req.PositionTypes.Contains(o.PositionType)); } - + //客户希望用StartDate分组, 默认业务中StartDate会是TradeDate+1个交易日 var contractGroups = query.AsEnumerable() - .GroupBy(x => new { x.TradeDate, x.ClientId, x.PositionType }) - .Select(group => group.ToList()) + .GroupBy(x => new { x.StartDate, x.ClientId, x.PositionType }) + .Select(group => group.ToList()) .ToList(); // 构建返回结果 @@ -618,11 +611,11 @@ namespace YLErp.Modules.TradeModule.DealModule StampDocumentFileName = group.FirstOrDefault().StampDocumentFileName, OptDate = group.FirstOrDefault().OptDate, OptName = group.FirstOrDefault().OptName, - ContractDocId = group.FirstOrDefault().ContractDocId + ContractDocId = group.FirstOrDefault().ContractDocId }); } result = contractList.OrderByDescending(r => r.TradeDate).AsQueryable().ToSearchList(req); - return result; + return result; } } @@ -652,8 +645,8 @@ namespace YLErp.Modules.TradeModule.DealModule public DateTime? EndDate { get; set; } //客户 - public List? ClientIds { get; set; } - + public List? ClientIds { get; set; } + public List? PositionTypes { get; set; } @@ -665,7 +658,7 @@ namespace YLErp.Modules.TradeModule.DealModule public string ContractCode { get; set; } public DateTime TradeDate { get; set; } - + public string ClientNumber { get; set; } public string ClientName { get; set; } @@ -674,7 +667,7 @@ namespace YLErp.Modules.TradeModule.DealModule public string EmailResult { get; set; } - public List tradeIds { get; set;} + public List tradeIds { get; set; } public string ContractDocUrl { get; set; }