Commit a05aa7fd authored by tangwei's avatar tangwei

增加历史接口

parent 7065f92c
...@@ -39,7 +39,7 @@ public class DeviceController extends BaseController { ...@@ -39,7 +39,7 @@ public class DeviceController extends BaseController {
MonitorFanIndicatorImpl monitorFanIndicatorImpl; MonitorFanIndicatorImpl monitorFanIndicatorImpl;
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "获取告警数据") @ApiOperation(value = "获取每个风机实时告警数据")
@GetMapping("/nationwide") @GetMapping("/nationwide")
public ResponseModel<ResultsData> getNationWideInfo(@RequestParam(value = "current") int current,@RequestParam public ResponseModel<ResultsData> getNationWideInfo(@RequestParam(value = "current") int current,@RequestParam
(value = "size") int size,@RequestParam(value = "stationBasicId") String stationBasicId,@RequestParam(value = "equipmentNumber" , required = false ) String equipmentNumber) { (value = "size") int size,@RequestParam(value = "stationBasicId") String stationBasicId,@RequestParam(value = "equipmentNumber" , required = false ) String equipmentNumber) {
...@@ -49,6 +49,14 @@ public class DeviceController extends BaseController { ...@@ -49,6 +49,14 @@ public class DeviceController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "获取历史告警数据")
@GetMapping("/historyNationwide")
public ResponseModel<ResultsData> getLSNationWideInfo(@RequestParam(value = "current") int current,@RequestParam
(value = "size") int size,@RequestParam(value = "stationBasicId") String stationBasicId,@RequestParam(value = "equipmentNumber" , required = false ) String equipmentNumber) {
ResultsData resultsData=monitorFanIndicatorImpl.getLsNationWideInfo( current, size, stationBasicId, equipmentNumber);
return ResponseHelper.buildResponse(resultsData);
}
......
...@@ -16,4 +16,5 @@ public interface IMonitorFanIndicator { ...@@ -16,4 +16,5 @@ public interface IMonitorFanIndicator {
void UpdateMonitorFanIndicator(List<IndexDto> list); void UpdateMonitorFanIndicator(List<IndexDto> list);
ResultsData getNationWideInfo( int current, int size, String stationBasicId, String equipmentNumber); ResultsData getNationWideInfo( int current, int size, String stationBasicId, String equipmentNumber);
ResultsData getLsNationWideInfo( int current, int size, String stationBasicId, String equipmentNumber);
} }
...@@ -92,7 +92,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -92,7 +92,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
List<IndexDto> list1 = influxDButils.getListData(querysqlcountn,IndexDto.class); List<IndexDto> list1 = influxDButils.getListData(querysqlcountn,IndexDto.class);
page.setRecords(list); page.setRecords(list);
//构建平台数据 //构建平台数据
DataGridMock DataGridMock=new DataGridMock(current, list1.get(0).getCount(), false, current, list); DataGridMock DataGridMock=new DataGridMock(current, list1!=null?list1.get(0).getCount():0, false, current, list);
ColModel colModelequipmentNumber=new ColModel("equipmentNumber", "equipmentNumber", "风机号", "风机号", "dataGrid", "equipmentNumber"); ColModel colModelequipmentNumber=new ColModel("equipmentNumber", "equipmentNumber", "风机号", "风机号", "dataGrid", "equipmentNumber");
ColModel colModelvalueLabel=new ColModel("valueLabel", "valueLabel", "事件描述", "事件描述", "dataGrid", "valueLabel"); ColModel colModelvalueLabel=new ColModel("valueLabel", "valueLabel", "事件描述", "事件描述", "dataGrid", "valueLabel");
ColModel colModelcreatedTime=new ColModel("createdTime", "createdTime", "发生时间", "发生时间", "dataGrid", "createdTime"); ColModel colModelcreatedTime=new ColModel("createdTime", "createdTime", "发生时间", "发生时间", "dataGrid", "createdTime");
...@@ -106,6 +106,51 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -106,6 +106,51 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
return resultsData; return resultsData;
} }
@Override
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!='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 gatewayId= %s ");
if(StringUtils.isNotEmpty(equipmentNumber)){
String date = " '%s' and equipmentSpecificName=~/.*%s风机.*/ ";
gateway= String.format(date,gateway,equipmentNumber);
}else{
gateway=String.format("'%s'",gateway);
}
String querysqln= String.format(querysql.toString(),table,gateway, (int)page.getSize(),(int)(page.getCurrent() - 1)*page.getSize());
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);
//构建平台数据
DataGridMock DataGridMock=new DataGridMock(current, list1!=null?list1.get(0).getCount():0, false, current, list);
ColModel colModelequipmentNumber=new ColModel("equipmentNumber", "equipmentSpecificName", "风机号", "风机号", "dataGrid", "equipmentNumber");
ColModel colModelvalueLabel=new ColModel("valueLabel", "valueLabel", "事件描述", "事件描述", "dataGrid", "valueLabel");
ColModel colModelcreatedTime=new ColModel("createdTime", "createdTime", "发生时间", "发生时间", "dataGrid", "createdTime");
ColModel colModelvalue=new ColModel("value", "value", "告警值", "告警值", "dataGrid", "value");
List<ColModel> listColModel=new ArrayList<>();
listColModel.add(colModelequipmentNumber);
listColModel.add(colModelvalueLabel);
listColModel.add(colModelcreatedTime);
listColModel.add(colModelvalue);
ResultsData resultsData=new ResultsData(DataGridMock,listColModel);
return resultsData;
}
public IPage<IndexDto> getFanIdxInfoByPage(String equipNum, String stationId, String frontModule, int current, int size, String systemType) { public IPage<IndexDto> getFanIdxInfoByPage(String equipNum, String stationId, String frontModule, int current, int size, String systemType) {
StationBasic stationBasic = getOneByStationNumber(stationId); StationBasic stationBasic = getOneByStationNumber(stationId);
Page<IndexDto> page = new Page<>(current, size); Page<IndexDto> page = new Page<>(current, size);
......
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