From e90f2d9fc27797bfee46ada7e7ecb4cba2ce1adc Mon Sep 17 00:00:00 2001 From: hjhan Date: Sat, 22 Aug 2026 07:38:08 +0800 Subject: [PATCH] =?UTF-8?q?chore(swap):=20=E5=88=A0=E9=99=A4dbf=E6=97=A7?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=AD=BB=E7=B0=87=E4=B8=8EHTStatus=E6=AD=BB?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E2=80=94=E2=80=94SwapFlowImportService?= =?UTF-8?q?=E6=95=B4=E6=9D=A1zip/dbf=E9=93=BE+TradeBase.HTStatus?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ImportSwapTradesFromZip标记[Obsolete]且全仓零调用,其私有依赖链GetDbfFiles→GetDbfDatas→GetSwapFlowData_SZ/_SH→ConvertDateTime仅被它触达,连同DotNetDBF/SharpZipLib两个using一并删除;Excel导入路径(ImportSwapTradesFromExcel)不受影响。TradeBase.HTStatus全仓无读无写,属性删除后EF不再映射该列(数据库列残留留给DBA评估)。 dotnet build 0错误 --- Framework/YLErp.Core/DBModels/TradeBase.cs | 4 - .../SwapModule/SwapFlowImportService.cs | 199 +----------------- 2 files changed, 1 insertion(+), 202 deletions(-) diff --git a/Framework/YLErp.Core/DBModels/TradeBase.cs b/Framework/YLErp.Core/DBModels/TradeBase.cs index aa57a276..7aee59a2 100644 --- a/Framework/YLErp.Core/DBModels/TradeBase.cs +++ b/Framework/YLErp.Core/DBModels/TradeBase.cs @@ -809,10 +809,6 @@ namespace YLErp.DBModels [DisplayName("是否走审批")] public bool? IsAutoGenerate { get; set; } /// - /// 衡泰交易状态 - /// - public int? HTStatus { get; set; } - /// /// 用来标记该交易在修改时是否应提示操作人员注意 /// [NotMapped] diff --git a/YLErpDAL/Modules/SwapModule/SwapFlowImportService.cs b/YLErpDAL/Modules/SwapModule/SwapFlowImportService.cs index 3ee3e891..3bea5b09 100644 --- a/YLErpDAL/Modules/SwapModule/SwapFlowImportService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapFlowImportService.cs @@ -1,6 +1,4 @@ -using DotNetDBF; -using ICSharpCode.SharpZipLib.Zip; -using System; +using System; using System.Collections.Generic; using System.Data; using System.IO; @@ -29,32 +27,6 @@ namespace YLErp.Modules.SwapModule public SwapFlowImportService(YLBaseService baseService) : base(baseService) { - } - /// - /// 成交流水导入 dbf - /// - /// 压缩包文件路径 - /// 压缩包解压路径 - /// 总条数 - /// 成功条数 - [Obsolete] - public void ImportSwapTradesFromZip(string filePath, string fileDir, out int totalNum, out int successNum) - { - totalNum = 0; - successNum = 0; - var fileDirPath = ZipHelper.unZipFile(filePath, fileDir, out var msg); - var dbfFiles = GetDbfFiles(fileDirPath); - var swapFlowList = GetDbfDatas(dbfFiles); - if (swapFlowList.Count > 0) - { - DbContext.swap_flow.AddRange(swapFlowList); - DbContext.SaveChanges(); - new SysJobService(UserInfo).UpdateJob("互换流水合成持仓", 11, "互换流水导入完成"); - Task.Run(() => - { - RealtimePnlCalc.RealtimeSwapPosition(new OptUserInfo(0, "互换实时持仓服务", OptUserFrom.Service)); - }); - } } /// /// 成交流水导入 excel @@ -170,174 +142,5 @@ namespace YLErp.Modules.SwapModule throw new ServiceException($"第{rowIndex}行,发生错误:{ex.Message}", ex); } } - /// - /// 获取解压路径下所有符合的dbf文件 - /// - /// - /// - private List GetDbfFiles(string filePath) - { - List files = new List(); - var allFiles = Directory.GetFiles(filePath, ".", SearchOption.AllDirectories); - foreach (var file in allFiles) - { - FileInfo _file = new FileInfo(file); - var fileName = _file.Name.ToLower(); - //SZ:SJSMX20518.DBF SH:jsmx03_jsx73.518 - if ((fileName.StartsWith("sjsmx") && fileName.Contains(".dbf")) || fileName.StartsWith("jsmx")) - { - files.Add(file); - } - } - return files; - } - /// - /// dbf文件中获取流水数据 - /// - /// - /// - private List GetDbfDatas(List files) - { - List swap_Flows = new List(); - for (var i = 0; i < files.Count; i++) - { - using (var dbf = new DBFReader(files[i])) - { - var columnCount = dbf.Fields.Length; - if (columnCount != 48) - { - continue; - } - bool dbffile = dbf.Fields[0].Name == "MXJSZH"; - var swapflows = new List(); - if (dbffile)//SZ - { - swapflows = GetSwapFlowData_SZ(dbf); - } - else //SH - { - swapflows = GetSwapFlowData_SH(dbf); - } - swap_Flows.AddRange(swapflows); - } - } - return swap_Flows; - } - /// - /// 获取SZ流水数据 - /// - /// - /// - private List GetSwapFlowData_SZ(DBFReader dbf) - { - List swap_Flows = new List(); - var count = dbf.RecordCount; - for (var j = 0; j < count; j++) - { - var dbfRecord = dbf.NextRecord(); - if (dbfRecord != null) - { - string MXZQLB = dbfRecord[18].ToString().Trim();//证券类别 - if (MXZQLB != "00")//A股 - { - continue; - } - decimal.TryParse(dbfRecord[12].ToString().Trim(), out decimal tradingQty);//成交数量(MXCJSL) - decimal.TryParse(dbfRecord[23].ToString().Trim(), out decimal tradingAmount);//清算本金(MXQSBJ) - decimal.TryParse(dbfRecord[33].ToString().Trim(), out decimal tradingFee);//收付净额(MXSXF) - var underlyingCode = dbfRecord[4].ToString().Trim() + ".SZ";// 证券代码(MXSFJE) - var date = dbfRecord[34].ToString().Trim();//成交日期MXCJRQ - var bstype = dbfRecord[17].ToString().Trim();//平仓标识(MXPCBS) - var bsType = 0; - if (bstype == "2" || bstype == "3")//2平仓 3强制平仓 - { - bsType = 2; - } - else if (bstype == "1")//开仓 - { - bsType = 1; - } - var tradeDate = ConvertDateTime(date); - swap_Flows.Add(new swap_flow() - { - FundAccount = dbfRecord[7].ToString().Trim(),//证券账户号码(MXZQZH) - OccurTime = tradeDate, - UnderlyingCode = underlyingCode, - BsType = bsType, - TradingQty = tradingQty, - TradingAmount = tradingAmount, - TradingFee = tradingFee - tradingAmount,//收付净额-清算本金 - DataState = 1 - }); - } - } - return swap_Flows; - } - /// - /// 获取SH流水数据 - /// - /// - /// - private List GetSwapFlowData_SH(DBFReader dbf) - { - List swap_Flows = new List(); - var count = dbf.RecordCount; - for (var j = 0; j < count; j++) - { - var dbfRecord = dbf.NextRecord(); - if (dbfRecord != null) - { - string SCDM = dbfRecord[0].ToString().Trim();//市场代码 - if (SCDM != "01")//A股 - { - continue; - } - var bstype = dbfRecord[29].ToString().Trim();//买卖标识(MMBZ) - decimal.TryParse(dbfRecord[31].ToString().Trim(), out decimal tradingQty);//成交数量(CJSL) - decimal.TryParse(dbfRecord[36].ToString().Trim(), out decimal tradingAmount);//清算金额(QSJE) - decimal.TryParse(dbfRecord[45].ToString().Trim(), out decimal tradingPay);//实际收付(SJSF) - var underlyingCode = dbfRecord[23].ToString().Trim() + ".SH";// 证券代码1(ZQDM1) - var date = dbfRecord[11].ToString().Trim();//交易日期(JYRQ) - var tradeDate = ConvertDateTime(date); - var bsType = 0; - if (bstype == "B") - { - bsType = 1; - } - else if (bstype == "S") - { - bsType = 2; - } - swap_Flows.Add(new swap_flow() - { - FundAccount = dbfRecord[32].ToString().Trim(),//资金账号(ZJZH) - OccurTime = tradeDate, - UnderlyingCode = underlyingCode, - BsType = bsType, - TradingQty = tradingQty, - TradingAmount = tradingAmount, - TradingFee = tradingPay - tradingAmount, - DataState = 1 - }); - } - } - return swap_Flows; - } - - - /// - /// 6位字符串日期转换 - /// - /// - /// - private DateTime? ConvertDateTime(string date) - { - if (date.Length != 8) - { - return null; - } - DateTime.TryParse(date.Substring(0, 4) + "-" + date.Substring(4, 2) + "-" + date.Substring(6), out DateTime tradeDate); - return tradeDate; - } } }