469 lines
38 KiB
C#
469 lines
38 KiB
C#
using Newtonsoft.Json;
|
|
using System.Text;
|
|
using YLErp.Modules.QuotationModule;
|
|
using YLErp.Office.iTextModule;
|
|
using YLErp.QdpModule;
|
|
|
|
namespace YLErp.Web.Controllers
|
|
{
|
|
public class quotationconfirmController : BaseController
|
|
{
|
|
protected YLContext db = new();
|
|
|
|
private IEnumerable<flat_price_quotationDto> GetSortFlat_Quotation(DateTime? date, string[] assetTypeArray)
|
|
{
|
|
var userGroup = CurUser.UserGroup;
|
|
var flat_priceList = flat_price_quotationBLL.GetSortFlat_Quotation(date, userGroup);
|
|
if (assetTypeArray != null && (assetTypeArray = assetTypeArray.Where(O => !string.IsNullOrEmpty(O) && O.ToLower() != "undefind" && O.ToLower() != "null").ToArray()).Any())
|
|
{
|
|
var varietyCodes =
|
|
VarietyBLL.GetAllvarietyModel()
|
|
.Where(O => assetTypeArray.Contains(O.AssetType))
|
|
.Select(O => O.VarietyCode).ToHashSet(StringComparer.OrdinalIgnoreCase);
|
|
flat_priceList = flat_priceList.Where(O =>
|
|
{
|
|
if (O.UnderlyingType == ConsGlobal.InstrumentType.CommodityFutures)
|
|
{
|
|
return varietyCodes.Contains(UnderlyingHelper.GetVarietyCode(O.UnderlyingCode));
|
|
}
|
|
return varietyCodes.Contains(O.VarietyCode);
|
|
}).ToArray();
|
|
}
|
|
return flat_priceList;
|
|
}
|
|
|
|
public ActionResult OutPutPDF(DateTime? endDate, string assetType)
|
|
{
|
|
var flat_priceList = GetSortFlat_Quotation(endDate, assetType?.Split(','));
|
|
var selectedQuotation = GetQuotationGroup(flat_priceList, endDate);
|
|
var sb = new StringBuilder();
|
|
var ttindex = 0;
|
|
if (PS.Config.Is海通)
|
|
{
|
|
sb.Append($@" <div class=""title-wrap"" style=""width:100%;height:105px;"">
|
|
<div style="" text-align: center;margin:0px;justify-content: center;align-items: center;display: flex;"">
|
|
<table style=""width:100%;text-align: center;margin:0 auto;""><tr><td style=""text-align:right;width:25%""> <img style=""margin-right:5px;width:51px;height:34px;"" width=51 height=34 src=""{"/App_Docs/Images/title.png"}""/>
|
|
</td><td style=""text-align:left;width:60%""> <span style="" font-size: 18px;font-weight: 600"">{PS.Config.CompanyName}商品场外期权报价</span></td>
|
|
</tr></table>
|
|
</div>
|
|
<div style=""clear: both; ""></div>
|
|
<p style=""text-align:center;font-size:12px;"">1个月平值看涨/看跌期权</p>
|
|
<p style=""text-align:center;margin:0px;"">
|
|
<span style=""padding-left:0px 9px 0px 15px;font-size:12px;"">报价日: {valuedateBLL.ValueDate:yyyy-MM-dd}</span>
|
|
<span style=""padding-left:0px 9px 0px 15px;font-size:12px;"">到期日: {endDate.Value:yyyy-MM-dd}</span>
|
|
</p>
|
|
</div>
|
|
<table style="" width: 100%;font-family:YouYuan;"">
|
|
<tr>
|
|
<td style=""width: 10%""> </td>
|
|
<td style=""width: 80%"">
|
|
<table style=
|
|
""width: 100%;max-width: 100%;font-family:YouYuan;margin-bottom: 10px;border-collapse:collapse;margin-top: 30px;"">
|
|
<tr style=""height: 25px; font-size:11px;font-family:YouYuan;background:#15498c;color:#fff;text-align:center;font-weight:400;"">
|
|
<th colspan=""2"" style=""border-right: 1px solid #fff;border-bottom: 1px solid #fff;"">报价品种</th>
|
|
<th colspan=""2"" style=""border-right: 1px solid #fff;border-bottom: 1px solid #fff;"">标的信息</th>
|
|
<th colspan=""3"" style=""border-right: 1px solid #fff;border-bottom: 1px solid #fff;"">买入</th>
|
|
<th colspan=""3"" style=""border-right: 1px solid #fff;border-bottom: 1px solid #fff;"">卖出 </th>
|
|
</tr>
|
|
<tr style=""height: 25px;font-size:11px;font-family:YouYuan; background:#15498c;color:#fff;text-align:center;"">
|
|
<th style=""border-right:1px solid #fff;width = 8%"">板块</th>
|
|
<th style=""border-right:1px solid #fff;"">品种</th>
|
|
<th style=""border-right:1px solid #fff;"">代码</th>
|
|
<th style=""border-right:1px solid #fff;"">价格</th>
|
|
<th style=""border-right:1px solid #fff;"">波动率</th>
|
|
<th style=""border-right:1px solid #fff;"">绝对值</th>
|
|
<th style=""border-right:1px solid #fff;"">百分比%</th>
|
|
<th style=""border-right:1px solid #fff;"">波动率</th>
|
|
<th style=""border-right:1px solid #fff;"">绝对值</th>
|
|
<th style=""border-right:1px solid #fff;"">百分比%</th>
|
|
</tr>");
|
|
foreach (var quo in selectedQuotation)
|
|
{
|
|
for (var index = 0; index < quo.flat_price_quotations.Count; index++)
|
|
{
|
|
ttindex++;
|
|
var bgStyle = "";
|
|
if (ttindex % 2 == 1)
|
|
{
|
|
bgStyle = "background:#ecedec;font-family:YouYuan;";
|
|
}
|
|
var showName = quo.flat_price_quotations[index].ShortName;
|
|
if (string.IsNullOrEmpty(showName))
|
|
{
|
|
showName = quo.flat_price_quotations[index].UnderlyingType;
|
|
}
|
|
sb.Append($@" <tr style=""{bgStyle}"">");
|
|
if (index == 0)
|
|
{
|
|
sb.Append($@" <td style=""border-bottom: 1px solid #416fab;font-weight:600;border-left: 1px solid #416fab;border-right: 1px solid #416fab;background:#fff; font-size:11px; letter-spacing: 1rem; padding: 0px 15px;box-sizing:border-box;text-align:center;margin:0px;"" rowspan=""{quo.flat_price_quotations.Count}"">{quo.AssetType}</td>");
|
|
}
|
|
sb.Append($@" <td style=""border-right:1px solid #416fab;border-bottom: 1px solid #416fab;height:30px;font-size:11px;font-family:YouYuan;text-align:center;"">{showName}</td>");
|
|
sb.Append($@" <td style=""border-right: 1px solid #416fab;border-bottom: 1px solid #416fab;height:30px;font-size:11px;font-family:YouYuan;text-align:center;;"">{quo.flat_price_quotations[index].UnderlyingCode}</td>");
|
|
sb.Append($@" <td style=""border-right:1px solid #416fab;border-bottom: 1px solid #416fab;height:30px;font-size:11px;font-family:YouYuan;text-align:center;;"">{quo.flat_price_quotations[index].SpotPrice}</td>");
|
|
sb.Append($@" <td style=""border-right: 1px solid #416fab;border-bottom:1px solid #416fab;height:30px;font-size:11px;font-family:YouYuan;text-align:center;"">{quo.flat_price_quotations[index].BuyOptionVol?.ToString("P")}</td>");
|
|
sb.Append($@" <td style=""border-right: 1px solid #416fab;border-bottom:1px solid #416fab;height:30px;font-size:11px;font-family:YouYuan;text-align:center;"">{quo.flat_price_quotations[index].BuyOptionPrice?.ToString("N")}</td>");
|
|
sb.Append($@" <td style=""border-right: 1px solid #416fab;border-bottom: 1px solid #416fab;height:30px;font-size:11px;font-family:YouYuan;text-align:center;"">{(quo.flat_price_quotations[index].BuyOptionPrice / quo.flat_price_quotations[index].SpotPrice)?.ToString("P")}</td>");
|
|
sb.Append($@" <td style=""border-right: 1px solid #416fab;border-bottom: 1px solid #416fab;height:30px;font-size:11px;font-family:YouYuan;text-align:center;"">{quo.flat_price_quotations[index].SellOptionVol?.ToString("P")}</td>");
|
|
sb.Append($@" <td style=""border-right: 1px solid #416fab;border-bottom: 1px solid #416fab;height:30px;font-size:11px;font-family:YouYuan;text-align:center;"">{quo.flat_price_quotations[index].SellOptionPrice?.ToString("N")}</td>");
|
|
sb.Append($@" <td style=""border-right: 1px solid #416fab;border-bottom: 1px solid #416fab;height:30px;font-size:11px;font-family:YouYuan;text-align:center;"">{(quo.flat_price_quotations[index].SellOptionPrice / quo.flat_price_quotations[index].SpotPrice)?.ToString("P")}</td>");
|
|
sb.Append($@" </tr> ");
|
|
}
|
|
}
|
|
sb.Append("</table></td><td style=\" width: 10%\"> </td></tr></table>");
|
|
}
|
|
else
|
|
{
|
|
#region 非申万导出pdf
|
|
sb.Append($@" <div class=""title-wrap"" style=""width:100%;height:105px;"">
|
|
<div style="" text-align: center;margin:0px;justify-content: center;align-items: center;display: flex;"">
|
|
<table style=""width:100%;text-align: center;margin:0 auto;""><tr><td style=""text-align:right;width:25%""> <img style=""margin-right:5px;width:51px;height:34px;"" width=51 height=34 src=""{"/App_Docs/Images/title.png"}""/>
|
|
</td><td style=""text-align:left;width:60%""> <span style="" font-size: 18px;font-weight: 600"">{PS.Config.CompanyName}商品场外期权报价</span></td>
|
|
</tr></table>
|
|
</div>
|
|
<div style=""clear: both; ""></div>
|
|
<p style=""text-align:center;font-size:12px;"">1个月平值看涨/看跌期权</p>
|
|
<p style=""text-align:center;margin:0px;"">
|
|
<span style=""padding-left:0px 9px 0px 15px;font-size:12px;"">报价日: {valuedateBLL.ValueDate:yyyy-MM-dd}</span>
|
|
<span style=""padding-left:0px 9px 0px 15px;font-size:12px;"">到期日: {endDate.Value:yyyy-MM-dd}</span>
|
|
</p>
|
|
</div> ");
|
|
string background;
|
|
string borderColor;
|
|
if (PS.Config.Is光大光子)
|
|
{
|
|
background = "#532E86";
|
|
borderColor = "#AE9FC1";
|
|
}
|
|
else
|
|
{
|
|
background = "#15498c";
|
|
borderColor = "#416fab";
|
|
}
|
|
//sb.Append($"<div style=\"margin-buttom:19px;\"><span style=\"margin-left:15px; \">报价日: {@valuedateBLL.ValueDate.ToString("yyyy -MM-dd")}</span><span style=\"margin-left:15px;\">到期日: {@calendarBLL.GetNonHoliday(valuedateBLL.ValueDate.AddMonths(1)).ToString("yyyy-MM-dd")}</span></div>");
|
|
sb.Append("<table style=\" width: 100%;font-family:YouYuan;\" ><tr><td style=\" width: 10%\"> </td><td style=\" width: 80%\"><table style=\" width: 100%;max-width: 100%;font-family:YouYuan;margin-bottom: 10px;border-collapse:collapse;margin-top: 30px;\" > ");
|
|
if (YLErp.PS.Config.Is光大光子)
|
|
{
|
|
//光子导出时绝对值列更换为波动率列,客户买价这种百分比和波动率列位置调换
|
|
sb.Append($" <tr style=\"height: 25px; font-size:11px;font-family:YouYuan;background:{background};color:#fff;text-align:center;font-weight:400;\"><th style=\"border-right: 1px solid #fff;border-bottom: 1px solid #fff; \"colspan=\"2\">报价品种</th><th style=\"border-right:1px solid #fff;border-bottom: 1px solid #fff; \">标的信息</th><th style=\"border-right: 1px solid #fff;border-bottom: 1px solid #fff;\" colspan=\"2\">客户卖价</th><th style=\"border-bottom:1px solid #fff; \" colspan=\"2\">客户买价</th></tr>");
|
|
sb.AppendFormat($" <tr style=\"height: 25px;font-size:11px;font-family:YouYuan; background:{background};color:#fff;text-align:center;\"><th style=\"border-right: 1px solid #fff;;width:8%;text-align:center;\">板块</th><th style=\"border-right:1px solid #fff;width:16%\">品种</th><th style=\"border-right: 1px solid #fff;width:13%\">代码</th><th style=\"border-right: 1px solid #fff;width:13%\">波动率</th><th style=\"border-right: 1px solid #fff;width:13%\">百分比%</th><th style=\"border-right: 1px solid #fff;width:13%\">百分比%</th><th style=\"width:13%\">波动率</th></tr>");
|
|
}
|
|
else if (PS.Config.Is渤海 || PS.Config.Is润和)
|
|
{
|
|
sb.Append($" <tr style=\"height: 25px; font-size:11px;font-family:YouYuan;background:{background};color:#fff;text-align:center;font-weight:400;\">" +
|
|
$"<th style=\"border-right: 1px solid #fff;border-bottom: 1px solid #fff; \"colspan=\"2\">报价品种</th>" +
|
|
$"<th style=\"border-right:1px solid #fff;border-bottom: 1px solid #fff; \" colspan=\"2\">标的信息</th>" +
|
|
$"<th style=\"border-right: 1px solid #fff;border-bottom: 1px solid #fff;\" colspan=\"3\">买价</th>" +
|
|
$"<th style=\"border-bottom:1px solid #fff; \" colspan=\"3\">卖价</th></tr>");
|
|
sb.AppendFormat($"<tr style=\"height: 25px;font-size:11px;font-family:YouYuan; background:{background};color:#fff;text-align:center;\">" +
|
|
$"<th style=\"border-right: 1px solid #fff;;width:8%;text-align:center;\">板块</th>" +
|
|
$"<th style=\"border-right:1px solid #fff;width:10%\">品种</th>" +
|
|
$"<th style=\"border-right: 1px solid #fff;width:12%\">代码</th>" +
|
|
$"<th style=\"border-right: 1px solid #fff;width:10%\">价格</th>" +
|
|
$"<th style=\"border-right: 1px solid #fff;width:10%\">波动率</th>" +
|
|
$"<th style=\"border-right: 1px solid #fff;width:10%\">绝对值</th>" +
|
|
$"<th style=\"border-right: 1px solid #fff;width:10%\">百分比%</th>" +
|
|
$"<th style=\"border-right: 1px solid #fff;width:10%\">波动率</th>" +
|
|
$"<th style=\"border-right: 1px solid #fff;width:10%\">绝对值</th>" +
|
|
$"<th style=\"width:10%\">百分比%</th></tr>");
|
|
}
|
|
else
|
|
{
|
|
sb.Append($" <tr style=\"height: 25px; font-size:11px;font-family:YouYuan;background:{background};color:#fff;text-align:center;font-weight:400;\"><th style=\"border-right: 1px solid #fff;border-bottom: 1px solid #fff; \"colspan=\"2\">报价品种</th><th style=\"border-right:1px solid #fff;border-bottom: 1px solid #fff; \" colspan=\"2\">标的信息</th><th style=\"border-right: 1px solid #fff;border-bottom: 1px solid #fff;\" colspan=\"2\">买价</th><th style=\"border-bottom:1px solid #fff; \" colspan=\"2\">卖价</th></tr>");
|
|
sb.AppendFormat($" <tr style=\"height: 25px;font-size:11px;font-family:YouYuan; background:{background};color:#fff;text-align:center;\"><th style=\"border-right: 1px solid #fff;;width:8%;text-align:center;\">板块</th><th style=\"border-right:1px solid #fff;width:16%\">品种</th><th style=\"border-right: 1px solid #fff;width:13%\">代码</th><th style=\"border-right: 1px solid #fff;width:13%\">价格</th><th style=\"border-right: 1px solid #fff;width:13%\">绝对值</th><th style=\"border-right: 1px solid #fff;width:13%\">百分比%</th><th style=\"border-right: 1px solid #fff;width:13%\">绝对值</th><th style=\"width:13%\">百分比%</th></tr>");
|
|
}
|
|
foreach (var quo in selectedQuotation)
|
|
{
|
|
for (var index = 0; index < quo.flat_price_quotations.Count; index++)
|
|
{
|
|
ttindex++;
|
|
var bgStyle = "";
|
|
if (ttindex % 2 == 1)
|
|
{
|
|
bgStyle = "background:#ecedec;font-family:YouYuan;";
|
|
}
|
|
|
|
var showName = quo.flat_price_quotations[index].ShortName;
|
|
if (string.IsNullOrEmpty(showName))
|
|
{
|
|
showName = quo.flat_price_quotations[index].UnderlyingType;
|
|
}
|
|
|
|
sb.Append($@" <tr style=""{bgStyle}"">");
|
|
if (index == 0)
|
|
{
|
|
sb.Append($@" <td style=""border-bottom: 1px solid {borderColor};font-weight:600;border-left: 1px solid {borderColor};border-right: 1px solid {borderColor};background:#fff; font-size:11px; letter-spacing: 1rem; padding: 0px 15px;box-sizing:border-box;text-align:center;margin:0px;"" rowspan=""{quo.flat_price_quotations.Count}"">{quo.AssetType}</td>");
|
|
}
|
|
sb.Append($@" <td style=""border-right:1px solid {borderColor};border-bottom: 1px solid {borderColor};height:30px;font-size:11px;font-family:YouYuan;text-align:center;"">{showName}</td>");
|
|
sb.Append($@" <td style=""border-right: 1px solid {borderColor};border-bottom: 1px solid {borderColor};height:30px;font-size:11px;font-family:YouYuan;text-align:center;;"">{quo.flat_price_quotations[index].UnderlyingCode}</td>");
|
|
if (YLErp.PS.Config.Is光大光子)
|
|
{
|
|
sb.Append($@" <td style=""border-right: 1px solid {borderColor};border-bottom:1px solid {borderColor};height:30px;font-size:11px;font-family:YouYuan;text-align:center;"">{quo.flat_price_quotations[index].BuyOptionVol?.ToString("P")}</td>");
|
|
sb.Append($@" <td style=""border-right: 1px solid {borderColor};border-bottom: 1px solid {borderColor};height:30px;font-size:11px;font-family:YouYuan;text-align:center;"">{(quo.flat_price_quotations[index].BuyOptionPrice / quo.flat_price_quotations[index].SpotPrice)?.ToString("P")}</td>");
|
|
sb.Append($@" <td style=""border-right: 1px solid {borderColor};border-bottom: 1px solid {borderColor};height:30px;font-size:11px;font-family:YouYuan;text-align:center;"">{(quo.flat_price_quotations[index].SellOptionPrice / quo.flat_price_quotations[index].SpotPrice)?.ToString("P")}</td>");
|
|
sb.Append($@" <td style=""border-right: 1px solid {borderColor};border-bottom: 1px solid {borderColor};height:30px;font-size:11px;font-family:YouYuan;text-align:center;"">{quo.flat_price_quotations[index].SellOptionVol?.ToString("P")}</td>");
|
|
}
|
|
else if (PS.Config.Is渤海 || PS.Config.Is润和)
|
|
{
|
|
sb.Append($@"<td style=""border-right:1px solid {borderColor};border-bottom: 1px solid {borderColor};height:30px;font-size:11px;font-family:YouYuan;text-align:center;;"">{quo.flat_price_quotations[index].SpotPrice}</td>");
|
|
sb.Append($@" <td style=""border-right: 1px solid {borderColor};border-bottom:1px solid {borderColor};height:30px;font-size:11px;font-family:YouYuan;text-align:center;"">{quo.flat_price_quotations[index].BuyOptionVol?.ToString("P")}</td>");
|
|
sb.Append($@" <td style=""border-right: 1px solid {borderColor};border-bottom:1px solid {borderColor};height:30px;font-size:11px;font-family:YouYuan;text-align:center;"">{quo.flat_price_quotations[index].BuyOptionPrice?.ToString("N")}</td>");
|
|
sb.Append($@" <td style=""border-right: 1px solid {borderColor};border-bottom: 1px solid {borderColor};height:30px;font-size:11px;font-family:YouYuan;text-align:center;"">{(quo.flat_price_quotations[index].BuyOptionPrice / quo.flat_price_quotations[index].SpotPrice)?.ToString("P")}</td>");
|
|
sb.Append($@" <td style=""border-right: 1px solid {borderColor};border-bottom: 1px solid {borderColor};height:30px;font-size:11px;font-family:YouYuan;text-align:center;"">{quo.flat_price_quotations[index].SellOptionVol?.ToString("P")}</td>");
|
|
sb.Append($@" <td style=""border-right: 1px solid {borderColor};border-bottom: 1px solid {borderColor};height:30px;font-size:11px;font-family:YouYuan;text-align:center;"">{quo.flat_price_quotations[index].SellOptionPrice?.ToString("N")}</td>");
|
|
sb.Append($@" <td style=""border-right: 1px solid {borderColor};border-bottom: 1px solid {borderColor};height:30px;font-size:11px;font-family:YouYuan;text-align:center;"">{(quo.flat_price_quotations[index].SellOptionPrice / quo.flat_price_quotations[index].SpotPrice)?.ToString("P")}</td>");
|
|
}
|
|
else
|
|
{
|
|
sb.Append($@"<td style=""border-right:1px solid {borderColor};border-bottom: 1px solid {borderColor};height:30px;font-size:11px;font-family:YouYuan;text-align:center;;"">{quo.flat_price_quotations[index].SpotPrice}</td>");
|
|
sb.Append($@" <td style=""border-right: 1px solid {borderColor};border-bottom:1px solid {borderColor};height:30px;font-size:11px;font-family:YouYuan;text-align:center;"">{quo.flat_price_quotations[index].BuyOptionPrice?.ToString("N")}</td>");
|
|
sb.Append($@" <td style=""border-right: 1px solid {borderColor};border-bottom: 1px solid {borderColor};height:30px;font-size:11px;font-family:YouYuan;text-align:center;"">{(quo.flat_price_quotations[index].BuyOptionPrice / quo.flat_price_quotations[index].SpotPrice)?.ToString("P")}</td>");
|
|
sb.Append($@" <td style=""border-right: 1px solid {borderColor};border-bottom: 1px solid {borderColor};height:30px;font-size:11px;font-family:YouYuan;text-align:center;"">{quo.flat_price_quotations[index].SellOptionPrice?.ToString("N")}</td>");
|
|
sb.Append($@" <td style=""border-right: 1px solid {borderColor};border-bottom: 1px solid {borderColor};height:30px;font-size:11px;font-family:YouYuan;text-align:center;"">{(quo.flat_price_quotations[index].SellOptionPrice / quo.flat_price_quotations[index].SpotPrice)?.ToString("P")}</td>");
|
|
}
|
|
sb.Append($@" </tr> ");
|
|
}
|
|
}
|
|
sb.Append("</table></td><td style=\" width: 10%\"> </td></tr></table>");
|
|
|
|
if (PS.Config.Is渤海)
|
|
{
|
|
sb.Append($"<table style=\" width: 100 %; font - family:YouYuan; \">" +
|
|
$"<tbody>" +
|
|
$"<tr>" +
|
|
$"<td style=\" width: 10 % \"> </td>" +
|
|
$"<td style=\" width: 80 % \">" +
|
|
$"<div style=\" width: 100%;font-family:YouYuan;\"><p style=\"font-size:11px;\">报价说明</p>" +
|
|
$"<p style=\"font-size:11px;\">1.本表为参考报价,我司不承诺以上报价最终必然成交,实时报价请联系我司询价:021-60146471。</p>" +
|
|
$"<p style=\"font-size:11px;\">2.投资者以上述价格进行投资决策应自担投资风险,如有以下情形,我司不予提供场外期权服务:</p>" +
|
|
$"<ul><li style=\"font-size:11px;\"> 配资公司、互联网金融平台等敏感类客户;</li>" +
|
|
$"<li style=\"font-size:11px;\"> 规避监管、非法集资、违反反洗钱等监管规定;</li>" +
|
|
$"<li style=\"font-size:11px;\"> 投资者为我司股东居间人;</li>" +
|
|
$"<li style=\"font-size:11px;\"> 其他法律法规、自律规则禁止情形。</li></ul></div>" +
|
|
$"</td>" +
|
|
$"<td style=\" width: 10 % \"> </td>" +
|
|
$"</tr>" +
|
|
$"</tbody>" +
|
|
$"</table>");
|
|
}
|
|
if (PS.Config.Is国泰君安)
|
|
{
|
|
if (PS.Config.CompanyID == "国泰君安")
|
|
{
|
|
sb.Append("<table style=\" width: 100%;font-family:YouYuan;\" ><tr><td style=\" width: 10%\"> </td><td style=\" width: 80%\"><div style=\"width:100%;height:90px;\"><div style=\"text-align:center;margin:0px;justify-content:center; align-items:center;display:flex;\"><table style=\"width:95%;text-align:center;margin:0 auto;margin-bottom:40px;\"><tr><td style=\"text-align:left;width:1%;margin-left:5px;\"><img style=\"margin-right:5px;width:64px;height:60px;\"width=64 height=60 src=\"" + "/Images/qrcode.png" + "\"/></td><td style=\"text-align:center;width:55;\"><span style=\"font-size:11px;\">该价格对于名义本金规模500万以内的交易有效,实时报价可参见左下方微信报价平台。</span><p style=\"font-size:11px;\">量大或其他限制/结构价格,请联系:021-52138853、52138780、62155457.</p></td></tr></table></div></div></td><td style=\" width: 10%\"> </td></tr></table>");
|
|
}
|
|
else if (PS.Config.CompanyID == "中财资本")
|
|
{
|
|
sb.Append("<table style=\" width: 100%;font-family:YouYuan;\" ><tr><td style=\" width: 10%\"> </td><td style=\" width: 80%\"><div style=\"width:100%;height:90px;\"><div style=\"text-align:center;margin:0px;justify-content:center; align-items:center;display:flex;\"><table style=\"width:95%;text-align:center;margin:0 auto;margin-bottom:40px;\"><tr><td style=\"text-align:left;width:1%;margin-left:5px;\"></td><td style=\"text-align:center;width:55;\"><span style=\"font-size:11px;\">该价格对于名义本金规模500万以内的交易有效。</span><p style=\"font-size:11px;\">量大或其他限制/结构价格,请联系:021-61701584、61701608.</p></td></tr></table></div></div></td><td style=\" width: 10%\"> </td></tr></table>");
|
|
}
|
|
}
|
|
//国贸
|
|
if (PS.Config.ErpElement.Company == Configuration.CompanyEnum.国贸启润)
|
|
{
|
|
sb.Append("<p style =\" width: 100%;font-family:YouYuan;\" >1、公开报价有效范围为1000万名义本金以内,我司有权根据当天行情变动及成交情况进行调整</p>");
|
|
sb.Append("<p style=\" width: 100%;font-family:YouYuan;\" >2、本报价仅向我司特定客户(已完成适当性评估的合格投资者)提供,如需进一步了解我司场外业务请联系021-33588323。</p>");
|
|
}
|
|
#endregion
|
|
}
|
|
var company = PS.Config.CompanyName;
|
|
var fileBytes = new HtmlToPdfHelper().ConvertHtmlTextToPDF(sb.ToString(), new HtmlToPdfOptions
|
|
{
|
|
BaseUri = new Uri(Request.UrlLeftPart()),
|
|
ContentRootPath = Server.GetVirtualRootPath()
|
|
});
|
|
return File(fileBytes, "application/pdf", $"{company}报价" + DateTime.Now.ToString("yyyyMMdd") + ".pdf");
|
|
}
|
|
|
|
public ActionResult OutPutPDF2(string assetType)
|
|
{
|
|
var flat_priceList = GetSortFlat_Quotation(null, assetType?.Split(','));
|
|
var vq = underlying_main_contract_historyBLL.GetVolatilityQuotation(UserId, flat_priceList);
|
|
var sb = new StringBuilder();
|
|
var background = YLErp.PS.Config.Is光大光子 ? "#532E86" : "#00b4ff";
|
|
sb.Append("<table style=\"width: 100%;max-width: 100%;margin-bottom: 20px;\" >");
|
|
sb.Append($" <tr style=\"text-align:center;\"><td style=\"border: 1px solid #ddd;height:42px;\"></td><td style=\"border: 1px solid #ddd;\"></td><td style=\"background:{background};color:#fff;border: 1px solid #ddd;width:10%;\">到期日</td><td style=\"background:{background};color:#fff;width:10%;border: 1px solid #ddd;\">Bid</td><td style=\"background:{background};color:#fff;width:10%;border: 1px solid #ddd;\">Ask</td><td style=\"border: 1px solid #ddd;\"></td></tr>");
|
|
sb.Append(" ");
|
|
if (vq == null) { throw new Exception("请刷新界面后再导出"); }
|
|
foreach (var quo in vq)
|
|
{
|
|
var subSb = new StringBuilder();
|
|
subSb.Append("<table style=\"background:#eeeeee;width:100%;\">");
|
|
quo.BidAskMatureData.ForEach(ab =>
|
|
{
|
|
subSb.Append($"<tr><td style=\"width:33%; \">{ab.Expire}</td><td style=\"width:33%; \">{ab.BidVol.ToString("P")}</td><td style=\"width:33%;\">{ab.AskVol.ToString("P")}</td></tr>");
|
|
});
|
|
subSb.Append("</table>");
|
|
sb.Append($@"<tr style=""border: 1px solid #ddd;""><td style=""border: 1px solid #ddd;"">{quo.UnderlyingType}</td><td style=""border: 1px solid #ddd;"">{quo.CommodityCode}</td><td colspan='3' style=""background:#eeeeee;padding:5px 0px;border: 1px solid #ddd;"">{subSb.ToString()} </td><td>{quo.MarketName}</td></tr>");
|
|
}
|
|
sb.Append("</table>");
|
|
sb.Append($"<table><tr><td>报价日期</td><td colspan=\"3\">{valuedateBLL.ValueDate.ToString("yyyy-MM-dd")}</td></tr>" +
|
|
$"<tr><td>制表人:</td><td><span style=\"text-decoration:underline;\"> </span></td><td>审核人:</td><td><span style=\"text-decoration:underline;\"> </span></td></tr></table>");
|
|
//国贸
|
|
if (PS.Config.ErpElement.Company == Configuration.CompanyEnum.国贸启润)
|
|
{
|
|
sb.Append("<p style =\" width: 100%;font-family:YouYuan;\" >1、公开报价有效范围为1000万名义本金以内,我司有权根据当天行情变动及成交情况进行调整</p>");
|
|
sb.Append("<p style=\" width: 100%;font-family:YouYuan;\" >2、本报价仅向我司特定客户(已完成适当性评估的合格投资者)提供,如需进一步了解我司场外业务请联系021-33588323。</p>");
|
|
}
|
|
var company = PS.Config.CompanyName;
|
|
var fileBytes = new HtmlToPdfHelper().ConvertHtmlTextToPDF(sb.ToString(), new HtmlToPdfOptions
|
|
{
|
|
BaseUri = new Uri(Request.UrlLeftPart()),
|
|
ContentRootPath = Server.GetVirtualRootPath()
|
|
});
|
|
return File(fileBytes, "application/pdf", $"{company}报价" + DateTime.Now.ToString("yyyyMMdd") + "波动率报价表.pdf");
|
|
}
|
|
|
|
public ActionResult OutPutHistoryPDF(string valueDate)
|
|
{
|
|
var hDate = Convert.ToDateTime(valueDate);
|
|
var sb = new StringBuilder();
|
|
var underlyingMainContractHistory = db.underlying_main_contract_history.Where(t => t.HistoryDate == hDate).ToList();
|
|
|
|
if (underlyingMainContractHistory == null) { throw new Exception("没有历史数据!"); }
|
|
sb.Append("<table style=\"width: 100%;max-width: 100%;margin-bottom: 20px;border: none ;\" >");
|
|
sb.Append(" <tr style=\"text-align:center;\"><td style=\"border: 1px solid #ddd;height:42px;\"></td><td style=\"border: 1px solid #ddd;\"></td><td style=\"background:#00b4ff;color:#fff;border: 1px solid #ddd;width:10%;\">到期日</td><td style=\"background:#00b4ff;color:#fff;width:10%;border: 1px solid #ddd;\">Bid</td><td style=\"background:#00b4ff;color:#fff;width:10%;border: 1px solid #ddd;\">Ask</td><td style=\"border: 1px solid #ddd;\"></td></tr>");
|
|
sb.Append(" ");
|
|
foreach (var item in underlyingMainContractHistory)
|
|
{
|
|
var vq = JsonConvert.DeserializeObject<List<VolatilityQuotation>>(item.underlyingjson);
|
|
if (vq == null) { throw new Exception("没有历史数据!"); }
|
|
foreach (var quo in vq)
|
|
{
|
|
var subSb = new StringBuilder();
|
|
subSb.Append("<table style=\"background:#eeeeee;width:100%;\">");
|
|
quo.BidAskMatureData.ForEach(ab =>
|
|
{
|
|
subSb.Append($"<tr><td style=\"width:33%; \">{ab.Expire}</td><td style=\"width:33%; \">{ab.BidVol.ToString("P")}</td><td style=\"width:33%;\">{ab.AskVol.ToString("P")}</td></tr>");
|
|
});
|
|
subSb.Append("</table>");
|
|
sb.Append($@"<tr style=""border: 1px solid #ddd;""><td style=""border: 1px solid #ddd;"">{quo.UnderlyingType}</td><td style=""border: 1px solid #ddd;"">{quo.CommodityCode}</td><td colspan='3' style=""background:#eeeeee;padding:5px 0px;border: 1px solid #ddd;"">{subSb.ToString()} </td><td>{quo.MarketName}</td></tr>");
|
|
|
|
}
|
|
}
|
|
sb.Append("</table>");
|
|
sb.Append($"<table><tr><td>报价日期</td><td colspan=\"3\">{valueDate}</td></tr>" +
|
|
$"<tr><td>制表人:</td><td><span style=\"text-decoration:underline;\"> </span></td><td>审核人:</td><td><span style=\"text-decoration:underline;\"> </span></td></tr></table>");
|
|
var fileBytes = new HtmlToPdfHelper().ConvertHtmlTextToPDF(sb.ToString(), new HtmlToPdfOptions
|
|
{
|
|
BaseUri = new Uri(Request.UrlLeftPart()),
|
|
ContentRootPath = Server.GetVirtualRootPath()
|
|
});
|
|
return File(fileBytes, "application/pdf", valueDate + "波动率报价表.pdf");
|
|
}
|
|
|
|
public JsonResult GetVolatility()
|
|
{
|
|
var userGroup = CurUser.UserGroup;
|
|
var VQ = underlying_main_contract_historyBLL.GetVolatilityQuotation(UserId, flat_price_quotationBLL.GetSortFlat_Quotation(null, userGroup));
|
|
return JsonSuccess("", VQ);
|
|
}
|
|
|
|
public ActionResult quotationtable()
|
|
{
|
|
var userGroup = CurUser.UserGroup;
|
|
var maturityDate = flat_price_quotationBLL.GetAtmOptionQuotePreviewMaturity();
|
|
return View(GetQuotationGroup(flat_price_quotationBLL.GetSortFlat_Quotation(null, userGroup), maturityDate.DateTime));
|
|
}
|
|
|
|
List<flat_price_quotation_group> GetQuotationGroup(IEnumerable<flat_price_quotation> quotationList, DateTime? pickDate)
|
|
{
|
|
var varieties = VarietyBLL.GetAllvarietyModel();
|
|
foreach (var q in quotationList)
|
|
{
|
|
var targetVar = varieties.FirstOrDefault(v => v.VarietyName == q.UnderlyingType);
|
|
if (targetVar != null)
|
|
{
|
|
q.AssetType = targetVar.AssetType;
|
|
q.ShortName = targetVar.ShortName;
|
|
}
|
|
}
|
|
var selectedQuotation = new List<flat_price_quotation_group>();
|
|
var maturityDate = pickDate == null ? QdpCalendarHelper.GetNonHoliday(valuedateBLL.ValueDate.AddMonths(1).AddDays(-1)) : pickDate.Value;
|
|
//需要展示的标的信息
|
|
var underlyingList = underlying_main_contractBLL.GetDefaultAtMoneyQuoteList(maturityDate);
|
|
foreach (var flat in quotationList)
|
|
{
|
|
if (underlyingList.Any(c => c.UnderlyingCode == flat.UnderlyingCode))
|
|
{
|
|
var groupQuotation = selectedQuotation.FirstOrDefault(q => q.AssetType == flat.AssetType);
|
|
//var order = underlyingList.FirstOrDefault(c => c.UnderlyingCode == flat.UnderlyingCode).order;
|
|
//flat.order = order;
|
|
if (groupQuotation == null)
|
|
{
|
|
var group = new flat_price_quotation_group
|
|
{
|
|
order = flat.order,
|
|
AssetType = flat.AssetType,
|
|
flat_price_quotations = new List<flat_price_quotation> { flat }
|
|
};
|
|
selectedQuotation.Add(group);
|
|
}
|
|
else
|
|
{
|
|
groupQuotation.flat_price_quotations.Add(flat);
|
|
}
|
|
}
|
|
}
|
|
|
|
//排序补丁
|
|
selectedQuotation.ForEach(q =>
|
|
{
|
|
q.order = q.flat_price_quotations.Min(f => f.order) ?? 0;
|
|
q.flat_price_quotations = q.flat_price_quotations.OrderBy(f => f.order).ToList();
|
|
});
|
|
|
|
selectedQuotation = selectedQuotation.OrderBy(s => s.order).ToList();
|
|
|
|
return selectedQuotation;
|
|
}
|
|
|
|
public ActionResult quotationvolhistory()
|
|
{
|
|
ViewBag.VolatilityQuotation = new List<VolatilityQuotation>();
|
|
return View();
|
|
}
|
|
|
|
[MyAuthorize("报价管理-报价预览")]
|
|
public ActionResult quotationpreview(string[] assetType)
|
|
{
|
|
ViewBag.ValueDate = valuedateBLL.ValueDate.ToString("yyyy-MM-dd");
|
|
var maturityDate = flat_price_quotationBLL.GetAtmOptionQuotePreviewMaturity();
|
|
ViewBag.maturityDate = maturityDate;
|
|
ViewBag.assetType = assetType;
|
|
var flat_priceList = GetSortFlat_Quotation(null, assetType);
|
|
var selectedQuotation = GetQuotationGroup(flat_priceList, maturityDate.DateTime);
|
|
ViewBag.VolatilityQuotation = underlying_main_contract_historyBLL.GetVolatilityQuotation(UserId, flat_priceList);
|
|
return View(selectedQuotation);
|
|
}
|
|
|
|
public JsonResult getSelfVolatilityQuotation(DateTime? date, string[] assetType)
|
|
{
|
|
var flat_priceList = GetSortFlat_Quotation(date, assetType);
|
|
var selectedQuotation = GetQuotationGroup(flat_priceList, date);
|
|
ViewBag.VolatilityQuotation = underlying_main_contract_historyBLL.GetVolatilityQuotation(UserId, flat_priceList);
|
|
|
|
if (selectedQuotation.Count > 0)
|
|
{
|
|
return JsonSuccess("计算成功", selectedQuotation);
|
|
}
|
|
else
|
|
{
|
|
return JsonError("没有数据");
|
|
}
|
|
}
|
|
|
|
public JsonResult getVolatilityQuotation(DateTime date)
|
|
{
|
|
date = date.Date;
|
|
var underlyingMainContractHistory = db.underlying_main_contract_history.FirstOrDefault(t => t.HistoryDate == date);
|
|
if (underlyingMainContractHistory != null)
|
|
{
|
|
return JsonSuccess("获取成功", underlyingMainContractHistory);
|
|
}
|
|
else
|
|
{
|
|
return JsonError("没有历史数据");
|
|
}
|
|
}
|
|
}
|
|
}
|