找回证券业报送的逻辑,仅支持Excel模板报送

This commit is contained in:
嬴政 时
2025-05-14 20:00:04 +08:00
parent 0c9cd64038
commit fe2ff3bbcf
52 changed files with 10829 additions and 7124 deletions
@@ -1,4 +1,4 @@
using System.Globalization;
using System.Globalization;
using System.Reflection;
namespace YLErp.Modules.SuperviseReportModule.SAC.Common
@@ -56,11 +56,11 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
public override bool Execute(object value)
{
bool state = false;
string text = (value?.ToString()) ?? "";
var state = false;
var text = (value?.ToString()) ?? "";
if (text.Length == 0)
{
state = (!Required || IgnoreNullOrEmpty);
state = !Required || IgnoreNullOrEmpty;
}
else
{
@@ -258,7 +258,7 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
protected override bool Execute(string value)
{
bool match = false;
var match = false;
if (Multiple)
{
var split = EndsWithString.Split(SplitStr.ToCharArray());
@@ -316,13 +316,13 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
protected override bool Execute(string value)
{
bool result = true;
var result = true;
try
{
result = DateTime.TryParseExact((value ?? ""), FormatString, CultureInfo.CurrentCulture, DateTimeStyles.None, out _);
result = DateTime.TryParseExact(value ?? "", FormatString, CultureInfo.CurrentCulture, DateTimeStyles.None, out _);
if (!result)
{
result = DateTime.TryParse(value ?? "", out DateTime temp);
result = DateTime.TryParse(value ?? "", out var temp);
if (result)
{
UseChangeValue = true;
@@ -410,7 +410,7 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
minValue = MinValue_Number;
maxValue = MaxValue_Number;
}
List<string> msgArr = new List<string>();
var msgArr = new List<string>();
if (!double.IsNaN(minValue))
{
msgArr.Add(">={MinValue}");
@@ -439,7 +439,7 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
int beforePointMaxLength, afterPointMaxLength;
double maxValue, minValue;
isPercent = value.EndsWith("%");
isPercent = isPercent = value != null && value.EndsWith("%");
if (isPercent)
{
value = value.Remove(value.Length - 1);
@@ -455,11 +455,11 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
maxValue = MaxValue_Number;
minValue = MinValue_Number;
}
if (!double.TryParse(value, out double temp))
if (!double.TryParse(value, out var temp))
{
return false;
}
string[] part = (value ?? "").Split('.');
var part = (value ?? "").Split('.');
if (part.Length > 2)
{
return false;
@@ -468,6 +468,14 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
{
return false;
}
if (!double.IsNaN(maxValue) && temp > maxValue)
{
return false;
}
if (!double.IsNaN(minValue) && temp < minValue)
{
return false;
}
if (part.Length > 1 && part[1].Length > afterPointMaxLength)
{
UseChangeValue = true;
@@ -476,14 +484,6 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
ChangedValue = temp.ToString(sufix) + (isPercent ? "%" : "");
return true;
}
if (!double.IsNaN(maxValue) && temp > maxValue)
{
return false;
}
if (!double.IsNaN(minValue) && temp < minValue)
{
return false;
}
return true;
}
@@ -492,7 +492,7 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
int beforePointMaxLength, afterPointMaxLength;
double maxValue, minValue;
isPercent = isPercent = value != null && value.EndsWith("%");
isPercent = isPercent = value != null && value.EndsWith("%");
if (isPercent)
{
value = value.Remove(value.Length - 2);
@@ -512,8 +512,8 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
.Replace("{fieldValue}", value)
.Replace("{BeforePointMaxLength}", beforePointMaxLength.ToString())
.Replace("{AfterPointMaxLength}", afterPointMaxLength.ToString())
.Replace("{MinValue}", maxValue.ToString())
.Replace("{MaxValue}", minValue.ToString());
.Replace("{MinValue}", minValue.ToString())
.Replace("{MaxValue}", maxValue.ToString());
}
}
@@ -554,7 +554,7 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
{
//_errMsg = "{fieldName}={fieldValue}不合法,值应为数字,且最大保留位数为[{BeforePointMaxLength},{AfterPointMaxLength}]";
_errMsg = "值应为数字,且最大保留位数为[{BeforePointMaxLength},{AfterPointMaxLength}]";
List<string> msgArr = new List<string>();
var msgArr = new List<string>();
if (!double.IsNaN(MinValue))
{
msgArr.Add(">={MinValue}");
@@ -578,11 +578,11 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
protected override bool Execute(string value)
{
if (!double.TryParse(value, out double temp))
if (!double.TryParse(value, out var temp))
{
return false;
}
string[] part = (value ?? "").Split('.');
var part = (value ?? "").Split('.');
if (part.Length > 2)
{
return false;
@@ -591,23 +591,24 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
{
return false;
}
var state = true;
if (part.Length == 1 || (part.Length > 1 && part[1].Length != AfterPointMaxLength))
{
UseChangeValue = true;
string sufix = "0.".PadRight(AfterPointMaxLength + 2, '0');
var sufix = "0.".PadRight(AfterPointMaxLength + 2, '0');
UseChangeValue = true;
ChangedValue = temp.ToString(sufix);
return true;
state = true;
}
if (!double.IsNaN(MinValue) && temp < MinValue)
{
return false;
state = false;
}
if (!double.IsNaN(MaxValue) && temp > MaxValue)
{
return false;
state = false;
}
return true;
return state;
}
protected override string GenerateErrMsg(string value)
@@ -659,7 +660,7 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
{
//_errMsg = "{fieldName}={fieldValue}不合法,值应为数字,且保留位数必须为[{BeforePointMaxLength},{AfterPointLength}]";
_errMsg = "值应为数字,且保留位数必须为[{BeforePointMaxLength},{AfterPointLength}]";
List<string> msgArr = new List<string>();
var msgArr = new List<string>();
if (!double.IsNaN(MinValue))
{
msgArr.Add(">={MinValue}");
@@ -683,7 +684,7 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
protected override bool Execute(string value)
{
if (!double.TryParse(value, out double temp))
if (!double.TryParse(value, out var temp))
{
return false;
}
@@ -695,14 +696,14 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
{
return false;
}
string[] part = (value ?? "").Split('.');
var part = (value ?? "").Split('.');
if (part[0].Length > BeforePointMaxLength)
{
return false;
}
if (part.Length == 1 || (part.Length > 1 && part[1].Length != AfterPointLength))
{
string sufix = "0.".PadRight(AfterPointLength + 2, '0');
var sufix = "0.".PadRight(AfterPointLength + 2, '0');
UseChangeValue = true;
ChangedValue = temp.ToString(sufix);
return true;
@@ -728,8 +729,8 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
{
public override bool Execute(object value)
{
bool state = false;
IEnumerable<object> objs = value as IEnumerable<object>;
var state = false;
var objs = value as IEnumerable<object>;
//if (objs != null)
//{
state = Execute(objs);
@@ -869,7 +870,7 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
protected override bool Execute(string value)
{
return Map.Contains((value ?? ""));
return Map.Contains(value ?? "");
}
protected override string GenerateErrMsg(string value)
@@ -912,7 +913,7 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
protected override bool Execute(string value)
{
int length = value.Length;
var length = value.Length;
return Map.Contains(length);
}
@@ -974,7 +975,7 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
public override bool Execute(object value)
{
return (value?.ToString() == ConditionValue);
return value?.ToString() == ConditionValue;
}
}
/// <summary>
@@ -989,7 +990,7 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
public override bool Execute(object value)
{
return (value?.ToString() != ConditionValue);
return value?.ToString() != ConditionValue;
}
}
@@ -1012,7 +1013,7 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
public override bool Execute(object value)
{
if (double.TryParse((value ?? "").ToString(), out double temp))
if (double.TryParse((value ?? "").ToString(), out var temp))
{
return temp >= MinValue && temp <= MaxValue;
}
@@ -1038,7 +1039,7 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
public override bool Execute(object value)
{
if (int.TryParse((value ?? "").ToString(), out int temp))
if (double.TryParse((value ?? "").ToString(), out double temp))
{
return temp < MinValue || temp > MaxValue;
}
@@ -1055,7 +1056,7 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
public override bool Execute(object value)
{
return ConditionMap.Contains((value?.ToString() ?? ""));
return ConditionMap.Contains(value?.ToString() ?? "");
}
}
@@ -1068,7 +1069,7 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
public override bool Execute(object value)
{
return !ConditionMap.Contains((value?.ToString() ?? ""));
return !ConditionMap.Contains(value?.ToString() ?? "");
}
}
@@ -1078,14 +1079,14 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
/// 检查帮助类
/// </summary>
/// <typeparam name="T"></typeparam>
public class CheckHelper<T>
public class CheckHelper<T> where T:notnull
{
private PropertyInfo[] _properties = null;
private readonly PropertyInfo[]? _properties = null;
/// <summary>
/// 属性缓存
/// <para>应通过<see cref="CheckHelper{T}.getPropertyInfos(T)"/>方法访问</para>
/// </summary>
private Dictionary<T, Dictionary<string, object>> _propertyInfoDict = null;
private Dictionary<T, Dictionary<string, object>>? _propertyInfoDict = null;
/// <summary>
/// 检查不通过时回调的委托
/// </summary>
@@ -1101,10 +1102,7 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
private Dictionary<string, object> getPropertyInfos(T obj)
{
if (_propertyInfoDict == null)
{
_propertyInfoDict = new Dictionary<T, Dictionary<string, object>>();
}
_propertyInfoDict ??= new Dictionary<T, Dictionary<string, object>>();
if (!_propertyInfoDict.ContainsKey(obj))
{
_propertyInfoDict[obj] = _properties.ToDictionary(K => K.Name, V => V.GetValue(obj));
@@ -1114,7 +1112,7 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
private bool checkCondition(List<BaseCheckConditionAttribute> conditionAttributes, Dictionary<string, object> dict)
{
bool state = true;
var state = true;
foreach (var item in conditionAttributes)
{
if (!dict.ContainsKey(item.ConditionName))
@@ -1132,14 +1130,14 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
private bool checkCondition(PropertyInfo pInfo, T obj, Func<string[], bool> callback)
{
bool state = true;
IEnumerable<BaseCheckConditionAttribute> conditionAttrs = pInfo.GetCustomAttributes(typeof(BaseCheckConditionAttribute), true).Cast<BaseCheckConditionAttribute>();
var state = true;
var conditionAttrs = pInfo.GetCustomAttributes(typeof(BaseCheckConditionAttribute), true).Cast<BaseCheckConditionAttribute>();
var conditGroup = conditionAttrs.GroupBy(O => O.CheckHandleNameArr == null ? "" : string.Join(",", O.CheckHandleNameArr)).ToDictionary(K => K.Key, V => V.ToList());
if (conditGroup.Count > 0)
{
foreach (var condit in conditGroup)
{
Dictionary<string, object> dict = getPropertyInfos(obj);
var dict = getPropertyInfos(obj);
state = checkCondition(condit.Value, dict);
if (state)
{
@@ -1161,7 +1159,7 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
private bool checkValue(string checkName, BaseCheckAttribute[] checkAttributes, PropertyInfo pInfo, T obj, out string errMsg)
{
errMsg = "";
bool state = true;
var state = true;
var attrs = checkAttributes.Where(O => (O.CheckHandleName ?? "") == checkName);
foreach (var item in attrs)
{
@@ -1187,23 +1185,22 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Common
/// <returns></returns>
public bool ExecuteCheck(T obj, CheckErrorCallback callback)
{
bool checkState = false;
string errMsg;
var checkState = false;
if (obj == null)
{
return checkState;
}
foreach (var p in _properties)
{
BaseCheckAttribute[] attr = p.GetCustomAttributes(typeof(BaseCheckAttribute), true).Cast<BaseCheckAttribute>().ToArray();
var attr = p.GetCustomAttributes(typeof(BaseCheckAttribute), true).Cast<BaseCheckAttribute>().ToArray();
if (attr.Length == 0)
{ continue; }
checkCondition(p, obj, (checkNames) =>
{
bool status = true;
var status = true;
foreach (var item in checkNames)
{
if (!checkValue((item ?? ""), attr, p, obj, out errMsg))
if (!checkValue(item ?? "", attr, p, obj, out var errMsg))
{
callback(p.Name, p.GetValue(obj), errMsg);
status = false;