Commit e3f7d58b authored by tangwei's avatar tangwei

修改bug

parent 10a20d43
......@@ -6,6 +6,7 @@ import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.ColModel;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.DataGridMock;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.ResultsData;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.MonitorFanIndicatorImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -35,52 +36,14 @@ import java.util.List;
public class DeviceController extends BaseController {
@Autowired
InfluxDButils influxDButils;
MonitorFanIndicatorImpl monitorFanIndicatorImpl;
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "获取告警数据")
@GetMapping("/nationwide")
public ResponseModel<ResultsData> getNationWideInfo(@RequestParam(value = "current") int current,@RequestParam
(value = "size") int size,@RequestParam(value = "gateway") String gateway,@RequestParam(value = "equipmentNumber" , required = false ) 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 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 gatewayId= %s ");
if(StringUtils.isNotEmpty(equipmentNumber)){
String date ="'%s' and equipmentNumber = '%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.get(0).getCount(), false, current, list);
ColModel colModelequipmentNumber=new ColModel("equipmentNumber", "equipmentNumber", "风机号", "风机号", "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);
(value = "size") int size,@RequestParam(value = "stationBasicId") String stationBasicId,@RequestParam(value = "equipmentNumber" , required = false ) String equipmentNumber) {
ResultsData resultsData=monitorFanIndicatorImpl.getNationWideInfo( current, size, stationBasicId, equipmentNumber);
return ResponseHelper.buildResponse(resultsData);
}
......
package com.yeejoin.amos.boot.module.jxiop.biz.service;
import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.ResultsData;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
......@@ -13,4 +15,5 @@ public interface IMonitorFanIndicator {
//批量修改指标值
void UpdateMonitorFanIndicator(List<IndexDto> list);
ResultsData getNationWideInfo( int current, int size, String stationBasicId, String equipmentNumber);
}
......@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sun.org.apache.bcel.internal.generic.RETURN;
import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.RunRecord;
import com.yeejoin.amos.boot.module.jxiop.api.dto.TreeDto;
......@@ -14,12 +15,18 @@ import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.MonitorFanIndicatorMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.RegionMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.ColModel;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.DataGridMock;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.ResultsData;
import com.yeejoin.amos.boot.module.jxiop.biz.service.IMonitorFanIndicator;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
import com.yeejoin.amos.component.robot.BadRequest;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
......@@ -40,7 +47,8 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
@Autowired
private RegionMapper regionMapper;
@Autowired
InfluxDButils influxDButils;
@Override
public void UpdateMonitorFanIndicator(List<IndexDto> list) {
......@@ -51,6 +59,43 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
}
@Override
public ResultsData getNationWideInfo(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 ,equipmentNumber,gatewayId,address,valueLabel,equipmentSpecificName,value FROM indicators_%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 indicators_%s WHERE isAlarm='1' and value!='0.0' and gatewayId= %s ");
if(StringUtils.isNotEmpty(equipmentNumber)){
String date ="'%s' and equipmentNumber = '%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.get(0).getCount(), false, current, list);
ColModel colModelequipmentNumber=new ColModel("equipmentNumber", "equipmentNumber", "风机号", "风机号", "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<MonitorFanIndicator> getFanIdxInfoByPage(String equipmentNumber, String gateway, String frontModule, int current, int size) {
Page<MonitorFanIndicator> page = new Page<>(current, size);
Integer integer = monitorFanIndicatorregionMapper.queryByPageTotal(equipmentNumber, gateway, frontModule);
......
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