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
{
///
/// 报送方编号
///
public string SenderCode { get; set; }
///
/// 接收方编号
///
public string ReceiverCode { get; set; }
///
/// 报送日期
///
public DateTime ReportDate { get; set; }
///
/// 数据日期
///
public DateTime DataDate { get; set; }
///
/// 上月末现金余额
///
public double LastMonthCash { get; set; }
///
/// 本月末现金余额
///
public double LatestMonthCash { get; set; }
///
/// 最新净资产
///
public double LatestNetAssets { get; set; }
///
/// 是否存在SAC报告
///
public OptFlagsEnum SACReportStatus { get; set; }
///
/// SAC报告编码
///
public DateTime? SACReportDate { get; set; }
///
/// 是否存在NAFMII报告
///
public OptFlagsEnum NAFMIIReportStatus { get; set; }
///
/// NAFMII报告编码
///
public DateTime? NAFMIIReportDate { get; set; }
///
/// 是否存在ISDA报告
///
public OptFlagsEnum ISDAReportStatus { get; set; }
///
/// ISDA报告编码
///
public DateTime? ISDAReportDate { get; set; }
///
/// 是否存在重大事项报告
///
public OptFlagsEnum EventReportStatus { get; set; }
///
/// 重大事项报告编码
///
public DateTime? EventReportDate { get { return ReportDate; } }
///
/// 重大事项说明
///
public string EventReportDesc { get; set; }
///
/// 是否存在其他事项报告
///
public OptFlagsEnum OtherReportStatus { get; set; }
///
/// 其他事项报告编码
///
public DateTime? OtherReportDate { get { return ReportDate; } }
///
/// 其他事项说明
///
public string OtherReportDesc { get; set; }
///
/// 是否存在季度报告
///
public OptFlagsEnum PeriodicReportQuarterStatus { get; set; }
///
/// 要撤销的季度报告报送日期
///
public DateTime? PeriodicReportQuarterDate { get; set; }
///
/// 报告类型
///
public List ReportTypes { get; set; }
///
/// 证券业报送中定期报告取值模式
/// 1=Db;
/// 2=Excel模板;
/// 3=Db+Excel模板(该方式中涉及百分比汇总计算时仍使用模板中数据)
/// 4=金仕达视图(该方式只涉及互换确认书及存续期的数据)
/// 5=Db+金仕达视图
/// 6=Excel+金仕达视图
/// 7=Db+Excel+金仕达视图
///
public SAC_ReportDataSourceEnum DataSource { get; set; }
}
public class ReportResponse
{
public int Index { get; set; }
///
/// 文件名
///
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 Infos { get; set; }
}
public abstract class ReportBaseModel
{
///
/// 忽略字段校验
/// 仅外部数据来源使用
///
[XmlIgnore]
[NotMapped]
public bool IgnoreCheck { get; set; }
[Key]
[XmlIgnore]
public int Id { get; set; }
///
/// 报送日期
///
[XmlIgnore]
public DateTime ReportDate { get; set; }
///
/// 业务数据流水号
/// 长度:28
/// 必填:是
/// 说明:文件创建人代码(6位)+文件接收人代码(6位)+报送日期(8位)+当日顺序编号(8位)
///
[CheckStringLength(Length = 28)]
[SacDescription("ExceID", "业务数据流水号", "28", true, "文件创建人代码(6位)+文件接收人代码(6位)+报送日期(8位)+当日顺序编号(8位);")]
public string ExceID { get; set; }
///
/// 响应码
/// 长度:6
/// 必填:是
/// 说明:报送时该字段应为Null
///
[XmlElement(IsNullable = false)]
[NotMapped]
[SacDescription("RetCode", "响应码", "6", true, "报送时该字段应为Null;")]
public string RetCode { get; set; }
///
/// 响应描述
/// 长度:1000
/// 必填:是
/// 说明:报送时该字段应为Null
///
[XmlElement(IsNullable = false)]
[NotMapped]
[SacDescription("RetMsg", "响应描述", "1000", true, "报送时该字段应为Null;")]
public string RetMsg { get; set; }
///
/// 报送数据业务编号
/// 长度:50
/// 必填:否
/// 说明:报告库接口返回,数据处理异常时为空
/// 报送时该字段应为Null
///
[XmlElement(IsNullable = false)]
[NotMapped]
[SacDescription("BizID", "报送数据业务编号", "50", false, "报告库接口返回,数据处理异常时为空\r\n报送时该字段应为Null;")]
public string BizID { get; set; }
///
/// 操作事件编号
/// 长度:6
/// 必填:否
/// 说明:场外证券业务系统接口返回,当报送存续期业务时,返回操作时间编号ID
/// 报送时该字段应为Null
///
[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; }
///
/// 报送日期
///
[XmlIgnore]
public DateTime ReportDate { get; set; }
///
/// 来源报送文件 ExceID
///
[XmlIgnore]
public string ExceID { get; set; }
}
///
/// 报告状态
///
public class ReportStatusModel
{
///
/// 缓存信息
///
private Dictionary> CacheInfo { get; set; }
///
/// 200MB
///
public const long MaxFileLength = 209715200;
///
/// 30MB
///
public const long MaxAnnexLength = 31457280;
private long limitFileLength => MaxFileLength - 5242880;//留出5MB余量
public long CurrentLength { get; private set; } = 0;
public bool Continue { get; private set; }
///
/// 重置当前文件大小
///
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;
//}
}
///
/// 检查缓存是否存在value
///
///
///
/// 缓存是否存在value
public bool CheckCacheInfo(string key, string value)
{
CacheInfo ??= new Dictionary>();
if (!CacheInfo.ContainsKey(key))
{
CacheInfo[key] = new List();
}
return CacheInfo[key].Contains(value);
}
///
/// 获取缓存列表
///
///
///
public ReadOnlyCollection GetCacheInfo(string key)
{
CacheInfo ??= new Dictionary>();
if (!CacheInfo.ContainsKey(key))
{
CacheInfo[key] = new List();
}
return CacheInfo[key].AsReadOnly();
}
///
/// 将value添加到缓存
///
///
///
public void AddCacheInfo(string key, string value)
{
CacheInfo ??= new Dictionary>();
if (!CacheInfo.ContainsKey(key))
{
CacheInfo[key] = new List();
}
if (!CacheInfo[key].Contains(value))
{
CacheInfo[key].Add(value);
}
}
}
}