Commit dde55de9 authored by zhangsen's avatar zhangsen

分析需求API

parent 7c1f7b7c
package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments;
......@@ -14,12 +16,15 @@ import com.yeejoin.amos.boot.module.jxiop.biz.dto.ESEquipmentsDTO;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthLevel;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanPointProcessVariableClassification;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IndicatorData;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanHealthLevelMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanWarningRecordMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -55,6 +60,9 @@ public class BigScreenAnalyseController extends BaseController {
@Autowired
IdxBizFanHealthLevelMapper idxBizFanHealthLevelMapper;
@Autowired
IndicatorDataMapper indicatorDataMapper;
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "场站设备健康状态指数与趋势 - 仪表盘", notes = "场站设备健康状态指数与趋势 - 仪表盘")
@GetMapping(value = "/getHealthScoreInfo")
......@@ -553,4 +561,39 @@ public class BigScreenAnalyseController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "风站/光伏 右下实时趋势")
@GetMapping("/getTrendInfoByAddress")
public ResponseModel<Map<String, Object>> getTrendInfoByAddress(@RequestParam(value = "indexAddress", required = false) String indexAddress,
@RequestParam(value = "stationId", required = false) String stationId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
Date currentDayStartTime = DateUtils.getCurrentDayStartTime(new Date());
Date currentDayEndTime = DateUtils.getCurrentDayEndTime(new Date());
String startTime = DateUtils.convertDateToString(currentDayStartTime, DateUtils.DATE_TIME_PATTERN);
String endTime = DateUtils.convertDateToString(currentDayEndTime, DateUtils.DATE_TIME_PATTERN);
List<IndicatorData> indicatorData = indicatorDataMapper.selectDataByAddressAndtime(indexAddress, startTime, endTime, stationBasic.getFanGatewayId());
HashMap<String, Object> resultMap = new HashMap<>();
List<String> time = new ArrayList<>();
List<Object> valueList = new ArrayList<>();
indicatorData.forEach(item -> {
String date = DateUtils.convertDateToString(item.getCreatedTime(), "HH:mm:ss");
time.add(date);
String value = StrUtil.isEmpty(item.getValue()) ? "0.0" : item.getValue();
double v = Double.parseDouble(value);
valueList.add(v);
});
List<Map<String, Object>> arrayList = new ArrayList<>();
HashMap<String, Object> stringStringHashMap = new HashMap<>();
stringStringHashMap.put("data", valueList);
arrayList.add(stringStringHashMap);
resultMap.put("axisData", time);
resultMap.put("seriesData", arrayList);
return ResponseHelper.buildResponse(resultMap);
}
}
......@@ -11,7 +11,7 @@ import java.util.List;
@Repository
public interface IndicatorDataMapper extends BaseMapper<IndicatorData> {
@Select("select `value` from iot_data.indicator_data where address=#{address} and createdtime >= #{startTime} and createdtime <= #{endTime} and gateway_id =#{gatewayId}")
@Select("select `value`, createdTime, `value_f` as valueF from iot_data.indicator_data where address=#{address} and createdtime >= #{startTime} and createdtime <= #{endTime} and gateway_id =#{gatewayId}")
List<IndicatorData> selectDataByAddressAndtime(@Param("address")String address,@Param("startTime") String startTime, @Param("endTime")String endTime, @Param("gatewayId")String gatewayId);
}
......@@ -328,7 +328,8 @@
<select id="getFanInfoByPage" resultType="java.util.Map">
SELECT
EQUIPMENT_NAME as equipmentName
EQUIPMENT_NAME as equipmentName,
INDEX_ADDRESS as indexAddress
FROM
idx_biz_fan_point_process_variable_classification
<where>
......@@ -364,12 +365,17 @@
<select id="getSumSystemListByEquipment" resultType="java.util.Map">
SELECT
SUB_SYSTEM as subSystem
SUB_SYSTEM as subSystem,
INDEX_ADDRESS as indexAddress
FROM
idx_biz_fan_point_process_variable_classification
<where>
EQUIPMENT_NAME = #{equipmentName}
AND GATEWAY_ID = #{gatewayId}
<if test="equipmentName != null and equipmentName != ''">
AND EQUIPMENT_NAME = #{equipmentName}
</if>
<if test="gatewayId != null and gatewayId != ''">
AND GATEWAY_ID = #{gatewayId}
</if>
</where>
GROUP BY
SUB_SYSTEM
......@@ -377,12 +383,17 @@
<select id="getPointNameListBySumSystem" resultType="java.util.Map">
SELECT
POINT_NAME as pointName
POINT_NAME as pointName,
INDEX_ADDRESS as indexAddress
FROM
idx_biz_fan_point_process_variable_classification
<where>
SUB_SYSTEM = #{subSystem}
AND GATEWAY_ID = #{gatewayId}
<if test="subSystem != null and subSystem != ''">
AND SUB_SYSTEM = #{subSystem}
</if>
<if test="gatewayId != null and gatewayId != ''">
AND GATEWAY_ID = #{gatewayId}
</if>
</where>
GROUP BY
POINT_NAME
......@@ -491,8 +502,12 @@
FROM
idx_biz_pv_point_process_variable_classification
<where>
SUBARRAY = #{subarray}
AND GATEWAY_ID = #{gatewayId}
<if test="subarray != null and subarray != ''">
AND SUBARRAY = #{subarray}
</if>
<if test="gatewayId != null and gatewayId != ''">
AND GATEWAY_ID = #{gatewayId}
</if>
</where>
GROUP BY
EQUIPMENT_NAME
......@@ -536,8 +551,12 @@
FROM
idx_biz_pv_point_process_variable_classification
<where>
EQUIPMENT_NAME = #{equipmentName}
AND GATEWAY_ID = #{gatewayId}
<if test="equipmentName != null and equipmentName != ''">
AND EQUIPMENT_NAME = #{equipmentName}
</if>
<if test="gatewayId != null and gatewayId != ''">
AND GATEWAY_ID = #{gatewayId}
</if>
</where>
GROUP BY
POINT_NAME
......
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