From abbc9058e3ecb1790f81746b7a061a4f7bdca1fe Mon Sep 17 00:00:00 2001 From: 44673626 <44673626@qq.com> Date: Fri, 8 Apr 2022 16:16:25 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=A4=A7=E4=BC=97=E5=A4=87=E4=BB=B6?= =?UTF-8?q?=E6=9C=AA=E7=BB=93=E5=8A=9F=E8=83=BD=E6=8F=90=E5=87=BA=E6=9D=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/WMS/WMSHQHKanbanAppService.cs | 3 +- .../Entities/WMS/WmsHQCarAppService.cs | 6 +- .../WMS/WmsOneTimeSaleOutputAppService.cs | 16 +- .../ReportServices/ReportMakeService.cs | 39 +++++ .../Report/SettleSparePartExportService.cs | 133 +++++++--------- .../Report/SettleUnSparePartExportService.cs | 143 ++++++++++++++++++ .../Services/Report/UnSettledSumService.cs | 15 +- .../SettleAccountJobModule.cs | 5 + 8 files changed, 270 insertions(+), 90 deletions(-) create mode 100644 src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleUnSparePartExportService.cs diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSHQHKanbanAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSHQHKanbanAppService.cs index fb452056..f664b6e1 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSHQHKanbanAppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSHQHKanbanAppService.cs @@ -446,8 +446,9 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts var checkList = new List(); ExportImporter _exportImporter = new ExportImporter(); var result = await _exportImporter.ExtendExcelOfSheetOneImport(files, _excelImportService); + //检验1:导入模板中的第一页签数据不能为空 - if (result == null || result.Count == 0) + if (result == null || result.Count() == 0) { checkList.Add(new ErrorExportDto(version, "红旗批量出库单导入", string.Empty, string.Empty, string.Empty, string.Empty, "导入模板中第一页签没有数据,请检查!", string.Empty)); } diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsHQCarAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsHQCarAppService.cs index d06b8188..5d01ac30 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsHQCarAppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsHQCarAppService.cs @@ -414,9 +414,11 @@ namespace Win.Sfs.SettleAccount.Entities.WMS var _billNum = "BCar" + DateTime.Now.ToString("yyyyMMddhhmmss"); var checkList = new List(); ExportImporter _exportImporter = new ExportImporter(); - var result = await _exportImporter.ExtendExcelOfSheetOneImport(files, _excelImportService); + var result_org = await _exportImporter.ExtendExcelOfSheetOneImport(files, _excelImportService); + //过滤掉物料号为空的数据 + var result = result_org.Where(p => !string.IsNullOrEmpty(p.MaterialCode)); //检验1:导入模板中的第一页签数据不能为空 - if (result == null || result.Count == 0) + if (result == null || result.Count() == 0) { checkList.Add(new ErrorExportDto(version, "轿车出库单导入", string.Empty, string.Empty, string.Empty, string.Empty, "导入模板中第一页签没有数据,请检查!", string.Empty)); } diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsOneTimeSaleOutputAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsOneTimeSaleOutputAppService.cs index 3079fb60..ef026f53 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsOneTimeSaleOutputAppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WmsOneTimeSaleOutputAppService.cs @@ -211,7 +211,7 @@ namespace Win.Sfs.SettleAccount.Entities.WMS [UnitOfWork(false)] public async Task WmsKanbanOutPut([FromForm] IFormFileCollection files, string version) { - + var checkList = new List(); var _billNum = "OTS" + DateTime.Now.ToString("yyyyMMddhhmmss"); @@ -219,11 +219,19 @@ namespace Win.Sfs.SettleAccount.Entities.WMS ExportImporter _exportImporter = new ExportImporter(); //只取导入模板第一个页签 - var _list = await _exportImporter.ExtendExcelOfSheetOneImport(files, _excelImportService); + var _list_org = await _exportImporter.ExtendExcelOfSheetOneImport(files, _excelImportService); + // 根据物料号是否为空,过滤EXCEL自带的空行 + var _list = _list_org.Where(p => !string.IsNullOrEmpty(p.SapMaterialCode)); + - if (_list == null || _list.Count == 0) + //检验1:导入模板中的第一页签数据不能为空 + if (_list == null || _list.Count() == 0) + { + checkList.Add(new ErrorExportDto(version, "一次性寄售销售导入", string.Empty, string.Empty, string.Empty, string.Empty, "导入模板中第一页签没有数据,请检查!", string.Empty)); + } + if (checkList.Count > 0) { - throw new BusinessException("导入模板数据不能为空!"); + return await ExportErrorReportAsync(checkList); } ////插入数据前检验 diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs index cbe620ce..04af0f28 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Reports/ReportServices/ReportMakeService.cs @@ -252,6 +252,45 @@ namespace Win.Sfs.SettleAccount.Reports.ReportServices }); return _taskid; } + + /// + /// 大众备件未结明细 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + [HttpGet] + [Route("UnSettleSparePartExport")] + [DisableRequestSizeLimit] + + public async Task UnSettledSparePart(string purchaseOrderNo, string sapCode, string version, string customerCode, string factory, string matialCode, + string state, DateTime begin, DateTime end) + { + + List customConditionList = new List(); + customConditionList.Add(new CustomCondition() { Name = "Version", Value = version ?? string.Empty }); + customConditionList.Add(new CustomCondition() { Name = "PurchaseOrderNo", Value = purchaseOrderNo ?? string.Empty }); + customConditionList.Add(new CustomCondition() { Name = "SAPCode", Value = sapCode ?? string.Empty }); + customConditionList.Add(new CustomCondition() { Name = "CustomerCode", Value = customerCode ?? string.Empty }); + customConditionList.Add(new CustomCondition() { Name = "State", Value = state ?? "0" }); + customConditionList.Add(new CustomCondition() { Name = "MatialCode", Value = matialCode ?? string.Empty }); + customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = "大众备件结算核对" }); + customConditionList.Add(new CustomCondition() { Name = "BegingTime", Value = begin.ToString() }); + customConditionList.Add(new CustomCondition() { Name = "EndTime", Value = end.ToString() }); + + var _taskid = await _service.ExportEnqueueAsync("大众备件未结输出", ExportExtentsion.Excel, version, string.Empty, CurrentUser, typeof(SettleUnSparePartExportService), customConditionList, (rs) => + { + + }); + return _taskid; + } #endregion /// /// 无订单备件结算输出 diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs index e29f9803..12d4d2be 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs @@ -53,81 +53,58 @@ namespace SettleAccount.Job.Services.Report var _forwardls_withcode = _dapper.GetWithCodeSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); //反向对比,即大众备件未结(有单号),包含有发货有结算并且发货数量大于结算数量的数据也整合到未结中 - var _reversels_withcode = _dapper.GetReverseWithCodeSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); - - - var stockList = _wmsDapper.GetSalesStock(); - - //针对无单号备件,求和汇总显示 - var _forwardls_nocode = _dapper.GetNoCodeSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); - var queryStockList_nocode = from itm in _forwardls_nocode - join itm1 in stockList on itm.SAP编码 equals itm1.SapCode into temp1 - from tm1 in temp1.DefaultIfEmpty() - select new SettleSparePartExport( - itm.SAP编码, - itm.物料代码, - itm.物料描述, - itm.发货数量, - itm.收货数量, - itm.开票数量, - itm.收货与开票差异, - itm.开票单价, - itm.开票金额, - itm.定价, - itm.单价差异, - itm.差异总金额, - tm1 == null ? 0 : tm1.Qty - ); - - //不管有单号备件还是无单号备件,财务要求全部按照零件汇总求和显示,并和寄售库存比对 - var _forwardls = _dapper.GetForwardSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); - //按照零件号汇总数量,有一列显示寄售库数量 - - var queryStockList = from itm in _forwardls - join itm1 in stockList on itm.SAP编码 equals itm1.SapCode into temp1 - from tm1 in temp1.DefaultIfEmpty() - select new SettleSparePartExport( - itm.SAP编码, - itm.物料代码, - itm.物料描述, - itm.发货数量, - itm.收货数量, - itm.开票数量, - itm.收货与开票差异, - itm.开票单价, - itm.开票金额, - itm.定价, - itm.单价差异, - itm.差异总金额, - tm1 == null ? 0 : tm1.Qty - ); - - - - //var diffList = _dapper.GetSettleSparePartSumQtyDiff(version); - //if (diffList != null) - //{ - // foreach (var itm in diffList) - // { - // var _first = _ls.FirstOrDefault(p => p.采购订单号 == itm.订单号 && p.物料代码==itm.物料号); - // if (_first != null) - // { - // _first.开票数量 = _first.发货数量 + itm.数量差异;//开票数量(结算数量+差异) - // _first.数量差异 = itm.数量差异; + //var _reversels_withcode = _dapper.GetReverseWithCodeSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); + + + //var stockList = _wmsDapper.GetSalesStock(); + + ////针对无单号备件,求和汇总显示 + //var _forwardls_nocode = _dapper.GetNoCodeSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); + //var queryStockList_nocode = from itm in _forwardls_nocode + // join itm1 in stockList on itm.SAP编码 equals itm1.SapCode into temp1 + // from tm1 in temp1.DefaultIfEmpty() + // select new SettleSparePartExport( + // itm.SAP编码, + // itm.物料代码, + // itm.物料描述, + // itm.发货数量, + // itm.收货数量, + // itm.开票数量, + // itm.收货与开票差异, + // itm.开票单价, + // itm.开票金额, + // itm.定价, + // itm.单价差异, + // itm.差异总金额, + // tm1 == null ? 0 : tm1.Qty + // ); + + ////不管有单号备件还是无单号备件,财务要求全部按照零件汇总求和显示,并和寄售库存比对 + //var _forwardls = _dapper.GetForwardSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); + ////按照零件号汇总数量,有一列显示寄售库数量 + + //var queryStockList = from itm in _forwardls + // join itm1 in stockList on itm.SAP编码 equals itm1.SapCode into temp1 + // from tm1 in temp1.DefaultIfEmpty() + // select new SettleSparePartExport( + // itm.SAP编码, + // itm.物料代码, + // itm.物料描述, + // itm.发货数量, + // itm.收货数量, + // itm.开票数量, + // itm.收货与开票差异, + // itm.开票单价, + // itm.开票金额, + // itm.定价, + // itm.单价差异, + // itm.差异总金额, + // tm1 == null ? 0 : tm1.Qty + // ); + - // } - // } - //} - //if (!string.IsNullOrEmpty(materialGroup)) - //{ - // var _groupList = materialGroup.Split(new char[] { ',' }).Distinct().ToList(); - // if (_groupList.Count() > 0) - // { - // _ls = _ls.Where(p => _groupList.Contains(p.MaterialGroup)).ToList(); - // } - //} if (!string.IsNullOrEmpty(sapCode)) { var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList(); @@ -164,12 +141,12 @@ namespace SettleAccount.Job.Services.Report var result = _exporter.Append(_ls.ToList(), "大众备件明细数据") .SeparateBySheet() .Append(_forwardls_withcode.ToList(), "有结算无发货对比") - .SeparateBySheet() - .Append(_reversels_withcode.ToList(), "大众备件未结(包含发货数量大于结算数据)") - .SeparateBySheet() - .Append(queryStockList_nocode.ToList(), "大众备件无单号汇总") - .SeparateBySheet() - .Append(queryStockList.ToList(), "零件汇总比对寄售库存") + // .SeparateBySheet() + //.Append(_reversels_withcode.ToList(), "大众备件未结(包含发货数量大于结算数据)") + // .SeparateBySheet() + // .Append(queryStockList_nocode.ToList(), "大众备件无单号汇总") + // .SeparateBySheet() + //.Append(queryStockList.ToList(), "零件汇总比对寄售库存") .ExportAppendDataAsByteArray(); result.ShouldNotBeNull(); _fileContainer.SaveAsync(fileName, result.Result, true); diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleUnSparePartExportService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleUnSparePartExportService.cs new file mode 100644 index 00000000..afed0166 --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleUnSparePartExportService.cs @@ -0,0 +1,143 @@ +using Magicodes.ExporterAndImporter.Excel; +using Shouldly; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TaskJob.EventArgs; +using TaskJob.Interfaces; +using Volo.Abp.BlobStoring; +using Volo.Abp.DependencyInjection; +using Win.Sfs.BaseData.ImportExcelCommon; +using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report; + +namespace SettleAccount.Job.Services.Report +{ + public class SettleUnSparePartExportService : ITransientDependency, IExportJob + { + private readonly SettleSparePartDapperReportRepository _dapper; + private readonly OutputService _outputService; + private readonly ErpPartDapperRepository _erpdapperRepository; + private readonly IBlobContainer _fileContainer; + private readonly WmsDapperRepository _wmsDapper; + + + public SettleUnSparePartExportService(SettleSparePartDapperReportRepository dapper, ErpPartDapperRepository erpdapperRepository, OutputService outputService + , WmsDapperRepository wmsDapper + , IBlobContainer fileContainer) + { + _dapper = dapper; + _outputService = outputService; + _erpdapperRepository = erpdapperRepository; + _fileContainer = fileContainer; + _wmsDapper = wmsDapper; + } + + + public string ExportFile(Guid id, List exportName, List p_list) + { + var fileName = exportName.FirstOrDefault(); + var purchaseOrderNo = p_list.Where(p => p.Name == "PurchaseOrderNo").FirstOrDefault().Value; + var version = p_list.Where(p => p.Name == "Version").FirstOrDefault().Value; + var sapCode = p_list.Where(p => p.Name == "SAPCode").FirstOrDefault().Value; + var matialCode = p_list.Where(p => p.Name == "MatialCode").FirstOrDefault().Value; + var beginTime = p_list.Where(p => p.Name == "BegingTime").FirstOrDefault().Value; + var endTime = p_list.Where(p => p.Name == "EndTime").FirstOrDefault().Value; + //var iscontionversion = p_list.Where(p => p.Name == "IsContainVersion").FirstOrDefault().Value; + + + //反向对比,即大众备件未结(有单号),包含有发货有结算并且发货数量大于结算数量的数据也整合到未结中 + var _reversels_withcode = _dapper.GetReverseWithCodeSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); + + + var stockList = _wmsDapper.GetSalesStock(); + + //针对无单号备件,求和汇总显示 + var _forwardls_nocode = _dapper.GetNoCodeSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); + var queryStockList_nocode = from itm in _forwardls_nocode + join itm1 in stockList on itm.SAP编码 equals itm1.SapCode into temp1 + from tm1 in temp1.DefaultIfEmpty() + select new SettleSparePartExport( + itm.SAP编码, + itm.物料代码, + itm.物料描述, + itm.发货数量, + itm.收货数量, + itm.开票数量, + itm.收货与开票差异, + itm.开票单价, + itm.开票金额, + itm.定价, + itm.单价差异, + itm.差异总金额, + tm1 == null ? 0 : tm1.Qty + ); + + //不管有单号备件还是无单号备件,财务要求全部按照零件汇总求和显示,并和寄售库存比对 + var _forwardls = _dapper.GetForwardSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); + //按照零件号汇总数量,有一列显示寄售库数量 + + var queryStockList = from itm in _forwardls + join itm1 in stockList on itm.SAP编码 equals itm1.SapCode into temp1 + from tm1 in temp1.DefaultIfEmpty() + select new SettleSparePartExport( + itm.SAP编码, + itm.物料代码, + itm.物料描述, + itm.发货数量, + itm.收货数量, + itm.开票数量, + itm.收货与开票差异, + itm.开票单价, + itm.开票金额, + itm.定价, + itm.单价差异, + itm.差异总金额, + tm1 == null ? 0 : tm1.Qty + ); + + + if (!string.IsNullOrEmpty(sapCode)) + { + var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList(); + if (_groupList.Count() > 0) + { + _reversels_withcode = _reversels_withcode.Where(p => _groupList.Contains(p.SAP编码)).ToList(); + } + } + //if (!string.IsNullOrEmpty(matialCode)) + //{ + // var _groupList = matialCode.Split(new char[] { '\n' }).Distinct().ToList(); + // if (_groupList.Count() > 0) + // { + // _ls = _ls.Where(p => _groupList.Contains(p.物料代码)).ToList(); + // } + //} + if (!string.IsNullOrEmpty(purchaseOrderNo)) + { + var _groupList = purchaseOrderNo.Split(new char[] { '\n' }).Distinct().ToList(); + if (_groupList.Count() > 0) + { + _reversels_withcode = _reversels_withcode.Where(p => _groupList.Contains(p.采购订单号)).ToList(); + } + } + + + ExcelExporter _exporter = new ExcelExporter();//导出Excel + var result = _exporter.Append(_reversels_withcode.ToList(), "大众备件未结(包含发货数量大于结算数据)") + .SeparateBySheet() + .Append(queryStockList_nocode.ToList(), "大众备件无单号汇总") + .SeparateBySheet() + .Append(queryStockList.ToList(), "零件汇总比对寄售库存") + .ExportAppendDataAsByteArray(); + result.ShouldNotBeNull(); + _fileContainer.SaveAsync(fileName, result.Result, true); + + + return id.ToString(); + } + + + } +} diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs index d3dd9de6..76bb0038 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnSettledSumService.cs @@ -174,7 +174,11 @@ namespace SettleAccount.Job.Services.Report var materailCode = p_list.Where(p => p.Name == "MaterialCode").FirstOrDefault().Value; var materialGroup = p_list.Where(p => p.Name == "MaterialGroup").FirstOrDefault().Value; //var sapCode = p_list.Where(p => p.Name == "SAPCode").FirstOrDefault().Value; - var iscontionversion = p_list.Where(p => p.Name == "IsContainVersion").FirstOrDefault().Value; + //var iscontionversion = p_list.Where(p => p.Name == "IsContainVersion").FirstOrDefault().Value; + var iscontionversion = "1";//不分版本,全查 + + + //var version = p_list.Where(p => p.Name == "Version").FirstOrDefault().Value; //var customerCode = p_list.Where(p => p.Name == "CustomerCode").FirstOrDefault().Value; @@ -241,14 +245,15 @@ namespace SettleAccount.Job.Services.Report var _filename = exportName.FirstOrDefault(); var version = p_list.Where(p => p.Name == "Version").FirstOrDefault().Value; var materialCode = p_list.Where(p => p.Name == "MaterialCode").FirstOrDefault().Value; - var kanban = p_list.Where(p => p.Name == "Kanban").FirstOrDefault().Value; + //var kanban = p_list.Where(p => p.Name == "Kanban").FirstOrDefault().Value; var begin = p_list.Where(p => p.Name == "Begin").FirstOrDefault().Value; var end = p_list.Where(p => p.Name == "End").FirstOrDefault().Value; var materialGroup = p_list.Where(p => p.Name == "MaterialGroup").FirstOrDefault().Value; - var acceptNo = p_list.Where(p => p.Name == "AcceptNo").FirstOrDefault().Value; + //var acceptNo = p_list.Where(p => p.Name == "AcceptNo").FirstOrDefault().Value; var sapCode = p_list.Where(p => p.Name == "SapCode").FirstOrDefault().Value; - var warehouseDesc = p_list.Where(p => p.Name == "WarehouseDesc").FirstOrDefault().Value; - var iscontionversion = p_list.Where(p => p.Name == "IsContainVersion").FirstOrDefault().Value; + //var warehouseDesc = p_list.Where(p => p.Name == "WarehouseDesc").FirstOrDefault().Value; + //var iscontionversion = p_list.Where(p => p.Name == "IsContainVersion").FirstOrDefault().Value; + var iscontionversion = "1";//不分区间,全查 //有发货无结算,单独拿出去,财务要求 var _ls = _hqkanbanDapper.GetReverseSettledDetailDiffReportList(version, materialCode, begin, end, materialGroup, iscontionversion); if (!string.IsNullOrEmpty(sapCode)) diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs index 189c98af..28ab9839 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs @@ -119,6 +119,11 @@ namespace Win.Sfs.SettleAccount { return implementationFactory.GetService(); } + //大众备件未结明细 + if (key.Equals(typeof(SettleUnSparePartExportService).FullName)) + { + return implementationFactory.GetService(); + } //大众备件90天核对明细 if (key.Equals(typeof(SettleSparePart90ExportService).FullName)) { From 5a555e314d1bd2557641ebc7737b0ed9806285ce Mon Sep 17 00:00:00 2001 From: 44673626 <44673626@qq.com> Date: Fri, 8 Apr 2022 20:38:13 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=AF=BC=E5=87=BADTO=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/TaskListDto.cs | 8 +- .../SettleSparePartDapperReportRepository.cs | 519 ++---------------- 2 files changed, 62 insertions(+), 465 deletions(-) diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/TaskListDto.cs b/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/TaskListDto.cs index 8410800e..31793a80 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/TaskListDto.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/TaskListDto.cs @@ -234,8 +234,8 @@ namespace Win.Sfs.SettleAccount.Entities [ImporterHeader(Name = "开票金额")] [ExporterHeader(DisplayName = "开票金额")] public decimal Amt { set; get; } - + } /// /// 大众备件出库单 @@ -631,9 +631,6 @@ namespace Win.Sfs.SettleAccount.Entities } - /// - /// 学生状态 正常、流失、休学、勤工俭学、顶岗实习、毕业、参军 - /// public enum ExporterStatus { /// @@ -671,3 +668,6 @@ namespace Win.Sfs.SettleAccount.Entities } + + + 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 925afacc..24b707b4 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 @@ -21,7 +21,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report /// - /// 带采购订单号和无订单号一起统计报表 WHERE Extend != 'is90' 去掉 备件调整数据 + /// 带采购订单号和无订单号一起统计报表 WHERE Extend != 'is90' 去掉 备件调整数据,开票单价财务说会有调整,做了一个开票单价平均数据 /// /// /// @@ -34,133 +34,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report string begintime, string endtime) { - //string sqlString = "SELECT\n" + - //" union1.* \n" + - //"FROM\n" + - //" (\n" + - //" SELECT\n" + - //" temp1.交货日期,\n" + - //" temp1.交货单号,\n" + - //" NULL 订单日期,\n" + - //" temp1.采购订单号,\n" + - //" temp1.SAP编码,\n" + - //" temp1.物料代码,\n" + - //" temp1.物料描述,\n" + - //" temp1.采购订单文本,\n" + - //" temp1.收货数量,\n" + - //" temp1.开票数量,\n" + - //" ISNULL( temp1.收货数量, 0 ) - ISNULL( temp1.开票数量, 0 ) AS 收货与开票差异,\n" + - //" temp1.开票单价,\n" + - //" ISNULL( temp1.开票金额, 0 ) AS 开票金额,\n" + - //" ISNULL( TEMP2.Price, 0 ) AS 定价,\n" + - //" temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异 ,\n" + - //" ( temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) ) * temp1.开票数量 AS 差异总金额,\n" + - //" temp1.交货数量,\n" + - //" temp1.收货与交货差异,\n" + - //" ISNULL( temp1.交货数量, 0 ) - ISNULL( temp3.Qty, 0 ) 实际交货数量,\n" + - //" ISNULL( temp3.Qty, 0 ) 退货数量 \n" + - //" FROM\n" + - //" (\n" + - //" SELECT\n" + - //" a.Version AS 期间,\n" + - //" a.PurchaseOrderNoText AS 采购订单文本,\n" + - //" '' AS 交货单号,\n" + - //" NULL AS 交货日期,\n" + - //" a.PurchaseOrderNo AS 采购订单号,\n" + - //" b.MaterialCode AS SAP编码,\n" + - //" b.CustomerPartCode AS 物料代码,\n" + - //" b.MaterialDesc AS 物料描述,\n" + - //" b.EstimateTypeDesc AS 物料组,\n" + - //" ISNULL( a.PurchasePriceNoTax, 0 ) AS 开票单价,\n" + - //" ISNULL( a.ReceiptQty, 0 ) AS 收货数量,\n" + - //" ISNULL( a.InvoicedQty, 0 ) AS 开票数量 ,\n" + - //" ISNULL( a.InvoicedQty, 0 ) * ISNULL( a.PurchasePriceNoTax, 0 ) AS 开票金额,\n" + - //" ISNULL( C.WMSDeliveryQty, 0 ) AS 交货数量,\n" + - //" ( ISNULL( a.ReceiptQty, 0 ) - ISNULL( C.WMSDeliveryQty, 0 ) ) AS 收货与交货差异 \n" + - //" FROM\n" + - //" ( SELECT * FROM Set_SparePart WHERE Extend != 'is90' AND PurchaseOrderNo!='NoOrder' ) AS a\n" + - //" LEFT OUTER JOIN Set_material AS b ON a.MaterialCode = b.CustomerPartCode\n" + - //" LEFT JOIN (\n" + - //"   SELECT\n" + - //" ( ISNULL( temp1.Qty, 0 ) - ISNULL( temp2.Qty, 0 ) ) WMSDeliveryQty,\n" + - //" temp1.MaterialCode,\n" + - //" temp1.PurchaseOrderNo \n" + - //" FROM\n" + - //" (\n" + - //" ( SELECT SUM ( ReceiptQty ) Qty, PurchaseOrderNo, MaterialCode FROM Set_WMSSparePart GROUP BY PurchaseOrderNo, MaterialCode ) temp1\n" + - //" LEFT JOIN ( SELECT SUM ( ReceiptQty ) Qty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE VERSION < '{0}' AND Extend != 'is90' AND PurchaseOrderNo!='NoOrder' GROUP BY PurchaseOrderNo, MaterialCode ) temp2 ON temp1.PurchaseOrderNo = temp2.PurchaseOrderNo \n" + - //" AND temp1.MaterialCode = temp2.MaterialCode \n" + - //" ) \n" + - //" ) C ON A.PurchaseOrderNo = C.PurchaseOrderNo \n" + - //" AND A.MaterialCode = C.MaterialCode \n" + - //" WHERE\n" + - //" ( a.Version = '{0}' ) \n" + - //" ) AS temp1\n" + - //" LEFT JOIN ( SELECT * FROM set_backQty WHERE Version = '{0}' ) temp3 ON temp1.采购订单号 = temp3.Code \n" + - //" AND temp1.SAP编码= temp3.MaterialCode\n" + - //" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" + - //" ) union1 UNION ALL\n" + - //"SELECT\n" + - //" union2.* \n" + - //"FROM\n" + - //" (\n" + - //" SELECT\n" + - //" temp1.交货日期,\n" + - //" '' 交货单号,\n" + - //" '' 订单日期,\n" + - //" '' 采购订单号,\n" + - //" temp1.SAP编码,\n" + - //" temp1.物料代码,\n" + - //" temp1.物料描述,\n" + - //" '' 采购订单文本,\n" + - //" temp1.收货数量,\n" + - //" temp1.开票数量,\n" + - //" ISNULL( temp1.收货数量, 0 ) - ISNULL( temp1.开票数量, 0 ) AS 发货与开票差异,\n" + - //" temp1.开票单价,\n" + - //" ISNULL( temp1.开票金额, 0 ) AS 开票金额,\n" + - //" ISNULL( TEMP2.Price, 0 ) AS 定价,\n" + - //" temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异 ,\n" + - //" ( temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) ) * temp1.开票数量 AS 差异总金额,\n" + - //" 0 交货数量,\n" + - //" 0 收货与交货差异,\n" + - //" 0 实际交货数量,\n" + - //" 0 退货数量 \n" + - //" FROM\n" + - //" (\n" + - //" SELECT\n" + - //" '' AS 交货单号,\n" + - //" NULL AS 交货日期,\n" + - //" c.MaterialCode AS SAP编码,\n" + - //" a.MaterialCode AS 物料代码,\n" + - //" c.MaterialDesc AS 物料描述,\n" + - //" c.EstimateTypeDesc AS 物料组,\n" + - //" ISNULL( a.PurchasePriceNoTax, 0 ) AS 开票单价,\n" + - //" ISNULL( a.ReceiptQty, 0 ) AS 收货数量,\n" + - //" ISNULL( a.InvoicedQty, 0 ) AS 开票数量 ,\n" + - //" ISNULL( a.ReceiptQty, 0 ) * ISNULL( a.PurchasePriceNoTax, 0 ) AS 开票金额 \n" + - //" FROM\n" + - //" (\n" + - //" SELECT SUM\n" + - //" ( ReceiptQty ) AS ReceiptQty,\n" + - //" SUM ( InvoicedQty ) InvoicedQty,\n" + - //" MaterialCode,\n" + - //" PurchasePriceNoTax \n" + - //" FROM\n" + - //" Set_SparePart \n" + - //" WHERE\n" + - //" Extend != 'is90' \n" + - //" AND Version = '{0}' \n" + - //" AND PurchaseOrderNo='NoOrder' \n" + - //" GROUP BY\n" + - //" MaterialCode,\n" + - //" PurchasePriceNoTax \n" + - //" ) AS a\n" + - //" LEFT JOIN ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, MaterialCode FROM Set_WMSSparePart GROUP BY MaterialCode ) AS b ON a.MaterialCode = b.MaterialCode\n" + - //" LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, CustomerPartCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, CustomerPartCode ) AS c ON a.MaterialCode = c.CustomerPartCode \n" + - //" ) AS temp1\n" + - //" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = ( SELECT MAX ( VERSION ) FROM Set_PriceList ) ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" + - //" ) union2"; - string sqlString = "SELECT\n" + " union1.* \n" + @@ -178,11 +51,11 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " temp1.收货数量,\n" + " temp1.开票数量,\n" + " ISNULL( temp1.收货数量, 0 ) - ISNULL( temp1.开票数量, 0 ) AS 收货与开票差异,\n" + - " temp1.开票单价,\n" + - " ISNULL( temp1.开票金额, 0 ) AS 开票金额,\n" + + " ISNULL( TEMP4.PurchasePriceNoTax, 0 ) AS 开票单价,\n" + + " ISNULL( temp1.开票数量, 0 ) * ISNULL( TEMP4.PurchasePriceNoTax, 0 ) AS 开票金额,\n" + " ISNULL( TEMP2.Price, 0 ) AS 定价,\n" + - " temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异 ,\n" + - " ( temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) ) * temp1.开票数量 AS 差异总金额,\n" + + " ISNULL( TEMP4.PurchasePriceNoTax, 0 ) - ISNULL( TEMP2.Price, 0 ) AS 单价差异 ,\n" + + " ( ISNULL( TEMP4.PurchasePriceNoTax, 0 ) - ISNULL( TEMP2.Price, 0 ) ) * temp1.开票数量 AS 差异总金额,\n" + " temp1.交货数量,\n" + " temp1.收货与交货差异,\n" + " ISNULL( temp1.交货数量, 0 ) - ISNULL( temp3.Qty, 0 ) 实际交货数量,\n" + @@ -190,7 +63,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " FROM\n" + " (\n" + " SELECT\n" + - " a.Version AS 期间,\n" + " a.PurchaseOrderNoText AS 采购订单文本,\n" + " '' AS 交货单号,\n" + " NULL AS 交货日期,\n" + @@ -199,14 +71,29 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " b.CustomerPartCode AS 物料代码,\n" + " b.MaterialDesc AS 物料描述,\n" + " b.EstimateTypeDesc AS 物料组,\n" + - " ISNULL( a.PurchasePriceNoTax, 0 ) AS 开票单价,\n" + " ISNULL( a.ReceiptQty, 0 ) AS 收货数量,\n" + " ISNULL( a.InvoicedQty, 0 ) AS 开票数量 ,\n" + - " ISNULL( a.InvoicedQty, 0 ) * ISNULL( a.PurchasePriceNoTax, 0 ) AS 开票金额,\n" + " ISNULL( C.WMSDeliveryQty, 0 ) AS 交货数量,\n" + " ( ISNULL( a.ReceiptQty, 0 ) - ISNULL( C.WMSDeliveryQty, 0 ) ) AS 收货与交货差异 \n" + " FROM\n" + - " ( SELECT * FROM Set_SparePart WHERE Extend != 'is90' AND PurchaseOrderNo!='NoOrder' ) AS a\n" + + " (\n" + + " SELECT SUM\n" + + " ( ReceiptQty ) ReceiptQty,\n" + + " SUM ( InvoicedQty ) InvoicedQty,\n" + + " PurchaseOrderNo,\n" + + " MaterialCode,\n" + + " PurchaseOrderNoText \n" + + " FROM\n" + + " Set_SparePart \n" + + " WHERE\n" + + " Extend != 'is90' \n" + + " AND PurchaseOrderNo != 'NoOrder' \n" + + " AND Version = '{0}' \n" + + " GROUP BY\n" + + " PurchaseOrderNo,\n" + + " MaterialCode,\n" + + " PurchaseOrderNoText \n" + + " ) AS a\n" + " LEFT OUTER JOIN Set_material AS b ON a.MaterialCode = b.CustomerPartCode\n" + " LEFT JOIN (\n" + "   SELECT\n" + @@ -216,18 +103,46 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " FROM\n" + " (\n" + " ( SELECT SUM ( ReceiptQty ) Qty, PurchaseOrderNo, MaterialCode FROM Set_WMSSparePart GROUP BY PurchaseOrderNo, MaterialCode ) temp1\n" + - " LEFT JOIN ( SELECT SUM ( ReceiptQty ) Qty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE VERSION < '{0}' AND Extend != 'is90' AND PurchaseOrderNo!='NoOrder' GROUP BY PurchaseOrderNo, MaterialCode ) temp2 ON temp1.PurchaseOrderNo = temp2.PurchaseOrderNo \n" + + " LEFT JOIN (\n" + + " SELECT SUM\n" + + " ( ReceiptQty ) Qty,\n" + + " PurchaseOrderNo,\n" + + " MaterialCode \n" + + " FROM\n" + + " Set_SparePart \n" + + " WHERE\n" + + " VERSION < '{0}' \n" + + " AND Extend != 'is90' \n" + + " AND PurchaseOrderNo != 'NoOrder' \n" + + " GROUP BY\n" + + " PurchaseOrderNo,\n" + + " MaterialCode \n" + + " ) temp2 ON temp1.PurchaseOrderNo = temp2.PurchaseOrderNo \n" + " AND temp1.MaterialCode = temp2.MaterialCode \n" + " ) \n" + " ) C ON A.PurchaseOrderNo = C.PurchaseOrderNo \n" + " AND A.MaterialCode = C.MaterialCode \n" + - " WHERE\n" + - " ( a.Version = '{0}' ) \n" + " ) AS temp1\n" + " LEFT JOIN ( SELECT * FROM set_backQty WHERE Version = '{0}' ) temp3 ON temp1.采购订单号 = temp3.Code \n" + " AND temp1.SAP编码= temp3.MaterialCode\n" + - " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" + - " ) union1 \n" ; + " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode\n" + + " LEFT JOIN (\n" + + " SELECT\n" + + " ROUND( SUM ( AmountNoTax ) / SUM ( ReceiptQty ), 4 ) PurchasePriceNoTax,\n" + + " PurchaseOrderNo,\n" + + " MaterialCode \n" + + " FROM\n" + + " Set_SparePart \n" + + " WHERE\n" + + " Extend != 'is90' \n" + + " AND PurchaseOrderNo != 'NoOrder' \n" + + " AND Version = '{0}' \n" + + " GROUP BY\n" + + " PurchaseOrderNo,\n" + + " MaterialCode \n" + + " ) AS TEMP4 ON temp1.[物料代码] = TEMP4.MaterialCode \n" + + " AND temp1.采购订单号 = TEMP4.PurchaseOrderNo \n" + + " ) union1"; @@ -350,177 +265,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report } - /// - /// 带采购订单号和无订单号一起统计报表 WHERE Extend != 'is90' - /// - /// - /// - /// - /// - /// - /// - /// - //public virtual List GetSettleSparePartReportList(string purchaseOrderNo, string version, string sapCode, string matialCode, - // string begintime, string endtime) - //{ - // string sqlString = "SELECT\n" + - // " union1.* \n" + - // "FROM\n" + - // " (\n" + - // " SELECT\n" + - // " temp1.交货日期,\n" + - // " temp1.交货单号,\n" + - // " '' 订单日期,\n" + - // " temp1.采购订单号,\n" + - // " temp1.SAP编码,\n" + - // " temp1.物料代码,\n" + - // " temp1.物料描述,\n" + - // " temp1.采购订单文本,\n" + - // " temp1.发货数量,\n" + - // " temp1.开票数量,\n" + - // " ISNULL( temp1.发货数量, 0 ) - ISNULL( temp1.开票数量, 0 ) AS 发货与开票差异,\n" + - // " temp1.开票单价,\n" + - // " ISNULL( temp1.开票金额, 0 ) AS 开票金额,\n" + - // " ISNULL( TEMP2.Price, 0 ) AS 定价,\n" + - // " temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异 ,\n" + - // " ( temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) ) * temp1.开票数量 AS 差异总金额 \n" + - // " FROM\n" + - // " (\n" + - // " SELECT\n" + - // " a.Version AS 期间,\n" + - // " a.PurchaseOrderNoText AS 采购订单文本,\n" + - // " b.WMSDeliveryNote AS 交货单号,\n" + - // " b.SpareDate AS 交货日期,\n" + - // " a.PurchaseOrderNo AS 采购订单号,\n" + - // " c.MaterialCode AS SAP编码,\n" + - // " b.MaterialCode AS 物料代码,\n" + - // " c.MaterialDesc AS 物料描述,\n" + - // " c.EstimateTypeDesc AS 物料组,\n" + - // " a.PurchasePriceNoTax AS 开票单价,\n" + - // " 0 AS 数量差异,\n" + - // " ISNULL( b.ReceiptQty, 0 ) AS 发货数量,\n" + - // " ISNULL( a.InvoicedQty, 0 ) AS 开票数量 ,\n" + - // " ISNULL( a.AmountNoTax, 0 ) AS 开票金额 \n" + - // " FROM\n" + - // " (\n" + - // " SELECT SUM\n" + - // " ( ReceiptQty ) AS ReceiptQty,\n" + - // " PurchaseOrderNo,\n" + - // " MaterialCode,\n" + - // " Version,\n" + - // " PurchasePriceNoTax,\n" + - // " InvoicedQty,\n" + - // " PurchaseOrderNoText,\n" + - // " AmountNoTax \n" + - // " FROM\n" + - // " Set_SparePart WHERE Extend != 'is90' \n" + - // " GROUP BY\n" + - // " PurchaseOrderNo,\n" + - // " MaterialCode,\n" + - // " Version,\n" + - // " PurchasePriceNoTax,\n" + - // " InvoicedQty,\n" + - // " PurchaseOrderNoText,\n" + - // " AmountNoTax \n" + - // " ) AS a\n" + - // " INNER JOIN (\n" + - // " SELECT SUM\n" + - // " ( ReceiptQty ) AS ReceiptQty,\n" + - // " PurchaseOrderNo,\n" + - // " SapCode,\n" + - // " MaterialCode,\n" + - // " WMSDeliveryNote,\n" + - // " SpareDate \n" + - // " FROM\n" + - // " Set_WMSSparePart \n" + - // " GROUP BY\n" + - // " PurchaseOrderNo,\n" + - // " SapCode,\n" + - // " MaterialCode,\n" + - // " WMSDeliveryNote,\n" + - // " SpareDate \n" + - // " ) AS b ON a.PurchaseOrderNo = b.PurchaseOrderNo \n" + - // " AND a.MaterialCode = b.MaterialCode\n" + - // " LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" + - // " WHERE\n" + - // " ( a.Version = '{0}' ) \n" + - // " ) AS temp1\n" + - // " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" + - // " ) union1 UNION ALL\n" + - // "SELECT\n" + - // " union2.* \n" + - // "FROM\n" + - // " (\n" + - // " SELECT\n" + - // " temp1.交货日期,\n" + - // " '' 交货单号,\n" + - // " '' 订单日期,\n" + - // " '' 采购订单号,\n" + - // " temp1.SAP编码,\n" + - // " temp1.物料代码,\n" + - // " temp1.物料描述,\n" + - // " temp1.采购订单文本,\n" + - // " temp1.发货数量,\n" + - // " temp1.开票数量,\n" + - // " ISNULL( temp1.发货数量, 0 ) - ISNULL( temp1.开票数量, 0 ) AS 发货与开票差异,\n" + - // " temp1.开票单价,\n" + - // " ISNULL( temp1.开票金额, 0 ) AS 开票金额,\n" + - // " ISNULL( TEMP2.Price, 0 ) AS 定价,\n" + - // " temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异 ,\n" + - // " ( temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) ) * temp1.开票数量 AS 差异总金额 \n" + - // " FROM\n" + - // " (\n" + - // " SELECT\n" + - // " a.Version AS 期间,\n" + - // " '' AS 采购订单文本,\n" + - // " NULL AS 交货日期,\n" + - // " c.MaterialCode AS SAP编码,\n" + - // " a.MaterialCode AS 物料代码,\n" + - // " c.MaterialDesc AS 物料描述,\n" + - // " c.EstimateTypeDesc AS 物料组,\n" + - // " a.PurchasePriceNoTax AS 开票单价,\n" + - // " 0 AS 数量差异,\n" + - // " ISNULL( b.ReceiptQty, 0 ) AS 发货数量,\n" + - // " ISNULL( a.ReceiptQty, 0 ) AS 开票数量 ,\n" + - // " ISNULL( a.ReceiptQty, 0 ) * ISNULL( a.PurchasePriceNoTax, 0 ) AS 开票金额 \n" + - // " FROM\n" + - // " ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, MaterialCode, Version, PurchasePriceNoTax FROM Set_SparePart WHERE Extend != 'is90' and PurchaseOrderNo is null GROUP BY MaterialCode, Version, PurchasePriceNoTax ) AS a\n" + - // " LEFT JOIN ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, SapCode, MaterialCode FROM Set_WMSSparePart GROUP BY SapCode, MaterialCode ) AS b ON a.MaterialCode = b.MaterialCode\n" + - // " LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, CustomerPartCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, CustomerPartCode ) AS c ON a.MaterialCode = c.CustomerPartCode \n" + - // " WHERE\n" + - // " ( a.Version = '{0}' ) \n" + - // " ) AS temp1\n" + - // " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" + - // " ) union2"; - - // //" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) ) AS TEMP2 ON temp.Sap编码 = TEMP2.MaterialCode\n" + - // string addwhere = string.Empty; - // string addSqlStr = string.Format(sqlString, version); - - // //if (!string.IsNullOrEmpty(purchaseOrderNo)) - // //{ - // // addwhere += string.Format(" AND PurchaseOrderNo LIKE '{0}%' ", purchaseOrderNo); - // //} - // //else if (!string.IsNullOrEmpty(sapCode)) - // //{ - // // addwhere += string.Format(" AND SAPCode LIKE '{0}%' ", sapCode); - // //} - // //else if (!string.IsNullOrEmpty(matialCode)) - // //{ - // // addwhere += string.Format(" AND MaterialCode LIKE '{0}%' ", matialCode); - // //} - // //else if (!string.IsNullOrEmpty(begintime)&& !string.IsNullOrEmpty(endtime)) - // //{ - // // addwhere += string.Format(" AND OrderDate BETWEEN '{0}' AND '{1}' ", begintime, endtime); - // //} - - // string _sql = string.Format(addSqlStr, addwhere); - // //string _sql = string.Format(sqlString, version); - // var _query = DbConnection.Query(_sql, null, null, true, 1200, null); - // return _query.ToList(); - - //} - /// /// 大众备件有单号,统计有结算无发货 @@ -761,70 +505,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report } - /// - /// 有发货无结算的报表统计,不用了 - /// - /// - /// - /// - /// - /// - /// - /// - //public virtual List GetReverseSettleSparePartReportList(string purchaseOrderNo, string version, string sapCode, string matialCode, - // string begintime, string endtime) - //{ - // string sqlString = "SELECT\n" + - // " temp1.交货日期,\n" + - // " '' 交货单号,\n" + - // " '' 订单日期,\n" + - // " '' 采购订单号,\n" + - // " temp1.SAP编码,\n" + - // " temp1.物料代码,\n" + - // " temp1.物料描述,\n" + - // " temp1.采购订单文本,\n" + - // " temp1.发货数量,\n" + - // " temp1.开票数量,\n" + - // " ISNULL( temp1.发货数量, 0 ) - ISNULL( temp1.开票数量, 0 ) AS 发货与开票差异,\n" + - // " temp1.开票单价,\n" + - // " ISNULL( temp1.开票金额, 0 ) AS 开票金额,\n" + - // " ISNULL( TEMP2.Price, 0 ) AS 定价,\n" + - // " temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) AS 单价差异 ,\n" + - // " ( temp1.开票单价 - ISNULL( TEMP2.Price, 0 ) ) * temp1.开票数量 AS 差异总金额 \n" + - // "FROM\n" + - // " (\n" + - // " SELECT\n" + - // " b.Version AS 期间,\n" + - // " '' AS 采购订单文本,\n" + - // " NULL AS 交货日期,\n" + - // " c.MaterialCode AS SAP编码,\n" + - // " a.MaterialCode AS 物料代码,\n" + - // " c.MaterialDesc AS 物料描述,\n" + - // " c.EstimateTypeDesc AS 物料组,\n" + - // " b.PurchasePriceNoTax AS 开票单价,\n" + - // " 0 AS 数量差异,\n" + - // " ISNULL( a.ReceiptQty, 0 ) AS 发货数量,\n" + - // " ISNULL( b.ReceiptQty, 0 ) AS 开票数量 ,\n" + - // " ISNULL( b.ReceiptQty, 0 ) * ISNULL( b.PurchasePriceNoTax, 0 ) AS 开票金额 \n" + - // " FROM\n" + - // " ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, MaterialCode FROM Set_WMSSparePart GROUP BY MaterialCode ) AS a\n" + - // " LEFT JOIN ( SELECT * FROM Set_SparePart WHERE Extend != 'is90' AND Version = '{0}' ) AS b ON a.MaterialCode = b.MaterialCode\n" + - // " LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, CustomerPartCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, CustomerPartCode ) AS c ON a.MaterialCode = c.CustomerPartCode \n" + - // " WHERE\n" + - // " ( b.MaterialCode IS NULL ) \n" + - // " ) AS temp1\n" + - // " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode"; - - // string addwhere = string.Empty; - // string addSqlStr = string.Format(sqlString, version); - - // string _sql = string.Format(addSqlStr, addwhere); - // //string _sql = string.Format(sqlString, version); - // var _query = DbConnection.Query(_sql, null, null, true, 1200, null); - // return _query.ToList(); - - //} - + /// /// 大众备件未结(带单号),包含有发货有结算(条件:发货数量大于结算数据)也整合到大众备件未结中 @@ -938,91 +619,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" + " ) unint2"; - //string sqlString = "SELECT\n" + - //" * \n" + - //"FROM\n" + - //" (\n" + - //" SELECT\n" + - //" temp1.交货单号,\n" + - //" temp1.交货日期,\n" + - //" temp1.采购订单号,\n" + - //" temp1.SAP编码,\n" + - //" temp1.物料代码,\n" + - //" temp1.物料描述,\n" + - //" temp1.交货数量,\n" + - //" temp1.收货数量,\n" + - //" temp1.收货与交货差异,\n" + - //" ISNULL( temp3.Qty, 0 ) 退货数量,\n" + - //" ISNULL( temp1.交货数量, 0 ) - ISNULL( temp1.收货数量, 0 ) - ISNULL( temp3.Qty, 0 ) 实际交货数量,\n" + - //" ISNULL( TEMP2.Price, 0 ) AS 定价 \n" + - //" FROM\n" + - //" (\n" + - //" SELECT\n" + - //" '' AS 交货单号,\n" + - //" NULL AS 交货日期,\n" + - //" a.PurchaseOrderNo AS 采购订单号,\n" + - //" c.MaterialCode AS SAP编码,\n" + - //" c.CustomerPartCode AS 物料代码,\n" + - //" c.MaterialDesc AS 物料描述,\n" + - //" c.EstimateTypeDesc AS 物料组,\n" + - //" ISNULL( a.ReceiptQty, 0 ) AS 交货数量,\n" + - //" ISNULL( b.ReceiptQty, 0 ) AS 收货数量,\n" + - //" ( ISNULL( a.ReceiptQty, 0 ) - ISNULL( b.ReceiptQty, 0 ) ) AS 收货与交货差异 \n" + - //" FROM\n" + - //" ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_WMSSparePart GROUP BY PurchaseOrderNo, MaterialCode ) AS a\n" + - //" LEFT JOIN ( SELECT SUM ( ReceiptQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE Extend != 'is90' AND Version = '{0}' GROUP BY PurchaseOrderNo, MaterialCode ) AS b ON a.PurchaseOrderNo= b.PurchaseOrderNo \n" + - //" AND a.MaterialCode = b.MaterialCode\n" + - //" LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, CustomerPartCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, CustomerPartCode ) AS c ON a.MaterialCode = c.CustomerPartCode \n" + - //" WHERE\n" + - //" b.PurchaseOrderNo IS NULL \n" + - //" AND b.MaterialCode IS NULL \n" + - //" ) AS temp1\n" + - //" LEFT JOIN ( SELECT * FROM set_backQty WHERE Version = '{0}' ) temp3 ON temp1.采购订单号 = temp3.Code \n" + - //" AND temp1.SAP编码= temp3.MaterialCode\n" + - //" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" + - //" ) unint1 UNION ALL\n" + - //"SELECT\n" + - //" * \n" + - //"FROM\n" + - //" (\n" + - //" SELECT\n" + - //" temp1.交货单号,\n" + - //" temp1.交货日期,\n" + - //" temp1.采购订单号,\n" + - //" temp1.SAP编码,\n" + - //" temp1.物料代码,\n" + - //" temp1.物料描述,\n" + - //" temp1.交货数量,\n" + - //" temp1.收货数量,\n" + - //" temp1.收货与交货差异,\n" + - //" ISNULL( temp3.Qty, 0 ) 退货数量,\n" + - //" ISNULL( temp1.交货数量, 0 ) - ISNULL( temp1.收货数量, 0 ) - ISNULL( temp3.Qty, 0 ) 实际交货数量,\n" + - //" ISNULL( TEMP2.Price, 0 ) AS 定价 \n" + - //" FROM\n" + - //" (\n" + - //" SELECT\n" + - //" '' AS 交货单号,\n" + - //" NULL AS 交货日期,\n" + - //" a.PurchaseOrderNo AS 采购订单号,\n" + - //" c.MaterialCode AS SAP编码,\n" + - //" c.CustomerPartCode AS 物料代码,\n" + - //" c.MaterialDesc AS 物料描述,\n" + - //" c.EstimateTypeDesc AS 物料组,\n" + - //" ISNULL( a.ReceiptQty, 0 ) AS 交货数量,\n" + - //" ISNULL( b.ReceiptQty, 0 ) AS 收货数量,\n" + - //" ( ISNULL( b.ReceiptQty, 0 ) - ISNULL( a.ReceiptQty, 0 ) ) AS 收货与交货差异 \n" + - //" FROM\n" + - //" ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_WMSSparePart GROUP BY PurchaseOrderNo, MaterialCode ) a\n" + - //" INNER JOIN ( SELECT SUM ( ReceiptQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE Extend != 'is90' AND Version < '{0}' GROUP BY PurchaseOrderNo, MaterialCode ) AS b ON a.PurchaseOrderNo= b.PurchaseOrderNo \n" + - //" AND a.MaterialCode = b.MaterialCode\n" + - //" LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, CustomerPartCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc, CustomerPartCode ) AS c ON a.MaterialCode = c.CustomerPartCode \n" + - //" WHERE\n" + - //" a.ReceiptQty> b.ReceiptQty \n" + - //" ) AS temp1\n" + - //" LEFT JOIN ( SELECT * FROM set_backQty WHERE Version = '{0}' ) temp3 ON temp1.采购订单号 = temp3.Code \n" + - //" AND temp1.SAP编码= temp3.MaterialCode\n" + - //" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" + - //" ) unint2"; + string _sql = string.Format(sqlString, version); From 8e892a8a5c149457e76b74bdb78df1aa8e70f408 Mon Sep 17 00:00:00 2001 From: 44673626 <44673626@qq.com> Date: Mon, 11 Apr 2022 14:09:29 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=9B=B4=E8=B4=A5=E5=A4=A7=E4=BC=97?= =?UTF-8?q?=E5=A4=87=E4=BB=B6=E5=AF=B9=E5=BA=94DTO=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SettleSparePartDapperReportRepository.cs | 124 +++++++++++++++++- 1 file changed, 122 insertions(+), 2 deletions(-) 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 24b707b4..34713bdf 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 @@ -155,7 +155,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report var sql1 = "SELECT\n" + " A.WMSDeliveryNote WmsBillNum,\n" + " t1.MaterialCode MaterialCode,\n" + - " A.PurchaseOrderNo,\n" + + " A.PurchaseOrderNo Kanban,\n" + " A.SpareDate WmsDate \n" + "FROM\n" + " Set_WMSSparePart A\n" + @@ -200,7 +200,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report var sql2 = "SELECT\n" + " A.WMSDeliveryNote WmsBillNum,\n" + " t1.MaterialCode MaterialCode,\n" + - " A.PurchaseOrderNo,\n" + + " A.PurchaseOrderNo Kanban,\n" + " A.SpareDate WmsDate \n" + "FROM\n" + " Set_WMSSparePart A\n" + @@ -212,6 +212,120 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report + + + //结算表中订单日期也要合并 + var sql10 = "SELECT DISTINCT\n" + + " t1.* \n" + + "FROM\n" + + " (\n" + + " SELECT CONVERT\n" + + " ( VARCHAR ( 100 ), a.SpareDate, 23 ) AS AcceptanceDate,\n" + + " PurchaseOrderNo KanbanNumber,\n" + + " b2.MaterialCode \n" + + " FROM\n" + + " Set_SparePart a\n" + + " LEFT JOIN Set_material b2 ON a.MaterialCode = b2.CustomerPartCode \n" + + " WHERE\n" + + " a.Extend != 'is90' \n" + + " AND a.PurchaseOrderNo != 'NoOrder' \n" + + " AND a.Version = '{0}' \n" + + " ) t1\n" + + " LEFT JOIN (\n" + + " SELECT\n" + + " PurchaseOrderNo KanbanNumber,\n" + + " MaterialCode \n" + + " FROM\n" + + " Set_SparePart a \n" + + " WHERE\n" + + " a.Extend != 'is90' \n" + + " AND a.PurchaseOrderNo != 'NoOrder' \n" + + " AND a.Version = '{0}' \n" + + " GROUP BY\n" + + " PurchaseOrderNo,\n" + + " MaterialCode \n" + + " HAVING\n" + + " COUNT ( * ) > 1 \n" + + " ) t2 ON t1.KanbanNumber = t2.KanbanNumber \n" + + " AND t1.MaterialCode = t2.MaterialCode \n" + + "WHERE\n" + + " t2.KanbanNumber IS NULL"; + + + var list11 = DbConnection.Query(string.Format(sql10, version)); + + + + + + var sql11 = "SELECT DISTINCT\n" + + " t1.* \n" + + "FROM\n" + + " (\n" + + " SELECT CONVERT\n" + + " ( VARCHAR ( 100 ), a.SpareDate, 23 ) AS AcceptanceDate,\n" + + " PurchaseOrderNo KanbanNumber,\n" + + " b2.MaterialCode \n" + + " FROM\n" + + " Set_SparePart a\n" + + " LEFT JOIN Set_material b2 ON a.MaterialCode = b2.CustomerPartCode \n" + + " WHERE\n" + + " a.Extend != 'is90' \n" + + " AND a.PurchaseOrderNo != 'NoOrder' \n" + + " AND a.Version = '{0}' \n" + + " ) t1\n" + + " INNER JOIN (\n" + + " SELECT\n" + + " PurchaseOrderNo KanbanNumber,\n" + + " MaterialCode \n" + + " FROM\n" + + " Set_SparePart a \n" + + " WHERE\n" + + " a.Extend != 'is90' \n" + + " AND a.PurchaseOrderNo != 'NoOrder' \n" + + " AND a.Version = '{0}' \n" + + " GROUP BY\n" + + " PurchaseOrderNo,\n" + + " MaterialCode \n" + + " HAVING\n" + + " COUNT ( * ) > 1 \n" + + " ) t2 ON t1.KanbanNumber = t2.KanbanNumber \n" + + " AND t1.MaterialCode = t2.MaterialCode \n" + + "ORDER BY\n" + + " t1.KanbanNumber,\n" + + " t1.MaterialCode"; + + + var list12 = DbConnection.Query(string.Format(sql11, version)); + + + List _lscopy = new List(); + + foreach (var itm in list11) + { + var first = _lscopy.FirstOrDefault(p => p.KanbanNumber == itm.KanbanNumber && p.MaterialCode == itm.MaterialCode); + if (first != null) + { + first.AcceptanceDate += "," + itm.AcceptanceDate; + } + else + { + _lscopy.Add(itm); + } + } + foreach (var itm in list12) + { + _lscopy.Add(itm); + } + + + + + + + + + List _ls = new List(); foreach (var itm in listCompare.ToList()) { @@ -257,6 +371,12 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report itm1.交货日期 = itm.WmsDate; } + var itmcopy = _lscopy.FirstOrDefault(p => p.KanbanNumber == itm1.采购订单号 && p.MaterialCode == itm1.SAP编码); + if (itmcopy != null) + { + itm1.订单日期 = itmcopy.AcceptanceDate; + } + }