71 lines
2.8 KiB
C#
71 lines
2.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using YLErp.BLL;
|
|
using YLErp.Modules.TradeMsgOutputModule.Dto;
|
|
|
|
namespace YLErp.Modules.TradeMsgOutputModule
|
|
{
|
|
public class BaseTradeAfterEodOutputService
|
|
{
|
|
/// <summary>
|
|
/// 检测收盘状态
|
|
/// </summary>
|
|
/// <param name="valueDate"></param>
|
|
/// <exception cref="ServiceException"></exception>
|
|
public void CheckEodStatus(DateTime valueDate)
|
|
{
|
|
using (var db = DbContextFactory.GetYLDbContext())
|
|
{
|
|
var eodStatus = db.eodStatus.AsNoTracking().Any(p => p.ValueDate == valueDate && ConsGlobal.EodStatusVlue.Success.Equals(p.Status));
|
|
if (!eodStatus)
|
|
{
|
|
throw new ServiceException($"日期{valueDate:yyyy-MM-dd}未完成收盘");
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
protected Dictionary<int, TradeDicSimpleDto> GetTradeDicSimpleDic(YLContext db,List<int> tradeIds)
|
|
{
|
|
return db.trade.AsNoTracking().Where(p => tradeIds.Contains(p.id)).ToDictionary(p => p.id, p => new TradeDicSimpleDto
|
|
{
|
|
TradeNumber = p.TradeNumber,
|
|
AssetId = p.AssetId,
|
|
TradeDate = p.TradeDate,
|
|
TradeType = p.TradeType,
|
|
ExerciseDate = p.ExerciseDate,
|
|
UnderlyingCode = p.UnderlyingCode,
|
|
PremiumPayDate = p.PremiumPayDate,
|
|
OriginalStockEqvNotional = p.OriginalStockEqvNotional,
|
|
StockEqvNotional = p.StockEqvNotional
|
|
});
|
|
}
|
|
|
|
protected Dictionary<int, TradeDicSimpleDto> GetEodTradeDicSimpleDic(YLContext db,DateTime valueDate, List<int> tradeIds)
|
|
{
|
|
var eodTradeList = db.eod_trade.AsNoTracking().Where(p => p.ValueDate == valueDate && tradeIds.Contains(p.TradeId)).ToList();
|
|
if (eodTradeList != null && eodTradeList.Count > 0)
|
|
{
|
|
return eodTradeList.ToDictionary(p => p.TradeId, p => new TradeDicSimpleDto
|
|
{
|
|
TradeNumber = p.trade.TradeNumber,
|
|
AssetId = p.trade.AssetId,
|
|
TradeDate = p.trade.TradeDate,
|
|
TradeType = p.trade.TradeType,
|
|
ExerciseDate = p.trade.ExerciseDate,
|
|
UnderlyingCode = p.trade.UnderlyingCode,
|
|
PremiumPayDate = p.trade.PremiumPayDate,
|
|
OriginalStockEqvNotional = p.trade.OriginalStockEqvNotional,
|
|
StockEqvNotional = p.trade.StockEqvNotional,
|
|
OriginalNotional=p.trade.OriginalNotional??.0
|
|
|
|
});
|
|
}
|
|
return new Dictionary<int, TradeDicSimpleDto>();
|
|
}
|
|
}
|
|
}
|