Commit 78d0acc7 authored by zhangsen's avatar zhangsen

脑图API

parent f7095eb3
......@@ -16,10 +16,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
......@@ -162,20 +159,20 @@ public class KafkaAnalyseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "全景诊断回溯")
@GetMapping("/getFullViewRecall")
public ResponseModel<List<FullViewRecallInfoDTO>> getFullViewRecall() {
List<Map<String, Object>> stationIndexInfo = idxBizFanHealthIndexMapper.getStationIndexInfo();
public ResponseModel<List<FullViewRecallInfoDTO>> getFullViewRecall(@RequestParam(required = false, value = "analysisType") String analysisType) {
List<Map<String, Object>> stationIndexInfo = idxBizFanHealthIndexMapper.getStationIndexInfoByParam(analysisType);
Map<String, Double> stationHealthIndexMap = stationIndexInfo.stream().collect(Collectors.toMap(t -> t.get("station").toString(), t -> Double.parseDouble(t.get("healthIndex").toString())));
List<Map<String, Object>> equipmentIndexInfo = idxBizFanHealthIndexMapper.getEquipmentIndexInfo();
List<Map<String, Object>> equipmentIndexInfo = idxBizFanHealthIndexMapper.getEquipmentIndexInfoByParam(analysisType);
Map<String, Double> equipmentIndexInfoMap = equipmentIndexInfo.stream().collect(Collectors.toMap(t -> t.get("equipmentName").toString(), t -> Double.parseDouble(t.get("healthIndex").toString())));
List<Map<String, Object>> subSystemIndexInfo = idxBizFanHealthIndexMapper.getSubSystemIndexInfo();
List<Map<String, Object>> subSystemIndexInfo = idxBizFanHealthIndexMapper.getSubSystemIndexInfoByParam(analysisType);
Map<String, Double> subSystemIndexInfoMap = subSystemIndexInfo.stream().collect(Collectors.toMap(t -> t.get("subSystem").toString(), t -> Double.parseDouble(t.get("healthIndex").toString())));
List<Map<String, Object>> pointNameIndexInfo = idxBizFanHealthIndexMapper.getPointNameIndexInfo();
List<Map<String, Object>> pointNameIndexInfo = idxBizFanHealthIndexMapper.getPointNameIndexInfoByParam(analysisType);
Map<String, Double> pointNameIndexInfoMap = pointNameIndexInfo.stream().collect(Collectors.toMap(t -> t.get("gatewayIndexAddress").toString(), t -> Double.parseDouble(t.get("healthIndex").toString())));
......
......@@ -99,6 +99,15 @@ public interface IdxBizFanHealthIndexMapper extends BaseMapper<IdxBizFanHealthIn
List<Map<String, Object>> getPointNameIndexInfo();
List<Map<String, Object>> getStationIndexInfoByParam(@Param("analysisType") String analysisType);
List<Map<String, Object>> getEquipmentIndexInfoByParam(@Param("analysisType") String analysisType);
List<Map<String, Object>> getSubSystemIndexInfoByParam(@Param("analysisType") String analysisType);
List<Map<String, Object>> getPointNameIndexInfoByParam(@Param("analysisType") String analysisType);
List<IdxBizFanHealthLevel> getHealthLevelInfoList();
......
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.excel.EasyExcel;
......@@ -1453,8 +1454,8 @@ public class CommonServiceImpl {
if (!openHealth) {
return;
}
Date time = new Date();
String format = DateUtil.format(time, DatePattern.NORM_DATETIME_PATTERN);
String format = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:00");
Date time = DateUtil.parse(format, "yyyy-MM-dd HH:mm:00");
Calendar calendar = Calendar.getInstance();
List<IdxBizFanPointProcessVariableClassificationDto> data = idxBizFanPointProcessVariableClassificationMapper.getInfluxDBData();
Map<String, List<IdxBizFanPointProcessVariableClassificationDto>> maps = data.stream().collect(Collectors.groupingBy(IdxBizFanPointProcessVariableClassificationDto::getGatewayId));
......@@ -1709,8 +1710,8 @@ public class CommonServiceImpl {
return;
}
Calendar calendar = Calendar.getInstance();
Date time = new Date();
String format = DateUtil.format(time, DatePattern.NORM_DATETIME_PATTERN);
String format = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:00");
Date time = DateUtil.parse(format, "yyyy-MM-dd HH:mm:00");
List<IdxBizPvPointProcessVariableClassificationDto> data = idxBizPvPointProcessVariableClassificationMapper.getInfluxDBData();
Map<String, List<IdxBizPvPointProcessVariableClassificationDto>> maps = data.stream().collect(Collectors.groupingBy(IdxBizPvPointProcessVariableClassificationDto::getGatewayId));
// BoolQueryBuilder boolMustAll = QueryBuilders.boolQuery();
......
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.jxiop.api.dto.BizMessage;
import com.yeejoin.amos.boot.module.jxiop.api.dto.RiskBizInfoVo;
import com.yeejoin.amos.boot.module.jxiop.api.dto.RiskDynamicDetailsVo;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanHealthIndexMomentMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexMoment;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Service;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@Slf4j
@Service
@EnableScheduling
public class TdengineTimeServiceImpl {
@Autowired
private FanHealthIndexMomentMapper fanHealthIndexMomentMapper;
/**
* 风电 - 按小时生成测点数据
*/
@Async
public void insertHourData() {
QueryWrapper<FanHealthIndexMoment> fanHealthLambda = new QueryWrapper<>();
fanHealthLambda.select("*, FORMAT(AVG(HEALTH_INDEX),2) as avgHealthIndex");
fanHealthLambda.lambda().ge(FanHealthIndexMoment::getRecDate, DateUtils.dateAddHours(new Date(), -1));
fanHealthLambda.lambda().eq(FanHealthIndexMoment::getAnalysisObjType, "测点");
fanHealthLambda.lambda().groupBy
(FanHealthIndexMoment::getGatewayId,
FanHealthIndexMoment::getIndexAddress
);
List<FanHealthIndexMoment> fanHealthIndexMoments = fanHealthIndexMomentMapper.selectList(fanHealthLambda);
fanHealthIndexMoments.forEach(item -> {
});
}
}
......@@ -1284,4 +1284,207 @@
AND GATEWAY_ID = #{fanGatewayId}
and DISPOSOTION_STATE = '未处置'
</select>
<select id="getStationIndexInfoByParam" resultType="java.util.Map">
SELECT a.STATION AS station,
ROUND(avg(a.avgHealthIndex), 2) AS healthIndex
FROM (
SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex,
STATION AS STATION
FROM idx_biz_fan_health_index
<where>
ANALYSIS_OBJ_TYPE = '场站'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''">
AND ANALYSIS_TYPE = '按天'
AND DATE_FORMAT(REC_DATE, "%Y-%m-%d") = CURRENT_DATE
</if>
<if test="analysisType == '按小时'">
AND ANALYSIS_TYPE = '按小时'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 59 MINUTE )
</if>
<if test="analysisType == '按时刻'">
AND ANALYSIS_TYPE = '按时刻'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 9 MINUTE )
</if>
</where>
GROUP BY STATION
UNION ALL
(
SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex,
STATION AS STATION
FROM idx_biz_pv_health_index
<where>
ANALYSIS_OBJ_TYPE = '场站'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''">
AND ANALYSIS_TYPE = '按天'
AND DATE_FORMAT(REC_DATE, "%Y-%m-%d") = CURRENT_DATE
</if>
<if test="analysisType == '按小时'">
AND ANALYSIS_TYPE = '按小时'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 59 MINUTE )
</if>
<if test="analysisType == '按时刻'">
AND ANALYSIS_TYPE = '按时刻'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 9 MINUTE )
</if>
</where>
GROUP BY STATION
)
) a
GROUP BY a.STATION
</select>
<select id="getEquipmentIndexInfoByParam" resultType="java.util.Map">
SELECT a.equipmentName AS equipmentName,
ROUND(avg(a.avgHealthIndex), 2) AS healthIndex
FROM (
SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex,
EQUIPMENT_NAME AS equipmentName
FROM idx_biz_fan_health_index
<where>
ANALYSIS_OBJ_TYPE = '设备'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''">
AND ANALYSIS_TYPE = '按天'
AND DATE_FORMAT(REC_DATE, "%Y-%m-%d") = CURRENT_DATE
</if>
<if test="analysisType == '按小时'">
AND ANALYSIS_TYPE = '按小时'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 59 MINUTE )
</if>
<if test="analysisType == '按时刻'">
AND ANALYSIS_TYPE = '按时刻'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 9 MINUTE )
</if>
</where>
GROUP BY EQUIPMENT_NAME
UNION ALL
(
SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex,
SUBARRAY AS equipmentName
FROM idx_biz_pv_health_index
<where>
ANALYSIS_OBJ_TYPE = '子阵'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''">
AND ANALYSIS_TYPE = '按天'
AND DATE_FORMAT(REC_DATE, "%Y-%m-%d") = CURRENT_DATE
</if>
<if test="analysisType == '按小时'">
AND ANALYSIS_TYPE = '按小时'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 59 MINUTE )
</if>
<if test="analysisType == '按时刻'">
AND ANALYSIS_TYPE = '按时刻'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 9 MINUTE )
</if>
</where>
GROUP BY SUBARRAY
)
) a
where equipmentName is not null
and equipmentName != ''
GROUP BY
a.equipmentName
</select>
<select id="getSubSystemIndexInfoByParam" resultType="java.util.Map">
SELECT a.subSystem AS subSystem,
ROUND(avg(a.avgHealthIndex), 2) AS healthIndex
FROM (
SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex,
SUB_SYSTEM AS subSystem
FROM idx_biz_fan_health_index
<where>
ANALYSIS_OBJ_TYPE = '子系统'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''">
AND ANALYSIS_TYPE = '按天'
AND DATE_FORMAT(REC_DATE, "%Y-%m-%d") = CURRENT_DATE
</if>
<if test="analysisType == '按小时'">
AND ANALYSIS_TYPE = '按小时'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 59 MINUTE )
</if>
<if test="analysisType == '按时刻'">
AND ANALYSIS_TYPE = '按时刻'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 9 MINUTE )
</if>
</where>
GROUP BY SUB_SYSTEM
UNION ALL
(
SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex,
EQUIPMENT_NAME AS subSystem
FROM idx_biz_pv_health_index
<where>
ANALYSIS_OBJ_TYPE = '设备'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''">
AND ANALYSIS_TYPE = '按天'
AND DATE_FORMAT(REC_DATE, "%Y-%m-%d") = CURRENT_DATE
</if>
<if test="analysisType == '按小时'">
AND ANALYSIS_TYPE = '按小时'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 59 MINUTE )
</if>
<if test="analysisType == '按时刻'">
AND ANALYSIS_TYPE = '按时刻'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 9 MINUTE )
</if>
</where>
GROUP BY EQUIPMENT_NAME
)
) a
where subSystem is not null
and subSystem != ''
GROUP BY
a.subSystem
</select>
<select id="getPointNameIndexInfoByParam" resultType="java.util.Map">
SELECT IFNULL(HEALTH_INDEX, 100) AS healthIndex,
concat(STATION, '_', INDEX_ADDRESS) as gatewayIndexAddress
FROM idx_biz_fan_health_index
<where>
ANALYSIS_OBJ_TYPE = '测点'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''">
AND ANALYSIS_TYPE = '按天'
AND DATE_FORMAT(REC_DATE, "%Y-%m-%d") = CURRENT_DATE
</if>
<if test="analysisType == '按小时'">
AND ANALYSIS_TYPE = '按小时'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 59 MINUTE )
</if>
<if test="analysisType == '按时刻'">
AND ANALYSIS_TYPE = '按时刻'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 9 MINUTE )
</if>
</where>
GROUP BY INDEX_ADDRESS
UNION ALL
(
SELECT IFNULL(HEALTH_INDEX, 100) AS healthIndex,
concat(STATION, '_', INDEX_ADDRESS) as gatewayIndexAddress
FROM idx_biz_pv_health_index
<where>
ANALYSIS_OBJ_TYPE = '测点'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''">
AND ANALYSIS_TYPE = '按天'
AND DATE_FORMAT(REC_DATE, "%Y-%m-%d") = CURRENT_DATE
</if>
<if test="analysisType == '按小时'">
AND ANALYSIS_TYPE = '按小时'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 59 MINUTE )
</if>
<if test="analysisType == '按时刻'">
AND ANALYSIS_TYPE = '按时刻'
AND REC_DATE >= DATE_SUB( NOW(), INTERVAL 9 MINUTE )
</if>
</where>
GROUP BY INDEX_ADDRESS
)
</select>
</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