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 d49bc0a9..14860355 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSHQHKanbanAppService.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/WMS/WMSHQHKanbanAppService.cs @@ -474,9 +474,18 @@ namespace Win.Sfs.SettleAccount.Entities.SettleAccounts { checkList.Add(new ErrorExportDto(version, "红旗批量出库单导入", string.Empty, string.Empty, string.Empty, string.Empty, string.Format("导入模板中看板号{0}的结算数量为0,影响出库请检查!", itm.Kanban), string.Empty)); } + if(string.IsNullOrEmpty(itm.WmsBillNum)) + { + checkList.Add(new ErrorExportDto(version, "红旗批量出库单导入", string.Empty, string.Empty, string.Empty, string.Empty, string.Format("导入模板中看板号{0}的交货单号为空,影响出库请检查!", itm.Kanban), string.Empty)); + } } + if (checkList.Count > 0) + { + return await ExportErrorReportAsync(checkList); + } + List _lst = new List(); var _lsCopy = new List(); foreach (var itm in filteResult) diff --git a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQFactorySettledDetailDapperRepository.cs b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQFactorySettledDetailDapperRepository.cs index 0d25a824..48492c9c 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQFactorySettledDetailDapperRepository.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/HQFactorySettledDetailDapperRepository.cs @@ -676,7 +676,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " a.Kanban AS 订货看板编号,\n" + " b.MaterialCode AS 订货零件号,\n" + " c.MaterialCode Sap编码,\n" + - " c.CustomerPartCode 客户物料号,\n" + + " a.MaterialCode 客户物料号,\n" + " c.MaterialDesc AS 零件中文名称,\n" + " isnull( a.Qty, 0 ) AS 发货数量,\n" + " b.ExternalKanbanNumber AS 外部单号,\n" + @@ -722,7 +722,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " a.Kanban AS 订货看板编号,\n" + " b.MaterialCode AS 订货零件号,\n" + " c.MaterialCode Sap编码,\n" + - " c.CustomerPartCode 客户物料号,\n" + + " a.MaterialCode 客户物料号,\n" + " c.MaterialDesc AS 零件中文名称,\n" + " isnull( a.Qty, 0 ) AS 发货数量,\n" + " '' AS 外部单号,\n" + 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 ee330ebb..78b3e270 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 @@ -35,237 +35,237 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report { - 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" + - " ISNULL( TEMP4.PurchasePriceNoTax, 0 ) AS 开票单价,\n" + - " ISNULL( temp1.开票数量, 0 ) * ISNULL( TEMP4.PurchasePriceNoTax, 0 ) AS 开票金额,\n" + - " ISNULL( TEMP2.Price, 0 ) 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" + - " ISNULL( temp1.发货数量, 0 ) - ISNULL( temp1.开票数量, 0 ) - ISNULL( temp3.Qty, 0 ) AS 实际交货与开票差异,\n" + - " ISNULL( temp3.Qty, 0 ) 退货数量 \n" + - " FROM\n" + - " (\n" + - " SELECT\n" + - " a.PurchaseOrderNoText AS 采购订单文本,\n" + - " '' AS 交货单号,\n" + - " NULL AS 交货日期,\n" + - " a.PurchaseOrderNo AS 采购订单号,\n" + - " b.MaterialCode AS SAP编码,\n" + - " a.MaterialCode AS 物料代码,\n" + - " b.MaterialDesc AS 物料描述,\n" + - " b.EstimateTypeDesc AS 物料组,\n" + - " ISNULL( a.InvoicedQty, 0 ) AS 开票数量 ,\n" + - " ISNULL( C.Qty, 0 ) AS 发货数量,\n" + - " ISNULL( C.Qty, 0 ) - ISNULL( a.InvoicedQty, 0 ) AS 发货与开票差异 \n" + - " FROM\n" + - " (\n" + - " SELECT SUM\n" + - " ( 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" + - " ISNULL( temp1.Qty, 0 ) AS Qty,\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 (\n" + - " SELECT SUM\n" + - " ( InvoicedQty ) 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" + - " ) AS temp1\n" + - " LEFT JOIN ( SELECT * FROM set_backQty ) 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" + - " LEFT JOIN (\n" + - " SELECT\n" + - " ROUND( SUM ( AmountNoTax ) / SUM ( InvoicedQty ), 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"; + //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" + + // " ISNULL( TEMP4.PurchasePriceNoTax, 0 ) AS 开票单价,\n" + + // " ISNULL( temp1.开票数量, 0 ) * ISNULL( TEMP4.PurchasePriceNoTax, 0 ) AS 开票金额,\n" + + // " ISNULL( TEMP2.Price, 0 ) 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" + + // " ISNULL( temp1.发货数量, 0 ) - ISNULL( temp1.开票数量, 0 ) - ISNULL( temp3.Qty, 0 ) AS 实际交货与开票差异,\n" + + // " ISNULL( temp3.Qty, 0 ) 退货数量 \n" + + // " FROM\n" + + // " (\n" + + // " SELECT\n" + + // " a.PurchaseOrderNoText AS 采购订单文本,\n" + + // " '' AS 交货单号,\n" + + // " NULL AS 交货日期,\n" + + // " a.PurchaseOrderNo AS 采购订单号,\n" + + // " b.MaterialCode AS SAP编码,\n" + + // " a.MaterialCode AS 物料代码,\n" + + // " b.MaterialDesc AS 物料描述,\n" + + // " b.EstimateTypeDesc AS 物料组,\n" + + // " ISNULL( a.InvoicedQty, 0 ) AS 开票数量 ,\n" + + // " ISNULL( C.Qty, 0 ) AS 发货数量,\n" + + // " ISNULL( C.Qty, 0 ) - ISNULL( a.InvoicedQty, 0 ) AS 发货与开票差异 \n" + + // " FROM\n" + + // " (\n" + + // " SELECT SUM\n" + + // " ( 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" + + // " ISNULL( temp1.Qty, 0 ) AS Qty,\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 (\n" + + // " SELECT SUM\n" + + // " ( InvoicedQty ) 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" + + // " ) AS temp1\n" + + // " LEFT JOIN ( SELECT * FROM set_backQty ) 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" + + // " LEFT JOIN (\n" + + // " SELECT\n" + + // " ROUND( SUM ( AmountNoTax ) / SUM ( InvoicedQty ), 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"; //加上--往期已经字段 - //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" + - //" ISNULL( TEMP4.PurchasePriceNoTax, 0 ) AS 开票单价,\n" + - //" ISNULL( temp1.开票数量, 0 ) * ISNULL( TEMP4.PurchasePriceNoTax, 0 ) AS 开票金额,\n" + - //" ISNULL( TEMP2.Price, 0 ) 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" + - //" ISNULL( temp1.发货数量, 0 ) - ISNULL( temp1.开票数量, 0 ) - ISNULL( temp3.Qty, 0 ) AS 实际交货与开票差异,\n" + - //" ISNULL( temp3.Qty, 0 ) 退货数量,\n" + - //" ISNULL( TEMP5.Qty, 0 ) 往期已结 \n" + - //" FROM\n" + - //" (\n" + - //" SELECT\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.InvoicedQty, 0 ) AS 开票数量 ,\n" + - //" ISNULL( C.Qty, 0 ) AS 发货数量,\n" + - //" ISNULL( C.Qty, 0 ) - ISNULL( a.InvoicedQty, 0 ) AS 发货与开票差异 \n" + - //" FROM\n" + - //" (\n" + - //" SELECT SUM\n" + - //" ( 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" + - //" ISNULL( temp1.Qty, 0 ) AS Qty,\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 (\n" + - //" SELECT SUM\n" + - //" ( InvoicedQty ) 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" + - //" ) AS temp1\n" + - //" LEFT JOIN ( SELECT * FROM set_backQty ) 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" + - //" LEFT JOIN (\n" + - //" SELECT\n" + - //" ROUND( SUM ( AmountNoTax ) / SUM ( InvoicedQty ), 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" + - //" LEFT JOIN (\n" + - //" SELECT SUM\n" + - //" ( Qty ) Qty,\n" + - //" OrderBillNum,\n" + - //" Extend1 \n" + - //" FROM\n" + - //" Set_WmsSharePart90OutPutDetial \n" + - //" WHERE\n" + - //" Version < '{0}' \n" + - //" AND State = 2 \n" + - //" AND Extend1 != '' \n" + - //" GROUP BY\n" + - //" OrderBillNum,\n" + - //" Extend1 \n" + - //" ) AS TEMP5 ON temp1.采购订单号 = TEMP5.OrderBillNum \n" + - //" AND temp1.[物料代码] = TEMP5.Extend1 \n" + - //" ) union1"; + 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" + + " ISNULL( TEMP4.PurchasePriceNoTax, 0 ) AS 开票单价,\n" + + " ISNULL( temp1.开票数量, 0 ) * ISNULL( TEMP4.PurchasePriceNoTax, 0 ) AS 开票金额,\n" + + " ISNULL( TEMP2.Price, 0 ) 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" + + " ISNULL( temp1.发货数量, 0 ) - ISNULL( temp1.开票数量, 0 ) - ISNULL( temp3.Qty, 0 ) AS 实际交货与开票差异,\n" + + " ISNULL( temp3.Qty, 0 ) 退货数量,\n" + + " ISNULL( TEMP5.Qty, 0 ) 往期已结 \n" + + " FROM\n" + + " (\n" + + " SELECT\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.InvoicedQty, 0 ) AS 开票数量 ,\n" + + " ISNULL( C.Qty, 0 ) AS 发货数量,\n" + + " ISNULL( C.Qty, 0 ) - ISNULL( a.InvoicedQty, 0 ) AS 发货与开票差异 \n" + + " FROM\n" + + " (\n" + + " SELECT SUM\n" + + " ( 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" + + " ISNULL( temp1.Qty, 0 ) AS Qty,\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 (\n" + + " SELECT SUM\n" + + " ( InvoicedQty ) 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" + + " ) AS temp1\n" + + " LEFT JOIN ( SELECT * FROM set_backQty ) 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" + + " LEFT JOIN (\n" + + " SELECT\n" + + " ROUND( SUM ( AmountNoTax ) / SUM ( InvoicedQty ), 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" + + " LEFT JOIN (\n" + + " SELECT SUM\n" + + " ( Qty ) Qty,\n" + + " OrderBillNum,\n" + + " Extend1 \n" + + " FROM\n" + + " Set_WmsSharePart90OutPutDetial \n" + + " WHERE\n" + + " Version < '{0}' \n" + + " AND State = 2 \n" + + " AND Extend1 != '' \n" + + " GROUP BY\n" + + " OrderBillNum,\n" + + " Extend1 \n" + + " ) AS TEMP5 ON temp1.采购订单号 = TEMP5.OrderBillNum \n" + + " AND temp1.[物料代码] = TEMP5.Extend1 \n" + + " ) union1"; @@ -1286,7 +1286,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " MaterialCode\n" + " ) AS a\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" + -" LEFT JOIN ( SELECT SUM ( Qty ) Qty, OrderBillNum, Extend1 FROM Set_WmsSharePart90OutPutDetial WHERE State = 2 GROUP BY OrderBillNum, Extend1 ) AS b ON a.PurchaseOrderNo= b.OrderBillNum \n" + +" LEFT JOIN ( SELECT SUM ( Qty ) Qty, OrderBillNum, Extend1 FROM Set_WmsSharePart90OutPutDetial WHERE State = 2 and Extend1!='' GROUP BY OrderBillNum, Extend1 ) AS b ON a.PurchaseOrderNo= b.OrderBillNum \n" + " AND a.MaterialCode = b.Extend1 \n" + " WHERE\n" + " b.OrderBillNum IS NULL \n" + @@ -1343,7 +1343,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report " PurchaseOrderNo,\n" + " MaterialCode \n" + " ) a\n" + -" INNER JOIN ( SELECT SUM ( Qty ) ReceiptQty, OrderBillNum, Extend1 FROM Set_WmsSharePart90OutPutDetial WHERE State = 2 GROUP BY OrderBillNum, Extend1 ) AS b ON a.PurchaseOrderNo= b.OrderBillNum \n" + +" INNER JOIN ( SELECT SUM ( Qty ) ReceiptQty, OrderBillNum, Extend1 FROM Set_WmsSharePart90OutPutDetial WHERE State = 2 and Extend1!='' GROUP BY OrderBillNum, Extend1 ) AS b ON a.PurchaseOrderNo= b.OrderBillNum \n" + " AND a.MaterialCode = b.Extend1\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" +