" ) AS temp1 ON unhq.HQHKanBan = temp1.[订货看板编号] \n"+
" ) AS temp1 ON unhq.HQHKanBan = temp1.[订货看板编号] \n"+
" AND unhq.CustomerPartCode= temp1.客户物料号 -- WHERE\n"+
" AND unhq.CustomerPartCode= temp1.客户物料号 -- WHERE\n"+
"-- temp1.[订货看板编号] IS NULL\n"+
"-- temp1.[订货看板编号] IS NULL\n"+
"-- AND temp1.客户物料号 IS NULL\n"+
"-- AND temp1.客户物料号 IS NULL\n"+
" \n"+
" \n"+
" ) temp3\n"+
" ) temp3\n"+
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) ) AS TEMP2 ON temp3.MaterialCode = TEMP2.MaterialCode";
" LEFT OUTER JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE ( Version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) ) AS TEMP2 ON temp3.MaterialCode = TEMP2.MaterialCode";
var_sql=string.Format(str,condition);
var_sql=string.Format(str,condition);
varsql2="SELECT\n"+
" a.WmsBillNum,\n"+
" t1.MaterialCode MaterialCode,\n"+
" a.Kanban ,\n"+
" A.LastModificationTime WmsDate \n"+
"FROM\n"+
" Set_HQ_H_Kanban A\n"+
" INNER JOIN ( SELECT MaterialCode, Kanban FROM Set_HQ_H_Kanban GROUP BY MaterialCode, Kanban HAVING COUNT(*)> 1 ) B ON A.Kanban = B.Kanban \n"+
" AND A.MaterialCode = B.MaterialCode "+
" left join Set_material t1 on a.MaterialCode=t1.CustomerPartCode ";
// " INNER JOIN ( SELECT SUM ( Qty ) AS Qty, Kanban, MaterialCode FROM Set_HQ_H_Kanban GROUP BY Kanban, MaterialCode ) AS b ON a.HQHKanBan = b.Kanban \n" +
// " AND a.MaterialCode = b.MaterialCode\n" +
// " LEFT OUTER JOIN Set_material AS c ON a.MaterialCode = c.CustomerPartCode \n" +
// " WHERE\n" +
// " ( a.HQHKanBan <> 'BJ' AND a.HQHKanBan IS NOT NULL ) \n" +
// " AND a.Version= '{0}' \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\n" +
// " LEFT JOIN (\n" +
// " SELECT\n" +
// " ROUND( SUM ( Amt ) / SUM ( Qty ), 4 ) price,\n" +
// " HQHKanBan,\n" +
// " MaterialCode,\n" +
// " Version \n" +
// " FROM\n" +
// " Set_HQ_H_Platform \n" +
// " WHERE\n" +
// " HQHKanBan <> 'BJ' \n" +
// " AND Version = '{0}' \n" +
// " GROUP BY\n" +
// " HQHKanBan,\n" +
// " MaterialCode,\n" +
// " Version \n" +
// " ) AS TEMP3 ON temp1.[结算物料代码] = TEMP3.MaterialCode \n" +
" LEFT JOIN ( SELECT * FROM Set_KanBanSettle ) B ON A.Kanban = B.Kanban \n"+
" LEFT JOIN ( {1}) B ON A.Kanban = B.Kanban \n"+
" AND A.MaterialCode = B.MaterialCode\n"+
" AND A.MaterialCode = B.MaterialCode\n"+
" LEFT JOIN Set_material AS C ON a.MaterialCode = C.CustomerPartCode \n"+
" LEFT JOIN Set_material AS C ON a.MaterialCode = C.CustomerPartCode \n"+
" left join set_backQty as tt on a.Kanban = tt.Code and a.MaterialCode = b.MaterialCode \n"+
" left join set_backQty as tt on a.Kanban = tt.Code and a.MaterialCode = b.MaterialCode \n"+
" WHERE\n"+
" WHERE\n"+
" B.Kanban IS NULL \n"+
" B.Kanban IS NULL \n"+
" AND B.MaterialCode IS NULL {0}\n"+
" AND B.MaterialCode IS NULL {0}\n"+
" ) TEMP1\n"+
" ) TEMP1\n"+
" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) TEMP2 ON TEMP1.SapCode = TEMP2.MaterialCode";
" LEFT JOIN ( SELECT Price, MaterialCode FROM Set_PriceList WHERE version = ( SELECT MAX ( Version ) FROM Set_PriceList ) ) TEMP2 ON TEMP1.SapCode = TEMP2.MaterialCode";
stringstr=string.Empty;
sql=string.Format(sql,str,contion);
//str += " where 1=1 ";
if(!string.IsNullOrEmpty(begintime))
{
str+=string.Format(" and a.WMSActualGoodsDate >='{0}' ",begintime);
}
if(string.IsNullOrEmpty(endtime))
{
str+=string.Format(" and a.WMSActualGoodsDate<='{0}' ",endtime);