Commit ad930d78 authored by zhangsen's avatar zhangsen

分析需求API

parent c0c7b425
package com.yeejoin.amos.boot.module.jxiop.biz.controller; package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import cn.hutool.core.text.CharSequenceUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...@@ -148,7 +149,7 @@ public class BigScreenAnalyseController extends BaseController { ...@@ -148,7 +149,7 @@ public class BigScreenAnalyseController extends BaseController {
@RequestParam(value = "size", required = false) Integer size, @RequestParam(value = "size", required = false) Integer size,
@RequestParam(value = "warningName", required = false) String warningName) { @RequestParam(value = "warningName", required = false) String warningName) {
Integer count = idxBizFanWarningRecordMapper.getEquipWarningInfoByPageCount(arae, station, stationType); Integer count = idxBizFanWarningRecordMapper.getEquipWarningInfoByPageCount(arae, station, stationType);
List<IdxBizFanWarningRecord> idxBizFanWarningRecordIPage = idxBizFanWarningRecordMapper.getEquipWarningInfoByPage(arae, station, stationType, current, size, warningName); List<IdxBizFanWarningRecord> idxBizFanWarningRecordIPage = idxBizFanWarningRecordMapper.getEquipWarningInfoByPage(arae, station, stationType, (current - 1) * size, size, warningName);
Page<IdxBizFanWarningRecord> idxBizFanWarningRecordPage = new Page<>(current, size); Page<IdxBizFanWarningRecord> idxBizFanWarningRecordPage = new Page<>(current, size);
idxBizFanWarningRecordPage.setRecords(idxBizFanWarningRecordIPage); idxBizFanWarningRecordPage.setRecords(idxBizFanWarningRecordIPage);
idxBizFanWarningRecordPage.setTotal(count); idxBizFanWarningRecordPage.setTotal(count);
...@@ -246,4 +247,62 @@ public class BigScreenAnalyseController extends BaseController { ...@@ -246,4 +247,62 @@ public class BigScreenAnalyseController extends BaseController {
return ResponseHelper.buildResponse(resultMap); return ResponseHelper.buildResponse(resultMap);
} }
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "片区设备预警统计分析 - 右下角柱状图 ", notes = "片区设备预警统计分析 - 右下角柱状图 ")
@GetMapping(value = "/getAllEquipAlarmInfoAnalysis")
public ResponseModel<Map<String, Object>> getAllEquipAlarmInfoAnalysis(@RequestParam(required = false) String stationType,
@RequestParam(required = false) String areaCode) {
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, "idx_biz_fan_point_process_variable_classification");
} else if ("pv".equals(stationType)) {
allEquipAlarmInfo = idxBizFanHealthIndexMapper.getAllEquipAlarmInfoAnalysisByStationType("idx_biz_pv_warning_record", areaCode, "idx_biz_pv_point_process_variable_classification");
}
} 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()));
}
});
List<Integer> wxList = new ArrayList<>();
List<Integer> zyList = new ArrayList<>();
List<Integer> jgList = new ArrayList<>();
List<String> list = allEquipAlarmInfo.stream().map(t -> t.get("pointName").toString()).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);
wxMapResult.put("name", "危险");
HashMap<String, Object> zyMapResult = new HashMap<>();
zyMapResult.put("data", zyList);
zyMapResult.put("name", "注意");
HashMap<String, Object> jgMapResult = new HashMap<>();
jgMapResult.put("data", jgList);
jgMapResult.put("name", "警告");
List<Map<String, Object>> hashMaps = Arrays.asList(wxMapResult, zyMapResult, jgMapResult);
resultMap.put("axisData", list);
resultMap.put("seriesData", hashMaps);
return ResponseHelper.buildResponse(resultMap);
}
} }
...@@ -30,4 +30,11 @@ public interface IdxBizFanHealthIndexMapper extends BaseMapper<IdxBizFanHealthIn ...@@ -30,4 +30,11 @@ public interface IdxBizFanHealthIndexMapper extends BaseMapper<IdxBizFanHealthIn
List<Map<String, Object>> getHealthInfoByStation(@Param("areaCode") String areaCode); List<Map<String, Object>> getHealthInfoByStation(@Param("areaCode") String areaCode);
List<Map<String, Object>> equipWarningRadarMap(@Param("stationCode") String stationCode); List<Map<String, Object>> equipWarningRadarMap(@Param("stationCode") String stationCode);
List<Map<String, Object>> getAllEquipAlarmInfoAnalysisByStationType(@Param("tableName") String tableName,
@Param("areaCode") String areaCode,
@Param("tableName2") String tableName2);
List<Map<String, Object>> getAllEquipAlarmInfoAnalysisByArea(@Param("areaCode") String areaCode);
} }
...@@ -245,4 +245,61 @@ ...@@ -245,4 +245,61 @@
GROUP BY GROUP BY
a.warningName a.warningName
</select> </select>
<select id="getAllEquipAlarmInfoAnalysisByStationType" resultType="java.util.Map">
SELECT
( SELECT POINT_NAME FROM ${tableName2} WHERE GATEWAY_ID = a.GATEWAY_ID AND INDEX_ADDRESS = a.INDEX_ADDRESS ) AS pointName,
a.WARNING_NAME as warningName,
count(1) as num
FROM
${tableName} a
<where>
<if test="areaCode != null and areaCode != ''">
a.ARAE = #{areaCode}
</if>
</where>
group by pointName,
a.WARNING_NAME
having pointName IS NOT NULL
AND pointName != ''
</select>
<select id="getAllEquipAlarmInfoAnalysisByArea" resultType="java.util.Map">
SELECT
a.*
FROM
(
SELECT
( SELECT POINT_NAME FROM idx_biz_pv_point_process_variable_classification WHERE GATEWAY_ID = idx_biz_pv_warning_record.GATEWAY_ID AND INDEX_ADDRESS = idx_biz_pv_warning_record.INDEX_ADDRESS ) AS pointName,
WARNING_NAME AS warningName,
count( 1 ) AS num
FROM
idx_biz_pv_warning_record
<where>
<if test="areaCode != null and areaCode != ''">
ARAE = #{areaCode}
</if>
</where>
GROUP BY
pointName,
WARNING_NAME UNION ALL
SELECT
( SELECT POINT_NAME FROM idx_biz_fan_point_process_variable_classification WHERE GATEWAY_ID = idx_biz_fan_warning_record.GATEWAY_ID AND INDEX_ADDRESS = idx_biz_fan_warning_record.INDEX_ADDRESS ) AS pointName,
WARNING_NAME AS warningName,
count( 1 ) AS num
FROM
idx_biz_fan_warning_record
<where>
<if test="areaCode != null and areaCode != ''">
ARAE = #{areaCode}
</if>
</where>
GROUP BY
pointName,
WARNING_NAME
) a
WHERE
a.pointName IS NOT NULL
AND a.pointName != ''
</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