778 lines
40 KiB
C#
778 lines
40 KiB
C#
using BaseOUDAL;
|
|
using NPOI.SS.Formula.Functions;
|
|
using Qdp.Foundation.Implementations;
|
|
using Qdp.Pricing.Base.Utilities;
|
|
using Qdp.Pricing.Library.Base.Utilities;
|
|
using System.Data;
|
|
using System.Net;
|
|
using System.Text.RegularExpressions;
|
|
using YLErp.BLL;
|
|
using YLErp.Commons;
|
|
using YLErp.Configuration;
|
|
using YLErp.DBModels.Consts;
|
|
using YLErp.DBModels.Enums;
|
|
using YLErp.Helpers;
|
|
using YLErp.Modules.EodModule;
|
|
using YLErp.Modules.StructureModule;
|
|
using YLErp.Modules.SuperviseReportModule.SAC.Common;
|
|
using YLErp.Modules.SuperviseReportModule.SAC.Model;
|
|
using YLErp.QdpModule;
|
|
using static YLErp.DBModels.Consts.ConsReport;
|
|
|
|
namespace YLErp.Modules.SuperviseReportModule.SAC.Service
|
|
{
|
|
//交易确认书-期权交易确认书
|
|
class ReportOptionConfirmationService : ReportBaseService
|
|
{
|
|
public ReportOptionConfirmationService(OptUserInfo optUser) : base(optUser)
|
|
{
|
|
}
|
|
|
|
protected override string _excelDataSourcePath => "交易相关\\";
|
|
|
|
protected override string _excelDataSourceFileName => "import_OptionConfirmation_template.xlsx";
|
|
|
|
protected override DataFlagsEnum BusiDataType => DataFlagsEnum.A1004;
|
|
|
|
private List<OptFlagsEnum>? _validOperationType = null;
|
|
public override List<OptFlagsEnum> ValidOperationType
|
|
{
|
|
get
|
|
{
|
|
_validOperationType ??= new List<OptFlagsEnum>() {
|
|
OptFlagsEnum.A,
|
|
OptFlagsEnum.U,
|
|
OptFlagsEnum.D,
|
|
};
|
|
return _validOperationType;
|
|
}
|
|
}
|
|
|
|
protected override SuperviseReportTypeEnum ReportType => SuperviseReportTypeEnum.SAC_OptionConfirmation;
|
|
|
|
readonly List<SACReportNotes> noteList = new();
|
|
|
|
protected override BodyModel GenerateBody(out bool noData, out List<string> fileList)
|
|
{
|
|
fileList = new List<string>();
|
|
noData = true;
|
|
var model = new BodyModel();
|
|
var dataList = new List<OptionConfirmationModel>();
|
|
//if (_reqInfo.DataSource.HasFlag(SAC_ReportDataSourceEnum.Template))
|
|
//{
|
|
dataList = GetOptionConfirmationModelFromExcel(ref fileList);
|
|
//}
|
|
var subsystemDataList = loadSubsystemDataSource<OptionConfirmationModel>(fileList, AddSubsystemNote);
|
|
|
|
if (subsystemDataList != null && subsystemDataList.Count > 0)
|
|
{
|
|
dataList.AddRange(subsystemDataList);
|
|
}
|
|
|
|
fileList = fileList.Distinct().ToList();
|
|
noData = dataList.Count == 0;
|
|
model.OptionConfirmation = dataList;
|
|
return model;
|
|
}
|
|
|
|
public bool AddSubsystemNote(OptionConfirmationModel model, List<string> fileList, string tag)
|
|
{
|
|
var note = base.GetReportNotes(ReportType, formatInfoTag(model, true)).FirstOrDefault();//参数true要加,要不A和D会查到同一条记录,在D时候,就会和A相同的数据
|
|
if (note == null)
|
|
{
|
|
note = new SACReportNotes()
|
|
{
|
|
InfoCache = $"{{\"NotinalPrincipleAmt\":\"{model.NotinalPrincipleAmt}\",\"DueDate\":\"{model.DueDate}\",\"Tag\":\"{model.ConfirmationNo}\",\"Source\":\"Subsystem\",\"SubFileTag\":\"{tag}\",\"ExceID\":\"{model.ExceID}\"}}",
|
|
IsValid = true,
|
|
};
|
|
}
|
|
else//多次U的时候,每次用最新的tag来赋值SubFileTag
|
|
{
|
|
switch (model.OperationType)
|
|
{
|
|
case OptFlagsEnum.A:
|
|
return false;//新增数据已报送,跳过
|
|
case OptFlagsEnum.U:
|
|
//多次U的时候,每次用最新的tag来赋值SubFileTag
|
|
note.InfoCache = $"{{\"NotinalPrincipleAmt\":\"{model.NotinalPrincipleAmt}\",\"DueDate\":\"{model.DueDate}\",\"Tag\":\"{model.ConfirmationNo}\",\"Source\":\"Subsystem\",\"SubFileTag\":\"{tag}\",\"ExceID\":\"{model.ExceID}\"}}";
|
|
note.IsValid = true;
|
|
break;
|
|
case OptFlagsEnum.D://
|
|
note.IsValid = false;
|
|
break;
|
|
case OptFlagsEnum.NONE:
|
|
default:
|
|
throw new ServiceException("未知操作类型");
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(model.ComplianceOpinion))
|
|
{
|
|
fileList.Add(model.ComplianceOpinion);
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(model.PerformanceGuaranteeAtt))
|
|
{
|
|
fileList.Add(model.PerformanceGuaranteeAtt);
|
|
}
|
|
|
|
//if (model.ConfirmationAttTuple != null && model.ConfirmationAttTuple.Count > 0)
|
|
//{
|
|
// fileList.AddRange(model.ConfirmationAttTuple.Select(x => x.ConfirmationAtt));
|
|
//}
|
|
|
|
model.ExceID = base.formatExceID();
|
|
note.id = 0;
|
|
note.ExceId = model.ExceID;
|
|
note.CreateTime = DateTime.Now;
|
|
note.FileTag = FileTag;
|
|
note.ReportType = ReportType;
|
|
note.ReportDate = _reqInfo.ReportDate;
|
|
note.InfoTag = formatInfoTag(model, true);
|
|
note.OptTime = note.CreateTime;
|
|
note.RetCode = "";
|
|
note.RetMsg = "";
|
|
note.ReportResponse = false;
|
|
note.BizId = "";
|
|
note.changeStatus = false;
|
|
noteList.Add(note);
|
|
return true;
|
|
}
|
|
|
|
private List<OptionConfirmationModel> GetOptionConfirmationModelFromExcel(ref List<string> fileList)
|
|
{
|
|
var result = new List<OptionConfirmationModel>();
|
|
var path = "";
|
|
if (_excelDataSource != null && _excelDataSource.Tables.Contains("期权交易确认书明细"))
|
|
{
|
|
var sourcePath = Path.Combine(_excelDataSourceRootPath, "附件");
|
|
var dt = _excelDataSource.Tables["期权交易确认书明细"];
|
|
for (var i = 1; i < dt.Rows.Count; i++)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(dt.Rows[i][0]?.ToString()))
|
|
{
|
|
//第一列空白说明数据结束了;
|
|
break;
|
|
}
|
|
|
|
OptionConfirmationModel model = new OptionConfirmationModel();
|
|
|
|
model.ConfirmationNo = GetDataSetValue(dt, i, 2);
|
|
var optType = OptFlagsEnum.NONE;
|
|
switch (dt.Rows[i][3]?.ToString())
|
|
{
|
|
case "0":
|
|
case "A":
|
|
case "首次":
|
|
optType = OptFlagsEnum.A;
|
|
break;
|
|
case "1":
|
|
case "U":
|
|
case "变更":
|
|
optType = OptFlagsEnum.U;
|
|
break;
|
|
case "2":
|
|
case "D":
|
|
case "废止":
|
|
optType = OptFlagsEnum.D;
|
|
ReportStatus.AddCacheInfo($"{DataFlagsEnum.A1018}_D", model.ConfirmationNo);
|
|
break;
|
|
}
|
|
if (optType != _operationType)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
model.OperationType = optType;
|
|
model.MasterAgrmtNo = GetDataSetValue(dt, i, 0);
|
|
model.SupAgrmtNo = GetDataSetValue(dt, i, 1);
|
|
model.ConfirmationType = ConsReport.ReportTypeMap[optType == OptFlagsEnum.A ? "首次" : "变更"];
|
|
model.FillParty = ConsReport.FillPartyMap[GetDataSetValue(dt, i, 4)];
|
|
model.OptionSeller = ConsReport.OptionTraderMap[GetDataSetValue(dt, i, 5)];
|
|
model.OptionDirection = ConsReport.OptionDirectionMap[GetDataSetValue(dt, i, 6)];
|
|
model.OptionStructureType = ConsReport.OptionStructureTypeMap[GetDataSetValue(dt, i, 7)];
|
|
model.OptionStructure = GetDataSetValue(dt, i, 8);
|
|
model.ExerciseApproach = ConsReport.ExerciseApproachMap[GetDataSetValue(dt, i, 9)];
|
|
model.StartDate = GetDataSetValue(dt, i, 10);
|
|
model.DueDate = GetDataSetValue(dt, i, 11);
|
|
model.SettlementDate = GetDataSetValue(dt, i, 12);
|
|
model.OptionPremium = GetDataSetValue(dt, i, 13);
|
|
model.AnnualizedDays = GetDataSetValue(dt, i, 14);
|
|
model.PricingVolatility = GetDataSetValueToDoubleOrNull(dt, i, 15)?.ToString("0.00");
|
|
model.RiskFreeInterestRates = GetDataSetValueToDoubleOrNull(dt, i, 16)?.ToString("0.00");
|
|
var currencyStr = GetDataSetValue(dt, i, 17);
|
|
currencyStr = currencyStr == "其他" ? "Other" : currencyStr;
|
|
if (!Enum.TryParse(currencyStr, out CurrencyEnum currency))
|
|
{
|
|
model.Currency = null;
|
|
}
|
|
else
|
|
{
|
|
model.Currency = ((int)currency).ToString();
|
|
|
|
}
|
|
model.NotinalPrincipleAmt = GetDataSetValueToDoubleOrNull(dt, i, 18)?.ToString("0.00");
|
|
model.ClearingAgency = ConsReport.ClearingAgencyMap[GetDataSetValue(dt, i, 19)];
|
|
model.TradingPlace = ConsReport.TradingPlaceMap[GetDataSetValue(dt, i, 20)];
|
|
model.TradingPlaceOther = GetDataSetValue(dt, i, 21);
|
|
//model.BusinessModelType = ConsReport.BusinessModelTypeMap[GetDataSetValue(dt, i, 18)];
|
|
model.ConfirmationRemark = GetDataSetValue(dt, i, 22);
|
|
model.UndrlygAssetType = ConsReport.UndrlygAssetTypeMap[GetDataSetValue(dt, i, 23)];
|
|
model.UndrlygAssetNo = ConsReport.UndrlygAssetNoMap[GetDataSetValue(dt, i, 24)];
|
|
model.ProfitCalculationInfo = GetDataSetValue(dt, i, 25);
|
|
model.ProfitRemark = GetDataSetValue(dt, i, 26);
|
|
model.PerformanceGuaranteeType = ConsReport.PerformanceGuaranteeMap[GetDataSetValue(dt, i, 27)];
|
|
model.PerformanceCollProvider = ConsReport.PerformanceCollProviderMap[GetDataSetValue(dt, i, 28)];
|
|
model.PartyUseColl = ConsReport.BoolMap[GetDataSetValue(dt, i, 29)];
|
|
model.CollInstruction = GetDataSetValue(dt, i, 30);
|
|
model.CalculateCollInterest = ConsReport.BoolMap[GetDataSetValue(dt, i, 31)];
|
|
model.PerformanceCollInitialRatio = GetDataSetValue(dt, i, 32);
|
|
model.PerformanceCollInitialRatioCash = GetDataSetValue(dt, i, 33);
|
|
model.PerformanceCollAddtlRatio = GetDataSetValue(dt, i, 34);
|
|
model.PerformanceCollOffsetRatio = GetDataSetValue(dt, i, 35);
|
|
model.MaintainGuaranteeRatio = GetDataSetValue(dt, i, 36);
|
|
model.PerformanceGuaranteeRemark = GetDataSetValue(dt, i, 37);
|
|
model.PerformanceGuaranteeAtt = GetDataSetValue(dt, i, 38);
|
|
model.Remark = GetDataSetValue(dt, i, 39);
|
|
model.ValidNotinalPrincipleAmt = GetDataSetValueToDoubleOrNull(dt, i, 40)?.ToString("0.00");
|
|
model.ComplianceOpinion = GetDataSetValue(dt, i, 41);
|
|
model.PtyAPdctName = GetDataSetValue(dt, i, 42);
|
|
model.PytAPdctCode = GetDataSetValue(dt, i, 43);
|
|
model.PtyBPdctName = GetDataSetValue(dt, i, 44);
|
|
model.PytBPdctCode = GetDataSetValue(dt, i, 45);
|
|
model.CrossBorderTransactions = BoolMap[GetDataSetValue(dt, i, 46)];
|
|
model.Blank1 = GetDataSetValue(dt, i, 47);
|
|
model.Blank2 = GetDataSetValue(dt, i, 48);
|
|
|
|
var notinalPrincipleAmt = GetDataSetValueToDouble(dt, i, 18);
|
|
|
|
var cacheValue = (model.ConfirmationNo ?? "").ToString();
|
|
if (cacheValue.IsNullOrWhiteSpace())
|
|
{
|
|
continue;
|
|
}
|
|
if (ReportStatus.CheckCacheInfo(CacheKey, cacheValue))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
var note = base.GetReportNotes(ReportType, formatInfoTag(model)).FirstOrDefault();
|
|
if (note == null && _operationType == OptFlagsEnum.A)
|
|
{
|
|
note = new SACReportNotes()
|
|
{
|
|
IsValid = true,
|
|
};
|
|
}
|
|
else
|
|
{
|
|
if (note == null)
|
|
{
|
|
continue;
|
|
}
|
|
switch (_operationType)
|
|
{
|
|
case OptFlagsEnum.A:
|
|
continue;//新增数据已报送,跳过
|
|
case OptFlagsEnum.U:
|
|
note.IsValid = true;
|
|
break;
|
|
case OptFlagsEnum.D:
|
|
note.IsValid = false;
|
|
break;
|
|
case OptFlagsEnum.NONE:
|
|
default:
|
|
throw new ServiceException("未知操作类型");
|
|
}
|
|
if (_operationType == OptFlagsEnum.U)
|
|
{
|
|
var reportCacheDic = JsonHelper.ToObject<Dictionary<string, string>>(note.InfoCache) ?? new Dictionary<string, string>();
|
|
var settleList = base.GetReportNotes(SuperviseReportTypeEnum.SAC_OptionTermination, formatInfoTag(model, false, true));
|
|
if (settleList.Count > 0)
|
|
{
|
|
if (reportCacheDic.ContainsKey("DueDate") && !reportCacheDic["DueDate"].StartsWith(model.DueDate) && !model.DueDate.StartsWith(reportCacheDic["DueDate"]))
|
|
{
|
|
throw new ServiceException("补正时,如果该交易还存在有效的存续期记录,到期日字段不能修改");
|
|
}
|
|
if (reportCacheDic.ContainsKey("NotinalPrincipleAmt") && reportCacheDic["NotinalPrincipleAmt"] != model.NotinalPrincipleAmt && reportCacheDic["NotinalPrincipleAmt"] != notinalPrincipleAmt.ToString("0"))
|
|
{
|
|
throw new ServiceException("补正时,如果该交易还存在有效的存续期记录,名义本金额(人民币)字段不能修改");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (model.OperationType != OptFlagsEnum.A)
|
|
{
|
|
model.ConfirmationID = note.BizId;//确认书编号;
|
|
}
|
|
|
|
//var confirmationAttTuple = GetDataSetValue(dt, i, 19).Split(',');
|
|
//foreach (var item in confirmationAttTuple)
|
|
//{
|
|
// if (string.IsNullOrWhiteSpace(item))
|
|
// {
|
|
// continue;
|
|
// }
|
|
// model.ConfirmationAttTuple ??= new List<ConfirmationAttModel>();
|
|
// model.ConfirmationAttTuple.Add(new ConfirmationAttModel() { ConfirmationAtt = item });
|
|
// path = Path.Combine(sourcePath, item);
|
|
// if (!ReportStatus.CheckFileLength(path))
|
|
// {
|
|
// break;
|
|
// }
|
|
// fileList.Add(path);
|
|
//}
|
|
model.UndrlygAssetTuple = GetUndrlygAssetModel(model.ConfirmationNo, model.UndrlygAssetNo, model.UndrlygAssetType);
|
|
model.PerformanceCollTuple = GetPerformanceGuaranteeAttModel(model.ConfirmationNo, model.PerformanceGuaranteeType);
|
|
|
|
SetOptionStructureModelFromExcel(model);
|
|
path = Path.Combine(sourcePath, model.PerformanceGuaranteeAtt);
|
|
if (!string.IsNullOrWhiteSpace(model.PerformanceGuaranteeAtt))
|
|
{
|
|
if (!ReportStatus.CheckFileLength(path))
|
|
{
|
|
break;
|
|
}
|
|
fileList.Add(path);
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(model.ComplianceOpinion))
|
|
{
|
|
path = Path.Combine(sourcePath, model.ComplianceOpinion);
|
|
if (!ReportStatus.CheckFileLength(path))
|
|
{
|
|
break;
|
|
}
|
|
fileList.Add(path);
|
|
}
|
|
model.ExceID = base.formatExceID();
|
|
result.Add(model);
|
|
ReportStatus.AddCacheInfo(CacheKey, cacheValue);
|
|
note.id = 0;
|
|
note.InfoCache = $"{{\"NotinalPrincipleAmt\":\"{model.NotinalPrincipleAmt}\",\"DueDate\":\"{model.DueDate}\",\"Tag\":\"{model.ConfirmationNo}\",\"Source\":\"Template\"}}";
|
|
note.ExceId = model.ExceID;
|
|
note.CreateTime = DateTime.Now;
|
|
note.FileTag = FileTag;
|
|
note.ReportType = ReportType;
|
|
note.ReportDate = _reqInfo.ReportDate;
|
|
note.InfoTag = formatInfoTag(model, true);
|
|
note.OptTime = note.CreateTime;
|
|
note.RetCode = "";
|
|
note.RetMsg = "";
|
|
note.ReportResponse = false;
|
|
note.BizId = "";
|
|
note.changeStatus = false;
|
|
noteList.Add(note);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
private List<PerformanceGuaranteeAttModel> GetPerformanceGuaranteeAttModel(string masterAgrmtNo, string performanceGuaranteeType)
|
|
{
|
|
var result = new List<PerformanceGuaranteeAttModel>();
|
|
if (_excelDataSource != null && _excelDataSource.Tables.Contains("履约担保品详情明细"))
|
|
{
|
|
var dt = _excelDataSource.Tables["履约担保品详情明细"];
|
|
for (var i = 1; i < dt.Rows.Count; i++)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(dt.Rows[i][0]?.ToString()))
|
|
{
|
|
//第一列空白说明数据结束了;
|
|
break;
|
|
}
|
|
if (dt.Rows[i][0]?.ToString().Trim() != masterAgrmtNo)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
var model = new PerformanceGuaranteeAttModel
|
|
{
|
|
PerformanceGuaranteeType = performanceGuaranteeType,
|
|
ConfirmationNo = GetDataSetValue(dt, i, 0),
|
|
PerformanceCollType = ConsReport.PerformanceCollTypeMap[GetDataSetValue(dt, i, 1)],
|
|
PerformanceCollRange = ConsReport.PerformanceCollRangeMap[GetDataSetValue(dt, i, 2)],
|
|
MultiConfirmationID = GetDataSetValue(dt, i, 3),
|
|
Remarks = GetDataSetValue(dt, i, 4)
|
|
};
|
|
|
|
result.Add(model);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
private List<UndrlygAssetModel> GetUndrlygAssetModel(string masterAgrmtNo, string undrlygAssetNo, string undrlygAssetType)
|
|
{
|
|
var result = new List<UndrlygAssetModel>();
|
|
if (_excelDataSource != null && _excelDataSource.Tables.Contains("标的详情明细"))
|
|
{
|
|
var dt = _excelDataSource.Tables["标的详情明细"];
|
|
for (var i = 1; i < dt.Rows.Count; i++)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(dt.Rows[i][0]?.ToString()))
|
|
{
|
|
//第一列空白说明数据结束了;
|
|
break;
|
|
}
|
|
if (dt.Rows[i][0]?.ToString().Trim() != masterAgrmtNo)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
var model = new UndrlygAssetModel
|
|
{
|
|
ConfirmationNo = GetDataSetValue(dt, i, 0),
|
|
UndrlygAssetDtldType = ConsReport.SwapUndrlygAssetDtldTypeMap[GetDataSetValue(dt, i, 1)],
|
|
UndrlygAssetName = GetDataSetValue(dt, i, 2),
|
|
UndrlygAssetTradgPlc = GetDataSetValue(dt, i, 3),
|
|
UndrlygAssetCode = GetDataSetValue(dt, i, 4),
|
|
UndrlygAssetAmt = GetDataSetValue(dt, i, 5)
|
|
};
|
|
model.ContractMultiplier = GetDataSetValueToDoubleOrNull(dt, i, 6)?.ToString() ?? "";
|
|
|
|
model.UndrlygAssetNo = undrlygAssetNo;
|
|
model.MultiOrderOptionType = MultiOrderOptionTypeMap[GetDataSetValue(dt, i, 7)];
|
|
|
|
model.UndrlygAssetNotinalPrincipleAmtRMB = GetDataSetValueToDoubleOrNull(dt, i, 8)?.ToString();
|
|
model.OpeningPrice = GetDataSetValueToDoubleOrNull(dt, i, 9)?.ToString();
|
|
|
|
model.UndrlygAssetType = undrlygAssetType;
|
|
|
|
var currencyStr = GetDataSetValue(dt, i, 10);
|
|
currencyStr = currencyStr == "其他" ? "Other" : currencyStr;
|
|
if (!Enum.TryParse(currencyStr, out CurrencyEnum currency))
|
|
{
|
|
model.OpeningPriceCurrency = "";
|
|
}
|
|
else
|
|
{
|
|
model.OpeningPriceCurrency = ((int)currency).ToString();
|
|
}
|
|
|
|
model.Blank1 = GetDataSetValue(dt, i, 11);
|
|
model.Blank2 = GetDataSetValue(dt, i, 12);
|
|
|
|
result.Add(model);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
private void SetOptionStructureModelFromExcel(OptionConfirmationModel model)
|
|
{
|
|
var tbName = "";
|
|
|
|
switch (model.OptionStructureType)
|
|
{
|
|
case "0":
|
|
tbName = "期权结构类型详情(香草及其组合)";
|
|
break;
|
|
case "1":
|
|
tbName = "期权结构类型详情(二元及其组合)";
|
|
break;
|
|
case "2":
|
|
tbName = "期权结构类型详情(障碍及其组合)";
|
|
break;
|
|
case "3":
|
|
tbName = "期权结构类型详情(自动赎回)";
|
|
break;
|
|
case "4":
|
|
tbName = "期权结构类型详情(区间累计)";
|
|
break;
|
|
case "5":
|
|
tbName = "期权结构类型详情(安全气囊)";
|
|
break;
|
|
case "99":
|
|
tbName = "期权结构类型详情(其他)";
|
|
break;
|
|
}
|
|
|
|
if (_excelDataSource != null && _excelDataSource.Tables.Contains(tbName))
|
|
{
|
|
DataTable dt = _excelDataSource.Tables[tbName];
|
|
for (int i = 1; i < dt.Rows.Count; i++)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(dt.Rows[i][0]?.ToString()))
|
|
{
|
|
//第一列空白说明数据结束了;
|
|
break;
|
|
}
|
|
if (dt.Rows[i][0]?.ToString().Trim() != model.ConfirmationNo)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
switch (model.OptionStructureType)
|
|
{
|
|
case "0":
|
|
model.VanillaOptionStructureSubclass = VanillaOptionStructureSubclassMap[GetDataSetValue(dt, i, 1)];
|
|
model.VanillaStrikePriceCoefficientOne = GetDataSetValue(dt, i, 2);
|
|
model.VanillaStrikePriceCoefficientTwo = GetDataSetValue(dt, i, 3);
|
|
model.VanillaStrikePriceCoefficientThree = GetDataSetValue(dt, i, 4);
|
|
model.VanillaStrikePriceCoefficientFour = GetDataSetValue(dt, i, 5);
|
|
model.VanillaEngagementRateOne = GetDataSetValue(dt, i, 6);
|
|
model.VanillaEngagementRateTwo = GetDataSetValue(dt, i, 7);
|
|
model.VanillaEngagementRateThree = GetDataSetValue(dt, i, 8);
|
|
model.VanillaEngagementRateFour = GetDataSetValue(dt, i, 9);
|
|
model.VanillaBackCoverYield = GetDataSetValue(dt, i, 10);
|
|
model.VanillaCappingYield = GetDataSetValue(dt, i, 11);
|
|
model.VanillaBlank1 = GetDataSetValue(dt, i, 12);
|
|
model.VanillaBlank2 = GetDataSetValue(dt, i, 13);
|
|
break;
|
|
case "1":
|
|
model.DigitalOptionStructureSubclass = DigitalOptionStructureSubclassMap[GetDataSetValue(dt, i, 1)];
|
|
model.DigitalStrikePriceCoefficientOne = GetDataSetValue(dt, i, 2);
|
|
model.DigitalStrikePriceCoefficientTwo = GetDataSetValue(dt, i, 3);
|
|
model.DigitalStrikePriceCoefficientThree = GetDataSetValue(dt, i, 4);
|
|
model.DigitalEngagementRateOne = GetDataSetValue(dt, i, 5);
|
|
model.DigitalEngagementRateTwo = GetDataSetValue(dt, i, 6);
|
|
model.DigitalEngagementRateThree = GetDataSetValue(dt, i, 7);
|
|
model.DigitalYieldOneNonAnnualized = GetDataSetValue(dt, i, 8);
|
|
model.DigitalYieldTwoNonAnnualized = GetDataSetValue(dt, i, 9);
|
|
model.DigitalYieldThreeNonAnnualized = GetDataSetValue(dt, i, 10);
|
|
model.DigitalYieldFourNonAnnualized = GetDataSetValue(dt, i, 11);
|
|
model.DigitalBlank1 = GetDataSetValue(dt, i, 12);
|
|
model.DigitalBlank2 = GetDataSetValue(dt, i, 13);
|
|
break;
|
|
case "2":
|
|
model.BarrierOptionStructureSubclass = BarrierOptionStructureSubclassMap[GetDataSetValue(dt, i, 1)];
|
|
model.BarrierStrikePriceCoefficientOne = GetDataSetValue(dt, i, 2);
|
|
model.BarrierStrikePriceCoefficientTwo = GetDataSetValue(dt, i, 3);
|
|
model.BarrierEngagementRateOne = GetDataSetValue(dt, i, 4);
|
|
model.BarrierEngagementRateTwo = GetDataSetValue(dt, i, 5);
|
|
model.BarrierKnockInPriceCoefficient = GetDataSetValue(dt, i, 6);
|
|
model.BarrierKnockOutPriceCoefficientOne = GetDataSetValue(dt, i, 7);
|
|
model.BarrierKnockOutYieldOneNonAnnualized = GetDataSetValue(dt, i, 8);
|
|
model.BarrierKnockOutPriceCoefficientTwo = GetDataSetValue(dt, i, 9);
|
|
model.BarrierKnockOutYieldTwoNonAnnualized = GetDataSetValue(dt, i, 10);
|
|
model.BarrierObservationType = BarrierObservationTypeMap[GetDataSetValue(dt, i, 11)];
|
|
model.BarrierBackCoverYield = GetDataSetValue(dt, i, 12);
|
|
model.BarrierUnknockedYield = GetDataSetValue(dt, i, 13);
|
|
model.BarrierBlank1 = GetDataSetValue(dt, i, 14);
|
|
model.BarrierBlank2 = GetDataSetValue(dt, i, 15);
|
|
break;
|
|
case "3":
|
|
model.AutoCallableOptionStructureSubclass = AutoCallableOptionStructureSubclassMap[GetDataSetValue(dt, i, 1)];
|
|
model.AutoCallableEngagementRate = GetDataSetValueToDouble(dt, i, 2).ToString();
|
|
model.AutoCallableStrikePriceCoefficient = GetDataSetValue(dt, i, 3);
|
|
model.AutoCallableKnockOutPriceCoefficient = AddBrackets(GetDataSetValue(dt, i, 4));
|
|
model.AutoCallableKnockOutYieldAnnualized = AddBrackets(GetDataSetValue(dt, i, 5));
|
|
model.AutoCallableKnockOutObservationDay = AddBrackets(GetDataSetValue(dt, i, 6));
|
|
model.AutoCallableKnockOutSettlementDay = AddBrackets(GetDataSetValue(dt, i, 7));
|
|
model.AutoCallableKnockInPriceCoefficient = AddBrackets(GetDataSetValue(dt, i, 8));
|
|
model.AutoCallableKnockInObservationDay = AddBrackets(GetDataSetValue(dt, i, 9));
|
|
model.AutoCallableDividendYieldAnnualized = GetDataSetValue(dt, i, 10);
|
|
model.AutoCallableMinimumYieldAnnualized = GetDataSetValue(dt, i, 11);
|
|
model.AutoCallableMinimumPrincipalProtectionRatio = GetDataSetValueToDouble(dt, i, 12).ToString();
|
|
model.AutoCallableWhetherDiscountedWarehouseType =
|
|
AutoCallableWhetherDiscountedWarehouseTypeMap[GetDataSetValue(dt, i, 13)];
|
|
model.AutoCallableWhetherRevenueEnhancedType =
|
|
AutoCallableWhetherRevenueEnhancedTypeMap[GetDataSetValue(dt, i, 14)];
|
|
model.AutoCallableWhetherFixedCouponNote =
|
|
AutoCallableWhetherRevenueEnhancedTypeMap[GetDataSetValue(dt, i, 15)];
|
|
model.AutoCallableWhetherKnockInPriceCoefficientIsVariable =
|
|
AutoCallableWhetherKnockInPriceCoefficientIsVariableMap[GetDataSetValue(dt, i, 16)];
|
|
model.AutoCallableWhetherKnockOutPriceCoefficientIsVariable =
|
|
AutoCallableWhetherKnockOutPriceCoefficientIsVariableMap[GetDataSetValue(dt, i, 17)];
|
|
model.AutoCallableWhetherKnockOutYieldIsVariable =
|
|
AutoCallableWhetherKnockOutYieldIsVariableMap[GetDataSetValue(dt, i, 18)];
|
|
model.AutoCallableWhetherDividendYieldIsVariable =
|
|
AutoCallableWhetherDividendYieldIsVariableMap[GetDataSetValue(dt, i, 19)];
|
|
model.AutoCallableBlank1 = GetDataSetValue(dt, i, 20);
|
|
model.AutoCallableBlank2 = GetDataSetValue(dt, i, 21);
|
|
break;
|
|
case "4":
|
|
model.RangeAccrualOptionStructureSubclass =
|
|
RangeAccrualOptionStructureSubclassMap[GetDataSetValue(dt, i, 1)];
|
|
model.RangeAccrualStrikePriceCoefficientOne = GetDataSetValue(dt, i, 2);
|
|
model.RangeAccrualStrikePriceCoefficientTwo = GetDataSetValue(dt, i, 3);
|
|
model.RangeAccrualStrikePriceCoefficientThree = GetDataSetValue(dt, i, 4);
|
|
model.RangeAccrualStrikePriceCoefficientFour = GetDataSetValue(dt, i, 5);
|
|
model.RangeAccrualEngagementRate = GetDataSetValue(dt, i, 6);
|
|
model.RangeAccrualOneNonAnnualized = GetDataSetValue(dt, i, 7);
|
|
model.RangeAccrualTwoNonAnnualized = GetDataSetValue(dt, i, 8);
|
|
model.RangeAccrualThreeNonAnnualized = GetDataSetValue(dt, i, 9);
|
|
model.RangeAccrualFourNonAnnualized = GetDataSetValue(dt, i, 10);
|
|
//model.RangeAccrualMinimumYieldAnnualized = GetDataSetValue(dt, i, 11);
|
|
model.RangeAccrualBlank1 = GetDataSetValue(dt, i, 11);
|
|
model.RangeAccrualBlank2 = GetDataSetValue(dt, i, 12);
|
|
break;
|
|
case "5":
|
|
model.AirbagOptionStructureSubclass =
|
|
AirbagOptionStructureSubclassMap[GetDataSetValue(dt, i, 1)];
|
|
model.AirbagStrikePriceCoefficientOne = GetDataSetValue(dt, i, 2);
|
|
model.AirbagStrikePriceCoefficientTwo = GetDataSetValue(dt, i, 3);
|
|
model.AirbagStrikePriceCoefficientThree = GetDataSetValue(dt, i, 4);
|
|
model.AirbagStrikePriceCoefficientFour = GetDataSetValue(dt, i, 5);
|
|
model.AirbagEngagementRateOne = GetDataSetValue(dt, i, 6);
|
|
model.AirbagEngagementRateTwo = GetDataSetValue(dt, i, 7);
|
|
model.AirbagEngagementRateThree = GetDataSetValue(dt, i, 8);
|
|
model.AirbagKnockInPriceCoefficient = GetDataSetValue(dt, i, 9);
|
|
model.AirbagBackCoverYield = GetDataSetValue(dt, i, 10);
|
|
model.AirbagCappingYield = GetDataSetValue(dt, i, 11);
|
|
model.AirbagBlank1 = GetDataSetValue(dt, i, 12);
|
|
model.AirbagBlank2 = GetDataSetValue(dt, i, 13);
|
|
break;
|
|
case "99":
|
|
model.OthersOptionStructureSubclass = GetDataSetValue(dt, i, 1);
|
|
model.OthersStrikePriceCoefficientOne = GetDataSetValue(dt, i, 2);
|
|
model.OthersStrikePriceCoefficientTwo = GetDataSetValue(dt, i, 3);
|
|
model.OthersStrikePriceCoefficientThree = GetDataSetValue(dt, i, 4);
|
|
model.OthersStrikePriceCoefficientFour = GetDataSetValue(dt, i, 5);
|
|
model.OthersEngagementRateOne = GetDataSetValue(dt, i, 6);
|
|
model.OthersEngagementRateTwo = GetDataSetValue(dt, i, 7);
|
|
model.OthersEngagementRateThree = GetDataSetValue(dt, i, 8);
|
|
model.OthersEngagementRateFour = GetDataSetValue(dt, i, 9);
|
|
model.OthersBarrierPricesCoefficientOne = GetDataSetValue(dt, i, 10);
|
|
model.OthersBarrierPricesCoefficientTwo = GetDataSetValue(dt, i, 11);
|
|
model.OthersBackCoverYield = GetDataSetValue(dt, i, 12);
|
|
model.OthersCappingYield = GetDataSetValue(dt, i, 13);
|
|
model.OthersBlank1 = GetDataSetValue(dt, i, 14);
|
|
model.OthersBlank2 = GetDataSetValue(dt, i, 15);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private string formatInfoTag(OptionConfirmationModel model, bool suffixType = false, bool isSettlement = false)
|
|
{
|
|
var result = $"{(isSettlement ? "" : BusiDataType.ToString())}_{model.ConfirmationNo.Replace("_", "-")}_{(isSettlement ? "" : "成交_")}";
|
|
if (suffixType)
|
|
{
|
|
result = $"{result}{_operationType}";
|
|
}
|
|
return result;
|
|
}
|
|
|
|
protected override string _changeCodeOfInfoTag(string infoTag, string newCode, out string originalCode)
|
|
{
|
|
var arr = infoTag.Split('_');
|
|
if (arr.Length != 4)
|
|
{
|
|
throw new ServiceException($"InfoTag信息不匹配:{infoTag}");
|
|
}
|
|
originalCode = arr[1];
|
|
arr[1] = newCode.Replace("_", "-");
|
|
return string.Join("_", arr);
|
|
}
|
|
|
|
protected override List<SacInfo> CheckBodyValue(BodyModel model, out bool checkStatus)
|
|
{
|
|
var result = new List<SacInfo>();
|
|
if (model?.OptionConfirmation != null)
|
|
{
|
|
var helper = new Common.CheckHelper<OptionConfirmationModel>();
|
|
//var cAttHelper = new Common.CheckHelper<ConfirmationAttModel>();
|
|
var undrlygHelper = new Common.CheckHelper<UndrlygAssetModel>();
|
|
var pAttHelper = new Common.CheckHelper<PerformanceGuaranteeAttModel>();
|
|
for (var i = 0; i < model.OptionConfirmation.Count; i++)
|
|
{
|
|
var listRoot = new List<SacInfo>();
|
|
var item = model.OptionConfirmation[i];
|
|
if (item.IgnoreCheck)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
helper.ExecuteCheck(item, (name, value, msg) =>
|
|
{
|
|
listRoot.Add(new SacInfo(name, value, msg));
|
|
});
|
|
if (item.UndrlygAssetTuple != null)
|
|
{
|
|
for (var j = 0; j < item.UndrlygAssetTuple.Count; j++)
|
|
{
|
|
var listItem = new List<SacInfo>();
|
|
var undrlygItem = item.UndrlygAssetTuple[j];
|
|
undrlygHelper.ExecuteCheck(undrlygItem, (name, value, msg) =>
|
|
{
|
|
listItem.Add(new SacInfo(name, value, msg));
|
|
});
|
|
if (listItem.Count > 0)
|
|
{
|
|
var temp = new SacInfo("UndrlygAssetTuple", j)
|
|
{
|
|
SubMaps = new List<SacInfo>(listItem)
|
|
};
|
|
listRoot.Add(temp);
|
|
}
|
|
}
|
|
}
|
|
if (item.PerformanceCollTuple != null)
|
|
{
|
|
for (var j = 0; j < item.PerformanceCollTuple.Count; j++)
|
|
{
|
|
var listItem = new List<SacInfo>();
|
|
var pItem = item.PerformanceCollTuple[j];
|
|
pAttHelper.ExecuteCheck(pItem, (name, value, msg) =>
|
|
{
|
|
listItem.Add(new SacInfo(name, value, msg));
|
|
});
|
|
if (listItem.Count > 0)
|
|
{
|
|
var temp = new SacInfo("PerformanceCollTuple", j)
|
|
{
|
|
SubMaps = new List<SacInfo>(listItem)
|
|
};
|
|
listRoot.Add(temp);
|
|
}
|
|
}
|
|
}
|
|
if (listRoot.Count > 0)
|
|
{
|
|
var errMsg = new SacInfo("OptionConfirmation", i)
|
|
{
|
|
FieldValue = item.ConfirmationNo,
|
|
SubMaps = new List<SacInfo>(listRoot)
|
|
};
|
|
result.Add(errMsg);
|
|
}
|
|
}
|
|
}
|
|
checkStatus = result.Count > 0;
|
|
return result;
|
|
}
|
|
|
|
public override bool BeforeOfGenerated(out string errMsg)
|
|
{
|
|
errMsg = "";
|
|
foreach (var file in xmlAttachmentList)
|
|
{
|
|
try
|
|
{
|
|
File.Delete(file);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
LogFactory.GetLogger<ReportMasterAgrmtProductService>().Error(e);
|
|
};
|
|
}
|
|
for (var i = 0; i < noteList.Count; i++)
|
|
{
|
|
base.SaveReportNotes(noteList[i]);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
//写一个方法,判断字符串前面是否存在括号,如果不存在,就在前面加上括号,后面同理
|
|
private string AddBrackets(string str)
|
|
{
|
|
if (str.IsNullOrWhiteSpace())
|
|
{
|
|
return str;
|
|
}
|
|
string result = str;
|
|
if (!str.StartsWith("("))
|
|
{
|
|
result = "(" + result;
|
|
}
|
|
if (!str.EndsWith(")"))
|
|
{
|
|
result += ")";
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
}
|