" ( SELECT SUM ( WMSDeliveryQty ) WMSDeliveryQty, MaterialCode, Kanban FROM Set_WMSKanBanSettle WHERE 1 = 1 {1} GROUP BY MaterialCode, Kanban ) A\n"+
" INNER JOIN ( SELECT SUM ( Qty ) Qty, Kanban, Extend1 AS MaterialCode FROM Set_WmsKanbanOutPutDetial {0} GROUP BY Kanban, Extend1 ) B ON A.Kanban = B.Kanban \n"+
" AND A.MaterialCode = B.MaterialCode\n"+
" LEFT JOIN Set_material AS C ON a.MaterialCode = C.CustomerPartCode\n"+
" LEFT JOIN set_backQty AS tt ON a.Kanban = tt.Code \n"+
" AND c.MaterialCode = tt.MaterialCode \n"+
" WHERE\n"+
" a.WMSDeliveryQty> B.Qty \n"+
" AND ( a.WMSDeliveryQty- tt.Qty ) != B.Qty \n"+
" ) TEMP1\n"+
" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) TEMP2 ON TEMP1.SapCode = TEMP2.MaterialCode \n"+
" ) UNION1\n"+
" LEFT JOIN temp_vwkanban UNION2 ON UNION1.Kanban= UNION2.[看板号] \n"+
" AND UNION1.CustomerPartCode= UNION2.[客户零件号] \n"+
//" ( SELECT SUM ( WMSDeliveryQty ) WMSDeliveryQty, MaterialCode, Kanban FROM Set_WMSKanBanSettle WHERE 1 = 1 {1} GROUP BY MaterialCode, Kanban ) A\n" +
//" LEFT JOIN ( SELECT SUM ( Qty ) Qty, Kanban, Extend1 AS MaterialCode FROM Set_WmsKanbanOutPutDetial {0} GROUP BY Kanban, Extend1 ) B ON A.Kanban = B.Kanban \n" +
//" AND A.MaterialCode = B.MaterialCode\n" +
//" LEFT JOIN Set_material AS C ON a.MaterialCode = C.CustomerPartCode\n" +
//" LEFT JOIN set_backQty AS tt ON a.Kanban = tt.Code \n" +
//" AND c.MaterialCode = tt.MaterialCode \n" +
//" WHERE\n" +
//" B.Kanban IS NULL \n" +
//" AND B.MaterialCode IS NULL \n" +
//" ) TEMP1\n" +
//" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = '202110' ) TEMP2 ON TEMP1.SapCode = TEMP2.MaterialCode \n" +
//" ) UNION1\n" +
//" LEFT JOIN temp_vwkanban UNION2 ON UNION1.Kanban= UNION2.[看板号] \n" +
//" AND UNION1.CustomerPartCode= UNION2.[客户零件号] \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, MaterialCode FROM Set_WmsSharePart90OutPutDetial WHERE State = 2 GROUP BY OrderBillNum, MaterialCode ) AS b ON a.PurchaseOrderNo= b.OrderBillNum \n"+
" AND a.SapCode = b.MaterialCode \n"+
" WHERE\n"+
" b.OrderBillNum IS NULL \n"+
" AND b.MaterialCode IS NULL \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 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, MaterialCode FROM Set_WmsSharePart90OutPutDetial WHERE State = 2 GROUP BY OrderBillNum, MaterialCode ) AS b ON a.PurchaseOrderNo= b.OrderBillNum \n"+
" AND a.SapCode = b.MaterialCode \n"+
" WHERE\n"+
" b.OrderBillNum IS NULL \n"+
" AND b.MaterialCode IS NULL \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"+
" INNER JOIN ( SELECT SUM ( Qty ) ReceiptQty, OrderBillNum, MaterialCode FROM Set_WmsSharePart90OutPutDetial WHERE State = 2 GROUP BY OrderBillNum, MaterialCode ) AS b ON a.PurchaseOrderNo= b.OrderBillNum \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 ) 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 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, MaterialCode FROM Set_WmsSharePart90OutPutDetial WHERE State = 2 GROUP BY OrderBillNum, MaterialCode ) AS b ON a.PurchaseOrderNo= b.OrderBillNum \n" +
//" AND a.SapCode = b.MaterialCode \n" +
//" WHERE\n" +
//" b.OrderBillNum IS NULL \n" +
//" AND b.MaterialCode IS NULL \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" +