From c023dda6759dbc1831ad5dad2e730000844b868a Mon Sep 17 00:00:00 2001 From: 44673626 <44673626@qq.com> Date: Sat, 29 Jan 2022 15:43:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=87=E4=BB=B6=E6=95=B0=E6=8D=AE=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=8F=8D=E5=90=91=E6=8A=A5=E8=A1=A8=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...SettleSparePart90DapperReportRepository.cs | 60 ++++++++++++++++++- .../Report/SettleSparePart90ExportService.cs | 22 +++++-- 2 files changed, 77 insertions(+), 5 deletions(-) diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePart90DapperReportRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePart90DapperReportRepository.cs index e00c9580..9383e6b7 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePart90DapperReportRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/SettleSparePart90DapperReportRepository.cs @@ -105,7 +105,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) AS Expr1 FROM Set_PriceList ) ) ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" + "ORDER BY\n" + " temp1.采购订单号"; - ; string addwhere = string.Empty; string addSqlStr = string.Format(sqlString, version); @@ -118,6 +117,65 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report } + public virtual List GetUnSettleSparePart90ReportList(string purchaseOrderNo, string version, string sapCode, string matialCode, + string begintime, string endtime) + { + string sqlString = "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.PurchaseOrderNo AS 采购订单号,\n" + + " a.WMSDeliveryNote AS 交货单号,\n" + + " a.SpareDate AS 交货日期,\n" + + " a.MaterialCode AS 物料代码,\n" + + " ISNULL( a.ReceiptQty, 0 ) AS 发货数量,\n" + + " c.MaterialCode AS SAP编码,\n" + + " c.MaterialDesc AS 物料描述,\n" + + " c.EstimateTypeDesc AS 物料组,\n" + + " b.Version AS 期间,\n" + + " b.PurchaseOrderNoText AS 采购订单文本,\n" + + " b.PurchasePriceNoTax AS 开票单价,\n" + + " 0 AS 数量差异,\n" + + " ISNULL( b.InvoicedQty, 0 ) AS 开票数量 ,\n" + + " ISNULL( b.AmountNoTax, 0 ) AS 开票金额 \n" + + " FROM\n" + + " Set_WMSSparePart a\n" + + " LEFT JOIN ( SELECT PurchaseOrderNo, Version, PurchaseOrderNoText, PurchasePriceNoTax, InvoicedQty, AmountNoTax FROM Set_SparePart WHERE Version = '{0}' ) b ON a.PurchaseOrderNo = b.PurchaseOrderNo\n" + + " LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" + + " WHERE\n" + + " b.PurchaseOrderNo IS NULL \n" + + " ) AS temp1\n" + + " LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) AS Expr1 FROM Set_PriceList ) ) ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" + + "ORDER BY\n" + + " temp1.采购订单号"; + + 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(); + + } + + //public virtual List GetSettleSparePart90SumQtyDiff(string version) //{ // string sqlString = "SELECT\n" + diff --git a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePart90ExportService.cs b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePart90ExportService.cs index 2e0537bf..133dbdb7 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePart90ExportService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePart90ExportService.cs @@ -1,11 +1,15 @@ -using System; +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 @@ -15,12 +19,15 @@ namespace SettleAccount.Job.Services.Report private readonly SettleSparePart90DapperReportRepository _dapper; private readonly OutputService _outputService; private readonly ErpPartDapperRepository _erpdapperRepository; + private readonly IBlobContainer _fileContainer; - public SettleSparePart90ExportService(SettleSparePart90DapperReportRepository dapper, ErpPartDapperRepository erpdapperRepository, OutputService outputService) + public SettleSparePart90ExportService(SettleSparePart90DapperReportRepository dapper, ErpPartDapperRepository erpdapperRepository, OutputService outputService, + IBlobContainer fileContainer) { _dapper = dapper; _outputService = outputService; _erpdapperRepository = erpdapperRepository; + _fileContainer = fileContainer; } @@ -34,6 +41,7 @@ namespace SettleAccount.Job.Services.Report var beginTime = p_list.Where(p => p.Name == "BegingTime").FirstOrDefault().Value; var endTime = p_list.Where(p => p.Name == "EndTime").FirstOrDefault().Value; var _ls = _dapper.GetSettleSparePart90ReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); + var _unls = _dapper.GetUnSettleSparePart90ReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime); //var diffList = _dapper.GetSettleSparePart90SumQtyDiff(version); //if (diffList != null) @@ -86,11 +94,17 @@ namespace SettleAccount.Job.Services.Report + ExcelExporter _exporter = new ExcelExporter();//导出Excel + var result = _exporter.Append(_ls.ToList(), "大众备件数据调整") + .SeparateBySheet() + .Append(_unls.ToList(), "有发货无结算") + .ExportAppendDataAsByteArray(); + result.ShouldNotBeNull(); + _fileContainer.SaveAsync(fileName, result.Result, true); - - _outputService.Export(id, fileName, _ls); + //_outputService.Export(id, fileName, _ls); return id.ToString();