" ( SELECT SUM ( ReceiptQty ) Qty, PurchaseOrderNo, MaterialCode FROM Set_WMSSparePart GROUP BY PurchaseOrderNo, MaterialCode ) temp1\n"+
" LEFT JOIN ( SELECT SUM ( ReceiptQty ) Qty, PurchaseOrderNo, MaterialCode FROM Set_SparePart WHERE VERSION < '{0}' AND Extend != 'is90' GROUP BY PurchaseOrderNo, MaterialCode ) 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"+
" WHERE\n"+
" C.PurchaseOrderNo is null and C.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";
" 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"+
" ) AS temp1\n"+
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE Version = ( SELECT MAX ( VERSION ) FROM Set_PriceList ) ) AS TEMP2 ON temp1.SAP编码 = TEMP2.MaterialCode";
" ( 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"+
" ( 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);
//发运数据中,查出看板号+物料号相同的重复数据
varsql2="SELECT\n"+
" a.WMSDeliveryNote WmsBillNum,\n"+
" t1.MaterialCode MaterialCode,\n"+
" a.PurchaseOrderNo Kanban ,\n"+
" A.SpareDate WmsDate \n"+
"FROM\n"+
" Set_WMSSparePart A\n"+
" INNER JOIN ( SELECT MaterialCode, PurchaseOrderNo FROM Set_WMSSparePart GROUP BY MaterialCode, PurchaseOrderNo HAVING COUNT ( * ) > 1 ) B ON A.PurchaseOrderNo = B.PurchaseOrderNo \n"+
" AND A.MaterialCode = B.MaterialCode\n"+
" LEFT JOIN Set_material t1 ON a.MaterialCode= t1.CustomerPartCode \n"+
" LEFT JOIN ( SELECT MaterialCode, PurchaseOrderNo FROM Set_WMSSparePart GROUP BY MaterialCode, PurchaseOrderNo HAVING COUNT ( * ) > 1 ) B ON A.PurchaseOrderNo = B.PurchaseOrderNo \n"+
" AND A.MaterialCode = B.MaterialCode\n"+
" LEFT JOIN Set_material t1 ON a.MaterialCode= t1.CustomerPartCode \n"+