Commit a58fd3f3 authored by zhangsen's avatar zhangsen

bug

parent ac974e93
......@@ -79,8 +79,18 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "风机布置图 - 风机状态统计")
@GetMapping("/getFanStatusStatistics")
public ResponseModel<Map<String, Long>> getFanStatusStatistics(@RequestParam(value = "stationId", required = false) String stationId) {
return ResponseHelper.buildResponse(monitorFanIndicator.getFanStatusStatistics(stationId));
public ResponseModel<IPage<IndexDto>> getFanStatusStatistics(@RequestParam(value = "stationId", required = false) String stationId,
@RequestParam(value = "current", required = false) int current,
@RequestParam(value = "size", required = false) int size) {
List<IndexDto> fanStatusStatistics = monitorFanIndicator.getFanStatusStatistics(stationId);
Page<IndexDto> page = new Page<>(current, size);
List<IndexDto> collect = fanStatusStatistics.stream()
.skip((long) (current - 1) * size)
.limit(size)
.collect(Collectors.toList());
page.setTotal(fanStatusStatistics.size());
page.setRecords(collect);
return ResponseHelper.buildResponse(page);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
......
......@@ -251,13 +251,20 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
return equipNumList;
}
public Map<String, Long> getFanStatusStatistics(String stationId) {
public List<IndexDto> getFanStatusStatistics(String stationId) {
StationBasic stationBasic = getOneByStationNumber(stationId);
String sql = String.format("SELECT equipmentNumber, equipmentIndexName FROM \"indicators_%s\" WHERE equipmentIndexName =~/^正常运行|告警运行|正常停机|故障停机|限功率|待机状态|维护状态|通讯中断$/ and value = 'true'", stationBasic.getFanGatewayId());
List<IndexDto> influxDBList = influxDButils.getListData(sql, IndexDto.class);
// key:状态 value:数量
Map<String, Long> collect = influxDBList.stream().collect(Collectors.groupingBy(IndexDto::getEquipmentIndexName, Collectors.counting()));
return collect;
List<String> list = Arrays.asList("正常运行", "告警运行", "正常停机", "故障停机", "限功率", "待机状态", "维护状态", "通讯中断");
List<IndexDto> resultList = new ArrayList<>();
list.forEach(item -> {
IndexDto indexDto = new IndexDto();
indexDto.setCount(Math.toIntExact(collect.getOrDefault(item, 0L)));
indexDto.setEquipmentIndexName(item);
resultList.add(indexDto);
});
return resultList;
}
public IndexDto getFanBasicInfoByEquipNum(String equipNum, String 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