From 022566f2c228b1f4c34d2528669f97c253045a61 Mon Sep 17 00:00:00 2001 From: 44673626 <44673626@qq.com> Date: Mon, 4 Apr 2022 19:57:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E4=BC=97=E5=A4=87=E4=BB=B6=E6=9C=AA?= =?UTF-8?q?=E7=BB=93=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SettleSparePartDapperReportRepository.cs | 98 +++++++++++++++++-- .../Report/SettleSparePartExportService.cs | 1 + 2 files changed, 92 insertions(+), 7 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 9da565c1..e0ba4e0a 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 @@ -33,6 +33,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report public virtual List GetSettleSparePartReportList(string purchaseOrderNo, string version, string sapCode, string matialCode, string begintime, string endtime) { + string sqlString = "SELECT\n" + " union1.* \n" + "FROM\n" + @@ -649,7 +650,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report "FROM\n" + " (\n" + " SELECT\n" + - " a.Version AS 期间,\n" + " '' AS 采购订单文本,\n" + " NULL AS 交货日期,\n" + " c.MaterialCode AS SAP编码,\n" + @@ -662,11 +662,9 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " ISNULL( a.ReceiptQty, 0 ) AS 开票数量 ,\n" + " ISNULL( a.ReceiptQty, 0 ) * ISNULL( a.PurchasePriceNoTax, 0 ) AS 开票金额 \n" + " FROM\n" + - " ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, MaterialCode, PurchasePriceNoTax FROM Set_SparePart WHERE Extend != 'is90' GROUP BY MaterialCode, PurchasePriceNoTax ) 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" + + " ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, MaterialCode, PurchasePriceNoTax FROM Set_SparePart WHERE Extend != 'is90' AND Version = '{0}' GROUP BY MaterialCode, PurchasePriceNoTax ) 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" + - " 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"; @@ -801,7 +799,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " ( 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" + + " LEFT JOIN ( SELECT SUM ( ReceiptQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE Extend != 'is90' 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" + @@ -844,7 +842,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " ( 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" + + " INNER JOIN ( SELECT SUM ( ReceiptQty ) ReceiptQty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE Extend != 'is90' 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" + @@ -855,6 +853,92 @@ 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); 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 874c34d2..78a33cbe 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleSparePartExportService.cs @@ -44,6 +44,7 @@ namespace SettleAccount.Job.Services.Report 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 _ls = _dapper.GetSettleSparePartReportList(purchaseOrderNo, version, sapCode, matialCode, beginTime, endTime);