|
|
@ -3,27 +3,47 @@ package com.hnac.hzims.operational.alert.service.impl; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.alert.constants.AbnormalAlarmConstant; |
|
|
|
import com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity; |
|
|
|
import com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity; |
|
|
|
import com.hnac.hzims.operational.alert.mapper.HistoryAbnormalAlarmMapper; |
|
|
|
import com.hnac.hzims.operational.alert.mapper.HistoryAbnormalAlarmMapper; |
|
|
|
import com.hnac.hzims.operational.alert.service.HistoryAbnormalAlarmService; |
|
|
|
import com.hnac.hzims.operational.alert.service.HistoryAbnormalAlarmService; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.config.entity.StAlarmRecordEntity; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.config.vo.AlarmDataPageVo; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.config.vo.AlarmVo; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.config.vo.IntelligentAlarmCountVo; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.config.vo.SoeBodyVo; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.main.vo.AreaMonthReportVo; |
|
|
|
import com.hnac.hzims.operational.maintenance.constants.HomePageConstant; |
|
|
|
import com.hnac.hzims.operational.maintenance.constants.HomePageConstant; |
|
|
|
import com.hnac.hzims.operational.station.entity.StationEntity; |
|
|
|
import com.hnac.hzims.operational.station.entity.StationEntity; |
|
|
|
import com.hnac.hzims.operational.station.service.IStationService; |
|
|
|
import com.hnac.hzims.operational.station.service.IStationService; |
|
|
|
import com.hnac.hzims.operational.station.vo.HistoryAbnormalAlarmVo; |
|
|
|
import com.hnac.hzims.operational.station.vo.HistoryAbnormalAlarmVo; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.datasearch.soe.ISoeClient; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.datasearch.soe.domian.SoeData; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.datasearch.soe.domian.SoeQueryConditionByStation; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import net.logstash.logback.encoder.org.apache.commons.lang3.ObjectUtils; |
|
|
|
import net.logstash.logback.encoder.org.apache.commons.lang3.ObjectUtils; |
|
|
|
import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils; |
|
|
|
import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
|
|
|
|
import org.springblade.core.mp.support.BladePage; |
|
|
|
import org.springblade.core.mp.support.Condition; |
|
|
|
import org.springblade.core.mp.support.Condition; |
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.utils.BeanUtil; |
|
|
|
import org.springblade.core.tool.utils.BeanUtil; |
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
|
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
|
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
|
|
|
|
import org.springblade.core.tool.utils.ObjectUtil; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
|
|
|
import org.springframework.data.domain.Page; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Field; |
|
|
|
import java.lang.reflect.Field; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
@ -37,6 +57,11 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno |
|
|
|
|
|
|
|
|
|
|
|
private final IStationService stationService; |
|
|
|
private final IStationService stationService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final ISoeClient alarmClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${hzims.operation.alarm.types}") |
|
|
|
|
|
|
|
private String types; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 查询单条历史告警 |
|
|
|
* 查询单条历史告警 |
|
|
|
* |
|
|
|
* |
|
|
@ -154,6 +179,110 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno |
|
|
|
return historyAbnormalAlarmEntityIPage; |
|
|
|
return historyAbnormalAlarmEntityIPage; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 告警数量:时间范围-当天 |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public List<IntelligentAlarmCountVo> alarmCount() { |
|
|
|
|
|
|
|
// 步骤1.查询用户权限站点
|
|
|
|
|
|
|
|
List<StationEntity> stations = stationService.list(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 步骤2.查询告警数据
|
|
|
|
|
|
|
|
SoeQueryConditionByStation condition = new SoeQueryConditionByStation(); |
|
|
|
|
|
|
|
DateTimeFormatter format = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
condition.setBeginTime(LocalDateTime.parse(/*DateUtil.format(new Date(), DateUtil.PATTERN_DATE) +*/ "2022-12-01 00:00:00", format)); |
|
|
|
|
|
|
|
condition.setEndTime(LocalDateTime.parse(/*DateUtil.format(new Date(), DateUtil.PATTERN_DATE) +*/ "2022-12-28 00:00:00", format)); |
|
|
|
|
|
|
|
condition.setNeedPage(false); |
|
|
|
|
|
|
|
condition.setStationIds(stations.stream().filter(station->StringUtils.isNotEmpty(station.getCode())).map(StationEntity::getCode).collect(Collectors.toList())); |
|
|
|
|
|
|
|
// nacos中配置告警类型:"0-默认", "1-系统", "2-告警", "3-故障", "4-用户操作", "5-遥测越限", "6-遥信变位", "7-注册信息",
|
|
|
|
|
|
|
|
// "8-信息提示", "9-设备巡检", "10-遥控操作", "11-遥测越限恢复","12-未定义","13-通讯中断","14-数据异常"
|
|
|
|
|
|
|
|
condition.setTypes(Arrays.asList(types.split(","))); |
|
|
|
|
|
|
|
R<BladePage<SoeData>> result = alarmClient.getByStationsAndTime(condition); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 步骤3. TODO 过滤已处理告警
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 步骤4.遍历获取
|
|
|
|
|
|
|
|
return Arrays.asList(types.split(",")).stream().map(type->{ |
|
|
|
|
|
|
|
IntelligentAlarmCountVo count = new IntelligentAlarmCountVo(); |
|
|
|
|
|
|
|
count.setType(type); |
|
|
|
|
|
|
|
count.setName(AbnormalAlarmConstant.TYPE_NAMES[Integer.valueOf(type)]); |
|
|
|
|
|
|
|
if(result.isSuccess() && !ObjectUtil.isEmpty(result.getData())){ |
|
|
|
|
|
|
|
count.setCount(result.getData().getRecords().stream().filter(record->type.equals(record.getSoeType())).count()); |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
count.setCount(0L); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return count; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 告警数据:时间范围-当天 |
|
|
|
|
|
|
|
* @param param |
|
|
|
|
|
|
|
* @param query |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public IPage<AlarmVo> alarmData(AlarmDataPageVo param,Query query) { |
|
|
|
|
|
|
|
// 步骤1.查询用户权限站点
|
|
|
|
|
|
|
|
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery(); |
|
|
|
|
|
|
|
if(StringUtils.isNotEmpty(param.getCode())){ |
|
|
|
|
|
|
|
wappers.eq(StationEntity::getCode,param.getCode()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<StationEntity> stations = stationService.list(wappers); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 步骤2.查询告警数据
|
|
|
|
|
|
|
|
List<String> type_list; |
|
|
|
|
|
|
|
if(Optional.ofNullable(param.getType()).isPresent()){ |
|
|
|
|
|
|
|
type_list = Collections.singletonList(param.getType()); |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
type_list = Collections.singletonList(Arrays.asList(types.split(",")).get(0)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SoeQueryConditionByStation condition = new SoeQueryConditionByStation(); |
|
|
|
|
|
|
|
DateTimeFormatter format = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
condition.setBeginTime(LocalDateTime.parse(/*DateUtil.format(new Date(), DateUtil.PATTERN_DATE) +*/ "2022-12-01 00:00:00", format)); |
|
|
|
|
|
|
|
condition.setEndTime(LocalDateTime.parse(/*DateUtil.format(new Date(), DateUtil.PATTERN_DATE) +*/ "2022-12-28 00:00:00", format)); |
|
|
|
|
|
|
|
condition.setNeedPage(false); |
|
|
|
|
|
|
|
condition.setStationIds(stations.stream().filter(station->StringUtils.isNotEmpty(station.getCode())).map(StationEntity::getCode).collect(Collectors.toList())); |
|
|
|
|
|
|
|
// nacos中配置告警类型:"0-默认", "1-系统", "2-告警", "3-故障", "4-用户操作", "5-遥测越限", "6-遥信变位", "7-注册信息",
|
|
|
|
|
|
|
|
// "8-信息提示", "9-设备巡检", "10-遥控操作", "11-遥测越限恢复","12-未定义","13-通讯中断","14-数据异常"
|
|
|
|
|
|
|
|
condition.setTypes(type_list); |
|
|
|
|
|
|
|
R<BladePage<SoeData>> result = alarmClient.getByStationsAndTime(condition); |
|
|
|
|
|
|
|
IPage<AlarmVo> page = Condition.getPage(query); |
|
|
|
|
|
|
|
if(result.isSuccess() && ObjectUtil.isNotEmpty(result)){ |
|
|
|
|
|
|
|
// 步骤3.TODO 过滤完成告警处理数据
|
|
|
|
|
|
|
|
List<AlarmVo> alarms = result.getData().getRecords().stream().map(record ->{ |
|
|
|
|
|
|
|
AlarmVo alarm = new AlarmVo(); |
|
|
|
|
|
|
|
alarm.setId(record.getId()); |
|
|
|
|
|
|
|
alarm.setContent(record.getSoeExplain()); |
|
|
|
|
|
|
|
alarm.setRealId(record.getRealId()); |
|
|
|
|
|
|
|
alarm.setTs(record.getTs()); |
|
|
|
|
|
|
|
alarm.setSoeStatus(record.getSoeStatus()); |
|
|
|
|
|
|
|
alarm.setSoeType(AbnormalAlarmConstant.TYPE_NAMES[Integer.valueOf(record.getSoeType())]); |
|
|
|
|
|
|
|
alarm.setOptionvals(record.getOptionvals()); |
|
|
|
|
|
|
|
alarm.setSoeStatus(record.getSoeStatus()); |
|
|
|
|
|
|
|
alarm.setStation(record.getStation()); |
|
|
|
|
|
|
|
List<String> names = stations.stream().filter(station -> station.getCode().equals(record.getStation())).map(StationEntity::getName).collect(Collectors.toList()); |
|
|
|
|
|
|
|
if(CollectionUtil.isNotEmpty(names)){ |
|
|
|
|
|
|
|
alarm.setStationName(names.get(0)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return alarm; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 步骤4.分页
|
|
|
|
|
|
|
|
page.setTotal(alarms.size()); |
|
|
|
|
|
|
|
page.setRecords(alarms.stream().sorted(Comparator.comparing(AlarmVo::getTs,Comparator.reverseOrder())) |
|
|
|
|
|
|
|
.skip((long) page.getSize() * (page.getCurrent() - 1)).limit(page.getSize()) |
|
|
|
|
|
|
|
.collect(Collectors.toList())); |
|
|
|
|
|
|
|
page.setPages((alarms.size() -1) / page.getSize() + 1); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
page.setTotal(0); |
|
|
|
|
|
|
|
page.setPages(0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return page; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Boolean entityIsNull(Object object) { |
|
|
|
private Boolean entityIsNull(Object object) { |
|
|
|
if (null == object) { |
|
|
|
if (null == object) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|