diff --git a/Framework/YLErp.Cache/YLRedisCache.cs b/Framework/YLErp.Cache/YLRedisCache.cs index 6097729a..c88e6e24 100644 --- a/Framework/YLErp.Cache/YLRedisCache.cs +++ b/Framework/YLErp.Cache/YLRedisCache.cs @@ -183,7 +183,11 @@ namespace YLErp.Cache public bool BatchDelete(string pattern) { var keys = QueryKeys(pattern); - return db.KeyDelete(keys.ToArray())>0; + foreach (var key in keys) + { + db.KeyDelete(key); // 逐个删除,规避跨槽位问题 + } + return true; } /// diff --git a/YLErpDAL/Modules/SuperviseReportModule/ExtendReport/ExtendReportBaseService.cs b/YLErpDAL/Modules/SuperviseReportModule/ExtendReport/ExtendReportBaseService.cs index 7581a03a..f7461754 100644 --- a/YLErpDAL/Modules/SuperviseReportModule/ExtendReport/ExtendReportBaseService.cs +++ b/YLErpDAL/Modules/SuperviseReportModule/ExtendReport/ExtendReportBaseService.cs @@ -3,6 +3,7 @@ using YLErp.Model; using YLErp.Modules.SuperviseReportModule.ExtendReport.Common; using YLErp.Modules.SuperviseReportModule.ExtendReport.GeLin; using YLErp.Modules.SuperviseReportModule.ExtendReport.ZheQi; +using YLErp.Modules.SuperviseReportModule.ExtendReport.ZheShang; namespace YLErp.Modules.SuperviseReportModule.ExtendReport { @@ -48,6 +49,9 @@ namespace YLErp.Modules.SuperviseReportModule.ExtendReport case "客户资金记录报表": service = new CustomerFundsReport(optUser, req); break; + case "月报基础数据债券收益互换": + service = new SwapTradeMothReport(optUser, req); + break; default: throw new ServiceException("报表未实现"); } diff --git a/YLErpDAL/Modules/SuperviseReportModule/ExtendReport/ZheShang/SwapTradeMothReport.cs b/YLErpDAL/Modules/SuperviseReportModule/ExtendReport/ZheShang/SwapTradeMothReport.cs new file mode 100644 index 00000000..a3025d88 --- /dev/null +++ b/YLErpDAL/Modules/SuperviseReportModule/ExtendReport/ZheShang/SwapTradeMothReport.cs @@ -0,0 +1,149 @@ +using BaseOUDAL; +using CsvHelper; +using Org.BouncyCastle.Ocsp; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using YLErp.DBModels; +using YLErp.DBModels.Consts; +using YLErp.DBModels.Enums; +using YLErp.Model; +using YLErp.Modules.SuperviseReportModule.ExtendReport.ZheQi; + +namespace YLErp.Modules.SuperviseReportModule.ExtendReport.ZheShang +{ + public class SwapTradeMothReport: SimpleExtendReportBaseService + { + public SwapTradeMothReport(OptUserInfo userInfo, SuperviseReportReq req) : base(userInfo, req) + { + } + public override string TemplateName => "月报基础数据债券收益互换.xlsx"; + public override string TargetFileName => "月报基础数据债券收益互换"+ base.RequestInfo.ValueDate.ToString("yyyyMM") +".xlsx"; + public override string[] SheetNames => new[] { "本月末存量业务明细" }; + public override object SearchReportInfo(string sheetName) + { + var dealList = new List(); + var predicate = PredicateBuilder.Create(n => !n.Invalid && n.PosiQuantity > 0); + var tradePredicate = PredicateBuilder.Create(n => n.TradeType=="收益互换" + && n.ValidState != "InValid"); + // 获取当月最后一次日期 + var currentMonth = new DateTime(base.RequestInfo.ValueDate.Year, base.RequestInfo.ValueDate.Month, 1); + var nextMonth = currentMonth.AddMonths(1); + var valueDate = DbContext.eodStatus + .Where(t => t.Status == "已收盘" && t.ValueDate >= currentMonth && t.ValueDate < nextMonth) + .OrderByDescending(t => t.ValueDate) + .Select(t => t.ValueDate) + .FirstOrDefault(); + + // 如果没有找到当月的收盘日期,则使用请求中的日期 + if (valueDate == default(DateTime)) + { + valueDate = base.RequestInfo.ValueDate; + } + predicate = predicate.And(x => x.ValueDate == valueDate); + tradePredicate = tradePredicate.And(x => valueDate >= x.StartDate); + var positionQuery = DbContext.eod_swap_position.Where(predicate); + var tradeQuery = DbContext.trade.Where(tradePredicate); + var query = from position in positionQuery + join td in tradeQuery on position.SwapTradeId equals td.id + join tcrConfirm in DbContext.trade_contract_r.Where(O => O.Type == ContractTypeEnum.Trade && O.IsValid) on td.id equals tcrConfirm.TradeId into tcrConfirms + from tcrConfirm in tcrConfirms.DefaultIfEmpty() + select new EodSwapPositionResponse + { + position = position, + ClientName = td.ClientName, + ConfrimNo = tcrConfirm.ContractCode, + TradeNumber = td.TradeNumber, + StructureType = td.StructureType, + UnwindDate = td.UnWindDate, + TradeStatus = td.TradeStatus + }; + var list= query.ToList(); + var eodSwapList= DbContext.eod_swap.Where(s=>s.ValueDate==valueDate).AsNoTracking().ToList(); + foreach (var item in list) + { + var obj = new SwapTradeMothReportModel(); + + // 获取标的名称 + string underlyingName = ""; + if (!string.IsNullOrEmpty(item.position?.UnderlyingCode)) + { + var underlying = DbContext.underlying_manager.FirstOrDefault(s => s.UnderlyingCode == item.position.UnderlyingCode); + underlyingName = underlying?.UnderlyingName ?? ""; + } + + // 填充 SwapTradeMothReportModel 对象 + obj.NameOfSecuritiesCompany = ""; // 报送机构名称 + obj.NameOfCounterparty = item.ClientName; // 交易对手方名称 + obj.NameOfCounterpartyProduct = ""; // 交易对手产品名称,如果有需要从其他地方获取 + obj.TransactionConfirmationNumber = item.ConfrimNo; // 交易确认书编号 + var eodSwap= eodSwapList.FirstOrDefault(s => s.SwapTradeId == item.position.SwapTradeId); + obj.NotionalPrincipalAmountL = eodSwap.NotionalValueLong; + obj.SNotionalPrincipalAmount = eodSwap.NotionalValueShort; + obj.BusinessType = obj.NotionalPrincipalAmountL>0? "11":"12"; + obj.LongPositionContractValue = obj.NotionalPrincipalAmountL > 0? eodSwap.PostionValue:0; + obj.ShortPositionContractValue = obj.SNotionalPrincipalAmount > 0 ? eodSwap.PostionValue:0; + // 设置维持保证金比例 + var maitainMargin = eodSwap.PostionMarginGain+ eodSwap.PostionMarginLoss; + var MaitainMarginRation= eodSwap.NotionalValue==0?0: maitainMargin / eodSwap.NotionalValue; + obj.MaitainMarginRation =Math.Round(MaitainMarginRation*100,2,MidpointRounding.AwayFromZero).ToString()+"%"; // 需要从其他地方获取维持保证金比例 + /** + * 校验规则: + 当选择“场外期权”时,“期权费(非年化)”、“期权标的小类(场外期权填写)” 和“期权类型” 三项必填; + 当选择“收益互换”类型时,“收益互换标的小类(收益互换填写)”必填 + + 11:收益互换(客户多头) + 12:收益互换(客户空头) + 13:多空组合收益互换 + 14:其他收益互换 + 02:场外期权 + */ + + // 名义本金/多头名义本金和空头名义本金 + if (item.position != null) + { + // 设置起始日和到期日 + obj.StartDay = item.position.PosiStartDate.ToString("yyyy-MM-dd"); + obj.DueDate = item.position.PosiMatuirityDate.Value.ToString("yyyy-MM-dd"); + // 设置标的信息 + obj.UndrlygAssetCode = item.position.UnderlyingCode; + obj.UndrlygAssetName = underlyingName; // 使用前面获取的标的名称 + obj.SumInvestmentTargetType = ""; // 标的类型,可能需要根据实际情况调整 + obj.UndrlygAssetTradgPlc = ""; // 标的交易场所,可能需要根据实际情况调整 + /** + * 校验规则:当“业务类型”为“收益互换”时,必填 + 0:股票 + 1:股指 + 2:北交所/新三板挂牌股票 + 3:香港股票 + 4:香港股指 + 5:基金及基金专户 + 6:债券 + 7:黄金期货 + 8:国债期货 + 9:股指期货 + 10:其他期货 + 11:黄金现货 + 12:其他现货 + 13:境外期货 + 14:境外现货 + 15:境外股票 + 16:境外股指 + 17:汇率 + 18:利率 + 99:其他标的 + */ + obj.ExchangeSumInvestmentTargetType = "6"; // 收益互换标的小类 + } + dealList.Add(obj); + } + return new + { + DataDate = RequestInfo.ValueDate.ToString("yyyy-MM"), + DealList = dealList + }; + } + } +} diff --git a/YLErpDAL/Modules/SuperviseReportModule/ExtendReport/ZheShang/SwapTradeMothReportModel.cs b/YLErpDAL/Modules/SuperviseReportModule/ExtendReport/ZheShang/SwapTradeMothReportModel.cs new file mode 100644 index 00000000..e2dff822 --- /dev/null +++ b/YLErpDAL/Modules/SuperviseReportModule/ExtendReport/ZheShang/SwapTradeMothReportModel.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace YLErp.Modules.SuperviseReportModule.ExtendReport.ZheShang +{ + public class SwapTradeMothReportModel + { + /// + /// 报送机构名称(全称) + /// + public string NameOfSecuritiesCompany { get; set; } + + /// + /// 交易对手方名称(全称) + /// + public string NameOfCounterparty { get; set; } + + /// + /// 交易对手产品名称 + /// + public string NameOfCounterpartyProduct { get; set; } + + /// + /// 交易确认书编号(报告库编号) + /// + public string TransactionConfirmationNumber { get; set; } + + /// + /// 业务类型 (如场外期权/收益互换) + /// + public string BusinessType { get; set; } + + /// + /// 名义本金/多头名义本金 (元) + /// + public decimal NotionalPrincipalAmountL { get; set; } + + /// + /// 空头名义本金(元) (多空组合填写) + /// + public decimal? SNotionalPrincipalAmount { get; set; } + + /// + /// 起始日(T日) + /// + public string StartDay { get; set; } + + /// + /// 到期日 + /// + public string DueDate { get; set; } + + /// + /// 标的类型 + /// + public string SumInvestmentTargetType { get; set; } + + /// + /// 标的名称 + /// + public string UndrlygAssetName { get; set; } + + /// + /// 标的编码 + /// + public string UndrlygAssetCode { get; set; } + + /// + /// 标的交易场所 + /// + public string UndrlygAssetTradgPlc { get; set; } + + /// + /// 场外期权标的小类 (当业务类型为场外期权时填写) + /// + public string OptionSumInvestmentTargetType { get; set; } + + /// + /// 收益互换标的小类 (当业务类型为收益互换时填写) + /// + public string ExchangeSumInvestmentTargetType { get; set; } + + /// + /// 期权费(非年化)(%) (场外期权填写) + /// + public decimal? OptionFee { get; set; } + + /// + /// 期权类型 (场外期权填写) + /// + public string OptionType { get; set; } + + /// + /// 本月末维持保证金比例(%) + /// + public string MaitainMarginRation { get; set; } + + /// + /// 标的相关系数 (特殊字段,根据备注"不填"处理) + /// + public decimal? CorrelationCoefficient { get; set; } = null; + + /// + /// 多头合约价值(元) + /// + public decimal LongPositionContractValue { get; set; } + + /// + /// 空头合约价值(元) + /// + public decimal ShortPositionContractValue { get; set; } + } +} diff --git a/YLErpWeb/App/Startup.cs b/YLErpWeb/App/Startup.cs index f2a3e36d..a1b8d0b1 100644 --- a/YLErpWeb/App/Startup.cs +++ b/YLErpWeb/App/Startup.cs @@ -53,14 +53,11 @@ namespace YLErp.Web GlobalConfig.EnableExtendSetting = true; GlobalConfig.ProjectTitle = "场外衍生品业务管理系统"; break; - case Configuration.CompanyEnum.浙期: + case Configuration.CompanyEnum.浙商: + GlobalConfig.ExtendReportType.Add("月报基础数据债券收益互换", 2); + break; case Configuration.CompanyEnum.方顿: - - if (PS.Config.Company == Configuration.CompanyEnum.浙期) - { - GlobalConfig.ExtendReportType.Add("成交明细汇总", 1); - } - GlobalConfig.ExtendReportType.Add("风险资本准备计算表", 1); + GlobalConfig.ExtendReportType.Add("风险资本准备计算表", 1); break; case Configuration.CompanyEnum.格林大华: GlobalConfig.ExtendReportType.Add("客户持仓信息", 3); diff --git a/YLErpWeb/App_Data/Menus.txt b/YLErpWeb/App_Data/Menus.txt index 689f0137..2157c45f 100644 --- a/YLErpWeb/App_Data/Menus.txt +++ b/YLErpWeb/App_Data/Menus.txt @@ -25,6 +25,7 @@ {Name:"交易确认书",Rights:["结算管理-交易确认书"],Url:"TradeConfirmBook/ConfirmBookListByClient"}, {Name:"结算确认书",Rights:["结算管理-结算确认书"],Url:"swaptrade2/tradeEndConfirmList"}, {Name:"每日估值报告",Rights:["结算管理-每日估值报告"],Url:"clientbalance/TradeMarketReport"}, + {Name:"其他报告",Rights:["结算管理-其他报告"],Url:"supervise_report/ExtendReport"}, ] }, {Name:"监管报告",Rights:["监管报告"],Icon:"menu-icon iconteleven" diff --git a/YLErpWeb/App_Docs/导出模板/月报基础数据债券收益互换.xlsx b/YLErpWeb/App_Docs/导出模板/月报基础数据债券收益互换.xlsx index 9affa739..a72c617e 100644 Binary files a/YLErpWeb/App_Docs/导出模板/月报基础数据债券收益互换.xlsx and b/YLErpWeb/App_Docs/导出模板/月报基础数据债券收益互换.xlsx differ diff --git a/YLErpWeb/Controllers/supervise_reportController.cs b/YLErpWeb/Controllers/supervise_reportController.cs index d4488948..6b54a5cb 100644 --- a/YLErpWeb/Controllers/supervise_reportController.cs +++ b/YLErpWeb/Controllers/supervise_reportController.cs @@ -1394,7 +1394,7 @@ namespace YLErp.Web.Controllers { Directory.CreateDirectory(targetPath); } - + ExcelPackage.LicenseContext= LicenseContext.NonCommercial; var targetFileName = Path.Combine(targetPath, service.TargetFileName); var path = ExcelTemplate.GeneratePDFFromExeclTemplate(sourcePath, sourceFileName, modelDict, targetPath, targetFileName, null, null, null, false); diff --git a/YLErpWeb/Views/supervise_report/ExtendReport.cshtml b/YLErpWeb/Views/supervise_report/ExtendReport.cshtml index ed917b48..b5a7fb92 100644 --- a/YLErpWeb/Views/supervise_report/ExtendReport.cshtml +++ b/YLErpWeb/Views/supervise_report/ExtendReport.cshtml @@ -9,7 +9,7 @@ defaultType = GlobalConfig.ExtendReportType.FirstOrDefault().Key, }; } -@section CSS{ +@section CSS { } - @section JS{ +@section JS{ - + } -
- - -
- @Html.SearchDate("ValueDate", "日期") -
-
- @Html.ShortInput("ValueMonthly", "月份") -
-
- @Html.SearchDate("StartDate", "开始日期")@Html.SearchDate("EndDate", "结束日期") -
-
- @Html.SearchDateRange("ValueDate1", "发生时间") - @Html.MyAceDropdownInput("ClientId", "客户名称", CurUser.GetClientSelectItems(),false) -
- @MyControls.Btn("导出", "exportToFile()") +
+ + +
+ @Html.SearchDate("ValueDate", "日期")
+
+ + +
+
+ @Html.SearchDate("StartDate", "开始日期")@Html.SearchDate("EndDate", "结束日期") +
+ @MyControls.Btn("导出", "exportToFile()") +
diff --git a/YLErpWeb/YLErpWeb.csproj b/YLErpWeb/YLErpWeb.csproj index 7b0a1442..b637f139 100644 --- a/YLErpWeb/YLErpWeb.csproj +++ b/YLErpWeb/YLErpWeb.csproj @@ -106,6 +106,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest