Commit 3441dd41 authored by zhangsen's avatar zhangsen

监盘大屏 - 获取历史告警数据

parent a0c201ac
......@@ -65,7 +65,15 @@ public class DeviceController extends BaseController {
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "监盘大屏 - 获取历史告警数据")
@GetMapping("/historyNationwideByPage")
public ResponseModel<Page<IndexDto>> historyNationwideByPage(@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size,
@RequestParam(value = "stationBasicId") String stationBasicId) {
Page<IndexDto> resultsData = monitorFanIndicatorImpl.historyNationwideByPage( current, size, stationBasicId);
return ResponseHelper.buildResponse(resultsData);
}
......
......@@ -34,6 +34,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.velocity.runtime.directive.Break;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.elasticsearch.common.recycler.Recycler;
import org.elasticsearch.index.Index;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -192,6 +193,29 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
}
public Page<IndexDto> historyNationwideByPage(int current, int size, String stationBasicId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationBasicId);
String gateway = stationBasic.getFanGatewayId();
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 ");
gateway = String.format("'%s'", gateway);
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);
//对于查询到的告警信息进行按照时间顺序进行排序
ArrayList<IndexDto> lisSort= (ArrayList<IndexDto>) list.stream().sorted(Comparator.comparing(IndexDto::getTimeString,Comparator.comparingLong(Long::parseLong)).reversed()).collect(Collectors.toList());
Page<IndexDto> indexDtoPage = new Page<>();
indexDtoPage.setTotal(list1.size());
indexDtoPage.setRecords(lisSort);
indexDtoPage.setCurrent(current);
indexDtoPage.setSize(size);
return indexDtoPage;
}
public IPage<IndexDto> getFanIdxInfoByPage(String equipNum, String stationId, String frontModule, int current, int size, String systemType) {
StationBasic stationBasic = getOneByStationNumber(stationId);
......
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