Commit 309be22e authored by caotao's avatar caotao

告警信息按照时间降序处理

parent 3c56d3cb
......@@ -41,4 +41,8 @@ public class IndexDto {
private String displayName;
private String pictureName;
private String title;
//对于创建时间进行处理用于列表排序
public String getTimeString(){
return getCreatedTime().replace("-","").replace(" ","").replace(":","");
}
}
......@@ -119,9 +119,6 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
@Override
public ResultsData getNationWideInfo(int current, int size, String gateway, String equipmentNumber) {
Page<IndexDto> page = new Page<IndexDto>();
page.setCurrent(current);
page.setSize(size);
String table = gateway;
StringBuffer querysql = new StringBuffer("SELECT createdTime ,equipmentNumber,gatewayId,address,valueLabel,equipmentSpecificName,value FROM indicators_%s WHERE isAlarm='1' and value!='0.0' and value!=valueLabel and gatewayId= %s ORDER BY time desc LIMIT %d OFFSET %d ");
StringBuffer querysqlcount = new StringBuffer("SELECT count(value) FROM indicators_%s WHERE isAlarm='1' and value!='0.0' and value!=valueLabel and gatewayId= %s ");
......@@ -131,14 +128,15 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} else {
gateway = String.format("'%s'", gateway);
}
String querysqln = String.format(querysql.toString(), table, gateway, (int) page.getSize(), (int) (page.getCurrent() - 1) * page.getSize());
String querysqln = String.format(querysql.toString(), table, gateway, size, (current - 1) * size);
String querysqlcountn = String.format(querysqlcount.toString(), table, gateway);
//每个分机的指标数据
List<IndexDto> list = influxDButils.getListData(querysqln, IndexDto.class);
List<IndexDto> list1 = influxDButils.getListData(querysqlcountn, IndexDto.class);
page.setRecords(list);
//对于查询到的告警信息进行按照时间顺序进行排序
ArrayList<IndexDto> lisSort= (ArrayList<IndexDto>) list.stream().sorted(Comparator.comparing(IndexDto::getTimeString,Comparator.comparingLong(Long::parseLong)).reversed()).collect(Collectors.toList());
//构建平台数据
DataGridMock DataGridMock = new DataGridMock(current, !list1.isEmpty()? list1.get(0).getCount() : 0, false, current, list);
DataGridMock DataGridMock = new DataGridMock(current, !list1.isEmpty()? list1.get(0).getCount() : 0, false, current, lisSort);
ColModel colModelequipmentNumber = new ColModel("equipmentNumber", "equipmentNumber", "风机号", "风机号", "dataGrid", "equipmentNumber");
ColModel colModelvalueLabel = new ColModel("valueLabel", "valueLabel", "事件描述", "事件描述", "dataGrid", "valueLabel");
ColModel colModelcreatedTime = new ColModel("createdTime", "createdTime", "发生时间", "发生时间", "dataGrid", "createdTime");
......@@ -156,9 +154,6 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
public ResultsData getLsNationWideInfo(int current, int size, String stationBasicId, String equipmentNumber) {
StationBasic stationBasic = stationBasicMapper.selectById(stationBasicId);
String gateway = stationBasic.getFanGatewayId();
Page<IndexDto> page = new Page<IndexDto>();
page.setCurrent(current);
page.setSize(size);
String table = gateway;
StringBuffer querysql = new StringBuffer("SELECT createdTime ,gatewayId,address,valueLabel,equipmentSpecificName,value FROM iot_data_%s WHERE isAlarm='1' and value!=valueLabel and value!='0.0' and gatewayId= %s ORDER BY time desc LIMIT %d OFFSET %d ");
StringBuffer querysqlcount = new StringBuffer("SELECT count(value) FROM iot_data_%s WHERE isAlarm='1' and value!='0.0' and value!=valueLabel and gatewayId= %s ");
......@@ -168,14 +163,15 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} else {
gateway = String.format("'%s'", gateway);
}
String querysqln = String.format(querysql.toString(), table, gateway, (int) page.getSize(), (int) (page.getCurrent() - 1) * page.getSize());
String querysqln = String.format(querysql.toString(), table, gateway, size, (current - 1) *size);
String querysqlcountn = String.format(querysqlcount.toString(), table, gateway);
//每个分机的指标数据
List<IndexDto> list = influxDButils.getListData(querysqln, IndexDto.class);
List<IndexDto> list1 = influxDButils.getListData(querysqlcountn, IndexDto.class);
page.setRecords(list);
//对于查询到的告警信息进行按照时间顺序进行排序
ArrayList<IndexDto> lisSort= (ArrayList<IndexDto>) list.stream().sorted(Comparator.comparing(IndexDto::getTimeString,Comparator.comparingLong(Long::parseLong)).reversed()).collect(Collectors.toList());
//构建平台数据
DataGridMock DataGridMock = new DataGridMock(current, !list1.isEmpty() ? list1.get(0).getCount() : 0, false, current, list);
DataGridMock DataGridMock = new DataGridMock(current, !list1.isEmpty() ? list1.get(0).getCount() : 0, false, current, lisSort);
ColModel colModelequipmentNumber = new ColModel("equipmentNumber", "equipmentSpecificName", "风机号", "风机号", "dataGrid", "equipmentNumber");
ColModel colModelvalueLabel = new ColModel("valueLabel", "valueLabel", "事件描述", "事件描述", "dataGrid", "valueLabel");
ColModel colModelcreatedTime = new ColModel("createdTime", "createdTime", "发生时间", "发生时间", "dataGrid", "createdTime");
......
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