Commit 8d87161f authored by zhangsen's avatar zhangsen

td相关

parent 0b90ed8d
package com.yeejoin.amos.boot.module.jxiop.biz.controller; package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.FanHealthIndexDto; 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.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.FanHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvHealthIndexMapper; 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.FanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex; 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.ObjectUtils;
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;
...@@ -33,6 +42,15 @@ public class TdInfoQueryController { ...@@ -33,6 +42,15 @@ public class TdInfoQueryController {
@Autowired @Autowired
private PvHealthIndexMapper pvHealthIndexMapper; private PvHealthIndexMapper pvHealthIndexMapper;
@Autowired
IdxBizFanHealthLevelMapper idxBizFanHealthLevelMapper;
@Autowired
IdxBizPvHealthLevelMapper idxBizPvHealthLevelMapper;
@Autowired
IdxBizFanHealthIndexMapper idxBizFanHealthIndexMapper;
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/getFanHealthIndexInfo") @GetMapping(value = "/getFanHealthIndexInfo")
...@@ -79,4 +97,231 @@ public class TdInfoQueryController { ...@@ -79,4 +97,231 @@ public class TdInfoQueryController {
resultPage.setTotal(infoByPageTotal); resultPage.setTotal(infoByPageTotal);
return ResponseHelper.buildResponse(resultPage); return ResponseHelper.buildResponse(resultPage);
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "全景诊断回溯")
@GetMapping("/getFullViewRecall")
public ResponseModel<List<FullViewRecallInfoDTO>> getFullViewRecall(@RequestParam(required = false, value = "analysisType") String analysisType) {
List<Map<String, Object>> stationIndexInfo = idxBizFanHealthIndexMapper.getStationIndexInfoByParam(analysisType);
Map<String, Double> stationHealthIndexMap = stationIndexInfo.stream().collect(Collectors.toMap(t -> t.get("station").toString(), t -> Double.parseDouble(t.get("healthIndex").toString())));
List<Map<String, Object>> equipmentIndexInfo = idxBizFanHealthIndexMapper.getEquipmentIndexInfoByParam(analysisType);
Map<String, Double> equipmentIndexInfoMap = equipmentIndexInfo.stream().collect(Collectors.toMap(t -> t.get("equipmentName").toString(), t -> Double.parseDouble(t.get("healthIndex").toString())));
List<Map<String, Object>> subSystemIndexInfo = idxBizFanHealthIndexMapper.getSubSystemIndexInfoByParam(analysisType);
Map<String, Double> subSystemIndexInfoMap = subSystemIndexInfo.stream().collect(Collectors.toMap(t -> t.get("subSystem").toString(), t -> Double.parseDouble(t.get("healthIndex").toString())));
List<Map<String, Object>> pointNameIndexInfo = idxBizFanHealthIndexMapper.getPointNameIndexInfoByParam(analysisType);
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;
Double healthScoreInfo = idxBizFanHealthIndexMapper.getHealthScoreInfoByParam(null, null, analysisType).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.setScoreRange("");
allMapDto.setStatus(idxBizFanHealthLevel.getHealthLevel());
allMapDto.setScore(healthScoreInfo);
allMapDto.setIsRoot(true);
allMapDto.setCategory("category");
allMapDto.setChildren(new ArrayList<>());
allMapDto.setParentKey("0");
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.getHealthScoreInfoByParam(areaMap.getKey(), null, analysisType).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.setStatus(areaIdxBizFanHealthLevel.getHealthLevel());
areaMapDto.setScore(areaHealthScoreInfo);
areaMapDto.setParentKey(allMapDto.getKey());
allMapDto.getChildren().add(areaMapDto);
areaInt++;
List<FullViewRecallInfoDTO> areaMapList = new ArrayList<>();
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.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, stationDto.getScore());
stationQuery.ge(IdxBizFanHealthLevel::getGroupUpperLimit, stationDto.getScore());
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, stationDto.getScore());
stationPvQuery.ge(IdxBizPvHealthLevel::getGroupUpperLimit, stationDto.getScore());
IdxBizPvHealthLevel stationPvLevel = idxBizPvHealthLevelMapper.selectOne(stationPvQuery);
if (ObjectUtils.isNotEmpty(stationPvLevel)) {
stationDto.setStatus(stationPvLevel.getHealthLevel());
}
}
stationDto.setParentKey(areaMapDto.getKey());
areaMapDto.getChildren().add(stationDto);
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.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));
equipmentMapDto.setParentKey(stationDto.getKey());
stationDto.getChildren().add(equipmentMapDto);
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.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));
subSystemMapDto.setParentKey(equipmentMapDto.getKey());
equipmentMapDto.getChildren().add(subSystemMapDto);
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.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));
pointNameMapDto.setParentKey(subSystemMapDto.getKey());
subSystemMapDto.getChildren().add(pointNameMapDto);
pointNameInt++;
}
}
}
stationDto.setScoreRange("(最高:" + stationLowScore + "分, 最低:" + stationHighScore + "分)");
}
areaMapDto.setScoreRange("(最高:" + areaLowScore + "分, 最低:" + areaHighScore + "分)");
}
List<FullViewRecallInfoDTO> resultList = new ArrayList<>();
resultList.add(allMapDto);
return ResponseHelper.buildResponse(resultList);
}
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 = "光伏站";
break;
}
}
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;
}
} }
...@@ -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);
} }
...@@ -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;
...@@ -1733,7 +1737,7 @@ public class CommonServiceImpl { ...@@ -1733,7 +1737,7 @@ public class CommonServiceImpl {
*/ */
@Async @Async
public void insertFanDataTDEngine(ArrayList<FanHealthIndex> fanHealthIndices, String recDate, String analysisType) { public void insertFanDataTDEngine(ArrayList<FanHealthIndex> fanHealthIndices, String recDate, String analysisType) {
fanHealthIndexMapper.deleteAllDataByTableName("fan_health_index_latest_data", "按时刻"); 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++) {
...@@ -1742,7 +1746,7 @@ public class CommonServiceImpl { ...@@ -1742,7 +1746,7 @@ public class CommonServiceImpl {
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", analysisType); fanHealthIndexMapper.saveBatchHealthIndexList(newList, "fan_health_index_moment", analysisType);
fanHealthIndexMapper.saveBatchHealthIndexLatestInfo(newList, "fan_health_index_latest_data"); idxFanHealthIndexMapper.saveBatchHealthIndexLatestInfo(newList);
newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入 newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入
} }
} }
...@@ -2004,7 +2008,7 @@ public class CommonServiceImpl { ...@@ -2004,7 +2008,7 @@ public class CommonServiceImpl {
@Async @Async
public void insertPvDataTDEngine(ArrayList<PvHealthIndex> pvHealthIndices, String recDate, String analysisType) { public void insertPvDataTDEngine(ArrayList<PvHealthIndex> pvHealthIndices, String recDate, String analysisType) {
fanHealthIndexMapper.deleteAllDataByTableName("fan_health_index_latest_data", analysisType); idxFanHealthIndexMapper.deleteAllDataByTableName("pv_health_index_latest_data", analysisType);
// 按时刻 - 测点插入 // 按时刻 - 测点插入
ArrayList<PvHealthIndex> newList = new ArrayList<>(); ArrayList<PvHealthIndex> newList = new ArrayList<>();
...@@ -2014,7 +2018,7 @@ public class CommonServiceImpl { ...@@ -2014,7 +2018,7 @@ public class CommonServiceImpl {
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", analysisType); pvHealthIndexMapper.saveBatchHealthIndexList(newList, "pv_health_index_moment", analysisType);
pvHealthIndexMapper.saveBatchHealthIndexLatestInfo(newList, "fan_health_index_latest_data"); idxFanHealthIndexMapper.saveBatchHealthIndexLatestInfoPv(newList);
newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入 newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入
} }
} }
......
...@@ -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;
...@@ -34,6 +35,10 @@ public class TdengineTimeServiceImpl { ...@@ -34,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
...@@ -78,7 +83,7 @@ public class TdengineTimeServiceImpl { ...@@ -78,7 +83,7 @@ public class TdengineTimeServiceImpl {
if (!openHealth) { if (!openHealth) {
return; return;
} }
fanHealthIndexMapper.deleteAllDataByTableName("fan_health_index_latest_data", "按小时"); 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);
...@@ -112,7 +117,7 @@ public class TdengineTimeServiceImpl { ...@@ -112,7 +117,7 @@ public class TdengineTimeServiceImpl {
if (!openHealth) { if (!openHealth) {
return; return;
} }
fanHealthIndexMapper.deleteAllDataByTableName("fan_health_index_latest_data", "按天"); 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"));
...@@ -166,7 +171,7 @@ public class TdengineTimeServiceImpl { ...@@ -166,7 +171,7 @@ public class TdengineTimeServiceImpl {
if (500 == newList.size() || i == fanHealthIndices.size() - 1) { //载体list达到要求,进行批量操作 if (500 == newList.size() || i == fanHealthIndices.size() - 1) { //载体list达到要求,进行批量操作
//调用批量插入 //调用批量插入
fanHealthIndexMapper.saveBatchHealthIndexList(newList, tableName, analysisType); fanHealthIndexMapper.saveBatchHealthIndexList(newList, tableName, analysisType);
fanHealthIndexMapper.saveBatchHealthIndexLatestInfo(newList, "fan_health_index_latest_data"); idxFanHealthIndexMapper.saveBatchHealthIndexLatestInfo(newList);
newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入 newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入
} }
} }
...@@ -203,7 +208,7 @@ public class TdengineTimeServiceImpl { ...@@ -203,7 +208,7 @@ public class TdengineTimeServiceImpl {
if (!openHealth) { if (!openHealth) {
return; return;
} }
fanHealthIndexMapper.deleteAllDataByTableName("pv_health_index_latest_data", "按小时"); 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);
...@@ -237,7 +242,7 @@ public class TdengineTimeServiceImpl { ...@@ -237,7 +242,7 @@ public class TdengineTimeServiceImpl {
if (!openHealth) { if (!openHealth) {
return; return;
} }
fanHealthIndexMapper.deleteAllDataByTableName("pv_health_index_latest_data", "按天"); 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);
...@@ -290,7 +295,7 @@ public class TdengineTimeServiceImpl { ...@@ -290,7 +295,7 @@ public class TdengineTimeServiceImpl {
if (500 == newList.size() || i == pvHealthIndices.size() - 1) { //载体list达到要求,进行批量操作 if (500 == newList.size() || i == pvHealthIndices.size() - 1) { //载体list达到要求,进行批量操作
//调用批量插入 //调用批量插入
pvHealthIndexMapper.saveBatchHealthIndexList(newList, tableName, analysisType); pvHealthIndexMapper.saveBatchHealthIndexList(newList, tableName, analysisType);
pvHealthIndexMapper.saveBatchHealthIndexLatestInfo(newList, "pv_health_index_latest_data"); idxFanHealthIndexMapper.saveBatchHealthIndexLatestInfoPv(newList);
newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入 newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入
} }
} }
......
...@@ -27,9 +27,9 @@ public interface FanHealthIndexMapper extends BaseMapper<FanHealthIndex> { ...@@ -27,9 +27,9 @@ public interface FanHealthIndexMapper extends BaseMapper<FanHealthIndex> {
int saveBatchHealthIndexList(@Param("list") List<FanHealthIndex> list, @Param("tableName") String tableName, @Param("analysisType") String analysisType); 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); // int saveBatchHealthIndexLatestInfo(@Param("list") List<FanHealthIndex> list, @Param("tableName") String tableName);
//
void deleteAllDataByTableName(@Param("tableName") String tableName, @Param("analysisType") String analysisType); // void deleteAllDataByTableName(@Param("tableName") String tableName, @Param("analysisType") String analysisType);
/** /**
* 测点 * 测点
......
...@@ -31,7 +31,7 @@ public interface PvHealthIndexMapper extends BaseMapper<PvHealthIndex> { ...@@ -31,7 +31,7 @@ public interface PvHealthIndexMapper extends BaseMapper<PvHealthIndex> {
int saveBatchHealthIndexList(@Param("list") List<PvHealthIndex> list, @Param("tableName") String tableName, @Param("analysisType") String analysisType); 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); // 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,
......
...@@ -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 = '按天'
...@@ -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>
...@@ -224,6 +224,6 @@ ...@@ -224,6 +224,6 @@
</select> </select>
<delete id="deleteAllDataByTableName"> <delete id="deleteAllDataByTableName">
delete * from ${tableName} where analysis_type = #{analysisType} delete from ${tableName} where analysis_type = #{analysisType}
</delete> </delete>
</mapper> </mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment