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 89e6b2bc..0e07d3ff 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePart90AppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePart90AppService.cs @@ -457,7 +457,8 @@ namespace Win.Sfs.SettleAccount.Entities.WMS { WmsSharePart90OutPutDetial _detail = new WmsSharePart90OutPutDetial( GuidGenerator.Create(), - itm.WmsBillNum, + //itm.WmsBillNum, + string.Empty, itm.OrderBillNum, itm.MaterialCode, 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 3c89a8b0..ff2bbb9e 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePartAppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSSharePartAppService.cs @@ -482,7 +482,7 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts string.Empty, string.Empty, 0, - !string.IsNullOrEmpty(p.Extend1) ? p.Extend1 : string.Empty, + !string.IsNullOrEmpty(itm.Extend1) ? itm.Extend1 : string.Empty, string.Empty, version, itm.ParentMaterialCode, 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 43a17053..f5f22be1 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 @@ -22,204 +22,153 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report //string state, DateTime begin, DateTime end) + /// + /// 带采购订单号和无订单号一起统计报表 + /// + /// + /// + /// + /// + /// + /// + /// public virtual List GetSettleSparePartReportList(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.Version AS 期间,\n" + - //" a.PurchaseOrderNoText AS 采购订单文本,\n" + - //" b.WMSDeliveryNote AS 交货单号,\n" + - //" b.SpareDate AS 交货日期,\n" + - //" a.PurchaseOrderNo AS 采购订单号,\n" + - //" b.SapCode 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\n" + - //" t.ReceiptQty,\n" + - //" t.PurchaseOrderNo,\n" + - //" t.Version,\n" + - //" t.PurchasePriceNoTax,\n" + - //" t.InvoicedQty,\n" + - //" t.AmountNoTax,\n" + - //" t.PurchaseOrderNoText,\n" + - //" ( SELECT MaterialCode FROM Set_material WHERE CustomerPartCode = t.MaterialCode ) AS SapCode \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 \n" + - //" WHERE\n" + - //" Extend != 'is90' \n" + - //" GROUP BY\n" + - //" PurchaseOrderNo,\n" + - //" MaterialCode,\n" + - //" Version,\n" + - //" PurchasePriceNoTax,\n" + - //" InvoicedQty,\n" + - //" PurchaseOrderNoText,\n" + - //" AmountNoTax \n" + - //" ) t \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.SapCode = b.SapCode\n" + - //" LEFT OUTER JOIN ( SELECT MAX ( Id ) Id, MaterialCode, MaterialDesc, EstimateTypeDesc FROM Set_material GROUP BY MaterialCode, MaterialDesc, EstimateTypeDesc ) AS c ON b.SapCode = c.MaterialCode \n" + - //" WHERE\n" + - //" ( a.Version = '{0}' ) \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 sqlString = "SELECT\n" + - " temp1.交货日期,\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" + - " b.SpareDate 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' GROUP BY MaterialCode, Version, PurchasePriceNoTax ) AS a\n" + - " LEFT JOIN ( SELECT SUM ( ReceiptQty ) AS ReceiptQty, SapCode, MaterialCode, SpareDate FROM Set_WMSSparePart GROUP BY SapCode, MaterialCode, SpareDate ) 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}' and b.MaterialCode 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"; - 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(); + " 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 \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 = ( SELECT MAX ( Version ) AS Expr1 FROM Set_PriceList ) ) ) 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' 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 = ( SELECT MAX ( Version ) AS Expr1 FROM Set_PriceList ) ) ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode \n" + + " ) union2"; - } - public virtual List GetSettleSparePartNoOrderList(string purchaseOrderNo, string version, string sapCode, string matialCode, - string begintime, string endtime) - { - string sqlString = " SELECT \n" + - " * , \n" + - " (Price-InvoicePrice) as InvoiceDiffPrice, --单价差异 \n" + - " ISNULL( Price * ReceiptQty-InvoiceMoney, 0 ) AS SumDiffMoney --总金额差异 \n" + - " FROM \n" + - " ( \n" + - " SELECT \n" + - " c.Period as WMSDeliveryDate,--交货日期 \n" + - " c.WMSDeliveryNote,--交货单号 \n" + - " c.SpareDate as OrderDate,--订单日期 \n" + - " a.PurchaseOrderNo,--采购订单号 \n" + - " b.MaterialCode as SAPCode,--SAP编码,即厂内物料号 \n" + - " a.MaterialCode,--物料代码 \n" + - " b.MaterialDesc,--物料描述 \n" + - " a.PurchaseOrderNoText,--采购订单文本 \n" + - " c.ReceiptQty,-- 发货数量 \n" + - " a.InvoicedQty as InvoicedQty,--开票数量 \n" + - " (c.ReceiptQty-d.Amt) as SettleInvoiceDiffQty,--发货与开票差异 \n" + - " d.InvoicePrice,--开票单价 \n" + - " 0 as InvoiceMoney --开票金额 \n" + - " \n" + - " FROM \n" + - " Set_SparePart AS a \n" + - " LEFT JOIN Set_material AS b ON a.MaterialCode= b.CustomerPartCode \n" + - " LEFT JOIN Set_WMSSparePart c ON a.PurchaseOrderNo= c.WMSDeliveryNote \n" + - " AND a.MaterialCode= c.MaterialCode \n" + - " LEFT JOIN ( SELECT SUM ( amt ) / SUM ( Qty ) InvoicePrice, MaterialCode,Amt FROM set_invoice WHERE version = '{0}' GROUP BY materialcode,Amt ) d ON a.MaterialCode= d.MaterialCode \n" + - " ) TEMP1 \n" + - " LEFT JOIN ( SELECT Price, --定价 \n" + - " MaterialCode --厂内物料号 \n" + - " FROM Set_PriceList WHERE version = ( SELECT MAX ( Version ) FROM Set_PriceList_20 ) ) TEMP2 ON TEMP1.SAPCode= TEMP2.MaterialCode "; string addwhere = string.Empty; string addSqlStr = string.Format(sqlString, version); + //if (!string.IsNullOrEmpty(purchaseOrderNo)) //{ // addwhere += string.Format(" AND PurchaseOrderNo LIKE '{0}%' ", purchaseOrderNo); @@ -244,66 +193,70 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report } - public virtual List GetSettleSparePartSumQtyDiff(string version) + /// + /// 有发货无结算的报表统计 + /// + /// + /// + /// + /// + /// + /// + /// + public virtual List GetUnSettleSparePart90ReportList(string purchaseOrderNo, string version, string sapCode, string matialCode, + string begintime, string endtime) { string sqlString = "SELECT\n" + - " ISNULL( A.ReceiptQty - ISNULL( B.ReceiptQty, 0 ), 0 ) 数量差异,\n" + - " a.PurchaseOrderNo 订单号,\n" + - " a.SapCode 厂内物料号 \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" + - " t.ReceiptQty,\n" + - " t.PurchaseOrderNo,\n" + - " t.Version,\n" + - " t.PurchasePriceNoTax,\n" + - " ( SELECT MaterialCode FROM Set_material WHERE CustomerPartCode = t.MaterialCode ) AS SapCode \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" + - " (\n" + - " SELECT SUM\n" + - " ( ReceiptQty ) AS ReceiptQty,\n" + - " PurchaseOrderNo,\n" + - " MaterialCode,\n" + - " Version,\n" + - " PurchasePriceNoTax \n" + - " FROM\n" + - " Set_SparePart \n" + - " WHERE\n" + - " Version = '{0}' \n" + - " AND Extend != 'is90' \n" + - " GROUP BY\n" + - " PurchaseOrderNo,\n" + - " MaterialCode,\n" + - " Version,\n" + - " PurchasePriceNoTax \n" + - " ) t \n" + - " ) A\n" + - " LEFT 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" + - " ) B ON A.SapCode = B.SapCode \n" + - "WHERE\n" + - " ( A.ReceiptQty - ISNULL( B.ReceiptQty, 0 ) ) <> 0"; + " 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); - - var _query = DbConnection.Query(_sql, null, null, true, 1200, null); + //string _sql = string.Format(sqlString, version); + var _query = DbConnection.Query(_sql, null, null, true, 1200, null); return _query.ToList(); }