#TRS-ZS-532 交易确认书合并生成的维度变更
This commit is contained in:
@@ -195,14 +195,6 @@ namespace YLErp.Modules.TradeModule.DealModule
|
||||
public bool GJGenerateConfirmBook(List<int> tradeIds, string docType,
|
||||
out IEnumerable<string> errors, out IEnumerable<string> files, DateTime? startDate = null, DateTime? endDate = null)
|
||||
{
|
||||
if (PS.Config.Company == CompanyEnum.国信金阳)
|
||||
{
|
||||
if (!GXJY_CorrespondingConfirmationTemplate(tradeIds, out string Msg))
|
||||
{
|
||||
|
||||
throw new ServiceException(Msg);
|
||||
}
|
||||
}
|
||||
Func<int, string> getUnderlyingInstrumentType = new Func<int, string>((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<int>? ClientIds { get; set; }
|
||||
|
||||
public List<int>? ClientIds { get; set; }
|
||||
|
||||
public List<int>? 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<int> tradeIds { get; set;}
|
||||
public List<int> tradeIds { get; set; }
|
||||
|
||||
public string ContractDocUrl { get; set; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user