From da47daad2224b1d1cf61ab56a4e65fe93bf14093 Mon Sep 17 00:00:00 2001 From: 44673626 <44673626@qq.com> Date: Wed, 16 Feb 2022 18:08:53 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A4=A7=E4=BC=97=E5=A4=87=E4=BB=B6?= =?UTF-8?q?=E8=BE=93=E5=87=BA=EF=BC=88=E5=B8=A6=E9=87=87=E8=B4=AD=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=8F=B7=E5=92=8C=E4=B8=8D=E5=B8=A6=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=8F=B7=EF=BC=89=E7=9A=84=E6=94=B9=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/WMS/WMSSharePart90AppService.cs | 6 + .../Entities/WMS/WMSSharePartAppService.cs | 996 ++++++++++++++---- .../SettleAccount.Application.xml | 8 + .../SettleSparePartDapperReportRepository.cs | 4 +- 4 files changed, 819 insertions(+), 195 deletions(-) diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePart90AppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePart90AppService.cs index 60abb997..b6809a65 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePart90AppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePart90AppService.cs @@ -242,6 +242,11 @@ namespace Win.Sfs.SettleAccount.Entities.WMS string fileSavePath = Environment.CurrentDirectory + @"\wwwroot\files\host\my-file-container\" + filename; ExcelHelper _excelHelper = new ExcelHelper(fileSavePath); var _list = _excelHelper.ExcelToList(); + + //var _list_withbillNo = _list.Select(p => p.BillNum != string.Empty); + //var _list_withNoBillNo= _list.Select(p => p.BillNum == string.Empty); + + if (_list.Count() > 0) { var _lsAry = _list.Select(p => new @@ -459,6 +464,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS } + [HttpPost] [Route("ExcelImport")] [DisableRequestSizeLimit] diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePartAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePartAppService.cs index d0642581..631c1f0b 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePartAppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePartAppService.cs @@ -216,28 +216,45 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts } return false; } - /// - /// 选择任务,生成出库单,只包含已确认的单据 - /// - /// - /// - /// + + + + + + + /// + /// 选择任务,生成出库单,只包含已确认的单据 + /// + /// + /// + /// [HttpPost] [Route("WmsSharePartOutPut")] public async Task WmsSharePartOutPut(WmsJitRequestDto input) { var _billNum = "B" + DateTime.Now.ToString("yyyyMMddhhmmss"); + var _billNoNum = "BNoBill" + DateTime.Now.ToString("yyyyMMddhhmmss"); var _joblist = _job.Where(p => input.Guids.Contains(p.Id) && p.FileName == "已确认").ToList(); if (_joblist.Count() > 0) { var fileList = _joblist.Select(p => p.RealDownFileName).ToList(); List _lst = new List(); + List _lstBill = new List(); foreach (var filename in fileList) { string fileSavePath = Environment.CurrentDirectory + @"\wwwroot\files\host\my-file-container\" + filename; ExcelHelper _excelHelper = new ExcelHelper(fileSavePath); - var _list = _excelHelper.ExcelToList(); - if (_list.Count() > 0) + var _listSummary = _excelHelper.ExcelToList(); + + var _list = _listSummary.Where(p => p.OrderBillNum == "").ToList();//过滤 采购订单号为空的集合 + var _listBill = _listSummary.Where(p => p.OrderBillNum != "").ToList();//过滤 采购订单号不为空的集合 + + + + + //var _list = _excelHelper.ExcelToList(); + //没有 采购订单号 + if (_list != null && _list.Count > 0) { var _lsAry = _list.Select(p => new WmsSharePartOutPutDetial( @@ -251,11 +268,11 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts string.Empty, 0, !string.IsNullOrEmpty(p.Extend1) ? p.Extend1 : string.Empty, - + string.Empty, string.Empty, p.MaterialCode, - _billNum, + _billNoNum, GuidGenerator.Create(), string.Empty, p.Qty, @@ -266,88 +283,219 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts )); _lst.AddRange(_list.ToArray()); } - } - - var outPutDetail = await _wmsRepository.Where(p => p.Version == input.Version).ToListAsync(); - var error = from itm1 in outPutDetail - join itm2 in _lst on - new { itm1.MaterialCode, itm1.OrderBillNum,itm1.WmsBillNum } - equals - new { itm2.MaterialCode, itm2.OrderBillNum,itm2.WmsBillNum } - select itm1; + if (_listBill != null && _listBill.Count() > 0) + { + var _lsAry = _listBill.Select(p => new + WmsSharePartOutPutDetial( + GuidGenerator.Create(), + p.WmsBillNum, + p.OrderBillNum, + p.MaterialCode, + p.MaterialDesc, + p.MaterialGroup, + string.Empty, + string.Empty, + 0, + !string.IsNullOrEmpty(p.Extend1) ? p.Extend1 : string.Empty, - var errList = error.GroupBy(p => new { p.BillNum }).Select(p => new { BillNum = p.Key.BillNum, Number = p.Sum(itm => itm.Qty) }); - if (errList.Count() == 0) - { - var query = from itm1 in _lst - join itm2 in outPutDetail on - new { itm1.MaterialCode, itm1.OrderBillNum, itm1.WmsBillNum } - equals - new { itm2.MaterialCode, itm2.OrderBillNum, itm2.WmsBillNum } into temp1 - from tm1 in temp1.DefaultIfEmpty() - where tm1 == null - select itm1; - var _wmslst = query.ToList(); - _wmslst= _wmslst.Select(p => new - WmsSharePartOutPutDetial( - GuidGenerator.Create(), - string.Empty, - string.Empty, - p.MaterialCode, - p.MaterialDesc, - p.MaterialGroup, - string.Empty, - string.Empty, - 0, - !string.IsNullOrEmpty(p.Extend1) ? p.Extend1 : string.Empty, - string.Empty, - input.Version, - p.MaterialCode, - _billNum, - GuidGenerator.Create(), - string.Empty, - p.Qty, + string.Empty, + string.Empty, + p.MaterialCode, + _billNum, + GuidGenerator.Create(), + string.Empty, + p.Qty, p.StockQty, p.Qty, p.Price, p.Amt - )).ToList(); - await _wmsRepository.GetDbContext().BulkInsertAsync(_wmslst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 }); - int _count = _wmsVersionRepository.Count(p => p.Version == input.Version && p.BillNum == _billNum); - if (_wmslst.Count()>0 && _count == 0) + )); + _lstBill.AddRange(_listBill.ToArray()); + } + } + + + if (_lst != null) + { + //没有采购订单号 + var outPutDetail = await _wmsRepository.Where(p => p.Version == input.Version && p.OrderBillNum == "").ToListAsync(); + + var error = from itm1 in outPutDetail + join itm2 in _lst on + new { itm1.MaterialCode } + equals + new { itm2.MaterialCode } + select itm1; + + var errList = error.GroupBy(p => new { p.BillNum }).Select(p => new { BillNum = p.Key.BillNum, Number = p.Sum(itm => itm.Qty) }); + if (errList.Count() == 0) { - var _version = new WmsSharePartOutPut(GuidGenerator.Create(), input.Version, _billNum, CurrentUser.Email); - await _wmsVersionRepository.InsertAsync(_version, true); + var query = from itm1 in _lst + join itm2 in outPutDetail on + new { itm1.MaterialCode } + equals + new { itm2.MaterialCode } into temp1 + from tm1 in temp1.DefaultIfEmpty() + where tm1 == null + select itm1; + var _wmslst = query.ToList(); + _wmslst = _wmslst.Select(p => new + WmsSharePartOutPutDetial( + GuidGenerator.Create(), + string.Empty, + string.Empty, + p.MaterialCode, + p.MaterialDesc, + p.MaterialGroup, + string.Empty, + string.Empty, + 0, + !string.IsNullOrEmpty(p.Extend1) ? p.Extend1 : string.Empty, + string.Empty, + input.Version, + p.MaterialCode, + _billNoNum, + GuidGenerator.Create(), + string.Empty, + p.Qty, + p.StockQty, + p.Qty, + p.Price, + p.Amt + )).ToList(); + await _wmsRepository.GetDbContext().BulkInsertAsync(_wmslst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 }); + int _count = _wmsVersionRepository.Count(p => p.Version == input.Version && p.BillNum == _billNoNum); + if (_wmslst.Count() > 0 && _count == 0) + { + var _version = new WmsSharePartOutPut(GuidGenerator.Create(), input.Version, _billNoNum, CurrentUser.Email); + await _wmsVersionRepository.InsertAsync(_version, true); + } + foreach (var job in _joblist) + { + job.FileName = _billNoNum; + await _job.UpdateAsync(job); + } } - foreach (var job in _joblist) + else { - job.FileName = _billNum; - await _job.UpdateAsync(job); + StringBuilder _buffer = new StringBuilder(); + foreach (var itm in errList) + { + _buffer.AppendFormat("出库单号:{0}重复记录数:{1}条", itm.BillNum, itm.Number); + } + var _errinfo = _buffer.ToString(); + + foreach (var job in _joblist) + { + job.FileName = _errinfo; + await _job.UpdateAsync(job); + } } } - else + + + + + if (_lstBill != null) { - StringBuilder _buffer = new StringBuilder(); - foreach (var itm in errList) + //有采购订单号 + var outPutDetailBill = await _wmsRepository.Where(p => p.Version == input.Version && p.OrderBillNum != "").ToListAsync(); + + var error = from itm1 in outPutDetailBill + join itm2 in _lstBill on + new { itm1.MaterialCode, itm1.OrderBillNum } + equals + new { itm2.MaterialCode, itm2.OrderBillNum } + select itm1; + + var errList = error.GroupBy(p => new { p.BillNum }).Select(p => new { BillNum = p.Key.BillNum, Number = p.Sum(itm => itm.Qty) }); + if (errList.Count() == 0) { - _buffer.AppendFormat("出库单号:{0}重复记录数:{1}条", itm.BillNum, itm.Number); - } - var _errinfo = _buffer.ToString(); + var queryBill = from itm1 in _lstBill + join itm2 in outPutDetailBill on + new { itm1.MaterialCode, itm1.OrderBillNum } + equals + new { itm2.MaterialCode, itm2.OrderBillNum } into temp1 + from tm1 in temp1.DefaultIfEmpty() + where tm1 == null + select itm1; + var _wmslstBill = queryBill.ToList(); + _wmslstBill = _wmslstBill.Select(p => new + WmsSharePartOutPutDetial( + GuidGenerator.Create(), + p.WmsBillNum, + p.OrderBillNum, + p.MaterialCode, + p.MaterialDesc, + p.MaterialGroup, + string.Empty, + string.Empty, + 0, + !string.IsNullOrEmpty(p.Extend1) ? p.Extend1 : string.Empty, + string.Empty, + input.Version, + p.MaterialCode, + _billNum, + GuidGenerator.Create(), + string.Empty, + p.Qty, + p.StockQty, + p.Qty, + p.Price, + p.Amt + )).ToList(); - foreach (var job in _joblist) + await _wmsRepository.GetDbContext().BulkInsertAsync(_wmslstBill, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 }); + int _count = _wmsVersionRepository.Count(p => p.Version == input.Version && p.BillNum == _billNum); + if (_wmslstBill.Count() > 0 && _count == 0) + { + var _version = new WmsSharePartOutPut(GuidGenerator.Create(), input.Version, _billNum, CurrentUser.Email); + await _wmsVersionRepository.InsertAsync(_version, true); + } + foreach (var job in _joblist) + { + if (_lst != null) + { + job.FileName = _billNum + "/" + _billNoNum; + } + else + { + job.FileName = _billNum; + } + + await _job.UpdateAsync(job); + } + } + else { - job.FileName = _errinfo; - await _job.UpdateAsync(job); + StringBuilder _buffer = new StringBuilder(); + foreach (var itm in errList) + { + _buffer.AppendFormat("出库单号:{0}重复记录数:{1}条", itm.BillNum, itm.Number); + } + var _errinfo = _buffer.ToString(); + + foreach (var job in _joblist) + { + job.FileName = _errinfo; + await _job.UpdateAsync(job); + } } } + + } else { _billNum = string.Empty; + _billNoNum = string.Empty; } return ApplicationConsts.SuccessStr; } + + + /// /// 出库界面功能,核准出库功能 /// @@ -359,34 +507,246 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts [UnitOfWork(false)] public async Task WmsSharePartOutPutPass(WmsJitRequestDto input) { - if (input.Guids != null) + if (input.BillNum.Contains("NoBill")) { - List _ls = new List(); - if (input.Guids.Count() > 0) - { - _ls = await _wmsRepository.Where(p => input.Guids.Contains(p.Id) && p.Version == input.Version && p.BillNum == input.BillNum && p.State != 2).ToListAsync(); - } - else + //没有采购订单号的出库方式 + if (input.Guids != null) { - _ls = await _wmsRepository.Where(p => p.Version == input.Version && p.BillNum == input.BillNum && p.State != 2).ToListAsync(); + List _ls = new List(); + if (input.Guids.Count() > 0) + { + _ls = await _wmsRepository.Where(p => input.Guids.Contains(p.Id) && p.Version == input.Version && p.BillNum == input.BillNum && p.State != 2).ToListAsync(); + } + else + { + _ls = await _wmsRepository.Where(p => p.Version == input.Version && p.BillNum == input.BillNum && p.State != 2).ToListAsync(); + } + if (_ls.Count() > 0) + { + var sql = "DECLARE @return_value int\n" + + "EXEC @return_value = [dbo].[p_wms_output]\n" + + " @billnum = N'{0}',\n" + + " @type = 2,\n" + + " @date = N'{1}'\n" + + "SELECT 'Return Value' = @return_value"; + await _wmsRepository.GetDbContext().Database.ExecuteSqlRawAsync( + string.Format(sql, input.BillNum, input.AccountDate.ToShortDateString())); + + } } - if (_ls.Count() > 0) + } + else + { + //有采购订单号的出库方式 + if (input.Guids != null) { - var sql = "DECLARE @return_value int\n" + - "EXEC @return_value = [dbo].[p_wms_output]\n" + - " @billnum = N'{0}',\n" + - " @type = 2,\n" + - " @date = N'{1}'\n" + - "SELECT 'Return Value' = @return_value"; - await _wmsRepository.GetDbContext().Database.ExecuteSqlRawAsync( - string.Format(sql, input.BillNum,input.AccountDate.ToShortDateString())); - + List _ls = new List(); + if (input.Guids.Count() > 0) + { + _ls = await _wmsRepository.Where(p => input.Guids.Contains(p.Id) && p.Version == input.Version && p.BillNum == input.BillNum && p.State != 2).ToListAsync(); + } + else + { + _ls = await _wmsRepository.Where(p => p.Version == input.Version && p.BillNum == input.BillNum && p.State != 2).ToListAsync(); + } + if (_ls.Count() > 0) + { + var sql = "DECLARE @return_value int\n" + + "EXEC @return_value = [dbo].[p_wms_output]\n" + + " @billnum = N'{0}',\n" + + " @type = 10,\n" + + " @date = N'{1}'\n" + + "SELECT 'Return Value' = @return_value"; + await _wmsRepository.GetDbContext().Database.ExecuteSqlRawAsync( + string.Format(sql, input.BillNum, input.AccountDate.ToShortDateString())); + + } } } return true; } + + + /// + /// 选择任务,生成出库单,只包含已确认的单据 + /// + /// + /// + /// + //[HttpPost] + //[Route("WmsSharePartOutPut")] + //public async Task WmsSharePartOutPut(WmsJitRequestDto input) + //{ + // var _billNum = "B" + DateTime.Now.ToString("yyyyMMddhhmmss"); + // var _joblist = _job.Where(p => input.Guids.Contains(p.Id) && p.FileName == "已确认").ToList(); + // if (_joblist.Count() > 0) + // { + // var fileList = _joblist.Select(p => p.RealDownFileName).ToList(); + // List _lst = new List(); + // foreach (var filename in fileList) + // { + // string fileSavePath = Environment.CurrentDirectory + @"\wwwroot\files\host\my-file-container\" + filename; + // ExcelHelper _excelHelper = new ExcelHelper(fileSavePath); + // var _list = _excelHelper.ExcelToList(); + // if (_list.Count() > 0) + // { + // var _lsAry = _list.Select(p => new + // WmsSharePartOutPutDetial( + // GuidGenerator.Create(), + // string.Empty, + // string.Empty, + // p.MaterialCode, + // p.MaterialDesc, + // p.MaterialGroup, + // string.Empty, + // string.Empty, + // 0, + // !string.IsNullOrEmpty(p.Extend1) ? p.Extend1 : string.Empty, + + // string.Empty, + // string.Empty, + // p.MaterialCode, + // _billNum, + // GuidGenerator.Create(), + // string.Empty, + // p.Qty, + // p.StockQty, + // p.Qty, + // p.Price, + // p.Amt + // )); + // _lst.AddRange(_list.ToArray()); + // } + // } + + // var outPutDetail = await _wmsRepository.Where(p => p.Version == input.Version).ToListAsync(); + + // var error = from itm1 in outPutDetail + // join itm2 in _lst on + // new { itm1.MaterialCode, itm1.OrderBillNum, itm1.WmsBillNum } + // equals + // new { itm2.MaterialCode, itm2.OrderBillNum, itm2.WmsBillNum } + // select itm1; + + // var errList = error.GroupBy(p => new { p.BillNum }).Select(p => new { BillNum = p.Key.BillNum, Number = p.Sum(itm => itm.Qty) }); + // if (errList.Count() == 0) + // { + // var query = from itm1 in _lst + // join itm2 in outPutDetail on + // new { itm1.MaterialCode, itm1.OrderBillNum, itm1.WmsBillNum } + // equals + // new { itm2.MaterialCode, itm2.OrderBillNum, itm2.WmsBillNum } into temp1 + // from tm1 in temp1.DefaultIfEmpty() + // where tm1 == null + // select itm1; + // var _wmslst = query.ToList(); + // _wmslst = _wmslst.Select(p => new + // WmsSharePartOutPutDetial( + // GuidGenerator.Create(), + // string.Empty, + // string.Empty, + // p.MaterialCode, + // p.MaterialDesc, + // p.MaterialGroup, + // string.Empty, + // string.Empty, + // 0, + // !string.IsNullOrEmpty(p.Extend1) ? p.Extend1 : string.Empty, + // string.Empty, + // input.Version, + // p.MaterialCode, + // _billNum, + // GuidGenerator.Create(), + // string.Empty, + // p.Qty, + // p.StockQty, + // p.Qty, + // p.Price, + // p.Amt + // )).ToList(); + // await _wmsRepository.GetDbContext().BulkInsertAsync(_wmslst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 }); + // int _count = _wmsVersionRepository.Count(p => p.Version == input.Version && p.BillNum == _billNum); + // if (_wmslst.Count() > 0 && _count == 0) + // { + // var _version = new WmsSharePartOutPut(GuidGenerator.Create(), input.Version, _billNum, CurrentUser.Email); + // await _wmsVersionRepository.InsertAsync(_version, true); + // } + // foreach (var job in _joblist) + // { + // job.FileName = _billNum; + // await _job.UpdateAsync(job); + // } + // } + // else + // { + // StringBuilder _buffer = new StringBuilder(); + // foreach (var itm in errList) + // { + // _buffer.AppendFormat("出库单号:{0}重复记录数:{1}条", itm.BillNum, itm.Number); + // } + // var _errinfo = _buffer.ToString(); + + // foreach (var job in _joblist) + // { + // job.FileName = _errinfo; + // await _job.UpdateAsync(job); + // } + // } + // } + // else + // { + // _billNum = string.Empty; + // } + // return ApplicationConsts.SuccessStr; + //} + + + + + + + + ///// + ///// 出库界面功能,核准出库功能 + ///// + ///// + ///// + ///// + //[HttpPost] + //[Route("WmsSharePartOutPut-Pass")] + //[UnitOfWork(false)] + //public async Task WmsSharePartOutPutPass(WmsJitRequestDto input) + //{ + // if (input.Guids != null) + // { + // List _ls = new List(); + // if (input.Guids.Count() > 0) + // { + // _ls = await _wmsRepository.Where(p => input.Guids.Contains(p.Id) && p.Version == input.Version && p.BillNum == input.BillNum && p.State != 2).ToListAsync(); + // } + // else + // { + // _ls = await _wmsRepository.Where(p => p.Version == input.Version && p.BillNum == input.BillNum && p.State != 2).ToListAsync(); + // } + // if (_ls.Count() > 0) + // { + // var sql = "DECLARE @return_value int\n" + + // "EXEC @return_value = [dbo].[p_wms_output]\n" + + // " @billnum = N'{0}',\n" + + // " @type = 2,\n" + + // " @date = N'{1}'\n" + + // "SELECT 'Return Value' = @return_value"; + // await _wmsRepository.GetDbContext().Database.ExecuteSqlRawAsync( + // string.Format(sql, input.BillNum,input.AccountDate.ToShortDateString())); + + // } + // } + // return true; + //} + + [HttpPost] [Route("WmsSharePartOutPutModify")] [DisableRequestSizeLimit] @@ -414,31 +774,65 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts [Route("WmsSharePartOutPut-Cancel")] public async Task WmsSharePartOutPutCancel(WmsJitRequestDto input) { - if(input.Guids != null && input.Guids.Count() > 0) + if (input.BillNum.Contains("NoBill")) { - List _ls = new List(); - foreach (var itm in input.Guids) + //没有有采购单据号的单子 + if (input.Guids != null && input.Guids.Count() > 0) { - _ls.Add(string.Format("{0}", itm)); + List _ls = new List(); + foreach (var itm in input.Guids) + { + _ls.Add(string.Format("{0}", itm)); + } + + string str = string.Join(",", _ls.ToArray()); + + var sql = "DECLARE @return_value int\n" + + "EXEC @return_value = [dbo].[p_wms_output_cancel]\n" + + " @Guids ='{0}', \n" + + " @billnum = N'{1}',\n" + + " @type = 2,\n" + + " @accountdate = N'{2}'\n" + + "SELECT 'Return Value' = @return_value"; + + sql = string.Format(sql, str, input.BillNum, input.AccountDate.ToShortDateString()); + + await _wmsRepository.GetDbContext().Database.ExecuteSqlRawAsync( + sql + ); + } + } + else + { + //有采购单据号的单子 + if (input.Guids != null && input.Guids.Count() > 0) + { + List _ls = new List(); + foreach (var itm in input.Guids) + { + _ls.Add(string.Format("{0}", itm)); + } - string str = string.Join(",", _ls.ToArray()); + string str = string.Join(",", _ls.ToArray()); - var sql = "DECLARE @return_value int\n" + - "EXEC @return_value = [dbo].[p_wms_output_cancel]\n" + - " @Guids ='{0}', \n" + - " @billnum = N'{1}',\n" + - " @type = 2,\n" + - " @accountdate = N'{2}'\n" + - "SELECT 'Return Value' = @return_value"; + var sql = "DECLARE @return_value int\n" + + "EXEC @return_value = [dbo].[p_wms_output_cancel]\n" + + " @Guids ='{0}', \n" + + " @billnum = N'{1}',\n" + + " @type = 10,\n" + + " @accountdate = N'{2}'\n" + + "SELECT 'Return Value' = @return_value"; - sql = string.Format(sql, str, input.BillNum, input.AccountDate.ToShortDateString()); + sql = string.Format(sql, str, input.BillNum, input.AccountDate.ToShortDateString()); - await _wmsRepository.GetDbContext().Database.ExecuteSqlRawAsync( - sql - ); + await _wmsRepository.GetDbContext().Database.ExecuteSqlRawAsync( + sql + ); + } } + return true; } @@ -453,20 +847,42 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts [UnitOfWork(false)] public async Task WmsOutPutDelete(WmsJitRequestDto input) { - var count = _wmsRepository.Count(p => p.BillNum == input.BillNum && p.State != 0); + if (input.BillNum.Contains("NoBill")) + { + //没有采购单据号的单子 + var count = _wmsRepository.Count(p => p.BillNum == input.BillNum && p.State != 0); - if (count > 0) + if (count > 0) + { + return false; + } + var sql = "DECLARE @return_value int\n" + + "EXEC @return_value = [dbo].[p_wms_output_cancel_all]\n" + + " @billnum = N'{0}',\n" + + " @type = 2\n" + + "SELECT 'Return Value' = @return_value"; + await _wmsRepository.GetDbContext().Database.ExecuteSqlRawAsync( + string.Format(sql, input.BillNum) + ); + } + else { - return false; + //有采购单据号的单子 + var count = _wmsRepository.Count(p => p.BillNum == input.BillNum && p.State != 0); + + if (count > 0) + { + return false; + } + var sql = "DECLARE @return_value int\n" + + "EXEC @return_value = [dbo].[p_wms_output_cancel_all]\n" + + " @billnum = N'{0}',\n" + + " @type = 10\n" + + "SELECT 'Return Value' = @return_value"; + await _wmsRepository.GetDbContext().Database.ExecuteSqlRawAsync( + string.Format(sql, input.BillNum) + ); } - var sql = "DECLARE @return_value int\n" + - "EXEC @return_value = [dbo].[p_wms_output_cancel_all]\n" + - " @billnum = N'{0}',\n" + - " @type = 2\n" + - "SELECT 'Return Value' = @return_value"; - await _wmsRepository.GetDbContext().Database.ExecuteSqlRawAsync( - string.Format(sql, input.BillNum) - ); @@ -480,105 +896,299 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts //[Authorize(SettleAccountPermissions.SettleAccounts.Default)] public async Task ExcelImport([FromForm] IFormFileCollection files, string version) { - var _billNum = "B" + DateTime.Now.ToString("yyyyMMddhhmmss"); + ExportImporter _exportImporter = new ExportImporter(); var result = await _exportImporter.ExtendExcelImport(files, _excelImportService); - List _lst = new List(); - var _lsCopy = new List(); - foreach (var itm in result) + if (result == null) { - WmsSharePartOutPutDetial _detail = new WmsSharePartOutPutDetial( - GuidGenerator.Create(), - //itm.WmsBillNum, - //itm.OrderBillNum, - string.Empty, - string.Empty, - itm.MaterialCode, - itm.MaterialDesc, - itm.MaterialGroup, - string.Empty, - string.Empty, - 0, - !string.IsNullOrEmpty(itm.Extend1) ?itm.Extend1 : string.Empty, - string.Empty, - version, - itm.ParentMaterialCode, - itm.BillNum, - GuidGenerator.Create() - , string.Empty - , itm.Qty - , 0 - , itm.Qty - ,itm.Price - ,itm.Amt - ); - _lsCopy.Add(_detail); + throw new BusinessException("导入的模板中没有数据,不能为空,请检查!"); } - _lst.AddRange(_lsCopy.ToArray()); - //var _ls1 = _lst.Where(p => p.ParentMaterialCode == p.MaterialCode).ToList(); - var outPutDetail = await _wmsRepository.Where(p => p.Version == version).ToListAsync(); + var result_withbill = result.Where(p => p.OrderBillNum != "").ToList(); + var result_nobill = result.Where(p => p.OrderBillNum == "").ToList(); + //没有采购单号 + if (result_nobill != null) + { + var _billNoNum = "BNoBill" + DateTime.Now.ToString("yyyyMMddhhmmss"); + List _lst = new List(); - //var error = from itm1 in outPutDetail - // join itm2 in _ls1 on - // new { itm1.MaterialCode, itm1.OrderBillNum,itm1.WmsBillNum } - // equals - // new { itm2.MaterialCode, itm2.OrderBillNum,itm2.WmsBillNum } - // select itm1; + var _lsCopy = new List(); + foreach (var itm in result_nobill) + { + WmsSharePartOutPutDetial _detail = new WmsSharePartOutPutDetial( + GuidGenerator.Create(), + string.Empty, + string.Empty, + itm.MaterialCode, + itm.MaterialDesc, + itm.MaterialGroup, + string.Empty, + string.Empty, + 0, + !string.IsNullOrEmpty(itm.Extend1) ? itm.Extend1 : string.Empty, + string.Empty, + version, + itm.ParentMaterialCode, + itm.BillNum, + GuidGenerator.Create() + , string.Empty + , itm.Qty + , 0 + , itm.Qty + , itm.Price + , itm.Amt + ); + _lsCopy.Add(_detail); + } + _lst.AddRange(_lsCopy.ToArray()); - var error = from itm1 in outPutDetail - join itm2 in _lst on - new { itm1.MaterialCode } - equals - new { itm2.MaterialCode } - select itm1; + //var _ls1 = _lst.Where(p => p.ParentMaterialCode == p.MaterialCode).ToList(); + var outPutDetail = await _wmsRepository.Where(p => p.Version == version).ToListAsync(); - var errList = error.GroupBy(p => new { p.BillNum }).Select(p => new { BillNum = p.Key.BillNum, Number = p.Sum(itm => itm.Qty) }); + var error = from itm1 in outPutDetail + join itm2 in _lst on + new { itm1.MaterialCode } + equals + new { itm2.MaterialCode } + select itm1; - 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) - { + var errList = error.GroupBy(p => new { p.BillNum }).Select(p => new { BillNum = p.Key.BillNum, Number = p.Sum(itm => itm.Qty) }); - return await ExportErrorReportAsync(checkList); - } + 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) + { - //var query = from itm1 in _ls1 - // join itm2 in outPutDetail on - // new { itm1.MaterialCode, itm1.OrderBillNum } - // equals - // new { itm2.MaterialCode, itm2.OrderBillNum } into temp1 - // from tm1 in temp1.DefaultIfEmpty() - // where tm1 == null - // select itm1; - var query = from itm1 in _lst - join itm2 in outPutDetail on - new { itm1.MaterialCode } - equals - new { itm2.MaterialCode } into temp1 - from tm1 in temp1.DefaultIfEmpty() - where tm1 == null - select itm1; - var _wmslst = query.ToList(); - foreach (var itm in _wmslst) - { - itm.BillNum = _billNum; + return await ExportErrorReportAsync(checkList); + } + + var query = from itm1 in _lst + join itm2 in outPutDetail on + new { itm1.MaterialCode } + equals + new { itm2.MaterialCode } into temp1 + from tm1 in temp1.DefaultIfEmpty() + where tm1 == null + select itm1; + var _wmslst = query.ToList(); + foreach (var itm in _wmslst) + { + itm.BillNum = _billNoNum; + } + await _wmsRepository.GetDbContext().BulkInsertAsync(_wmslst, new BulkConfig() { BulkCopyTimeout = 0, BatchSize = 10000 }); + int _count = _wmsVersionRepository.Count(p => p.Version == version && p.BillNum == _billNoNum); + if (_count == 0 && _wmslst.Count() > 0) + { + var _version = new WmsSharePartOutPut(GuidGenerator.Create(), version, _billNoNum, CurrentUser.Email); + await _wmsVersionRepository.InsertAsync(_version, true); + } } - 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 && _wmslst.Count()>0) + + //有采购单号 + if (result_withbill != null) { - var _version = new WmsSharePartOutPut(GuidGenerator.Create(), version, _billNum, CurrentUser.Email); - await _wmsVersionRepository.InsertAsync(_version, true); + var _billNum = "B" + DateTime.Now.ToString("yyyyMMddhhmmss"); + List _lst = new List(); + + var _lsCopy = new List(); + foreach (var itm in result_withbill) + { + WmsSharePartOutPutDetial _detail = new WmsSharePartOutPutDetial( + GuidGenerator.Create(), + itm.WmsBillNum, + itm.OrderBillNum, + itm.MaterialCode, + itm.MaterialDesc, + itm.MaterialGroup, + string.Empty, + string.Empty, + 0, + !string.IsNullOrEmpty(itm.Extend1) ? itm.Extend1 : string.Empty, + string.Empty, + version, + itm.ParentMaterialCode, + itm.BillNum, + GuidGenerator.Create() + , string.Empty + , itm.Qty + , 0 + , itm.Qty + , itm.Price + , itm.Amt + ); + _lsCopy.Add(_detail); + } + _lst.AddRange(_lsCopy.ToArray()); + + var outPutDetail = await _wmsRepository.Where(p => p.Version == version).ToListAsync(); + + + var error = from itm1 in outPutDetail + join itm2 in _lst on + new { itm1.MaterialCode, itm1.OrderBillNum, itm1.WmsBillNum } + equals + new { itm2.MaterialCode, itm2.OrderBillNum, itm2.WmsBillNum } + 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.MaterialCode, itm1.OrderBillNum } + equals + new { itm2.MaterialCode, itm2.OrderBillNum } 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 && _wmslst.Count() > 0) + { + var _version = new WmsSharePartOutPut(GuidGenerator.Create(), version, _billNum, CurrentUser.Email); + await _wmsVersionRepository.InsertAsync(_version, true); + } } + return ApplicationConsts.SuccessStr; } + //[HttpPost] + //[Route("ExcelImport")] + //[DisableRequestSizeLimit] + ////[Authorize(SettleAccountPermissions.SettleAccounts.Default)] + //public async Task ExcelImport([FromForm] IFormFileCollection files, string version) + //{ + // var _billNum = "B" + DateTime.Now.ToString("yyyyMMddhhmmss"); + // ExportImporter _exportImporter = new ExportImporter(); + // var result = await _exportImporter.ExtendExcelImport(files, _excelImportService); + + // //if (result == null) + // //{ + // // throw new BusinessException("导入的模板中没有数据,不能为空,请检查!"); + // //} + + // //var result_withbill = result.Select(p => p.BillNum != string.Empty).ToList(); + // //var result_nobill = result.Select(p => p.BillNum == string.Empty).ToList(); + + // List _lst = new List(); + + // var _lsCopy = new List(); + // foreach (var itm in result) + // { + // WmsSharePartOutPutDetial _detail = new WmsSharePartOutPutDetial( + // GuidGenerator.Create(), + // //itm.WmsBillNum, + // //itm.OrderBillNum, + // string.Empty, + // string.Empty, + // itm.MaterialCode, + // itm.MaterialDesc, + // itm.MaterialGroup, + // string.Empty, + // string.Empty, + // 0, + // !string.IsNullOrEmpty(itm.Extend1) ? itm.Extend1 : string.Empty, + // string.Empty, + // version, + // itm.ParentMaterialCode, + // itm.BillNum, + // GuidGenerator.Create() + // , string.Empty + // , itm.Qty + // , 0 + // , itm.Qty + // , itm.Price + // , itm.Amt + // ); + // _lsCopy.Add(_detail); + // } + // _lst.AddRange(_lsCopy.ToArray()); + + // //var _ls1 = _lst.Where(p => p.ParentMaterialCode == p.MaterialCode).ToList(); + // var outPutDetail = await _wmsRepository.Where(p => p.Version == version).ToListAsync(); + + + // //var error = from itm1 in outPutDetail + // // join itm2 in _ls1 on + // // new { itm1.MaterialCode, itm1.OrderBillNum,itm1.WmsBillNum } + // // equals + // // new { itm2.MaterialCode, itm2.OrderBillNum,itm2.WmsBillNum } + // // select itm1; + + // var error = from itm1 in outPutDetail + // join itm2 in _lst on + // new { itm1.MaterialCode } + // equals + // new { itm2.MaterialCode } + // 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 _ls1 + // // join itm2 in outPutDetail on + // // new { itm1.MaterialCode, itm1.OrderBillNum } + // // equals + // // new { itm2.MaterialCode, itm2.OrderBillNum } into temp1 + // // from tm1 in temp1.DefaultIfEmpty() + // // where tm1 == null + // // select itm1; + // var query = from itm1 in _lst + // join itm2 in outPutDetail on + // new { itm1.MaterialCode } + // equals + // new { itm2.MaterialCode } 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 && _wmslst.Count() > 0) + // { + // var _version = new WmsSharePartOutPut(GuidGenerator.Create(), version, _billNum, CurrentUser.Email); + // await _wmsVersionRepository.InsertAsync(_version, true); + // } + // return ApplicationConsts.SuccessStr; + //} + + } } \ No newline at end of file diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml b/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml index 2b7173cc..63b70b69 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.xml @@ -2305,6 +2305,14 @@ + + + 选择任务,生成出库单,只包含已确认的单据 + + + + + 出库界面功能, 撤销核准出库 diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs index 64bf6cd0..36fc39fd 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs @@ -23,7 +23,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report /// - /// 带采购订单号和无订单号一起统计报表 + /// 带采购订单号和无订单号一起统计报表 WHERE Extend != 'is90' /// /// /// @@ -85,7 +85,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " PurchaseOrderNoText,\n" + " AmountNoTax \n" + " FROM\n" + - " Set_SparePart WHERE Extend != 'is90' \n" + + " Set_SparePart \n" + " GROUP BY\n" + " PurchaseOrderNo,\n" + " MaterialCode,\n" + From ebac85d702fd39fbc1ba92f50aeec462233ab5a7 Mon Sep 17 00:00:00 2001 From: 44673626 <44673626@qq.com> Date: Wed, 16 Feb 2022 18:14:33 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A4=A7=E4=BC=97=E5=A4=87=E4=BB=B6?= =?UTF-8?q?=E5=87=BA=E5=BA=93=E6=9D=A1=E4=BB=B6=E5=8A=A0=E4=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Report/SettleSparePartDapperReportRepository.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs index 36fc39fd..497f56f0 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePartDapperReportRepository.cs @@ -85,7 +85,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " PurchaseOrderNoText,\n" + " AmountNoTax \n" + " FROM\n" + - " Set_SparePart \n" + + " Set_SparePart WHERE Extend != 'is90' \n" + " GROUP BY\n" + " PurchaseOrderNo,\n" + " MaterialCode,\n" +