Files
zszq-trs/YLErpDAL/Modules/SuperviseReportModule/SAC/Model/ReportReq.cs
T
2024-05-09 14:06:26 +08:00

306 lines
10 KiB
C#

using System.Collections.ObjectModel;
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; }
}
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")}";
}
}
public List<ReportRootModel> Infos { get; set; }
}
public abstract class ReportBaseModel
{
/// <summary>
/// 忽略字段校验
/// <para>仅外部数据来源使用</para>
/// </summary>
[XmlIgnore]
public bool IgnoreCheck { 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)]
[SacDescription("RetCode", "响应码", "6", true, "报送时该字段应为Null;")]
public string RetCode { get; set; }
/// <summary>
/// 响应描述
/// <para>长度:1000</para>
/// <para>必填:是</para>
/// <para>说明:报送时该字段应为Null</para>
/// </summary>
[XmlElement(IsNullable = false)]
[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)]
[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)]
[SacDescription("DurationEventNO", "操作事件编号", "6", false, "场外证券业务系统接口返回,当报送存续期业务时,返回操作时间编号ID\r\n报送时该字段应为Null;")]
public string DurationEventNO { 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余量
private long _currentLength = 0;
public long CurrentLength => _currentLength;
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 > limitFileLength)
{
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)
{
if (CacheInfo == null)
{
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)
{
if (CacheInfo == null)
{
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)
{
if (CacheInfo == null)
{
CacheInfo = new Dictionary<string, List<string>>();
}
if (!CacheInfo.ContainsKey(key))
{
CacheInfo[key] = new List<string>();
}
if (!CacheInfo[key].Contains(value))
{
CacheInfo[key].Add(value);
}
}
}
}