Commit 9f7d2709 authored by chenzhao's avatar chenzhao

TDENGINE 风机预警

parent 19a96358
...@@ -13,6 +13,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvWarningRuleSet; ...@@ -13,6 +13,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvWarningRuleSet;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizFanWarningRecordServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizFanWarningRecordServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizFanWarningRuleSetServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizFanWarningRuleSetServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizPvWarningRuleSetServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizPvWarningRuleSetServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanWaringRecordMapper;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.beanutils.BeanMap; import org.apache.commons.beanutils.BeanMap;
...@@ -50,6 +51,9 @@ public class IdxBizFanWarningRecordController extends BaseController { ...@@ -50,6 +51,9 @@ public class IdxBizFanWarningRecordController extends BaseController {
@Autowired @Autowired
IdxBizPvWarningRuleSetServiceImpl idxBizPvWarningRuleSetService; IdxBizPvWarningRuleSetServiceImpl idxBizPvWarningRuleSetService;
@Autowired
FanWaringRecordMapper fanWaringRecordMapper;
/** /**
* 新增 * 新增
* *
...@@ -327,4 +331,14 @@ public class IdxBizFanWarningRecordController extends BaseController { ...@@ -327,4 +331,14 @@ public class IdxBizFanWarningRecordController extends BaseController {
boolean b = idxBizFanWarningRuleSetService.updateBatchById(idxBizFanWarningRecordList); boolean b = idxBizFanWarningRuleSetService.updateBatchById(idxBizFanWarningRecordList);
return ResponseHelper.buildResponse(b); return ResponseHelper.buildResponse(b);
} }
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "/selectFanWarningNum")
@ApiOperation(httpMethod = "GET", value = "查询各风机预警状况", notes = "查询各风机预警状况")
public ResponseModel<List<Map<String,Object>>> selectFanWarningNum(@RequestParam String station) {
List<Map<String, Object>> maps = fanWaringRecordMapper.selectFanWarningNum(station);
return ResponseHelper.buildResponse(maps);
}
} }
...@@ -2,7 +2,12 @@ package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2; ...@@ -2,7 +2,12 @@ package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanWarningRecord; import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanWarningRecord;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
public interface FanWaringRecordMapper extends BaseMapper<FanWarningRecord> { public interface FanWaringRecordMapper extends BaseMapper<FanWarningRecord> {
public List<Map<String,Object>> selectFanWarningNum(String station);
} }
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanWaringRecordMapper"> <mapper namespace="com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanWaringRecordMapper">
<select id="selectFanWarningNum" resultType="map">
SELECT `b`.`EQUIPMENT_NAME` AS `EQUIPMENT_NAME`,
`b`.`STATION` AS `STATION`,
`b`.`警告` AS `警告`,
`b`.`注意` AS `注意`,
`b`.`危险` AS `危险`,
sum(((`b`.`注意` + `b`.`危险`) + `b`.`警告`)) AS `sort`
FROM (select `a`.`EQUIPMENT_NAME` as `EQUIPMENT_NAME`,
a.`STATION` as `STATION`,
max(case `a`.`WARNING_NAME` when '危险' then `a`.`num` else 0 end) as `危险`,
max(case `a`.`WARNING_NAME` when '注意' then `a`.`num` else 0 end) as `注意`,
max(case `a`.`WARNING_NAME` when '警告' then `a`.`num` else 0 end) as `警告`
from (
select `warning_name` as `WARNING_NAME`,
`equipment_name` as `EQUIPMENT_NAME`,
`station` as `STATION`,
count(1) as `num`
from analysis_data.fan_warning_record
where `status` = 0
or (`status` = 1
and `ts` > (now() - 3D - 8h))
<if test="station != null">
and station = #{station}
</if>
group by `station`,
`equipment_name`,
`warning_name`) a
group by `a`.`EQUIPMENT_NAME`, a.`STATION`) b
GROUP BY `b`.`EQUIPMENT_NAME`,
`b`.`STATION`, `b`.`警告`, `b`.`注意`, `b`.`危险`
order by sort DESC
</select>
</mapper> </mapper>
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