修复unwindreport代码文件编码问题

This commit is contained in:
嬴政 时
2026-05-07 13:23:31 +08:00
parent 7a664fe33c
commit 4e77ada8ac
@@ -6,7 +6,7 @@ using YLErp.Plugins.TradeDocGenerator.Abstracts;
namespace YLErp.Plugins.GuoLian.DocumentGenerator
{
/// <summary>
/// 国联证券了结报告生成器
/// 国联证券了结报告生成器
/// </summary>
internal class TradeUnwindReportGenerator : BaseUnwindReportGenerator, ITradeUnwindReportGenerator
{
@@ -17,7 +17,7 @@ namespace YLErp.Plugins.GuoLian.DocumentGenerator
}
/// <summary>
/// 准备Word模板数据
/// 准备Word模板数据
/// </summary>
protected override void PrepareViewData(Dictionary<string, JToken> dic)
{
@@ -37,72 +37,72 @@ namespace YLErp.Plugins.GuoLian.DocumentGenerator
var settlementprice = (trade.IsUsePremiumRate != null && trade.IsUsePremiumRate.Value ? tradeCashs.UnwindPricePercentRate.OtcFormatPercent() : tradeCashs.UnwindPrice.OtcFormatMoney());
var row = new JObject();
OtcTradeBase trades = tradelist.Find(O => O.id == tradeCashs.TradeId);
row["交易编号"] = trades.TradeNumber;
row["交易编号"] = trades.TradeNumber;
switch (item.BuySell)
{
case "买入":
if (trade.OpponentRole == null || trade.OpponentRole == "乙方")
case "买入":
if (trade.OpponentRole == null || trade.OpponentRole == "乙方")
{
row["买方"] = $"甲方";
row["买方"] = $"甲方";
}
else
{
row["买方"] = $"乙方";
row["买方"] = $"乙方";
}
break;
case "卖出":
if (trade.OpponentRole == null || trade.OpponentRole == "乙方")
case "卖出":
if (trade.OpponentRole == null || trade.OpponentRole == "乙方")
{
row["买方"] = $"乙方";
row["买方"] = $"乙方";
}
else
{
row["买方"] = $"甲方";
row["买方"] = $"甲方";
}
break;
default:
break;
}
row["交易日期"] = $"{trades.TradeDate:yyyy/MM/dd}";
row["开始日期"] = $"{trades.StartDate:yyyy/MM/dd}-{trades.ExerciseDate:yyyy/MM/dd}";
row["名义本金"] = $"{trades.OriginalStockEqvNotional.OtcFormatMoney()}";
row["标的代码"] = $"{trades.UnderlyingCode}";
row["期权类型"] = $"{trades.TradeType}";
row["期初价格"] = $"{trades.TradePrice.OtcFormatMoney()}";
row["结算日期"] = $"{tradeCashs.ValueDate:yyyy/MM/dd}";
row["结算价格"] = $"{tradeCashs.FinalPrice.OtcFormatMoney()}";
row["结算模块"] = $"{(tradeCashs.UnwindPercentRate * trades.OriginalNotional * underlying.CountRatio).OtcFormatMoney()}";
row["结算单价"] = $"{settlementprice}";
row["交易日期"] = $"{trades.TradeDate:yyyy/MM/dd}";
row["开始日期"] = $"{trades.StartDate:yyyy/MM/dd}-{trades.ExerciseDate:yyyy/MM/dd}";
row["名义本金"] = $"{trades.OriginalStockEqvNotional.OtcFormatMoney()}";
row["标的代码"] = $"{trades.UnderlyingCode}";
row["期权类型"] = $"{trades.TradeType}";
row["期初价格"] = $"{trades.TradePrice.OtcFormatMoney()}";
row["结算日期"] = $"{tradeCashs.ValueDate:yyyy/MM/dd}";
row["结算价格"] = $"{tradeCashs.FinalPrice.OtcFormatMoney()}";
row["结算模块"] = $"{(tradeCashs.UnwindPercentRate * trades.OriginalNotional * underlying.CountRatio).OtcFormatMoney()}";
row["结算单价"] = $"{settlementprice}";
var Amountqrs = -tradeCashs.Amount;
var Amountqrs2 = -(tradeCashs.Amount + (trades.TradePrice ?? 0) * (tradeCashs.UnwindPercentRate ?? 0) * ((trades.BuySell == "卖出") ? 1 : -1));
var Amountqrs2 = -(tradeCashs.Amount + (trades.TradePrice ?? 0) * (tradeCashs.UnwindPercentRate ?? 0) * ((trades.BuySell == "卖出") ? 1 : -1));
row["结算期权费"] = $"{Amountqrs.OtcFormatMoney()}";
row["结算金额"] = $"{Amountqrs2.OtcFormatMoney()}";
row["结算期权费"] = $"{Amountqrs.OtcFormatMoney()}";
row["结算金额"] = $"{Amountqrs2.OtcFormatMoney()}";
table1.Add(row);
valuetimelist.Add(tradeCashs.ValueDate);
}
}
dic["合同编号"] = Context.GenerateContractNo(out _);
dic["合同编号"] = Context.GenerateContractNo(out _);
dic["table1"] = table1;
dic["合同日期"] = $"{DateTime.Now.ToString("yyyy/MM/dd")}";//ValueDate
dic["了结日期1"] = $"{valuetimelist.Min():yyyy/MM/dd}";
dic["了结日期2"] = $"{valuetimelist.Max():yyyy/MM/dd}";
dic["合同日期"] = $"{DateTime.Now.ToString("yyyy/MM/dd")}";//ValueDate
dic["了结日期1"] = $"{valuetimelist.Min():yyyy/MM/dd}";
dic["了结日期2"] = $"{valuetimelist.Max():yyyy/MM/dd}";
#region
#region
var owner_Info = Context.GetOwner_info("默认");
dic["客户名称"] = client != null ? client.Name : "";
dic["公司名称"] = owner_Info != null ? owner_Info.FullName != null ? owner_Info.FullName : "" : "";
if (trade.OpponentRole == null || trade.OpponentRole == "乙方")
var owner_Info = Context.GetOwner_info("默认");
dic["客户名称"] = client != null ? client.Name : "";
dic["公司名称"] = owner_Info != null ? owner_Info.FullName != null ? owner_Info.FullName : "" : "";
if (trade.OpponentRole == null || trade.OpponentRole == "乙方")
{
dic["甲方"] = owner_Info != null ? owner_Info.FullName != null ? owner_Info.FullName : "" : "";
dic["乙方"] = client != null ? client.Name : "";
dic["甲方"] = owner_Info != null ? owner_Info.FullName != null ? owner_Info.FullName : "" : "";
dic["乙方"] = client != null ? client.Name : "";
}
else
{
dic["甲方"] = client != null ? client.Name : "";
dic["乙方"] = owner_Info != null ? owner_Info.FullName != null ? owner_Info.FullName : "" : "";
dic["甲方"] = client != null ? client.Name : "";
dic["乙方"] = owner_Info != null ? owner_Info.FullName != null ? owner_Info.FullName : "" : "";
}
#endregion
@@ -120,7 +120,7 @@ namespace YLErp.Plugins.GuoLian.DocumentGenerator
var client = Context.GetClient();
var trade = Context.Trade;
var tradelist = Context.Trades.Union(Context.SubTrades).ToList();
var owner_Info = Context.GetOwner_info("默认") ?? new Owner_info();
var owner_Info = Context.GetOwner_info("默认") ?? new Owner_info();
var dts = tradelist.Max(m => m.TradeDate);
var dte = tradelist.Min(m => m.TradeDate);
var date = "";
@@ -133,7 +133,7 @@ namespace YLErp.Plugins.GuoLian.DocumentGenerator
date = dts?.ToString("yyyyMMdd") + "-" + dte?.ToString("yyyyMMdd");
}
var FullName = owner_Info != null ? owner_Info.FullName != null ? owner_Info.FullName : "" : "";
var rule = $"{FullName}{trade.TradeType}结算确认书{date}";
var rule = $"{FullName}{trade.TradeType}结算确认书{date}";
Context.GetcontractIndex(rule, out var contractIndex2);
return $"{rule}-{contractIndex2}.{DocType.ToLower()}";
}