Commit 897337b0 authored by chenzhao's avatar chenzhao

大屏 TD接口开发

parent 25285773
...@@ -265,7 +265,7 @@ public class AnalyseController extends BaseController { ...@@ -265,7 +265,7 @@ public class AnalyseController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "预警详情信息-光伏", notes = "预警详情信息-光伏") @ApiOperation(httpMethod = "GET", value = "预警详情信息-光伏", notes = "预警详情信息-光伏")
@GetMapping(value = "/queryIndexByArae") @GetMapping(value = "/queryIndexByArae")
public ResponseModel<Map<String, Object>> queryIndexByArae(String area, String analysisType, String startTimeTop, String endTimeTop) { public ResponseModel<Map<String, Object>> queryIndexByArae(@RequestParam(required = false) String area, String analysisType, String startTimeTop, String endTimeTop) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if ( null != endTimeTop){ if ( null != endTimeTop){
......
...@@ -20,6 +20,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.*; ...@@ -20,6 +20,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.*;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl;
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 com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper; import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege; import com.yeejoin.amos.feign.privilege.Privilege;
...@@ -56,6 +57,8 @@ public class BigScreenAnalyseController extends BaseController { ...@@ -56,6 +57,8 @@ public class BigScreenAnalyseController extends BaseController {
@Autowired @Autowired
IdxBizPvHealthLevelMapper idxBizPvHealthLevelMapper; IdxBizPvHealthLevelMapper idxBizPvHealthLevelMapper;
@Autowired
FanWaringRecordMapper fanWaringRecordMapper;
@Autowired @Autowired
StationBasicMapper stationBasicMapper; StationBasicMapper stationBasicMapper;
......
...@@ -21,6 +21,14 @@ import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvHealthLevelMapper; ...@@ -21,6 +21,14 @@ import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvHealthLevelMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl;
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.FanHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanWaringRecordMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvWaringRecordMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper; import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege; import com.yeejoin.amos.feign.privilege.Privilege;
...@@ -28,6 +36,7 @@ import com.yeejoin.amos.feign.privilege.model.CompanyModel; ...@@ -28,6 +36,7 @@ import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
...@@ -38,6 +47,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel; ...@@ -38,6 +47,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -57,6 +67,10 @@ public class TDBigScreenAnalyseController extends BaseController { ...@@ -57,6 +67,10 @@ public class TDBigScreenAnalyseController extends BaseController {
@Autowired @Autowired
FanHealthIndexMapper fanHealthIndexMapper;
@Autowired
PvHealthIndexMapper pvHealthIndexMapper;
@Autowired
StationBasicMapper stationBasicMapper; StationBasicMapper stationBasicMapper;
@Autowired @Autowired
...@@ -71,6 +85,12 @@ public class TDBigScreenAnalyseController extends BaseController { ...@@ -71,6 +85,12 @@ public class TDBigScreenAnalyseController extends BaseController {
@Autowired @Autowired
RiskWarningFeign riskWarningFeign; RiskWarningFeign riskWarningFeign;
@Autowired
FanWaringRecordMapper fanWaringRecordMapper;
@Autowired
PvWaringRecordMapper pvWaringRecordMapper;
@Autowired @Autowired
private IdxBizFanWarningRuleSetServiceImpl idxBizFanWarningRuleSetService; private IdxBizFanWarningRuleSetServiceImpl idxBizFanWarningRuleSetService;
...@@ -128,7 +148,13 @@ public class TDBigScreenAnalyseController extends BaseController { ...@@ -128,7 +148,13 @@ public class TDBigScreenAnalyseController extends BaseController {
@GetMapping(value = "/getAllEquipAlarmInfo") @GetMapping(value = "/getAllEquipAlarmInfo")
public ResponseModel<Map<String, Object>> getAllEquipAlarmInfo(@RequestParam(required = false) String tableName) throws Exception { public ResponseModel<Map<String, Object>> getAllEquipAlarmInfo(@RequestParam(required = false) String tableName) throws Exception {
Map<String, Object> resultMap = new HashMap<>(); Map<String, Object> resultMap = new HashMap<>();
List<Map<String, Object>> allEquipAlarmInfo = idxBizFanHealthIndexMapper.getAllEquipAlarmInfo(tableName); List<Map<String, Object>> allEquipAlarmInfo = new ArrayList<>();
if (tableName.contains("fan")){
allEquipAlarmInfo = fanWaringRecordMapper.getAllEquipAlarmInfo();
}else {
allEquipAlarmInfo = pvWaringRecordMapper.getAllEquipAlarmInfo();
}
HashMap<String, Integer> wxMap = new HashMap<>(); HashMap<String, Integer> wxMap = new HashMap<>();
HashMap<String, Integer> zyMap = new HashMap<>(); HashMap<String, Integer> zyMap = new HashMap<>();
HashMap<String, Integer> jgMap = new HashMap<>(); HashMap<String, Integer> jgMap = new HashMap<>();
...@@ -226,7 +252,7 @@ public class TDBigScreenAnalyseController extends BaseController { ...@@ -226,7 +252,7 @@ public class TDBigScreenAnalyseController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "全域各场站设备实时预警处置信息", notes = "全域各场站设备实时预警处置信息") @ApiOperation(httpMethod = "GET", value = "全域各场站设备实时预警处置信息", notes = "全域各场站设备实时预警处置信息")
@GetMapping(value = "/getEquipWarningInfoByPage") @GetMapping(value = "/getEquipWarningInfoByPage")
public ResponseModel<IPage<IdxBizFanWarningRecord>> getEquipWarningInfoByPage(@RequestParam(value = "arae", required = false) String arae, public ResponseModel<IPage<FanWarningRecord>> getEquipWarningInfoByPage(@RequestParam(value = "arae", required = false) String arae,
@RequestParam(value = "station", required = false) String station, @RequestParam(value = "station", required = false) String station,
@RequestParam(value = "stationType", required = false) String stationType, @RequestParam(value = "stationType", required = false) String stationType,
@RequestParam(value = "current", required = false) Integer current, @RequestParam(value = "current", required = false) Integer current,
...@@ -241,9 +267,11 @@ public class TDBigScreenAnalyseController extends BaseController { ...@@ -241,9 +267,11 @@ public class TDBigScreenAnalyseController extends BaseController {
StationBasic stationBasic = stationBasicMapper.selectById(stationId); StationBasic stationBasic = stationBasicMapper.selectById(stationId);
stationId = stationBasic.getFanGatewayId(); stationId = stationBasic.getFanGatewayId();
} }
Integer count = idxBizFanWarningRecordMapper.getEquipWarningInfoByPageCount(arae, station, stationType, warningName, stationId, startDate, endDate); Integer count = fanWaringRecordMapper.getEquipWarningInfoByPageCount(arae, station, stationType, warningName, stationId, startDate, endDate);
List<IdxBizFanWarningRecord> idxBizFanWarningRecordIPage = idxBizFanWarningRecordMapper.getEquipWarningInfoByPage(arae, station, stationType, (current - 1) * size, size, warningName, stationId, startDate, endDate); // List<IdxBizFanWarningRecord> idxBizFanWarningRecordIPage = idxBizFanWarningRecordMapper.getEquipWarningInfoByPage(arae, station, stationType, (current - 1) * size, size, warningName, stationId, startDate, endDate);
Page<IdxBizFanWarningRecord> idxBizFanWarningRecordPage = new Page<>(current, size); List<FanWarningRecord> idxBizFanWarningRecordIPage = fanWaringRecordMapper.getEquipWarningInfoByPage(arae, station, stationType, (current - 1) * size, size, warningName, stationId, startDate, endDate);
Page<FanWarningRecord> idxBizFanWarningRecordPage = new Page<>(current, size);
idxBizFanWarningRecordPage.setRecords(idxBizFanWarningRecordIPage); idxBizFanWarningRecordPage.setRecords(idxBizFanWarningRecordIPage);
idxBizFanWarningRecordPage.setTotal(count); idxBizFanWarningRecordPage.setTotal(count);
return ResponseHelper.buildResponse(idxBizFanWarningRecordPage); return ResponseHelper.buildResponse(idxBizFanWarningRecordPage);
...@@ -1108,4 +1136,41 @@ public class TDBigScreenAnalyseController extends BaseController { ...@@ -1108,4 +1136,41 @@ public class TDBigScreenAnalyseController extends BaseController {
return ResponseHelper.buildResponse(true); return ResponseHelper.buildResponse(true);
} }
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "预警详情信息-光伏", notes = "预警详情信息-光伏")
@GetMapping(value = "/queryIndexByArae")
public ResponseModel<Map<String, Object>> queryIndexByArae(@RequestParam(required = false) String area, String analysisType, String startTimeTop, String endTimeTop) {
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<FanHealthIndex> fanHealthIndices = fanHealthIndexMapper.selectData(null, area, null, null, analysisType, "片区", null, null, null, startTimeTop, endTimeTop);
List<PvHealthIndex> pvHealthIndices = pvHealthIndexMapper.selectData(null, area, null, null, analysisType, "片区", null, null, null, startTimeTop, endTimeTop);
for (PvHealthIndex pvHealthIndex : pvHealthIndices) {
FanHealthIndex fanHealthIndex = new FanHealthIndex();
BeanUtils.copyProperties(pvHealthIndex,fanHealthIndex);
fanHealthIndices.add(fanHealthIndex);
}
Map<String, Object> map = new HashMap<>();
List<Object> axisData = new ArrayList<>();
List<Object> seriesData = new ArrayList<>();
Map<String, List<FanHealthIndex>> mapList = fanHealthIndices.stream().collect(Collectors.groupingBy(FanHealthIndex::getAnalysisTime));
for (String s : mapList.keySet()) {
List<FanHealthIndex> fanHealthIndices1 = mapList.get(s);
Double healtnIndex = fanHealthIndices1.stream().collect(Collectors.averagingDouble(FanHealthIndex::getHealthIndex));
seriesData.add(healtnIndex.intValue());
axisData.add(s);
}
map.put("axisData", axisData);
map.put("seriesData", seriesData);
return ResponseHelper.buildResponse(map);
}
} }
...@@ -25,6 +25,7 @@ public interface FanWaringRecordMapper extends BaseMapper<FanWarningRecord> { ...@@ -25,6 +25,7 @@ public interface FanWaringRecordMapper extends BaseMapper<FanWarningRecord> {
int saveBatchWarningRecords(@Param("list") List<FanWarningRecord> list); int saveBatchWarningRecords(@Param("list") List<FanWarningRecord> list);
List<Map<String, Object>> getAllEquipAlarmInfo();
List<FanWarningRecord> getInfoByPage(@Param("dto") FanHealthIndexDto dto); List<FanWarningRecord> getInfoByPage(@Param("dto") FanHealthIndexDto dto);
...@@ -33,5 +34,13 @@ public interface FanWaringRecordMapper extends BaseMapper<FanWarningRecord> { ...@@ -33,5 +34,13 @@ public interface FanWaringRecordMapper extends BaseMapper<FanWarningRecord> {
FanWarningRecord getInfoByTs(@Param("ts") Long ts); FanWarningRecord getInfoByTs(@Param("ts") Long ts);
int updateStatusByTs(@Param("list") List<FanWarningRecord> list); int updateStatusByTs(@Param("list") List<FanWarningRecord> list);
Integer getEquipWarningInfoByPageCount(@Param("arae") String arae,
@Param("station") String station,
@Param("stationType") String stationType,
@Param("warningName") String warningName,
@Param("stationId") String stationId,
@Param("startDate") String startDate,
@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);
} }
...@@ -29,4 +29,6 @@ public interface PvWaringRecordMapper extends BaseMapper<PvWarningRecord> { ...@@ -29,4 +29,6 @@ public interface PvWaringRecordMapper extends BaseMapper<PvWarningRecord> {
PvWarningRecord getInfoByTs(@Param("ts") Long ts); PvWarningRecord getInfoByTs(@Param("ts") Long ts);
int updateStatusByTs(@Param("list") List<PvWarningRecord> list); int updateStatusByTs(@Param("list") List<PvWarningRecord> list);
List<Map<String, Object>> getAllEquipAlarmInfo();
} }
...@@ -233,4 +233,147 @@ ...@@ -233,4 +233,147 @@
</foreach> </foreach>
</insert> </insert>
<select id="getAllEquipAlarmInfo" resultType="map">
select arae as area,
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 ))
group by arae,
warning_name
</select>
<select id="getEquipWarningInfoByPage" resultType="com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanWarningRecord">
select
a.*
from
(
select
rec_date as recdate,
station as station,
equipment_name as equipmentname,
content as content,
warning_name as warningname,
disposotion_state as disposotionstate,
arae as arae,
'pv' as stationtype,
gateway_id,
concat(point_name, '异常') as pointname,
disposotion_date as disposotiondate,
(case when warning_name = '注意' then 1
when warning_name = '警告' then 2
when warning_name = '危险' then 3
end) as sort
from
analysis_data.pv_warning_record union all
select
rec_date as recdate,
station as station,
equipment_name as equipmentname,
content as content,
warning_name as warningname,
disposotion_state as disposotionstate,
arae as arae,
'fan' as stationtype,
gateway_id,
concat(point_name, '异常') as pointname,
disposotion_date as disposotiondate,
(case when warning_name = '注意' then 1
when warning_name = '警告' then 2
when warning_name = '危险' then 3
end) as sort
from
analysis_data.fan_warning_record
) a
<where>
(a.disposotionstate = '未处置') or (a.disposotionstate = '已处置' and a.disposotiondate >( now()- 3d - 8h ))
<if test="arae != '' and arae != null">
and a.arae like concat('%', #{arae}, '%')
</if>
<if test="station != '' and station != null">
and a.station = #{station}
</if>
<if test="stationtype != '' and stationtype != null">
and a.stationtype = #{stationtype}
</if>
<if test="warningname != '' and warningname != null">
and a.warningname = #{warningname}
</if>
<if test="stationid != '' and stationid != null">
and a.gateway_id = #{stationid}
</if>
<if test="startdate != '' and startdate != null">
and a.recdate >= concat(#{startdate}, ' 00:00:00')
</if>
<if test="enddate != '' and enddate != null">
and concat(#{enddate}, ' 23:59:59') >= a.recdate
</if>
</where>
order by sort desc, recdate desc
limit #{current}, #{size}
</select>
<select id="getEquipWarningInfoByPageCount" resultType="integer">
select count(1) from
(select
a.*
from
(
select
rec_date as recdate,
station as station,
equipment_name as equipmentname,
content as content,
warning_name as warningname,
disposotion_state as disposotionstate,
arae as arae,
'pv' as stationtype,
gateway_id,
disposotion_date as disposotiondate
from
analysis_data.pv_warning_record union all
select
rec_date as recdate,
station as station,
equipment_name as equipmentname,
content as content,
warning_name as warningname,
disposotion_state as disposotionstate,
arae as arae,
'fan' as stationtype,
gateway_id,
disposotion_date as disposotiondate
from
analysis_data.fan_warning_record
) a
<where>
a.disposotionstate = '未处置' or (a.disposotionstate = '已处置' and a.disposotiondate > ( now() - 3D - 8h ))
<if test="arae != '' and arae != null">
and a.arae like concat('%', #{arae}, '%')
</if>
<if test="station != '' and station != null">
and a.station = #{station}
</if>
<if test="stationtype != '' and stationtype != null">
and a.stationtype = #{stationtype}
</if>
<if test="warningname != '' and warningname != null">
and a.warningname = #{warningname}
</if>
<if test="stationid != '' and stationid != null">
and a.gateway_id = #{stationid}
</if>
<if test="startdate != '' and startdate != null">
and a.recdate >= concat(#{startdate}, ' 00:00:00')
</if>
<if test="enddate != '' and enddate != null">
and concat(#{enddate}, ' 23:59:59') >= a.recdate
</if>
</where>) b
</select>
</mapper> </mapper>
...@@ -248,4 +248,17 @@ ...@@ -248,4 +248,17 @@
#{item.status, jdbcType=VARCHAR}) #{item.status, jdbcType=VARCHAR})
</foreach> </foreach>
</insert> </insert>
<select id="getAllEquipAlarmInfo" resultType="map">
select arae as area,
warning_name as warningname,
count(1) as num
from analysis_data.pv_warning_record a
where (a.disposotion_state = '未处置')
or (a.disposotion_state = '已处置' and a.disposotion_date >(now()-3d -8h ))
group by arae,
warning_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