找回证券业报送的逻辑,仅支持Excel模板报送
This commit is contained in:
+56
-150
@@ -19,151 +19,38 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Service
|
||||
|
||||
protected override DataFlagsEnum BusiDataType => DataFlagsEnum.A1008;
|
||||
|
||||
private List<OptFlagsEnum> _validOperationType = null;
|
||||
private List<OptFlagsEnum>? _validOperationType = null;
|
||||
public override List<OptFlagsEnum> ValidOperationType
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_validOperationType == null)
|
||||
{
|
||||
_validOperationType = new List<OptFlagsEnum>() {
|
||||
_validOperationType ??= new List<OptFlagsEnum>() {
|
||||
OptFlagsEnum.A,
|
||||
OptFlagsEnum.U,
|
||||
OptFlagsEnum.D,
|
||||
};
|
||||
}
|
||||
return _validOperationType;
|
||||
}
|
||||
}
|
||||
|
||||
protected override SuperviseReportTypeEnum ReportType => SuperviseReportTypeEnum.SAC_PerformanceGuaranteeAgrmt;
|
||||
List<SACReportNotes> noteList = new List<SACReportNotes>();
|
||||
|
||||
readonly List<SACReportNotes> noteList = new();
|
||||
|
||||
protected override BodyModel GenerateBody(out bool noData, out List<string> fileList)
|
||||
{
|
||||
fileList = new List<string>();
|
||||
BodyModel model = new BodyModel();
|
||||
List<PerformanceGuaranteeAgrmtModel> dataList = new List<PerformanceGuaranteeAgrmtModel>();
|
||||
if ((PS.Config.ErpElement.SAC_ReportDataSource & SAC_ReportDataSourceEnum.Template) == SAC_ReportDataSourceEnum.Template)
|
||||
var model = new BodyModel();
|
||||
var dataList = new List<PerformanceGuaranteeAgrmtModel>();
|
||||
if (_reqInfo.DataSource.HasFlag(SAC_ReportDataSourceEnum.Template))
|
||||
{
|
||||
dataList = GetPerformanceGuaranteeAgrmtModel(ref fileList);
|
||||
}
|
||||
if ((PS.Config.ErpElement.SAC_ReportDataSource & SAC_ReportDataSourceEnum.System) == SAC_ReportDataSourceEnum.System)
|
||||
{
|
||||
var cacheKey = $"{BusiDataType}";
|
||||
using (var baseDb = DbContextFactory.GetClientDbContext(null))
|
||||
{
|
||||
var nextDate = _reqInfo.ReportDate.AddDays(1);
|
||||
var fileObjList = (from c in baseDb.client
|
||||
join cf in baseDb.client_file
|
||||
on c.id equals cf.ClientId
|
||||
where c.ProcessStatus == "已开户" && cf.HasSent == false && cf.IsValid &&
|
||||
cf.FileTypeName == ConsGlobal.ClientFileType.DateMargin && cf.OptState == _operationType &&
|
||||
((c.ProcessOptDate >= _reqInfo.ReportDate && c.ProcessOptDate < nextDate && cf.OptDate < nextDate) ||//如果这一天开户,则把这一天之前(含这一天)的所有文件都报送了
|
||||
(cf.OptDate >= _reqInfo.ReportDate && cf.OptDate < nextDate && c.ProcessOptDate < _reqInfo.ReportDate))//如果这一天不是开户日期,则只在报送日期大于开户日期时,报送当日修改的文件
|
||||
&& cf.ApprovalOrder < 1
|
||||
select new
|
||||
{
|
||||
cf.id,
|
||||
cf.ProtocolNumber,
|
||||
cf.MainProtocolNumber,
|
||||
cf.FilePath,
|
||||
cf.FileName,
|
||||
cf.SignDate,
|
||||
}).ToArray();
|
||||
var codes = fileObjList.Select(O => O.MainProtocolNumber);
|
||||
ExpandoDictionary<string, client_file> protocolFileDict = null;
|
||||
if (codes.Count() > 0)
|
||||
{
|
||||
protocolFileDict = new ExpandoDictionary<string, client_file>(
|
||||
baseDb.client_file
|
||||
.Where(O => O.ApprovalOrder < 1 && O.FileTypeName == ConsGlobal.ClientFileType.EnhanceProtocol && codes.Contains(O.ProtocolNumber) && O.IsValid)
|
||||
.AsEnumerable()
|
||||
.GroupBy(O => O.ProtocolNumber)
|
||||
.ToDictionary(K => K.Key, V => V.FirstOrDefault())
|
||||
);
|
||||
}
|
||||
foreach (var item in fileObjList)
|
||||
{
|
||||
var info = new PerformanceGuaranteeAgrmtModel();
|
||||
info.OperationType = _operationType;
|
||||
info.MasterAgrmtNo = protocolFileDict[item.MainProtocolNumber ?? ""]?.MainProtocolNumber;
|
||||
info.SupAgrmtNo = protocolFileDict[item.MainProtocolNumber ?? ""]?.ProtocolNumber;
|
||||
info.PerformanceGuaranteeAgrmt = item.FileName;
|
||||
info.SigningDate = item.SignDate?.ToString("yyyy-MM-dd");
|
||||
var cacheValue = info.MasterAgrmtNo + "_" + info.SupAgrmtNo;
|
||||
if (ReportStatus.CheckCacheInfo(cacheKey, cacheValue))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
SACReportNotes note = base.GetReportNotes(ReportType, formatInfoTag(info)).FirstOrDefault();
|
||||
if (note == null && _operationType == OptFlagsEnum.A)
|
||||
{
|
||||
note = new SACReportNotes()
|
||||
{
|
||||
InfoCache = $"{{\"Tag\":\"{info.PerformanceGuaranteeAgrmt}\",\"Source\":\"System\"}}",
|
||||
IsValid = true,
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
if (note == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
switch (_operationType)
|
||||
{
|
||||
case OptFlagsEnum.A:
|
||||
continue;//新增数据已报送,跳过
|
||||
case OptFlagsEnum.U:
|
||||
note.IsValid = true;
|
||||
break;
|
||||
case OptFlagsEnum.D:
|
||||
note.IsValid = false;
|
||||
break;
|
||||
case OptFlagsEnum.NONE:
|
||||
default:
|
||||
throw new ServiceException("未知操作类型");
|
||||
}
|
||||
}
|
||||
if (info.OperationType != OptFlagsEnum.A)
|
||||
{
|
||||
info.PerformanceGuaranteeAgrmtID = note.BizId;
|
||||
}
|
||||
info.ExceID = base.formatExceID();
|
||||
if (!ReportStatus.CheckFileLength(item.FilePath))
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportStatus.AddCacheInfo(cacheKey, cacheValue);
|
||||
}
|
||||
dataList.Add(info);
|
||||
fileList.Add(item.FilePath);
|
||||
note.id = 0;
|
||||
note.DataId = item.id.ToString();
|
||||
note.ExceId = info.ExceID;
|
||||
note.CreateTime = DateTime.Now;
|
||||
note.FileTag = FileTag;
|
||||
note.ReportType = ReportType;
|
||||
note.ReportDate = _reqInfo.ReportDate;
|
||||
note.InfoTag = formatInfoTag(info, true);
|
||||
note.OptTime = note.CreateTime;
|
||||
note.RetCode = "";
|
||||
note.RetMsg = "";
|
||||
note.ReportResponse = false;
|
||||
note.BizId = "";
|
||||
note.changeStatus = false;
|
||||
noteList.Add(note);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var subsystemDataList = loadSubsystemDataSource<PerformanceGuaranteeAgrmtModel>(fileList, AddSubsystemNote);
|
||||
if (subsystemDataList != null && subsystemDataList.Count > 0)
|
||||
{
|
||||
dataList.AddRange(subsystemDataList);
|
||||
}
|
||||
|
||||
noData = dataList.Count == 0;
|
||||
model.PerformanceGuaranteeAgrmt = dataList;
|
||||
@@ -172,7 +59,7 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Service
|
||||
|
||||
public bool AddSubsystemNote(PerformanceGuaranteeAgrmtModel model, List<string> fileList, string tag)
|
||||
{
|
||||
SACReportNotes note = base.GetReportNotes(ReportType, formatInfoTag(model,true)).FirstOrDefault();//参数true要加,要不A和D会查到同一条记录,在D时候,就会和A相同的数据
|
||||
var note = base.GetReportNotes(ReportType, formatInfoTag(model, true)).FirstOrDefault();//参数true要加,要不A和D会查到同一条记录,在D时候,就会和A相同的数据
|
||||
if (note == null)
|
||||
{
|
||||
note = new SACReportNotes()
|
||||
@@ -200,7 +87,7 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Service
|
||||
throw new ServiceException("未知操作类型");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!string.IsNullOrEmpty(model.PerformanceGuaranteeAgrmt))
|
||||
{
|
||||
fileList.Add(model.PerformanceGuaranteeAgrmt);
|
||||
@@ -225,7 +112,7 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Service
|
||||
|
||||
private string formatInfoTag(PerformanceGuaranteeAgrmtModel model, bool suffixType = false)
|
||||
{
|
||||
string result = $"{BusiDataType}_{model.MasterAgrmtNo.Replace("_", "-")}_{model.SupAgrmtNo.Replace("_", "-")}_";
|
||||
var result = $"{BusiDataType}_{model.MasterAgrmtNo.Replace("_", "-")}_{model.SupAgrmtNo.Replace("_", "-")}_{model.PerformanceGuaranteeAgrmt.Replace("_", "-")}_";
|
||||
if (suffixType)
|
||||
{
|
||||
result = $"{result}{_operationType}";
|
||||
@@ -233,15 +120,20 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Service
|
||||
return result;
|
||||
}
|
||||
|
||||
protected override string _changeCodeOfInfoTag(string infoTag, string newCode, out string originalCode)
|
||||
{
|
||||
originalCode = "";
|
||||
return infoTag;
|
||||
}
|
||||
|
||||
private List<PerformanceGuaranteeAgrmtModel> GetPerformanceGuaranteeAgrmtModel(ref List<string> fileList)
|
||||
{
|
||||
List<PerformanceGuaranteeAgrmtModel> result = new List<PerformanceGuaranteeAgrmtModel>();
|
||||
var result = new List<PerformanceGuaranteeAgrmtModel>();
|
||||
if (_excelDataSource != null && _excelDataSource.Tables.Contains("履约保证书明细"))
|
||||
{
|
||||
var cacheKey = $"{BusiDataType}";
|
||||
string sourcePath = Path.Combine(_excelDataSourceRootPath, "附件");
|
||||
DataTable dt = _excelDataSource.Tables["履约保证书明细"];
|
||||
for (int i = 1; i < dt.Rows.Count; i++)
|
||||
var sourcePath = Path.Combine(_excelDataSourceRootPath, "附件");
|
||||
var dt = _excelDataSource.Tables["履约保证书明细"];
|
||||
for (var i = 1; i < dt.Rows.Count; i++)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(dt.Rows[i][0]?.ToString()))
|
||||
{
|
||||
@@ -251,12 +143,18 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Service
|
||||
var optType = OptFlagsEnum.NONE;
|
||||
switch (dt.Rows[i][2]?.ToString())
|
||||
{
|
||||
case "0":
|
||||
case "A":
|
||||
case "首次":
|
||||
optType = OptFlagsEnum.A;
|
||||
break;
|
||||
case "1":
|
||||
case "U":
|
||||
case "变更":
|
||||
optType = OptFlagsEnum.U;
|
||||
break;
|
||||
case "2":
|
||||
case "D":
|
||||
case "废止":
|
||||
optType = OptFlagsEnum.D;
|
||||
break;
|
||||
@@ -266,20 +164,21 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Service
|
||||
continue;
|
||||
}
|
||||
|
||||
PerformanceGuaranteeAgrmtModel model = new PerformanceGuaranteeAgrmtModel();
|
||||
|
||||
model.MasterAgrmtNo = GetDataSetValue(dt, i, 0);
|
||||
model.SupAgrmtNo = GetDataSetValue(dt, i, 1);
|
||||
model.OperationType = optType == OptFlagsEnum.A ? OptFlagsEnum.A : OptFlagsEnum.U;
|
||||
model.PerformanceGuaranteeAgrmt = GetDataSetValue(dt, i, 3);
|
||||
model.SigningDate = GetDataSetValue(dt, i, 4);
|
||||
var cacheValue = model.MasterAgrmtNo + "_" + model.SupAgrmtNo;
|
||||
if (ReportStatus.CheckCacheInfo(cacheKey, cacheValue))
|
||||
var model = new PerformanceGuaranteeAgrmtModel
|
||||
{
|
||||
MasterAgrmtNo = GetDataSetValue(dt, i, 0),
|
||||
SupAgrmtNo = GetDataSetValue(dt, i, 1),
|
||||
OperationType = optType == OptFlagsEnum.A ? OptFlagsEnum.A : OptFlagsEnum.U,
|
||||
PerformanceGuaranteeAgrmt = GetDataSetValue(dt, i, 3),
|
||||
SigningDate = GetDataSetValue(dt, i, 4)
|
||||
};
|
||||
var cacheValue = model.MasterAgrmtNo + "_" + model.SupAgrmtNo + "_" + model.PerformanceGuaranteeAgrmt;
|
||||
if (ReportStatus.CheckCacheInfo(CacheKey, cacheValue))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
SACReportNotes note = base.GetReportNotes(ReportType, formatInfoTag(model)).FirstOrDefault();
|
||||
var note = base.GetReportNotes(ReportType, formatInfoTag(model)).FirstOrDefault();
|
||||
if (note == null && _operationType == OptFlagsEnum.A)
|
||||
{
|
||||
note = new SACReportNotes()
|
||||
@@ -316,14 +215,14 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Service
|
||||
if (!string.IsNullOrWhiteSpace(model.PerformanceGuaranteeAgrmt))
|
||||
{
|
||||
model.ExceID = base.formatExceID();
|
||||
string path = Path.Combine(sourcePath, model.PerformanceGuaranteeAgrmt);
|
||||
var path = Path.Combine(sourcePath, model.PerformanceGuaranteeAgrmt);
|
||||
if (!ReportStatus.CheckFileLength(path))
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportStatus.AddCacheInfo(cacheKey, cacheValue);
|
||||
ReportStatus.AddCacheInfo(CacheKey, cacheValue);
|
||||
}
|
||||
result.Add(model);
|
||||
fileList.Add(path);
|
||||
@@ -349,23 +248,30 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Service
|
||||
|
||||
protected override List<SacInfo> CheckBodyValue(BodyModel model, out bool checkStatus)
|
||||
{
|
||||
List<SacInfo> result = new List<SacInfo>();
|
||||
var result = new List<SacInfo>();
|
||||
if (model.PerformanceGuaranteeAgrmt != null)
|
||||
{
|
||||
CheckHelper<PerformanceGuaranteeAgrmtModel> helper = new Common.CheckHelper<PerformanceGuaranteeAgrmtModel>();
|
||||
for (int i = 0; i < model.PerformanceGuaranteeAgrmt.Count; i++)
|
||||
var helper = new Common.CheckHelper<PerformanceGuaranteeAgrmtModel>();
|
||||
for (var i = 0; i < model.PerformanceGuaranteeAgrmt.Count; i++)
|
||||
{
|
||||
List<SacInfo> listRoot = new List<SacInfo>();
|
||||
var listRoot = new List<SacInfo>();
|
||||
var item = model.PerformanceGuaranteeAgrmt[i];
|
||||
if (item.IgnoreCheck) continue;
|
||||
if (item.IgnoreCheck)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
helper.ExecuteCheck(item, (name, value, msg) =>
|
||||
{
|
||||
listRoot.Add(new SacInfo(name, value, msg));
|
||||
});
|
||||
if (listRoot.Count > 0)
|
||||
{
|
||||
var errMsg = new SacInfo("PerformanceGuaranteeAgrmt", i);
|
||||
errMsg.SubMaps = new List<SacInfo>(listRoot);
|
||||
var errMsg = new SacInfo("PerformanceGuaranteeAgrmt", i)
|
||||
{
|
||||
FieldValue = item.MasterAgrmtNo,
|
||||
SubMaps = new List<SacInfo>(listRoot)
|
||||
};
|
||||
result.Add(errMsg);
|
||||
}
|
||||
}
|
||||
@@ -391,7 +297,7 @@ namespace YLErp.Modules.SuperviseReportModule.SAC.Service
|
||||
};
|
||||
|
||||
}
|
||||
for (int i = 0; i < noteList.Count; i++)
|
||||
for (var i = 0; i < noteList.Count; i++)
|
||||
{
|
||||
base.SaveReportNotes(noteList[i]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user