fix(swap): 修复FR007数据添加时的标的验证和关联逻辑

- 添加对FR007标的存在的验证检查
- 移除冗余的新增数据查询逻辑
- 直接使用查找到的标的ID进行关联
- 集成EodPriceService中的标的ID解析逻辑
- 统一数据源设置为人工来源
This commit is contained in:
张名锐
2026-08-07 19:44:01 +08:00
parent a0be0eb003
commit fb5a5d0ab4
+9 -14
View File
@@ -9,6 +9,7 @@ using YLErp.DBModels;
using YLErp.Helpers;
using YLErp.Model;
using YLErp.Model.Enum;
using YLErp.Modules.EodModule;
using YLErp.Modules.SwapModule.Dto;
using YLErp.Office;
using YLErp.QdpModule;
@@ -79,8 +80,13 @@ namespace YLErp.Modules.SwapModule
/// <exception cref="ServiceException"></exception>
public bool AddOrUpdateFRdata(Double price, DateTime dateTime)
{
string beforedate = "";
var frdata = DbContext.eod_commodity_future_price.Where(a => a.ValueDate == dateTime && a.UnderlyingCode == "FR007").FirstOrDefault();
var frUnderlying = DbContext.underlying_manager.FirstOrDefault(a => a.UnderlyingCode == "FR007");
if (frUnderlying == null)
{
throw new ServiceException("找不到FR007的标的");
}
if (frdata == null)
{
frdata = new eod_commodity_future_price();
@@ -91,28 +97,17 @@ namespace YLErp.Modules.SwapModule
frdata.ValueDate = dateTime;
frdata.HighPrice = 0;
frdata.LowPrice = 0;
beforedate = JsonHelper.Serialize(frdata);
}
else
{
//新增
var newestdata = DbContext.eod_commodity_future_price.OrderByDescending(a => a.ValueDate).FirstOrDefault();
if (newestdata == null)
{
var underlyingCode = DbContext.underlying_manager.Where(a => a.UnderlyingCode == "FR007").FirstOrDefault();
if (underlyingCode == null)
{
throw new ServiceException("找不到FR007的标的");
}
newestdata = new eod_commodity_future_price();
newestdata.UnderlyingId = underlyingCode.id;
}
frdata.ValueDate = dateTime;
frdata.UnderlyingCode = "FR007";
frdata.UnderlyingId = newestdata.UnderlyingId;
frdata.UnderlyingId = frUnderlying.id;
frdata.DataSource = EodPriceBase.;
DbContext.Add(frdata);
}
frdata.UnderlyingId = EodPriceService.ResolveUnderlyingIdForCode(frdata.UnderlyingCode, frdata.UnderlyingId ?? 0, frUnderlying.id);
frdata.ClosePrice = Math.Round(price, 4);
frdata.SettlePrice = Math.Round(price, 4);
frdata.ReferencePrice = Math.Round(price, 4);