sql="select ts as time,nm as monitorId,v as monitorValue from "+countTableName+"_count where nm in("+fieldSqlPart+") and ts>=? and ts <? ";
if(timeType.equals("1")){
sql="select ts as time,nm as monitorId,v as monitorValue from "+countTableName+"_count where nm in("+fieldSqlPart+") and ts>='"+tsStartTime+"' and ts <'"+tsEndTime+"' ";
}
//日数据
if(tableType.equals("2")){
if(timeType.equals("2")){
sql="select aaa.date as time , aaa.monitorId ,SUM( to_number ( aaa.monitorValue, '9999999999999999.99' ) )as monitorValue from (";
sql+="select to_char(to_timestamp(ts::INT8)::DATE,'YYYY-MM-DD') as date, ts as time,nm as monitorId,v as monitorValue from "+countTableName+"_count where nm in("+fieldSqlPart+") and ts>=? and ts <? ";
sql+="select to_char(to_timestamp(ts::INT8)::DATE,'YYYY-MM-DD') as date, ts as time,nm as monitorId,v as monitorValue from "+countTableName+"_count where nm in("+fieldSqlPart+") and ts>='"+tsStartTime+"' and ts <'"+tsEndTime+"' ";
sql+=" )aaa group by aaa.date ,aaa.monitorId order by aaa.date asc";
}
//月数据
if(tableType.equals("3")){
if(timeType.equals("3")){
sql="select aaa.date as time , aaa.monitorId ,SUM( to_number ( aaa.monitorValue, '9999999999999999.99' ) )as monitorValue from (";
sql+="select to_char(to_timestamp(ts::INT8)::DATE,'YYYY-MM') as date, ts as time,nm as monitorId,v as monitorValue from "+countTableName+"_count where nm in("+fieldSqlPart+") and ts>=? and ts <? ";
sql+="select to_char(to_timestamp(ts::INT8)::DATE,'YYYY-MM') as date, ts as time,nm as monitorId,v as monitorValue from "+countTableName+"_count where nm in("+fieldSqlPart+") and ts>='"+tsStartTime+"' and ts <'"+tsEndTime+"' ";
sql+=" )aaa group by aaa.date ,aaa.monitorId order by aaa.date asc";