|
@@ -1,5 +1,8 @@
|
|
|
package org.jeecg.modules.leanEventWarn.service.impl;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.jeecg.common.util.DateUtils;
|
|
|
import org.jeecg.modules.common.enums.EDeviceInformationType;
|
|
|
import org.jeecg.modules.events.entity.LeanEventsHost;
|
|
|
import org.jeecg.modules.gatherData.entity.FpgStatiscsModelMongodb;
|
|
@@ -23,6 +26,7 @@ import org.springframework.data.mongodb.core.query.Query;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
@@ -32,10 +36,7 @@ import java.time.Instant;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Calendar;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -44,6 +45,7 @@ import java.util.stream.Collectors;
|
|
|
* @Date: 2024-10-29
|
|
|
* @Version: V1.0
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoMapper, LeanEventWarnInfo> implements ILeanEventWarnInfoService {
|
|
|
|
|
@@ -60,6 +62,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
ISystemVariableService systemVariableService;
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void openDeviceTriggerWarnInfo(FpgGatherData fpgGatherData) {
|
|
|
LeanEventWarnInfo leanEventWarnInfo = new LeanEventWarnInfo();
|
|
|
leanEventWarnInfo.setDeviceRegionId(fpgGatherData.getDeviceRegionId());
|
|
@@ -73,6 +76,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
queryWrapper.eq("status", 0);
|
|
|
SystemVariable systemVariable = systemVariableService.getOne(queryWrapper);
|
|
|
if (systemVariable == null){
|
|
|
+ log.info("{}{}", "host_open系统变量未配置正常状态的运行电流限制!", JSON.toJSON(fpgGatherData));
|
|
|
return;
|
|
|
}
|
|
|
BigDecimal limitCurrent = new BigDecimal(systemVariable.getDefaultValue());
|
|
@@ -88,6 +92,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void stopDeviceTriggerWarnInfo(FpgGatherData fpgGatherData) {
|
|
|
LeanEventWarnInfo leanEventWarnInfo = new LeanEventWarnInfo();
|
|
|
leanEventWarnInfo.setDeviceRegionId(fpgGatherData.getDeviceRegionId());
|
|
@@ -100,12 +105,13 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
queryWrapper.eq("status", 0);
|
|
|
SystemVariable systemVariable = systemVariableService.getOne(queryWrapper);
|
|
|
if (systemVariable == null){
|
|
|
+ log.info("{}{}", "host_stop系统变量未配置正常状态的运行电流限制!", JSON.toJSON(fpgGatherData));
|
|
|
return;
|
|
|
}
|
|
|
BigDecimal limitCurrent = new BigDecimal(systemVariable.getDefaultValue());
|
|
|
if (fpgGatherData.getRunCurrent().compareTo(limitCurrent) > 0){
|
|
|
// 上报告警信息
|
|
|
- leanEventWarnInfo.setDeviceWarnInfo("HOST_CLOSE状态下,辅设备电流大于5A,触发告警!");
|
|
|
+ leanEventWarnInfo.setDeviceWarnInfo("HOST_CLOSE状态下,辅设备电流大于" + limitCurrent + "A,触发告警!");
|
|
|
leanEventWarnInfo.setWarnType(EDeviceInformationType.HOST_STOP.getCode());
|
|
|
leanEventWarnInfo.setDeviceWarnLevel("0");
|
|
|
// 更新或者新增逻辑处理
|
|
@@ -114,6 +120,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void openFpgTriggerWarnInfo(FpgGatherData fpgGatherData) {
|
|
|
LeanEventWarnInfo leanEventWarnInfo = new LeanEventWarnInfo();
|
|
|
leanEventWarnInfo.setDeviceRegionId(fpgGatherData.getDeviceRegionId());
|
|
@@ -135,6 +142,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
queryWrapper.eq("status", 0);
|
|
|
SystemVariable systemVariable = systemVariableService.getOne(queryWrapper);
|
|
|
if (systemVariable == null){
|
|
|
+ log.info("{}{}", "fpg_open系统变量未配置正常状态的运行电流限制!", JSON.toJSON(fpgGatherData));
|
|
|
return;
|
|
|
}
|
|
|
BigDecimal limitCurrent = new BigDecimal(systemVariable.getDefaultValue());
|
|
@@ -146,7 +154,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
boolean topsIsExit = topsNewPeaksAndValleysTimeConfigList.stream().anyMatch(a -> containsCreateTime(localDateTime, a.getStartTime(), a.getEndTime()));
|
|
|
if (topsIsExit && fpgGatherData.getRunCurrent().compareTo(limitCurrent) < 0){
|
|
|
// 采集到的数据电流小于5A,上报告警信息
|
|
|
- leanEventWarnInfo.setDeviceWarnInfo("FPG_OPEN状态下,尖时段采集到的数据电流小于5A,触发告警!");
|
|
|
+ leanEventWarnInfo.setDeviceWarnInfo("FPG_OPEN状态下,尖时段采集到的数据电流小于" + limitCurrent + "A,触发告警!");
|
|
|
leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_OPEN.getCode());
|
|
|
leanEventWarnInfo.setDeviceWarnLevel("0");
|
|
|
// 更新或者新增逻辑处理
|
|
@@ -155,7 +163,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
boolean peaksIsExit = peaksNewPeaksAndValleysTimeConfigList.stream().anyMatch(a -> containsCreateTime(localDateTime, a.getStartTime(), a.getEndTime()));
|
|
|
if (peaksIsExit && fpgGatherData.getRunCurrent().compareTo(limitCurrent) < 0){
|
|
|
// 采集到的数据电流小于5A,上报告警信息
|
|
|
- leanEventWarnInfo.setDeviceWarnInfo("FPG_OPEN状态下,峰时段采集到的数据电流小于5A,触发告警!");
|
|
|
+ leanEventWarnInfo.setDeviceWarnInfo("FPG_OPEN状态下,峰时段采集到的数据电流小于" + limitCurrent + "A,触发告警!");
|
|
|
leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_OPEN.getCode());
|
|
|
leanEventWarnInfo.setDeviceWarnLevel("0");
|
|
|
// 更新或者新增逻辑处理
|
|
@@ -164,7 +172,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
boolean flatIsExit = flatNewPeaksAndValleysTimeConfigList.stream().anyMatch(a -> containsCreateTime(localDateTime, a.getStartTime(), a.getEndTime()));
|
|
|
if (flatIsExit && fpgGatherData.getRunCurrent().compareTo(limitCurrent) < 0){
|
|
|
// 采集到的数据电流小于5A,上报告警信息
|
|
|
- leanEventWarnInfo.setDeviceWarnInfo("FPG_OPEN状态下,平时段采集到的数据电流小于5A,触发告警!");
|
|
|
+ leanEventWarnInfo.setDeviceWarnInfo("FPG_OPEN状态下,平时段采集到的数据电流小于" + limitCurrent + "A,触发告警!");
|
|
|
leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_OPEN.getCode());
|
|
|
leanEventWarnInfo.setDeviceWarnLevel("0");
|
|
|
// 更新或者新增逻辑处理
|
|
@@ -173,7 +181,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
boolean valleysIsExit = valleysNewPeaksAndValleysTimeConfigList.stream().anyMatch(a -> containsCreateTime(localDateTime, a.getStartTime(), a.getEndTime()));
|
|
|
if (valleysIsExit && fpgGatherData.getRunCurrent().compareTo(limitCurrent) < 0){
|
|
|
// 采集到的数据电流小于5A,上报告警信息
|
|
|
- leanEventWarnInfo.setDeviceWarnInfo("FPG_OPEN状态下,谷时段采集到的数据电流小于5A,触发告警!");
|
|
|
+ leanEventWarnInfo.setDeviceWarnInfo("FPG_OPEN状态下,谷时段采集到的数据电流小于" + limitCurrent + "A,触发告警!");
|
|
|
leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_OPEN.getCode());
|
|
|
leanEventWarnInfo.setDeviceWarnLevel("0");
|
|
|
// 更新或者新增逻辑处理
|
|
@@ -202,6 +210,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void closeFpgTriggerWarnInfo(FpgGatherData fpgGatherData) {
|
|
|
LeanEventWarnInfo leanEventWarnInfo = new LeanEventWarnInfo();
|
|
|
leanEventWarnInfo.setDeviceRegionId(fpgGatherData.getDeviceRegionId());
|
|
@@ -225,6 +234,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
queryWrapper.eq("status", 0);
|
|
|
SystemVariable systemVariable = systemVariableService.getOne(queryWrapper);
|
|
|
if (systemVariable == null){
|
|
|
+ log.info("{}{}", "fpg_close系统变量未配置正常状态的运行电流限制!", JSON.toJSON(fpgGatherData));
|
|
|
return;
|
|
|
}
|
|
|
BigDecimal limitCurrent = new BigDecimal(systemVariable.getDefaultValue());
|
|
@@ -234,7 +244,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
boolean topsIsExit = topsNewPeaksAndValleysTimeConfigList.stream().anyMatch(a -> containsCreateTime(localDateTime, a.getStartTime(), a.getEndTime()));
|
|
|
if (topsIsExit && fpgGatherData.getRunCurrent().compareTo(limitCurrent) > 0){
|
|
|
// 采集到的数据电流大于5A,上报告警信息
|
|
|
- leanEventWarnInfo.setDeviceWarnInfo("FPG_CLOSE状态下,采集到的数据电流大于5A,触发告警!");
|
|
|
+ leanEventWarnInfo.setDeviceWarnInfo("FPG_CLOSE状态下,尖采集到的数据电流大于" + limitCurrent + "A,触发告警!");
|
|
|
leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_CLOSE.getCode());
|
|
|
leanEventWarnInfo.setDeviceWarnLevel("0");
|
|
|
// 更新或者新增逻辑处理
|
|
@@ -243,7 +253,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
boolean peaksIsExit = peaksNewPeaksAndValleysTimeConfigList.stream().anyMatch(a -> containsCreateTime(localDateTime, a.getStartTime(), a.getEndTime()));
|
|
|
if (peaksIsExit && fpgGatherData.getRunCurrent().compareTo(limitCurrent) > 0){
|
|
|
// 采集到的数据电流大于5A,上报告警信息
|
|
|
- leanEventWarnInfo.setDeviceWarnInfo("FPG_CLOSE状态下,采集到的数据电流大于5A,触发告警!");
|
|
|
+ leanEventWarnInfo.setDeviceWarnInfo("FPG_CLOSE状态下,峰采集到的数据电流大于" + limitCurrent + "A,触发告警!");
|
|
|
leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_CLOSE.getCode());
|
|
|
leanEventWarnInfo.setDeviceWarnLevel("0");
|
|
|
// 更新或者新增逻辑处理
|
|
@@ -252,7 +262,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
boolean flatIsExit = flatNewPeaksAndValleysTimeConfigList.stream().anyMatch(a -> containsCreateTime(localDateTime, a.getStartTime(), a.getEndTime()));
|
|
|
if (flatIsExit && fpgGatherData.getRunCurrent().compareTo(limitCurrent) > 0){
|
|
|
// 采集到的数据电流大于5A,上报告警信息
|
|
|
- leanEventWarnInfo.setDeviceWarnInfo("FPG_CLOSE状态下,采集到的数据电流大于5A,触发告警!");
|
|
|
+ leanEventWarnInfo.setDeviceWarnInfo("FPG_CLOSE状态下,平采集到的数据电流大于" + limitCurrent + "A,触发告警!");
|
|
|
leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_CLOSE.getCode());
|
|
|
leanEventWarnInfo.setDeviceWarnLevel("0");
|
|
|
// 更新或者新增逻辑处理
|
|
@@ -261,7 +271,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
boolean valleysIsExit = valleysNewPeaksAndValleysTimeConfigList.stream().anyMatch(a -> containsCreateTime(localDateTime, a.getStartTime(), a.getEndTime()));
|
|
|
if (valleysIsExit && fpgGatherData.getRunCurrent().compareTo(limitCurrent) > 0){
|
|
|
// 采集到的数据电流大于5A,上报告警信息
|
|
|
- leanEventWarnInfo.setDeviceWarnInfo("FPG_CLOSE状态下,采集到的数据电流大于5A,触发精益事件告警!");
|
|
|
+ leanEventWarnInfo.setDeviceWarnInfo("FPG_CLOSE状态下,谷采集到的数据电流大于" + limitCurrent + "A,触发告警!");
|
|
|
leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_CLOSE.getCode());
|
|
|
leanEventWarnInfo.setDeviceWarnLevel("0");
|
|
|
// 更新或者新增逻辑处理
|
|
@@ -270,6 +280,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void runTimeTriggerWarnInfo(FpgGatherData fpgGatherData, LeanEventsHost leanEventsHost) {
|
|
|
LeanEventWarnInfo leanEventWarnInfo = new LeanEventWarnInfo();
|
|
|
leanEventWarnInfo.setDeviceRegionId(fpgGatherData.getDeviceRegionId());
|
|
@@ -283,6 +294,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
.eq(LeanEventsHostConfig::getEventsId, leanEventsHost.getEventsId()).eq(LeanEventsHostConfig::getLimitType, "0");
|
|
|
LeanEventsHostConfig leanEventsHostConfig = leanEventsHostConfigService.list(queryWrapper).stream().findFirst().orElse(null);
|
|
|
if (leanEventsHostConfig == null){
|
|
|
+ log.info("{}{}", "fpg_ing_time精益事件配置关联表查询为空!", "设备ID:" +fpgGatherData.getDeviceInformationId() + "事件ID:" + leanEventsHost.getEventsId());
|
|
|
return;
|
|
|
}
|
|
|
// 获取峰平谷配置的时段
|
|
@@ -301,6 +313,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
// 根据类型、采集点ID、设备ID、区域ID、峰平谷配置时间范围查询mongoDB
|
|
|
List<FpgStatiscsModelMongodb> fpgStatiscsModelDataList = queryByTimeRanges(mongoTemplate, timeRanges, fpgGatherData.getDevicePointId(), fpgGatherData.getDeviceInformationId(), fpgGatherData.getDeviceRegionId());
|
|
|
if (oConvertUtils.listIsEmpty(fpgStatiscsModelDataList) ){
|
|
|
+ log.info("{}{}", "fpg_ing_time峰平谷数据采集FpgStatiscsModelMongodb查询为空!", "设备ID:" +fpgGatherData.getDeviceInformationId() + "采集点ID:" + fpgGatherData.getDevicePointId()+ "区域ID:" + fpgGatherData.getDevicePointId());
|
|
|
return;
|
|
|
}
|
|
|
// 判断MongoDB中的累加运行时长是否大于 LeanEventsHostConfig中的尖峰平谷运行限制时长
|
|
@@ -310,7 +323,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(60), 0, RoundingMode.CEILING);
|
|
|
if (topsIngTimeSum.intValue() > runTimeLimit){
|
|
|
// 尖——累加运行时长超过限制时长,触发告警
|
|
|
- leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_ING_TIME,尖运行时长超过限制时长,触发告警!");
|
|
|
+ leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_ING_TIME,尖运行时长超过限制时长" + runTimeLimit + ",触发告警!");
|
|
|
leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_ING_TIME.getCode());
|
|
|
leanEventWarnInfo.setDeviceWarnLevel("0");
|
|
|
// 更新或者新增逻辑处理
|
|
@@ -321,7 +334,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(60), 0, RoundingMode.CEILING);
|
|
|
if (peaksIngTimeSum.intValue() > runTimeLimit){
|
|
|
// 峰——累加运行时长超过限制时长,触发告警
|
|
|
- leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_ING_TIME,峰运行时长超过限制时长,触发告警!");
|
|
|
+ leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_ING_TIME,峰运行时长超过限制时长" + runTimeLimit + ",触发告警!");
|
|
|
leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_ING_TIME.getCode());
|
|
|
leanEventWarnInfo.setDeviceWarnLevel("0");
|
|
|
// 更新或者新增逻辑处理
|
|
@@ -332,7 +345,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(60), 0, RoundingMode.CEILING);
|
|
|
if (flatIngTimeSum.intValue() > runTimeLimit){
|
|
|
// 平——累加运行时长超过限制时长,触发告警
|
|
|
- leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_ING_TIME,平运行时长超过限制时长,触发告警!");
|
|
|
+ leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_ING_TIME,平运行时长超过限制时长" + runTimeLimit + ",触发告警!");
|
|
|
leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_ING_TIME.getCode());
|
|
|
leanEventWarnInfo.setDeviceWarnLevel("0");
|
|
|
// 更新或者新增逻辑处理
|
|
@@ -343,7 +356,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(60), 0, RoundingMode.CEILING);
|
|
|
if (valleysIngTimeSum.intValue() > runTimeLimit){
|
|
|
// 谷——累加运行时长超过限制时长,触发告警
|
|
|
- leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_ING_TIME,谷运行时长超过限制时长,触发告警!");
|
|
|
+ leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_ING_TIME,谷运行时长超过限制时长" + runTimeLimit + ",触发告警!");
|
|
|
leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_ING_TIME.getCode());
|
|
|
leanEventWarnInfo.setDeviceWarnLevel("0");
|
|
|
// 更新或者新增逻辑处理
|
|
@@ -353,6 +366,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void powerLimitTriggerWarnInfo(FpgGatherData fpgGatherData, LeanEventsHost leanEventsHost) {
|
|
|
LeanEventWarnInfo leanEventWarnInfo = new LeanEventWarnInfo();
|
|
|
leanEventWarnInfo.setDeviceRegionId(fpgGatherData.getDeviceRegionId());
|
|
@@ -366,6 +380,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
.eq(LeanEventsHostConfig::getEventsId, leanEventsHost.getEventsId()).eq(LeanEventsHostConfig::getLimitType, "1");
|
|
|
LeanEventsHostConfig leanEventsHostConfig = leanEventsHostConfigService.list(queryWrapper).stream().findFirst().orElse(null);
|
|
|
if (leanEventsHostConfig == null){
|
|
|
+ log.info("{}{}", "fpg_power_limit精益事件配置关联表查询为空!", "设备ID:" +fpgGatherData.getDeviceInformationId() + "事件ID:" + leanEventsHost.getEventsId());
|
|
|
return;
|
|
|
}
|
|
|
// 获取峰平谷配置的时段
|
|
@@ -384,49 +399,46 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
// 根据类型、采集点ID、设备ID、区域ID、峰平谷配置时间范围查询mongoDB
|
|
|
List<FpgStatiscsModelMongodb> fpgStatiscsModelDataList = queryByTimeRanges(mongoTemplate, timeRanges, fpgGatherData.getDevicePointId(), fpgGatherData.getDeviceInformationId(), fpgGatherData.getDeviceRegionId());
|
|
|
if (oConvertUtils.listIsEmpty(fpgStatiscsModelDataList) ){
|
|
|
+ log.info("{}{}", "fpg_power_limit峰平谷数据采集FpgStatiscsModelMongodb查询为空!", "设备ID:" +fpgGatherData.getDeviceInformationId() + "采集点ID:" + fpgGatherData.getDevicePointId()+ "区域ID:" + fpgGatherData.getDevicePointId());
|
|
|
return;
|
|
|
}
|
|
|
// 判断MongoDB中的累加运行时长是否大于 LeanEventsHostConfig中的尖峰平谷运行限制时长
|
|
|
int powerLimit = Integer.parseInt(leanEventsHostConfig.getPowerLimit());
|
|
|
if("tops".equals(leanEventsHost.getDeviceInformationId())){
|
|
|
- BigDecimal topsPowerLimitSum = fpgStatiscsModelDataList.stream().map(FpgStatiscsModelMongodb::getTopsPower)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(60), 0, RoundingMode.CEILING);
|
|
|
+ BigDecimal topsPowerLimitSum = fpgStatiscsModelDataList.stream().map(FpgStatiscsModelMongodb::getTopsPower).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
if (topsPowerLimitSum.intValue() > powerLimit){
|
|
|
// 尖——累加累计功率超过功率限制,触发告警
|
|
|
- leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_POWER_LIMIT,尖累计功率超过功率限制,触发告警!");
|
|
|
+ leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_POWER_LIMIT,尖累计功率超过功率限制" + powerLimit +"A,触发告警!");
|
|
|
leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_POWER_LIMIT.getCode());
|
|
|
leanEventWarnInfo.setDeviceWarnLevel("0");
|
|
|
// 更新或者新增逻辑处理
|
|
|
saveOrUpdateLeanEventWarnInfo(fpgGatherData, leanEventWarnInfo);
|
|
|
}
|
|
|
}else if ("peaks".equals(leanEventsHost.getDeviceInformationId())){
|
|
|
- BigDecimal peaksPowerLimitSum = fpgStatiscsModelDataList.stream().map(FpgStatiscsModelMongodb::getPeaksPower)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(60), 0, RoundingMode.CEILING);
|
|
|
+ BigDecimal peaksPowerLimitSum = fpgStatiscsModelDataList.stream().map(FpgStatiscsModelMongodb::getPeaksPower).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
if (peaksPowerLimitSum.intValue() > powerLimit){
|
|
|
// 峰——累加累计功率超过功率限制,触发告警
|
|
|
- leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_POWER_LIMIT,峰累计功率超过功率限制,触发告警!");
|
|
|
+ leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_POWER_LIMIT,峰累计功率超过功率限制" + powerLimit +"A,触发告警!");
|
|
|
leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_POWER_LIMIT.getCode());
|
|
|
leanEventWarnInfo.setDeviceWarnLevel("0");
|
|
|
// 更新或者新增逻辑处理
|
|
|
saveOrUpdateLeanEventWarnInfo(fpgGatherData, leanEventWarnInfo);
|
|
|
}
|
|
|
}else if ("flat".equals(leanEventsHost.getDeviceInformationId())){
|
|
|
- BigDecimal flatPowerLimitSum = fpgStatiscsModelDataList.stream().map(FpgStatiscsModelMongodb::getFlatPower)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(60), 0, RoundingMode.CEILING);
|
|
|
+ BigDecimal flatPowerLimitSum = fpgStatiscsModelDataList.stream().map(FpgStatiscsModelMongodb::getFlatPower).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
if (flatPowerLimitSum.intValue() > powerLimit){
|
|
|
// 平——累加累计功率超过功率限制,触发告警
|
|
|
- leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_POWER_LIMIT,平累计功率超过功率限制,触发告警!");
|
|
|
+ leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_POWER_LIMIT,平累计功率超过功率限制" + powerLimit +"A,触发告警!");
|
|
|
leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_POWER_LIMIT.getCode());
|
|
|
leanEventWarnInfo.setDeviceWarnLevel("0");
|
|
|
// 更新或者新增逻辑处理
|
|
|
saveOrUpdateLeanEventWarnInfo(fpgGatherData, leanEventWarnInfo);
|
|
|
}
|
|
|
} else if ("valleys".equals(leanEventsHost.getDeviceInformationId())) {
|
|
|
- BigDecimal valleysPowerLimitSum = fpgStatiscsModelDataList.stream().map(FpgStatiscsModelMongodb::getValleysPower)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(60), 0, RoundingMode.CEILING);
|
|
|
+ BigDecimal valleysPowerLimitSum = fpgStatiscsModelDataList.stream().map(FpgStatiscsModelMongodb::getValleysPower).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
if (valleysPowerLimitSum.intValue() > powerLimit){
|
|
|
// 谷——累加累计功率超过功率限制,触发告警
|
|
|
- leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_POWER_LIMIT,谷累计功率超过功率限制,触发精益事件告警!");
|
|
|
+ leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_POWER_LIMIT,谷累计功率超过功率限制" + powerLimit +"A,触发告警!");
|
|
|
leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_POWER_LIMIT.getCode());
|
|
|
leanEventWarnInfo.setDeviceWarnLevel("0");
|
|
|
// 更新或者新增逻辑处理
|
|
@@ -446,29 +458,25 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
|
|
|
*/
|
|
|
public List<FpgStatiscsModelMongodb> queryByTimeRanges(MongoTemplate mongoTemplate, List<Date[]> timeRanges, String devicePointId, String deviceInformationId, String deviceRegionId) {
|
|
|
Query query = new Query();
|
|
|
- query.addCriteria(Criteria.where("devicePointId").is(devicePointId));
|
|
|
+ String devicePointIds = Arrays.stream(devicePointId.split(",")).collect(Collectors.joining("|"));
|
|
|
+ // 设置devicePointId的查询条件,使用正则表达式
|
|
|
+ query.addCriteria(Criteria.where("devicePointId").regex(devicePointIds));
|
|
|
query.addCriteria(Criteria.where("deviceInformationId").is(deviceInformationId));
|
|
|
query.addCriteria(Criteria.where("deviceRegionId").is(deviceRegionId));
|
|
|
// 使用Criteria添加多个时间范围条件
|
|
|
for (int i = 0; i < timeRanges.size(); i++) {
|
|
|
Date startTime = timeRanges.get(i)[0];
|
|
|
- // 加8小时
|
|
|
- Calendar calendar1 = Calendar.getInstance();
|
|
|
- calendar1.setTime(startTime);
|
|
|
- calendar1.add(Calendar.HOUR, 8);
|
|
|
- Date specifiedTimePlus8HoursStartTime = calendar1.getTime();
|
|
|
Date endTime = timeRanges.get(i)[1];
|
|
|
- Calendar calendar2 = Calendar.getInstance();
|
|
|
- calendar2.setTime(endTime);
|
|
|
- calendar2.add(Calendar.HOUR, 8);
|
|
|
- Date specifiedTimePlus8HoursStartEndTime = calendar2.getTime();
|
|
|
+ // 加8小时
|
|
|
+ Date specifiedTimePlus8HoursStartTime = DateUtils.addHours(startTime, 8);
|
|
|
+ Date specifiedTimePlus8HoursStartEndTime = DateUtils.addHours(endTime, 8);
|
|
|
query.addCriteria(Criteria.where("createTime").gte(specifiedTimePlus8HoursStartTime).lt(specifiedTimePlus8HoursStartEndTime));
|
|
|
}
|
|
|
+ log.info("{}{}", "查询FpgStatiscsModelMongodb模型参数:", query);
|
|
|
// 执行查询
|
|
|
List<FpgStatiscsModelMongodb> fpgStatiscsModelDataList = mongoTemplate.find(query, FpgStatiscsModelMongodb.class, "leanmodel_run_power_current_minute");
|
|
|
return fpgStatiscsModelDataList;
|
|
|
}
|
|
|
-
|
|
|
/**
|
|
|
* 处理峰平谷的配置,并拼接开始时间和结束时间
|
|
|
* @param peaksAndValleysTimeConfigParam
|