Commit 20ca2fe8 authored by tangwei's avatar tangwei

分页

parent 8ed79c9a
......@@ -18,4 +18,5 @@ public class IndexDto {
private String createdTime;// '上报时间',
private String equipmentSpecificName;//
private String value;
private int count;
}
......@@ -46,29 +46,42 @@ public class DeviceController extends BaseController {
page.setCurrent(current);
page.setSize(size);
StringBuffer querysql = new StringBuffer("SELECT createdTime ,gatewayId,address,valueLabel,equipmentSpecificName,value FROM iot_data WHERE isAlarm='1' and value!='0.0' and time > now() - 1d ");
StringBuffer querysqlcount = new StringBuffer("SELECT count(value) FROM iot_data WHERE isAlarm='1' and value!='0.0' and time > now() - 1d ");
if(StringUtils.isNotEmpty(gateway)){
String[] da= gateway.split(",");
for (int i = 0; i < da.length; i++) {
if(i==0){
querysql.append("and ( gatewayId = ").append("'"+da[i]+"'");
querysqlcount.append("and ( gatewayId = ").append("'"+da[i]+"'");
}else if(i==da.length-1){
querysql.append(" or gatewayId = ").append("'"+da[i]+"'").append(") ");
querysqlcount.append(" or gatewayId = ").append("'"+da[i]+"'").append(") ");
}else{
querysql.append(" or gatewayId = ").append("'"+da[i]+"'");
querysqlcount.append(" or gatewayId = ").append("'"+da[i]+"'");
}
}
}
querysql.append(" ORDER BY time desc LIMIT ").append(page.getSize()).append(" OFFSET ").append((page.getCurrent() - 1)*page.getSize());
//每个分机的指标数据
List<IndexDto> list = influxDButils.getListData(querysql.toString(),IndexDto.class);
List<IndexDto> list1 = influxDButils.getListData(querysqlcount.toString(),IndexDto.class);
page.setRecords(list);
if(list1!=null&&list1.size()>0){
page.setTotal(list1.get(0).getCount());
}
return ResponseHelper.buildResponse(page);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment