Set<String> queryFieldSet = new HashSet<String>();
//查询所有id;
queryFieldSet.add("id");
List<QueryCondition> queryConList = new ArrayList<QueryCondition>();
if (startTimestamp != null) {
queryConList.add(new QueryCondition("createTime",">=","'"+startTimestamp.toString() + "'"));
}
if (endTimestamp != null) {
queryConList.add(new QueryCondition("createTime","<=","'"+endTimestamp.toString() + "'"));
}
if (templateId != null) {
queryConList.add(new QueryCondition("templateId","=","'"+templateId.getValue() + "'"));
}
if (statisticVal.indexOf(",") != -1) {
StringBuffer queryValBuffer = new StringBuffer();
String[] valArr = statisticVal.split(",");
for (String val : valArr) {
queryValBuffer.append(queryValBuffer.length() > 0 ? "," : "").append("'" + val + "'");
}
queryConList.add(new QueryCondition(fieldColName,"in"," (" + queryValBuffer.toString() + ")"));
}else {
queryConList.add(new QueryCondition(fieldColName,"=","'"+statisticVal + "'"));
}
String idSql = DataFilterMemory.getQuerySql(tablesList, queryFieldSet, whereStr, null, isCurrent, templateId, queryConList);
List<Map<String, String>> allIdList = DbPoolConnection.getInstance().getResultSetListBySql(idSql);
for (Map<String, String> map : allIdList) {
allIdSet.add(map.get("id"));
}
}
StringBuffer idBuffer = new StringBuffer();
for (String id : allIdSet) {
idBuffer.append(idBuffer.length() > 0 ? "," : "").append("'" + id + "'");
}
List<QueryCondition> allQueryList = new ArrayList<QueryCondition>();
QueryCondition queryCondition = new QueryCondition("id","in"," (" + idBuffer.toString() + ") ");
allQueryList.add(queryCondition);
String sql = QueryUtil.getQuerySql(templateId,allQueryList);
return sql;
}