Commit 0b90ed8d authored by chenzhao's avatar chenzhao

光伏预警监测页面接口

parent e86a96cc
...@@ -2,9 +2,12 @@ package com.yeejoin.amos.boot.module.jxiop.biz.controller; ...@@ -2,9 +2,12 @@ package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizPvHealthIndexDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizPvHealthIndexDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvWarningRecord; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizPvHealthIndexServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizPvHealthIndexServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.*;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.*;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -15,7 +18,10 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper; ...@@ -15,7 +18,10 @@ 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 javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* *
...@@ -30,7 +36,14 @@ public class IdxBizPvHealthIndexController extends BaseController { ...@@ -30,7 +36,14 @@ public class IdxBizPvHealthIndexController extends BaseController {
@Autowired @Autowired
IdxBizPvHealthIndexServiceImpl idxBizPvHealthIndexServiceImpl; IdxBizPvHealthIndexServiceImpl idxBizPvHealthIndexServiceImpl;
@Autowired
PvHealthIndexDayMapper pvHealthIndexDayMapper;
@Autowired
PvHealthIndexHourMapper pvHealthIndexHourMapper;
@Autowired
PvHealthIndexMomentMapper pvHealthIndexMomentMapper;
@Autowired
PvWaringRecordMapper pvWaringRecordMapper;
/** /**
* 新增 * 新增
* *
...@@ -209,4 +222,198 @@ public class IdxBizPvHealthIndexController extends BaseController { ...@@ -209,4 +222,198 @@ public class IdxBizPvHealthIndexController extends BaseController {
result.put("seriesData",seriesData); result.put("seriesData",seriesData);
result.put("axisData",axisData); result.put("axisData",axisData);
return ResponseHelper.buildResponse(result);} return ResponseHelper.buildResponse(result);}
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(httpMethod = "GET",value = "TD 光伏场站/设备列表通用接口", notes = "TD 光伏场站/设备列表通用接口")
@GetMapping(value = "/pointHealthIndexTable")
public ResponseModel<Object> pointHealthIndexTable(@RequestParam(value = "area",required = false) String area,
@RequestParam(value = "station",required = false) String station,
@RequestParam(value = "analysisObjType",required = false) String analysisObjType,
@RequestParam(value = "analysisType",required = false) String analysisType,
@RequestParam(value = "endTimeTop",required = false) String endTimeTop,
@RequestParam(value = "startTimeTop",required = false) String startTimeTop,
@RequestParam(value = "indexAddress",required = false) String indexAddress,
@RequestParam(value = "pointName",required = false) String pointName,
@RequestParam(value = "equipmentName",required = false) String equipmentName,
@RequestParam(value = "healthLevel",required = false) String healthLevel,
@RequestParam(value = "type",required = false) String type,
@RequestParam(value = "requiredType",required = false) String requiredType,
@RequestParam(value = "subarray",required = false) String subarray){
if (requiredType.equals("按天")){
Date startDayTime = DateUtils.getCurrentDayStartTime(new Date());
Date date = DateUtils.dateAddHours(startDayTime, -8);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
startTimeTop = formatter.format(date);
List<PvHealthIndexDay> fanHealthIndexDays = pvHealthIndexDayMapper.selectData(healthLevel, area, equipmentName, subarray, analysisType, analysisObjType, station, pointName, indexAddress, startTimeTop, endTimeTop);
return ResponseHelper.buildResponse(fanHealthIndexDays);
}else if (requiredType.equals("按小时")){
int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
String day = DateUtils.getDateNowShortStr();
startTimeTop = day + " "+ hour+":00:00";
try {
Date date = DateUtils.dateAddHours(DateUtils.dateParse(startTimeTop,DateUtils.DATE_TIME_PATTERN),-8);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
startTimeTop = formatter.format(date);
} catch (ParseException e) {
e.printStackTrace();
}
List<PvHealthIndexHour> fanHealthIndexHours = pvHealthIndexHourMapper.selectData(healthLevel, area, equipmentName, subarray, analysisType, analysisObjType, station, pointName, indexAddress, startTimeTop, endTimeTop);
return ResponseHelper.buildResponse(fanHealthIndexHours);
}else {
Date date = DateUtils.dateAddMinutes(null,-9);
date = DateUtils.dateAddHours(date, -8);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
startTimeTop = formatter.format(date);
List<PvHealthIndexMoment> fanHealthIndexMoments = pvHealthIndexMomentMapper.selectData(healthLevel, area, equipmentName, subarray, analysisType, analysisObjType, station, pointName, indexAddress, startTimeTop, endTimeTop);
return ResponseHelper.buildResponse(fanHealthIndexMoments);
}
}
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(httpMethod = "GET",value = "TD 光伏折线图", notes = "TD光伏折线图")
@GetMapping(value = "/pointHealthIndexTrend")
public ResponseModel<Object> pointHealthIndexTrend(@RequestParam(value = "area",required = false) String area,
@RequestParam(value = "station",required = false) String station,
@RequestParam(value = "analysisObjType",required = false) String analysisObjType,
@RequestParam(value = "analysisType",required = false) String analysisType,
@RequestParam(value = "endTimeTop",required = false) String endTimeTop,
@RequestParam(value = "startTimeTop",required = false) String startTimeTop,
@RequestParam(value = "indexAddress",required = false) String indexAddress,
@RequestParam(value = "pointName",required = false) String pointName,
@RequestParam(value = "equipmentName",required = false) String equipmentName,
@RequestParam(value = "healthLevel",required = false) String healthLevel,
@RequestParam(value = "type",required = false) String type,
@RequestParam(value = "requiredType",required = false) String requiredType,
@RequestParam(value = "subarray",required = false) String subarray) {
Map<String,Object> result = new HashMap<>();
List<Object> seriesData = new ArrayList<>();
List<Object> axisData = new ArrayList<>();
if (requiredType.equals("按天")){
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if ( null != endTimeTop){
Date endDate = DateUtils.dateAddHours(DateUtils.longStr2Date(endTimeTop), -8);
endTimeTop = formatter.format(endDate);
}
Date startDate = DateUtils.dateAddHours(DateUtils.longStr2Date(startTimeTop), -8);
startTimeTop = formatter.format(startDate);
List<PvHealthIndexDay> fanHealthIndexDays = pvHealthIndexDayMapper.selectData(healthLevel, area, equipmentName, subarray, analysisType, analysisObjType, station, pointName, indexAddress, startTimeTop, endTimeTop);
fanHealthIndexDays= fanHealthIndexDays.stream().sorted(Comparator.comparing(PvHealthIndexDay::getAnalysisTime)).collect(Collectors.toList());
for (PvHealthIndexDay obj : fanHealthIndexDays) {
if (type.equals("0")){
seriesData.add(obj.getHealthIndex().intValue());
}else {
seriesData.add(obj.getAnomaly());
}
axisData.add(obj.getAnalysisTime());
}
result.put("seriesData",seriesData);
result.put("axisData",axisData);
return ResponseHelper.buildResponse(result);
}else if (requiredType.equals("按小时")){
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if ( null != endTimeTop){
Date endDate = DateUtils.dateAddHours(DateUtils.longStr2Date(endTimeTop), -8);
endTimeTop = formatter.format(endDate);
}
Date startDate = DateUtils.dateAddHours(DateUtils.longStr2Date(startTimeTop), -8);
startTimeTop = formatter.format(startDate);
List<PvHealthIndexHour> fanHealthIndexHours = pvHealthIndexHourMapper.selectData(healthLevel, area, equipmentName, subarray, analysisType, analysisObjType, station, pointName, indexAddress, startTimeTop, endTimeTop);
fanHealthIndexHours= fanHealthIndexHours.stream().sorted(Comparator.comparing(PvHealthIndexHour::getAnalysisTime)).collect(Collectors.toList());
for (PvHealthIndexHour obj : fanHealthIndexHours) {
if (type.equals("0")){
seriesData.add(obj.getHealthIndex().intValue());
}else {
seriesData.add(obj.getAnomaly());
}
axisData.add(obj.getAnalysisTime());
}
result.put("seriesData",seriesData);
result.put("axisData",axisData);
return ResponseHelper.buildResponse(result);
}else {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if ( null != endTimeTop){
Date endDate = DateUtils.dateAddHours(DateUtils.longStr2Date(endTimeTop), -8);
endTimeTop = formatter.format(endDate);
}
Date startDate = DateUtils.dateAddHours(DateUtils.longStr2Date(startTimeTop), -8);
startTimeTop = formatter.format(startDate);
List<PvHealthIndexMoment> fanHealthIndexMoments = pvHealthIndexMomentMapper.selectData(healthLevel, area, equipmentName, subarray, analysisType, analysisObjType, station, pointName, indexAddress, startTimeTop, endTimeTop);
fanHealthIndexMoments= fanHealthIndexMoments.stream().sorted(Comparator.comparing(PvHealthIndexMoment::getAnalysisTime)).collect(Collectors.toList());
for (PvHealthIndexMoment obj : fanHealthIndexMoments) {
if (type.equals("0")){
seriesData.add(obj.getHealthIndex().intValue());
}else {
seriesData.add(obj.getAnomaly());
}
axisData.add(obj.getAnalysisTime());
}
result.put("seriesData",seriesData);
result.put("axisData",axisData);
return ResponseHelper.buildResponse(result);
}
}
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(httpMethod = "GET",value = "预警监测设备级统计 TD", notes = "预警监测设备级统计 TD")
@GetMapping(value = "/selectPointNum")
public ResponseModel<List<Map<String,Object>>> selectPointNum(@RequestParam(required = false) String STATION,@RequestParam(required = false) String SUBARRAY,@RequestParam(required = false) String EQUIPMENTNAME) {
List<PvWarningRecord> idxBizPvWarningRecordList = pvWaringRecordMapper.warningData(STATION, SUBARRAY, EQUIPMENTNAME);
int total = idxBizPvHealthIndexServiceImpl.pointNum(STATION, SUBARRAY, EQUIPMENTNAME);
Map<String,Object> map =new HashMap<>();
Map<String,Object> map1 =new HashMap<>();
Map<String,Object> warningNum =new HashMap<>();
Map<String,Object> pointNum =new HashMap<>();
map1.put("name","危险");
map1.put("value",idxBizPvWarningRecordList.stream().filter(e->e.getWarningName().equals("危险")).count());
map.put("name","警告");
map.put("value",idxBizPvWarningRecordList.stream().filter(e->e.getWarningName().equals("警告")).count());
warningNum.put("name","注意");
warningNum.put("value",idxBizPvWarningRecordList.stream().filter(e->e.getWarningName().equals("注意")).count());
pointNum.put("name","安全");
pointNum.put("value", Math.max((total - idxBizPvWarningRecordList.size()), 0));
List<Map<String,Object>> list = new ArrayList<>();
list.add(pointNum);
list.add(warningNum);
list.add(map);
list.add(map1);
return ResponseHelper.buildResponse(list);
}
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "/selectWarningPoint")
@ApiOperation(httpMethod = "GET", value = "预警监测设备右侧预警重复列表", notes = "预警监测设备右侧预警重复列表")
public ResponseModel<List<PvWarningRecord>> selectFanWarningNum(@RequestParam String STATION,@RequestParam String EQUIPMENTNAME,@RequestParam String SUBARRAY) {
List<PvWarningRecord> maps = pvWaringRecordMapper.selectWarningPoint(STATION,EQUIPMENTNAME,SUBARRAY);
return ResponseHelper.buildResponse(maps);
}
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "/selectEquipWarningTotal")
@ApiOperation(httpMethod = "GET", value = "预警信息统计富文本", notes = "预警信息统计富文本")
public ResponseModel<List<Map<String,Object>>> selectEquipWarningTotal(@RequestParam String STATION,@RequestParam String EQUIPMENTNAME,@RequestParam String SUBARRAY) {
List<Map<String, Object>> maps = pvWaringRecordMapper.selectEquipWarningTotal(STATION,EQUIPMENTNAME,SUBARRAY);
return ResponseHelper.buildResponse(maps);
} }
}
...@@ -11,7 +11,7 @@ import java.util.List; ...@@ -11,7 +11,7 @@ import java.util.List;
public interface PvHealthIndexDayMapper extends BaseMapper<PvHealthIndexDay> { public interface PvHealthIndexDayMapper extends BaseMapper<PvHealthIndexDay> {
@Select("<script>"+ @Select("<script>"+
"SELECT `health_index` AS healthIndex,`health_index` AS `value`, rec_date AS recDate, analysis_time,station,equipment_name AS equipmentName, ( CASE HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status" + "SELECT `health_index` AS healthIndex,`health_index` AS `value`, rec_date AS recDate, analysis_time,station,equipment_name AS equipmentName, ( CASE HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status" +
"FROM analysis_data.pv_health_index_day WHERE and analysis_obj_type = #{analysisObjType}" + " FROM analysis_data.pv_health_index_day WHERE analysis_obj_type = #{analysisObjType}" +
"<if test='endTimeTop!= null'> and ts &lt;= #{endTimeTop} </if> " + "<if test='endTimeTop!= null'> and ts &lt;= #{endTimeTop} </if> " +
"<if test='startTimeTop!= null'> and ts &gt;= #{startTimeTop} </if> " + "<if test='startTimeTop!= null'> and ts &gt;= #{startTimeTop} </if> " +
"<if test='area!= null '> AND area = #{area} </if> " + "<if test='area!= null '> AND area = #{area} </if> " +
......
...@@ -11,7 +11,7 @@ import java.util.List; ...@@ -11,7 +11,7 @@ import java.util.List;
public interface PvHealthIndexHourMapper extends BaseMapper<PvHealthIndexHour> { public interface PvHealthIndexHourMapper extends BaseMapper<PvHealthIndexHour> {
@Select("<script>"+ @Select("<script>"+
"SELECT `health_index` AS healthIndex, `health_index` AS `value`, rec_date AS recDate, analysis_time,station,equipment_name AS equipmentName, ( CASE HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status" + "SELECT `health_index` AS healthIndex, `health_index` AS `value`, rec_date AS recDate, analysis_time,station,equipment_name AS equipmentName, ( CASE HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status" +
"FROM analysis_data.pv_health_index_hour WHERE and analysis_obj_type = #{analysisObjType}" + " FROM analysis_data.pv_health_index_hour WHERE analysis_obj_type = #{analysisObjType}" +
"<if test='endTimeTop!= null'> and ts &lt;= #{endTimeTop} </if> " + "<if test='endTimeTop!= null'> and ts &lt;= #{endTimeTop} </if> " +
"<if test='startTimeTop!= null'> and ts &gt;= #{startTimeTop} </if> " + "<if test='startTimeTop!= null'> and ts &gt;= #{startTimeTop} </if> " +
"<if test='area!= null '> AND area = #{area} </if> " + "<if test='area!= null '> AND area = #{area} </if> " +
...@@ -22,6 +22,6 @@ public interface PvHealthIndexHourMapper extends BaseMapper<PvHealthIndexHour> { ...@@ -22,6 +22,6 @@ public interface PvHealthIndexHourMapper extends BaseMapper<PvHealthIndexHour> {
"<if test='subarray!= null'>AND subarray = #{subarray} </if> " + "<if test='subarray!= null'>AND subarray = #{subarray} </if> " +
"<if test='equipmentName!= null'>AND equipment_name = #{equipmentName} </if>" + "<if test='equipmentName!= null'>AND equipment_name = #{equipmentName} </if>" +
"</script>") "</script>")
List<FanHealthIndexDay> selectData (@Param("healthLevel")String healthLevel, @Param("area")String area, @Param("equipmentName")String equipmentName, @Param("subSystem")String subSystem, @Param("analysisType")String analysisType, @Param("analysisObjType")String analysisObjType, @Param("station")String station, @Param("pointName")String pointName, @Param("indexAddress")String indexAddress, @Param("startTimeTop") String startTimeTop, @Param("endTimeTop")String endTimeTop); List<PvHealthIndexHour> selectData (@Param("healthLevel")String healthLevel, @Param("area")String area, @Param("equipmentName")String equipmentName, @Param("subarray")String subarray, @Param("analysisType")String analysisType, @Param("analysisObjType")String analysisObjType, @Param("station")String station, @Param("pointName")String pointName, @Param("indexAddress")String indexAddress, @Param("startTimeTop") String startTimeTop, @Param("endTimeTop")String endTimeTop);
} }
...@@ -16,7 +16,7 @@ import java.util.List; ...@@ -16,7 +16,7 @@ import java.util.List;
public interface PvHealthIndexMapper extends BaseMapper<PvHealthIndex> { public interface PvHealthIndexMapper extends BaseMapper<PvHealthIndex> {
@Select("<script>"+ @Select("<script>"+
"SELECT `health_index` AS healthIndex, `health_index` AS `value`, rec_date AS recDate, analysis_time,station,equipment_name AS equipmentName, ( CASE HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status" + "SELECT `health_index` AS healthIndex, `health_index` AS `value`, rec_date AS recDate, analysis_time,station,equipment_name AS equipmentName, ( CASE HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status" +
"FROM analysis_data.pv_health_index_data WHERE and analysis_obj_type = #{analysisObjType} and analysis_type = #{analysisType}" + " FROM analysis_data.pv_health_index_data WHERE analysis_obj_type = #{analysisObjType} and analysis_type = #{analysisType}" +
"<if test='endTimeTop!= null'> and ts &lt;= #{endTimeTop} </if> " + "<if test='endTimeTop!= null'> and ts &lt;= #{endTimeTop} </if> " +
"<if test='startTimeTop!= null'> and ts &gt;= #{startTimeTop} </if> " + "<if test='startTimeTop!= null'> and ts &gt;= #{startTimeTop} </if> " +
"<if test='area!= null '> AND area = #{area} </if> " + "<if test='area!= null '> AND area = #{area} </if> " +
......
...@@ -11,7 +11,7 @@ import java.util.List; ...@@ -11,7 +11,7 @@ import java.util.List;
public interface PvHealthIndexMomentMapper extends BaseMapper<PvHealthIndexMoment> { public interface PvHealthIndexMomentMapper extends BaseMapper<PvHealthIndexMoment> {
@Select("<script>"+ @Select("<script>"+
"SELECT `health_index` AS healthIndex,`health_index` AS `value`, rec_date AS recDate, analysis_time,station,equipment_name AS equipmentName, ( CASE HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status" + "SELECT `health_index` AS healthIndex,`health_index` AS `value`, rec_date AS recDate, analysis_time,station,equipment_name AS equipmentName, ( CASE HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status" +
"FROM analysis_data.pv_health_index_moment WHERE and analysis_obj_type = #{analysisObjType}" + " FROM analysis_data.pv_health_index_moment WHERE analysis_obj_type = #{analysisObjType}" +
"<if test='endTimeTop!= null'> and ts &lt;= #{endTimeTop} </if> " + "<if test='endTimeTop!= null'> and ts &lt;= #{endTimeTop} </if> " +
"<if test='startTimeTop!= null'> and ts &gt;= #{startTimeTop} </if> " + "<if test='startTimeTop!= null'> and ts &gt;= #{startTimeTop} </if> " +
"<if test='area!= null '> AND area = #{area} </if> " + "<if test='area!= null '> AND area = #{area} </if> " +
...@@ -22,5 +22,5 @@ public interface PvHealthIndexMomentMapper extends BaseMapper<PvHealthIndexMomen ...@@ -22,5 +22,5 @@ public interface PvHealthIndexMomentMapper extends BaseMapper<PvHealthIndexMomen
"<if test='subarray!= null'>AND subarray = #{subarray} </if> " + "<if test='subarray!= null'>AND subarray = #{subarray} </if> " +
"<if test='equipmentName!= null'>AND equipment_name = #{equipmentName} </if>" + "<if test='equipmentName!= null'>AND equipment_name = #{equipmentName} </if>" +
"</script>") "</script>")
List<FanHealthIndexDay> selectData(@Param("healthLevel")String healthLevel, @Param("area")String area, @Param("equipmentName")String equipmentName, @Param("subSystem")String subSystem, @Param("analysisType")String analysisType, @Param("analysisObjType")String analysisObjType, @Param("station")String station, @Param("pointName")String pointName, @Param("indexAddress")String indexAddress, @Param("startTimeTop") String startTimeTop, @Param("endTimeTop")String endTimeTop); List<PvHealthIndexMoment> selectData(@Param("healthLevel")String healthLevel, @Param("area")String area, @Param("equipmentName")String equipmentName, @Param("subarray")String subarray, @Param("analysisType")String analysisType, @Param("analysisObjType")String analysisObjType, @Param("station")String station, @Param("pointName")String pointName, @Param("indexAddress")String indexAddress, @Param("startTimeTop") String startTimeTop, @Param("endTimeTop")String endTimeTop);
} }
...@@ -6,8 +6,17 @@ import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvWarningRecord; ...@@ -6,8 +6,17 @@ import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvWarningRecord;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Map;
public interface PvWaringRecordMapper extends BaseMapper<PvWarningRecord> { public interface PvWaringRecordMapper extends BaseMapper<PvWarningRecord> {
int saveBatchWarningRecords(@Param("list") List<PvWarningRecord> list); int saveBatchWarningRecords(@Param("list") List<PvWarningRecord> list);
public List<PvWarningRecord> warningData(String STATION,String EQUIPMENTNAME,String SUBARRAY);
public List<Map<String,Object>> selectFanWarningNum(String station);
List<PvWarningRecord> selectWarningPoint(String STATION, String EQUIPMENTNAME, String SUBARRAY);
List<Map<String, Object>> selectEquipWarningTotal(String STATION, String EQUIPMENTNAME, String SUBARRAY);
} }
...@@ -53,4 +53,144 @@ ...@@ -53,4 +53,144 @@
#{item.status, jdbcType=VARCHAR}) #{item.status, jdbcType=VARCHAR})
</foreach> </foreach>
</insert> </insert>
<select id="warningData" resultType="com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvWarningRecord">
SELECT
warning_name as WarningName
FROM
analysis_data.pv_warning_record re
WHERE
re.`status` = 0
<if test="EQUIPMENTNAME != '' and EQUIPMENTNAME != null">
AND re.equipment_name = #{EQUIPMENTNAME}
</if>
<if test="SUBARRAY != null and SUBARRAY != '' ">
AND re.subarray = #{SUBARRAY}
</if>
<if test="STATION != null and STATION != '' ">
AND re.station = #{STATION}
</if>
</select>
<select id="selectFanWarningNum" resultType="map">
select
`a`.`subarray` as `subarray`,
`a`.`station` as `station`,
`a`.`警告` as `警告`,
`a`.`注意` as `注意`,
`a`.`危险` as `危险`,
sum(((`a`.`注意` + `a`.`危险`) + `a`.`警告`)) AS `sort`
from
(select
a.subarray,
a.station,
max( case a.warning_name when '危险' then num else 0 end ) as `危险`,
max( case a.warning_name when '注意' then num else 0 end ) as `注意`,
max( case a.warning_name when '警告' then num else 0 end ) as `警告`
from
(
select
re.warning_name,
re.subarray,
re.station,
count( 1 ) as num
from
analysis_data.pv_warning_record re
where
re.`status` = 0
or ( re.`status` = 1 and `ts` > (now() - 3d - 8h))
<if test="station != null">
and station = #{station}
</if>
group by
re.station,
re.subarray,
re.warning_name
) a
group by
a.subarray,a.station) a
group by
`a`.`subarray`,
`a`.`station`,`a`.`警告`, `a`.`注意`, `a`.`危险`
order by sort DESC
</select>
<select id="selectWarningPoint" resultType="com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvWarningRecord">
SELECT
a.station,
a.warning_name,
a.content,
a.equipment_name,
a.point_name,
a.rec_date
from
analysis_data.pv_warning_record a
where
a.status = 0
<if test="STATION != null and STATION != '' ">
AND a.station = #{STATION}
</if>
<if test="EQUIPMENTNAME != '' and EQUIPMENTNAME != null">
AND a.equipment_name = #{EQUIPMENTNAME}
</if>
<if test="SUBARRAY != '' and SUBARRAY != null">
AND a.subarray = #{SUBARRAY}
</if>
group by
station,
equipment_name,
point_name,
rec_date ,
content,
warning_name
</select>
<select id="selectEquipWarningTotal" resultType="map">
SELECT
`STATION` AS `STATION`,
`EQUIPMENT_NAME` AS `EQUIPMENT_NAME`,
max( ( case `WARNING_NAME` WHEN '注意' THEN `num` ELSE 0 END ) ) AS `zhuyi`,
max( ( case `WARNING_NAME` WHEN '警告' THEN `num` ELSE 0 END ) ) AS `jinggao`,
max( ( case `WARNING_NAME` WHEN '危险' THEN `num` ELSE 0 END ) ) AS `weixian`,
sum(
(
(
( CASE `WARNING_NAME` WHEN '注意' THEN `num` ELSE 0 END ) + ( case `WARNING_NAME` WHEN '警告' THEN `num` ELSE 0 END
)
) + ( case `WARNING_NAME` WHEN '危险' THEN `num` ELSE 0 END )
)
) AS `total`
FROM
(
select
`z`.`station` as `STATION`,
`z`.`equipment_name` as `EQUIPMENT_NAME`,
`z`.`warning_name` as `WARNING_NAME`,
count( 1 ) as `num`
from
analysis_data.fan_warning_record z where
( `z`.`status` = 0 )
<if test="STATION != null and STATION != '' ">
AND z.station = #{STATION}
</if>
<if test="EQUIPMENTNAME != '' and EQUIPMENTNAME != null">
AND z.equipment_name = #{EQUIPMENTNAME}
</if>
<if test="SUBARRAY != '' and SUBARRAY != null">
AND z.subarray = #{SUBARRAY}
</if>
group by
`z`.`station`,
`z`.`warning_name`,
`z`.`equipment_name`
) b
GROUP BY
`b`.`STATION`,
`b`.`EQUIPMENT_NAME`
</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