346 lines
11 KiB
C#
346 lines
11 KiB
C#
using System.Collections.ObjectModel;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Xml.Serialization;
|
|
using YLErp.Modules.SuperviseReportModule.SAC.Common;
|
|
using static YLErp.DBModels.Consts.ConsReport;
|
|
|
|
namespace YLErp.Modules.SuperviseReportModule.SAC.Model
|
|
{
|
|
public class ReportInfo
|
|
{
|
|
/// <summary>
|
|
/// 报送方编号
|
|
/// </summary>
|
|
public string SenderCode { get; set; }
|
|
/// <summary>
|
|
/// 接收方编号
|
|
/// </summary>
|
|
public string ReceiverCode { get; set; }
|
|
/// <summary>
|
|
/// 报送日期
|
|
/// </summary>
|
|
public DateTime ReportDate { get; set; }
|
|
/// <summary>
|
|
/// 数据日期
|
|
/// </summary>
|
|
public DateTime DataDate { get; set; }
|
|
/// <summary>
|
|
/// 上月末现金余额
|
|
/// </summary>
|
|
public double LastMonthCash { get; set; }
|
|
/// <summary>
|
|
/// 本月末现金余额
|
|
/// </summary>
|
|
public double LatestMonthCash { get; set; }
|
|
/// <summary>
|
|
/// 最新净资产
|
|
/// </summary>
|
|
public double LatestNetAssets { get; set; }
|
|
/// <summary>
|
|
/// 是否存在SAC报告
|
|
/// </summary>
|
|
public OptFlagsEnum SACReportStatus { get; set; }
|
|
/// <summary>
|
|
/// SAC报告编码
|
|
/// </summary>
|
|
public DateTime? SACReportDate { get; set; }
|
|
/// <summary>
|
|
/// 是否存在NAFMII报告
|
|
/// </summary>
|
|
public OptFlagsEnum NAFMIIReportStatus { get; set; }
|
|
/// <summary>
|
|
/// NAFMII报告编码
|
|
/// </summary>
|
|
public DateTime? NAFMIIReportDate { get; set; }
|
|
/// <summary>
|
|
/// 是否存在ISDA报告
|
|
/// </summary>
|
|
public OptFlagsEnum ISDAReportStatus { get; set; }
|
|
/// <summary>
|
|
/// ISDA报告编码
|
|
/// </summary>
|
|
public DateTime? ISDAReportDate { get; set; }
|
|
/// <summary>
|
|
/// 是否存在重大事项报告
|
|
/// </summary>
|
|
public OptFlagsEnum EventReportStatus { get; set; }
|
|
/// <summary>
|
|
/// 重大事项报告编码
|
|
/// </summary>
|
|
public DateTime? EventReportDate { get { return ReportDate; } }
|
|
/// <summary>
|
|
/// 重大事项说明
|
|
/// </summary>
|
|
public string EventReportDesc { get; set; }
|
|
/// <summary>
|
|
/// 是否存在其他事项报告
|
|
/// </summary>
|
|
public OptFlagsEnum OtherReportStatus { get; set; }
|
|
/// <summary>
|
|
/// 其他事项报告编码
|
|
/// </summary>
|
|
public DateTime? OtherReportDate { get { return ReportDate; } }
|
|
/// <summary>
|
|
/// 其他事项说明
|
|
/// </summary>
|
|
public string OtherReportDesc { get; set; }
|
|
/// <summary>
|
|
/// 是否存在季度报告
|
|
/// </summary>
|
|
public OptFlagsEnum PeriodicReportQuarterStatus { get; set; }
|
|
/// <summary>
|
|
/// 要撤销的季度报告报送日期
|
|
/// </summary>
|
|
public DateTime? PeriodicReportQuarterDate { get; set; }
|
|
/// <summary>
|
|
/// 报告类型
|
|
/// </summary>
|
|
public List<int> ReportTypes { get; set; }
|
|
|
|
/// <summary>
|
|
/// 证券业报送中定期报告取值模式
|
|
/// <para>1=Db;</para>
|
|
/// <para>2=Excel模板;</para>
|
|
/// <para>3=Db+Excel模板(该方式中涉及百分比汇总计算时仍使用模板中数据)</para>
|
|
/// <para>4=金仕达视图(该方式只涉及互换确认书及存续期的数据)</para>
|
|
/// <para>5=Db+金仕达视图</para>
|
|
/// <para>6=Excel+金仕达视图</para>
|
|
/// <para>7=Db+Excel+金仕达视图</para>
|
|
/// </summary>
|
|
public SAC_ReportDataSourceEnum DataSource { get; set; }
|
|
}
|
|
|
|
public class ReportResponse
|
|
{
|
|
public int Index { get; set; }
|
|
|
|
/// <summary>
|
|
/// 文件名
|
|
/// </summary>
|
|
public string FileTag
|
|
{
|
|
get
|
|
{
|
|
if (Infos == null || Infos.Count == 0)
|
|
{
|
|
return "";
|
|
}
|
|
return $"OTC_{Infos[0].Header.SenderCode}_{Infos[0].Header.ReceiverCode}_{Infos[0].Header.ReportType}_{Infos[0].Header.SendDate.Replace("-", "")}_{Index.ToString("0000")}{(Infos.Any(O => O.Header.BusiDataType == DataFlagsEnum.A1015) ? "_checked" : "")}";
|
|
}
|
|
}
|
|
|
|
public List<ReportRootModel> Infos { get; set; }
|
|
}
|
|
|
|
public abstract class ReportBaseModel
|
|
{
|
|
/// <summary>
|
|
/// 忽略字段校验
|
|
/// <para>仅外部数据来源使用</para>
|
|
/// </summary>
|
|
[XmlIgnore]
|
|
[NotMapped]
|
|
public bool IgnoreCheck { get; set; }
|
|
|
|
[Key]
|
|
[XmlIgnore]
|
|
public int Id { get; set; }
|
|
|
|
/// <summary>
|
|
/// 报送日期
|
|
/// </summary>
|
|
[XmlIgnore]
|
|
public DateTime ReportDate { get; set; }
|
|
|
|
/// <summary>
|
|
/// 业务数据流水号
|
|
/// <para>长度:28</para>
|
|
/// <para>必填:是</para>
|
|
/// <para>说明:文件创建人代码(6位)+文件接收人代码(6位)+报送日期(8位)+当日顺序编号(8位)</para>
|
|
/// </summary>
|
|
|
|
[CheckStringLength(Length = 28)]
|
|
[SacDescription("ExceID", "业务数据流水号", "28", true, "文件创建人代码(6位)+文件接收人代码(6位)+报送日期(8位)+当日顺序编号(8位);")]
|
|
public string ExceID { get; set; }
|
|
/// <summary>
|
|
/// 响应码
|
|
/// <para>长度:6</para>
|
|
/// <para>必填:是</para>
|
|
/// <para>说明:<see cref="Consts.RetCodeMap"/>报送时该字段应为Null</para>
|
|
/// </summary>
|
|
[XmlElement(IsNullable = false)]
|
|
[NotMapped]
|
|
[SacDescription("RetCode", "响应码", "6", true, "报送时该字段应为Null;")]
|
|
public string RetCode { get; set; }
|
|
/// <summary>
|
|
/// 响应描述
|
|
/// <para>长度:1000</para>
|
|
/// <para>必填:是</para>
|
|
/// <para>说明:报送时该字段应为Null</para>
|
|
/// </summary>
|
|
[XmlElement(IsNullable = false)]
|
|
[NotMapped]
|
|
[SacDescription("RetMsg", "响应描述", "1000", true, "报送时该字段应为Null;")]
|
|
public string RetMsg { get; set; }
|
|
/// <summary>
|
|
/// 报送数据业务编号
|
|
/// <para>长度:50</para>
|
|
/// <para>必填:否</para>
|
|
/// <para>说明:报告库接口返回,数据处理异常时为空</para>
|
|
/// <para>报送时该字段应为Null</para>
|
|
/// </summary>
|
|
[XmlElement(IsNullable = false)]
|
|
[NotMapped]
|
|
[SacDescription("BizID", "报送数据业务编号", "50", false, "报告库接口返回,数据处理异常时为空\r\n报送时该字段应为Null;")]
|
|
public string BizID { get; set; }
|
|
/// <summary>
|
|
/// 操作事件编号
|
|
/// <para>长度:6</para>
|
|
/// <para>必填:否</para>
|
|
/// <para>说明:场外证券业务系统接口返回,当报送存续期业务时,返回操作时间编号ID</para>
|
|
/// <para>报送时该字段应为Null</para>
|
|
/// </summary>
|
|
[XmlElement(IsNullable = false)]
|
|
[NotMapped]
|
|
[SacDescription("DurationEventNO", "操作事件编号", "6", false, "场外证券业务系统接口返回,当报送存续期业务时,返回操作时间编号ID\r\n报送时该字段应为Null;")]
|
|
public string DurationEventNO { get; set; }
|
|
}
|
|
|
|
public abstract class ReportSubBaseModel
|
|
{
|
|
[Key]
|
|
[XmlIgnore]
|
|
public int Id { get; set; }
|
|
|
|
/// <summary>
|
|
/// 报送日期
|
|
/// </summary>
|
|
[XmlIgnore]
|
|
public DateTime ReportDate { get; set; }
|
|
|
|
/// <summary>
|
|
/// 来源报送文件 ExceID
|
|
/// </summary>
|
|
[XmlIgnore]
|
|
public string ExceID { get; set; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 报告状态
|
|
/// </summary>
|
|
public class ReportStatusModel
|
|
{
|
|
/// <summary>
|
|
/// 缓存信息
|
|
/// </summary>
|
|
private Dictionary<string, List<string>> CacheInfo { get; set; }
|
|
|
|
/// <summary>
|
|
/// 200MB
|
|
/// </summary>
|
|
public const long MaxFileLength = 209715200;
|
|
|
|
/// <summary>
|
|
/// 30MB
|
|
/// </summary>
|
|
public const long MaxAnnexLength = 31457280;
|
|
|
|
private long limitFileLength => MaxFileLength - 5242880;//留出5MB余量
|
|
|
|
public long CurrentLength { get; private set; } = 0;
|
|
|
|
public bool Continue { get; private set; }
|
|
|
|
/// <summary>
|
|
/// 重置当前文件大小
|
|
/// </summary>
|
|
public void ResetCurrentLength()
|
|
{
|
|
CurrentLength = 0;
|
|
Continue = false;
|
|
}
|
|
|
|
public bool CheckFileLength(string path)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(path))
|
|
{
|
|
return true;
|
|
}
|
|
if (path.StartsWith("\\") || path.StartsWith("/") || !Path.IsPathRooted(path))
|
|
{
|
|
path = OtcAppContext.MapPath(path);
|
|
}
|
|
if (!File.Exists(path))
|
|
{
|
|
return true;
|
|
}
|
|
//var length = new FileInfo(path).Length;
|
|
//if (length > MaxAnnexLength)
|
|
//{
|
|
// LogFactory.GetLogger("CheckFileLength").Error($"单一文件大小不应超过30MB,错误文件:{path}");
|
|
// throw new ServiceException("单一文件大小不应超过30MB");
|
|
//}
|
|
//CurrentLength += length;
|
|
//if (CurrentLength <= limitFileLength)
|
|
//{
|
|
return true;
|
|
//}
|
|
//else
|
|
//{
|
|
// Continue = true;
|
|
// return false;
|
|
//}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 检查缓存是否存在value
|
|
/// </summary>
|
|
/// <param name="key"></param>
|
|
/// <param name="value"></param>
|
|
/// <returns>缓存是否存在value</returns>
|
|
public bool CheckCacheInfo(string key, string value)
|
|
{
|
|
CacheInfo ??= new Dictionary<string, List<string>>();
|
|
if (!CacheInfo.ContainsKey(key))
|
|
{
|
|
CacheInfo[key] = new List<string>();
|
|
}
|
|
return CacheInfo[key].Contains(value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取缓存列表
|
|
/// </summary>
|
|
/// <param name="key"></param>
|
|
/// <returns></returns>
|
|
public ReadOnlyCollection<string> GetCacheInfo(string key)
|
|
{
|
|
CacheInfo ??= new Dictionary<string, List<string>>();
|
|
if (!CacheInfo.ContainsKey(key))
|
|
{
|
|
CacheInfo[key] = new List<string>();
|
|
}
|
|
return CacheInfo[key].AsReadOnly();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 将value添加到缓存
|
|
/// </summary>
|
|
/// <param name="key"></param>
|
|
/// <param name="value"></param>
|
|
public void AddCacheInfo(string key, string value)
|
|
{
|
|
CacheInfo ??= new Dictionary<string, List<string>>();
|
|
if (!CacheInfo.ContainsKey(key))
|
|
{
|
|
CacheInfo[key] = new List<string>();
|
|
}
|
|
if (!CacheInfo[key].Contains(value))
|
|
{
|
|
CacheInfo[key].Add(value);
|
|
}
|
|
}
|
|
}
|
|
}
|