diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/SettleAccounts/SettleAccountRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/SettleAccounts/SettleAccountRepository.cs index 5af42774..5f7f141f 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/SettleAccounts/SettleAccountRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/SettleAccounts/SettleAccountRepository.cs @@ -106,24 +106,24 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccount try { DbContext.Database.SetCommandTimeout(1200); - List _insertls = new List(); - if (list.Count > 0) - { - var _version = list.FirstOrDefault().Version; - var _ls= GetQueryable().Where(p => p.Version == _version).Select(p=>new { MaterialCode=p.MaterialCode, ChassisNumber=p.ChassisNumber }).ToList(); - var _query = from r1 in list join r2 in _ls on new { r1.ChassisNumber, r1.MaterialCode } equals new { r2.ChassisNumber, r2.MaterialCode } - into temp from t in temp.DefaultIfEmpty() - where t==null - select r1 ; - foreach (var s in _query.ToList()) - { - _insertls.Add(s); - } - } + //List _insertls = new List(); + //if (list.Count > 0) + //{ + // var _version = list.FirstOrDefault().Version; + // var _ls= GetQueryable().Where(p => p.Version == _version).Select(p=>new { MaterialCode=p.MaterialCode, ChassisNumber=p.ChassisNumber }).ToList(); + // var _query = from r1 in list join r2 in _ls on new { r1.ChassisNumber, r1.MaterialCode } equals new { r2.ChassisNumber, r2.MaterialCode } + // into temp from t in temp.DefaultIfEmpty() + // where t==null + // select r1 ; + // foreach (var s in _query.ToList()) + // { + // _insertls.Add(s); + // } + //} - BulkConfig cfg = new BulkConfig() { BulkCopyTimeout=0, BatchSize=2000}; - DbContext.BulkInsert(_insertls,cfg); + BulkConfig cfg = new BulkConfig() { BulkCopyTimeout=0, BatchSize=100000, }; + DbContext.BulkInsert(list,cfg); } catch (Exception e) { diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/SettleAccount/SettleAccountImportService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/SettleAccount/SettleAccountImportService.cs index e8faaf57..dc7876b4 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/SettleAccount/SettleAccountImportService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/SettleAccount/SettleAccountImportService.cs @@ -59,73 +59,73 @@ namespace TaskJob.Services { var filePath = fileSavePath + itm;//获取到导入的excel var exten = Path.GetExtension(fileSavePath); - List _errorList = new List(); - var checkList = new List(); - //var _chList = await _relrepository.GetAllAsync(GuidGenerator.Create(), true); - //var _chls = _chList.Select(p => p.SettleMaterialCode).Distinct(); - List _precodeList = new List();// - if (exten.ToUpper() == ".TXT") - { - using (TextReader textReader = new StreamReader(filePath)) - { - int i = 0; - while (true) - { - string str = textReader.ReadLine(); - if (string.IsNullOrEmpty(str)) - { - break; - } - else - { - try - { - var _lst = str.Split(new char[] { '|' }).ToList(); - string _settleyear = _lst[1].Trim(); - string _kENNCode = _lst[2].Trim(); - string _chassisNumber = _lst[3].Trim(); - string _model = _lst[4].Trim(); - DateTime _cP5A = DateTime.Parse(_lst[5].Trim()); - DateTime _cP7 = DateTime.Parse(_lst[6].Trim()); - string _materialCode = _lst[7].Trim(); - decimal _qty = decimal.Parse(_lst[8].Trim()); - string _settlementID = _lst[9].Trim(); - string _settlementSupplier = _lst[10].Trim(); - _setls.Add(new Win.Sfs.SettleAccount.Entities.SettleAccounts.SettleAccount( - Guid.NewGuid(), - Guid.NewGuid(), - _settleyear, - _kENNCode, - _chassisNumber, - _model, - _cP5A, - _cP7, - _materialCode, - _qty, - _settlementID, - _settlementSupplier, - DateTime.Now.Year.ToString(), - DateTime.Now.Month.ToString(), - _id, - version, - DateTime.Now, - Guid.NewGuid() - )); - } - catch - { + //List _errorList = new List(); + //var checkList = new List(); + ////var _chList = await _relrepository.GetAllAsync(GuidGenerator.Create(), true); + ////var _chls = _chList.Select(p => p.SettleMaterialCode).Distinct(); + //List _precodeList = new List();// + //if (exten.ToUpper() == ".TXT") + //{ + // using (TextReader textReader = new StreamReader(filePath)) + // { + // int i = 0; + // while (true) + // { + // string str = textReader.ReadLine(); + // if (string.IsNullOrEmpty(str)) + // { + // break; + // } + // else + // { + // try + // { + // var _lst = str.Split(new char[] { '|' }).ToList(); + // string _settleyear = _lst[1].Trim(); + // string _kENNCode = _lst[2].Trim(); + // string _chassisNumber = _lst[3].Trim(); + // string _model = _lst[4].Trim(); + // DateTime _cP5A = DateTime.Parse(_lst[5].Trim()); + // DateTime _cP7 = DateTime.Parse(_lst[6].Trim()); + // string _materialCode = _lst[7].Trim(); + // decimal _qty = decimal.Parse(_lst[8].Trim()); + // string _settlementID = _lst[9].Trim(); + // string _settlementSupplier = _lst[10].Trim(); + // _setls.Add(new Win.Sfs.SettleAccount.Entities.SettleAccounts.SettleAccount( + // Guid.NewGuid(), + // Guid.NewGuid(), + // _settleyear, + // _kENNCode, + // _chassisNumber, + // _model, + // _cP5A, + // _cP7, + // _materialCode, + // _qty, + // _settlementID, + // _settlementSupplier, + // DateTime.Now.Year.ToString(), + // DateTime.Now.Month.ToString(), + // _id, + // version, + // DateTime.Now, + // Guid.NewGuid() + // )); + // } + // catch + // { - } - } - i++; - } - textReader.Close(); - } - } - else - { - // _setls= _inputService.Input(filePath); - var errorlist = new List(); + // } + // } + // i++; + // } + // textReader.Close(); + // } + //} + //else + //{ + // _setls= _inputService.Input(filePath); + var errorlist = new List(); var dtoList = _inputService.Input(filePath, null, errorlist); foreach (var dto in dtoList) { @@ -139,7 +139,7 @@ namespace TaskJob.Services DateTime.Now.Month.ToString(), dto.SettleYear, _id, version, DateTime.Now, Guid.NewGuid()); _setls.Add(_settleaccount); } - } + //} #region //var errorFileName = "错误文件.xlsx"; //checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("ERP物料号{0}底盘号 {1}有重复", "11111111111", "22222222222"), string.Empty));