Commit 46c83bc3 authored by tangwei's avatar tangwei

告警列表

parent 0ccc7b1b
......@@ -30,11 +30,6 @@ public interface MonitorFanIndicatorMapper extends BaseMapper<MonitorFanIndicato
@Param("offset") int offset);
Object getIndicatoralueAvage(String gateway,String indicator);
List<RunRecord> queryRunRecord(@Param("size") long size,
@Param("list") String[] list,
@Param("offset") long offset);
int queryRunRecordTotal( @Param("list") String[] list);
Object getIndicatoralueTotal(String gateway,String indicator);
......
......@@ -78,34 +78,6 @@
WHERE gateway=#{gateway} and
indicator like concat('%',#{indicator},'%')
</select>
<select id="queryRunRecord" resultType="com.yeejoin.amos.boot.module.jxiop.api.dto.RunRecord">
SELECT
t.equipment_number AS FanName,
(SELECT indicator_value FROM monitor_fan_indicator WHERE equipment_number=t.equipment_number AND gateway=t.gateway and indicator="有功功率") AS 'power',
(SELECT indicator_value FROM monitor_fan_indicator WHERE equipment_number=t.equipment_number AND gateway=t.gateway and indicator="瞬时风速") AS 'windSpeed',
(SELECT indicator_value FROM monitor_fan_indicator WHERE equipment_number=t.equipment_number AND gateway=t.gateway and indicator="60秒平均风向角") AS 'windDirection',
(SELECT indicator_value FROM monitor_fan_indicator WHERE equipment_number=t.equipment_number AND gateway=t.gateway and indicator="日发电量") AS 'PowerGeneration'
FROM
(select
DISTINCT a.equipment_number,a.gateway
from monitor_fan_indicator a where a.equipment_number is not null and a.gateway in
<foreach collection="list" index="index" item="item" separator="," open="(" close=")">
#{item}
</foreach>
ORDER BY a.equipment_number ) AS t
limit #{offset}, #{size}
</select>
<select id="queryRunRecordTotal" resultType="java.lang.Integer">
select
count(DISTINCT a.equipment_number) num
from monitor_fan_indicator a where a.equipment_number is not null and a.gateway in
<foreach collection="list" index="index" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</select>
......
......@@ -41,30 +41,23 @@ public class DeviceController extends BaseController {
@ApiOperation(value = "获取告警数据")
@GetMapping("/nationwide")
public ResponseModel<Page<IndexDto>> getNationWideInfo(@RequestParam(value = "current") int current,@RequestParam
(value = "size") int size,@RequestParam(value = "gateway") String gateway) {
(value = "size") int size,@RequestParam(value = "gateway") String gateway,@RequestParam(value = "equipmentNumber") String equipmentNumber) {
Page<IndexDto> page = new Page<IndexDto>();
page.setCurrent(current);
page.setSize(size);
StringBuffer querysql = new StringBuffer("SELECT createdTime ,gatewayId,address,valueLabel,equipmentSpecificName,value FROM iot_data WHERE isAlarm='1' and value!='0.0' and time > now() - 1d ");
StringBuffer querysqlcount = new StringBuffer("SELECT count(value) FROM iot_data WHERE isAlarm='1' and value!='0.0' and time > now() - 1d ");
if(StringUtils.isNotEmpty(gateway)){
String[] da= gateway.split(",");
for (int i = 0; i < da.length; i++) {
if(i==0){
querysql.append("and ( gatewayId = ").append("'"+da[i]+"'");
querysqlcount.append("and ( gatewayId = ").append("'"+da[i]+"'");
}else if(i==da.length-1){
querysql.append(" or gatewayId = ").append("'"+da[i]+"'").append(") ");
querysqlcount.append(" or gatewayId = ").append("'"+da[i]+"'").append(") ");
}else{
querysql.append(" or gatewayId = ").append("'"+da[i]+"'");
querysqlcount.append(" or gatewayId = ").append("'"+da[i]+"'");
}
}
StringBuffer querysql = new StringBuffer("SELECT createdTime ,gatewayId,address,valueLabel,equipmentSpecificName,value FROM ");
querysql.append("indicators_").append(gateway);
querysql.append(" WHERE isAlarm='1' and value!='0.0' and gatewayId=");
querysql.append(gateway);
StringBuffer querysqlcount = new StringBuffer("SELECT count(value) FROM ");
querysqlcount.append("indicators_").append(gateway);
querysqlcount.append(" WHERE isAlarm='1' and value!='0.0' and gatewayId=");
querysqlcount.append(gateway);
if(StringUtils.isNotEmpty(querysqlcount)){
querysqlcount.append(" and equipmentNumber =").append(equipmentNumber);
querysql.append(" and equipmentNumber =").append(equipmentNumber);
}
querysql.append(" ORDER BY time desc LIMIT ").append(page.getSize()).append(" OFFSET ").append((page.getCurrent() - 1)*page.getSize());
//每个分机的指标数据
List<IndexDto> list = influxDButils.getListData(querysql.toString(),IndexDto.class);
......
......@@ -52,17 +52,7 @@ public class MonitorFanIdxController extends BaseController {
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "运行记录")
@GetMapping("/runRecord")
public ResponseModel<IPage<RunRecord>> runRecord(
@RequestParam(value = "gateway", required = false) String gateway,
@RequestParam(value = "current", required = false) int current,
@RequestParam(value = "size", required = false) int size) {
String[] gateways=gateway.split(",");
IPage<RunRecord> page= monitorFanIndicator.queryRunRecord( size,gateways, current);
return ResponseHelper.buildResponse(page);
}
......
......@@ -112,17 +112,6 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
public IPage<RunRecord> queryRunRecord(long size,String[] gateway, int current){
Page<RunRecord> page = new Page<>(current, size);
Integer integer = monitorFanIndicatorregionMapper.queryRunRecordTotal(gateway);
List<RunRecord> runRecord = monitorFanIndicatorregionMapper.queryRunRecord(page.getSize(), gateway, (current - 1) * size);
page.setTotal(integer);
page.setRecords(runRecord);
return page;
}
/**
* 根据网关与指标获取指标的总值
......
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