Browse Source

#告警处理

zhongwei
yang_shj 2 years ago
parent
commit
0ca88f2ac6
  1. 3
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java
  2. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/HandleQueryVo.java
  3. 1
      hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/dto/FdpMonitorBindingDTO.java
  4. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/HistoryAbnormalAlarmMapper.java
  5. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/HistoryAbnormalAlarmMapper.xml
  6. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/HistoryAbnormalAlarmService.java
  7. 22
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java
  8. 10
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java
  9. 9
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/scheduled/StAlamRecordTask.java
  10. 10
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

3
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java

@ -10,10 +10,11 @@ public interface AbnormalAlarmConstant {
List<String> TYPE_LIST = Arrays.asList("13","14");
/**通讯恢复*/
String ABNORMAL_STATUS = "1";
String TYPE_NAMES[] = {"默认", "系统", "告警", "故障", "用户操作", "遥测越限", "遥信变位", "注册信息", "信息提示", "设备巡检", "遥控操作", "遥测越限恢复","未定义","通讯中断","数据异常"};
/**处理、延后、误报*/
List<Long> HANDLE_WAY = Arrays.asList(0L,1L,2L);
List<Long> HANDLE_WAY = Arrays.asList(1L,2L,3L,4l);
}

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/HandleQueryVo.java

@ -22,6 +22,6 @@ public class HandleQueryVo {
@ApiModelProperty("结束时间")
private Date endTime;
@ApiModelProperty("处理类型:0-处理 1-延后 2-误报")
@ApiModelProperty("处理类型:1-延后 2-误报 3-缺陷 4-检修")
private Long handleWay;
}

1
hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/dto/FdpMonitorBindingDTO.java

@ -1,7 +1,6 @@
package com.hnac.hzims.monitor.dto;
import com.hnac.hzims.fdp.entity.FdpMonitorEntity;
import com.hnac.hzinfo.dataconfig.entity.AnalyzeInstanceField;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeInstanceFieldVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/HistoryAbnormalAlarmMapper.java

@ -16,7 +16,7 @@ import java.util.List;
*/
public interface HistoryAbnormalAlarmMapper extends UserDataScopeBaseMapper<HistoryAbnormalAlarmEntity> {
HistoryAbnormalAlarmEntity getHistoryAbnormalAlarm(@Param("stationId") String stationId,@Param("type") String type,@Param("startTime") Date ts);
List<HistoryAbnormalAlarmEntity> getHistoryAbnormalAlarm(@Param("stationId") String stationId,@Param("type") String type);
List<HistoryAbnormalAlarmVo> selectPageList(IPage<HistoryAbnormalAlarmVo> page, String type, List<String> stations);

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/HistoryAbnormalAlarmMapper.xml

@ -6,7 +6,7 @@
select * from hzims_history_abnormal_alarm
where station_id = #{stationId}
and type = #{type}
and start_time = #{startTime}
and status = 0
</select>
<select id="selectPageList" resultType="com.hnac.hzims.operational.station.vo.HistoryAbnormalAlarmVo">

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/HistoryAbnormalAlarmService.java

@ -19,7 +19,7 @@ import java.util.List;
*/
public interface HistoryAbnormalAlarmService extends BaseService<HistoryAbnormalAlarmEntity> {
HistoryAbnormalAlarmEntity getAbnormalAlarm(String station, String soeType, Date ts);
HistoryAbnormalAlarmEntity getAbnormalAlarm(String station, String soeType);
IPage<HistoryAbnormalAlarmVo> list(IPage<HistoryAbnormalAlarmVo> page, String type);

22
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AbnormalAlarmServiceImpl.java

@ -61,9 +61,9 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl<AbnormalAlarmMappe
query.setTypes(AbnormalAlarmConstant.TYPE_LIST);
query.setStationIds(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
Calendar calendar = Calendar.getInstance();
query.setEndTime(LocalDateTime.parse(DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME), df));
query.setEndTime(LocalDateTime.parse(/*DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME)*/"2022-12-30 00:00:00", df));
calendar.add(Calendar.MINUTE,-2);
query.setBeginTime(LocalDateTime.parse(DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME), df));
query.setBeginTime(LocalDateTime.parse(/*DateUtil.format(calendar.getTime() , DateUtil.PATTERN_DATETIME)*/"2022-12-01 00:00:00", df));
query.setNeedPage(false);
log.error("alarm_data_handle_param : {}",query);
R<BladePage<SoeData>> result = soeClient.getByStationsAndTime(query);
@ -103,6 +103,7 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl<AbnormalAlarmMappe
queryEntity.setStationName(stationName);
queryEntity.setType(item.getSoeType());
queryEntity.setStartTime(queryEntity.getStartTime());
queryEntity.setUpdateTime(new Date());
queryEntity.setEndTime(null);
queryEntity.setStatus(0);
if(flag){
@ -137,10 +138,12 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl<AbnormalAlarmMappe
private String saveHistoryAlarm(List<SoeData> list,List<StationEntity> stations) {
list.forEach(item -> {
Date ts = DateUtil.parse(DateUtil.format(item.getTs(),DateUtil.PATTERN_DATETIME),DateUtil.DATETIME_FORMAT);
HistoryAbnormalAlarmEntity queryEntity = this.historyAbnormalAlarmService.getAbnormalAlarm(item.getStation(),item.getSoeType(),ts);
String stationName = Optional.ofNullable(stations.stream().filter(o-> o.getCode().equals(item.getStation())).collect(Collectors.toList())).map(o->o.get(0).getName()).orElse(null);
// 历史数据异常查询
HistoryAbnormalAlarmEntity queryEntity = this.historyAbnormalAlarmService.getAbnormalAlarm(item.getStation(),item.getSoeType());
// 数据中断恢复
boolean flag = AbnormalAlarmConstant.ABNORMAL_STATUS.equals(item.getSoeAlarmType());
if(ObjectUtil.isEmpty(queryEntity)){
String stationName = Optional.ofNullable(stations.stream().filter(o-> o.getCode().equals(item.getStation())).collect(Collectors.toList())).map(o->o.get(0).getName()).orElse(null);
if(ObjectUtil.isEmpty(queryEntity) || !flag){
HistoryAbnormalAlarmEntity entity = new HistoryAbnormalAlarmEntity();
entity.setStationId(item.getStation());
entity.setStationName(stationName);
@ -149,11 +152,14 @@ public class AbnormalAlarmServiceImpl extends BaseServiceImpl<AbnormalAlarmMappe
entity.setType(item.getSoeType());
entity.setStartTime(ts);
entity.setStatus(0);
if(flag){
entity.setStatus(1);
}
this.historyAbnormalAlarmService.save(entity);
return;
}
queryEntity.setSoeExplain(item.getSoeExplain());
queryEntity.setUpdateTime(new Date());
queryEntity.setEndTime(item.getTs());
queryEntity.setStatus(1);
this.historyAbnormalAlarmService.updateById(queryEntity);
});
return "success";
}

10
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java

@ -13,6 +13,7 @@ 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.AreaGenerationMakeUpVo;
import com.hnac.hzims.operational.main.vo.AreaMonthReportVo;
import com.hnac.hzims.operational.maintenance.constants.HomePageConstant;
import com.hnac.hzims.operational.station.entity.StationEntity;
@ -67,12 +68,15 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno
*
* @param station
* @param soeType
* @param ts
* @return
*/
@Override
public HistoryAbnormalAlarmEntity getAbnormalAlarm(String station, String soeType, Date ts) {
return this.baseMapper.getHistoryAbnormalAlarm(station, soeType, ts);
public HistoryAbnormalAlarmEntity getAbnormalAlarm(String station, String soeType) {
List<HistoryAbnormalAlarmEntity> alarms = this.baseMapper.getHistoryAbnormalAlarm(station, soeType);
if(CollectionUtil.isEmpty(alarms)){
return null;
}
return alarms.stream().sorted(Comparator.comparing(HistoryAbnormalAlarmEntity::getStartTime)).collect(Collectors.toList()).get(0);
}
/**

9
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/scheduled/StAlamRecordTask.java

@ -91,12 +91,13 @@ public class StAlamRecordTask {
/**
* 集中监控数据处理
* 数据中断告警
* @return ReturnT<String>
*/
@XxlJob(ALARM_DATA_HANDLE)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> alarmDataHandle(String param) throws Exception {
//@XxlJob(ALARM_DATA_HANDLE)
@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> alarmDataHandle() throws Exception {
String param = "";
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");
}

10
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

@ -20,10 +20,10 @@ import com.hnac.hzims.operational.station.vo.HzimsStationCountVo;
import com.hnac.hzims.operational.station.vo.StationAndDeptVo;
import com.hnac.hzims.operational.station.vo.StationVO;
import com.hnac.hzims.operational.station.wrapper.StationWrapper;
import com.hnac.hzinfo.sdk.core.response.Result;
/*import com.hnac.hzinfo.sdk.core.response.Result;
import com.hnac.hzinfo.sdk.v5.project.ProjectClient;
import com.hnac.hzinfo.sdk.v5.project.dto.ProjectDTO;
import com.hnac.hzinfo.sdk.v5.project.vo.ProjectVO;
import com.hnac.hzinfo.sdk.v5.project.vo.ProjectVO;*/
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
@ -62,7 +62,7 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
private final IDeptClient deptClient;
private final UserAuthDataService userAuthDataService;
private final IUserClient userClient;
private final ProjectClient projectClient;
//private final ProjectClient projectClient;
private final BladeLogger logger;
private final IQuestionClient questionClient;
@ -103,7 +103,7 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
if(Func.isEmpty(req.getSecretKey()) || Func.isEmpty(req.getDataSource())) {
return true;
}
if(super.updateById(req)) {
/*if(super.updateById(req)) {
ProjectDTO projectDTO = new ProjectDTO();
projectDTO.setName(req.getName());
projectDTO.setSource(1);
@ -113,7 +113,7 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
Result result = projectClient.saveOrUpdate(projectDTO);
logger.info("operational:station:buildStation:"+req.getCode(), JSON.toJSONString(result));
return result.getCode() == ResultCode.SUCCESS.getCode() && result.isSuccess();
}
}*/
return false;
}

Loading…
Cancel
Save