From a3166135f1621a443efc82eb5b7c79c71a173c3b Mon Sep 17 00:00:00 2001 From: Administrator Date: Tue, 12 Apr 2022 08:43:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/WMS/WMSKanbanAppService.cs | 66 +++--- .../Entities/WMS/WMSKanbanExtendAppService.cs | 195 ++++++++++++++++-- 2 files changed, 213 insertions(+), 48 deletions(-) diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSKanbanAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSKanbanAppService.cs index c3cc8b90..240183e4 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSKanbanAppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSKanbanAppService.cs @@ -594,45 +594,45 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts //[Authorize(SettleAccountPermissions.SettleAccounts.Default)] public async Task ExcelImportWithOutKanban([FromForm] IFormFileCollection files, string version) { - var _billNum = "KA" + DateTime.Now.ToString("yyyyMMddhhmmss"); + //var _billNum = "KA" + DateTime.Now.ToString("yyyyMMddhhmmss"); - var _list= _dapper.GetNoKanbanSettleDetail(version); + //var _list= _dapper.GetNoKanbanSettleDetail(version); - var stockList = _wmsDapper.GetSalesStock(); - var query = from itm in _list - join itm1 in stockList on itm.MaterialCode equals itm1.SapCode - into temp1 - from tm1 in temp1.DefaultIfEmpty() - select new WmsWithOutKanbanOutPutDetial( - GuidGenerator.Create(), - "无看板", - itm.SapMaterialCode, - itm.MaterialDesc, - itm.Version, - string.Empty, - string.Empty, - itm.Qty, - tm1.Qty, - itm.Qty, - string.Empty, - _billNum, - 0, - 0, - itm.InvoicePrice - ,itm.InvoiceAmt - ); + //var stockList = _wmsDapper.GetSalesStock(); + //var query = from itm in _list + // join itm1 in stockList on itm.MaterialCode equals itm1.SapCode + //into temp1 + // from tm1 in temp1.DefaultIfEmpty() + // select new WmsWithOutKanbanOutPutDetial( + // GuidGenerator.Create(), + // "无看板", + // itm.SapMaterialCode, + // itm.MaterialDesc, + // itm.Version, + // string.Empty, + // string.Empty, + // itm.Qty, + // tm1.Qty, + // itm.Qty, + // string.Empty, + // _billNum, + // 0, + // 0, + // itm.InvoicePrice + // ,itm.InvoiceAmt + // ); - await _wmsRepository.GetDbContext().BulkInsertAsync(query.ToList(), new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 }); - int _count = _wmsVersionRepository.Count(p => p.Version == version && p.BillNum == _billNum); - if (_count == 0) - { - var _version = new WmsKanbanOutPut(GuidGenerator.Create(), version, _billNum, CurrentUser.Email); - await _wmsVersionRepository.InsertAsync(_version, true); - } + //await _wmsRepository.GetDbContext().BulkInsertAsync(query.ToList(), new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 }); + //int _count = _wmsVersionRepository.Count(p => p.Version == version && p.BillNum == _billNum); + //if (_count == 0) + //{ + // var _version = new WmsWithOutKanbanOutPut(GuidGenerator.Create(), version, _billNum, CurrentUser.Email); + // await _wmsVersionRepository.InsertAsync(_version, true); + //} @@ -732,7 +732,7 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts // var _version = new WmsKanbanOutPut(GuidGenerator.Create(), version, _billNum, CurrentUser.Email); // await _wmsVersionRepository.InsertAsync(_version, true); //} - return _billNum; + //return _billNum; diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSKanbanExtendAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSKanbanExtendAppService.cs index 077f4793..736c3c88 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSKanbanExtendAppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSKanbanExtendAppService.cs @@ -234,6 +234,186 @@ namespace Win.Sfs.SettleAccount.Entities.WMS + [HttpPost] + [Route("ExcelImportWithOutKanban")] + [DisableRequestSizeLimit] + //[Authorize(SettleAccountPermissions.SettleAccounts.Default)] + public async Task ExcelImportWithOutKanban([FromForm] IFormFileCollection files, string version) + { + var _billNum = "KA" + DateTime.Now.ToString("yyyyMMddhhmmss"); + + + + //var _list = _dapper.GetNoKanbanSettleDetail(version); + + + //var stockList = _wmsDapper.GetSalesStock(); + //var query = from itm in _list + // join itm1 in stockList on itm.MaterialCode equals itm1.SapCode + //into temp1 + // from tm1 in temp1.DefaultIfEmpty() + // select new WmsWithOutKanbanOutPutDetial( + // GuidGenerator.Create(), + // "无看板", + // itm.SapMaterialCode, + // itm.MaterialDesc, + // itm.Version, + // string.Empty, + // string.Empty, + // itm.Qty, + // tm1.Qty, + // itm.Qty, + // string.Empty, + // _billNum, + // 0, + // 0, + // itm.InvoicePrice + // , itm.InvoiceAmt + // ); + + + //await _wmsRepository.GetDbContext().BulkInsertAsync(query.ToList(), new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 }); + //int _count = _wmsVersionRepository.Count(p => p.Version == version && p.BillNum == _billNum); + //if (_count == 0) + //{ + // var _version = new WmsWithOutKanbanOutPut(GuidGenerator.Create(), version, _billNum, CurrentUser.Email); + // await _wmsVersionRepository.InsertAsync(_version, true); + //} + + + + //return _billNum; + + + + + + + + //var _lsCopy = new List(); + //foreach (var itm in query.ToList()) + //{ + + + // WmsWithOutKanbanOutPutDetial _detail = new WmsWithOutKanbanOutPutDetial( + // GuidGenerator.Create(), + // "无看板", + // itm.SapMaterialCode, + // itm.MaterialDesc, + // itm.Version, + // string.Empty, + // string.Empty, + // itm.Qty, + // 0, + // itm.Qty, + // string.Empty, + // _billNum, + // 0, + // itm. + + // ); + // _lsCopy.Add(_detail); + //} + //_lst.AddRange(_lsCopy.ToArray()); + ExportImporter _exportImporter = new ExportImporter(); + var result = await _exportImporter.ExtendExcelImport(files, _excelImportService); + List _lst = new List(); + var _lsCopy = new List(); + foreach (var itm in result) + { + WmsWithOutKanbanOutPutDetial _detail = new WmsWithOutKanbanOutPutDetial( + GuidGenerator.Create(), + !string.IsNullOrEmpty(itm.Type) ? itm.Type : string.Empty, + itm.SapMaterialCode, + itm.MaterialDesc, + itm.Version, + itm.IsBack, + itm.Remark, + itm.Qty, + itm.SockQty, + itm.OutputQty, + itm.Extend, + itm.BillNum,0 + ,0, + itm.Price, + itm.Amt + ); + _lsCopy.Add(_detail); + } + _lst.AddRange(_lsCopy.ToArray()); + + + var outPutDetail = await _wmsRepository.Where(p => p.Version == version && p.State!=4).ToListAsync(); + + + var error = from itm1 in outPutDetail + join itm2 in _lst on + new { itm1.SapMaterialCode } + equals + new { itm2.SapMaterialCode } + select itm1; + var errList = error.GroupBy(p => new { p.BillNum }).Select(p => new { BillNum = p.Key.BillNum, Number = p.Sum(itm => itm.Qty) }); + + var checkList = new List(); + foreach (var itm in errList) + { + checkList.Add(new ErrorExportDto() { Message = string.Format("出库单号:{0}重复记录数:{1}条", itm.BillNum, itm.Number) }); + } + if (checkList.Count > 0) + { + + return await ExportErrorReportAsync(checkList); + } + + + + var query = from itm1 in _lst + join itm2 in outPutDetail on + new { itm1.SapMaterialCode } + equals + new { itm2.SapMaterialCode } into temp1 + from tm1 in temp1.DefaultIfEmpty() + where tm1 == null + select itm1; + var _wmslst = query.ToList(); + foreach (var itm in _wmslst) + { + itm.BillNum = _billNum; + } + await _wmsRepository.GetDbContext().BulkInsertAsync(_wmslst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 }); + int _count = _wmsVersionRepository.Count(p => p.Version == version && p.BillNum == _billNum); + if (_count == 0) + { + var _version = new WmsWithOutKanbanOutPut(GuidGenerator.Create(), version, _billNum, CurrentUser.Email); + await _wmsVersionRepository.InsertAsync(_version, true); + } + return _billNum; + + + + + + + + + + + + + + + + + + + + + + } + + + + /// /// 选择任务,生成出库单,只包含已确认的单据 /// @@ -459,22 +639,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS } ); return _fileName; - - - } - - - - - // 物料 物料组 物料描述 物料号 开始日期 结束日期 单位 出库数量 结算数量 寄售库存数量 - - - - - - - }