Commit 9d212a62 authored by tangwei's avatar tangwei

解决冲突

parents 839d7866 25285773
package com.yeejoin.amos.boot.module.jxiop.biz.Enum;
public enum HealthLevelSortEnum {
ANQUAN(1,"安全"),
ZHUYI(2,"注意"),
JINGGAO(3, "警告"),
WEIXIAN(4,"危险");
private int code;
private String name;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
HealthLevelSortEnum(int code, String name) {
this.code = code;
this.name = name;
}
public static int getCode(String name) {
for (HealthLevelSortEnum warningNameEnum : HealthLevelSortEnum.values())
{
if (warningNameEnum.getName().equals(name))
{
return warningNameEnum.getCode();
}
}
return 0;
}
}
...@@ -11,9 +11,15 @@ import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvPointProcessVariabl ...@@ -11,9 +11,15 @@ import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvPointProcessVariabl
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanHealthIndexMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.service.IAlarmInfoDetailService; import com.yeejoin.amos.boot.module.jxiop.biz.service.IAlarmInfoDetailService;
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.tdMapper2.FanHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexDay;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex;
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.StringUtils; import org.apache.commons.lang3.StringUtils;
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;
...@@ -22,7 +28,9 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper; ...@@ -22,7 +28,9 @@ 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 java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* @author system_generator * @author system_generator
...@@ -41,6 +49,11 @@ public class AnalyseController extends BaseController { ...@@ -41,6 +49,11 @@ public class AnalyseController extends BaseController {
@Autowired @Autowired
IAlarmInfoDetailService iAlarmInfoDetailService; IAlarmInfoDetailService iAlarmInfoDetailService;
@Autowired
FanHealthIndexMapper fanHealthIndexMapper;
@Autowired
PvHealthIndexMapper pvHealthIndexMapper;
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "工况测点区间划分-风机", notes = "工况测点区间划分-风机") @ApiOperation(httpMethod = "GET", value = "工况测点区间划分-风机", notes = "工况测点区间划分-风机")
@GetMapping(value = "/getFanConditionVariablesByTime") @GetMapping(value = "/getFanConditionVariablesByTime")
...@@ -252,15 +265,35 @@ public class AnalyseController extends BaseController { ...@@ -252,15 +265,35 @@ 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 ARAE, String ANALYSISTYPE, String startTimeTop, String endTimeTop) { public ResponseModel<Map<String, Object>> queryIndexByArae(String area, String analysisType, String startTimeTop, String endTimeTop) {
List<Map<String, Object>> maps = idxBizFanHealthIndexMapper.queryIndexByArae(ARAE, ANALYSISTYPE, startTimeTop, endTimeTop);
List<String> axisData = new ArrayList<>(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
List<String> seriesData = new ArrayList<>(); 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<>(); Map<String, Object> map = new HashMap<>();
for (Map<String, Object> obj : maps) { List<Object> axisData = new ArrayList<>();
axisData.add(obj.get("HEALTHINDEX").toString()); List<Object> seriesData = new ArrayList<>();
seriesData.add(obj.get("ANALYSISTIME").toString()); 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("axisData", axisData);
map.put("seriesData", seriesData); map.put("seriesData", seriesData);
return ResponseHelper.buildResponse(map); return ResponseHelper.buildResponse(map);
......
...@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; ...@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
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.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.common.biz.utils.CommonResponseUtil;
import com.yeejoin.amos.boot.module.jxiop.biz.Enum.HealthLevelSortEnum;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizFanHealthIndexDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizFanHealthIndexDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanPointTag; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanPointTag;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWarningRecord; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWarningRecord;
...@@ -14,7 +16,13 @@ import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanPointTagMapper; ...@@ -14,7 +16,13 @@ import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanPointTagMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvPointTagMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvPointTagMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizFanHealthIndexServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizFanHealthIndexServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanHealthIndexDayMapper; import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanHealthIndexDayMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanHealthIndexHourMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanHealthIndexMomentMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanWaringRecordMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexDay; import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexDay;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexHour;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexMoment;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanWarningRecord;
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;
...@@ -26,8 +34,10 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel; ...@@ -26,8 +34,10 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.POST; import javax.ws.rs.POST;
import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* *
...@@ -49,6 +59,12 @@ public class IdxBizFanHealthIndexController extends BaseController { ...@@ -49,6 +59,12 @@ public class IdxBizFanHealthIndexController extends BaseController {
IdxBizPvPointTagMapper idxBizPvPointTagMapper; IdxBizPvPointTagMapper idxBizPvPointTagMapper;
@Autowired @Autowired
FanHealthIndexDayMapper fanHealthIndexDayMapper; FanHealthIndexDayMapper fanHealthIndexDayMapper;
@Autowired
FanHealthIndexHourMapper fanHealthIndexHourMapper;
@Autowired
FanHealthIndexMomentMapper fanHealthIndexMomentMapper;
@Autowired
FanWaringRecordMapper fanWarningRecord;
/** /**
* 新增 * 新增
* *
...@@ -262,8 +278,6 @@ public class IdxBizFanHealthIndexController extends BaseController { ...@@ -262,8 +278,6 @@ public class IdxBizFanHealthIndexController extends BaseController {
List<Object> seriesData = new ArrayList<>(); List<Object> seriesData = new ArrayList<>();
List<Object> axisData = new ArrayList<>(); List<Object> axisData = new ArrayList<>();
Collections.reverse(seriesData);
Collections.reverse(axisData);
for (Map<String, Object> map : maps) { for (Map<String, Object> map : maps) {
seriesData.add(map.get("value")); seriesData.add(map.get("value"));
...@@ -332,7 +346,7 @@ public class IdxBizFanHealthIndexController extends BaseController { ...@@ -332,7 +346,7 @@ public class IdxBizFanHealthIndexController extends BaseController {
} }
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(httpMethod = "GET",value = "TD 风电场站列表接口", notes = "TD 风电场站列表接口") @ApiOperation(httpMethod = "GET",value = "TD 风电场站/设备列表通用接口", notes = "TD 风电场站/设备列表通用接口")
@GetMapping(value = "/stationHealthIndexTable") @GetMapping(value = "/stationHealthIndexTable")
public ResponseModel<List<FanHealthIndexDay>> stationHealthIndexTable(@RequestParam(value = "area",required = false) String area, public ResponseModel<List<FanHealthIndexDay>> stationHealthIndexTable(@RequestParam(value = "area",required = false) String area,
@RequestParam(value = "station",required = false) String station, @RequestParam(value = "station",required = false) String station,
...@@ -353,7 +367,12 @@ public class IdxBizFanHealthIndexController extends BaseController { ...@@ -353,7 +367,12 @@ public class IdxBizFanHealthIndexController extends BaseController {
Date date = DateUtils.dateAddHours(startDayTime, -8); Date date = DateUtils.dateAddHours(startDayTime, -8);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
startTimeTop = formatter.format(date); startTimeTop = formatter.format(date);
}else{
Date endDate = DateUtils.dateAddHours(DateUtils.longStr2Date(endTimeTop), -8);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
endTimeTop = formatter.format(endDate);
Date startDate = DateUtils.dateAddHours(DateUtils.longStr2Date(startTimeTop), -8);
startTimeTop = formatter.format(startDate);
} }
List<FanHealthIndexDay> fanHealthIndexDays = fanHealthIndexDayMapper.selectData(healthLevel, area, equipmentName, subSystem, analysisType, analysisObjType, station, pointName, indexAddress, startTimeTop, endTimeTop); List<FanHealthIndexDay> fanHealthIndexDays = fanHealthIndexDayMapper.selectData(healthLevel, area, equipmentName, subSystem, analysisType, analysisObjType, station, pointName, indexAddress, startTimeTop, endTimeTop);
...@@ -361,4 +380,236 @@ public class IdxBizFanHealthIndexController extends BaseController { ...@@ -361,4 +380,236 @@ public class IdxBizFanHealthIndexController extends BaseController {
} }
} @TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(httpMethod = "GET",value = "查询场站下设备状态统计", notes = "查询场站下设备状态统计")
@GetMapping (value = "/selectEquipStatusByStation")
public ResponseModel<List<Map<String,Object>>> getFanEquipStatusByStation(@RequestParam(value = "area",required = false) String area,
@RequestParam(value = "station",required = false) String station,
@RequestParam(value = "analysisObjType",required = false) String analysisObjType
) {
List<Map<String, Object>> maps = fanHealthIndexDayMapper.selectEquipStatusByStation(area, analysisObjType, station);
if (maps.size() == 4){
for (Map<String, Object> map : maps) {
map.put("name",map.get("healthlevel"));
}
} else {
String[] levels = {"安全","注意","警告","危险"};
List<String> level = Arrays.asList(levels);
for (Map<String, Object> map : maps) {
map.put("name",map.get("healthLevel"));
level.remove(map.get("healthLevel"));
}
if (level.size()>0){
for (String s : level) {
Map<String, Object> map = new HashMap<>();
map.put("name",s);
map.put("value",0);
map.put("sort",HealthLevelSortEnum.getCode(s));
maps.add(map);
}
maps = maps.stream().sorted(Comparator.comparingInt(e -> (Integer) (e.get("sort")))).collect(Collectors.toList());
}
}
return ResponseHelper.buildResponse(maps);
}
@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 SUBSYSTEM,@RequestParam(required = false) String EQUIPMENTNAME) {
List<FanWarningRecord> idxBizPvWarningRecordList = fanWarningRecord.warningData(STATION,EQUIPMENTNAME ,SUBSYSTEM );
int total = idxBizFanHealthIndexServiceImpl.pointNum(STATION, SUBSYSTEM, 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",total - idxBizPvWarningRecordList.size());
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)
@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 = "subSystem",required = false) String subSystem){
if (requiredType.equals("按天")){
// if (null != type && type.equals("0")){
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);
// }else{
// Date endDate = DateUtils.dateAddHours(DateUtils.longStr2Date(endTimeTop), -8);
// SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// endTimeTop = formatter.format(endDate);
// Date startDate = DateUtils.dateAddHours(DateUtils.longStr2Date(startTimeTop), -8);
// startTimeTop = formatter.format(startDate);
// }
List<FanHealthIndexDay> fanHealthIndexDays = fanHealthIndexDayMapper.selectData(healthLevel, area, equipmentName, subSystem, analysisType, analysisObjType, station, pointName, indexAddress, startTimeTop, endTimeTop);
return ResponseHelper.buildResponse(fanHealthIndexDays);
}else if (requiredType.equals("按小时")){
// if (null != type && type.equals("0")){
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();
}
// }else{
// Date endDate = DateUtils.dateAddHours(DateUtils.longStr2Date(endTimeTop), -8);
// SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// endTimeTop = formatter.format(endDate);
// Date startDate = DateUtils.dateAddHours(DateUtils.longStr2Date(startTimeTop), -8);
// startTimeTop = formatter.format(startDate);
// }
List<FanHealthIndexHour> fanHealthIndexHours = fanHealthIndexHourMapper.selectData(healthLevel, area, equipmentName, subSystem, analysisType, analysisObjType, station, pointName, indexAddress, startTimeTop, endTimeTop);
return ResponseHelper.buildResponse(fanHealthIndexHours);
}else {
// if (null != type && type.equals("0")){
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);
// }else{
// Date endDate = DateUtils.dateAddHours(DateUtils.longStr2Date(endTimeTop), -8);
// SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// endTimeTop = formatter.format(endDate);
// Date startDate = DateUtils.dateAddHours(DateUtils.longStr2Date(startTimeTop), -8);
// startTimeTop = formatter.format(startDate);
// }
List<FanHealthIndexMoment> fanHealthIndexMoments = fanHealthIndexMomentMapper.selectData(healthLevel, area, equipmentName, subSystem, 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 = "subSystem",required = false) String subSystem) {
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<FanHealthIndexDay> fanHealthIndexDays = fanHealthIndexDayMapper.selectData(healthLevel, area, equipmentName, subSystem, analysisType, analysisObjType, station, pointName, indexAddress, startTimeTop, endTimeTop);
fanHealthIndexDays= fanHealthIndexDays.stream().sorted(Comparator.comparing(FanHealthIndexDay::getAnalysisTime)).collect(Collectors.toList());
for (FanHealthIndexDay 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<FanHealthIndexHour> fanHealthIndexHours = fanHealthIndexHourMapper.selectData(healthLevel, area, equipmentName, subSystem, analysisType, analysisObjType, station, pointName, indexAddress, startTimeTop, endTimeTop);
fanHealthIndexHours= fanHealthIndexHours.stream().sorted(Comparator.comparing(FanHealthIndexHour::getAnalysisTime)).collect(Collectors.toList());
for (FanHealthIndexHour 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<FanHealthIndexMoment> fanHealthIndexMoments = fanHealthIndexMomentMapper.selectData(healthLevel, area, equipmentName, subSystem, analysisType, analysisObjType, station, pointName, indexAddress, startTimeTop, endTimeTop);
fanHealthIndexMoments= fanHealthIndexMoments.stream().sorted(Comparator.comparing(FanHealthIndexMoment::getAnalysisTime)).collect(Collectors.toList());
for (FanHealthIndexMoment 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);
}
}
}
...@@ -13,6 +13,8 @@ import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvWarningRuleSet; ...@@ -13,6 +13,8 @@ import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvWarningRuleSet;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizFanWarningRecordServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizFanWarningRecordServiceImpl;
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.tdengine.FanWarningRecord;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.beanutils.BeanMap; import org.apache.commons.beanutils.BeanMap;
...@@ -50,6 +52,9 @@ public class IdxBizFanWarningRecordController extends BaseController { ...@@ -50,6 +52,9 @@ public class IdxBizFanWarningRecordController extends BaseController {
@Autowired @Autowired
IdxBizPvWarningRuleSetServiceImpl idxBizPvWarningRuleSetService; IdxBizPvWarningRuleSetServiceImpl idxBizPvWarningRuleSetService;
@Autowired
FanWaringRecordMapper fanWaringRecordMapper;
/** /**
* 新增 * 新增
* *
...@@ -327,4 +332,34 @@ public class IdxBizFanWarningRecordController extends BaseController { ...@@ -327,4 +332,34 @@ public class IdxBizFanWarningRecordController extends BaseController {
boolean b = idxBizFanWarningRuleSetService.updateBatchById(idxBizFanWarningRecordList); boolean b = idxBizFanWarningRuleSetService.updateBatchById(idxBizFanWarningRecordList);
return ResponseHelper.buildResponse(b); return ResponseHelper.buildResponse(b);
} }
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "/selectFanWarningNum")
@ApiOperation(httpMethod = "GET", value = "查询各风机预警状况", notes = "查询各风机预警状况")
public ResponseModel<List<Map<String,Object>>> selectFanWarningNum(@RequestParam String station) {
List<Map<String, Object>> maps = fanWaringRecordMapper.selectFanWarningNum(station);
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) {
List<Map<String, Object>> maps = fanWaringRecordMapper.selectEquipWarningTotal(STATION,EQUIPMENTNAME);
return ResponseHelper.buildResponse(maps);
}
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "/selectWarningPoint")
@ApiOperation(httpMethod = "GET", value = "预警监测设备右侧预警重复列表", notes = "预警监测设备右侧预警重复列表")
public ResponseModel<List<FanWarningRecord>> selectFanWarningNum(@RequestParam String STATION,@RequestParam String EQUIPMENTNAME) {
List<FanWarningRecord> maps = fanWaringRecordMapper.selectWarningPoint(STATION,EQUIPMENTNAME);
return ResponseHelper.buildResponse(maps);
}
} }
...@@ -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);
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.controller;
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.conditions.update.LambdaUpdateWrapper;
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.feign.RiskWarningFeign;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.FullViewRecallDataDTO;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.FullViewRecallInfoDTO;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.*;
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.mapper2.IdxBizPvHealthLevelMapper;
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.IdxBizPvWarningRuleSetServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
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.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.UnsupportedEncodingException;
import java.sql.Timestamp;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
@RestController
@Api(tags = "智能分析 - 大屏API")
@RequestMapping(value = "/tdBigScreenAnalyse")
public class TDBigScreenAnalyseController extends BaseController {
@Autowired
IdxBizFanHealthIndexMapper idxBizFanHealthIndexMapper;
@Autowired
IdxBizFanWarningRecordMapper idxBizFanWarningRecordMapper;
@Autowired
IdxBizPvHealthLevelMapper idxBizPvHealthLevelMapper;
@Autowired
StationBasicMapper stationBasicMapper;
@Autowired
CommonServiceImpl commonServiceImpl;
@Autowired
IdxBizFanHealthLevelMapper idxBizFanHealthLevelMapper;
@Autowired
IndicatorDataMapper indicatorDataMapper;
@Autowired
RiskWarningFeign riskWarningFeign;
@Autowired
private IdxBizFanWarningRuleSetServiceImpl idxBizFanWarningRuleSetService;
@Autowired
private IdxBizPvWarningRuleSetServiceImpl idxBizPvWarningRuleSetService;
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "场站设备健康状态指数与趋势 - 仪表盘", notes = "场站设备健康状态指数与趋势 - 仪表盘")
@GetMapping(value = "/getHealthScoreInfo")
public ResponseModel<Map<String, Integer>> getHealthScoreInfo(@RequestParam(required = false) String areaCode,
@RequestParam(required = false) String stationCode,
@RequestParam (required = false) String tableName) {
HashMap<String, Integer> stringBigDecimalHashMap = new HashMap<>();
if (CharSequenceUtil.isNotEmpty(stationCode)) {
StationBasic stationBasic = stationBasicMapper.selectById(stationCode);
stationCode = stationBasic.getFanGatewayId();
stringBigDecimalHashMap.put("value", Integer.valueOf(idxBizFanHealthIndexMapper.getHealthScoreInfoByStation(stationCode, tableName).toString().replace(".0", "")));
return ResponseHelper.buildResponse(stringBigDecimalHashMap);
}
stringBigDecimalHashMap.put("value", Integer.valueOf(idxBizFanHealthIndexMapper.getHealthScoreInfo(areaCode, stationCode).toString().replace(".0", "")));
return ResponseHelper.buildResponse(stringBigDecimalHashMap);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "场站设备健康状态指数与趋势 - 折线图", notes = "场站设备健康状态指数与趋势 - 折线图")
@GetMapping(value = "/getHealthListInfo")
public ResponseModel<Map<String, Object>> getHealthListInfo(@RequestParam(required = false) String areaCode, @RequestParam(required = false) String stationCode) {
if (StrUtil.isNotEmpty(stationCode)) {
StationBasic stationBasic = stationBasicMapper.selectById(stationCode);
stationCode = stationBasic.getFanGatewayId();
}
HashMap<String, Object> resultMap = new HashMap<>();
List<Map<String, Object>> healthListInfo = idxBizFanHealthIndexMapper.getHealthListInfo(areaCode, stationCode);
List<String> time = new ArrayList<>();
List<String> valueList = new ArrayList<>();
healthListInfo.forEach(item -> {
time.add(item.get("date").toString());
valueList.add(item.get("avgHealthIndex").toString().replace(".0", ""));
});
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);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "全域各片区设备预警情况(条) ", notes = "全域各片区设备预警情况(条) ")
@GetMapping(value = "/getAllEquipAlarmInfo")
public ResponseModel<Map<String, Object>> getAllEquipAlarmInfo(@RequestParam(required = false) String tableName) throws Exception {
Map<String, Object> resultMap = new HashMap<>();
List<Map<String, Object>> allEquipAlarmInfo = idxBizFanHealthIndexMapper.getAllEquipAlarmInfo(tableName);
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("area").toString(), Integer.parseInt(item.get("num").toString()));
} else if ("注意".equals(item.get("warningName"))) {
zyMap.put(item.get("area").toString(), Integer.parseInt(item.get("num").toString()));
} else if ("警告".equals(item.get("warningName"))) {
jgMap.put(item.get("area").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 = new ArrayList<>();
FeignClientResult<List<CompanyModel>> listFeignClientResult = Privilege.companyClient.queryAgencyList("AREA");
List<CompanyModel> companyModels = new ArrayList<>();
if (!ObjectUtils.isEmpty(listFeignClientResult)) {
if (listFeignClientResult.getStatus() == 200) {
companyModels = listFeignClientResult.getResult();
} else {
throw new RuntimeException(listFeignClientResult.getMessage());
}
}
List<String> collect = companyModels.stream().map(t -> t.getCompanyName()).collect(Collectors.toList());
if ("idx_biz_fan_warning_record".equals(tableName)) {
list = collect;
// list = Arrays.asList("华中片区", "西北片区", "西南片区", "华南片区", "华东片区", "东北片区", "华北片区");
} else {
list = collect;
Collections.reverse(list);
// list = Arrays.asList("华北片区", "东北片区", "华东片区", "华南片区", "西南片区", "西北片区", "华中片区");
}
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);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "全域各片区设备健康状态指数 ", notes = "全域各片区设备健康状态指数 ")
@GetMapping(value = "/getHealthInfoByArea")
public ResponseModel<Map<String, Object>> getHealthInfoByArea() throws Exception {
Map<String, Object> resultMap = new HashMap<>();
List<Map<String, Object>> healthListInfo = idxBizFanHealthIndexMapper.getHealthInfoByArea();
Map<String, Integer> collect = healthListInfo.stream().collect(Collectors.toMap(t -> t.get("area").toString(), t -> Integer.valueOf(t.get("healthIndex").toString().replace(".0", ""))));
// List<String> list = Arrays.asList("华中片区", "西北片区", "西南片区", "华南片区", "华东片区", "东北片区", "华北片区");
List<String> list = new ArrayList<>();
FeignClientResult<List<CompanyModel>> listFeignClientResult = Privilege.companyClient.queryAgencyList("AREA");
List<CompanyModel> companyModels = new ArrayList<>();
if (!ObjectUtils.isEmpty(listFeignClientResult)) {
if (listFeignClientResult.getStatus() == 200) {
companyModels = listFeignClientResult.getResult();
} else {
throw new RuntimeException(listFeignClientResult.getMessage());
}
}
list = companyModels.stream().map(CompanyModel::getCompanyName).collect(Collectors.toList());
List<Object> seriesData = new ArrayList<>();
list.forEach(item -> seriesData.add(collect.getOrDefault(item, 100)));
resultMap.put("axisData", list);
resultMap.put("seriesData", seriesData);
return ResponseHelper.buildResponse(resultMap);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "全域各场站设备实时预警处置信息", notes = "全域各场站设备实时预警处置信息")
@GetMapping(value = "/getEquipWarningInfoByPage")
public ResponseModel<IPage<IdxBizFanWarningRecord>> getEquipWarningInfoByPage(@RequestParam(value = "arae", required = false) String arae,
@RequestParam(value = "station", required = false) String station,
@RequestParam(value = "stationType", required = false) String stationType,
@RequestParam(value = "current", required = false) Integer current,
@RequestParam(value = "size", required = false) Integer size,
@RequestParam(value = "warningName", required = false) String warningName,
@RequestParam(value = "stationId", required = false) String stationId,
@RequestParam(value = "startDate", required = false) String startDate,
@RequestParam(value = "endDate", required = false) String endDate) {
if (StrUtil.isNotEmpty(stationId)) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
stationId = stationBasic.getFanGatewayId();
}
Integer count = idxBizFanWarningRecordMapper.getEquipWarningInfoByPageCount(arae, station, stationType, 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);
idxBizFanWarningRecordPage.setRecords(idxBizFanWarningRecordIPage);
idxBizFanWarningRecordPage.setTotal(count);
return ResponseHelper.buildResponse(idxBizFanWarningRecordPage);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "各场站设备预警情况(条) ", notes = "各场站设备预警情况(条) ")
@GetMapping(value = "/getAllEquipAlarmInfoByStation")
public ResponseModel<Map<String, Object>> getAllEquipAlarmInfoByStation() {
Map<String, Object> resultMap = new HashMap<>();
List<Map<String, Object>> allEquipAlarmInfo = idxBizFanHealthIndexMapper.getAllEquipAlarmInfoByStation();
HashMap<String, Integer> wxMap = new HashMap<>();
HashMap<String, Integer> zyMap = new HashMap<>();
HashMap<String, Integer> jgMap = new HashMap<>();
LinkedHashSet<String> list = new LinkedHashSet<>();
allEquipAlarmInfo.forEach(item -> {
if ("危险".equals(item.get("warningName"))) {
wxMap.put(item.get("station").toString(), Integer.parseInt(item.get("num").toString()));
} else if ("注意".equals(item.get("warningName"))) {
zyMap.put(item.get("station").toString(), Integer.parseInt(item.get("num").toString()));
} else if ("警告".equals(item.get("warningName"))) {
jgMap.put(item.get("station").toString(), Integer.parseInt(item.get("num").toString()));
}
list.add(item.get("station").toString());
});
List<Integer> wxList = new ArrayList<>();
List<Integer> zyList = new ArrayList<>();
List<Integer> jgList = new ArrayList<>();
// List<StationBasic> stationBasics = stationBasicMapper.selectList(null);
// List<String> list = stationBasics.stream().map(StationBasic::getStationName).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);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "各场站健康状态指数 ", notes = "各场站健康状态指数 ")
@GetMapping(value = "/getHealthInfoByStation")
public ResponseModel<Map<String, Object>> getHealthInfoByArea(@RequestParam(required = false) String areaCode) {
Map<String, Object> resultMap = new HashMap<>();
List<Map<String, Object>> healthListInfo = idxBizFanHealthIndexMapper.getHealthInfoByStation(areaCode);
// Map<String, BigDecimal> collect = healthListInfo.stream().collect(Collectors.toMap(t -> t.get("station").toString(), t -> new BigDecimal(t.get("healthIndex").toString())));
// List<StationBasic> stationBasics = stationBasicMapper.selectList(new LambdaQueryWrapper<StationBasic>().like(StationBasic::getAreaName, areaCode));
// List<String> list = stationBasics.stream().map(StationBasic::getStationName).collect(Collectors.toList());
// List<Object> seriesData = new ArrayList<>();
// list.forEach(item -> seriesData.add(collect.getOrDefault(item, new BigDecimal("100"))));
List<String> list = new ArrayList<>();
List<Object> seriesData = new ArrayList<>();
healthListInfo.forEach(item -> {
list.add(item.get("station").toString());
seriesData.add(item.get("healthIndex").toString().replace(".0", ""));
});
resultMap.put("axisData", list);
resultMap.put("seriesData", seriesData);
return ResponseHelper.buildResponse(resultMap);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(value = "场站预警信息统计图 - 雷达图", httpMethod = "GET")
@GetMapping("/equipWarningRadarMap")
public ResponseModel<Map<String, Object>> assessIndexRadarMap(@RequestParam(required = false, value = "stationCode") String stationCode) {
if (StrUtil.isNotEmpty(stationCode)) {
StationBasic stationBasic = stationBasicMapper.selectById(stationCode);
stationCode = stationBasic.getFanGatewayId();
}
List<Map<String, Object>> list = idxBizFanHealthIndexMapper.equipWarningRadarMap(stationCode);
Map<String, Integer> warningNumMap = list.stream().collect(Collectors.toMap(t -> t.get("warningName").toString(), t -> Integer.parseInt(t.get("num").toString())));
List<String> warningList = Arrays.asList("危险", "注意", "警告");
List<Integer> data = new ArrayList<>();
List<List<Integer>> resultData = new ArrayList<>();
List<Map<String, Object>> resultList = new ArrayList<>();
warningList.forEach(item -> {
HashMap<String, Object> map = new HashMap<>();
map.put("text", item);
resultList.add(map);
data.add(warningNumMap.getOrDefault(item, 0));
});
resultData.add(data);
HashMap<String, Object> resultMap = new HashMap<>();
resultMap.put("radar", resultList);
resultMap.put("array", resultData);
return ResponseHelper.buildResponse(resultMap);
// HashMap<String, Object> resultMap = new HashMap<>();
// List<String> data = new ArrayList<>();
// list.forEach(item -> {
// HashMap<String, Object> map = new HashMap<>();
// map.put("text", item.get("warningName"));
// resultList.add(map);
// data.add(item.get("num").toString());
// });
//
}
@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, "风电");
} else if ("pv".equals(stationType)) {
allEquipAlarmInfo = idxBizFanHealthIndexMapper.getAllEquipAlarmInfoAnalysisByStationType("idx_biz_pv_warning_record", areaCode, "光伏");
}
} 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()).distinct().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);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "风站 左侧风机信息列表")
@GetMapping("/getFanInfoByPage")
public ResponseModel<Page<Map<String, Object>>> getFanInfoByPage(@RequestParam(value = "stationId", required = false) String stationId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
List<Map<String, Object>> equipmentList = idxBizFanHealthIndexMapper.getFanInfoByPage(stationBasic.getFanGatewayId());
List<Map<String, Object>> healthInfoList = idxBizFanHealthIndexMapper.getFanHealthInfoList(stationBasic.getFanGatewayId());
Map<Object, Double> equipmentHealthIndexMap = healthInfoList.stream().collect(Collectors.toMap(t -> t.get("equipmentName"), t -> Double.parseDouble(t.get("avgHealthIndex").toString())));
equipmentList.forEach(item -> {
Double equipmentHealthScore = equipmentHealthIndexMap.getOrDefault(item.get("equipmentName"), 100.0);
if (100.0 == equipmentHealthScore) {
item.put("warningName", "安全");
} else {
LambdaQueryWrapper<IdxBizFanHealthLevel> query = new LambdaQueryWrapper<>();
query.eq(IdxBizFanHealthLevel::getAnalysisObjType, "设备");
query.eq(IdxBizFanHealthLevel::getStatus, item.get("station"));
query.lt(IdxBizFanHealthLevel::getGroupLowerLimit, equipmentHealthScore);
query.ge(IdxBizFanHealthLevel::getGroupUpperLimit, equipmentHealthScore);
IdxBizFanHealthLevel idxBizFanHealthLevel = idxBizFanHealthLevelMapper.selectOne(query);
item.put("warningName", idxBizFanHealthLevel.getHealthLevel());
}
item.put("healthIndex", equipmentHealthScore);
// String equipmentName = CharSequenceUtil.replace(item.get("equipmentName").toString(), "集电Ⅳ线#", "");
// String replace = CharSequenceUtil.replace(equipmentName, "集电Ⅲ线#", "");
// String replace1 = CharSequenceUtil.replace(replace, "集电Ⅱ线#", "");
// String replace2 = CharSequenceUtil.replace(replace1, "集电Ⅰ线#", "");
// String replace3 = CharSequenceUtil.replace(replace2, "风机", "");
String equipmentName = item.get("equipmentName").toString();
String str1 = equipmentName.substring(0, equipmentName.indexOf("#"));
String str2 = equipmentName.substring(str1.length()+1, equipmentName.length());
String str3 = CharSequenceUtil.replace(str2, "风机", "");
item.put("equipmentNameSimple", str3);
});
Page<Map<String, Object>> mapPage = new Page<>();
mapPage.setSize(equipmentList.size());
mapPage.setTotal(equipmentList.size());
mapPage.setCurrent(1);
mapPage.setRecords(equipmentList);
return ResponseHelper.buildResponse(mapPage);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "风站 风机子系统状态指数 柱状图")
@GetMapping("/getSubSystemInfo")
public ResponseModel<Map<String, Object>> getSubSystemInfo(@RequestParam(value = "equipmentName", required = false) String equipmentName,
@RequestParam(value = "stationId", required = false) String stationId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
Map<String, Object> resultMap = new HashMap<>();
List<Map<String, Object>> healthListInfo = idxBizFanHealthIndexMapper.getSubSystemInfo(equipmentName, stationBasic.getFanGatewayId());
Map<Object, Integer> equipmentHealthIndexMap = healthListInfo.stream().collect(Collectors.toMap(t -> t.get("subSystem"), t -> Integer.valueOf(t.get("healthIndex").toString().replace(".0", ""))));
List<Object> seriesData = new ArrayList<>();
List<Object> axisData = new ArrayList<>();
List<Map<String, Object>> equipmentList = idxBizFanHealthIndexMapper.getSumSystemListByEquipment(stationBasic.getFanGatewayId(), equipmentName);
equipmentList.forEach(item -> {
Integer equipmentHealthScore = equipmentHealthIndexMap.getOrDefault(item.get("subSystem"), 100);
seriesData.add(equipmentHealthScore);
axisData.add(item.get("subSystem"));
});
resultMap.put("axisData", axisData);
resultMap.put("seriesData", seriesData);
return ResponseHelper.buildResponse(resultMap);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "该子系统各指标预警 - 风站中间 下方列表")
@GetMapping("/getSubSystemPointInfo")
public ResponseModel<Page<Map<String, Object>>> getSubSystemPointInfo(@RequestParam(value = "subSystem", required = false) String subSystem,
@RequestParam(value = "stationId", required = false) String stationId) throws UnsupportedEncodingException {
subSystem = java.net.URLDecoder.decode(subSystem,"UTF-8");
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
// List<Map<String, Object>> healthListInfo = idxBizFanHealthIndexMapper.getHealthInfoBySubSystem(subSystem, stationBasic.getFanGatewayId());
List<Map<String, Object>> healthListInfo = idxBizFanHealthIndexMapper.getWarningInfoBySubSystem(subSystem, stationBasic.getFanGatewayId());
Map<Object, String> equipmentHealthIndexMap = healthListInfo.stream().collect(Collectors.toMap(t -> t.get("pointName"), t -> t.get("warningName").toString()));
List<Map<String, Object>> pointNameList = idxBizFanHealthIndexMapper.getPointNameListBySumSystem(stationBasic.getFanGatewayId(), subSystem);
pointNameList.forEach(item -> {
String warningName = equipmentHealthIndexMap.getOrDefault(item.get("pointName"), "安全");
int sort = 4;
item.put("warningName", warningName);
item.put("status", warningName);
if ("注意".equals(warningName)) {
sort = 3;
} else if ("警告".equals(warningName)) {
sort = 2;
} else if ("危险".equals(warningName)) {
sort = 1;
}
item.put("sort", sort);
});
pointNameList.sort(Comparator.comparing(o -> o.get("sort").toString()));
Page<Map<String, Object>> mapPage = new Page<>();
mapPage.setSize(pointNameList.size());
mapPage.setTotal(pointNameList.size());
mapPage.setCurrent(1);
mapPage.setRecords(pointNameList);
return ResponseHelper.buildResponse(mapPage);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "光伏 左侧风机信息列表")
@GetMapping("/getPvInfoByPage")
public ResponseModel<Page<Map<String, Object>>> getPvInfoByPage(@RequestParam(value = "stationId", required = false) String stationId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
List<Map<String, Object>> equipmentList = idxBizFanHealthIndexMapper.getPvInfoByPage(stationBasic.getFanGatewayId());
List<Map<String, Object>> healthInfoList = idxBizFanHealthIndexMapper.getPvHealthInfoList(stationBasic.getFanGatewayId());
Map<Object, Double> equipmentHealthIndexMap = healthInfoList.stream().collect(Collectors.toMap(t -> t.get("subarray"), t -> Double.parseDouble(t.get("avgHealthIndex").toString())));
equipmentList.forEach(item -> {
Double equipmentHealthScore = equipmentHealthIndexMap.getOrDefault(item.get("subarray"), 100.0);
if (100.0 == equipmentHealthScore) {
item.put("warningName", "安全");
} else {
LambdaQueryWrapper<IdxBizPvHealthLevel> query = new LambdaQueryWrapper<>();
query.eq(IdxBizPvHealthLevel::getAnalysisObjType, "设备");
query.eq(IdxBizPvHealthLevel::getStatus, item.get("station").toString());
query.lt(IdxBizPvHealthLevel::getGroupLowerLimit, equipmentHealthScore);
query.ge(IdxBizPvHealthLevel::getGroupUpperLimit, equipmentHealthScore);
IdxBizPvHealthLevel idxBizPvHealthLevel = idxBizPvHealthLevelMapper.selectOne(query);
item.put("warningName", idxBizPvHealthLevel.getHealthLevel());
}
item.put("healthIndex", equipmentHealthScore);
String subarray = CharSequenceUtil.replace(item.get("subarray").toString(), "#", "");
item.put("subarray", subarray);
});
Page<Map<String, Object>> mapPage = new Page<>();
mapPage.setSize(equipmentList.size());
mapPage.setTotal(equipmentList.size());
mapPage.setCurrent(1);
mapPage.setRecords(equipmentList);
return ResponseHelper.buildResponse(mapPage);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "光伏 子阵下各设备状态指数 柱状图")
@GetMapping("/getPvSubSystemInfo")
public ResponseModel<Map<String, Object>> getPvSubSystemInfo(@RequestParam(value = "subarray", required = false) String subarray,
@RequestParam(value = "stationId", required = false) String stationId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
Map<String, Object> resultMap = new HashMap<>();
List<Map<String, Object>> healthListInfo = idxBizFanHealthIndexMapper.getPvSubSystemInfo(subarray, stationBasic.getFanGatewayId());
Map<Object, Object> equipmentHealthIndexMap = healthListInfo.stream().collect(Collectors.toMap(t -> t.get("equipmentName"), t -> t.get("avgHealthIndex").toString().replace(".0", "")));
List<Object> seriesData = new ArrayList<>();
List<Object> axisData = new ArrayList<>();
List<Map<String, Object>> equipmentList = idxBizFanHealthIndexMapper.getPvSumSystemListByEquipment(stationBasic.getFanGatewayId(), subarray);
equipmentList.forEach(item -> {
Object equipmentHealthScore = equipmentHealthIndexMap.getOrDefault(item.get("equipmentName"), 100);
seriesData.add(equipmentHealthScore);
axisData.add(item.get("equipmentName"));
});
resultMap.put("axisData", axisData);
resultMap.put("seriesData", seriesData);
return ResponseHelper.buildResponse(resultMap);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "光伏 该装备下各指标预警 - 风站中间 下方列表")
@GetMapping("/getPvSubSystemPointInfo")
public ResponseModel<Page<Map<String, Object>>> getPvSubSystemPointInfo(@RequestParam(value = "equipmentName", required = false) String equipmentName,
@RequestParam(value = "stationId", required = false) String stationId) throws UnsupportedEncodingException {
equipmentName = java.net.URLDecoder.decode(equipmentName,"UTF-8");
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
// List<Map<String, Object>> healthListInfo = idxBizFanHealthIndexMapper.getPvHealthInfoBySubSystem(equipmentName, stationBasic.getFanGatewayId());
List<Map<String, Object>> healthListInfo = idxBizFanHealthIndexMapper.getPvWarningInfoBySubSystem(equipmentName, stationBasic.getFanGatewayId());
Map<Object, String> equipmentHealthIndexMap = healthListInfo.stream().collect(Collectors.toMap(t -> t.get("pointName"), t -> t.get("warningName").toString()));
List<Map<String, Object>> pointNameList = idxBizFanHealthIndexMapper.getPvPointNameListBySumSystem(stationBasic.getFanGatewayId(), equipmentName);
pointNameList.forEach(item -> {
String equipmentHealthScore = equipmentHealthIndexMap.getOrDefault(item.get("pointName"), "安全");
int sort = 4;
if ("注意".equals(equipmentHealthScore)) {
sort = 3;
} else if ("警告".equals(equipmentHealthScore)) {
sort = 2;
} else if ("危险".equals(equipmentHealthScore)) {
sort = 1;
}
item.put("sort", sort);
item.put("warningName", equipmentHealthScore);
item.put("status", equipmentHealthScore);
});
pointNameList.sort(Comparator.comparing(o -> o.get("sort").toString()));
Page<Map<String, Object>> mapPage = new Page<>();
mapPage.setSize(pointNameList.size());
mapPage.setTotal(pointNameList.size());
mapPage.setCurrent(1);
mapPage.setRecords(pointNameList);
return ResponseHelper.buildResponse(mapPage);
}
@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,
@RequestParam(value = "tableName", required = false) String tableName,
@RequestParam(value = "tableName2", required = false) String tableName2) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
List<Map<String, Object>> resultListData = new ArrayList<>();
String recDate = idxBizFanHealthIndexMapper.getRecDateByIndexAddress(stationBasic.getFanGatewayId(), indexAddress, tableName);
if (CharSequenceUtil.isNotEmpty(recDate)) {
resultListData = idxBizFanHealthIndexMapper.getInfoListByTableName(stationBasic.getFanGatewayId(), indexAddress, tableName2, recDate);
}
HashMap<String, Object> resultMap = new HashMap<>();
List<String> time = new ArrayList<>();
List<Object> valueList = new ArrayList<>();
resultListData.forEach(item -> {
String date = "";
try {
date = DateUtils.convertDateToString(DateUtils.dateParse(item.get("REC_DATE").toString(), DateUtils.DATE_TIME_PATTERN), "MM-dd HH:mm:ss");
} catch (ParseException e) {
}
time.add(date);
String value = CharSequenceUtil.isEmpty(item.get("healthIndex").toString().replace(".0", "")) ? "100" : item.get("healthIndex").toString().replace(".0", "");
valueList.add(value);
});
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);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "根据测点ID查询测点名称")
@GetMapping("/getMapStringByString")
public ResponseModel<Map<String, Object>> getMapStringByString(@RequestParam(value = "indexAddress", required = false) String indexAddress,
@RequestParam(value = "tableName", required = true) String tableName,
@RequestParam(value = "stationId", required = true) String stationId,
@RequestParam(value = "tableName2", required = false) String tableName2) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String nameByIndexAddress = idxBizFanHealthIndexMapper.getPointNameByIndexAddress(indexAddress, tableName, stationBasic.getFanGatewayId());
int num = idxBizFanHealthIndexMapper.getIsWarningByPointId(indexAddress, stationBasic.getFanGatewayId(), tableName2);
HashMap<String, Object> resultMap = new HashMap<>();
resultMap.put("text", nameByIndexAddress);
resultMap.put("warningNum", num);
return ResponseHelper.buildResponse(resultMap);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "风站/光伏 右下诊断分析")
@GetMapping("/getRiskHandleByVarDesc")
public ResponseModel<Map<String, String>> getRiskHandleByVarDesc(@RequestParam(value = "varDesc", required = false) String varDesc,
@RequestParam(value = "tableName", required = true) String tableName,
@RequestParam(value = "stationId") String stationId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
varDesc = idxBizFanHealthIndexMapper.getPointNameByIndexAddress(varDesc, tableName, stationBasic.getFanGatewayId());
FeignClientResult<List<String>> sevenEntityMcb = null;
try {
sevenEntityMcb = riskWarningFeign.getRiskHandleByVarDesc(varDesc);
} catch (Exception e) {
e.printStackTrace();
}
if (ObjectUtils.isEmpty(sevenEntityMcb) || sevenEntityMcb.getStatus() != 200) {
HashMap<String, String> stringStringHashMap = new HashMap<>();
stringStringHashMap.put("content", "");
return ResponseHelper.buildResponse(stringStringHashMap);
}
StringBuilder resultString = new StringBuilder();
List<String> result = sevenEntityMcb.getResult();
for (String s : result) {
resultString.append(s);
}
HashMap<String, String> stringStringHashMap = new HashMap<>();
stringStringHashMap.put("content", resultString.toString());
return ResponseHelper.buildResponse(stringStringHashMap);
}
private IdxBizFanHealthLevel getHealthLevelByScore(List<IdxBizFanHealthLevel> healthLevelInfoList, String station, String type, Double score) {
IdxBizFanHealthLevel resultDto = new IdxBizFanHealthLevel();
String stationType = "风电站";
List<IdxBizFanHealthLevel> collect = healthLevelInfoList.stream().filter(item -> item.getAnalysisObjType().contains(station)).collect(Collectors.toList());
for (IdxBizFanHealthLevel item : collect) {
if (!item.getAnalysisObjType().contains("子系统")) {
stationType = "光伏站";
}
}
for (IdxBizFanHealthLevel item : collect) {
if (type.equals("设备") && stationType.equals("风电站") && item.getAnalysisObjType().contains(type) && score >= item.getGroupLowerLimit() && score <= item.getGroupUpperLimit() ) {
resultDto = item;
break;
}
if (type.equals("子系统") && stationType.equals("风电站") && item.getAnalysisObjType().contains(type) && score >= item.getGroupLowerLimit() && score <= item.getGroupUpperLimit() ) {
resultDto = item;
break;
}
if (type.equals("测点") && item.getAnalysisObjType().contains(type) && score >= item.getGroupLowerLimit() && score <= item.getGroupUpperLimit() ) {
resultDto = item;
break;
}
if (type.equals("设备") && stationType.equals("光伏站") && item.getAnalysisObjType().contains("子阵") && score >= item.getGroupLowerLimit() && score <= item.getGroupUpperLimit() ) {
resultDto = item;
break;
}
if (type.equals("子系统") && stationType.equals("光伏站") && item.getAnalysisObjType().contains("设备") && score >= item.getGroupLowerLimit() && score <= item.getGroupUpperLimit() ) {
resultDto = item;
break;
}
}
return resultDto;
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "全景诊断回溯")
@GetMapping("/getFullViewRecall")
public ResponseModel<Map<String, Object>> getFullViewRecall() {
HashMap<String, Object> resultMapFinally = new HashMap<>();
List<Map<String, Object>> stationIndexInfo = idxBizFanHealthIndexMapper.getStationIndexInfo();
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();
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();
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();
Map<String, Double> pointNameIndexInfoMap = pointNameIndexInfo.stream().collect(Collectors.toMap(t -> t.get("gatewayIndexAddress").toString(), t -> Double.parseDouble(t.get("healthIndex").toString())));
List<IdxBizFanHealthLevel> healthLevelInfoList = idxBizFanHealthIndexMapper.getHealthLevelInfoList();
List<FullViewRecallDataDTO> list = idxBizFanHealthIndexMapper.getFullViewRecall();
Map<String, Map<String, Map<String, Map<String, Map<String, List<FullViewRecallDataDTO>>>>>> resultMap = list.stream()
.collect(Collectors.groupingBy(FullViewRecallDataDTO::getArea,
Collectors.groupingBy(FullViewRecallDataDTO::getStation,
Collectors.groupingBy(FullViewRecallDataDTO::getEquipmentName,
Collectors.groupingBy(FullViewRecallDataDTO::getSubSystem,
Collectors.groupingBy(FullViewRecallDataDTO::getPointName))))));
int areaInt = 1;
int pointNameInt = 1;
int stationInt = 1;
int equipmentInt = 1;
int subSystemInt = 1;
List<FullViewRecallInfoDTO> fullViewRecallList = new ArrayList<>();
List<Map<String, String>> resultMapFromToList = new ArrayList<>();
Double healthScoreInfo = idxBizFanHealthIndexMapper.getHealthScoreInfo(null, null).doubleValue();
LambdaQueryWrapper<IdxBizFanHealthLevel> query = new LambdaQueryWrapper<>();
query.isNull(IdxBizFanHealthLevel::getStatus);
query.eq(IdxBizFanHealthLevel::getAnalysisObjType, "全域");
query.lt(IdxBizFanHealthLevel::getGroupLowerLimit, healthScoreInfo);
query.ge(IdxBizFanHealthLevel::getGroupUpperLimit, healthScoreInfo);
IdxBizFanHealthLevel idxBizFanHealthLevel = idxBizFanHealthLevelMapper.selectOne(query);
FullViewRecallInfoDTO allMapDto = new FullViewRecallInfoDTO();
allMapDto.setKey("0");
allMapDto.setName("全域设备健康状态指数");
allMapDto.setLoc("0 2000");
allMapDto.setScoreRange("");
allMapDto.setStatus(idxBizFanHealthLevel.getHealthLevel());
allMapDto.setScore(healthScoreInfo);
allMapDto.setIsRoot(true);
allMapDto.setCategory("category");
fullViewRecallList.add(allMapDto);
for (Map.Entry<String, Map<String, Map<String, Map<String, Map<String, List<FullViewRecallDataDTO>>>>>> areaMap : resultMap.entrySet()) {
Double areaLowScore = null;
Double areaHighScore = null;
Double areaHealthScoreInfo = idxBizFanHealthIndexMapper.getHealthScoreInfo(areaMap.getKey(), null).doubleValue();
LambdaQueryWrapper<IdxBizFanHealthLevel> areaQuery = new LambdaQueryWrapper<>();
areaQuery.isNull(IdxBizFanHealthLevel::getStatus);
areaQuery.eq(IdxBizFanHealthLevel::getAnalysisObjType, "片区");
areaQuery.lt(IdxBizFanHealthLevel::getGroupLowerLimit, areaHealthScoreInfo);
areaQuery.ge(IdxBizFanHealthLevel::getGroupUpperLimit, areaHealthScoreInfo);
IdxBizFanHealthLevel areaIdxBizFanHealthLevel = idxBizFanHealthLevelMapper.selectOne(areaQuery);
FullViewRecallInfoDTO areaMapDto = new FullViewRecallInfoDTO();
areaMapDto.setKey("0-" + areaInt);
areaMapDto.setName(areaMap.getKey());
areaMapDto.setLoc(350 + " " + (1410 + areaInt * 20));
areaMapDto.setStatus(areaIdxBizFanHealthLevel.getHealthLevel());
areaMapDto.setScore(areaHealthScoreInfo);
HashMap<String, String> areaMapFromTo = new HashMap<>();
areaMapFromTo.put("from", "0");
areaMapFromTo.put("to", areaMapDto.getKey());
resultMapFromToList.add(areaMapFromTo);
areaInt++;
for (Map.Entry<String, Map<String, Map<String, Map<String, List<FullViewRecallDataDTO>>>>> stationMap : areaMap.getValue().entrySet()) {
Double stationLowScore = null;
Double stationHighScore = null;
if (areaLowScore == null && areaHighScore == null) {
areaLowScore = stationHealthIndexMap.getOrDefault(stationMap.getKey(), 100.0);
areaHighScore = stationHealthIndexMap.getOrDefault(stationMap.getKey(), 100.0);
} else {
if (stationHealthIndexMap.getOrDefault(stationMap.getKey(), 100.0) < areaLowScore) {
areaLowScore = stationHealthIndexMap.getOrDefault(stationMap.getKey(), 100.0);
}
if (stationHealthIndexMap.getOrDefault(stationMap.getKey(), 100.0) > areaHighScore) {
areaHighScore = stationHealthIndexMap.getOrDefault(stationMap.getKey(), 100.0);
}
}
FullViewRecallInfoDTO stationDto = new FullViewRecallInfoDTO();
stationDto.setKey(areaMapDto.getKey() + "-" + stationInt);
stationDto.setName(stationMap.getKey());
stationDto.setLoc(680 + " " + (1000 + 900 * (stationInt - 1)));
stationDto.setStatus("");
stationDto.setScore(stationHealthIndexMap.getOrDefault(stationMap.getKey(), 100.0));
LambdaQueryWrapper<IdxBizFanHealthLevel> stationQuery = new LambdaQueryWrapper<>();
stationQuery.like(IdxBizFanHealthLevel::getStatus, stationMap.getKey());
stationQuery.eq(IdxBizFanHealthLevel::getAnalysisObjType, "场站");
stationQuery.lt(IdxBizFanHealthLevel::getGroupLowerLimit, areaHealthScoreInfo);
stationQuery.ge(IdxBizFanHealthLevel::getGroupUpperLimit, areaHealthScoreInfo);
IdxBizFanHealthLevel stationLevel = idxBizFanHealthLevelMapper.selectOne(stationQuery);
stationDto.setStatus(ObjectUtils.isNotEmpty(stationLevel) ? stationLevel.getHealthLevel() : "");
if (ObjectUtils.isEmpty(stationLevel)) {
LambdaQueryWrapper<IdxBizPvHealthLevel> stationPvQuery = new LambdaQueryWrapper<>();
stationPvQuery.like(IdxBizPvHealthLevel::getStatus, stationMap.getKey());
stationPvQuery.eq(IdxBizPvHealthLevel::getAnalysisObjType, "场站");
stationPvQuery.lt(IdxBizPvHealthLevel::getGroupLowerLimit, areaHealthScoreInfo);
stationPvQuery.ge(IdxBizPvHealthLevel::getGroupUpperLimit, areaHealthScoreInfo);
IdxBizPvHealthLevel stationPvLevel = idxBizPvHealthLevelMapper.selectOne(stationPvQuery);
if (ObjectUtils.isNotEmpty(stationPvLevel)) {
stationDto.setStatus(stationPvLevel.getHealthLevel());
}
}
HashMap<String, String> stationMapFromTo = new HashMap<>();
stationMapFromTo.put("from", areaMapDto.getKey());
stationMapFromTo.put("to", stationDto.getKey());
resultMapFromToList.add(stationMapFromTo);
stationInt++;
for (Map.Entry<String, Map<String, Map<String, List<FullViewRecallDataDTO>>>> equipmentMap : stationMap.getValue().entrySet()) {
if (stationLowScore == null && stationHighScore == null) {
stationLowScore = equipmentIndexInfoMap.getOrDefault(equipmentMap.getKey(), 100.0);
stationHighScore = equipmentIndexInfoMap.getOrDefault(equipmentMap.getKey(), 100.0);
} else {
if (equipmentIndexInfoMap.getOrDefault(equipmentMap.getKey(), 100.0) < stationLowScore) {
stationLowScore = equipmentIndexInfoMap.getOrDefault(equipmentMap.getKey(), 100.0);
}
if (equipmentIndexInfoMap.getOrDefault(equipmentMap.getKey(), 100.0) > stationHighScore) {
stationHighScore = equipmentIndexInfoMap.getOrDefault(equipmentMap.getKey(), 100.0);
}
}
FullViewRecallInfoDTO equipmentMapDto = new FullViewRecallInfoDTO();
equipmentMapDto.setKey(stationDto.getKey() + "-" + equipmentInt);
equipmentMapDto.setName(equipmentMap.getKey());
equipmentMapDto.setLoc(1000 + " " + (400 + 200 * (equipmentInt - 1)));
equipmentMapDto.setScoreRange("");
IdxBizFanHealthLevel levelInfo = getHealthLevelByScore(healthLevelInfoList, stationMap.getKey(), "设备", equipmentIndexInfoMap.getOrDefault(equipmentMap.getKey(), 100.0));
equipmentMapDto.setStatus(levelInfo.getHealthLevel());
equipmentMapDto.setScore(equipmentIndexInfoMap.getOrDefault(equipmentMap.getKey(), 100.0));
fullViewRecallList.add(equipmentMapDto);
HashMap<String, String> equipmentMapFromTo = new HashMap<>();
equipmentMapFromTo.put("from", stationDto.getKey());
equipmentMapFromTo.put("to", equipmentMapDto.getKey());
resultMapFromToList.add(equipmentMapFromTo);
equipmentInt++;
for (Map.Entry<String, Map<String, List<FullViewRecallDataDTO>>> subSystemMap : equipmentMap.getValue().entrySet()) {
FullViewRecallInfoDTO subSystemMapDto = new FullViewRecallInfoDTO();
subSystemMapDto.setKey(equipmentMapDto.getKey() + "-" + subSystemInt);
subSystemMapDto.setName(subSystemMap.getKey());
subSystemMapDto.setLoc(2000 + " " + (300 + 90 * (subSystemInt - 1)));
subSystemMapDto.setScoreRange("");
// subSystemMapDto.setStatus(null);
IdxBizFanHealthLevel levelInfoZxt = getHealthLevelByScore(healthLevelInfoList, stationMap.getKey(), "子系统", subSystemIndexInfoMap.getOrDefault(subSystemMap.getKey(), 100.0));
subSystemMapDto.setStatus(levelInfoZxt.getHealthLevel());
subSystemMapDto.setScore(subSystemIndexInfoMap.getOrDefault(subSystemMap.getKey(), 100.0));
fullViewRecallList.add(subSystemMapDto);
HashMap<String, String> subSystemMapFromTo = new HashMap<>();
subSystemMapFromTo.put("from", equipmentMapDto.getKey());
subSystemMapFromTo.put("to", subSystemMapDto.getKey());
resultMapFromToList.add(subSystemMapFromTo);
subSystemInt++;
for (Map.Entry<String, List<FullViewRecallDataDTO>> pointNameMap : subSystemMap.getValue().entrySet()) {
FullViewRecallInfoDTO pointNameMapDto = new FullViewRecallInfoDTO();
pointNameMapDto.setKey(subSystemMapDto.getKey() + "-" + pointNameInt);
pointNameMapDto.setName(pointNameMap.getKey());
FullViewRecallDataDTO fullViewRecallDataDTO = pointNameMap.getValue().get(0);
pointNameMapDto.setLoc(3800 + " " + (250 + 80 * (pointNameInt - 1)));
pointNameMapDto.setScoreRange("");
IdxBizFanHealthLevel levelInfoBL = getHealthLevelByScore(healthLevelInfoList, stationMap.getKey(), "测点", pointNameIndexInfoMap.getOrDefault(fullViewRecallDataDTO.getStation() + "_" + fullViewRecallDataDTO.getIndexAddress(), 100.0));
pointNameMapDto.setStatus(levelInfoBL.getHealthLevel());
pointNameMapDto.setScore(pointNameIndexInfoMap.getOrDefault(fullViewRecallDataDTO.getStation() + "_" + fullViewRecallDataDTO.getIndexAddress(), 100.0));
fullViewRecallList.add(pointNameMapDto);
HashMap<String, String> pointNameMapFromTo = new HashMap<>();
pointNameMapFromTo.put("from", subSystemMapDto.getKey());
pointNameMapFromTo.put("to", pointNameMapDto.getKey());
resultMapFromToList.add(pointNameMapFromTo);
pointNameInt++;
}
}
}
stationDto.setScoreRange("(" + stationLowScore + ", " + stationHighScore + ")");
fullViewRecallList.add(stationDto);
}
areaMapDto.setScoreRange("(" + areaLowScore + ", " + areaHighScore + ")");
fullViewRecallList.add(areaMapDto);
}
resultMapFinally.put("nodeDataArray", fullViewRecallList);
resultMapFinally.put("linkDataArray", resultMapFromToList);
resultMapFinally.put("class", "GraphLinksModel");
return ResponseHelper.buildResponse(resultMapFinally);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "获取区域信息,根据层级查询单位信息 key 和 value都是区域名称")
@GetMapping("/getAreaListByLevel")
public ResponseModel<List<Map<String, String>>> getAreaListByLevel(@RequestParam("level") String level) throws Exception {
FeignClientResult<List<CompanyModel>> listFeignClientResult = Privilege.companyClient.queryAgencyList(level);
ArrayList<Map<String, String>> maps = new ArrayList<>();
if (!ObjectUtils.isEmpty(listFeignClientResult)) {
if (listFeignClientResult.getStatus() == 200) {
listFeignClientResult.getResult().forEach(item -> {
HashMap<String, String> resultMap = new HashMap<>();
resultMap.put("text", item.getCompanyName());
resultMap.put("value", item.getCompanyName());
maps.add(resultMap);
});
} else {
throw new RuntimeException(listFeignClientResult.getMessage());
}
}
return ResponseHelper.buildResponse(maps);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "风电-场站风速 、 光伏-辐照强度 (WTX-801_25_WTX-801_总辐射)")
@GetMapping("/getFanWindSpeedInfo")
public ResponseModel<Map<String, Object>> getFanWindSpeedInfo(@RequestParam("stationId") String stationId,
@RequestParam("equipmentIndexName") String equipmentIndexName,
@RequestParam("limitNum") Integer limitNum,
@RequestParam(value = "stationType", required = false) String stationType) throws Exception {
if (StrUtil.isNotEmpty(stationId)) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
stationId = StrUtil.isNotEmpty(stationType) ? stationBasic.getBoosterGatewayId() : stationBasic.getFanGatewayId();
}
String date = DateUtils.convertDateToString(DateUtils.dateAddHours(DateUtils.getCurrentDayStartTime(new Date()), -8), DateUtils.DATE_TIME_PATTERN);
List<IndicatorData> indicatorDataList = indicatorDataMapper.selectByIndexNameAndDate(equipmentIndexName, stationId, date, limitNum);
Map<String,Object> map = new HashMap<>();
List<Object> valueList = new ArrayList<>();
List<Object> time = new ArrayList<>();
Collections.reverse(indicatorDataList);
for (IndicatorData indicatorData : indicatorDataList) {
valueList.add(String.format("%.2f", indicatorData.getValueF()));
Timestamp createdTime = indicatorData.getCreatedTime();
String s = DateUtils.convertDateToString(createdTime, "HH:mm");
time.add(s);
}
map.put("seriesData", valueList);
map.put("axisData",time);
return ResponseHelper.buildResponse(map);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "修改业务事实表的一条数据")
@PutMapping("/updateRowAndManyTable")
public ResponseModel<Boolean> updateRowAndManyTable(@RequestBody Map<String, Object> kv) {
if ("安全".equals(kv.get("HEALTH_LEVEL").toString())
&& (!"100.0".equals(kv.get("GROUP_UPPER_LIMIT").toString())
&& !"100".equals(kv.get("GROUP_UPPER_LIMIT").toString()))) {
throw new RuntimeException("安全的分数上限只能是100");
}
if ("危险".equals(kv.get("HEALTH_LEVEL").toString())
&& (!"0.0".equals(kv.get("GROUP_LOWER_LIMIT").toString())
&& !"0".equals(kv.get("GROUP_LOWER_LIMIT").toString()))) {
throw new RuntimeException("危险的分数下限只能是0");
}
idxBizFanHealthLevelMapper.updateByInfo(
"idx_biz_pv_health_level",
kv.get("GROUP_UPPER_LIMIT").toString(),
kv.get("GROUP_LOWER_LIMIT").toString(),
kv.get("ANALYSIS_OBJ_TYPE").toString(),
kv.get("HEALTH_LEVEL").toString());
idxBizFanHealthLevelMapper.updateByInfo(
"idx_biz_fan_health_level",
kv.get("GROUP_UPPER_LIMIT").toString(),
kv.get("GROUP_LOWER_LIMIT").toString(),
kv.get("ANALYSIS_OBJ_TYPE").toString(),
kv.get("HEALTH_LEVEL").toString());
if ("安全".equals(kv.get("HEALTH_LEVEL").toString())) {
idxBizFanHealthLevelMapper.updateByInfoIsNull(
"idx_biz_fan_health_level",
kv.get("GROUP_LOWER_LIMIT").toString(),
null,
kv.get("ANALYSIS_OBJ_TYPE").toString(),
"注意");
idxBizFanHealthLevelMapper.updateByInfoIsNull(
"idx_biz_pv_health_level",
kv.get("GROUP_LOWER_LIMIT").toString(),
null,
kv.get("ANALYSIS_OBJ_TYPE").toString(),
"注意");
} else if ("注意".equals(kv.get("HEALTH_LEVEL").toString())) {
idxBizFanHealthLevelMapper.updateByInfoIsNull(
"idx_biz_fan_health_level",
kv.get("GROUP_LOWER_LIMIT").toString(),
null,
kv.get("ANALYSIS_OBJ_TYPE").toString(),
"警告");
idxBizFanHealthLevelMapper.updateByInfoIsNull(
"idx_biz_pv_health_level",
kv.get("GROUP_LOWER_LIMIT").toString(),
null,
kv.get("ANALYSIS_OBJ_TYPE").toString(),
"警告");
} else if ("警告".equals(kv.get("HEALTH_LEVEL").toString())) {
idxBizFanHealthLevelMapper.updateByInfoIsNull(
"idx_biz_fan_health_level",
kv.get("GROUP_LOWER_LIMIT").toString(),
null,
kv.get("ANALYSIS_OBJ_TYPE").toString(),
"危险");
idxBizFanHealthLevelMapper.updateByInfoIsNull(
"idx_biz_pv_health_level",
kv.get("GROUP_LOWER_LIMIT").toString(),
null,
kv.get("ANALYSIS_OBJ_TYPE").toString(),
"危险");
}
if ("测点".equals(kv.get("ANALYSIS_OBJ_TYPE").toString())) {
LambdaUpdateWrapper<IdxBizFanWarningRuleSet> lambda1 = new LambdaUpdateWrapper<>();
lambda1.set(IdxBizFanWarningRuleSet::getWarningIf, "<=" + kv.get("GROUP_UPPER_LIMIT").toString());
lambda1.eq(IdxBizFanWarningRuleSet::getWarningName, kv.get("HEALTH_LEVEL").toString());
idxBizFanWarningRuleSetService.update(lambda1);
LambdaUpdateWrapper<IdxBizPvWarningRuleSet> lambda2 = new LambdaUpdateWrapper<>();
lambda2.set(IdxBizPvWarningRuleSet::getWarningIf, "<=" + kv.get("GROUP_UPPER_LIMIT").toString());
lambda2.eq(IdxBizPvWarningRuleSet::getWarningName, kv.get("HEALTH_LEVEL").toString());
idxBizPvWarningRuleSetService.update(lambda2);
}
return ResponseHelper.buildResponse(true);
}
}
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.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.FanHealthIndexDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.FullViewRecallDataDTO;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.FullViewRecallInfoDTO;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.PvHealthIndexDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthLevel;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvHealthLevel;
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.IdxBizPvHealthLevelMapper;
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 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.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
import static com.yeejoin.amos.boot.biz.common.utils.DateUtils.DATE_TIME_PATTERN;
@RestController
@Api(tags = "智能分析相关API - TD数据源")
@RequestMapping(value = "/tdInfoQueryApi")
public class TdInfoQueryController {
@Autowired
private FanHealthIndexMapper fanHealthIndexMapper;
@Autowired
private PvHealthIndexMapper pvHealthIndexMapper;
@Autowired
private FanWaringRecordMapper fanWaringRecordMapper;
@Autowired
private PvWaringRecordMapper pvWaringRecordMapper;
@Autowired
IdxBizFanHealthLevelMapper idxBizFanHealthLevelMapper;
@Autowired
IdxBizPvHealthLevelMapper idxBizPvHealthLevelMapper;
@Autowired
IdxBizFanHealthIndexMapper idxBizFanHealthIndexMapper;
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping(value = "/getFanHealthIndexInfo")
@ApiOperation(httpMethod = "POST", value = "分页查询健康指数信息 - 风电", notes = "分页查询健康指数信息 - 风电")
public ResponseModel<Page<FanHealthIndex>> getFanHealthIndexInfo(@RequestBody FanHealthIndexDto dto) throws ParseException {
if (CharSequenceUtil.isNotEmpty(dto.getStartDate())) {
String startDate = dto.getStartDate();
Date date = DateUtils.dateParse(startDate, DATE_TIME_PATTERN);
String startDateString = DateUtils.dateFormat(DateUtils.dateAddHours(date, -8), DATE_TIME_PATTERN);
dto.setStartDate(startDateString);
}
if (CharSequenceUtil.isNotEmpty(dto.getEndDate())) {
String endDate = dto.getEndDate();
Date endDateDate = DateUtils.dateParse(endDate, DATE_TIME_PATTERN);
String endDateString = DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, -8), DATE_TIME_PATTERN);
dto.setEndDate(endDateString);
}
Page<FanHealthIndex> resultPage = new Page<>(dto.getCurrent(), dto.getSize());
dto.setCurrent((dto.getCurrent() - 1) * dto.getSize());
List<Map<String, String>> orderWeight = dto.getSorts().stream().sorted(Comparator.comparing(t -> Integer.parseInt(t.get("orderWeight")))).collect(Collectors.toList());
List<String> orderByList = new ArrayList<>();
for (Map<String, String> map : orderWeight) {
String replace = map.get("order").replace("end", "");
String columnOrder = map.get("columnKey") + " " + replace;
orderByList.add(columnOrder);
}
String join = String.join(",", orderByList);
dto.setOrderColumns(join);
List<FanHealthIndex> fanHealthIndexIPage = fanHealthIndexMapper.getInfoByPage(dto);
Integer infoByPageTotal = fanHealthIndexMapper.getInfoByPageTotal(dto);
resultPage.setRecords(fanHealthIndexIPage);
resultPage.setTotal(infoByPageTotal);
return ResponseHelper.buildResponse(resultPage);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping(value = "/getPvHealthIndexInfo")
@ApiOperation(httpMethod = "POST", value = "分页查询健康指数信息 - 光伏", notes = "分页查询健康指数信息 - 光伏")
public ResponseModel<Page<PvHealthIndex>> getPvHealthIndexInfo(@RequestBody PvHealthIndexDto dto) throws ParseException {
if (CharSequenceUtil.isNotEmpty(dto.getStartDate())) {
String startDate = dto.getStartDate();
Date date = DateUtils.dateParse(startDate, DATE_TIME_PATTERN);
String startDateString = DateUtils.dateFormat(DateUtils.dateAddHours(date, -8), DATE_TIME_PATTERN);
dto.setStartDate(startDateString);
}
if (CharSequenceUtil.isNotEmpty(dto.getEndDate())) {
String endDate = dto.getEndDate();
Date endDateDate = DateUtils.dateParse(endDate, DATE_TIME_PATTERN);
String endDateString = DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, -8), DATE_TIME_PATTERN);
dto.setEndDate(endDateString);
}
Page<PvHealthIndex> resultPage = new Page<>(dto.getCurrent(), dto.getSize());
dto.setCurrent((dto.getCurrent() - 1) * dto.getSize());
List<Map<String, String>> orderWeight = dto.getSorts().stream().sorted(Comparator.comparing(t -> Integer.parseInt(t.get("orderWeight")))).collect(Collectors.toList());
List<String> orderByList = new ArrayList<>();
for (Map<String, String> map : orderWeight) {
String replace = map.get("order").replace("end", "");
String columnOrder = map.get("columnKey") + " " + replace;
orderByList.add(columnOrder);
}
String join = String.join(",", orderByList);
dto.setOrderColumns(join);
List<PvHealthIndex> pvHealthIndexIPage = pvHealthIndexMapper.getInfoByPage(dto);
Integer infoByPageTotal = pvHealthIndexMapper.getInfoByPageTotal(dto);
resultPage.setRecords(pvHealthIndexIPage);
resultPage.setTotal(infoByPageTotal);
return ResponseHelper.buildResponse(resultPage);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping(value = "/getFanWarningRecordInfo")
@ApiOperation(httpMethod = "POST", value = "分页查询健康指数信息 - 风电", notes = "分页查询健康指数信息 - 风电")
public ResponseModel<Page<FanWarningRecord>> getFanWarningRecordInfo(@RequestBody FanHealthIndexDto dto) throws ParseException {
if (CharSequenceUtil.isNotEmpty(dto.getStartDate())) {
String startDate = dto.getStartDate();
Date date = DateUtils.dateParse(startDate, DATE_TIME_PATTERN);
String startDateString = DateUtils.dateFormat(DateUtils.dateAddHours(date, -8), DATE_TIME_PATTERN);
dto.setStartDate(startDateString);
}
if (CharSequenceUtil.isNotEmpty(dto.getEndDate())) {
String endDate = dto.getEndDate();
Date endDateDate = DateUtils.dateParse(endDate, DATE_TIME_PATTERN);
String endDateString = DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, -8), DATE_TIME_PATTERN);
dto.setEndDate(endDateString);
}
Page<FanWarningRecord> resultPage = new Page<>(dto.getCurrent(), dto.getSize());
dto.setCurrent((dto.getCurrent() - 1) * dto.getSize());
List<Map<String, String>> orderWeight = dto.getSorts().stream().sorted(Comparator.comparing(t -> Integer.parseInt(t.get("orderWeight")))).collect(Collectors.toList());
List<String> orderByList = new ArrayList<>();
for (Map<String, String> map : orderWeight) {
String replace = map.get("order").replace("end", "");
String columnOrder = map.get("columnKey") + " " + replace;
orderByList.add(columnOrder);
}
String join = String.join(",", orderByList);
dto.setOrderColumns(join);
List<FanWarningRecord> fanWarningRecordsIPage = fanWaringRecordMapper.getInfoByPage(dto);
Integer infoByPageTotal = fanWaringRecordMapper.getInfoByPageTotal(dto);
resultPage.setRecords(fanWarningRecordsIPage);
resultPage.setTotal(infoByPageTotal);
return ResponseHelper.buildResponse(resultPage);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping(value = "/getPvWarningRecordInfo")
@ApiOperation(httpMethod = "POST", value = "分页查询健康指数信息 - 光伏", notes = "分页查询健康指数信息 - 光伏")
public ResponseModel<Page<PvWarningRecord>> getPvWarningRecordInfo(@RequestBody FanHealthIndexDto dto) throws ParseException {
if (CharSequenceUtil.isNotEmpty(dto.getStartDate())) {
String startDate = dto.getStartDate();
Date date = DateUtils.dateParse(startDate, DATE_TIME_PATTERN);
String startDateString = DateUtils.dateFormat(DateUtils.dateAddHours(date, -8), DATE_TIME_PATTERN);
dto.setStartDate(startDateString);
}
if (CharSequenceUtil.isNotEmpty(dto.getEndDate())) {
String endDate = dto.getEndDate();
Date endDateDate = DateUtils.dateParse(endDate, DATE_TIME_PATTERN);
String endDateString = DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, -8), DATE_TIME_PATTERN);
dto.setEndDate(endDateString);
}
Page<PvWarningRecord> resultPage = new Page<>(dto.getCurrent(), dto.getSize());
dto.setCurrent((dto.getCurrent() - 1) * dto.getSize());
List<Map<String, String>> orderWeight = dto.getSorts().stream().sorted(Comparator.comparing(t -> Integer.parseInt(t.get("orderWeight")))).collect(Collectors.toList());
List<String> orderByList = new ArrayList<>();
for (Map<String, String> map : orderWeight) {
String replace = map.get("order").replace("end", "");
String columnOrder = map.get("columnKey") + " " + replace;
orderByList.add(columnOrder);
}
String join = String.join(",", orderByList);
dto.setOrderColumns(join);
List<PvWarningRecord> pvWarningRecords = pvWaringRecordMapper.getInfoByPage(dto);
Integer infoByPageTotal = pvWaringRecordMapper.getInfoByPageTotal(dto);
resultPage.setRecords(pvWarningRecords);
resultPage.setTotal(infoByPageTotal);
return ResponseHelper.buildResponse(resultPage);
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.dto;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Data
public class FanHealthIndexDto implements Serializable {
private Long ts;
private String recDate;
private String analysisObjType;
private String analysisObjSeq;
private Double weight;
private Double healthIndex;
private String healthLevel;
private String analysisType;
private String analysisStartTime;
private String analysisEndTime;
private String area;
private String station;
private String subSystem;
private String number;
private String equipmentName;
private String gatewayId;
private String indexAddress;
private Double anomaly;
private String pointName;
private String analysisTime;
private String kks;
private String startDate;
private String endDate;
private List<Map<String, String>> sorts = new ArrayList<>();
private Integer current;
private Integer size;
private String orderColumns;
private String warningName;
private String warningStatus;
private String disposotionState;
private String subarray;
}
package com.yeejoin.amos.boot.module.jxiop.biz.dto;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
*
*
* @author system_generator
* @date 2023-08-15
*/
@Data
public class PvHealthIndexDto {
private Long ts;
private String recDate;
private String analysisObjType;
private String analysisObjSeq;
private Double weight;
private Double healthIndex;
private String healthLevel;
private String analysisType;
private String analysisStartTime;
private String analysisEndTime;
private String area;
private String station;
private String subarray;
private String manufacturer;
private String deviceType;
private String gatewayId;
private String indexAddress;
private String equipmentName;
private Double anomaly;
private String pointName;
private String analysisTime;
private String kks;
private String startDate;
private String endDate;
private List<Map<String, String>> sorts = new ArrayList<>();
private Integer current;
private Integer size;
private String orderColumns;
}
package com.yeejoin.amos.boot.module.jxiop.biz.emqx; package com.yeejoin.amos.boot.module.jxiop.biz.emqx;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.FanWarningRecordServiceImpl;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.HealthStatusIndicatorServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.HealthStatusIndicatorServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizFanWarningRecordServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.PvWarningRecordServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.IdxBizPvWarningRecordServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanWaringRecordMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvWaringRecordMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvWarningRecord;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttMessage; import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.component.emq.EmqxListener; import org.typroject.tyboot.component.emq.EmqxListener;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.util.*; import java.util.ArrayList;
import java.util.concurrent.BlockingQueue; import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Component @Component
...@@ -35,19 +36,20 @@ public class WarningRecordStatusMessage extends EmqxListener { ...@@ -35,19 +36,20 @@ public class WarningRecordStatusMessage extends EmqxListener {
public static final String WARNING_CHANGE_MESSAGE = "+/warning/change"; public static final String WARNING_CHANGE_MESSAGE = "+/warning/change";
private static final BlockingQueue<JSONArray> blockingQueueFan = new LinkedBlockingQueue<JSONArray>(); @Autowired
private FanWaringRecordMapper fanWaringRecordMapper;
private static final BlockingQueue<JSONArray> blockingQueuePv = new LinkedBlockingQueue<JSONArray>(); @Autowired
private PvWaringRecordMapper pvWaringRecordMapper;
@Autowired @Autowired
private IdxBizFanWarningRecordServiceImpl idxBizFanWarningRecordService; FanWarningRecordServiceImpl fanWarningRecordService;
@Autowired @Autowired
private IdxBizPvWarningRecordServiceImpl idxBizPvWarningRecordService; PvWarningRecordServiceImpl pvWarningRecordService;
@PostConstruct @PostConstruct
void init() throws Exception { void init() throws Exception {
new Thread(taskRunnable).start();
emqKeeper.subscript(WARNING_CHANGE_MESSAGE, 2, this); emqKeeper.subscript(WARNING_CHANGE_MESSAGE, 2, this);
} }
...@@ -56,57 +58,61 @@ public class WarningRecordStatusMessage extends EmqxListener { ...@@ -56,57 +58,61 @@ public class WarningRecordStatusMessage extends EmqxListener {
if (topic.contains(HealthStatusIndicatorServiceImpl.SMART_ANALYSE_PV)) { if (topic.contains(HealthStatusIndicatorServiceImpl.SMART_ANALYSE_PV)) {
log.info("预警状态改变消息-光伏{}", new String(message.getPayload())); log.info("预警状态改变消息-光伏{}", new String(message.getPayload()));
JSONArray ja = JSON.parseArray(new String(message.getPayload())); JSONArray ja = JSON.parseArray(new String(message.getPayload()));
blockingQueuePv.add(ja); jxIopUpdatePv(ja);
} else if (topic.contains(HealthStatusIndicatorServiceImpl.SMART_ANALYSE_FAN)) { } else if (topic.contains(HealthStatusIndicatorServiceImpl.SMART_ANALYSE_FAN)) {
log.info("预警状态改变消息-风电{}", new String(message.getPayload())); log.info("预警状态改变消息-风电{}", new String(message.getPayload()));
JSONArray ja = JSON.parseArray(new String(message.getPayload())); JSONArray ja = JSON.parseArray(new String(message.getPayload()));
blockingQueueFan.add(ja); jxIopUpdateFan(ja);
} }
} }
Runnable taskRunnable = new Runnable() {
@Override
public void run() {
boolean isRun = true;
int k = 0;
while (isRun) {
k++;
isRun = k < Integer.MAX_VALUE;
try {
JSONArray analysisResultFan = blockingQueueFan.take();
jxIopUpdateFan(analysisResultFan);
JSONArray analysisResultPv = blockingQueuePv.take();
jxIopUpdatePv(analysisResultPv);
} catch (Exception e) {
e.printStackTrace();
}
}
}
};
@Async("async")
public void jxIopUpdateFan(JSONArray analysisResult) { public void jxIopUpdateFan(JSONArray analysisResult) {
log.info("修改预警状态信息:{}", analysisResult); log.info("修改预警状态信息:{}", analysisResult);
List<JSONObject> taskList = JSONObject.parseArray(analysisResult.toJSONString(), JSONObject.class); List<JSONObject> taskList = JSONObject.parseArray(analysisResult.toJSONString(), JSONObject.class);
List<String> traceIds = taskList.stream().map(t -> t.get("extAttr1").toString()).collect(Collectors.toList()); List<String> traceIds = taskList.stream().map(t -> t.get("extAttr1").toString()).collect(Collectors.toList());
LambdaUpdateWrapper<IdxBizFanWarningRecord> lambda = new LambdaUpdateWrapper<>(); // LambdaUpdateWrapper<IdxBizFanWarningRecord> lambda = new LambdaUpdateWrapper<>();
lambda.set(IdxBizFanWarningRecord::getDisposotionState, "已处置"); // lambda.set(IdxBizFanWarningRecord::getDisposotionState, "已处置");
lambda.set(IdxBizFanWarningRecord::getStatus, "1"); // lambda.set(IdxBizFanWarningRecord::getStatus, "1");
lambda.set(IdxBizFanWarningRecord::getDisposotionDate, new Date()); // lambda.set(IdxBizFanWarningRecord::getDisposotionDate, new Date());
lambda.in(IdxBizFanWarningRecord::getSequenceNbr, traceIds); // lambda.in(IdxBizFanWarningRecord::getSequenceNbr, traceIds);
idxBizFanWarningRecordService.update(lambda); // idxBizFanWarningRecordService.update(lambda);
List<FanWarningRecord> list = new ArrayList<>();
for (String traceId : traceIds) {
FanWarningRecord fanWarningRecord = new FanWarningRecord();
fanWarningRecord.setTs(Long.valueOf(traceId));
fanWarningRecord.setDisposotionDate(DateUtil.now());
fanWarningRecord.setStatus("1");
fanWarningRecord.setDisposotionState("已处置");
list.add(fanWarningRecord);
}
fanWaringRecordMapper.updateStatusByTs(list);
} }
@Async("async")
public void jxIopUpdatePv(JSONArray analysisResult) { public void jxIopUpdatePv(JSONArray analysisResult) {
log.info("修改预警状态信息:{}", analysisResult); log.info("修改预警状态信息:{}", analysisResult);
List<JSONObject> taskList = JSONObject.parseArray(analysisResult.toJSONString(), JSONObject.class); List<JSONObject> taskList = JSONObject.parseArray(analysisResult.toJSONString(), JSONObject.class);
List<String> traceIds = taskList.stream().map(t -> t.get("extAttr1").toString()).collect(Collectors.toList()); List<String> traceIds = taskList.stream().map(t -> t.get("extAttr1").toString()).collect(Collectors.toList());
LambdaUpdateWrapper<IdxBizPvWarningRecord> lambda = new LambdaUpdateWrapper<>(); // LambdaUpdateWrapper<IdxBizPvWarningRecord> lambda = new LambdaUpdateWrapper<>();
lambda.set(IdxBizPvWarningRecord::getDisposotionState, "已处置"); // lambda.set(IdxBizPvWarningRecord::getDisposotionState, "已处置");
lambda.set(IdxBizPvWarningRecord::getStatus, "1"); // lambda.set(IdxBizPvWarningRecord::getStatus, "1");
lambda.set(IdxBizPvWarningRecord::getDisposotionDate, new Date()); // lambda.set(IdxBizPvWarningRecord::getDisposotionDate, new Date());
lambda.in(IdxBizPvWarningRecord::getSequenceNbr, traceIds); // lambda.in(IdxBizPvWarningRecord::getSequenceNbr, traceIds);
idxBizPvWarningRecordService.update(lambda); // idxBizPvWarningRecordService.update(lambda);
// td
List<PvWarningRecord> list = new ArrayList<>();
for (String traceId : traceIds) {
PvWarningRecord pvWarningRecord = new PvWarningRecord();
pvWarningRecord.setTs(Long.valueOf(traceId));
pvWarningRecord.setDisposotionDate(DateUtil.now());
pvWarningRecord.setStatus("1");
pvWarningRecord.setDisposotionState("已处置");
list.add(pvWarningRecord);
}
pvWaringRecordMapper.updateStatusByTs(list);
} }
} }
...@@ -131,7 +131,7 @@ public interface IdxBizFanHealthIndexMapper extends BaseMapper<IdxBizFanHealthIn ...@@ -131,7 +131,7 @@ public interface IdxBizFanHealthIndexMapper extends BaseMapper<IdxBizFanHealthIn
Map<String,Object> queryForLeftTableListByPointNum(String STATION, String HEALTHLEVEL,String EQUIPMENTNAME,String POINTNAME); Map<String,Object> queryForLeftTableListByPointNum(String STATION, String HEALTHLEVEL,String EQUIPMENTNAME,String POINTNAME);
List<IdxBizFanWarningRecord> warningData(String STATION, String SUBARRAY, String EQUIPMENTNAME); List<IdxBizFanWarningRecord> warningData(String STATION, String SUBARRAY, String EQUIPMENTNAME);
Integer pointNum(String STATION, String SUBARRAY, String EQUIPMENTNAME); Integer pointNum(String STATION, String SUBSYSTEM, String EQUIPMENTNAME);
Map<String, Object> getPvEquipStatusByStation(String station); Map<String, Object> getPvEquipStatusByStation(String station);
......
...@@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
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.IdxBizPvHealthIndex; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvHealthIndex;
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.tdengine.FanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -33,4 +36,10 @@ public interface IdxBizPvHealthIndexMapper extends BaseMapper<IdxBizPvHealthInde ...@@ -33,4 +36,10 @@ public interface IdxBizPvHealthIndexMapper extends BaseMapper<IdxBizPvHealthInde
List<Map<String,Object>> selectPointByANALYSISTYPE(String STATION, String HEALTHLEVEL,String EQUIPMENTNAME,String POINTNAME,String SUBARRAY,String startTime,String endTime); List<Map<String,Object>> selectPointByANALYSISTYPE(String STATION, String HEALTHLEVEL,String EQUIPMENTNAME,String POINTNAME,String SUBARRAY,String startTime,String endTime);
int saveBatchHealthIndexLatestInfo(@Param("list") List<FanHealthIndex> list);
void deleteAllDataByTableName(@Param("tableName") String tableName, @Param("analysisType") String analysisType);
int saveBatchHealthIndexLatestInfoPv(@Param("list") List<PvHealthIndex> list);
} }
...@@ -7,6 +7,14 @@ import com.yeejoin.amos.boot.module.jxiop.biz.constants.CommonConstans; ...@@ -7,6 +7,14 @@ import com.yeejoin.amos.boot.module.jxiop.biz.constants.CommonConstans;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.*; import com.yeejoin.amos.boot.module.jxiop.biz.entity.*;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.*; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.*;
import com.yeejoin.amos.boot.module.jxiop.biz.service.IAlarmInfoDetailService; import com.yeejoin.amos.boot.module.jxiop.biz.service.IAlarmInfoDetailService;
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 org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -43,10 +51,25 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService { ...@@ -43,10 +51,25 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService {
@Autowired @Autowired
IdxBizPvPointVarCorrelationMapper idxBizPvPointVarCorrelationMapper; IdxBizPvPointVarCorrelationMapper idxBizPvPointVarCorrelationMapper;
@Autowired
private FanWaringRecordMapper fanWaringRecordMapper;
@Autowired
private PvWaringRecordMapper pvWaringRecordMapper;
@Autowired
FanHealthIndexMapper fanHealthIndexMapper;
@Autowired
PvHealthIndexMapper pvHealthIndexMapper;
@Override @Override
public Map<String, Object> getAlramInfoDetailOfFan(String id) { public Map<String, Object> getAlramInfoDetailOfFan(String id) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
IdxBizFanWarningRecord idxBizFanWarningRecord = idxBizFanWarningRecordMapper.selectById(id); FanWarningRecord idxBizFanWarningRecord = fanWaringRecordMapper.getInfoByTs(Long.valueOf(id));
//获取告警信息 //获取告警信息
result.put("warningInfo", getFanAlarmInfoMap(idxBizFanWarningRecord)); result.put("warningInfo", getFanAlarmInfoMap(idxBizFanWarningRecord));
//获取工况组合来源 //获取工况组合来源
...@@ -58,7 +81,7 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService { ...@@ -58,7 +81,7 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService {
String startTime = (String) alarmTrendAndAlarmAbnormalityListResult.get("startTime"); String startTime = (String) alarmTrendAndAlarmAbnormalityListResult.get("startTime");
String endTime = (String) alarmTrendAndAlarmAbnormalityListResult.get("endTime"); String endTime = (String) alarmTrendAndAlarmAbnormalityListResult.get("endTime");
//----健康指数来源 //----健康指数来源
List<IdxBizFanPointVarCentralValue> idxBizFanPointVarCentralValueList = idxBizFanPointVarCentralValueMapper List<IdxBizFanPointVarCentralValue> idxBizFanPointVarCentralValueList = idxBizFanPointVarCentralValueMapper
.selectList(new QueryWrapper<IdxBizFanPointVarCentralValue>() .selectList(new QueryWrapper<IdxBizFanPointVarCentralValue>()
.eq("ANALYSIS_POINT_ID", idxBizFanWarningRecord.getAnalysisPointId())); .eq("ANALYSIS_POINT_ID", idxBizFanWarningRecord.getAnalysisPointId()));
IdxBizFanPointVarCentralValue idxBizFanPointVarCentralValue = new IdxBizFanPointVarCentralValue(); IdxBizFanPointVarCentralValue idxBizFanPointVarCentralValue = new IdxBizFanPointVarCentralValue();
...@@ -83,7 +106,7 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService { ...@@ -83,7 +106,7 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService {
@Override @Override
public Map<String, Object> getAlramInfoDetailOfPv(String id) { public Map<String, Object> getAlramInfoDetailOfPv(String id) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
IdxBizPvWarningRecord idxBizPvWarningRecord = idxBizPvWarningRecordMapper.selectById(id); PvWarningRecord idxBizPvWarningRecord = pvWaringRecordMapper.getInfoByTs(Long.valueOf(id));
//告警信息 //告警信息
result.put("warningInfo", getPvAlarmInfoMap(idxBizPvWarningRecord)); result.put("warningInfo", getPvAlarmInfoMap(idxBizPvWarningRecord));
//---------------工况组合来源 //---------------工况组合来源
...@@ -122,7 +145,7 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService { ...@@ -122,7 +145,7 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService {
* @param idxBizFanWarningRecord * @param idxBizFanWarningRecord
* @return 告警信息 * @return 告警信息
*/ */
public HashMap<String, String> getFanAlarmInfoMap(IdxBizFanWarningRecord idxBizFanWarningRecord) { public HashMap<String, String> getFanAlarmInfoMap(FanWarningRecord idxBizFanWarningRecord) {
HashMap<String, String> alarmInfoMap = new HashMap<>(); HashMap<String, String> alarmInfoMap = new HashMap<>();
//测点名称 //测点名称
...@@ -130,11 +153,11 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService { ...@@ -130,11 +153,11 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService {
//告警周期 //告警周期
alarmInfoMap.put("waringPeriod", CommonConstans.waringPeriodStatus.get(idxBizFanWarningRecord.getWarningPeriod())); alarmInfoMap.put("waringPeriod", CommonConstans.waringPeriodStatus.get(idxBizFanWarningRecord.getWarningPeriod()));
//告警时间 //告警时间
alarmInfoMap.put("waringTime", DateUtil.format(idxBizFanWarningRecord.getRecDate(), CommonConstans.waringPeriodDateFormate.get(idxBizFanWarningRecord.getWarningPeriod()))); alarmInfoMap.put("waringTime", DateUtil.format(DateUtil.parse(idxBizFanWarningRecord.getRecDate(), DatePattern.NORM_DATETIME_PATTERN), CommonConstans.waringPeriodDateFormate.get(idxBizFanWarningRecord.getWarningPeriod())));
//预警等级 //预警等级
alarmInfoMap.put("waringLevel", idxBizFanWarningRecord.getWarningName()); alarmInfoMap.put("waringLevel", idxBizFanWarningRecord.getWarningName());
//预警触发规则 //预警触发规则
alarmInfoMap.put("waringRule", idxBizFanWarningRecord.getCONTENT()); alarmInfoMap.put("waringRule", idxBizFanWarningRecord.getContent());
return alarmInfoMap; return alarmInfoMap;
} }
...@@ -143,7 +166,7 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService { ...@@ -143,7 +166,7 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService {
* @param idxBizPvWarningRecord * @param idxBizPvWarningRecord
* @return 告警信息 * @return 告警信息
*/ */
public HashMap<String, String> getPvAlarmInfoMap(IdxBizPvWarningRecord idxBizPvWarningRecord) { public HashMap<String, String> getPvAlarmInfoMap(PvWarningRecord idxBizPvWarningRecord) {
HashMap<String, String> alarmInfoMap = new HashMap<>(); HashMap<String, String> alarmInfoMap = new HashMap<>();
//测点名称 //测点名称
...@@ -151,11 +174,11 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService { ...@@ -151,11 +174,11 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService {
//告警周期 //告警周期
alarmInfoMap.put("waringPeriod", CommonConstans.waringPeriodStatus.get(idxBizPvWarningRecord.getWarningPeriod())); alarmInfoMap.put("waringPeriod", CommonConstans.waringPeriodStatus.get(idxBizPvWarningRecord.getWarningPeriod()));
//告警时间 //告警时间
alarmInfoMap.put("waringTime", DateUtil.format(idxBizPvWarningRecord.getRecDate(), CommonConstans.waringPeriodDateFormate.get(idxBizPvWarningRecord.getWarningPeriod()))); alarmInfoMap.put("waringTime", DateUtil.format(DateUtil.parse(idxBizPvWarningRecord.getRecDate(), DatePattern.NORM_DATETIME_PATTERN), CommonConstans.waringPeriodDateFormate.get(idxBizPvWarningRecord.getWarningPeriod())));
//预警等级 //预警等级
alarmInfoMap.put("waringLevel", idxBizPvWarningRecord.getWarningName()); alarmInfoMap.put("waringLevel", idxBizPvWarningRecord.getWarningName());
//预警触发规则 //预警触发规则
alarmInfoMap.put("waringRule", idxBizPvWarningRecord.getCONTENT()); alarmInfoMap.put("waringRule", idxBizPvWarningRecord.getContent());
return alarmInfoMap; return alarmInfoMap;
} }
...@@ -164,34 +187,35 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService { ...@@ -164,34 +187,35 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService {
* @param idxBizFanWarningRecord * @param idxBizFanWarningRecord
* @return * @return
*/ */
public HashMap<String, Object> getFanAlarmTrendAndAlarmAbnormalityList(IdxBizFanWarningRecord idxBizFanWarningRecord) { public HashMap<String, Object> getFanAlarmTrendAndAlarmAbnormalityList(FanWarningRecord idxBizFanWarningRecord) {
HashMap<String, Object> result = new HashMap<>(); HashMap<String, Object> result = new HashMap<>();
HashMap<String, Object> alarmTrendMap = new HashMap<>(); HashMap<String, Object> alarmTrendMap = new HashMap<>();
HashMap<String,Object> maxValueAndWaringCycle = getWaringCycleAndMaxValueByWaring(idxBizFanWarningRecord.getWarningPeriod(),idxBizFanWarningRecord.getCONTENT(),idxBizFanWarningRecord.getPointName()); HashMap<String,Object> maxValueAndWaringCycle = getWaringCycleAndMaxValueByWaring(idxBizFanWarningRecord.getWarningPeriod(),idxBizFanWarningRecord.getContent(),idxBizFanWarningRecord.getPointName());
Integer warningCycle = Integer.valueOf(maxValueAndWaringCycle.get("warningCycle").toString()); Integer warningCycle = Integer.valueOf(maxValueAndWaringCycle.get("warningCycle").toString());
alarmTrendMap.put("maxValue", maxValueAndWaringCycle.get("maxValue")); alarmTrendMap.put("maxValue", maxValueAndWaringCycle.get("maxValue"));
alarmTrendMap.put("warningCycle", warningCycle); alarmTrendMap.put("warningCycle", warningCycle);
List<HashMap<String, String>> alarmAbnormalityList = new ArrayList<>(); List<HashMap<String, String>> alarmAbnormalityList = new ArrayList<>();
List<IdxBizFanHealthIndex> idxBizFanHealthIndexList = idxBizFanHealthIndexMapper.selectList(new QueryWrapper<IdxBizFanHealthIndex>() List<FanHealthIndex> idxBizFanHealthIndexList = fanHealthIndexMapper.selectList(new QueryWrapper<FanHealthIndex>()
.eq("GATEWAY_ID", idxBizFanWarningRecord.getGatewayId()) .eq("gateway_id", idxBizFanWarningRecord.getGatewayId())
.eq("INDEX_ADDRESS", idxBizFanWarningRecord.getIndexAddress()) .eq("index_address", idxBizFanWarningRecord.getIndexAddress())
.eq("ANALYSIS_TYPE", idxBizFanWarningRecord.getWarningPeriod()) .eq("analysis_type", idxBizFanWarningRecord.getWarningPeriod())
.le("ANALYSIS_TIME", DateUtil.offsetMinute(idxBizFanWarningRecord.getRecDate(), 1)) //时区减8小时 时间加1分钟
.orderByDesc("ANALYSIS_TIME") .le("ts", DateUtil.offsetMinute(DateUtil.parse(idxBizFanWarningRecord.getRecDate(), DatePattern.NORM_DATETIME_PATTERN), -479))
.orderByDesc("ts")
.last("limit 30")); .last("limit 30"));
List<String> xDatas = new ArrayList<>(); List<String> xDatas = new ArrayList<>();
List<Double> yDatas = new ArrayList<>(); List<Double> yDatas = new ArrayList<>();
String startTime = ""; String startTime = idxBizFanWarningRecord.getRecDate();
String endTime = ""; String endTime = idxBizFanWarningRecord.getRecDate();
int idxBizFanHealthIndexListSize = idxBizFanHealthIndexList.size(); int idxBizFanHealthIndexListSize = idxBizFanHealthIndexList.size();
for (int i = idxBizFanHealthIndexListSize - 1; i >= 0; i--) { for (int i = idxBizFanHealthIndexListSize - 1; i >= 0; i--) {
HashMap<String, String> alarmAbnormalityItem = new HashMap<>(); HashMap<String, String> alarmAbnormalityItem = new HashMap<>();
IdxBizFanHealthIndex idxBizFanHealthIndex = idxBizFanHealthIndexList.get(i); FanHealthIndex idxBizFanHealthIndex = idxBizFanHealthIndexList.get(i);
xDatas.add(idxBizFanHealthIndex.getANALYSISTIME()); xDatas.add(idxBizFanHealthIndex.getAnalysisTime());
yDatas.add(idxBizFanHealthIndex.getHealthIndex()); yDatas.add(idxBizFanHealthIndex.getHealthIndex());
alarmAbnormalityItem.put("sort", String.valueOf(i)); alarmAbnormalityItem.put("sort", String.valueOf(i));
alarmAbnormalityItem.put("time", idxBizFanHealthIndex.getANALYSISTIME()); alarmAbnormalityItem.put("time", idxBizFanHealthIndex.getAnalysisTime());
alarmAbnormalityItem.put("abnormal", String.valueOf(idxBizFanHealthIndex.getANOMALY()).replace("null","0.0")); alarmAbnormalityItem.put("abnormal", String.valueOf(idxBizFanHealthIndex.getAnomaly()).replace("null","0.0"));
alarmAbnormalityItem.put("healthValue", String.valueOf(idxBizFanHealthIndex.getHealthIndex())); alarmAbnormalityItem.put("healthValue", String.valueOf(idxBizFanHealthIndex.getHealthIndex()));
alarmAbnormalityList.add(alarmAbnormalityItem); alarmAbnormalityList.add(alarmAbnormalityItem);
} }
...@@ -200,7 +224,7 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService { ...@@ -200,7 +224,7 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService {
result.put("alarmTrend", alarmTrendMap); result.put("alarmTrend", alarmTrendMap);
// 异常度 alarmAbnormality // 异常度 alarmAbnormality
alarmAbnormalityList=alarmAbnormalityList.subList(alarmAbnormalityList.size() - warningCycle, alarmAbnormalityList.size()); alarmAbnormalityList=alarmAbnormalityList.subList(alarmAbnormalityList.size() - warningCycle >= 0 ? alarmAbnormalityList.size() - warningCycle : 0, alarmAbnormalityList.size());
alarmAbnormalityList.sort(Comparator.comparingInt(o->Integer.parseInt(o.get("sort")))); alarmAbnormalityList.sort(Comparator.comparingInt(o->Integer.parseInt(o.get("sort"))));
if(alarmAbnormalityList.size()>0){ if(alarmAbnormalityList.size()>0){
endTime = handlerDateStr(alarmAbnormalityList.get(0).get("time"),-8,5); endTime = handlerDateStr(alarmAbnormalityList.get(0).get("time"),-8,5);
...@@ -217,55 +241,55 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService { ...@@ -217,55 +241,55 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService {
* @param idxBizPvWarningRecord * @param idxBizPvWarningRecord
* @return * @return
*/ */
public HashMap<String, Object> getPvAlarmTrendAndAlarmAbnormalityList(IdxBizPvWarningRecord idxBizPvWarningRecord) { public HashMap<String, Object> getPvAlarmTrendAndAlarmAbnormalityList(PvWarningRecord idxBizPvWarningRecord) {
HashMap<String, Object> result = new HashMap<>(); HashMap<String, Object> result = new HashMap<>();
HashMap<String, Object> alarmTrendMap = new HashMap<>(); HashMap<String, Object> alarmTrendMap = new HashMap<>();
HashMap<String,Object> maxValueAndWaringCycle = getWaringCycleAndMaxValueByWaring(idxBizPvWarningRecord.getWarningPeriod(),idxBizPvWarningRecord.getCONTENT(),idxBizPvWarningRecord.getPointName()); HashMap<String,Object> maxValueAndWaringCycle = getWaringCycleAndMaxValueByWaring(idxBizPvWarningRecord.getWarningPeriod(),idxBizPvWarningRecord.getContent(),idxBizPvWarningRecord.getPointName());
Integer warningCycle = Integer.valueOf(maxValueAndWaringCycle.get("warningCycle").toString()); Integer warningCycle = Integer.valueOf(maxValueAndWaringCycle.get("warningCycle").toString());
alarmTrendMap.put("maxValue", maxValueAndWaringCycle.get("maxValue")); alarmTrendMap.put("maxValue", maxValueAndWaringCycle.get("maxValue"));
alarmTrendMap.put("warningCycle", warningCycle); alarmTrendMap.put("warningCycle", warningCycle);
List<HashMap<String, String>> alarmAbnormalityList = new ArrayList<>(); List<HashMap<String, String>> alarmAbnormalityList = new ArrayList<>();
List<IdxBizPvHealthIndex> idxBizPvHealthIndexList = idxBizPvHealthIndexMapper.selectList(new QueryWrapper<IdxBizPvHealthIndex>() List<PvHealthIndex> idxBizPvHealthIndexList = pvHealthIndexMapper.selectList(new QueryWrapper<PvHealthIndex>()
.eq("GATEWAY_ID", idxBizPvWarningRecord.getGatewayId()) .eq("gateway_id", idxBizPvWarningRecord.getGatewayId())
.eq("INDEX_ADDRESS", idxBizPvWarningRecord.getIndexAddress()) .eq("index_address", idxBizPvWarningRecord.getIndexAddress())
.eq("ANALYSIS_TYPE", idxBizPvWarningRecord.getWarningPeriod()) .eq("analysis_type", idxBizPvWarningRecord.getWarningPeriod())
.le("ANALYSIS_TIME", DateUtil.offsetMinute(idxBizPvWarningRecord.getRecDate(), 1)) .le("ts", DateUtil.offsetMinute(DateUtil.parse(idxBizPvWarningRecord.getRecDate(), DatePattern.NORM_DATETIME_PATTERN), -479))
.orderByDesc("ANALYSIS_TIME") .orderByDesc("ts")
.last("limit 30")); .last("limit 30"));
List<String> xDatas = new ArrayList<>(); List<String> xDatas = new ArrayList<>();
List<Double> yDatas = new ArrayList<>(); List<Double> yDatas = new ArrayList<>();
String startTime = ""; String startTime = idxBizPvWarningRecord.getRecDate();
String endTime = ""; String endTime = idxBizPvWarningRecord.getRecDate();
int idxBizPvHealthIndexListSize = idxBizPvHealthIndexList.size(); int idxBizPvHealthIndexListSize = idxBizPvHealthIndexList.size();
for (int i = idxBizPvHealthIndexList.size() - 1; i >= 0; i--) { for (int i = idxBizPvHealthIndexList.size() - 1; i >= 0; i--) {
HashMap<String, String> alarmAbnormalityItem = new HashMap<>(); HashMap<String, String> alarmAbnormalityItem = new HashMap<>();
IdxBizPvHealthIndex idxBizPvHealthIndex = idxBizPvHealthIndexList.get(i); PvHealthIndex idxBizPvHealthIndex = idxBizPvHealthIndexList.get(i);
xDatas.add(idxBizPvHealthIndex.getANALYSISTIME()); xDatas.add(idxBizPvHealthIndex.getAnalysisTime());
yDatas.add(idxBizPvHealthIndex.getHealthIndex()); yDatas.add(idxBizPvHealthIndex.getHealthIndex());
alarmAbnormalityItem.put("sort", String.valueOf(i)); alarmAbnormalityItem.put("sort", String.valueOf(i));
alarmAbnormalityItem.put("time", idxBizPvHealthIndex.getANALYSISTIME()); alarmAbnormalityItem.put("time", idxBizPvHealthIndex.getAnalysisTime());
alarmAbnormalityItem.put("abnormal", String.valueOf(idxBizPvHealthIndex.getANOMALY()).replace("null","0.0")); alarmAbnormalityItem.put("abnormal", String.valueOf(idxBizPvHealthIndex.getAnomaly()).replace("null","0.0"));
alarmAbnormalityItem.put("healthValue", String.valueOf(idxBizPvHealthIndex.getHealthIndex())); alarmAbnormalityItem.put("healthValue", String.valueOf(idxBizPvHealthIndex.getHealthIndex()));
if (idxBizPvHealthIndexListSize >= 3) { if (idxBizPvHealthIndexListSize >= 3) {
if (i == 0) { if (i == 0) {
endTime = handlerDateStr(idxBizPvHealthIndex.getANALYSISTIME(), -8, 5); endTime = handlerDateStr(idxBizPvHealthIndex.getAnalysisTime(), -8, 5);
} }
if (i == 2) { if (i == 2) {
startTime = handlerDateStr(idxBizPvHealthIndex.getANALYSISTIME(), -8, -5); startTime = handlerDateStr(idxBizPvHealthIndex.getAnalysisTime(), -8, -5);
} }
} }
if (idxBizPvHealthIndexListSize == 2) { if (idxBizPvHealthIndexListSize == 2) {
if (i == 0) { if (i == 0) {
endTime = handlerDateStr(idxBizPvHealthIndex.getANALYSISTIME(), -8, 5); endTime = handlerDateStr(idxBizPvHealthIndex.getAnalysisTime(), -8, 5);
} }
if (i == 1) { if (i == 1) {
startTime = handlerDateStr(idxBizPvHealthIndex.getANALYSISTIME(), -8, -5); startTime = handlerDateStr(idxBizPvHealthIndex.getAnalysisTime(), -8, -5);
} }
} }
if (idxBizPvHealthIndexListSize == 1) { if (idxBizPvHealthIndexListSize == 1) {
if (i == 0) { if (i == 0) {
endTime = handlerDateStr(idxBizPvHealthIndex.getANALYSISTIME(), -8, 5); endTime = handlerDateStr(idxBizPvHealthIndex.getAnalysisTime(), -8, 5);
startTime = handlerDateStr(idxBizPvHealthIndex.getANALYSISTIME(), -8, -5); startTime = handlerDateStr(idxBizPvHealthIndex.getAnalysisTime(), -8, -5);
} }
} }
alarmAbnormalityList.add(alarmAbnormalityItem); alarmAbnormalityList.add(alarmAbnormalityItem);
...@@ -276,7 +300,7 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService { ...@@ -276,7 +300,7 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService {
alarmTrendMap.put("warningCycle", maxValueAndWaringCycle.get("warningCycle")); alarmTrendMap.put("warningCycle", maxValueAndWaringCycle.get("warningCycle"));
result.put("alarmTrend", alarmTrendMap); result.put("alarmTrend", alarmTrendMap);
// 异常度 alarmAbnormality // 异常度 alarmAbnormality
alarmAbnormalityList=alarmAbnormalityList.subList(alarmAbnormalityList.size() - warningCycle, alarmAbnormalityList.size()); alarmAbnormalityList=alarmAbnormalityList.subList(alarmAbnormalityList.size() - warningCycle >= 0 ? alarmAbnormalityList.size() - warningCycle : 0, alarmAbnormalityList.size());
alarmAbnormalityList.sort(Comparator.comparingInt(o->Integer.parseInt(o.get("sort")))); alarmAbnormalityList.sort(Comparator.comparingInt(o->Integer.parseInt(o.get("sort"))));
if(alarmAbnormalityList.size()>0){ if(alarmAbnormalityList.size()>0){
endTime = handlerDateStr(alarmAbnormalityList.get(0).get("time"),-8,5); endTime = handlerDateStr(alarmAbnormalityList.get(0).get("time"),-8,5);
...@@ -397,7 +421,7 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService { ...@@ -397,7 +421,7 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService {
* @param idxBizFanWarningRecord * @param idxBizFanWarningRecord
* @return * @return
*/ */
public HashMap<String, Object> getSourceInfoMapFan(IdxBizFanWarningRecord idxBizFanWarningRecord) { public HashMap<String, Object> getSourceInfoMapFan(FanWarningRecord idxBizFanWarningRecord) {
List<IdxBizFanPointVarCorrelation> idxBizFanPointVarCorrelationList = idxBizFanPointVarCorrelationMapper List<IdxBizFanPointVarCorrelation> idxBizFanPointVarCorrelationList = idxBizFanPointVarCorrelationMapper
.selectList(new QueryWrapper<IdxBizFanPointVarCorrelation>().eq("EQUIPMENT_NAME", idxBizFanWarningRecord.getEquipmentName())); .selectList(new QueryWrapper<IdxBizFanPointVarCorrelation>().eq("EQUIPMENT_NAME", idxBizFanWarningRecord.getEquipmentName()));
Map<String, Double> idxBizFanPointVarCorrelationListValues = new HashMap<>(); Map<String, Double> idxBizFanPointVarCorrelationListValues = new HashMap<>();
...@@ -423,7 +447,7 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService { ...@@ -423,7 +447,7 @@ public class AlarmInfoDetailServiceImpl implements IAlarmInfoDetailService {
* @param idxBizPvWarningRecord * @param idxBizPvWarningRecord
* @return * @return
*/ */
public HashMap<String, Object> getSourceInfoMapPv(IdxBizPvWarningRecord idxBizPvWarningRecord) { public HashMap<String, Object> getSourceInfoMapPv(PvWarningRecord idxBizPvWarningRecord) {
List<IdxBizPvPointVarCorrelation> idxBizPvPointVarCorrelationList = idxBizPvPointVarCorrelationMapper List<IdxBizPvPointVarCorrelation> idxBizPvPointVarCorrelationList = idxBizPvPointVarCorrelationMapper
.selectList(new QueryWrapper<IdxBizPvPointVarCorrelation>().eq("EQUIPMENT_NAME", idxBizPvWarningRecord.getEquipmentName())); .selectList(new QueryWrapper<IdxBizPvPointVarCorrelation>().eq("EQUIPMENT_NAME", idxBizPvWarningRecord.getEquipmentName()));
Map<String, Double> idxBizPvPointVarCorrelationListValues = new HashMap<>(); Map<String, Double> idxBizPvPointVarCorrelationListValues = new HashMap<>();
......
...@@ -150,6 +150,10 @@ public class CommonServiceImpl { ...@@ -150,6 +150,10 @@ public class CommonServiceImpl {
private FanHealthIndexMapper fanHealthIndexMapper; private FanHealthIndexMapper fanHealthIndexMapper;
@Autowired @Autowired
private IdxBizPvHealthIndexMapper idxFanHealthIndexMapper;
@Autowired
private PvHealthIndexMapper pvHealthIndexMapper; private PvHealthIndexMapper pvHealthIndexMapper;
...@@ -1708,7 +1712,7 @@ public class CommonServiceImpl { ...@@ -1708,7 +1712,7 @@ public class CommonServiceImpl {
} }
idxBizFanHealthIndexService.saveBatch(idxBizFanHealthIndexs); idxBizFanHealthIndexService.saveBatch(idxBizFanHealthIndexs);
// 按时刻相关数据插入TDEngine 【异步】 // 按时刻相关数据插入TDEngine 【异步】
insertFanDataTDEngine(fanHealthIndices1, format); insertFanDataTDEngine(fanHealthIndices1, format, "按时刻");
} }
...@@ -1732,7 +1736,8 @@ public class CommonServiceImpl { ...@@ -1732,7 +1736,8 @@ public class CommonServiceImpl {
* @param fanHealthIndices * @param fanHealthIndices
*/ */
@Async @Async
public void insertFanDataTDEngine(ArrayList<FanHealthIndex> fanHealthIndices, String recDate) { public void insertFanDataTDEngine(ArrayList<FanHealthIndex> fanHealthIndices, String recDate, String analysisType) {
idxFanHealthIndexMapper.deleteAllDataByTableName("fan_health_index_latest_data", analysisType);
// 按时刻 - 测点插入 // 按时刻 - 测点插入
ArrayList<FanHealthIndex> newList = new ArrayList<>(); ArrayList<FanHealthIndex> newList = new ArrayList<>();
for (int i = 0; i < fanHealthIndices.size(); i++) { for (int i = 0; i < fanHealthIndices.size(); i++) {
...@@ -1740,7 +1745,8 @@ public class CommonServiceImpl { ...@@ -1740,7 +1745,8 @@ public class CommonServiceImpl {
newList.add(fanHealthIndices.get(i));//循环将数据填入载体list newList.add(fanHealthIndices.get(i));//循环将数据填入载体list
if (500 == newList.size() || i == fanHealthIndices.size() - 1) { //载体list达到要求,进行批量操作 if (500 == newList.size() || i == fanHealthIndices.size() - 1) { //载体list达到要求,进行批量操作
//调用批量插入 //调用批量插入
fanHealthIndexMapper.saveBatchHealthIndexList(newList, "fan_health_index_moment"); fanHealthIndexMapper.saveBatchHealthIndexList(newList, "fan_health_index_moment", analysisType);
idxFanHealthIndexMapper.saveBatchHealthIndexLatestInfo(newList);
newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入 newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入
} }
} }
...@@ -1982,7 +1988,7 @@ public class CommonServiceImpl { ...@@ -1982,7 +1988,7 @@ public class CommonServiceImpl {
} }
idxBizPvHealthIndexService.saveBatch(idxBizPvHealthIndexs); idxBizPvHealthIndexService.saveBatch(idxBizPvHealthIndexs);
//按时刻 - 相关数据插入 //按时刻 - 相关数据插入
insertPvDataTDEngine(fanHealthIndices1, format); insertPvDataTDEngine(fanHealthIndices1, format, "按时刻");
} }
try { try {
logger.info("--------------------response: " + response); logger.info("--------------------response: " + response);
...@@ -2000,7 +2006,10 @@ public class CommonServiceImpl { ...@@ -2000,7 +2006,10 @@ public class CommonServiceImpl {
* @param pvHealthIndices * @param pvHealthIndices
*/ */
@Async @Async
public void insertPvDataTDEngine(ArrayList<PvHealthIndex> pvHealthIndices, String recDate) { public void insertPvDataTDEngine(ArrayList<PvHealthIndex> pvHealthIndices, String recDate, String analysisType) {
idxFanHealthIndexMapper.deleteAllDataByTableName("pv_health_index_latest_data", analysisType);
// 按时刻 - 测点插入 // 按时刻 - 测点插入
ArrayList<PvHealthIndex> newList = new ArrayList<>(); ArrayList<PvHealthIndex> newList = new ArrayList<>();
for (int i = 0; i < pvHealthIndices.size(); i++) { for (int i = 0; i < pvHealthIndices.size(); i++) {
...@@ -2008,7 +2017,8 @@ public class CommonServiceImpl { ...@@ -2008,7 +2017,8 @@ public class CommonServiceImpl {
newList.add(pvHealthIndices.get(i));//循环将数据填入载体list newList.add(pvHealthIndices.get(i));//循环将数据填入载体list
if (500 == newList.size() || i == pvHealthIndices.size() - 1) { //载体list达到要求,进行批量操作 if (500 == newList.size() || i == pvHealthIndices.size() - 1) { //载体list达到要求,进行批量操作
//调用批量插入 //调用批量插入
pvHealthIndexMapper.saveBatchHealthIndexList(newList, "pv_health_index_moment"); pvHealthIndexMapper.saveBatchHealthIndexList(newList, "pv_health_index_moment", analysisType);
idxFanHealthIndexMapper.saveBatchHealthIndexLatestInfoPv(newList);
newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入 newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入
} }
} }
......
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanWaringRecordMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanWarningRecord;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService;
@Service
public class FanWarningRecordServiceImpl extends BaseService<FanWarningRecord, FanWarningRecord, FanWaringRecordMapper> {
}
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl; package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jxiop.api.dto.BizMessage; 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.RiskBizInfoVo;
...@@ -13,8 +15,11 @@ import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper; ...@@ -13,8 +15,11 @@ import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.Enum.WarningNameEnum; import com.yeejoin.amos.boot.module.jxiop.biz.Enum.WarningNameEnum;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.*; import com.yeejoin.amos.boot.module.jxiop.biz.entity.*;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.*; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.*;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.*;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
...@@ -25,9 +30,13 @@ import org.springframework.util.ObjectUtils; ...@@ -25,9 +30,13 @@ import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.yeejoin.amos.boot.biz.common.utils.DateUtils.DATE_TIME_PATTERN;
@EnableScheduling @EnableScheduling
@Service @Service
@Slf4j @Slf4j
...@@ -71,6 +80,27 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -71,6 +80,27 @@ public class HealthStatusIndicatorServiceImpl {
@Autowired @Autowired
IdxBizPvHealthIndexMapper idxBizPvHealthIndexMapper; IdxBizPvHealthIndexMapper idxBizPvHealthIndexMapper;
@Autowired
PvHealthIndexHourMapper pvHealthIndexHourMapper;
@Autowired
PvHealthIndexDayMapper pvHealthIndexDayMapper;
@Autowired
PvHealthIndexMomentMapper pvHealthIndexMomentMapper;
@Autowired
FanHealthIndexHourMapper fanHealthIndexHourMapper;
@Autowired
FanHealthIndexDayMapper fanHealthIndexDayMapper;
@Autowired
FanHealthIndexMomentMapper fanHealthIndexMomentMapper;
@Autowired @Autowired
IdxBizPvWarningRuleSetMapper idxBizPvWarningRuleSetMapper; IdxBizPvWarningRuleSetMapper idxBizPvWarningRuleSetMapper;
@Autowired @Autowired
...@@ -106,6 +136,14 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -106,6 +136,14 @@ public class HealthStatusIndicatorServiceImpl {
*/ */
public static final String SMART_ANALYSE_FAN = "smartAnalyseFan"; public static final String SMART_ANALYSE_FAN = "smartAnalyseFan";
@Autowired
private FanWaringRecordMapper fanWaringRecordMapper;
@Autowired
private FanWarningRecordServiceImpl fanWarningRecordService;
@Autowired
private PvWaringRecordMapper pvWaringRecordMapper;
/*** /***
* 每一小时获取一次最大粒度内的指数异常数据 * 每一小时获取一次最大粒度内的指数异常数据
...@@ -119,19 +157,21 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -119,19 +157,21 @@ public class HealthStatusIndicatorServiceImpl {
if (!openHealth){ if (!openHealth){
return; return;
} }
String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00");
Date date = DateUtils.dateAddHours(time, -8);
log.info("光伏---------------------预警时间----"+time); log.info("光伏---------------------预警时间----"+time);
// Calendar calendar = Calendar.getInstance(); // Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY,calendar.get(Calendar.HOUR_OF_DAY)-1); calendar.set(Calendar.HOUR_OF_DAY,calendar.get(Calendar.HOUR_OF_DAY)-1);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm"); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
LambdaQueryWrapper<IdxBizPvHealthIndex> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PvHealthIndexMoment> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(IdxBizPvHealthIndex::getAnalysisType,"按时刻"); wrapper.ne(PvHealthIndexMoment::getHealthLevel,"安全");
wrapper.ne(IdxBizPvHealthIndex::getHealthLevel,"安全"); wrapper.ge(PvHealthIndexMoment::getTs,date);
wrapper.ge(IdxBizPvHealthIndex::getRecDate,df.format(calendar.getTime())); wrapper.eq(PvHealthIndexMoment::getAnalysisObjType, "测点");
wrapper.orderByDesc(IdxBizPvHealthIndex::getRecDate); wrapper.orderByDesc(PvHealthIndexMoment::getTs);
List<IdxBizPvHealthIndex> healthIndices = idxBizPvHealthIndexMapper.selectList(wrapper); List<PvHealthIndexMoment> healthIndices = pvHealthIndexMomentMapper.selectList(wrapper);
List<String> collect = healthIndices.stream().map(IdxBizPvHealthIndex::getAnalysisObjSeq).collect(Collectors.toList()); List<String> collect = healthIndices.stream().map(PvHealthIndexMoment::getAnalysisObjSeq).collect(Collectors.toList());
if (null == healthIndices ){ if (null == healthIndices ){
return; return;
} }
...@@ -141,8 +181,9 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -141,8 +181,9 @@ public class HealthStatusIndicatorServiceImpl {
List<IdxBizPvWarningRuleSet> idxBizPvWarningRules = idxBizPvWarningRuleSetMapper.selectList(queryWrapper); List<IdxBizPvWarningRuleSet> idxBizPvWarningRules = idxBizPvWarningRuleSetMapper.selectList(queryWrapper);
Map<String, Map<String, List<IdxBizPvHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizPvHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizPvHealthIndex::getIndexAddress))); Map<String, Map<String, List<PvHealthIndexMoment>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(PvHealthIndexMoment::getGatewayId, Collectors.groupingBy(PvHealthIndexMoment::getIndexAddress)));
List<IdxBizPvWarningRecord> idxBizPvWarningRecordList = new ArrayList<>(); List<IdxBizPvWarningRecord> idxBizPvWarningRecordList = new ArrayList<>();
List<PvWarningRecord> tdPvWarningRecordList = new ArrayList<>();
HashMap<String, StationBasic> stationMap = new HashMap<>(); HashMap<String, StationBasic> stationMap = new HashMap<>();
for (String gateWayId : gateWayMaps.keySet()) { for (String gateWayId : gateWayMaps.keySet()) {
...@@ -152,9 +193,9 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -152,9 +193,9 @@ public class HealthStatusIndicatorServiceImpl {
StationBasic stationBasic = stationBasicMapper.selectOne(basicLambdaQueryWrapper); StationBasic stationBasic = stationBasicMapper.selectOne(basicLambdaQueryWrapper);
stationMap.put(gateWayId, stationBasic); stationMap.put(gateWayId, stationBasic);
Map<String, List<IdxBizPvHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId); Map<String, List<PvHealthIndexMoment>> healthDataMaps = gateWayMaps.get(gateWayId);
for (String address : healthDataMaps.keySet()) { for (String address : healthDataMaps.keySet()) {
List<IdxBizPvHealthIndex> idxBizPvHealthIndices = healthDataMaps.get(address); List<PvHealthIndexMoment> idxBizPvHealthIndices = healthDataMaps.get(address);
List<IdxBizPvWarningRuleSet> idxBizPvWarningRuleSets = idxBizPvWarningRules.stream().filter(t -> t.getAnalysisPointId().equals(idxBizPvHealthIndices.get(0).getAnalysisObjSeq())).collect(Collectors.toList()); List<IdxBizPvWarningRuleSet> idxBizPvWarningRuleSets = idxBizPvWarningRules.stream().filter(t -> t.getAnalysisPointId().equals(idxBizPvHealthIndices.get(0).getAnalysisObjSeq())).collect(Collectors.toList());
if (ObjectUtils.isEmpty(idxBizPvWarningRuleSets) ){ if (ObjectUtils.isEmpty(idxBizPvWarningRuleSets) ){
continue; continue;
...@@ -187,7 +228,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -187,7 +228,7 @@ public class HealthStatusIndicatorServiceImpl {
} }
List<Double> healthIndex = idxBizPvHealthIndices.stream().map(IdxBizPvHealthIndex::getHealthIndex).collect(Collectors.toList()); List<Double> healthIndex = idxBizPvHealthIndices.stream().map(PvHealthIndexMoment::getHealthIndex).collect(Collectors.toList());
Double finalHealthValueRisk = healthValueRisk; Double finalHealthValueRisk = healthValueRisk;
long riskNum = healthIndex.stream().filter(e -> e <= finalHealthValueRisk).count(); long riskNum = healthIndex.stream().filter(e -> e <= finalHealthValueRisk).count();
Double finalHealthValueWarn = healthValueWarn; Double finalHealthValueWarn = healthValueWarn;
...@@ -215,19 +256,18 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -215,19 +256,18 @@ public class HealthStatusIndicatorServiceImpl {
} }
//库里若已存在该测点预警 不生成重复的 若新生预警等级高于历史 则生成 //库里若已存在该测点预警 不生成重复的 若新生预警等级高于历史 则生成
LambdaQueryWrapper<IdxBizPvWarningRecord> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PvWarningRecord> query = new LambdaQueryWrapper<>();
query.eq(IdxBizPvWarningRecord::getAnalysisPointId,idxBizPvHealthIndices.get(0).getAnalysisObjSeq()); query.eq(PvWarningRecord::getAnalysisPointId,idxBizPvHealthIndices.get(0).getAnalysisObjSeq());
query.eq(IdxBizPvWarningRecord::getStatus,0); query.eq(PvWarningRecord::getStatus,0);
query.orderByDesc(IdxBizPvWarningRecord::getRecDate); query.orderByDesc(PvWarningRecord::getTs);
List<IdxBizPvWarningRecord> idxBizPvWarningRecords = idxBizPvWarningRecordMapper.selectList(query); List<PvWarningRecord> idxBizPvWarningRecords = pvWaringRecordMapper.selectList(query);
int flag = ObjectUtils.isEmpty(idxBizPvWarningRecords) || WarningNameEnum.getCode(level) > WarningNameEnum.getCode(idxBizPvWarningRecords.get(0).getWarningName()) ? 0 :1; int flag = ObjectUtils.isEmpty(idxBizPvWarningRecords) || WarningNameEnum.getCode(level) > WarningNameEnum.getCode(idxBizPvWarningRecords.get(0).getWarningName()) ? 0 :1;
if (!level.equals("") && flag == 0){ if (!level.equals("") && flag == 0){
IdxBizPvWarningRecord idxBizPvWarningRecord = new IdxBizPvWarningRecord(); IdxBizPvWarningRecord idxBizPvWarningRecord = new IdxBizPvWarningRecord();
idxBizPvWarningRecord.setKks(idxBizPvHealthIndices.get(0).getKks()); idxBizPvWarningRecord.setKks(idxBizPvHealthIndices.get(0).getKks());
idxBizPvWarningRecord.setRecord(idxBizPvHealthIndices.get(0).getRecord()); idxBizPvWarningRecord.setArae(idxBizPvHealthIndices.get(0).getArea());
idxBizPvWarningRecord.setArae(idxBizPvHealthIndices.get(0).getArae());
idxBizPvWarningRecord.setStation(idxBizPvHealthIndices.get(0).getStation()); idxBizPvWarningRecord.setStation(idxBizPvHealthIndices.get(0).getStation());
idxBizPvWarningRecord.setSubarray(idxBizPvHealthIndices.get(0).getSubarray()); idxBizPvWarningRecord.setSubarray(idxBizPvHealthIndices.get(0).getSubarray());
idxBizPvWarningRecord.setGatewayId(gateWayId); idxBizPvWarningRecord.setGatewayId(gateWayId);
...@@ -245,14 +285,27 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -245,14 +285,27 @@ public class HealthStatusIndicatorServiceImpl {
idxBizPvWarningRecord.setHealthIndexSeq(idxBizPvHealthIndices.get(0).getHealthIndex().toString()); idxBizPvWarningRecord.setHealthIndexSeq(idxBizPvHealthIndices.get(0).getHealthIndex().toString());
idxBizPvWarningRecord.setHealthLevel(idxBizPvHealthIndices.get(0).getHealthLevel()); idxBizPvWarningRecord.setHealthLevel(idxBizPvHealthIndices.get(0).getHealthLevel());
idxBizPvWarningRecordList.add(idxBizPvWarningRecord); idxBizPvWarningRecordList.add(idxBizPvWarningRecord);
long currentTimeMillis = System.currentTimeMillis();
// idxBizPvWarningRecordMapper.insert(idxBizPvWarningRecord); long nanoTime = System.nanoTime();
long timestamp = currentTimeMillis * 1000000 + nanoTime % 1000000;
PvWarningRecord pvWarningRecord = new PvWarningRecord();
BeanUtils.copyProperties(idxBizPvWarningRecord, pvWarningRecord, "disposotionDate", "recDate", "CONTENT");
pvWarningRecord.setContent(idxBizPvWarningRecord.getCONTENT());
pvWarningRecord.setRecDate(format);
pvWarningRecord.setTs(timestamp);
tdPvWarningRecordList.add(pvWarningRecord);
// idxBizPvWarningRecordMapper.insert(idxBizPvWarningRecord);
} }
} }
} }
idxBizPvWarningRecordService.saveBatch(idxBizPvWarningRecordList); idxBizPvWarningRecordService.saveBatch(idxBizPvWarningRecordList);
if (CollUtil.isNotEmpty(tdPvWarningRecordList)) {
// tdengine插入
pvWaringRecordMapper.saveBatchWarningRecords(tdPvWarningRecordList);
}
// 触发风险模型生成预警处置模块的预警记录 // 触发风险模型生成预警处置模块的预警记录
fetchDataPv(idxBizPvWarningRecordList, stationMap); fetchDataPv(tdPvWarningRecordList, stationMap);
} }
...@@ -269,18 +322,20 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -269,18 +322,20 @@ public class HealthStatusIndicatorServiceImpl {
return; return;
} }
Date time = new Date(); Date time = new Date();
Calendar calendar = Calendar.getInstance(); Date date = DateUtils.dateAddHours(time, -13);
calendar.set(Calendar.HOUR_OF_DAY,calendar.get(Calendar.HOUR_OF_DAY)-5); // Calendar calendar = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm"); // calendar.set(Calendar.HOUR_OF_DAY,calendar.get(Calendar.HOUR_OF_DAY)-5);
// SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
LambdaQueryWrapper<IdxBizPvHealthIndex> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(IdxBizPvHealthIndex::getAnalysisType,"按小时"); String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00");
wrapper.ne(IdxBizPvHealthIndex::getHealthLevel,"安全");
wrapper.eq(IdxBizPvHealthIndex::getAnalysisObjType,"测点"); LambdaQueryWrapper<PvHealthIndexHour> wrapper = new LambdaQueryWrapper<>();
wrapper.ge(IdxBizPvHealthIndex::getRecDate,df.format(calendar.getTime())); wrapper.ne(PvHealthIndexHour::getHealthLevel,"安全");
wrapper.orderByDesc(IdxBizPvHealthIndex::getRecDate); wrapper.eq(PvHealthIndexHour::getAnalysisObjType,"测点");
List<IdxBizPvHealthIndex> healthIndices = idxBizPvHealthIndexMapper.selectList(wrapper); wrapper.ge(PvHealthIndexHour::getTs,date);
List<String> collect = healthIndices.stream().map(IdxBizPvHealthIndex::getAnalysisObjSeq).collect(Collectors.toList()); wrapper.orderByDesc(PvHealthIndexHour::getTs);
List<PvHealthIndexHour> healthIndices = pvHealthIndexHourMapper.selectList(wrapper);
List<String> collect = healthIndices.stream().map(PvHealthIndexHour::getAnalysisObjSeq).collect(Collectors.toList());
if (null == healthIndices ){ if (null == healthIndices ){
return; return;
} }
...@@ -290,8 +345,9 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -290,8 +345,9 @@ public class HealthStatusIndicatorServiceImpl {
List<IdxBizPvWarningRuleSet> idxBizPvWarningRules = idxBizPvWarningRuleSetMapper.selectList(queryWrapper); List<IdxBizPvWarningRuleSet> idxBizPvWarningRules = idxBizPvWarningRuleSetMapper.selectList(queryWrapper);
Map<String, Map<String, List<IdxBizPvHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizPvHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizPvHealthIndex::getIndexAddress))); Map<String, Map<String, List<PvHealthIndexHour>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(PvHealthIndexHour::getGatewayId, Collectors.groupingBy(PvHealthIndexHour::getIndexAddress)));
List<IdxBizPvWarningRecord> idxBizPvWarningRecordList = new ArrayList<>(); List<IdxBizPvWarningRecord> idxBizPvWarningRecordList = new ArrayList<>();
List<PvWarningRecord> tdPvWarningRecordList = new ArrayList<>();
HashMap<String, StationBasic> stationMap = new HashMap<>(); HashMap<String, StationBasic> stationMap = new HashMap<>();
for (String gateWayId : gateWayMaps.keySet()) { for (String gateWayId : gateWayMaps.keySet()) {
...@@ -301,9 +357,9 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -301,9 +357,9 @@ public class HealthStatusIndicatorServiceImpl {
StationBasic stationBasic = stationBasicMapper.selectOne(basicLambdaQueryWrapper); StationBasic stationBasic = stationBasicMapper.selectOne(basicLambdaQueryWrapper);
stationMap.put(gateWayId, stationBasic); stationMap.put(gateWayId, stationBasic);
Map<String, List<IdxBizPvHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId); Map<String, List<PvHealthIndexHour>> healthDataMaps = gateWayMaps.get(gateWayId);
for (String address : healthDataMaps.keySet()) { for (String address : healthDataMaps.keySet()) {
List<IdxBizPvHealthIndex> idxBizPvHealthIndices = healthDataMaps.get(address); List<PvHealthIndexHour> idxBizPvHealthIndices = healthDataMaps.get(address);
List<IdxBizPvWarningRuleSet> idxBizPvWarningRuleSets = idxBizPvWarningRules.stream().filter(t -> t.getAnalysisPointId().equals(idxBizPvHealthIndices.get(0).getAnalysisObjSeq())).collect(Collectors.toList()); List<IdxBizPvWarningRuleSet> idxBizPvWarningRuleSets = idxBizPvWarningRules.stream().filter(t -> t.getAnalysisPointId().equals(idxBizPvHealthIndices.get(0).getAnalysisObjSeq())).collect(Collectors.toList());
if (ObjectUtils.isEmpty(idxBizPvWarningRuleSets) ){ if (ObjectUtils.isEmpty(idxBizPvWarningRuleSets) ){
continue; continue;
...@@ -338,7 +394,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -338,7 +394,7 @@ public class HealthStatusIndicatorServiceImpl {
} }
List<Double> healthIndex = idxBizPvHealthIndices.stream().map(IdxBizPvHealthIndex::getHealthIndex).collect(Collectors.toList()); List<Double> healthIndex = idxBizPvHealthIndices.stream().map(PvHealthIndexHour::getHealthIndex).collect(Collectors.toList());
Double finalHealthValueRisk = healthValueRisk; Double finalHealthValueRisk = healthValueRisk;
long riskNum = healthIndex.stream().filter(e -> e <= finalHealthValueRisk).count(); long riskNum = healthIndex.stream().filter(e -> e <= finalHealthValueRisk).count();
Double finalHealthValueWarn = healthValueWarn; Double finalHealthValueWarn = healthValueWarn;
...@@ -364,19 +420,18 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -364,19 +420,18 @@ public class HealthStatusIndicatorServiceImpl {
content = healthValueRiskCount + "小时"; content = healthValueRiskCount + "小时";
} }
//库里若已存在该测点预警 不生成重复的 若新生预警等级高于历史 则生成 //库里若已存在该测点预警 不生成重复的 若新生预警等级高于历史 则生成
LambdaQueryWrapper<IdxBizPvWarningRecord> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PvWarningRecord> query = new LambdaQueryWrapper<>();
query.eq(IdxBizPvWarningRecord::getAnalysisPointId,idxBizPvHealthIndices.get(0).getAnalysisObjSeq()); query.eq(PvWarningRecord::getAnalysisPointId,idxBizPvHealthIndices.get(0).getAnalysisObjSeq());
query.eq(IdxBizPvWarningRecord::getStatus,0); query.eq(PvWarningRecord::getStatus,0);
query.orderByDesc(IdxBizPvWarningRecord::getRecDate); query.orderByDesc(PvWarningRecord::getRecDate);
List<IdxBizPvWarningRecord> idxBizPvWarningRecords = idxBizPvWarningRecordMapper.selectList(query); List<PvWarningRecord> idxBizPvWarningRecords = pvWaringRecordMapper.selectList(query);
int flag = ObjectUtils.isEmpty(idxBizPvWarningRecords) || WarningNameEnum.getCode(level) > WarningNameEnum.getCode(idxBizPvWarningRecords.get(0).getWarningName()) ? 0 :1; int flag = ObjectUtils.isEmpty(idxBizPvWarningRecords) || WarningNameEnum.getCode(level) > WarningNameEnum.getCode(idxBizPvWarningRecords.get(0).getWarningName()) ? 0 :1;
if (!level.equals("") && flag == 0){ if (!level.equals("") && flag == 0){
IdxBizPvWarningRecord idxBizPvWarningRecord = new IdxBizPvWarningRecord(); IdxBizPvWarningRecord idxBizPvWarningRecord = new IdxBizPvWarningRecord();
idxBizPvWarningRecord.setKks(idxBizPvHealthIndices.get(0).getKks()); idxBizPvWarningRecord.setKks(idxBizPvHealthIndices.get(0).getKks());
idxBizPvWarningRecord.setRecord(idxBizPvHealthIndices.get(0).getRecord()); idxBizPvWarningRecord.setArae(idxBizPvHealthIndices.get(0).getArea());
idxBizPvWarningRecord.setArae(idxBizPvHealthIndices.get(0).getArae());
idxBizPvWarningRecord.setStation(idxBizPvHealthIndices.get(0).getStation()); idxBizPvWarningRecord.setStation(idxBizPvHealthIndices.get(0).getStation());
idxBizPvWarningRecord.setSubarray(idxBizPvHealthIndices.get(0).getSubarray()); idxBizPvWarningRecord.setSubarray(idxBizPvHealthIndices.get(0).getSubarray());
idxBizPvWarningRecord.setGatewayId(gateWayId); idxBizPvWarningRecord.setGatewayId(gateWayId);
...@@ -395,12 +450,26 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -395,12 +450,26 @@ public class HealthStatusIndicatorServiceImpl {
idxBizPvWarningRecord.setHealthLevel(idxBizPvHealthIndices.get(0).getHealthLevel()); idxBizPvWarningRecord.setHealthLevel(idxBizPvHealthIndices.get(0).getHealthLevel());
idxBizPvWarningRecordList.add(idxBizPvWarningRecord); idxBizPvWarningRecordList.add(idxBizPvWarningRecord);
//idxBizPvWarningRecordMapper.insert(idxBizPvWarningRecord); //idxBizPvWarningRecordMapper.insert(idxBizPvWarningRecord);
long currentTimeMillis = System.currentTimeMillis();
long nanoTime = System.nanoTime();
long timestamp = currentTimeMillis * 1000000 + nanoTime % 1000000;
PvWarningRecord pvWarningRecord = new PvWarningRecord();
BeanUtils.copyProperties(idxBizPvWarningRecord, pvWarningRecord, "disposotionDate", "recDate", "CONTENT");
pvWarningRecord.setContent(idxBizPvWarningRecord.getCONTENT());
pvWarningRecord.setRecDate(format);
pvWarningRecord.setTs(timestamp);
tdPvWarningRecordList.add(pvWarningRecord);
} }
} }
} }
idxBizPvWarningRecordService.saveBatch(idxBizPvWarningRecordList); idxBizPvWarningRecordService.saveBatch(idxBizPvWarningRecordList);
if (CollUtil.isNotEmpty(tdPvWarningRecordList)) {
// tdengine插入
pvWaringRecordMapper.saveBatchWarningRecords(tdPvWarningRecordList);
}
// 触发风险模型生成预警处置模块的预警记录 // 触发风险模型生成预警处置模块的预警记录
fetchDataPv(idxBizPvWarningRecordList, stationMap); fetchDataPv(tdPvWarningRecordList, stationMap);
} }
/*** /***
...@@ -415,29 +484,33 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -415,29 +484,33 @@ public class HealthStatusIndicatorServiceImpl {
if (!openHealth){ if (!openHealth){
return; return;
} }
Calendar calendar = Calendar.getInstance(); // Calendar calendar = Calendar.getInstance();
Date time = new Date(); Date time = new Date();
calendar.set(Calendar.DAY_OF_MONTH,calendar.get(Calendar.DAY_OF_MONTH)-3); //三天 + 8小时
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); Date date = DateUtils.dateAddHours(time, -80);
// calendar.set(Calendar.DAY_OF_MONTH,calendar.get(Calendar.DAY_OF_MONTH)-3);
LambdaQueryWrapper<IdxBizPvHealthIndex> wrapper = new LambdaQueryWrapper<>(); // SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
wrapper.eq(IdxBizPvHealthIndex::getAnalysisType,"按天");
wrapper.ne(IdxBizPvHealthIndex::getHealthLevel,"安全"); String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00");
wrapper.ge(IdxBizPvHealthIndex::getRecDate,df.format(calendar.getTime())); LambdaQueryWrapper<PvHealthIndexDay> wrapper = new LambdaQueryWrapper<>();
wrapper.orderByDesc(IdxBizPvHealthIndex::getRecDate); wrapper.ne(PvHealthIndexDay::getHealthLevel, "安全");
List<IdxBizPvHealthIndex> healthIndices = idxBizPvHealthIndexMapper.selectList(wrapper); wrapper.eq(PvHealthIndexDay::getAnalysisObjType, "测点");
wrapper.ge(PvHealthIndexDay::getRecDate, date);
wrapper.orderByDesc(PvHealthIndexDay::getTs);
List<PvHealthIndexDay> healthIndices = pvHealthIndexDayMapper.selectList(wrapper);
if (null == healthIndices ){ if (null == healthIndices ){
return; return;
} }
List<String> collect = healthIndices.stream().map(IdxBizPvHealthIndex::getAnalysisObjSeq).collect(Collectors.toList()); List<String> collect = healthIndices.stream().map(PvHealthIndexDay::getAnalysisObjSeq).collect(Collectors.toList());
LambdaQueryWrapper<IdxBizPvWarningRuleSet> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizPvWarningRuleSet> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(IdxBizPvWarningRuleSet::getAnalysisType,"按天"); queryWrapper.eq(IdxBizPvWarningRuleSet::getAnalysisType,"按天");
queryWrapper.in(IdxBizPvWarningRuleSet::getAnalysisPointId, collect); queryWrapper.in(IdxBizPvWarningRuleSet::getAnalysisPointId, collect);
List<IdxBizPvWarningRuleSet> idxBizPvWarningRules = idxBizPvWarningRuleSetMapper.selectList(queryWrapper); List<IdxBizPvWarningRuleSet> idxBizPvWarningRules = idxBizPvWarningRuleSetMapper.selectList(queryWrapper);
Map<String, Map<String, List<IdxBizPvHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizPvHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizPvHealthIndex::getIndexAddress))); Map<String, Map<String, List<PvHealthIndexDay>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(PvHealthIndexDay::getGatewayId, Collectors.groupingBy(PvHealthIndexDay::getIndexAddress)));
List<IdxBizPvWarningRecord> idxBizPvWarningRecordList = new ArrayList<>(); List<IdxBizPvWarningRecord> idxBizPvWarningRecordList = new ArrayList<>();
List<PvWarningRecord> tdPvWarningRecordList = new ArrayList<>();
HashMap<String, StationBasic> stationMap = new HashMap<>(); HashMap<String, StationBasic> stationMap = new HashMap<>();
for (String gateWayId : gateWayMaps.keySet()) { for (String gateWayId : gateWayMaps.keySet()) {
...@@ -447,9 +520,9 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -447,9 +520,9 @@ public class HealthStatusIndicatorServiceImpl {
StationBasic stationBasic = stationBasicMapper.selectOne(basicLambdaQueryWrapper); StationBasic stationBasic = stationBasicMapper.selectOne(basicLambdaQueryWrapper);
stationMap.put(gateWayId, stationBasic); stationMap.put(gateWayId, stationBasic);
Map<String, List<IdxBizPvHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId); Map<String, List<PvHealthIndexDay>> healthDataMaps = gateWayMaps.get(gateWayId);
for (String address : healthDataMaps.keySet()) { for (String address : healthDataMaps.keySet()) {
List<IdxBizPvHealthIndex> idxBizPvHealthIndices = healthDataMaps.get(address); List<PvHealthIndexDay> idxBizPvHealthIndices = healthDataMaps.get(address);
List<IdxBizPvWarningRuleSet> idxBizPvWarningRuleSets = idxBizPvWarningRules.stream().filter(t -> t.getAnalysisPointId().equals(idxBizPvHealthIndices.get(0).getAnalysisObjSeq())).collect(Collectors.toList()); List<IdxBizPvWarningRuleSet> idxBizPvWarningRuleSets = idxBizPvWarningRules.stream().filter(t -> t.getAnalysisPointId().equals(idxBizPvHealthIndices.get(0).getAnalysisObjSeq())).collect(Collectors.toList());
if (ObjectUtils.isEmpty(idxBizPvWarningRuleSets) ){ if (ObjectUtils.isEmpty(idxBizPvWarningRuleSets) ){
continue; continue;
...@@ -481,7 +554,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -481,7 +554,7 @@ public class HealthStatusIndicatorServiceImpl {
} }
List<Double> healthIndex = idxBizPvHealthIndices.stream().map(IdxBizPvHealthIndex::getHealthIndex).collect(Collectors.toList()); List<Double> healthIndex = idxBizPvHealthIndices.stream().map(PvHealthIndexDay::getHealthIndex).collect(Collectors.toList());
Double finalHealthValueRisk = healthValueRisk; Double finalHealthValueRisk = healthValueRisk;
long riskNum = healthIndex.stream().filter(e -> e <= finalHealthValueRisk).count(); long riskNum = healthIndex.stream().filter(e -> e <= finalHealthValueRisk).count();
Double finalHealthValueWarn = healthValueWarn; Double finalHealthValueWarn = healthValueWarn;
...@@ -509,19 +582,18 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -509,19 +582,18 @@ public class HealthStatusIndicatorServiceImpl {
content = healthValueRiskCount + "天"; content = healthValueRiskCount + "天";
} }
//库里若已存在该测点预警 不生成重复的 若新生预警等级高于历史 则生成 //库里若已存在该测点预警 不生成重复的 若新生预警等级高于历史 则生成
LambdaQueryWrapper<IdxBizPvWarningRecord> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PvWarningRecord> query = new LambdaQueryWrapper<>();
query.eq(IdxBizPvWarningRecord::getAnalysisPointId,idxBizPvHealthIndices.get(0).getAnalysisObjSeq()); query.eq(PvWarningRecord::getAnalysisPointId,idxBizPvHealthIndices.get(0).getAnalysisObjSeq());
query.eq(IdxBizPvWarningRecord::getStatus,0); query.eq(PvWarningRecord::getStatus,0);
query.orderByDesc(IdxBizPvWarningRecord::getRecDate); query.orderByDesc(PvWarningRecord::getTs);
List<IdxBizPvWarningRecord> idxBizPvWarningRecords = idxBizPvWarningRecordMapper.selectList(query); List<PvWarningRecord> idxBizPvWarningRecords = pvWaringRecordMapper.selectList(query);
int flag = ObjectUtils.isEmpty(idxBizPvWarningRecords) || WarningNameEnum.getCode(level) > WarningNameEnum.getCode(idxBizPvWarningRecords.get(0).getWarningName()) ? 0 :1; int flag = ObjectUtils.isEmpty(idxBizPvWarningRecords) || WarningNameEnum.getCode(level) > WarningNameEnum.getCode(idxBizPvWarningRecords.get(0).getWarningName()) ? 0 :1;
if (!level.equals("") && flag == 0){ if (!level.equals("") && flag == 0){
IdxBizPvWarningRecord idxBizPvWarningRecord = new IdxBizPvWarningRecord(); IdxBizPvWarningRecord idxBizPvWarningRecord = new IdxBizPvWarningRecord();
idxBizPvWarningRecord.setKks(idxBizPvHealthIndices.get(0).getKks()); idxBizPvWarningRecord.setKks(idxBizPvHealthIndices.get(0).getKks());
idxBizPvWarningRecord.setRecord(idxBizPvHealthIndices.get(0).getRecord()); idxBizPvWarningRecord.setArae(idxBizPvHealthIndices.get(0).getArea());
idxBizPvWarningRecord.setArae(idxBizPvHealthIndices.get(0).getArae());
idxBizPvWarningRecord.setStation(idxBizPvHealthIndices.get(0).getStation()); idxBizPvWarningRecord.setStation(idxBizPvHealthIndices.get(0).getStation());
idxBizPvWarningRecord.setSubarray(idxBizPvHealthIndices.get(0).getSubarray()); idxBizPvWarningRecord.setSubarray(idxBizPvHealthIndices.get(0).getSubarray());
idxBizPvWarningRecord.setGatewayId(gateWayId); idxBizPvWarningRecord.setGatewayId(gateWayId);
...@@ -540,12 +612,27 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -540,12 +612,27 @@ public class HealthStatusIndicatorServiceImpl {
idxBizPvWarningRecord.setHealthLevel(idxBizPvHealthIndices.get(0).getHealthLevel()); idxBizPvWarningRecord.setHealthLevel(idxBizPvHealthIndices.get(0).getHealthLevel());
idxBizPvWarningRecordList.add(idxBizPvWarningRecord); idxBizPvWarningRecordList.add(idxBizPvWarningRecord);
//idxBizPvWarningRecordMapper.insert(idxBizPvWarningRecord); //idxBizPvWarningRecordMapper.insert(idxBizPvWarningRecord);
long currentTimeMillis = System.currentTimeMillis();
long nanoTime = System.nanoTime();
long timestamp = currentTimeMillis * 1000000 + nanoTime % 1000000;
PvWarningRecord pvWarningRecord = new PvWarningRecord();
BeanUtils.copyProperties(idxBizPvWarningRecord, pvWarningRecord, "disposotionDate", "recDate", "CONTENT");
pvWarningRecord.setContent(idxBizPvWarningRecord.getCONTENT());
pvWarningRecord.setRecDate(format);
pvWarningRecord.setTs(timestamp);
tdPvWarningRecordList.add(pvWarningRecord);
} }
} }
} }
idxBizPvWarningRecordService.saveBatch(idxBizPvWarningRecordList); idxBizPvWarningRecordService.saveBatch(idxBizPvWarningRecordList);
if (CollUtil.isNotEmpty(tdPvWarningRecordList)) {
// tdengine插入
pvWaringRecordMapper.saveBatchWarningRecords(tdPvWarningRecordList);
}
// 触发风险模型生成预警处置模块的预警记录 // 触发风险模型生成预警处置模块的预警记录
fetchDataPv(idxBizPvWarningRecordList, stationMap); fetchDataPv(tdPvWarningRecordList, stationMap);
} }
...@@ -557,28 +644,31 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -557,28 +644,31 @@ public class HealthStatusIndicatorServiceImpl {
} }
// Calendar calendar = Calendar.getInstance(); // Calendar calendar = Calendar.getInstance();
log.info("风机---------------------预警时间----"+time); log.info("风机---------------------预警时间----"+time);
String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00");
calendar.set(Calendar.HOUR_OF_DAY,calendar.get(Calendar.HOUR_OF_DAY)-1); calendar.set(Calendar.HOUR_OF_DAY,calendar.get(Calendar.HOUR_OF_DAY)-1);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm"); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
// 用ts字段查询时需要减8小时
LambdaQueryWrapper<IdxBizFanHealthIndex> wrapper = new LambdaQueryWrapper<>(); Date date = DateUtils.dateAddHours(time, -8);
wrapper.eq(IdxBizFanHealthIndex::getAnalysisType,"按时刻"); LambdaQueryWrapper<FanHealthIndexMoment> wrapper = new LambdaQueryWrapper<>();
wrapper.ne(IdxBizFanHealthIndex::getHealthLevel,"安全"); wrapper.ne(FanHealthIndexMoment::getHealthLevel,"安全");
wrapper.ge(IdxBizFanHealthIndex::getRecDate,df.format(calendar.getTime())); wrapper.eq(FanHealthIndexMoment::getAnalysisObjType, "测点");
wrapper.orderByDesc(IdxBizFanHealthIndex::getRecDate); wrapper.ge(FanHealthIndexMoment::getTs, date);
List<IdxBizFanHealthIndex> healthIndices = idxBizFanHealthIndexMapper.selectList(wrapper); wrapper.orderByDesc(FanHealthIndexMoment::getTs);
List<FanHealthIndexMoment> healthIndices = fanHealthIndexMomentMapper.selectList(wrapper);
if (ObjectUtils.isEmpty(healthIndices)){ if (ObjectUtils.isEmpty(healthIndices)){
return; return;
} }
List<String> collect = healthIndices.stream().map(IdxBizFanHealthIndex::getAnalysisObjSeq).collect(Collectors.toList()); List<String> collect = healthIndices.stream().map(FanHealthIndexMoment::getAnalysisObjSeq).collect(Collectors.toList());
LambdaQueryWrapper<IdxBizFanWarningRuleSet> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizFanWarningRuleSet> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(IdxBizFanWarningRuleSet::getAnalysisType,"按时刻"); queryWrapper.eq(IdxBizFanWarningRuleSet::getAnalysisType,"按时刻");
queryWrapper.in(IdxBizFanWarningRuleSet::getAnalysisPointId,collect); queryWrapper.in(IdxBizFanWarningRuleSet::getAnalysisPointId,collect);
List<IdxBizFanWarningRuleSet> idxBizPvWarningRules = idxBizFanWarningRuleSetMapper.selectList(queryWrapper); List<IdxBizFanWarningRuleSet> idxBizPvWarningRules = idxBizFanWarningRuleSetMapper.selectList(queryWrapper);
Map<String, Map<String, List<IdxBizFanHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizFanHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizFanHealthIndex::getIndexAddress))); Map<String, Map<String, List<FanHealthIndexMoment>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(FanHealthIndexMoment::getGatewayId, Collectors.groupingBy(FanHealthIndexMoment::getIndexAddress)));
List<IdxBizFanWarningRecord> idxBizFanWarningRecordList = new ArrayList<>(); List<IdxBizFanWarningRecord> idxBizFanWarningRecordList = new ArrayList<>();
List<FanWarningRecord> tdFanWarningRecordList = new ArrayList<>();
HashMap<String, StationBasic> stationMap = new HashMap<>(); HashMap<String, StationBasic> stationMap = new HashMap<>();
for (String gateWayId : gateWayMaps.keySet()) { for (String gateWayId : gateWayMaps.keySet()) {
...@@ -588,9 +678,9 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -588,9 +678,9 @@ public class HealthStatusIndicatorServiceImpl {
basicLambdaQueryWrapper.last("limit 1"); basicLambdaQueryWrapper.last("limit 1");
StationBasic stationBasic = stationBasicMapper.selectOne(basicLambdaQueryWrapper); StationBasic stationBasic = stationBasicMapper.selectOne(basicLambdaQueryWrapper);
stationMap.put(gateWayId, stationBasic); stationMap.put(gateWayId, stationBasic);
Map<String, List<IdxBizFanHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId); Map<String, List<FanHealthIndexMoment>> healthDataMaps = gateWayMaps.get(gateWayId);
for (String address : healthDataMaps.keySet()) { for (String address : healthDataMaps.keySet()) {
List<IdxBizFanHealthIndex> idxBizFanHealthIndices = healthDataMaps.get(address); List<FanHealthIndexMoment> idxBizFanHealthIndices = healthDataMaps.get(address);
List<IdxBizFanWarningRuleSet> idxBizPvWarningRuleSets = idxBizPvWarningRules.stream().filter(t -> t.getAnalysisPointId().equals(idxBizFanHealthIndices.get(0).getAnalysisObjSeq())).collect(Collectors.toList()); List<IdxBizFanWarningRuleSet> idxBizPvWarningRuleSets = idxBizPvWarningRules.stream().filter(t -> t.getAnalysisPointId().equals(idxBizFanHealthIndices.get(0).getAnalysisObjSeq())).collect(Collectors.toList());
...@@ -628,7 +718,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -628,7 +718,7 @@ public class HealthStatusIndicatorServiceImpl {
List<Double> healthIndex = idxBizFanHealthIndices.stream().map(IdxBizFanHealthIndex::getHealthIndex).collect(Collectors.toList()); List<Double> healthIndex = idxBizFanHealthIndices.stream().map(FanHealthIndexMoment::getHealthIndex).collect(Collectors.toList());
Double finalHealthValueRisk = healthValueRisk; Double finalHealthValueRisk = healthValueRisk;
long riskNum = healthIndex.stream().filter(e -> e <= finalHealthValueRisk).count(); long riskNum = healthIndex.stream().filter(e -> e <= finalHealthValueRisk).count();
Double finalHealthValueWarn = healthValueWarn; Double finalHealthValueWarn = healthValueWarn;
...@@ -657,19 +747,18 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -657,19 +747,18 @@ public class HealthStatusIndicatorServiceImpl {
content = healthValueRiskCount*10 + "分钟"; content = healthValueRiskCount*10 + "分钟";
} }
//库里若已存在该测点预警 不生成重复的 若新生预警等级高于历史 则生成 //库里若已存在该测点预警 不生成重复的 若新生预警等级高于历史 则生成
LambdaQueryWrapper<IdxBizFanWarningRecord> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<FanWarningRecord> query = new LambdaQueryWrapper<>();
query.eq(IdxBizFanWarningRecord::getAnalysisPointId,idxBizFanHealthIndices.get(0).getAnalysisObjSeq()); query.eq(FanWarningRecord::getAnalysisPointId,idxBizFanHealthIndices.get(0).getAnalysisObjSeq());
query.eq(IdxBizFanWarningRecord::getStatus,0); query.eq(FanWarningRecord::getStatus,0);
query.orderByDesc(IdxBizFanWarningRecord::getRecDate); query.orderByDesc(FanWarningRecord::getTs);
List<IdxBizFanWarningRecord> idxBizFanWarningRecords = idxBizFanWarningRecordMapper.selectList(query); List<FanWarningRecord> idxBizFanWarningRecords = fanWaringRecordMapper.selectList(query);
int flag = ObjectUtils.isEmpty(idxBizFanWarningRecords) || WarningNameEnum.getCode(level) > WarningNameEnum.getCode(idxBizFanWarningRecords.get(0).getWarningName()) ? 0 :1; int flag = ObjectUtils.isEmpty(idxBizFanWarningRecords) || WarningNameEnum.getCode(level) > WarningNameEnum.getCode(idxBizFanWarningRecords.get(0).getWarningName()) ? 0 :1;
if (!level.equals("") && flag == 0){ if (!level.equals("") && flag == 0){
IdxBizFanWarningRecord idxBizFanWarningRecord = new IdxBizFanWarningRecord(); IdxBizFanWarningRecord idxBizFanWarningRecord = new IdxBizFanWarningRecord();
idxBizFanWarningRecord.setKks(idxBizFanHealthIndices.get(0).getKks()); idxBizFanWarningRecord.setKks(idxBizFanHealthIndices.get(0).getKks());
idxBizFanWarningRecord.setRecord(idxBizFanHealthIndices.get(0).getRecord()); idxBizFanWarningRecord.setArae(idxBizFanHealthIndices.get(0).getArea());
idxBizFanWarningRecord.setArae(idxBizFanHealthIndices.get(0).getArae());
idxBizFanWarningRecord.setStation(idxBizFanHealthIndices.get(0).getStation()); idxBizFanWarningRecord.setStation(idxBizFanHealthIndices.get(0).getStation());
idxBizFanWarningRecord.setSubSystem(idxBizFanHealthIndices.get(0).getSubSystem()); idxBizFanWarningRecord.setSubSystem(idxBizFanHealthIndices.get(0).getSubSystem());
idxBizFanWarningRecord.setGatewayId(gateWayId); idxBizFanWarningRecord.setGatewayId(gateWayId);
...@@ -688,12 +777,33 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -688,12 +777,33 @@ public class HealthStatusIndicatorServiceImpl {
idxBizFanWarningRecord.setHealthLevel(idxBizFanHealthIndices.get(0).getHealthLevel()); idxBizFanWarningRecord.setHealthLevel(idxBizFanHealthIndices.get(0).getHealthLevel());
idxBizFanWarningRecordList.add(idxBizFanWarningRecord); idxBizFanWarningRecordList.add(idxBizFanWarningRecord);
//idxBizFanWarningRecordMapper.insert(idxBizFanWarningRecord); //idxBizFanWarningRecordMapper.insert(idxBizFanWarningRecord);
long currentTimeMillis = System.currentTimeMillis();
long nanoTime = System.nanoTime();
long timestamp = currentTimeMillis * 1000000 + nanoTime % 1000000;
FanWarningRecord fanWarningRecord = new FanWarningRecord();
BeanUtils.copyProperties(idxBizFanWarningRecord, fanWarningRecord, "disposotionDate", "recDate", "CONTENT");
fanWarningRecord.setContent(idxBizFanWarningRecord.getCONTENT());
fanWarningRecord.setRecDate(format);
fanWarningRecord.setTs(timestamp);
fanWarningRecord.setHealthIndex(idxBizFanHealthIndices.get(0).getHealthIndex().toString());
tdFanWarningRecordList.add(fanWarningRecord);
} }
} }
} }
idxBizFanWarningRecordService.saveBatch(idxBizFanWarningRecordList); idxBizFanWarningRecordService.saveBatch(idxBizFanWarningRecordList);
// tdengine插入
// fanWarningRecordService.saveBatch(tdFanWarningRecordList);
if (CollUtil.isNotEmpty(tdFanWarningRecordList)) {
fanWaringRecordMapper.saveBatchWarningRecords(tdFanWarningRecordList);
}
// 触发风险模型生成预警处置模块的预警记录 // 触发风险模型生成预警处置模块的预警记录
fetchDataFan(idxBizFanWarningRecordList, stationMap); fetchDataFan(tdFanWarningRecordList, stationMap);
} }
/*** /***
...@@ -709,29 +819,31 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -709,29 +819,31 @@ public class HealthStatusIndicatorServiceImpl {
return; return;
} }
Date time = new Date(); Date time = new Date();
Calendar calendar = Calendar.getInstance(); String format = DateUtil.format(time, "yyyy-MM-dd HH:00:00");
calendar.set(Calendar.HOUR_OF_DAY,calendar.get(Calendar.HOUR_OF_DAY)-5); Date date = DateUtils.dateAddHours(time, -13);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm"); // Calendar calendar = Calendar.getInstance();
// calendar.set(Calendar.HOUR_OF_DAY,calendar.get(Calendar.HOUR_OF_DAY)-5);
LambdaQueryWrapper<IdxBizFanHealthIndex> wrapper = new LambdaQueryWrapper<>(); // SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
wrapper.eq(IdxBizFanHealthIndex::getAnalysisType,"按小时");
wrapper.eq(IdxBizFanHealthIndex::getAnalysisObjType,"测点"); LambdaQueryWrapper<FanHealthIndexHour> wrapper = new LambdaQueryWrapper<>();
wrapper.ne(IdxBizFanHealthIndex::getHealthLevel,"安全"); wrapper.eq(FanHealthIndexHour::getAnalysisObjType, "测点");
wrapper.ge(IdxBizFanHealthIndex::getRecDate,df.format(calendar.getTime())); wrapper.ne(FanHealthIndexHour::getHealthLevel, "安全");
wrapper.orderByDesc(IdxBizFanHealthIndex::getRecDate); wrapper.ge(FanHealthIndexHour::getTs, date);
List<IdxBizFanHealthIndex> healthIndices = idxBizFanHealthIndexMapper.selectList(wrapper); wrapper.orderByDesc(FanHealthIndexHour::getTs);
List<FanHealthIndexHour> healthIndices = fanHealthIndexHourMapper.selectList(wrapper);
if (ObjectUtils.isEmpty(healthIndices)){ if (ObjectUtils.isEmpty(healthIndices)){
return; return;
} }
List<String> collect = healthIndices.stream().map(IdxBizFanHealthIndex::getAnalysisObjSeq).collect(Collectors.toList()); List<String> collect = healthIndices.stream().map(FanHealthIndexHour::getAnalysisObjSeq).collect(Collectors.toList());
LambdaQueryWrapper<IdxBizFanWarningRuleSet> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizFanWarningRuleSet> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(IdxBizFanWarningRuleSet::getAnalysisType,"按小时"); queryWrapper.eq(IdxBizFanWarningRuleSet::getAnalysisType,"按小时");
queryWrapper.in(IdxBizFanWarningRuleSet::getAnalysisPointId,collect); queryWrapper.in(IdxBizFanWarningRuleSet::getAnalysisPointId,collect);
List<IdxBizFanWarningRuleSet> idxBizPvWarningRules = idxBizFanWarningRuleSetMapper.selectList(queryWrapper); List<IdxBizFanWarningRuleSet> idxBizPvWarningRules = idxBizFanWarningRuleSetMapper.selectList(queryWrapper);
Map<String, Map<String, List<IdxBizFanHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizFanHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizFanHealthIndex::getIndexAddress))); Map<String, Map<String, List<FanHealthIndexHour>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(FanHealthIndexHour::getGatewayId, Collectors.groupingBy(FanHealthIndexHour::getIndexAddress)));
List<IdxBizFanWarningRecord> idxBizFanWarningRecordList = new ArrayList<>(); List<IdxBizFanWarningRecord> idxBizFanWarningRecordList = new ArrayList<>();
List<FanWarningRecord> tdFanWarningRecordList = new ArrayList<>();
HashMap<String, StationBasic> stationMap = new HashMap<>(); HashMap<String, StationBasic> stationMap = new HashMap<>();
for (String gateWayId : gateWayMaps.keySet()) { for (String gateWayId : gateWayMaps.keySet()) {
...@@ -741,9 +853,9 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -741,9 +853,9 @@ public class HealthStatusIndicatorServiceImpl {
StationBasic stationBasic = stationBasicMapper.selectOne(basicLambdaQueryWrapper); StationBasic stationBasic = stationBasicMapper.selectOne(basicLambdaQueryWrapper);
stationMap.put(gateWayId, stationBasic); stationMap.put(gateWayId, stationBasic);
Map<String, List<IdxBizFanHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId); Map<String, List<FanHealthIndexHour>> healthDataMaps = gateWayMaps.get(gateWayId);
for (String address : healthDataMaps.keySet()) { for (String address : healthDataMaps.keySet()) {
List<IdxBizFanHealthIndex> idxBizFanHealthIndices = healthDataMaps.get(address); List<FanHealthIndexHour> idxBizFanHealthIndices = healthDataMaps.get(address);
List<IdxBizFanWarningRuleSet> idxBizPvWarningRuleSets = idxBizPvWarningRules.stream().filter(t -> t.getAnalysisPointId().equals(idxBizFanHealthIndices.get(0).getAnalysisObjSeq())).collect(Collectors.toList()); List<IdxBizFanWarningRuleSet> idxBizPvWarningRuleSets = idxBizPvWarningRules.stream().filter(t -> t.getAnalysisPointId().equals(idxBizFanHealthIndices.get(0).getAnalysisObjSeq())).collect(Collectors.toList());
...@@ -779,7 +891,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -779,7 +891,7 @@ public class HealthStatusIndicatorServiceImpl {
List<Double> healthIndex = idxBizFanHealthIndices.stream().map(IdxBizFanHealthIndex::getHealthIndex).collect(Collectors.toList()); List<Double> healthIndex = idxBizFanHealthIndices.stream().map(FanHealthIndexHour::getHealthIndex).collect(Collectors.toList());
Double finalHealthValueRisk = healthValueRisk; Double finalHealthValueRisk = healthValueRisk;
long riskNum = healthIndex.stream().filter(e -> e <= finalHealthValueRisk).count(); long riskNum = healthIndex.stream().filter(e -> e <= finalHealthValueRisk).count();
Double finalHealthValueWarn = healthValueWarn; Double finalHealthValueWarn = healthValueWarn;
...@@ -803,19 +915,18 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -803,19 +915,18 @@ public class HealthStatusIndicatorServiceImpl {
num = ""+healthValueRisk; num = ""+healthValueRisk;
content = healthValueRiskCount + "小时"; content = healthValueRiskCount + "小时";
} }
LambdaQueryWrapper<IdxBizFanWarningRecord> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<FanWarningRecord> query = new LambdaQueryWrapper<>();
query.eq(IdxBizFanWarningRecord::getAnalysisPointId,idxBizFanHealthIndices.get(0).getAnalysisObjSeq()); query.eq(FanWarningRecord::getAnalysisPointId,idxBizFanHealthIndices.get(0).getAnalysisObjSeq());
query.eq(IdxBizFanWarningRecord::getStatus,0); query.eq(FanWarningRecord::getStatus,0);
query.orderByDesc(IdxBizFanWarningRecord::getRecDate); query.orderByDesc(FanWarningRecord::getTs);
List<IdxBizFanWarningRecord> idxBizFanWarningRecords = idxBizFanWarningRecordMapper.selectList(query); List<FanWarningRecord> idxBizFanWarningRecords = fanWaringRecordMapper.selectList(query);
int flag = ObjectUtils.isEmpty(idxBizFanWarningRecords) || WarningNameEnum.getCode(level) > WarningNameEnum.getCode(idxBizFanWarningRecords.get(0).getWarningName()) ? 0 :1; int flag = ObjectUtils.isEmpty(idxBizFanWarningRecords) || WarningNameEnum.getCode(level) > WarningNameEnum.getCode(idxBizFanWarningRecords.get(0).getWarningName()) ? 0 :1;
if (!level.equals("") && flag == 0){ if (!level.equals("") && flag == 0){
IdxBizFanWarningRecord idxBizFanWarningRecord = new IdxBizFanWarningRecord(); IdxBizFanWarningRecord idxBizFanWarningRecord = new IdxBizFanWarningRecord();
idxBizFanWarningRecord.setKks(idxBizFanHealthIndices.get(0).getKks()); idxBizFanWarningRecord.setKks(idxBizFanHealthIndices.get(0).getKks());
idxBizFanWarningRecord.setRecord(idxBizFanHealthIndices.get(0).getRecord()); idxBizFanWarningRecord.setArae(idxBizFanHealthIndices.get(0).getArea());
idxBizFanWarningRecord.setArae(idxBizFanHealthIndices.get(0).getArae());
idxBizFanWarningRecord.setStation(idxBizFanHealthIndices.get(0).getStation()); idxBizFanWarningRecord.setStation(idxBizFanHealthIndices.get(0).getStation());
idxBizFanWarningRecord.setSubSystem(idxBizFanHealthIndices.get(0).getSubSystem()); idxBizFanWarningRecord.setSubSystem(idxBizFanHealthIndices.get(0).getSubSystem());
idxBizFanWarningRecord.setGatewayId(gateWayId); idxBizFanWarningRecord.setGatewayId(gateWayId);
...@@ -833,12 +944,27 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -833,12 +944,27 @@ public class HealthStatusIndicatorServiceImpl {
idxBizFanWarningRecord.setHealthLevel(idxBizFanHealthIndices.get(0).getHealthLevel()); idxBizFanWarningRecord.setHealthLevel(idxBizFanHealthIndices.get(0).getHealthLevel());
idxBizFanWarningRecord.setPointName(idxBizFanHealthIndices.get(0).getPointName()); idxBizFanWarningRecord.setPointName(idxBizFanHealthIndices.get(0).getPointName());
idxBizFanWarningRecordList.add(idxBizFanWarningRecord); idxBizFanWarningRecordList.add(idxBizFanWarningRecord);
long currentTimeMillis = System.currentTimeMillis();
long nanoTime = System.nanoTime();
long timestamp = currentTimeMillis * 1000000 + nanoTime % 1000000;
FanWarningRecord fanWarningRecord = new FanWarningRecord();
BeanUtils.copyProperties(idxBizFanWarningRecord, fanWarningRecord, "disposotionDate", "recDate", "CONTENT");
fanWarningRecord.setContent(idxBizFanWarningRecord.getCONTENT());
fanWarningRecord.setRecDate(format);
fanWarningRecord.setTs(timestamp);
fanWarningRecord.setHealthIndex(idxBizFanHealthIndices.get(0).getHealthIndex().toString());
tdFanWarningRecordList.add(fanWarningRecord);
} }
} }
} }
idxBizFanWarningRecordService.saveBatch(idxBizFanWarningRecordList); idxBizFanWarningRecordService.saveBatch(idxBizFanWarningRecordList);
// tdengine插入
fanWaringRecordMapper.saveBatchWarningRecords(tdFanWarningRecordList);
// 触发风险模型生成预警处置模块的预警记录 // 触发风险模型生成预警处置模块的预警记录
fetchDataFan(idxBizFanWarningRecordList, stationMap); fetchDataFan(tdFanWarningRecordList, stationMap);
} }
/*** /***
...@@ -854,28 +980,32 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -854,28 +980,32 @@ public class HealthStatusIndicatorServiceImpl {
return; return;
} }
Date time = new Date(); Date time = new Date();
Calendar calendar = Calendar.getInstance(); String format = DateUtil.format(time, "yyyy-MM-dd 00:00:00");
calendar.set(Calendar.DAY_OF_MONTH,calendar.get(Calendar.DAY_OF_MONTH)-3); //三天 + 8小时
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); Date date = DateUtils.dateAddHours(time, -80);
// Calendar calendar = Calendar.getInstance();
LambdaQueryWrapper<IdxBizFanHealthIndex> wrapper = new LambdaQueryWrapper<>(); // calendar.set(Calendar.DAY_OF_MONTH,calendar.get(Calendar.DAY_OF_MONTH)-3);
wrapper.eq(IdxBizFanHealthIndex::getAnalysisType,"按天"); // SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
wrapper.ne(IdxBizFanHealthIndex::getHealthLevel,"安全");
wrapper.ge(IdxBizFanHealthIndex::getRecDate,df.format(calendar.getTime())); LambdaQueryWrapper<FanHealthIndexDay> wrapper = new LambdaQueryWrapper<>();
wrapper.orderByDesc(IdxBizFanHealthIndex::getRecDate); wrapper.ne(FanHealthIndexDay::getHealthLevel,"安全");
List<IdxBizFanHealthIndex> healthIndices = idxBizFanHealthIndexMapper.selectList(wrapper); wrapper.ge(FanHealthIndexDay::getRecDate,date);
wrapper.eq(FanHealthIndexDay::getAnalysisObjType, "测点");
wrapper.orderByDesc(FanHealthIndexDay::getTs);
List<FanHealthIndexDay> healthIndices = fanHealthIndexDayMapper.selectList(wrapper);
if (ObjectUtils.isEmpty(healthIndices)){ if (ObjectUtils.isEmpty(healthIndices)){
return; return;
} }
List<String> collect = healthIndices.stream().map(IdxBizFanHealthIndex::getAnalysisObjSeq).collect(Collectors.toList()); List<String> collect = healthIndices.stream().map(FanHealthIndexDay::getAnalysisObjSeq).collect(Collectors.toList());
LambdaQueryWrapper<IdxBizFanWarningRuleSet> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizFanWarningRuleSet> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(IdxBizFanWarningRuleSet::getAnalysisType,"按天"); queryWrapper.eq(IdxBizFanWarningRuleSet::getAnalysisType,"按天");
queryWrapper.in(IdxBizFanWarningRuleSet::getAnalysisPointId,collect); queryWrapper.in(IdxBizFanWarningRuleSet::getAnalysisPointId,collect);
List<IdxBizFanWarningRuleSet> idxBizPvWarningRules = idxBizFanWarningRuleSetMapper.selectList(queryWrapper); List<IdxBizFanWarningRuleSet> idxBizPvWarningRules = idxBizFanWarningRuleSetMapper.selectList(queryWrapper);
Map<String, Map<String, List<IdxBizFanHealthIndex>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(IdxBizFanHealthIndex::getGatewayId, Collectors.groupingBy(IdxBizFanHealthIndex::getIndexAddress))); Map<String, Map<String, List<FanHealthIndexDay>>> gateWayMaps = healthIndices.stream().collect(Collectors.groupingBy(FanHealthIndexDay::getGatewayId, Collectors.groupingBy(FanHealthIndexDay::getIndexAddress)));
List<IdxBizFanWarningRecord> idxBizFanWarningRecordList = new ArrayList<>(); List<IdxBizFanWarningRecord> idxBizFanWarningRecordList = new ArrayList<>();
List<FanWarningRecord> tdFanWarningRecordList = new ArrayList<>();
HashMap<String, StationBasic> stationMap = new HashMap<>(); HashMap<String, StationBasic> stationMap = new HashMap<>();
for (String gateWayId : gateWayMaps.keySet()) { for (String gateWayId : gateWayMaps.keySet()) {
...@@ -885,9 +1015,9 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -885,9 +1015,9 @@ public class HealthStatusIndicatorServiceImpl {
StationBasic stationBasic = stationBasicMapper.selectOne(basicLambdaQueryWrapper); StationBasic stationBasic = stationBasicMapper.selectOne(basicLambdaQueryWrapper);
stationMap.put(gateWayId, stationBasic); stationMap.put(gateWayId, stationBasic);
Map<String, List<IdxBizFanHealthIndex>> healthDataMaps = gateWayMaps.get(gateWayId); Map<String, List<FanHealthIndexDay>> healthDataMaps = gateWayMaps.get(gateWayId);
for (String address : healthDataMaps.keySet()) { for (String address : healthDataMaps.keySet()) {
List<IdxBizFanHealthIndex> idxBizFanHealthIndices = healthDataMaps.get(address); List<FanHealthIndexDay> idxBizFanHealthIndices = healthDataMaps.get(address);
List<IdxBizFanWarningRuleSet> idxBizPvWarningRuleSets = idxBizPvWarningRules.stream().filter(t -> t.getAnalysisPointId().equals(idxBizFanHealthIndices.get(0).getAnalysisObjSeq())).collect(Collectors.toList()); List<IdxBizFanWarningRuleSet> idxBizPvWarningRuleSets = idxBizPvWarningRules.stream().filter(t -> t.getAnalysisPointId().equals(idxBizFanHealthIndices.get(0).getAnalysisObjSeq())).collect(Collectors.toList());
...@@ -924,7 +1054,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -924,7 +1054,7 @@ public class HealthStatusIndicatorServiceImpl {
List<Double> healthIndex = idxBizFanHealthIndices.stream().map(IdxBizFanHealthIndex::getHealthIndex).collect(Collectors.toList()); List<Double> healthIndex = idxBizFanHealthIndices.stream().map(FanHealthIndexDay::getHealthIndex).collect(Collectors.toList());
Double finalHealthValueRisk = healthValueRisk; Double finalHealthValueRisk = healthValueRisk;
long riskNum = healthIndex.stream().filter(e -> e <= finalHealthValueRisk).count(); long riskNum = healthIndex.stream().filter(e -> e <= finalHealthValueRisk).count();
Double finalHealthValueWarn = healthValueWarn; Double finalHealthValueWarn = healthValueWarn;
...@@ -952,18 +1082,17 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -952,18 +1082,17 @@ public class HealthStatusIndicatorServiceImpl {
content = healthValueRiskCount + "天"; content = healthValueRiskCount + "天";
} }
LambdaQueryWrapper<IdxBizFanWarningRecord> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<FanWarningRecord> query = new LambdaQueryWrapper<>();
query.eq(IdxBizFanWarningRecord::getAnalysisPointId,idxBizFanHealthIndices.get(0).getAnalysisObjSeq()); query.eq(FanWarningRecord::getAnalysisPointId,idxBizFanHealthIndices.get(0).getAnalysisObjSeq());
query.eq(IdxBizFanWarningRecord::getStatus,0); query.eq(FanWarningRecord::getStatus,0);
query.orderByDesc(IdxBizFanWarningRecord::getRecDate); query.orderByDesc(FanWarningRecord::getTs);
List<IdxBizFanWarningRecord> idxBizFanWarningRecords = idxBizFanWarningRecordMapper.selectList(query); List<FanWarningRecord> idxBizFanWarningRecords = fanWaringRecordMapper.selectList(query);
int flag = ObjectUtils.isEmpty(idxBizFanWarningRecords) || WarningNameEnum.getCode(level) > WarningNameEnum.getCode(idxBizFanWarningRecords.get(0).getWarningName()) ? 0 :1; int flag = ObjectUtils.isEmpty(idxBizFanWarningRecords) || WarningNameEnum.getCode(level) > WarningNameEnum.getCode(idxBizFanWarningRecords.get(0).getWarningName()) ? 0 :1;
if (!level.equals("") && flag == 0){ if (!level.equals("") && flag == 0) {
IdxBizFanWarningRecord idxBizFanWarningRecord = new IdxBizFanWarningRecord(); IdxBizFanWarningRecord idxBizFanWarningRecord = new IdxBizFanWarningRecord();
idxBizFanWarningRecord.setKks(idxBizFanHealthIndices.get(0).getKks()); idxBizFanWarningRecord.setKks(idxBizFanHealthIndices.get(0).getKks());
idxBizFanWarningRecord.setRecord(idxBizFanHealthIndices.get(0).getRecord()); idxBizFanWarningRecord.setArae(idxBizFanHealthIndices.get(0).getArea());
idxBizFanWarningRecord.setArae(idxBizFanHealthIndices.get(0).getArae());
idxBizFanWarningRecord.setStation(idxBizFanHealthIndices.get(0).getStation()); idxBizFanWarningRecord.setStation(idxBizFanHealthIndices.get(0).getStation());
idxBizFanWarningRecord.setSubSystem(idxBizFanHealthIndices.get(0).getSubSystem()); idxBizFanWarningRecord.setSubSystem(idxBizFanHealthIndices.get(0).getSubSystem());
idxBizFanWarningRecord.setGatewayId(gateWayId); idxBizFanWarningRecord.setGatewayId(gateWayId);
...@@ -981,13 +1110,27 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -981,13 +1110,27 @@ public class HealthStatusIndicatorServiceImpl {
idxBizFanWarningRecord.setHealthLevel(idxBizFanHealthIndices.get(0).getHealthLevel()); idxBizFanWarningRecord.setHealthLevel(idxBizFanHealthIndices.get(0).getHealthLevel());
idxBizFanWarningRecord.setPointName(idxBizFanHealthIndices.get(0).getPointName()); idxBizFanWarningRecord.setPointName(idxBizFanHealthIndices.get(0).getPointName());
idxBizFanWarningRecordList.add(idxBizFanWarningRecord); idxBizFanWarningRecordList.add(idxBizFanWarningRecord);
long currentTimeMillis = System.currentTimeMillis();
long nanoTime = System.nanoTime();
long timestamp = currentTimeMillis * 1000000 + nanoTime % 1000000;
FanWarningRecord fanWarningRecord = new FanWarningRecord();
BeanUtils.copyProperties(idxBizFanWarningRecord, fanWarningRecord, "disposotionDate", "recDate", "CONTENT");
fanWarningRecord.setContent(idxBizFanWarningRecord.getCONTENT());
fanWarningRecord.setRecDate(format);
fanWarningRecord.setTs(timestamp);
tdFanWarningRecordList.add(fanWarningRecord);
} }
} }
} }
idxBizFanWarningRecordService.saveBatch(idxBizFanWarningRecordList); idxBizFanWarningRecordService.saveBatch(idxBizFanWarningRecordList);
// tdengine插入
fanWaringRecordMapper.saveBatchWarningRecords(tdFanWarningRecordList);
// 触发风险模型生成预警处置模块的预警记录 // 触发风险模型生成预警处置模块的预警记录
fetchDataFan(idxBizFanWarningRecordList, stationMap); fetchDataFan(tdFanWarningRecordList, stationMap);
} }
...@@ -997,7 +1140,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -997,7 +1140,7 @@ public class HealthStatusIndicatorServiceImpl {
* @return * @return
*/ */
@Async @Async
public void fetchDataPv(List<IdxBizPvWarningRecord> idxBizPvWarningRecords, HashMap<String, StationBasic> stationMap) { public void fetchDataPv(List<PvWarningRecord> idxBizPvWarningRecords, HashMap<String, StationBasic> stationMap) {
log.info("===开始触发风险预警模型===数量为:{}", idxBizPvWarningRecords.size()); log.info("===开始触发风险预警模型===数量为:{}", idxBizPvWarningRecords.size());
idxBizPvWarningRecords.stream().forEach(idxBizPvWarningRecord -> { idxBizPvWarningRecords.stream().forEach(idxBizPvWarningRecord -> {
BizMessage bizMessage = new BizMessage(); BizMessage bizMessage = new BizMessage();
...@@ -1017,7 +1160,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -1017,7 +1160,7 @@ public class HealthStatusIndicatorServiceImpl {
detailsVos.add(dynamicDetailsVo); detailsVos.add(dynamicDetailsVo);
riskBizInfoVo.setDynamicDetails(detailsVos); riskBizInfoVo.setDynamicDetails(detailsVos);
bizMessage.setBizInfo(riskBizInfoVo); bizMessage.setBizInfo(riskBizInfoVo);
bizMessage.setTraceId2(idxBizPvWarningRecord.getSequenceNbr()); bizMessage.setTraceId2(idxBizPvWarningRecord.getTs().toString());
try { try {
emqKeeper.getMqttClient().publish(SMART_ANALYSE_PV + "/data/analysis", JSON.toJSONString(bizMessage).getBytes(StandardCharsets.UTF_8), 2, false); emqKeeper.getMqttClient().publish(SMART_ANALYSE_PV + "/data/analysis", JSON.toJSONString(bizMessage).getBytes(StandardCharsets.UTF_8), 2, false);
} catch (MqttException e) { } catch (MqttException e) {
...@@ -1033,7 +1176,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -1033,7 +1176,7 @@ public class HealthStatusIndicatorServiceImpl {
* @return * @return
*/ */
@Async @Async
public void fetchDataFan(List<IdxBizFanWarningRecord> idxBizFanWarningRecords, HashMap<String, StationBasic> stationMap) { public void fetchDataFan(List<FanWarningRecord> idxBizFanWarningRecords, HashMap<String, StationBasic> stationMap) {
log.info("===开始触发风险预警模型===数量为:{}", idxBizFanWarningRecords.size()); log.info("===开始触发风险预警模型===数量为:{}", idxBizFanWarningRecords.size());
idxBizFanWarningRecords.stream().forEach(idxBizFanWarningRecord -> { idxBizFanWarningRecords.stream().forEach(idxBizFanWarningRecord -> {
BizMessage bizMessage = new BizMessage(); BizMessage bizMessage = new BizMessage();
...@@ -1053,7 +1196,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -1053,7 +1196,7 @@ public class HealthStatusIndicatorServiceImpl {
detailsVos.add(dynamicDetailsVo); detailsVos.add(dynamicDetailsVo);
riskBizInfoVo.setDynamicDetails(detailsVos); riskBizInfoVo.setDynamicDetails(detailsVos);
bizMessage.setBizInfo(riskBizInfoVo); bizMessage.setBizInfo(riskBizInfoVo);
bizMessage.setTraceId2(idxBizFanWarningRecord.getSequenceNbr()); bizMessage.setTraceId2(idxBizFanWarningRecord.getTs().toString());
try { try {
emqKeeper.getMqttClient().publish(SMART_ANALYSE_FAN + "/data/analysis", JSON.toJSONString(bizMessage).getBytes(StandardCharsets.UTF_8), 2, false); emqKeeper.getMqttClient().publish(SMART_ANALYSE_FAN + "/data/analysis", JSON.toJSONString(bizMessage).getBytes(StandardCharsets.UTF_8), 2, false);
} catch (MqttException e) { } catch (MqttException e) {
......
...@@ -203,8 +203,8 @@ public class IdxBizFanHealthIndexServiceImpl extends BaseService<IdxBizFanHealth ...@@ -203,8 +203,8 @@ public class IdxBizFanHealthIndexServiceImpl extends BaseService<IdxBizFanHealth
return this.getBaseMapper().queryForLeftTableListByPointNum(STATION,HEALTHLEVEL,EQUIPMENTNAME,POINTNAME); return this.getBaseMapper().queryForLeftTableListByPointNum(STATION,HEALTHLEVEL,EQUIPMENTNAME,POINTNAME);
} }
public int pointNum(String STATION, String SUBARRAY,String EQUIPMENTNAME) { public int pointNum(String STATION, String SUBSYSTEM,String EQUIPMENTNAME) {
return this.getBaseMapper().pointNum(STATION, SUBARRAY,EQUIPMENTNAME); return this.getBaseMapper().pointNum(STATION, SUBSYSTEM,EQUIPMENTNAME);
} }
public List<IdxBizFanWarningRecord> warningData(String STATION, String SUBARRAY , String EQUIPMENTNAME) { public List<IdxBizFanWarningRecord> warningData(String STATION, String SUBARRAY , String EQUIPMENTNAME) {
......
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvWaringRecordMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvWarningRecord;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService;
@Service
public class PvWarningRecordServiceImpl extends BaseService<PvWarningRecord, PvWarningRecord, PvWaringRecordMapper> {
}
...@@ -6,6 +6,7 @@ import com.yeejoin.amos.boot.biz.common.utils.DateUtils; ...@@ -6,6 +6,7 @@ import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthLevel; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthLevel;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvHealthLevel; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvHealthLevel;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanHealthLevelMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanHealthLevelMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvHealthLevelMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvHealthLevelMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanHealthIndexMapper; import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvHealthIndexMapper; import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvHealthIndexMapper;
...@@ -13,6 +14,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex; ...@@ -13,6 +14,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex; import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
...@@ -33,6 +35,10 @@ public class TdengineTimeServiceImpl { ...@@ -33,6 +35,10 @@ public class TdengineTimeServiceImpl {
private FanHealthIndexMapper fanHealthIndexMapper; private FanHealthIndexMapper fanHealthIndexMapper;
@Autowired @Autowired
private IdxBizPvHealthIndexMapper idxFanHealthIndexMapper;
@Autowired
private PvHealthIndexMapper pvHealthIndexMapper; private PvHealthIndexMapper pvHealthIndexMapper;
@Autowired @Autowired
...@@ -41,7 +47,8 @@ public class TdengineTimeServiceImpl { ...@@ -41,7 +47,8 @@ public class TdengineTimeServiceImpl {
@Autowired @Autowired
private IdxBizPvHealthLevelMapper idxBizPvHealthLevelMapper; private IdxBizPvHealthLevelMapper idxBizPvHealthLevelMapper;
@Value("${openHealth:true}")
Boolean openHealth;
/** /**
* 风电 - 按时刻生成子系统、设备、场站、区域 数据 * 风电 - 按时刻生成子系统、设备、场站、区域 数据
...@@ -73,6 +80,10 @@ public class TdengineTimeServiceImpl { ...@@ -73,6 +80,10 @@ public class TdengineTimeServiceImpl {
*/ */
@Scheduled(cron = "0 0 0/1 * * ? ") @Scheduled(cron = "0 0 0/1 * * ? ")
public void insertHourData() throws ParseException { public void insertHourData() throws ParseException {
if (!openHealth) {
return;
}
idxFanHealthIndexMapper.deleteAllDataByTableName("fan_health_index_latest_data", "按小时");
String recDate = DateUtil.format(new Date(), "yyyy-MM-dd HH:00:00"); String recDate = DateUtil.format(new Date(), "yyyy-MM-dd HH:00:00");
// 8小时 + 59分钟 // 8小时 + 59分钟
String startTime = DateUtils.dateFormat(DateUtils.dateAddMinutes(new Date(), -541), DateUtils.DATE_TIME_PATTERN); String startTime = DateUtils.dateFormat(DateUtils.dateAddMinutes(new Date(), -541), DateUtils.DATE_TIME_PATTERN);
...@@ -103,6 +114,10 @@ public class TdengineTimeServiceImpl { ...@@ -103,6 +114,10 @@ public class TdengineTimeServiceImpl {
*/ */
@Scheduled(cron = "0 0 0 1/1 * ? ") @Scheduled(cron = "0 0 0 1/1 * ? ")
public void insertDayData() throws ParseException { public void insertDayData() throws ParseException {
if (!openHealth) {
return;
}
idxFanHealthIndexMapper.deleteAllDataByTableName("fan_health_index_latest_data", "按天");
String recDate = DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00"); String recDate = DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00");
String startTime = DateUtils.dateFormat(DateUtils.dateAddHours(new Date(), -32), DateUtils.DATE_TIME_PATTERN); String startTime = DateUtils.dateFormat(DateUtils.dateAddHours(new Date(), -32), DateUtils.DATE_TIME_PATTERN);
List<IdxBizFanHealthLevel> levelList = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "测点").last("limit 4")); List<IdxBizFanHealthLevel> levelList = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "测点").last("limit 4"));
...@@ -155,7 +170,8 @@ public class TdengineTimeServiceImpl { ...@@ -155,7 +170,8 @@ public class TdengineTimeServiceImpl {
newList.add(fanHealthIndex);//循环将数据填入载体list newList.add(fanHealthIndex);//循环将数据填入载体list
if (500 == newList.size() || i == fanHealthIndices.size() - 1) { //载体list达到要求,进行批量操作 if (500 == newList.size() || i == fanHealthIndices.size() - 1) { //载体list达到要求,进行批量操作
//调用批量插入 //调用批量插入
fanHealthIndexMapper.saveBatchHealthIndexList(newList, tableName); fanHealthIndexMapper.saveBatchHealthIndexList(newList, tableName, analysisType);
idxFanHealthIndexMapper.saveBatchHealthIndexLatestInfo(newList);
newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入 newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入
} }
} }
...@@ -189,6 +205,10 @@ public class TdengineTimeServiceImpl { ...@@ -189,6 +205,10 @@ public class TdengineTimeServiceImpl {
*/ */
@Scheduled(cron = "0 0 0/1 * * ? ") @Scheduled(cron = "0 0 0/1 * * ? ")
public void insertHourDataPv() throws ParseException { public void insertHourDataPv() throws ParseException {
if (!openHealth) {
return;
}
idxFanHealthIndexMapper.deleteAllDataByTableName("pv_health_index_latest_data", "按小时");
String recDate = DateUtil.format(new Date(), "yyyy-MM-dd HH:00:00"); String recDate = DateUtil.format(new Date(), "yyyy-MM-dd HH:00:00");
// 8小时 + 59分钟 // 8小时 + 59分钟
String startTime = DateUtils.dateFormat(DateUtils.dateAddMinutes(new Date(), -541), DateUtils.DATE_TIME_PATTERN); String startTime = DateUtils.dateFormat(DateUtils.dateAddMinutes(new Date(), -541), DateUtils.DATE_TIME_PATTERN);
...@@ -219,6 +239,10 @@ public class TdengineTimeServiceImpl { ...@@ -219,6 +239,10 @@ public class TdengineTimeServiceImpl {
*/ */
@Scheduled(cron = "0 0 0 1/1 * ? ") @Scheduled(cron = "0 0 0 1/1 * ? ")
public void insertDayDataPv() throws ParseException { public void insertDayDataPv() throws ParseException {
if (!openHealth) {
return;
}
idxFanHealthIndexMapper.deleteAllDataByTableName("pv_health_index_latest_data", "按天");
String recDate = DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00"); String recDate = DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00");
List<IdxBizPvHealthLevel> levelList = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "测点").last("limit 4")); List<IdxBizPvHealthLevel> levelList = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "测点").last("limit 4"));
String startTime = DateUtils.dateFormat(DateUtils.dateAddHours(new Date(), -32), DateUtils.DATE_TIME_PATTERN); String startTime = DateUtils.dateFormat(DateUtils.dateAddHours(new Date(), -32), DateUtils.DATE_TIME_PATTERN);
...@@ -270,7 +294,8 @@ public class TdengineTimeServiceImpl { ...@@ -270,7 +294,8 @@ public class TdengineTimeServiceImpl {
newList.add(item);//循环将数据填入载体list newList.add(item);//循环将数据填入载体list
if (500 == newList.size() || i == pvHealthIndices.size() - 1) { //载体list达到要求,进行批量操作 if (500 == newList.size() || i == pvHealthIndices.size() - 1) { //载体list达到要求,进行批量操作
//调用批量插入 //调用批量插入
pvHealthIndexMapper.saveBatchHealthIndexList(newList, tableName); pvHealthIndexMapper.saveBatchHealthIndexList(newList, tableName, analysisType);
idxFanHealthIndexMapper.saveBatchHealthIndexLatestInfoPv(newList);
newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入 newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入
} }
} }
......
...@@ -7,10 +7,11 @@ import org.apache.ibatis.annotations.Param; ...@@ -7,10 +7,11 @@ import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import java.util.List; import java.util.List;
import java.util.Map;
public interface FanHealthIndexDayMapper extends BaseMapper<FanHealthIndexDay> { public interface FanHealthIndexDayMapper extends BaseMapper<FanHealthIndexDay> {
@Select("<script>"+ @Select("<script>"+
"SELECT `health_index` AS healthIndex, analysis_time AS analysisTime, 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.fan_health_index_day WHERE analysis_obj_type = #{analysisObjType}" + "SELECT `health_index` AS healthIndex,anomaly, `health_index` AS `value`, analysis_time AS analysisTime, 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.fan_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> " +
...@@ -20,8 +21,16 @@ public interface FanHealthIndexDayMapper extends BaseMapper<FanHealthIndexDay> { ...@@ -20,8 +21,16 @@ public interface FanHealthIndexDayMapper extends BaseMapper<FanHealthIndexDay> {
"<if test='healthLevel!= null'>AND health_level = #{healthLevel} </if>" + "<if test='healthLevel!= null'>AND health_level = #{healthLevel} </if>" +
"<if test='subSystem!= null'>AND sub_system = #{subSystem} </if> " + "<if test='subSystem!= null'>AND sub_system = #{subSystem} </if> " +
"<if test='equipmentName!= null'>AND equipment_name = #{equipmentName} </if>" + "<if test='equipmentName!= null'>AND equipment_name = #{equipmentName} </if>" +
"order by health_index "+
"</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<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);
@Select("<script>"+
"SELECT station, health_level as healthlevel,( CASE HEALTH_LEVEL WHEN '危险' THEN 4 WHEN '警告' THEN 3 WHEN '注意' THEN 2 ELSE 1 END ) AS sort, count( 1 ) AS `value` FROM analysis_data.fan_health_index_day WHERE analysis_obj_type = #{analysisObjType} AND ts >= TODAY()-8h" +
"<if test='area!= null'> AND area = #{area} </if> " +
"<if test='station!= null'>AND station = #{station} </if>" +
" GROUP BY station,health_level order by sort"+
"</script>")
List<Map<String,Object>> selectEquipStatusByStation(@Param("area")String area,@Param("analysisObjType")String analysisObjType,@Param("station")String station);
} }
...@@ -10,7 +10,7 @@ import java.util.List; ...@@ -10,7 +10,7 @@ import java.util.List;
public interface FanHealthIndexHourMapper extends BaseMapper<FanHealthIndexHour> { public interface FanHealthIndexHourMapper extends BaseMapper<FanHealthIndexHour> {
@Select("<script>"+ @Select("<script>"+
"SELECT `health_index` AS healthIndex, created_time AS createdTime, analysis_time AS analysisTime, 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.fan_health_index_hour WHERE analysis_obj_type = #{analysisObjType}" + "SELECT `health_index` AS healthIndex, anomaly, `health_index` AS `value`, rec_date AS recDate, analysis_time AS analysisTime, station,equipment_name AS equipmentName,point_name as pointName, ( CASE HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status FROM analysis_data.fan_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> " +
...@@ -20,7 +20,8 @@ public interface FanHealthIndexHourMapper extends BaseMapper<FanHealthIndexHour> ...@@ -20,7 +20,8 @@ public interface FanHealthIndexHourMapper extends BaseMapper<FanHealthIndexHour>
"<if test='healthLevel!= null'>AND health_level = #{healthLevel} </if>" + "<if test='healthLevel!= null'>AND health_level = #{healthLevel} </if>" +
"<if test='subSystem!= null'>AND sub_system = #{subSystem} </if> " + "<if test='subSystem!= null'>AND sub_system = #{subSystem} </if> " +
"<if test='equipmentName!= null'>AND equipment_name = #{equipmentName} </if>" + "<if test='equipmentName!= null'>AND equipment_name = #{equipmentName} </if>" +
"order by health_index "+
"</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<FanHealthIndexHour> 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);
} }
package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2; package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.FanHealthIndexDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthIndex; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex; import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexDay; import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexDay;
...@@ -11,7 +12,7 @@ import java.util.List; ...@@ -11,7 +12,7 @@ import java.util.List;
public interface FanHealthIndexMapper extends BaseMapper<FanHealthIndex> { public interface FanHealthIndexMapper extends BaseMapper<FanHealthIndex> {
@Select("<script>"+ @Select("<script>"+
"SELECT `health_index` AS healthIndex, created_time AS createdTime, analysis_time AS analysisTime, 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.fan_health_index_data WHERE analysis_obj_type = #{analysisObjType} and analysis_type = #{analysisType}" + "SELECT `health_index` AS healthIndex, rec_date AS recDate, `health_index` AS `value`,analysis_time AS analysisTime, 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.fan_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> " +
...@@ -22,9 +23,13 @@ public interface FanHealthIndexMapper extends BaseMapper<FanHealthIndex> { ...@@ -22,9 +23,13 @@ public interface FanHealthIndexMapper extends BaseMapper<FanHealthIndex> {
"<if test='subSystem!= null'>AND sub_system = #{subSystem} </if> " + "<if test='subSystem!= null'>AND sub_system = #{subSystem} </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<FanHealthIndex> 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);
int saveBatchHealthIndexList(@Param("list") List<FanHealthIndex> list, @Param("tableName") String tableName); int saveBatchHealthIndexList(@Param("list") List<FanHealthIndex> list, @Param("tableName") String tableName, @Param("analysisType") String analysisType);
// int saveBatchHealthIndexLatestInfo(@Param("list") List<FanHealthIndex> list, @Param("tableName") String tableName);
//
// void deleteAllDataByTableName(@Param("tableName") String tableName, @Param("analysisType") String analysisType);
/** /**
* 测点 * 测点
...@@ -62,4 +67,8 @@ public interface FanHealthIndexMapper extends BaseMapper<FanHealthIndex> { ...@@ -62,4 +67,8 @@ public interface FanHealthIndexMapper extends BaseMapper<FanHealthIndex> {
List<FanHealthIndex> getInfoListByGroupByQyFan(@Param("startTime") String startTime, List<FanHealthIndex> getInfoListByGroupByQyFan(@Param("startTime") String startTime,
@Param("tableName") String tableName, @Param("tableName") String tableName,
@Param("analysisObjectType") String analysisObjectType); @Param("analysisObjectType") String analysisObjectType);
List<FanHealthIndex> getInfoByPage(@Param("dto") FanHealthIndexDto dto);
Integer getInfoByPageTotal(@Param("dto") FanHealthIndexDto dto);
} }
...@@ -10,7 +10,7 @@ import java.util.List; ...@@ -10,7 +10,7 @@ import java.util.List;
public interface FanHealthIndexMomentMapper extends BaseMapper<FanHealthIndexMoment> { public interface FanHealthIndexMomentMapper extends BaseMapper<FanHealthIndexMoment> {
@Select("<script>"+ @Select("<script>"+
"SELECT `health_index` AS healthIndex, created_time AS createdTime, analysis_time AS analysisTime, 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.fan_health_index_moment WHERE analysis_obj_type = #{analysisObjType}" + "SELECT `health_index` AS healthIndex,`health_index` AS `value`, anomaly, analysis_time AS analysisTime, 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.fan_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> " +
...@@ -20,7 +20,8 @@ public interface FanHealthIndexMomentMapper extends BaseMapper<FanHealthIndexMom ...@@ -20,7 +20,8 @@ public interface FanHealthIndexMomentMapper extends BaseMapper<FanHealthIndexMom
"<if test='healthLevel!= null'>AND health_level = #{healthLevel} </if>" + "<if test='healthLevel!= null'>AND health_level = #{healthLevel} </if>" +
"<if test='subSystem!= null'>AND sub_system = #{subSystem} </if> " + "<if test='subSystem!= null'>AND sub_system = #{subSystem} </if> " +
"<if test='equipmentName!= null'>AND equipment_name = #{equipmentName} </if>" + "<if test='equipmentName!= null'>AND equipment_name = #{equipmentName} </if>" +
"order by health_index "+
"</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<FanHealthIndexMoment> 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);
} }
package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2; package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.FanHealthIndexDto;
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.FanWarningRecord;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
public interface FanWaringRecordMapper extends BaseMapper<FanWarningRecord> { public interface FanWaringRecordMapper extends BaseMapper<FanWarningRecord> {
public List<Map<String,Object>> selectFanWarningNum(String station);
public List<FanWarningRecord> warningData(String STATION,String EQUIPMENTNAME,String SUBSYSTEM);
public List<FanWarningRecord> selectWarningPoint(String STATION,String EQUIPMENTNAME);
public List<Map<String,Object>> selectEquipWarningTotal(String STATION,String EQUIPMENTNAME);
int saveBatchWarningRecords(@Param("list") List<FanWarningRecord> list);
List<FanWarningRecord> getInfoByPage(@Param("dto") FanHealthIndexDto dto);
Integer getInfoByPageTotal(@Param("dto") FanHealthIndexDto dto);
FanWarningRecord getInfoByTs(@Param("ts") Long ts);
int updateStatusByTs(@Param("list") List<FanWarningRecord> list);
} }
...@@ -10,8 +10,8 @@ import java.util.List; ...@@ -10,8 +10,8 @@ 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, created_time AS createdTime, 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> " +
......
...@@ -10,8 +10,8 @@ import java.util.List; ...@@ -10,8 +10,8 @@ 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, created_time AS createdTime, 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);
} }
package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2; package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.FanHealthIndexDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.PvHealthIndexDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthIndex; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvHealthIndex; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex; import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex;
...@@ -13,8 +15,8 @@ import java.util.List; ...@@ -13,8 +15,8 @@ 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, created_time AS createdTime, 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> " +
...@@ -25,9 +27,11 @@ public interface PvHealthIndexMapper extends BaseMapper<PvHealthIndex> { ...@@ -25,9 +27,11 @@ public interface PvHealthIndexMapper extends BaseMapper<PvHealthIndex> {
"<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<PvHealthIndex> 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);
int saveBatchHealthIndexList(@Param("list") List<PvHealthIndex> list, @Param("tableName") String tableName); int saveBatchHealthIndexList(@Param("list") List<PvHealthIndex> list, @Param("tableName") String tableName, @Param("analysisType") String analysisType);
// int saveBatchHealthIndexLatestInfo(@Param("list") List<PvHealthIndex> list, @Param("tableName") String tableName);
List<PvHealthIndex> getInfoListByGroupByCdPv(@Param("startTime") String startTime, List<PvHealthIndex> getInfoListByGroupByCdPv(@Param("startTime") String startTime,
@Param("tableName") String tableName, @Param("tableName") String tableName,
...@@ -48,4 +52,9 @@ public interface PvHealthIndexMapper extends BaseMapper<PvHealthIndex> { ...@@ -48,4 +52,9 @@ public interface PvHealthIndexMapper extends BaseMapper<PvHealthIndex> {
List<PvHealthIndex> getInfoListByGroupByQyPv(@Param("startTime") String startTime, List<PvHealthIndex> getInfoListByGroupByQyPv(@Param("startTime") String startTime,
@Param("tableName") String tableName, @Param("tableName") String tableName,
@Param("analysisObjectType") String analysisObjectType); @Param("analysisObjectType") String analysisObjectType);
List<PvHealthIndex> getInfoByPage(@Param("dto") PvHealthIndexDto dto);
Integer getInfoByPageTotal(@Param("dto") PvHealthIndexDto dto);
} }
...@@ -10,8 +10,8 @@ import java.util.List; ...@@ -10,8 +10,8 @@ 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, created_time AS createdTime, 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);
} }
package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2; package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.FanHealthIndexDto;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanWarningRecord; import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvWarningRecord; import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvWarningRecord;
import org.apache.ibatis.annotations.Param;
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);
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);
List<PvWarningRecord> getInfoByPage(@Param("dto") FanHealthIndexDto dto);
Integer getInfoByPageTotal(@Param("dto") FanHealthIndexDto dto);
PvWarningRecord getInfoByTs(@Param("ts") Long ts);
int updateStatusByTs(@Param("list") List<PvWarningRecord> list);
} }
...@@ -30,4 +30,5 @@ public class FanHealthIndexDay implements Serializable { ...@@ -30,4 +30,5 @@ public class FanHealthIndexDay implements Serializable {
private String analysisTime; private String analysisTime;
private String kks; private String kks;
private String status; private String status;
private String value;
} }
...@@ -29,4 +29,6 @@ public class FanHealthIndexHour implements Serializable { ...@@ -29,4 +29,6 @@ public class FanHealthIndexHour implements Serializable {
private String pointName; private String pointName;
private String analysisTime; private String analysisTime;
private String kks; private String kks;
private String status;
private String value;
} }
...@@ -29,4 +29,6 @@ public class FanHealthIndexMoment implements Serializable { ...@@ -29,4 +29,6 @@ public class FanHealthIndexMoment implements Serializable {
private String pointName; private String pointName;
private String analysisTime; private String analysisTime;
private String kks; private String kks;
private String status;
private String value;
} }
...@@ -3,9 +3,11 @@ package com.yeejoin.amos.boot.module.jxiop.biz.tdengine; ...@@ -3,9 +3,11 @@ package com.yeejoin.amos.boot.module.jxiop.biz.tdengine;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
@Data @Data
@TableName(value = "", autoResultMap = true) @TableName(value = "fan_warning_record", autoResultMap = true)
public class FanWarningRecord { public class FanWarningRecord implements Serializable {
private Long ts; private Long ts;
private String recDate; private String recDate;
private String disposotionState; private String disposotionState;
...@@ -25,4 +27,5 @@ public class FanWarningRecord { ...@@ -25,4 +27,5 @@ public class FanWarningRecord {
private String disposotionDate; private String disposotionDate;
private String kks; private String kks;
private String warningPeriod; private String warningPeriod;
private String status;
} }
...@@ -4,14 +4,15 @@ import com.baomidou.mybatisplus.annotation.TableField; ...@@ -4,14 +4,15 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
@Data @Data
@TableName(value = "", autoResultMap = true) @TableName(value = "pv_warning_record", autoResultMap = true)
public class PvWarningRecord { public class PvWarningRecord implements Serializable {
private Long ts; private Long ts;
private String recDate; private String recDate;
private String disposotionState; private String disposotionState;
private String healthIndexSeq; private String healthIndex;
private String analysisPointId; private String analysisPointId;
private String warningName; private String warningName;
private String arae; private String arae;
...@@ -28,4 +29,5 @@ public class PvWarningRecord { ...@@ -28,4 +29,5 @@ public class PvWarningRecord {
private String disposotionDate; private String disposotionDate;
private String kks; private String kks;
private String warningPeriod; private String warningPeriod;
private String status;
} }
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
SELECT SELECT
IFNULL( AVG( HEALTH_INDEX ), 100 ) AS avgHealthIndex IFNULL( AVG( HEALTH_INDEX ), 100 ) AS avgHealthIndex
FROM FROM
idx_biz_fan_health_index fan_health_index_latest_data
<where> <where>
<if test="analysisType == '按天' or analysisType == null or analysisType == ''"> <if test="analysisType == '按天' or analysisType == null or analysisType == ''">
AND ANALYSIS_TYPE = '按天' AND ANALYSIS_TYPE = '按天'
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
SELECT SELECT
IFNULL( AVG( HEALTH_INDEX ), 100 ) AS avgHealthIndex IFNULL( AVG( HEALTH_INDEX ), 100 ) AS avgHealthIndex
FROM FROM
idx_biz_pv_health_index pv_health_index_latest_data
<where> <where>
<if test="analysisType == '按天' or analysisType == null or analysisType == ''"> <if test="analysisType == '按天' or analysisType == null or analysisType == ''">
AND ANALYSIS_TYPE = '按天' AND ANALYSIS_TYPE = '按天'
...@@ -1165,22 +1165,22 @@ ...@@ -1165,22 +1165,22 @@
</select> </select>
<select id="warningData" resultType="com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWarningRecord"> <select id="warningData" resultType="com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWarningRecord">
SELECT SELECT
* *
FROM FROM
idx_biz_fan_warning_record re idx_biz_fan_warning_record re
WHERE WHERE
re.`STATUS` = 0 re.`STATUS` = 0
<if test="EQUIPMENTNAME != '' and EQUIPMENTNAME != null"> <if test="EQUIPMENTNAME != '' and EQUIPMENTNAME != null">
AND re.EQUIPMENT_NAME = #{EQUIPMENTNAME} AND re.EQUIPMENT_NAME = #{EQUIPMENTNAME}
</if> </if>
<if test="SUBARRAY != null and SUBARRAY != '' "> <if test="SUBARRAY != null and SUBARRAY != '' ">
AND re.SUBARRAY = #{SUBARRAY} AND re.SUBARRAY = #{SUBARRAY}
</if> </if>
<if test="STATION != null and STATION != '' "> <if test="STATION != null and STATION != '' ">
AND re.STATION = #{STATION} AND re.STATION = #{STATION}
</if> </if>
</select> </select>
<select id="pointNum" resultType="int"> <select id="pointNum" resultType="int">
SELECT SELECT
...@@ -1192,8 +1192,8 @@ ...@@ -1192,8 +1192,8 @@
<if test="EQUIPMENTNAME != '' and EQUIPMENTNAME != null"> <if test="EQUIPMENTNAME != '' and EQUIPMENTNAME != null">
AND cl.EQUIPMENT_NAME = #{EQUIPMENTNAME} AND cl.EQUIPMENT_NAME = #{EQUIPMENTNAME}
</if> </if>
<if test="SUBARRAY != null and SUBARRAY != '' "> <if test="SUBSYSTEM != null and SUBSYSTEM != '' ">
AND cl.SUBARRAY = #{SUBARRAY} AND cl.SUB_SYSTEM = #{SUBSYSTEM}
</if> </if>
<if test="STATION != null and STATION != '' "> <if test="STATION != null and STATION != '' ">
AND cl.STATION = #{STATION} AND cl.STATION = #{STATION}
...@@ -1367,7 +1367,7 @@ ...@@ -1367,7 +1367,7 @@
FROM ( FROM (
SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex, SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex,
STATION AS STATION STATION AS STATION
FROM idx_biz_fan_health_index FROM fan_health_index_latest_data
<where> <where>
ANALYSIS_OBJ_TYPE = '场站' ANALYSIS_OBJ_TYPE = '场站'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''"> <if test="analysisType == '按天' or analysisType == null or analysisType == ''">
...@@ -1388,7 +1388,7 @@ ...@@ -1388,7 +1388,7 @@
( (
SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex, SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex,
STATION AS STATION STATION AS STATION
FROM idx_biz_pv_health_index FROM pv_health_index_latest_data
<where> <where>
ANALYSIS_OBJ_TYPE = '场站' ANALYSIS_OBJ_TYPE = '场站'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''"> <if test="analysisType == '按天' or analysisType == null or analysisType == ''">
...@@ -1416,7 +1416,7 @@ ...@@ -1416,7 +1416,7 @@
FROM ( FROM (
SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex, SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex,
EQUIPMENT_NAME AS equipmentName EQUIPMENT_NAME AS equipmentName
FROM idx_biz_fan_health_index FROM fan_health_index_latest_data
<where> <where>
ANALYSIS_OBJ_TYPE = '设备' ANALYSIS_OBJ_TYPE = '设备'
...@@ -1438,7 +1438,7 @@ ...@@ -1438,7 +1438,7 @@
( (
SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex, SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex,
SUBARRAY AS equipmentName SUBARRAY AS equipmentName
FROM idx_biz_pv_health_index FROM pv_health_index_latest_data
<where> <where>
ANALYSIS_OBJ_TYPE = '子阵' ANALYSIS_OBJ_TYPE = '子阵'
...@@ -1471,7 +1471,7 @@ ...@@ -1471,7 +1471,7 @@
FROM ( FROM (
SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex, SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex,
SUB_SYSTEM AS subSystem SUB_SYSTEM AS subSystem
FROM idx_biz_fan_health_index FROM fan_health_index_latest_data
<where> <where>
ANALYSIS_OBJ_TYPE = '子系统' ANALYSIS_OBJ_TYPE = '子系统'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''"> <if test="analysisType == '按天' or analysisType == null or analysisType == ''">
...@@ -1492,7 +1492,7 @@ ...@@ -1492,7 +1492,7 @@
( (
SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex, SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex,
EQUIPMENT_NAME AS subSystem EQUIPMENT_NAME AS subSystem
FROM idx_biz_pv_health_index FROM pv_health_index_latest_data
<where> <where>
ANALYSIS_OBJ_TYPE = '设备' ANALYSIS_OBJ_TYPE = '设备'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''"> <if test="analysisType == '按天' or analysisType == null or analysisType == ''">
...@@ -1522,7 +1522,7 @@ ...@@ -1522,7 +1522,7 @@
SELECT IFNULL(HEALTH_INDEX, 100) AS healthIndex, SELECT IFNULL(HEALTH_INDEX, 100) AS healthIndex,
concat(STATION, '_', INDEX_ADDRESS) as gatewayIndexAddress concat(STATION, '_', INDEX_ADDRESS) as gatewayIndexAddress
FROM idx_biz_fan_health_index FROM fan_health_index_latest_data
<where> <where>
ANALYSIS_OBJ_TYPE = '测点' ANALYSIS_OBJ_TYPE = '测点'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''"> <if test="analysisType == '按天' or analysisType == null or analysisType == ''">
...@@ -1544,7 +1544,7 @@ ...@@ -1544,7 +1544,7 @@
( (
SELECT IFNULL(HEALTH_INDEX, 100) AS healthIndex, SELECT IFNULL(HEALTH_INDEX, 100) AS healthIndex,
concat(STATION, '_', INDEX_ADDRESS) as gatewayIndexAddress concat(STATION, '_', INDEX_ADDRESS) as gatewayIndexAddress
FROM idx_biz_pv_health_index FROM pv_health_index_latest_data
<where> <where>
ANALYSIS_OBJ_TYPE = '测点' ANALYSIS_OBJ_TYPE = '测点'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''"> <if test="analysisType == '按天' or analysisType == null or analysisType == ''">
......
...@@ -335,4 +335,112 @@ ...@@ -335,4 +335,112 @@
</select> </select>
<insert id="saveBatchHealthIndexLatestInfo">
insert into
fan_health_index_latest_data
(
`REC_DATE`,
`ANALYSIS_OBJ_TYPE`,
`ANALYSIS_OBJ_SEQ`,
`WEIGTH`,
`HEALTH_INDEX`,
`HEALTH_LEVEL`,
`ANALYSIS_TYPE`,
`ANALYSIS_START_TIME`,
`ANALYSIS_END_TIME`,
`ARAE`,
`STATION`,
`SUB_SYSTEM`,
`NUMBER`,
`EQUIPMENT_NAME`,
`GATEWAY_ID`,
`INDEX_ADDRESS`,
`ANOMALY`,
`POINT_NAME`,
`ANALYSIS_TIME`,
`KKS`
)
values
<foreach collection="list" separator="," item="item" index="index">
(
#{item.recDate, jdbcType=VARCHAR},
#{item.analysisObjType, jdbcType=VARCHAR},
#{item.analysisObjSeq, jdbcType=VARCHAR},
#{item.weight, jdbcType=FLOAT},
#{item.healthIndex, jdbcType=FLOAT},
#{item.healthLevel, jdbcType=VARCHAR},
#{item.analysisType, jdbcType=VARCHAR},
#{item.analysisStartTime, jdbcType=VARCHAR},
#{item.analysisEndTime, jdbcType=VARCHAR},
#{item.area, jdbcType=VARCHAR},
#{item.station, jdbcType=VARCHAR},
#{item.subSystem, jdbcType=VARCHAR},
#{item.number, jdbcType=VARCHAR},
#{item.equipmentName, jdbcType=VARCHAR},
#{item.gatewayId, jdbcType=VARCHAR},
#{item.indexAddress, jdbcType=VARCHAR},
#{item.anomaly, jdbcType=FLOAT},
#{item.pointName, jdbcType=VARCHAR},
#{item.analysisTime, jdbcType=VARCHAR},
#{item.kks, jdbcType=VARCHAR}
)
</foreach>
</insert>
<delete id="deleteAllDataByTableName">
delete from ${tableName} where analysis_type = #{analysisType}
</delete>
<insert id="saveBatchHealthIndexLatestInfoPv">
insert into pv_health_index_latest_data
(
`REC_DATE`,
`ANALYSIS_OBJ_TYPE`,
`ANALYSIS_OBJ_SEQ`,
`WEIGTH`,
`HEALTH_INDEX`,
`HEALTH_LEVEL`,
`ANALYSIS_TYPE`,
`ANALYSIS_START_TIME`,
`ANALYSIS_END_TIME`,
`ARAE`,
`STATION`,
`SUBARRAY`,
`MANUFACTURER`,
`DEVICE_TYPE`,
`GATEWAY_ID`,
`INDEX_ADDRESS`,
`EQUIPMENT_NAME`,
`ANOMALY`,
`POINT_NAME`,
`ANALYSIS_TIME`,
`KKS`
)
values
<foreach collection="list" separator="," item="item" index="index">
(
#{item.recDate, jdbcType=VARCHAR},
#{item.analysisObjType, jdbcType=VARCHAR},
#{item.analysisObjSeq, jdbcType=VARCHAR},
#{item.weight, jdbcType=FLOAT},
#{item.healthIndex, jdbcType=FLOAT},
#{item.healthLevel, jdbcType=VARCHAR},
#{item.analysisType, jdbcType=VARCHAR},
#{item.analysisStartTime, jdbcType=VARCHAR},
#{item.analysisEndTime, jdbcType=VARCHAR},
#{item.area, jdbcType=VARCHAR},
#{item.station, jdbcType=VARCHAR},
#{item.subarray, jdbcType=VARCHAR},
#{item.manufacturer, jdbcType=VARCHAR},
#{item.deviceType, jdbcType=VARCHAR},
#{item.gatewayId, jdbcType=VARCHAR},
#{item.indexAddress, jdbcType=VARCHAR},
#{item.equipmentName, jdbcType=VARCHAR},
#{item.anomaly, jdbcType=FLOAT},
#{item.pointName, jdbcType=VARCHAR},
#{item.analysisTime, jdbcType=VARCHAR},
#{item.kks, jdbcType=VARCHAR}
)
</foreach>
</insert>
</mapper> </mapper>
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<insert id="saveBatchHealthIndexList"> <insert id="saveBatchHealthIndexList">
insert into insert into
${tableName} ${tableName}
using fan_health_index_data TAGS ('按时刻') using fan_health_index_data TAGS (#{analysisType})
values values
<foreach collection="list" separator="," item="item" index="index"> <foreach collection="list" separator="," item="item" index="index">
( (
...@@ -77,6 +77,7 @@ ...@@ -77,6 +77,7 @@
area, area,
sub_system, sub_system,
equipment_name, equipment_name,
number,
avg(anomaly) as anomaly, avg(anomaly) as anomaly,
AVG(health_index) as health_index AVG(health_index) as health_index
from from
...@@ -90,7 +91,8 @@ ...@@ -90,7 +91,8 @@
analysis_obj_type, analysis_obj_type,
area, area,
sub_system, sub_system,
equipment_name equipment_name,
number
</select> </select>
<select id="getInfoListByGroupBySbFan" resultType="com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex"> <select id="getInfoListByGroupBySbFan" resultType="com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex">
...@@ -152,4 +154,79 @@ ...@@ -152,4 +154,79 @@
analysis_obj_type, analysis_obj_type,
area area
</select> </select>
<select id="getInfoByPage" resultType="com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex">
SELECT * FROM fan_health_index_data
<where>
<if test="dto.analysisObjType!= null and dto.analysisObjType!= ''">analysis_obj_type = #{dto.analysisObjType}</if>
<if test="dto.analysisType!= null and dto.analysisType!= ''">and analysis_type = #{dto.analysisType}</if>
<if test="dto.endDate!= null and dto.endDate!= '' "> and ts &lt;= #{dto.endDate} </if>
<if test="dto.startDate!= null and dto.startDate!= ''"> and ts &gt;= #{dto.startDate} </if>
<if test="dto.area!= null and dto.area!= ''"> AND area = #{area} </if>
<if test="dto.number!= null and dto.number!= ''"> AND `number` = #{dto.number} </if>
<if test="dto.pointName!= null and dto.pointName!= ''">AND point_name = #{dto.pointName} </if>
<if test="dto.station!= null and dto.station!= ''">AND station = #{dto.station} </if>
<if test="dto.healthLevel!= null and dto.healthLevel!= ''">AND health_level = #{dto.healthLevel} </if>
<if test="dto.subSystem!= null and dto.subSystem!= ''">AND sub_system = #{dto.subSystem} </if>
<if test="dto.equipmentName!= null and dto.equipmentName!= ''">AND equipment_name = #{dto.equipmentName}
</if>
</where>
<if test="dto.orderColumns != null and dto.orderColumns != ''">
order by ${dto.orderColumns}
</if>
limit #{dto.current}, #{dto.size}
</select>
<select id="getInfoByPageTotal" resultType="java.lang.Integer">
SELECT count(1) FROM fan_health_index_data
<where>
<if test="dto.analysisObjType!= null and dto.analysisObjType!= ''">analysis_obj_type = #{dto.analysisObjType}</if>
<if test="dto.analysisType!= null and dto.analysisType!= ''">and analysis_type = #{dto.analysisType}</if>
<if test="dto.endDate!= null and dto.endDate!= '' "> and ts &lt;= #{dto.endDate} </if>
<if test="dto.startDate!= null and dto.startDate!= ''"> and ts &gt;= #{dto.startDate} </if>
<if test="dto.area!= null and dto.area!= ''"> AND area = #{area} </if>
<if test="dto.number!= null and dto.number!= ''"> AND `number` = #{dto.number} </if>
<if test="dto.pointName!= null and dto.pointName!= ''">AND point_name = #{dto.pointName} </if>
<if test="dto.station!= null and dto.station!= ''">AND station = #{dto.station} </if>
<if test="dto.healthLevel!= null and dto.healthLevel!= ''">AND health_level = #{dto.healthLevel} </if>
<if test="dto.subSystem!= null and dto.subSystem!= ''">AND sub_system = #{dto.subSystem} </if>
<if test="dto.equipmentName!= null and dto.equipmentName!= ''">AND equipment_name = #{dto.equipmentName}
</if>
</where>
</select>
<select id="saveBatchHealthIndexLatestInfo" resultType="int">
insert into
${tableName}
values
<foreach collection="list" separator="," item="item" index="index">
(
now,
#{item.recDate, jdbcType=VARCHAR},
#{item.analysisObjType, jdbcType=VARCHAR},
#{item.analysisObjSeq, jdbcType=VARCHAR},
#{item.weight, jdbcType=FLOAT},
#{item.healthIndex, jdbcType=FLOAT},
#{item.healthLevel, jdbcType=VARCHAR},
#{item.analysisStartTime, jdbcType=VARCHAR},
#{item.analysisEndTime, jdbcType=VARCHAR},
#{item.area, jdbcType=VARCHAR},
#{item.station, jdbcType=VARCHAR},
#{item.subSystem, jdbcType=VARCHAR},
#{item.number, jdbcType=VARCHAR},
#{item.equipmentName, jdbcType=VARCHAR},
#{item.gatewayId, jdbcType=VARCHAR},
#{item.indexAddress, jdbcType=VARCHAR},
#{item.anomaly, jdbcType=FLOAT},
#{item.pointName, jdbcType=VARCHAR},
#{item.analysisTime, jdbcType=VARCHAR},
#{item.kks, jdbcType=VARCHAR}
)
</foreach>
</select>
<delete id="deleteAllDataByTableName">
delete from ${tableName} where analysis_type = #{analysisType}
</delete>
</mapper> </mapper>
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanWaringRecordMapper"> <mapper namespace="com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanWaringRecordMapper">
<insert id="saveBatchWarningRecords">
insert
into
fan_warning_record
<!-- (ts,-->
<!-- rec_date,-->
<!-- disposotion_state,-->
<!-- health_index_seq,-->
<!-- health_index,-->
<!-- analysis_point_id,-->
<!-- warning_name,-->
<!-- arae,-->
<!-- station,-->
<!-- subarray,-->
<!-- manufacturer,-->
<!-- device_type,-->
<!-- equipment_name,-->
<!-- gateway_id,-->
<!-- index_address,-->
<!-- content,-->
<!-- point_name,-->
<!-- health_level,-->
<!-- disposotion_date,-->
<!-- kks,-->
<!-- warning_period,-->
<!-- status)-->
values
<foreach collection="list" separator="," item="item" index="index">
(#{item.ts, jdbcType=TIMESTAMP},
#{item.recDate, jdbcType=VARCHAR},
#{item.disposotionState, jdbcType=VARCHAR},
<!-- #{item.healthIndexSeq, jdbcType=VARCHAR},-->
#{item.healthIndex, jdbcType=VARCHAR},
#{item.analysisPointId, jdbcType=VARCHAR},
#{item.warningName, jdbcType=VARCHAR},
#{item.arae, jdbcType=VARCHAR},
#{item.station, jdbcType=VARCHAR},
#{item.subSystem, jdbcType=VARCHAR},
#{item.number, jdbcType=VARCHAR},
#{item.equipmentName, jdbcType=VARCHAR},
#{item.gatewayId, jdbcType=VARCHAR},
#{item.indexAddress, jdbcType=VARCHAR},
#{item.content, jdbcType=VARCHAR},
#{item.pointName, jdbcType=VARCHAR},
#{item.healthLevel, jdbcType=VARCHAR},
#{item.disposotionDate, jdbcType=VARCHAR},
#{item.kks, jdbcType=VARCHAR},
#{item.warningPeriod, jdbcType=VARCHAR},
#{item.status, jdbcType=VARCHAR})
</foreach>
</insert>
<select id="selectFanWarningNum" resultType="map">
SELECT `b`.`EQUIPMENT_NAME` AS `EQUIPMENT_NAME`,
`b`.`STATION` AS `STATION`,
`b`.`警告` AS `警告`,
`b`.`注意` AS `注意`,
`b`.`危险` AS `危险`,
sum(((`b`.`注意` + `b`.`危险`) + `b`.`警告`)) AS `sort`
FROM (select `a`.`EQUIPMENT_NAME` as `EQUIPMENT_NAME`,
a.`STATION` as `STATION`,
max(case `a`.`WARNING_NAME` when '危险' then `a`.`num` else 0 end) as `危险`,
max(case `a`.`WARNING_NAME` when '注意' then `a`.`num` else 0 end) as `注意`,
max(case `a`.`WARNING_NAME` when '警告' then `a`.`num` else 0 end) as `警告`
from (
select `warning_name` as `WARNING_NAME`,
`equipment_name` as `EQUIPMENT_NAME`,
`station` as `STATION`,
count(1) as `num`
from analysis_data.fan_warning_record
where `status` = 0
or (`status` = 1
and `ts` > (now() - 3D - 8h))
<if test="station != null">
and station = #{station}
</if>
group by `station`,
`equipment_name`,
`warning_name`) a
group by `a`.`EQUIPMENT_NAME`, a.`STATION`) b
GROUP BY `b`.`EQUIPMENT_NAME`,
`b`.`STATION`, `b`.`警告`, `b`.`注意`, `b`.`危险`
order by sort DESC
</select>
<select id="warningData" resultType="com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanWarningRecord">
SELECT
warning_name as WarningName
FROM
analysis_data.fan_warning_record re
WHERE
re.`status` = 0
<if test="EQUIPMENTNAME != '' and EQUIPMENTNAME != null">
AND re.equipment_name = #{EQUIPMENTNAME}
</if>
<if test="SUBSYSTEM != null and SUBSYSTEM != '' ">
AND re.sub_system = #{SUBSYSTEM}
</if>
<if test="STATION != null and STATION != '' ">
AND re.station = #{STATION}
</if>
</select>
<select id="selectWarningPoint" resultType="com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanWarningRecord">
SELECT
a.station,
a.warning_name,
a.content,
a.equipment_name,
a.point_name,
a.rec_date
from
analysis_data.fan_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>
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>
group by
`z`.`station`,
`z`.`warning_name`,
`z`.`equipment_name`
) b
GROUP BY
`b`.`STATION`,
`b`.`EQUIPMENT_NAME`
</select>
<select id="getInfoByPage" resultType="com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanWarningRecord">
SELECT * FROM fan_warning_record
<where>
<if test="dto.area!= null and dto.area!= ''"> AND arae = #{dto.area} </if>
<if test="dto.station!= null and dto.station!= ''">AND station = #{dto.station} </if>
<if test="dto.equipmentName!= null and dto.equipmentName!= ''">AND equipment_name = #{dto.equipmentName}</if>
<if test="dto.subSystem!= null and dto.subSystem!= ''">AND sub_system = #{dto.subSystem} </if>
<if test="dto.pointName!= null and dto.pointName!= ''">AND point_name = #{dto.pointName} </if>
<if test="dto.warningName!= null and dto.warningName!= ''">AND warning_name = #{dto.warningName} </if>
<if test="dto.disposotionState!= null and dto.disposotionState!= ''">AND disposotion_state = #{dto.disposotionState} </if>
<if test="dto.endDate!= null and dto.endDate!= '' "> and ts &lt;= #{dto.endDate} </if>
<if test="dto.startDate!= null and dto.startDate!= ''"> and ts &gt;= #{dto.startDate} </if>
</where>
<if test="dto.orderColumns != null and dto.orderColumns != ''">
order by ${dto.orderColumns}
</if>
limit #{dto.current}, #{dto.size}
</select>
<select id="getInfoByPageTotal" resultType="java.lang.Integer">
SELECT count(1) FROM fan_warning_record
<where>
<if test="dto.area!= null and dto.area!= ''"> AND arae = #{dto.area} </if>
<if test="dto.station!= null and dto.station!= ''">AND station = #{dto.station} </if>
<if test="dto.equipmentName!= null and dto.equipmentName!= ''">AND equipment_name = #{dto.equipmentName}</if>
<if test="dto.subSystem!= null and dto.subSystem!= ''">AND sub_system = #{dto.subSystem} </if>
<if test="dto.pointName!= null and dto.pointName!= ''">AND point_name = #{dto.pointName} </if>
<if test="dto.warningName!= null and dto.warningName!= ''">AND warning_name = #{dto.warningName} </if>
<if test="dto.disposotionState!= null and dto.disposotionState!= ''">AND disposotion_state = #{dto.disposotionState} </if>
<if test="dto.endDate!= null and dto.endDate!= '' "> and ts &lt;= #{dto.endDate} </if>
<if test="dto.startDate!= null and dto.startDate!= ''"> and ts &gt;= #{dto.startDate} </if>
</where>
</select>
<select id="getInfoByTs" resultType="com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanWarningRecord">
select * from analysis_data.fan_warning_record where ts = #{ts,jdbcType=TIMESTAMP} limit 1
</select>
<insert id="updateStatusByTs">
insert
into
fan_warning_record
(ts,
disposotion_state,
disposotion_date,
status)
values
<foreach collection="list" separator="," item="item" index="index">
(#{item.ts, jdbcType=TIMESTAMP},
#{item.disposotionState, jdbcType=VARCHAR},
#{item.disposotionDate, jdbcType=VARCHAR},
#{item.status, jdbcType=VARCHAR})
</foreach>
</insert>
</mapper> </mapper>
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
<insert id="saveBatchHealthIndexList"> <insert id="saveBatchHealthIndexList">
insert into ${tableName} insert into ${tableName}
using pv_health_index_data TAGS ('按时刻') using pv_health_index_data TAGS (#{analysisType})
values values
<foreach collection="list" separator="," item="item" index="index"> <foreach collection="list" separator="," item="item" index="index">
( (
...@@ -186,4 +186,72 @@ ...@@ -186,4 +186,72 @@
analysis_obj_type, analysis_obj_type,
area area
</select> </select>
<select id="getInfoByPage" resultType="com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex">
SELECT * FROM pv_health_index_data
<where>
<if test="dto.analysisObjType!= null and dto.analysisObjType!= ''">analysis_obj_type = #{dto.analysisObjType}</if>
<if test="dto.analysisType!= null and dto.analysisType!= ''">and analysis_type = #{dto.analysisType}</if>
<if test="dto.endDate!= null and dto.endDate!= ''"> and ts &lt;= #{dto.endDate} </if>
<if test="dto.startDate!= null and dto.startDate!= ''"> and ts &gt;= #{dto.startDate} </if>
<if test="dto.area!= null and dto.area!= ''"> AND area = #{area} </if>
<if test="dto.subarray!= null and dto.subarray!= ''"> AND `subarray` = #{dto.subarray} </if>
<if test="dto.pointName!= null and dto.pointName!= ''">AND point_name = #{dto.pointName} </if>
<if test="dto.station!= null and dto.station!= ''">AND station = #{dto.station} </if>
<if test="dto.healthLevel!= null and dto.healthLevel!= ''">AND health_level = #{dto.healthLevel} </if>
<if test="dto.equipmentName!= null and dto.equipmentName!= ''">AND equipment_name = #{dto.equipmentName}
</if>
</where>
<if test="dto.orderColumns != null and dto.orderColumns != ''">
order by ${dto.orderColumns}
</if>
limit #{dto.current}, #{dto.size}
</select>
<select id="getInfoByPageTotal" resultType="java.lang.Integer">
SELECT count(1) FROM fan_health_index_data
<where>
<if test="dto.analysisObjType!= null and dto.analysisObjType!= ''">analysis_obj_type = #{dto.analysisObjType}</if>
<if test="dto.analysisType!= null and dto.analysisType!= ''">and analysis_type = #{dto.analysisType}</if>
<if test="dto.endDate!= null and dto.endDate!= ''"> and ts &lt;= #{dto.endDate} </if>
<if test="dto.startDate!= null and dto.startDate!= ''"> and ts &gt;= #{dto.startDate} </if>
<if test="dto.area!= null and dto.area!= ''"> AND area = #{area} </if>
<if test="dto.subarray!= null and dto.subarray!= ''"> AND `subarray` = #{dto.subarray} </if>
<if test="dto.pointName!= null and dto.pointName!= ''">AND point_name = #{dto.pointName} </if>
<if test="dto.station!= null and dto.station!= ''">AND station = #{dto.station} </if>
<if test="dto.healthLevel!= null and dto.healthLevel!= ''">AND health_level = #{dto.healthLevel} </if>
<if test="dto.equipmentName!= null and dto.equipmentName!= ''">AND equipment_name = #{dto.equipmentName}
</if>
</where>
</select>
<select id="saveBatchHealthIndexLatestInfo" resultType="int">
insert into ${tableName}
values
<foreach collection="list" separator="," item="item" index="index">
(
now,
#{item.recDate, jdbcType=VARCHAR},
#{item.analysisObjType, jdbcType=VARCHAR},
#{item.analysisObjSeq, jdbcType=VARCHAR},
#{item.weight, jdbcType=FLOAT},
#{item.healthIndex, jdbcType=FLOAT},
#{item.healthLevel, jdbcType=VARCHAR},
#{item.analysisStartTime, jdbcType=VARCHAR},
#{item.analysisEndTime, jdbcType=VARCHAR},
#{item.area, jdbcType=VARCHAR},
#{item.station, jdbcType=VARCHAR},
#{item.subarray, jdbcType=VARCHAR},
#{item.manufacturer, jdbcType=VARCHAR},
#{item.deviceType, jdbcType=VARCHAR},
#{item.equipmentName, jdbcType=VARCHAR},
#{item.gatewayId, jdbcType=VARCHAR},
#{item.indexAddress, jdbcType=VARCHAR},
#{item.anomaly, jdbcType=FLOAT},
#{item.pointName, jdbcType=VARCHAR},
#{item.analysisTime, jdbcType=VARCHAR},
#{item.kks, jdbcType=VARCHAR}
)
</foreach>
</select>
</mapper> </mapper>
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvWaringRecordMapper"> <mapper namespace="com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvWaringRecordMapper">
<insert id="saveBatchWarningRecords">
insert
into
pv_warning_record
<!-- (ts,-->
<!-- rec_date,-->
<!-- disposotion_state,-->
<!-- health_index_seq,-->
<!-- health_index,-->
<!-- analysis_point_id,-->
<!-- warning_name,-->
<!-- arae,-->
<!-- station,-->
<!-- subarray,-->
<!-- manufacturer,-->
<!-- device_type,-->
<!-- equipment_name,-->
<!-- gateway_id,-->
<!-- index_address,-->
<!-- content,-->
<!-- point_name,-->
<!-- health_level,-->
<!-- disposotion_date,-->
<!-- kks,-->
<!-- warning_period,-->
<!-- status)-->
values
<foreach collection="list" separator="," item="item" index="index">
(#{item.ts, jdbcType=TIMESTAMP},
#{item.recDate, jdbcType=VARCHAR},
#{item.disposotionState, jdbcType=VARCHAR},
#{item.healthIndex, jdbcType=VARCHAR},
#{item.analysisPointId, jdbcType=VARCHAR},
#{item.warningName, jdbcType=VARCHAR},
#{item.arae, jdbcType=VARCHAR},
#{item.station, jdbcType=VARCHAR},
#{item.subarray, jdbcType=VARCHAR},
#{item.manufacturer, jdbcType=VARCHAR},
#{item.deviceType, jdbcType=VARCHAR},
#{item.equipmentName, jdbcType=VARCHAR},
#{item.gatewayId, jdbcType=VARCHAR},
#{item.indexAddress, jdbcType=VARCHAR},
#{item.content, jdbcType=VARCHAR},
#{item.pointName, jdbcType=VARCHAR},
#{item.healthLevel, jdbcType=VARCHAR},
#{item.disposotionDate, jdbcType=VARCHAR},
#{item.kks, jdbcType=VARCHAR},
#{item.warningPeriod, jdbcType=VARCHAR},
#{item.status, jdbcType=VARCHAR})
</foreach>
</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>
<select id="getInfoByPage" resultType="com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvWarningRecord">
SELECT * FROM pv_warning_record
<where>
<if test="dto.area!= null and dto.area!= ''"> AND arae = #{dto.area} </if>
<if test="dto.station!= null and dto.station!= ''">AND station = #{dto.station} </if>
<if test="dto.equipmentName!= null and dto.equipmentName!= ''">AND equipment_name = #{dto.equipmentName}</if>
<if test="dto.subarray!= null and dto.subarray!= ''">AND subarray = #{dto.subarray} </if>
<if test="dto.pointName!= null and dto.pointName!= ''">AND point_name = #{dto.pointName} </if>
<if test="dto.warningName!= null and dto.warningName!= ''">AND warning_name = #{dto.warningName} </if>
<if test="dto.disposotionState!= null and dto.disposotionState!= ''">AND disposotion_state = #{dto.disposotionState} </if>
<if test="dto.endDate!= null and dto.endDate!= '' "> and ts &lt;= #{dto.endDate} </if>
<if test="dto.startDate!= null and dto.startDate!= ''"> and ts &gt;= #{dto.startDate} </if>
</where>
<if test="dto.orderColumns != null and dto.orderColumns != ''">
order by ${dto.orderColumns}
</if>
limit #{dto.current}, #{dto.size}
</select>
<select id="getInfoByPageTotal" resultType="java.lang.Integer">
SELECT count(1) FROM pv_warning_record
<where>
<if test="dto.area!= null and dto.area!= ''"> AND arae = #{dto.area} </if>
<if test="dto.station!= null and dto.station!= ''">AND station = #{dto.station} </if>
<if test="dto.equipmentName!= null and dto.equipmentName!= ''">AND equipment_name = #{dto.equipmentName}</if>
<if test="dto.subarray!= null and dto.subarray!= ''">AND subarray = #{dto.subarray} </if>
<if test="dto.pointName!= null and dto.pointName!= ''">AND point_name = #{dto.pointName} </if>
<if test="dto.warningName!= null and dto.warningName!= ''">AND warning_name = #{dto.warningName} </if>
<if test="dto.disposotionState!= null and dto.disposotionState!= ''">AND disposotion_state = #{dto.disposotionState} </if>
<if test="dto.endDate!= null and dto.endDate!= '' "> and ts &lt;= #{dto.endDate} </if>
<if test="dto.startDate!= null and dto.startDate!= ''"> and ts &gt;= #{dto.startDate} </if>
</where>
</select>
<select id="getInfoByTs" resultType="com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvWarningRecord">
select * from analysis_data.pv_warning_record where ts = #{ts,jdbcType=TIMESTAMP} limit 1
</select>
<insert id="updateStatusByTs">
insert
into
pv_warning_record
(ts,
disposotion_state,
disposotion_date,
status)
values
<foreach collection="list" separator="," item="item" index="index">
(#{item.ts, jdbcType=TIMESTAMP},
#{item.disposotionState, jdbcType=VARCHAR},
#{item.disposotionDate, jdbcType=VARCHAR},
#{item.status, jdbcType=VARCHAR})
</foreach>
</insert>
</mapper> </mapper>
...@@ -1515,4 +1515,10 @@ public class MonitorFanIdxController extends BaseController { ...@@ -1515,4 +1515,10 @@ public class MonitorFanIdxController extends BaseController {
// return ResponseHelper.buildResponse(hashMap); // return ResponseHelper.buildResponse(hashMap);
// } // }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "给部盾提供的发电率完成情况接口")
@GetMapping("/getGenPowerInfoForBuDun")
public ResponseModel<Map<String, String>> getGenPowerInfoForBuDun(@RequestParam(required = false) String areaCode,@RequestParam(required = false) String stationId) {
return ResponseHelper.buildResponse(monitoringService.getGenPowerInfoForBuDun(areaCode,stationId));
}
} }
...@@ -318,9 +318,8 @@ public class MonitoringMapController extends BaseController { ...@@ -318,9 +318,8 @@ public class MonitoringMapController extends BaseController {
wrapper.eq(areaCode!=null,StationBasic::getAreaCode,areaCode); wrapper.eq(areaCode!=null,StationBasic::getAreaCode,areaCode);
List<StationBasic> stationBasics = stationBasicMapper.selectList(wrapper); List<StationBasic> stationBasics = stationBasicMapper.selectList(wrapper);
// 2023年11月8日 12点51分 库中存储的历史数据存在问题逻辑由原来的通过网关id查询数据修改为场站id
List<String> ids = stationBasics.stream().map(StationBasic::getFanGatewayId).collect(Collectors.toList()); List<String> ids = stationBasics.stream().map(stationBasic -> String.valueOf(stationBasic.getSequenceNbr())).collect(Collectors.toList());
SeriesData map= largeScreenImpl.getSeriesDataqy( new Date(),ids, areaCode); SeriesData map= largeScreenImpl.getSeriesDataqy( new Date(),ids, areaCode);
......
...@@ -508,7 +508,7 @@ public class LargeScreenImpl { ...@@ -508,7 +508,7 @@ public class LargeScreenImpl {
public List<Double> gettimedateqy( Date date,List<String> gatewayId){ public List<Double> gettimedateqy( Date date,List<String> stationId){
SimpleDateFormat myFmt2=new SimpleDateFormat("yyyyMM"); SimpleDateFormat myFmt2=new SimpleDateFormat("yyyyMM");
String monthy= myFmt2.format(date); String monthy= myFmt2.format(date);
...@@ -517,7 +517,7 @@ public class LargeScreenImpl { ...@@ -517,7 +517,7 @@ public class LargeScreenImpl {
value.add(RSD); value.add(RSD);
Map<String,List<String>> map=new HashMap<>(); Map<String,List<String>> map=new HashMap<>();
map.put("equipmentIndexName.keyword",value); map.put("equipmentIndexName.keyword",value);
map.put("gatewayId.keyword", gatewayId); map.put("stationId.keyword", stationId);
List<String> value1=new ArrayList<>(); List<String> value1=new ArrayList<>();
value1.add(monthy); value1.add(monthy);
map.put("moon.keyword",value1); map.put("moon.keyword",value1);
......
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl; package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
...@@ -13,6 +14,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.dto.*; ...@@ -13,6 +14,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.dto.*;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IndicatorData; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IndicatorData;
import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper; import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper;
import lombok.Data; import lombok.Data;
import org.apache.commons.lang.StringUtils;
import org.checkerframework.checker.units.qual.min; import org.checkerframework.checker.units.qual.min;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -23,6 +25,7 @@ import org.springframework.stereotype.Service; ...@@ -23,6 +25,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils; import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
...@@ -93,40 +96,41 @@ public class MonitoringServiceImpl { ...@@ -93,40 +96,41 @@ public class MonitoringServiceImpl {
* 获取风站场站 * 获取风站场站
* *
* */ * */
public Map<String,String> getStationfs(StationBasic stationBasic) { public Map<String, String> getStationfs(StationBasic stationBasic) {
String value="0"; String value = "0";
Map<String,String> map=new HashMap<>(); Map<String, String> map = new HashMap<>();
Map<String, List<String>> queryCondtion = new HashMap<>(); Map<String, List<String>> queryCondtion = new HashMap<>();
if(stationBasic.getStationType().equals("FDZ")){ if (stationBasic.getStationType().equals("FDZ")) {
String gatewayId = stationBasic.getFanGatewayId(); String gatewayId = stationBasic.getFanGatewayId();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("30秒平均风速")); queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("30秒平均风速"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId)); queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
List<ESEquipments> result2 = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class); List<ESEquipments> result2 = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
value= String.format("%.2f", commonServiceImpl.getAvagerByEquipmentIndxName(result2, "30秒平均风速")); value = String.format("%.2f", commonServiceImpl.getAvagerByEquipmentIndxName(result2, "30秒平均风速"));
map.put("name","风速/辐照度"); map.put("name", "风速/辐照度");
map.put("value",value+"m/s"); map.put("value", value + "m/s");
}else{ } else {
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("WTX-801_25_WTX-801_总辐射")); queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("WTX-801_25_WTX-801_总辐射"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getBoosterGatewayId())); queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getBoosterGatewayId()));
List<ESEquipments> result1 = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class); List<ESEquipments> result1 = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
value= String.format("%.2f", commonServiceImpl.getSumByEquipmentIndxName(result1, "WTX-801_25_WTX-801_总辐射")); value = String.format("%.2f", commonServiceImpl.getSumByEquipmentIndxName(result1, "WTX-801_25_WTX-801_总辐射"));
map.put("name","风速/辐照度"); map.put("name", "风速/辐照度");
map.put("value",value+"W/㎡"); map.put("value", value + "W/㎡");
} }
return map; return map;
} }
/*** /***
* 电站容量 * 电站容量
* */ * */
public Map<String,String> getStationrl(StationBasic stationBasic) { public Map<String, String> getStationrl(StationBasic stationBasic) {
Double installCapacity = 0.0; Double installCapacity = 0.0;
installCapacity = this.SjglZsjZsbtzServiceImpl.getStationCapactityByStationWerks(stationBasic.getStationNumber()); installCapacity = this.SjglZsjZsbtzServiceImpl.getStationCapactityByStationWerks(stationBasic.getStationNumber());
String value= ObjectUtils.isEmpty(installCapacity) ? "0.00" :String.format("%.2f", installCapacity); String value = ObjectUtils.isEmpty(installCapacity) ? "0.00" : String.format("%.2f", installCapacity);
Map<String,String> map=new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("name","容量"); map.put("name", "容量");
map.put("value",value+"MW"); map.put("value", value + "MW");
return map; return map;
} }
...@@ -367,7 +371,6 @@ public class MonitoringServiceImpl { ...@@ -367,7 +371,6 @@ public class MonitoringServiceImpl {
// logger.error("-----------------发送区域实时生产数据消息=================== 失败!"); // logger.error("-----------------发送区域实时生产数据消息=================== 失败!");
// } // }
// } // }
public List<TabDto> getTabsByStationBasicId(String stationBasicId) { public List<TabDto> getTabsByStationBasicId(String stationBasicId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationBasicId); StationBasic stationBasic = stationBasicMapper.selectById(stationBasicId);
List<TabDto> tabDtoList = new ArrayList<>(); List<TabDto> tabDtoList = new ArrayList<>();
...@@ -489,8 +492,7 @@ public class MonitoringServiceImpl { ...@@ -489,8 +492,7 @@ public class MonitoringServiceImpl {
// } // }
public Map<String, Object> getDetailsWindSpeedAlldata(StationBasic stationBasic) {
public Map<String, Object> getDetailsWindSpeedAlldata(StationBasic stationBasic) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
List<String> values = new ArrayList<>(); List<String> values = new ArrayList<>();
Map<Date, Double> groupMap = new HashMap<>(); Map<Date, Double> groupMap = new HashMap<>();
...@@ -506,7 +508,7 @@ public class MonitoringServiceImpl { ...@@ -506,7 +508,7 @@ public class MonitoringServiceImpl {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
sdf.setTimeZone(TimeZone.getTimeZone("UTC")); sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
String startTime = sdf.format(currentDayStartTime); String startTime = sdf.format(currentDayStartTime);
String endTime= sdf.format(currentDayEndTime); String endTime = sdf.format(currentDayEndTime);
Double installedCapacity = commonServiceImpl.getStationCapactityByStationWerks(stationBasic.getStationNumber()); Double installedCapacity = commonServiceImpl.getStationCapactityByStationWerks(stationBasic.getStationNumber());
if ("FDZ".equals(stationBasic.getStationType())) { if ("FDZ".equals(stationBasic.getStationType())) {
...@@ -548,11 +550,10 @@ public class MonitoringServiceImpl { ...@@ -548,11 +550,10 @@ public class MonitoringServiceImpl {
} catch (Exception exception) { } catch (Exception exception) {
exception.printStackTrace(); exception.printStackTrace();
} }
return map; return map;
} }
public String getInstallCapity(List<StationBasic> stationBasicList) { public String getInstallCapity(List<StationBasic> stationBasicList) {
AtomicReference<Double> total = new AtomicReference<>(0.0); AtomicReference<Double> total = new AtomicReference<>(0.0);
stationBasicList.forEach(stationBasic -> { stationBasicList.forEach(stationBasic -> {
...@@ -733,7 +734,6 @@ public class MonitoringServiceImpl { ...@@ -733,7 +734,6 @@ public class MonitoringServiceImpl {
// hashMapPage.setRecords(hashMapList); // hashMapPage.setRecords(hashMapList);
// return hashMapPage; // return hashMapPage;
// } // }
public List<StationBasic> getListOfStationBasicByAreaName(String areaName) { public List<StationBasic> getListOfStationBasicByAreaName(String areaName) {
List<StationBasic> stationBasicListAll = new ArrayList<>(); List<StationBasic> stationBasicListAll = new ArrayList<>();
MapRegion mapRegion = mapRegionMapper.selectOne(new QueryWrapper<MapRegion>().eq("name", areaName)); MapRegion mapRegion = mapRegionMapper.selectOne(new QueryWrapper<MapRegion>().eq("name", areaName));
...@@ -900,15 +900,15 @@ public class MonitoringServiceImpl { ...@@ -900,15 +900,15 @@ public class MonitoringServiceImpl {
public void getTotalData() { public void getTotalData() {
//计算所有场站年计划完成量 //计算所有场站年计划完成量
int year = Calendar.getInstance().get(Calendar.YEAR); int year = Calendar.getInstance().get(Calendar.YEAR);
int Moon = Calendar.getInstance().get(Calendar.MONTH)+1; int Moon = Calendar.getInstance().get(Calendar.MONTH) + 1;
LambdaQueryWrapper<StationPlan> query = new LambdaQueryWrapper<>(); LambdaQueryWrapper<StationPlan> query = new LambdaQueryWrapper<>();
query.eq(StationPlan::getYear,String.valueOf(year)); query.eq(StationPlan::getYear, String.valueOf(year));
List<StationPlan> stationPlans = stationPlanMapper.selectList(query); List<StationPlan> stationPlans = stationPlanMapper.selectList(query);
double yearValue = stationPlans.stream().mapToDouble(StationPlan::getValue).sum(); double yearValue = stationPlans.stream().mapToDouble(StationPlan::getValue).sum();
double fdzValue = stationPlans.stream().filter(e -> e.getStationType().equals("FDZ")).mapToDouble(StationPlan::getValue).sum(); double fdzValue = stationPlans.stream().filter(e -> e.getStationType().equals("FDZ")).mapToDouble(StationPlan::getValue).sum();
double gfvalue = yearValue - fdzValue; double gfvalue = yearValue - fdzValue;
double moonValue = stationPlans.stream().filter(e ->e.getMonthly().equals(String.valueOf(Moon))).mapToDouble(StationPlan::getValue).sum(); double moonValue = stationPlans.stream().filter(e -> e.getMonthly().equals(String.valueOf(Moon))).mapToDouble(StationPlan::getValue).sum();
//查询风电站年计划完成量 //查询风电站年计划完成量
// //
...@@ -935,9 +935,9 @@ public class MonitoringServiceImpl { ...@@ -935,9 +935,9 @@ public class MonitoringServiceImpl {
//装机容量 //装机容量
HashMap<String, String> stringHashMap = new HashMap<>(); HashMap<String, String> stringHashMap = new HashMap<>();
BigDecimal totalInstall = new BigDecimal(getInstallCapity(stationBasicListAll)); BigDecimal totalInstall = new BigDecimal(getInstallCapity(stationBasicListAll));
// stringHashMap.put("title", totalInstall.toString()); // stringHashMap.put("title", totalInstall.toString());
//stringHashMap.put("data", ""); //stringHashMap.put("data", "");
// list.add(stringHashMap); // list.add(stringHashMap);
//风电站 //风电站
HashMap<String, String> stringHashMap1 = new HashMap<>(); HashMap<String, String> stringHashMap1 = new HashMap<>();
BigDecimal fdzInstall = new BigDecimal(getInstallCapity(fdzList)); BigDecimal fdzInstall = new BigDecimal(getInstallCapity(fdzList));
...@@ -970,10 +970,10 @@ public class MonitoringServiceImpl { ...@@ -970,10 +970,10 @@ public class MonitoringServiceImpl {
AtomicReference<Double> powerOfMonthGF = new AtomicReference<>(new Double(0.00)); AtomicReference<Double> powerOfMonthGF = new AtomicReference<>(new Double(0.00));
AtomicReference<Double> powerOfAnnualGF = new AtomicReference<>(new Double(0.00)); AtomicReference<Double> powerOfAnnualGF = new AtomicReference<>(new Double(0.00));
fdzList.forEach(stationBasic -> { fdzList.forEach(stationBasic -> {
Map<String,List<String>> queryCondtion = new HashMap<>(); Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName,Arrays.asList("日发电量","月发电量","年发电量")); queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("日发电量", "月发电量", "年发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId,Arrays.asList(stationBasic.getFanGatewayId())); queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion,null,ESEquipments.class); List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
// powerOfDayFD.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")); // powerOfDayFD.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量"));
// powerOfMonthFD.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")); // powerOfMonthFD.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量"));
// powerOfAnnualFD.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量")); // powerOfAnnualFD.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量"));
...@@ -985,9 +985,9 @@ public class MonitoringServiceImpl { ...@@ -985,9 +985,9 @@ public class MonitoringServiceImpl {
}); });
gfList.forEach(stationBasic -> { gfList.forEach(stationBasic -> {
Map<String,List<String>> queryCondtion = new HashMap<>(); Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName,CommonConstans.taiHeGenIndicator); queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, CommonConstans.taiHeGenIndicator);
queryCondtion.put(CommonConstans.QueryStringGateWayId,Arrays.asList(stationBasic.getBoosterGatewayId())); queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getBoosterGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class); List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
powerOfDayGF.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorDay)); powerOfDayGF.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorDay));
powerOfMonthGF.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorMonth)); powerOfMonthGF.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorMonth));
...@@ -997,35 +997,35 @@ public class MonitoringServiceImpl { ...@@ -997,35 +997,35 @@ public class MonitoringServiceImpl {
stringHashMap4.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfDayFD.get()) + "/" + String.format(CommonConstans.Twodecimalplaces, powerOfDayGF.get())); stringHashMap4.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfDayFD.get()) + "/" + String.format(CommonConstans.Twodecimalplaces, powerOfDayGF.get()));
list1.add(stringHashMap4); list1.add(stringHashMap4);
HashMap<String, String> stringHashMap5 = new HashMap<>(); HashMap<String, String> stringHashMap5 = new HashMap<>();
stringHashMap5.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfMonthFD.get()) + "/" + String.format(CommonConstans.Twodecimalplaces, powerOfMonthGF.get() )); stringHashMap5.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfMonthFD.get()) + "/" + String.format(CommonConstans.Twodecimalplaces, powerOfMonthGF.get()));
list1.add(stringHashMap5); list1.add(stringHashMap5);
HashMap<String, String> stringHashMap6 = new HashMap<>(); HashMap<String, String> stringHashMap6 = new HashMap<>();
stringHashMap6.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfAnnualFD.get()) + "/" + String.format(CommonConstans.Twodecimalplaces, powerOfAnnualGF.get() )); stringHashMap6.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfAnnualFD.get()) + "/" + String.format(CommonConstans.Twodecimalplaces, powerOfAnnualGF.get()));
list1.add(stringHashMap6); list1.add(stringHashMap6);
HashMap<String, String> stringHashMap7 = new HashMap<>(); HashMap<String, String> stringHashMap7 = new HashMap<>();
stringHashMap7.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfAnnualFD.get()/fdzValue ) + "/" + String.format(CommonConstans.Twodecimalplaces, powerOfAnnualGF.get()/gfvalue)); stringHashMap7.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfAnnualFD.get() / fdzValue) + "/" + String.format(CommonConstans.Twodecimalplaces, powerOfAnnualGF.get() / gfvalue));
list1.add(stringHashMap7); list1.add(stringHashMap7);
HashMap<String, String> stringHashMap8 = new HashMap<>(); HashMap<String, String> stringHashMap8 = new HashMap<>();
stringHashMap8.put("title", String.format(CommonConstans.Twodecimalplaces, (powerOfAnnualFD.get() * CommonConstans.wkwhToMv) / fdzInstall.doubleValue()) + "/" + String.format(CommonConstans.Twodecimalplaces, (powerOfAnnualGF.get() * CommonConstans.wkwhToMv) / gfInstall.doubleValue())); stringHashMap8.put("title", String.format(CommonConstans.Twodecimalplaces, (powerOfAnnualFD.get() * CommonConstans.wkwhToMv) / fdzInstall.doubleValue()) + "/" + String.format(CommonConstans.Twodecimalplaces, (powerOfAnnualGF.get() * CommonConstans.wkwhToMv) / gfInstall.doubleValue()));
list1.add(stringHashMap8); list1.add(stringHashMap8);
page1.setRecords(list1); page1.setRecords(list1);
HashMap<String, String> stringHashMap9 = new HashMap<>(); HashMap<String, String> stringHashMap9 = new HashMap<>();
stringHashMap9.put("title", String.format(CommonConstans.Fourdecimalplaces, powerOfDayFD.get() + powerOfDayGF.get() )); stringHashMap9.put("title", String.format(CommonConstans.Fourdecimalplaces, powerOfDayFD.get() + powerOfDayGF.get()));
HashMap<String, String> resultMap = new HashMap<>(); HashMap<String, String> resultMap = new HashMap<>();
resultMap.put("Day", String.format(CommonConstans.Fourdecimalplaces, powerOfDayFD.get() + powerOfDayGF.get())); resultMap.put("Day", String.format(CommonConstans.Fourdecimalplaces, powerOfDayFD.get() + powerOfDayGF.get()));
list2.add(stringHashMap9); list2.add(stringHashMap9);
HashMap<String, String> stringHashMap10 = new HashMap<>(); HashMap<String, String> stringHashMap10 = new HashMap<>();
stringHashMap10.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfMonthFD.get() + powerOfMonthGF.get())); stringHashMap10.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfMonthFD.get() + powerOfMonthGF.get()));
resultMap.put("Moon", String.format(CommonConstans.Fourdecimalplaces, powerOfMonthFD.get() + powerOfMonthGF.get() )); resultMap.put("Moon", String.format(CommonConstans.Fourdecimalplaces, powerOfMonthFD.get() + powerOfMonthGF.get()));
resultMap.put("YJHWC", String.format(CommonConstans.Twodecimalplaces, (powerOfMonthFD.get() + powerOfMonthGF.get())/moonValue* 100)); resultMap.put("YJHWC", String.format(CommonConstans.Twodecimalplaces, (powerOfMonthFD.get() + powerOfMonthGF.get()) / moonValue * 100));
list2.add(stringHashMap10); list2.add(stringHashMap10);
HashMap<String, String> stringHashMap11 = new HashMap<>(); HashMap<String, String> stringHashMap11 = new HashMap<>();
stringHashMap11.put("title", String.format(CommonConstans.Fourdecimalplaces, powerOfAnnualFD.get() + powerOfAnnualGF.get())); stringHashMap11.put("title", String.format(CommonConstans.Fourdecimalplaces, powerOfAnnualFD.get() + powerOfAnnualGF.get()));
resultMap.put("Year",String.format(CommonConstans.Fourdecimalplaces, powerOfAnnualFD.get() + powerOfAnnualGF.get())); resultMap.put("Year", String.format(CommonConstans.Fourdecimalplaces, powerOfAnnualFD.get() + powerOfAnnualGF.get()));
list2.add(stringHashMap11); list2.add(stringHashMap11);
HashMap<String, String> stringHashMap12 = new HashMap<>(); HashMap<String, String> stringHashMap12 = new HashMap<>();
stringHashMap12.put("title", String.format(CommonConstans.Twodecimalplaces, (powerOfAnnualFD.get() + powerOfAnnualGF.get()) /yearValue* 100)); stringHashMap12.put("title", String.format(CommonConstans.Twodecimalplaces, (powerOfAnnualFD.get() + powerOfAnnualGF.get()) / yearValue * 100));
resultMap.put("NJHWC",String.format(CommonConstans.Twodecimalplaces, (powerOfAnnualFD.get() + powerOfAnnualGF.get()) /yearValue* 100)); resultMap.put("NJHWC", String.format(CommonConstans.Twodecimalplaces, (powerOfAnnualFD.get() + powerOfAnnualGF.get()) / yearValue * 100));
list2.add(stringHashMap12); list2.add(stringHashMap12);
page2.setRecords(list2); page2.setRecords(list2);
Double totalAnnual = (powerOfAnnualFD.get() + powerOfAnnualGF.get()); Double totalAnnual = (powerOfAnnualFD.get() + powerOfAnnualGF.get());
...@@ -1038,13 +1038,13 @@ public class MonitoringServiceImpl { ...@@ -1038,13 +1038,13 @@ public class MonitoringServiceImpl {
stringHashMap14.put("unit", "节约标准煤(t)"); stringHashMap14.put("unit", "节约标准煤(t)");
list3.add(stringHashMap14); list3.add(stringHashMap14);
HashMap<String, String> stringHashMap15 = new HashMap<>(); HashMap<String, String> stringHashMap15 = new HashMap<>();
stringHashMap15.put("title", String.format(CommonConstans.Twodecimalplaces, (totalAnnual * CommonConstans.toner ))); stringHashMap15.put("title", String.format(CommonConstans.Twodecimalplaces, (totalAnnual * CommonConstans.toner)));
stringHashMap15.put("unit", "碳粉尘减排量(t)"); stringHashMap15.put("unit", "碳粉尘减排量(t)");
list3.add(stringHashMap15); list3.add(stringHashMap15);
HashMap<String, String> stringHashMap16 = new HashMap<>(); HashMap<String, String> stringHashMap16 = new HashMap<>();
stringHashMap16.put("title", String.format(CommonConstans.Twodecimalplaces, (totalAnnual * CommonConstans.sulfurDioxide ))); stringHashMap16.put("title", String.format(CommonConstans.Twodecimalplaces, (totalAnnual * CommonConstans.sulfurDioxide)));
stringHashMap16.put("unit", "二氧化硫减排量(t)"); stringHashMap16.put("unit", "二氧化硫减排量(t)");
list3.add(stringHashMap16); list3.add(stringHashMap16);
page3.setRecords(list3); page3.setRecords(list3);
try { try {
emqKeeper.getMqttClient().publish("bigscreen_zjrl_topic", JSON.toJSON(page).toString().getBytes("UTF-8"), 1, true); emqKeeper.getMqttClient().publish("bigscreen_zjrl_topic", JSON.toJSON(page).toString().getBytes("UTF-8"), 1, true);
...@@ -1130,7 +1130,7 @@ public class MonitoringServiceImpl { ...@@ -1130,7 +1130,7 @@ public class MonitoringServiceImpl {
// ] // ]
// }; // };
public HashMap<String, Object> getTheStationPowerCurve(String stationId,String date) { public HashMap<String, Object> getTheStationPowerCurve(String stationId, String date) {
HashMap<String, Object> result = new HashMap<>(); HashMap<String, Object> result = new HashMap<>();
List<HashMap<String, Object>> hashMapList = new ArrayList<>(); List<HashMap<String, Object>> hashMapList = new ArrayList<>();
StationBasic stationBasic = stationBasicMapper.selectById(stationId); StationBasic stationBasic = stationBasicMapper.selectById(stationId);
...@@ -1150,21 +1150,21 @@ public class MonitoringServiceImpl { ...@@ -1150,21 +1150,21 @@ public class MonitoringServiceImpl {
} }
result.put("xData", xdata); result.put("xData", xdata);
HashMap<String, Object> currentPowerHashMap = new HashMap<>(); HashMap<String, Object> currentPowerHashMap = new HashMap<>();
currentPowerHashMap.put("title", "实时有功 " +date); currentPowerHashMap.put("title", "实时有功 " + date);
currentPowerHashMap.put("yData", currentPowerYdata); currentPowerHashMap.put("yData", currentPowerYdata);
result.put("currentPower", currentPowerHashMap); result.put("currentPower", currentPowerHashMap);
HashMap<String, Object> shortPowerHashMap = new HashMap<>(); HashMap<String, Object> shortPowerHashMap = new HashMap<>();
shortPowerHashMap.put("title", "短期功率预测 "+date); shortPowerHashMap.put("title", "短期功率预测 " + date);
shortPowerHashMap.put("yData", currentPowerYdata); shortPowerHashMap.put("yData", currentPowerYdata);
result.put("shortPower", shortPowerHashMap); result.put("shortPower", shortPowerHashMap);
HashMap<String, Object> superShortPowerHashMap = new HashMap<>(); HashMap<String, Object> superShortPowerHashMap = new HashMap<>();
superShortPowerHashMap.put("title", "超短期功率预测 "+ date); superShortPowerHashMap.put("title", "超短期功率预测 " + date);
superShortPowerHashMap.put("yData", currentPowerYdata); superShortPowerHashMap.put("yData", currentPowerYdata);
result.put("superShortPower", superShortPowerHashMap); result.put("superShortPower", superShortPowerHashMap);
HashMap<String, Object> footerList = new HashMap<>(); HashMap<String, Object> footerList = new HashMap<>();
String currentMin = String.format("%.2f",currentPowerYdata.stream().mapToDouble(Double::parseDouble).min().getAsDouble()); String currentMin = String.format("%.2f", currentPowerYdata.stream().mapToDouble(Double::parseDouble).min().getAsDouble());
String shortMin = String.format("%.2f",shortPowerYdata.stream().mapToDouble(Double::parseDouble).min().getAsDouble()); String shortMin = String.format("%.2f", shortPowerYdata.stream().mapToDouble(Double::parseDouble).min().getAsDouble());
String supreMin = String.format("%.2f",superPowerShortYdata.stream().mapToDouble(Double::parseDouble).min().getAsDouble()); String supreMin = String.format("%.2f", superPowerShortYdata.stream().mapToDouble(Double::parseDouble).min().getAsDouble());
List<String> gz = new ArrayList<>(); List<String> gz = new ArrayList<>();
List<String> sj1 = new ArrayList<>(); List<String> sj1 = new ArrayList<>();
gz.add(currentMin); gz.add(currentMin);
...@@ -1174,9 +1174,9 @@ public class MonitoringServiceImpl { ...@@ -1174,9 +1174,9 @@ public class MonitoringServiceImpl {
gz.add(supreMin); gz.add(supreMin);
sj1.add(xdata.get(superPowerShortYdata.indexOf(supreMin))); sj1.add(xdata.get(superPowerShortYdata.indexOf(supreMin)));
String currentMax = String.format("%.2f",currentPowerYdata.stream().mapToDouble(Double::parseDouble).max().getAsDouble()); String currentMax = String.format("%.2f", currentPowerYdata.stream().mapToDouble(Double::parseDouble).max().getAsDouble());
String shortMax = String.format("%.2f",shortPowerYdata.stream().mapToDouble(Double::parseDouble).max().getAsDouble()); String shortMax = String.format("%.2f", shortPowerYdata.stream().mapToDouble(Double::parseDouble).max().getAsDouble());
String supreMax = String.format("%.2f",superPowerShortYdata.stream().mapToDouble(Double::parseDouble).max().getAsDouble()); String supreMax = String.format("%.2f", superPowerShortYdata.stream().mapToDouble(Double::parseDouble).max().getAsDouble());
List<String> zdz = new ArrayList<>(); List<String> zdz = new ArrayList<>();
List<String> sj2 = new ArrayList<>(); List<String> sj2 = new ArrayList<>();
zdz.add(currentMax); zdz.add(currentMax);
...@@ -1208,4 +1208,62 @@ public class MonitoringServiceImpl { ...@@ -1208,4 +1208,62 @@ public class MonitoringServiceImpl {
public Double keepFourdecimalPlaces(Double param) { public Double keepFourdecimalPlaces(Double param) {
return Double.valueOf(String.format("%.4f", param)); return Double.valueOf(String.format("%.4f", param));
} }
public Map<String, String> getGenPowerInfoForBuDun(String areaCode, String stationId) {
HashMap<String, String> returnResult = new HashMap<>();
returnResult.put("monthCompleteRate", "0.00%");
returnResult.put("monthValue", "0.0000");
returnResult.put("monthPlanValue", "0.0000");
returnResult.put("yearCompleteRate", "0.00%");
returnResult.put("yearValue", "0.0000");
returnResult.put("yearPlanValue", "0.0000");
List<StationCacheInfoDto> stationCacheInfoDtos = commonServiceImpl.getListStationCacheInfoDto();
if (StringUtils.isNotBlank(areaCode)) {
stationCacheInfoDtos = stationCacheInfoDtos.stream().filter(stationCacheInfoDto -> stationCacheInfoDto.getAreaCode().equals(areaCode)).collect(Collectors.toList());
}
if (StringUtils.isNotBlank(stationId)) {
stationCacheInfoDtos = stationCacheInfoDtos.stream().filter(stationCacheInfoDto -> stationCacheInfoDto.getStationId().equals(stationId)).collect(Collectors.toList());
}
//月发电量
AtomicReference<Double> monthlyPower = new AtomicReference<>(0.0);
//年发电量
AtomicReference<Double> annualPower = new AtomicReference<>(0.0);
for (StationCacheInfoDto stationCacheInfoDto : stationCacheInfoDtos) {
if ("FDZ".equals(stationCacheInfoDto.getStationType())) {
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("月发电量", "年发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
monthlyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")));
annualPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量")));
} else {
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, CommonConstans.taiHeGenIndicator);
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getBoosterGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
monthlyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorMonth)));
annualPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorYear)));
}
}
List<String> stationIds = stationCacheInfoDtos.stream().map(StationCacheInfoDto::getStationId).collect(Collectors.toList());
List<StationPlan> stationPlans = stationPlanMapper.selectList(new QueryWrapper<StationPlan>().in("station_basic_id", stationIds));
String currentYearAndMonth = DateUtil.format(new Date(), DatePattern.NORM_MONTH_PATTERN);
String currentYear = currentYearAndMonth.split("-")[0];
Integer currentMonth = Integer.valueOf(currentYearAndMonth.split("-")[1]);
Double yearPlanValue = stationPlans.stream().filter(stationPlan -> stationPlan.getYear().equals(currentYear)).mapToDouble(i -> i.getValue()).sum();
Double monthPlanValue = stationPlans.stream().filter(stationPlan -> currentMonth == Integer.valueOf(stationPlan.getMonthly())).mapToDouble(i -> i.getValue()).sum();
if (monthlyPower.get() > 0 && monthPlanValue > 0) {
returnResult.put("monthCompleteRate", String.format(CommonConstans.Twodecimalplaces, (monthlyPower.get() / monthPlanValue) * 100) + "%");
returnResult.put("monthValue", String.format(CommonConstans.Fourdecimalplaces, monthlyPower.get()));
returnResult.put("monthPlanValue", String.format(CommonConstans.Fourdecimalplaces, monthPlanValue));
}
if (annualPower.get() > 0 && yearPlanValue > 0) {
returnResult.put("yearCompleteRate", String.format(CommonConstans.Twodecimalplaces, (annualPower.get() / yearPlanValue) * 100) + "%");
returnResult.put("yearValue", String.format(CommonConstans.Fourdecimalplaces, annualPower.get()));
returnResult.put("yearPlanValue", String.format(CommonConstans.Fourdecimalplaces, yearPlanValue));
}
return returnResult;
}
} }
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