Commit 57ae2ad8 authored by chenzhao's avatar chenzhao

修改代码

parent e6b1d263
......@@ -399,42 +399,28 @@ public class TDBigScreenAnalyseController extends BaseController {
@ApiOperation(httpMethod = "GET", value = "片区设备预警统计分析 - 右下角柱状图 ", notes = "片区设备预警统计分析 - 右下角柱状图 ")
@GetMapping(value = "/getAllEquipAlarmInfoAnalysis")
public ResponseModel<Map<String, Object>> getAllEquipAlarmInfoAnalysis(@RequestParam(required = false) String stationType,
@RequestParam(required = false) String areaCode) {
@RequestParam(required = false) String araeCode) {
Map<String, Object> resultMap = new HashMap<>();
List<Map<String, Object>> allEquipAlarmInfo = new ArrayList<>();
if (CharSequenceUtil.isNotEmpty(stationType)) {
if ("fan".equals(stationType)) {
allEquipAlarmInfo = idxBizFanHealthIndexMapper.getAllEquipAlarmInfoAnalysisByStationType("idx_biz_fan_warning_record", areaCode, "风电");
stationType = "风电";
} else if ("pv".equals(stationType)) {
allEquipAlarmInfo = idxBizFanHealthIndexMapper.getAllEquipAlarmInfoAnalysisByStationType("idx_biz_pv_warning_record", areaCode, "光伏");
stationType = "光伏";
}
} else {
allEquipAlarmInfo = idxBizFanHealthIndexMapper.getAllEquipAlarmInfoAnalysisByArea(areaCode);
}
HashMap<String, Integer> wxMap = new HashMap<>();
HashMap<String, Integer> zyMap = new HashMap<>();
HashMap<String, Integer> jgMap = new HashMap<>();
allEquipAlarmInfo.forEach(item -> {
if ("危险".equals(item.get("warningName"))) {
wxMap.put(item.get("pointName").toString(), Integer.parseInt(item.get("num").toString()));
} else if ("注意".equals(item.get("warningName"))) {
zyMap.put(item.get("pointName").toString(), Integer.parseInt(item.get("num").toString()));
} else if ("警告".equals(item.get("warningName"))) {
jgMap.put(item.get("pointName").toString(), Integer.parseInt(item.get("num").toString()));
}
});
allEquipAlarmInfo = fanWaringRecordMapper.getAllEquipAlarmInfoAnalysisByArea(araeCode,stationType);
List<Integer> wxList = new ArrayList<>();
List<Integer> zyList = new ArrayList<>();
List<Integer> jgList = new ArrayList<>();
List<String> list =new ArrayList<>();
for (Map<String, Object> map : allEquipAlarmInfo) {
wxList.add(Integer.valueOf(map.get("危险").toString()));
zyList.add(Integer.valueOf(map.get("注意").toString()));
jgList.add(Integer.valueOf(map.get("警告").toString()));
list.add(map.get("EQUIPMENT_NAME").toString());
List<String> list = allEquipAlarmInfo.stream().map(t -> t.get("pointName").toString()).distinct().collect(Collectors.toList());
list.forEach(item -> {
wxList.add(wxMap.getOrDefault(item, 0));
zyList.add(zyMap.getOrDefault(item, 0));
jgList.add(jgMap.getOrDefault(item, 0));
});
}
HashMap<String, Object> wxMapResult = new HashMap<>();
wxMapResult.put("data", wxList);
......
......@@ -43,4 +43,7 @@ public interface FanWaringRecordMapper extends BaseMapper<FanWarningRecord> {
@Param("endDate") String endDate);
List<FanWarningRecord> getEquipWarningInfoByPage(String arae, String station, String stationType, Integer current, Integer size, String warningName, String stationId, String startDate, String endDate);
List<Map<String, Object>> getAllEquipAlarmInfoAnalysisByArea(String araeCode, String stationType);
}
......@@ -237,11 +237,11 @@
<select id="getAllEquipAlarmInfo" resultType="map">
select arae as area,
warning_name as warningname,
warning_name as warningName,
count(1) as num
from analysis_data.fan_warning_record a
where (a.disposotion_state = '未处置')
or (a.disposotion_state = '已处置' and a.disposotion_date >(now()-3d -8h ))
or (a.disposotion_state = '已处置' and a.ts >(now()-3d -8h ))
group by arae,
warning_name
......@@ -376,4 +376,118 @@
</if>
</where>) b
</select>
<select id="getAllEquipAlarmInfoAnalysisByArea" resultType="map">
select
*
from
(
select
concat('风电-',`b`.`EQUIPMENT_NAME`) as `EQUIPMENT_NAME`,
`b`.`STATION` as `STATION`,
`b`.`arae` as `arae`,
`b`.`警告` as `警告`,
`b`.`注意` as `注意`,
`b`.`危险` as `危险`,
'风电' as stationType,
sum(((`b`.`注意` + `b`.`危险`) + `b`.`警告`)) as `sort`
from
(
select
`a`.`EQUIPMENT_NAME` as `EQUIPMENT_NAME`,
a.`STATION` as `STATION`,
`a`.`arae` as `arae`,
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`,
`point_name` as `EQUIPMENT_NAME`,
`station` as `STATION`,
`arae` as `arae`,
count(1) as `num`
from
analysis_data.fan_warning_record
where
`status` = 0
or (`status` = 1
and `ts` > (now() - 3D - 8h))
group by
`station`,
`point_name`,
`warning_name`,arae) a
group by
`a`.`EQUIPMENT_NAME`,
a.`STATION`,a.`arae`) b
group by
`b`.`EQUIPMENT_NAME`,
`b`.`STATION`,
`b`.`arae`,
`b`.`警告`,
`b`.`注意`,
`b`.`危险`
union all
(
select
concat('光伏-',`b`.`EQUIPMENT_NAME`) as `EQUIPMENT_NAME`,
`b`.`STATION` as `STATION`,
`b`.`arae` as `arae`,
`b`.`警告` as `警告`,
`b`.`注意` as `注意`,
`b`.`危险` as `危险`,
'光伏' as stationType,
sum(((`b`.`注意` + `b`.`危险`) + `b`.`警告`)) as `sort`
from
(
select
`a`.`EQUIPMENT_NAME` as `EQUIPMENT_NAME`,
a.`STATION` as `STATION`,
a.`arae` as `arae`,
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`,
`point_name` as `EQUIPMENT_NAME`,
`station` as `STATION`,
`arae` as `arae`,
count(1) as `num`
from
analysis_data.pv_warning_record
where
`status` = 0
or (`status` = 1
and `ts` > (now() - 3D - 8h))
group by
`station`,
`point_name`,
`warning_name`,arae) a
group by
`a`.`EQUIPMENT_NAME`,
a.`STATION`,a.`arae`) b
group by
`b`.`EQUIPMENT_NAME`,
`b`.`STATION`,
`b`.`arae`,
`b`.`警告`,
`b`.`注意`,
`b`.`危险`
)) b
<where>
<if test="stationType != '' and stationType != null">
and b.stationtype = #{stationType}
</if>
<if test="araeCode != '' and araeCode != null">
and b.arae = #{araeCode}
</if>
</where>
order by b.`sort` desc
</select>
</mapper>
......@@ -252,7 +252,7 @@
<select id="getAllEquipAlarmInfo" resultType="map">
select arae as area,
warning_name as warningname,
warning_name as warningName,
count(1) as num
from analysis_data.pv_warning_record a
where (a.disposotion_state = '未处置')
......
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