Commit ca2dda60 authored by caotao's avatar caotao

新增获取实时表计温度接口

parent 2e821726
...@@ -20,6 +20,7 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation; ...@@ -20,6 +20,7 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -56,8 +57,6 @@ public class MonitorFanIdxController extends BaseController { ...@@ -56,8 +57,6 @@ public class MonitorFanIdxController extends BaseController {
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "风机布置图 - 风机状态列表") @ApiOperation(value = "风机布置图 - 风机状态列表")
@GetMapping("/getFanStatusList") @GetMapping("/getFanStatusList")
...@@ -101,4 +100,12 @@ public class MonitorFanIdxController extends BaseController { ...@@ -101,4 +100,12 @@ public class MonitorFanIdxController extends BaseController {
return ResponseHelper.buildResponse(monitorFanIndicator.getFanBasicInfoByEquipNum(equipNum, stationId)); return ResponseHelper.buildResponse(monitorFanIndicator.getFanBasicInfoByEquipNum(equipNum, stationId));
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "获取当前表记的实时温度")
@GetMapping("/getRealTimeTemperature")
public ResponseModel<HashMap<String, List<String>>> getRealTimeTemperature(@RequestParam(value = "equipNum", required = false) String equipNum,
@RequestParam(value = "stationId", required = false) String stationId,
@RequestParam(value = "frontModule", required = false) String frontModule) {
return ResponseHelper.buildResponse(monitorFanIndicator.getRealTimeTemperature(equipNum, stationId, frontModule)) ;
}
} }
...@@ -24,6 +24,7 @@ import com.yeejoin.amos.component.robot.BadRequest; ...@@ -24,6 +24,7 @@ import com.yeejoin.amos.component.robot.BadRequest;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -58,99 +59,88 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -58,99 +59,88 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
StationDataTaskImpl stationDataTask; StationDataTaskImpl stationDataTask;
@Override @Override
public void UpdateMonitorFanIndicator(List<IndexDto> list) { public void UpdateMonitorFanIndicator(List<IndexDto> list) {
monitorFanIndicatorregionMapper.UpdateMonitorFanIndicator(list); monitorFanIndicatorregionMapper.UpdateMonitorFanIndicator(list);
} }
@Override @Override
public ResultsData getNationWideInfo(int current, int size, String stationBasicId, String equipmentNumber) { public ResultsData getNationWideInfo(int current, int size, String stationBasicId, String equipmentNumber) {
StationBasic stationBasic =stationBasicMapper.selectById(stationBasicId); StationBasic stationBasic = stationBasicMapper.selectById(stationBasicId);
String gateway=stationBasic.getFanGatewayId(); String gateway = stationBasic.getFanGatewayId();
Page<IndexDto> page = new Page<IndexDto>(); Page<IndexDto> page = new Page<IndexDto>();
page.setCurrent(current); page.setCurrent(current);
page.setSize(size); page.setSize(size);
String table=gateway; 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 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 "); StringBuffer querysqlcount = new StringBuffer("SELECT count(value) FROM indicators_%s WHERE isAlarm='1' and value!='0.0' and gatewayId= %s ");
if(StringUtils.isNotEmpty(equipmentNumber)){ if (StringUtils.isNotEmpty(equipmentNumber)) {
String date ="'%s' and equipmentNumber = '%s' "; String date = "'%s' and equipmentNumber = '%s' ";
gateway= String.format(date,gateway,equipmentNumber); gateway = String.format(date, gateway, equipmentNumber);
}else{ } else {
gateway=String.format("'%s'",gateway); 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, (int) page.getSize(), (int) (page.getCurrent() - 1) * page.getSize());
String querysqlcountn= String.format(querysqlcount.toString(),table,gateway); String querysqlcountn = String.format(querysqlcount.toString(), table, gateway);
//每个分机的指标数据 //每个分机的指标数据
List<IndexDto> list = influxDButils.getListData(querysqln,IndexDto.class); List<IndexDto> list = influxDButils.getListData(querysqln, IndexDto.class);
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!=null?list1.get(0).getCount():0, 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");
ColModel colModelvalue=new ColModel("value", "value", "告警值", "告警值", "dataGrid", "value"); ColModel colModelvalue = new ColModel("value", "value", "告警值", "告警值", "dataGrid", "value");
List<ColModel> listColModel=new ArrayList<>(); List<ColModel> listColModel = new ArrayList<>();
listColModel.add(colModelequipmentNumber); listColModel.add(colModelequipmentNumber);
listColModel.add(colModelvalueLabel); listColModel.add(colModelvalueLabel);
listColModel.add(colModelcreatedTime); listColModel.add(colModelcreatedTime);
listColModel.add(colModelvalue); listColModel.add(colModelvalue);
ResultsData resultsData=new ResultsData(DataGridMock,listColModel); ResultsData resultsData = new ResultsData(DataGridMock, listColModel);
return resultsData; return resultsData;
} }
@Override @Override
public ResultsData getLsNationWideInfo(int current, int size, String stationBasicId, String equipmentNumber) { public ResultsData getLsNationWideInfo(int current, int size, String stationBasicId, String equipmentNumber) {
StationBasic stationBasic =stationBasicMapper.selectById(stationBasicId); StationBasic stationBasic = stationBasicMapper.selectById(stationBasicId);
String gateway=stationBasic.getFanGatewayId(); String gateway = stationBasic.getFanGatewayId();
Page<IndexDto> page = new Page<IndexDto>(); Page<IndexDto> page = new Page<IndexDto>();
page.setCurrent(current); page.setCurrent(current);
page.setSize(size); page.setSize(size);
String table=gateway; 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 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 "); 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)){ if (StringUtils.isNotEmpty(equipmentNumber)) {
String date = " '%s' and equipmentSpecificName=~/.*%s风机.*/ "; String date = " '%s' and equipmentSpecificName=~/.*%s风机.*/ ";
gateway= String.format(date,gateway,equipmentNumber); gateway = String.format(date, gateway, equipmentNumber);
}else{ } else {
gateway=String.format("'%s'",gateway); 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, (int) page.getSize(), (int) (page.getCurrent() - 1) * page.getSize());
String querysqlcountn= String.format(querysqlcount.toString(),table,gateway); String querysqlcountn = String.format(querysqlcount.toString(), table, gateway);
//每个分机的指标数据 //每个分机的指标数据
List<IndexDto> list = influxDButils.getListData(querysqln,IndexDto.class); List<IndexDto> list = influxDButils.getListData(querysqln, IndexDto.class);
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!=null?list1.get(0).getCount():0, false, current, 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 colModelequipmentNumber = new ColModel("equipmentNumber", "equipmentSpecificName", "风机号", "风机号", "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");
ColModel colModelvalue=new ColModel("value", "value", "告警值", "告警值", "dataGrid", "value"); ColModel colModelvalue = new ColModel("value", "value", "告警值", "告警值", "dataGrid", "value");
List<ColModel> listColModel=new ArrayList<>(); List<ColModel> listColModel = new ArrayList<>();
listColModel.add(colModelequipmentNumber); listColModel.add(colModelequipmentNumber);
listColModel.add(colModelvalueLabel); listColModel.add(colModelvalueLabel);
listColModel.add(colModelcreatedTime); listColModel.add(colModelcreatedTime);
listColModel.add(colModelvalue); listColModel.add(colModelvalue);
ResultsData resultsData=new ResultsData(DataGridMock,listColModel); ResultsData resultsData = new ResultsData(DataGridMock, listColModel);
return resultsData; 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);
...@@ -210,27 +200,25 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -210,27 +200,25 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
/** /**
* 根据网关与指标获取指标的平均值 * 根据网关与指标获取指标的平均值
*
* @param gateway * @param gateway
* @param indicator * @param indicator
* @return * @return
*/ */
public Object getIndicatoralueAvage(String gateway,String indicator){ public Object getIndicatoralueAvage(String gateway, String indicator) {
return monitorFanIndicatorregionMapper.getIndicatoralueAvage(gateway,indicator); return monitorFanIndicatorregionMapper.getIndicatoralueAvage(gateway, indicator);
} }
/** /**
* 根据网关与指标获取指标的总值 * 根据网关与指标获取指标的总值
*
* @param gateway * @param gateway
* @param indicator * @param indicator
* @return * @return
*/ */
public Object getIndicatoralueTotal(String gateway,String indicator) { public Object getIndicatoralueTotal(String gateway, String indicator) {
return monitorFanIndicatorregionMapper.getIndicatoralueTotal(gateway,indicator); return monitorFanIndicatorregionMapper.getIndicatoralueTotal(gateway, indicator);
} }
...@@ -288,4 +276,30 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -288,4 +276,30 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
return new IndexDto(); return new IndexDto();
} }
/**
* 根据风机号 场站号 模块获取实时温度
* @param equipNum
* @param stationId
* @param frontModule
* @return 风机的实时温度数据
*/
public HashMap<String, List<String>> getRealTimeTemperature(String equipNum, String stationId, String frontModule) {
HashMap<String, List<String>> realTimeTemperatureResult = new HashMap<>();
StationBasic stationBasic = getOneByStationNumber(stationId);
String sql = String.format("SELECT equipmentIndexName, value, frontModule, unit FROM \"indicators_%s\" WHERE equipmentNumber = '%s' and frontModule =~/%s/", stationBasic.getFanGatewayId(), equipNum, frontModule);
List<IndexDto> influxDBList = influxDButils.getListData(sql, IndexDto.class);
List<String> xList = new ArrayList<>();
List<String> yList = new ArrayList<>();
for (int i = 0; i < influxDBList.size(); i++) {
IndexDto indexDto = influxDBList.get(i);
if(indexDto.getEquipmentIndexName().contains("温度")){
xList.add(indexDto.getEquipmentIndexName());
yList.add(indexDto.getValue());
}
}
realTimeTemperatureResult.put("axisData", xList);
realTimeTemperatureResult.put("seriesData", yList);
return realTimeTemperatureResult;
}
} }
\ No newline at end of file
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