山证bug修复及功能 迁移

This commit is contained in:
吴方海
2024-06-04 18:19:49 +08:00
parent df65cd0add
commit acbd2e7678
39 changed files with 709 additions and 406 deletions
@@ -23,6 +23,7 @@ using YLErp.Model;
using YLErp.Model.Enum;
using YLErp.Models;
using YLErp.Modules.AppModule;
using YLErp.Modules.EodModule.QueryModule;
using YLErp.Modules.RiskModule;
using YLErp.Modules.TradeMsgOutputModule;
using YLErp.QdpModule;
@@ -118,8 +119,9 @@ namespace YLErp.Modules.SwapModule
string sql = $"select cd.id,{selectStr},co.settl_type from client_deal cd inner join client_order co on co.id=cd.client_order_id where cd.create_time<'{tomorrowDate.ToString("yyyy-MM-dd")}' and cd.create_time>='{valueDate.ToString("yyyy-MM-dd")}'";
return sql;
}
public void ResetTradeByDate(DateTime valueDate, Action<decimal>? action, List<int> tradeIds)
public void ResetTradeByDate(DateTime valueDate, int? clientId, string underlyingCode, Action<decimal>? action, List<int> tradeIds)
{
var swapEvents = DbContext.swap_event.Where(x => x.EventReason.Contains("自动") && x.ValueDate == valueDate);
//bool resetSingle = false;
if (tradeIds == null || tradeIds.Count() == 0)
@@ -133,21 +135,25 @@ namespace YLErp.Modules.SwapModule
var swaptrades = DbContext.trade.Where(x => tradeIds.Contains(x.id) && x.ValidState != ConsGlobal.InValid).ToList();
var swapflowMerges = DbContext.swap_flow_merge.Where(x => x.OccurTime == valueDate);
var swapflowDeals = DbContext.swap_flow_deal.Where(x => x.OccurDate == valueDate);
var swapFlows = DbContext.swap_flow.Where(x => x.OccurTime == valueDate).ToList();
//if (resetSingle == true)
//{
// var trade = swaptrades.FirstOrDefault();
// if (trade != null)
// {
// swapFlows = swapFlows.Where(x => x.ClientId == trade.ClientId && x.UnderlyingCode == trade.UnderlyingCode).ToList();
// }
//}
var swapFlows = DbContext.swap_flow.Where(x => x.OccurTime == valueDate);
if (clientId.HasValue)
{
swapFlows = swapFlows.Where(x => x.ClientId == clientId);
swapflowDeals = swapflowDeals.Where(x => x.ClientId == clientId);
swapflowMerges = swapflowMerges.Where(x => x.ClientId == clientId);
}
if (!string.IsNullOrEmpty(underlyingCode))
{
swapFlows = swapFlows.Where(x => x.UnderlyingCode == underlyingCode);
swapflowMerges = swapflowMerges.Where(x => x.UnderlyingCode == underlyingCode);
swapflowDeals = swapflowDeals.Where(x => x.UnderlyingCode == underlyingCode);
}
var trsDealIds = swapFlows.Where(x => x.trs_deal_id > 0).Select(s => s.trs_deal_id ?? 0).ToList();
var swaptradesCount = swaptrades.Count();
decimal backProcessedCount = 0;
if (swaptradesCount == 0)
{
backProcessedCount=100;
backProcessedCount = 100;
}
foreach (var td in swaptrades)
{
@@ -162,7 +168,6 @@ namespace YLErp.Modules.SwapModule
DbContext.swap_flow_merge.RemoveRange(swapflowMerges);
DbContext.swap_flow_deal.RemoveRange(swapflowDeals);
DbContext.SaveChanges();
}
/// <summary>
@@ -550,7 +555,7 @@ namespace YLErp.Modules.SwapModule
}
if (cashNeedAfter)
{
var flowEvents = DbContext.swap_flow_event.Where(x => x.EventDate == flowMerge.OccurTime && x.PayDate > x.UnwindDate && x.EventType == (int)SwapFlowEventTypeEnum. && x.DataState == (int)SwapFlowDateStateEnum. &&x.ClientId== flowMerge.ClientId);
var flowEvents = DbContext.swap_flow_event.Where(x => x.EventDate == flowMerge.OccurTime && x.PayDate > x.UnwindDate && x.EventType == (int)SwapFlowEventTypeEnum. && x.DataState == (int)SwapFlowDateStateEnum. && x.ClientId == flowMerge.ClientId && x.PayDirection > 0);
var tradeIds = flowEvents.Select(s=>s.SwapTradeId).Distinct();
var trades = DbContext.trade.Where(x=> tradeIds.Contains(x.id)&&x.ValidState!=ConsGlobal.InValid);
cashNeedAfter = !trades.Any();