Browse Source

#数据中断告警移植

zhongwei
yang_shj 9 months ago
parent
commit
f511f52e44
  1. 37
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmHandleConstant.java
  2. 3
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/interruption/constants/InterruptionConstants.java
  3. 29
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/interruption/entity/InterruptionEntity.java
  4. 9
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AlertDefectConfigConstant.java
  5. 41
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/AbnormalAlarmEntity.java
  6. 20
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/AlertDefectConfigEntity.java
  7. 50
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/HistoryAbnormalAlarmEntity.java
  8. 66
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/HistoryLevelAlarmEntity.java
  9. 44
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmDataVo.java
  10. 48
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmMergeVo.java
  11. 30
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmParamVo.java
  12. 31
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmReustVo.java
  13. 36
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlertVo.java
  14. 30
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/HandleQueryVo.java
  15. 42
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/HistoryAlarmVo.java
  16. 29
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/SoeParamVo.java
  17. 31
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/SoeReustVo.java
  18. 38
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/InterruptionAlarmServiceImpl.java

37
hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/constants/AlarmHandleConstant.java

@ -7,57 +7,20 @@ import java.util.List;
* @author YSJ
*/
public interface AlarmHandleConstant {
List<String> INTERRUPT_LIST = Arrays.asList("13","14");
List<String> TYPE_LIST = Arrays.asList("3","2","5","10","13","14");
List<Long> LONG_TYPE_LIST = Arrays.asList(3L,2L,5L,10L,13L,14L);
List<String> SEND_MESSSAGE_TYPE_LIST = Arrays.asList("3","13","14");
String LEVEL_TYPE_LIST = "3,2,5,10,13,14";
String SYSTEM_TYPE_LIST = "3,2,5,13,14";
/**通讯恢复*/
String ABNORMAL_STATUS = "1";
/**故障**/
String FAULT = "3";
/**预警**/
Long EARLY_WARNING = 20L;
String WEBSOCKET_FAULT = "3";
String[] TYPE_NAMES = {"默认", "系统", "告警"
, "故障", "用户操作", "遥测越限", "遥信变位", "注册信息", "信息提示", "设备巡检", "遥控操作", "遥测越限恢复","未定义","通讯中断","数据异常"};
/**误报 、延后、缺陷 、检修、处理*/
List<Long> HANDLE_WAY = Arrays.asList(1L,2L,3L,4L,5L);
List<Long> HANDLE = Arrays.asList(3L,4L,5L);
/**
* 2-告警,3-故障,5-遥测越限,13-通讯异常,14-数据异常
*/
List<Integer> SOE_TYPE_LIST = Arrays.asList(2,3,5,13,14);
/**
* 告警等级: 0 - 1级告警 1-二级告警
*/
List<String> LEVEL_LIST = Arrays.asList("0","1");
/**
* 告警类型: HZ3000告警
*/
Integer SYSTEM_ALARM = 0;
/**
* 告警类型: 智能告警
*/
Integer INTELLIGENCE_ALARM = 1;
/**
* 告警类型: 视频告警
*/
Integer VIDEO_ALARM = 4;

3
hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/interruption/constants/InterruptionConstants.java

@ -9,4 +9,7 @@ import java.util.List;
public interface InterruptionConstants {
List<String> INTERRUPTION_TYPE = Arrays.asList("13","14");
/**通讯恢复*/
String ABNORMAL_STATUS = "1";
}

29
hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/interruption/entity/InterruptionEntity.java

@ -2,10 +2,13 @@ package com.hnac.hzims.business.interruption.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity;
import java.util.Date;
/**
* @author ysj
@ -16,4 +19,30 @@ import org.springblade.core.tenant.mp.TenantEntity;
@ApiModel(value = "数据中断告警", description = "数据中断告警对象")
public class InterruptionEntity extends TenantEntity {
@ApiModelProperty("ID")
private Long id;
@ApiModelProperty("站点编码")
private String stationId;
@ApiModelProperty("站点名称")
private String stationName;
@ApiModelProperty("告警编码")
private Long alarmId;
@ApiModelProperty("检查点")
private String realId;
@ApiModelProperty("告警开始时间")
private Date alarmTime;
@ApiModelProperty("告警类型")
private String type;
@ApiModelProperty("状态")
private Integer status;
@ApiModelProperty("告警原因")
private String soeExplain;
}

9
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AlertDefectConfigConstant.java

@ -1,9 +0,0 @@
package com.hnac.hzims.operational.alert.constants;
/**
* @author YSJ
*/
public interface AlertDefectConfigConstant {
String ALERT_SOURCE_CODE = "XTGJ";
}

41
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/AbnormalAlarmEntity.java

@ -1,41 +0,0 @@
package com.hnac.hzims.operational.alert.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
import java.util.Date;
@Data
@TableName("hzims_abnormal_alarm")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "数据中断告警对象")
public class AbnormalAlarmEntity extends BaseEntity {
@ApiModelProperty("站点编码")
private String stationId;
@ApiModelProperty("站点名称")
private String stationName;
@ApiModelProperty("检查点")
private String realId;
@ApiModelProperty("告警开始时间")
private Date startTime;
@ApiModelProperty("告警结束时间")
private Date endTime;
@ApiModelProperty("告警类型")
private String type;
@ApiModelProperty("状态")
private Integer status;
@ApiModelProperty("告警原因")
private String soeExplain;
}

20
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/AlertDefectConfigEntity.java

@ -1,20 +0,0 @@
package com.hnac.hzims.operational.alert.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author : YSJ
*/
@Data
public class AlertDefectConfigEntity {
@ApiModelProperty("主键ID")
private Integer id;
@ApiModelProperty("告警类型")
private Integer alertType;
@ApiModelProperty("是否开启缺陷保存 : 0-关闭 1 - 开启")
private Integer isOpen;
}

50
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/HistoryAbnormalAlarmEntity.java

@ -1,50 +0,0 @@
package com.hnac.hzims.operational.alert.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
import java.util.Date;
/**
* @author ysj
*/
@Data
@TableName("hzims_history_abnormal_alarm")
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "数据中断告警对象")
public class HistoryAbnormalAlarmEntity extends BaseEntity {
@ApiModelProperty("ID")
private Long id;
@ApiModelProperty("站点编码")
private String stationId;
@ApiModelProperty("站点名称")
private String stationName;
@ApiModelProperty("告警编码")
private Long alarmId;
@ApiModelProperty("检查点")
private String realId;
@ApiModelProperty("告警开始时间")
private Date startTime;
@ApiModelProperty("告警结束时间")
private Date endTime;
@ApiModelProperty("告警类型")
private String type;
@ApiModelProperty("状态")
private Integer status;
@ApiModelProperty("告警原因")
private String soeExplain;
}

66
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/HistoryLevelAlarmEntity.java

@ -1,66 +0,0 @@
package com.hnac.hzims.operational.alert.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
import java.util.Date;
/**
* @author ysj
*/
@Data
@TableName("hzims_history_level_alarm")
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "数据中断告警对象")
public class HistoryLevelAlarmEntity extends BaseEntity {
@ApiModelProperty("ID")
private Long id;
@ApiModelProperty("站点编码")
private String stationId;
@ApiModelProperty("站点名称")
private String stationName;
@ApiModelProperty("设备编码")
private String deviceCode;
@ApiModelProperty("设备名称")
private String deviceName;
@ApiModelProperty("告警等级")
private String alarmLevel;
@ApiModelProperty("告警编码")
private String alarmId;
@ApiModelProperty("检查点")
private String realId;
@ApiModelProperty("告警开始时间")
private Date alarmTime;
@ApiModelProperty("告警类型")
private String type;
@ApiModelProperty("状态")
private Integer status;
@ApiModelProperty("告警原因")
private String soeExplain;
@ApiModelProperty(value = "告警所属类型:0-系统告警 1-智能告警")
@TableField(exist=false)
private Integer alarmType;
@ApiModelProperty(value = "告警是否处理")
@TableField(exist=false)
private Boolean isHandle;
}

44
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmDataVo.java

@ -1,44 +0,0 @@
package com.hnac.hzims.operational.alert.vo;
import com.hnac.hzinfo.datasearch.soe.domian.SoeData;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author ysj
* @date 2023/03/23 14:06:27
* @version 4.0.0
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class AlarmDataVo extends SoeData {
@ApiModelProperty(value = "数量")
private Integer count;
@ApiModelProperty(value = "站点编号")
private String stationCode;
@ApiModelProperty(value = "站点名称")
private String stationName;
@ApiModelProperty(value = "内容")
private String content;
@ApiModelProperty(value = "是否绑定")
private Boolean isBinding;
@ApiModelProperty(value = "站点类型: 2-待运维 1-云服务")
private String serveType;
@ApiModelProperty(value = "告警类型")
private String type;
@ApiModelProperty(value = "告警所属类型:0-系统告警 1-智能告警")
private Integer alarmType;
@ApiModelProperty(value = "告警是否处理")
private Boolean isHandle;
}

48
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmMergeVo.java

@ -1,48 +0,0 @@
package com.hnac.hzims.operational.alert.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.Data;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* @author ysj
* @date 2023/03/17 10:02:33
* @version 4.0.0
*/
@Data
public class AlarmMergeVo{
@ApiModelProperty("站点编号")
private String stationCode;
@ApiModelProperty("站点名称")
private String stationName;
@ApiModelProperty("检测点位")
private String realId;
@ApiModelProperty("告警编号")
private String alarmCode;
@ApiModelProperty("告警等级")
private String level;
@ApiModelProperty("告警类型")
private String type;
@ApiModelProperty("类型:0-系统告警、2-智能告警")
private Integer alarmType;
@ApiModelProperty("告警内容")
private String content;
@ApiModelProperty("告警时间")
@DateTimeFormat(pattern = DateUtil.PATTERN_DATE)
@JsonFormat(pattern = DateUtil.PATTERN_DATE)
private Date date;
}

30
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmParamVo.java

@ -1,30 +0,0 @@
package com.hnac.hzims.operational.alert.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
* @date 2023/03/23 13:34:37
* @version 4.0.0
*/
@Data
public class AlarmParamVo {
@ApiModelProperty(value = "查询开始时间:yyyy-MM-dd HH:mm:ss")
private String date;
@ApiModelProperty(value = "默认,系统,告警,故障,用户操作,遥测越限,遥信变位,注册信息,信息提示,设备巡检,遥控操作,遥测越限恢复,未定义,通讯中断,数据异常")
private String type;
@ApiModelProperty(value = "当前页码")
private Integer current;
@ApiModelProperty(value = "每页条目")
private Integer size;
@ApiModelProperty(value = "站点编码")
private String code;
}

31
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmReustVo.java

@ -1,31 +0,0 @@
package com.hnac.hzims.operational.alert.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author ysj
* @date 2023/03/23 13:34:37
* @version 4.0.0
*/
@Data
public class AlarmReustVo {
@ApiModelProperty(value = "最新的时间")
private String date;
@ApiModelProperty(value = "告警数据")
private List<AlarmDataVo> soeList;
@ApiModelProperty(value = "数量统计")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Integer count;
@ApiModelProperty(value = "总条数")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Long total;
}

36
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlertVo.java

@ -1,36 +0,0 @@
package com.hnac.hzims.operational.alert.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 告警对象
*/
@Data
public class AlertVo {
@ApiModelProperty("主键Id")
private String id;
@ApiModelProperty("告警类型")
private String soeType;
@ApiModelProperty("告警状态")
private String soeStatus;
@ApiModelProperty("站点")
private String station;
@ApiModelProperty("事件未定义(通道:2 模块:1 点号:2006)")
private String soeExplain;
@ApiModelProperty("告警报警类型")
private String soeAlarmType;
@ApiModelProperty("监测点位")
private String realid;
@ApiModelProperty("时间")
private String ts;
}

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

@ -1,30 +0,0 @@
package com.hnac.hzims.operational.alert.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author ysj
* @date 2023/03/17 10:02:33
* @version 4.0.0
*/
@Data
public class HandleQueryVo {
@ApiModelProperty("处理人")
private String stationCode;
@ApiModelProperty("处理人")
private Long handleUser;
@ApiModelProperty("开始时间")
private Date startTime;
@ApiModelProperty("结束时间")
private Date endTime;
@ApiModelProperty("处理类型:1-延后 2-误报 3-缺陷 4-检修")
private Long handleWay;
}

42
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/HistoryAlarmVo.java

@ -1,42 +0,0 @@
package com.hnac.hzims.operational.alert.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springblade.core.mp.base.BaseEntity;
import java.util.Date;
import java.util.List;
@Data
public class HistoryAlarmVo extends BaseEntity {
@ApiModelProperty("ID")
private Long id;
@ApiModelProperty("站点编码")
private String stationId;
@ApiModelProperty("站点名称")
private String stationName;
@ApiModelProperty("告警编码")
private Long alarmId;
@ApiModelProperty("检查点")
private String realId;
@ApiModelProperty("告警开始时间")
private Date startTime;
@ApiModelProperty("告警结束时间")
private Date endTime;
@ApiModelProperty("告警类型")
private List<String> type;
@ApiModelProperty("状态")
private Integer status;
@ApiModelProperty("告警原因")
private String soeExplain;
}

29
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/SoeParamVo.java

@ -1,29 +0,0 @@
package com.hnac.hzims.operational.alert.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
* @date 2023/03/23 13:34:37
* @version 4.0.0
*/
@Data
public class SoeParamVo {
@ApiModelProperty(value = "站点编码")
private String code;
@ApiModelProperty(value = "查询开始时间:yyyy-MM-dd HH:mm:ss")
private String date;
@ApiModelProperty(value = "2-告警,3-故障,5-遥测越限,13-通讯异常,14-数据异常")
private Integer type;
@ApiModelProperty(value = "当前页码")
private Integer current;
@ApiModelProperty(value = "每页条目")
private Integer size;
}

31
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/SoeReustVo.java

@ -1,31 +0,0 @@
package com.hnac.hzims.operational.alert.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author ysj
* @date 2023/03/23 13:34:37
* @version 4.0.0
*/
@Data
public class SoeReustVo {
@ApiModelProperty(value = "最新的时间")
private String date;
@ApiModelProperty(value = "告警数据")
private List<AlarmDataVo> soeList;
@ApiModelProperty(value = "数量统计")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Integer count;
@ApiModelProperty(value = "总条数")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Long total;
}

38
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/InterruptionAlarmServiceImpl.java

@ -20,9 +20,9 @@ import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.stream.Collectors;
@ -45,6 +45,7 @@ public class InterruptionAlarmServiceImpl extends BaseServiceImpl<InterruptionAl
* @param param
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void interruption(String param) {
// 查询接入站点
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
@ -73,7 +74,29 @@ public class InterruptionAlarmServiceImpl extends BaseServiceImpl<InterruptionAl
List<SoeData> soes = result.getData().getRecords();
// 查询当天数据中断告警记录
List<InterruptionEntity> saves = this.saveInterruptions(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
// 批量保存中断告警数据
this.saveBatch(soes.stream().filter(o-> CollectionUtil.isEmpty(saves) || !saves.stream().map(InterruptionEntity::getAlarmId).collect(Collectors.toList()).contains(o.getId())).map(soe->{
InterruptionEntity entity = new InterruptionEntity();
List<StationEntity> soeStations = stations.stream().filter(o->o.getCode().equals(soe.getStation())).collect(Collectors.toList());
if(!CollectionUtil.isEmpty(soeStations)){
entity.setStationId(soeStations.get(0).getCode());
entity.setStationName(soeStations.get(0).getName());
entity.setCreateDept(soeStations.get(0).getRefDept());
}
entity.setAlarmId(soe.getId());
entity.setRealId(soe.getRealId());
entity.setSoeExplain(soe.getSoeExplain());
entity.setType(soe.getSoeType());
entity.setAlarmTime(soe.getTs());
entity.setStatus(0);
// 通讯中断恢复
if(InterruptionConstants.ABNORMAL_STATUS.equals(soe.getSoeAlarmType())){
entity.setStatus(1);
}
return entity;
}).collect(Collectors.toList()));
}
/**
* 查询当天数据中断告警记录
@ -81,7 +104,16 @@ public class InterruptionAlarmServiceImpl extends BaseServiceImpl<InterruptionAl
* @return
*/
private List<InterruptionEntity> saveInterruptions(List<String> stations) {
this.list(Wrappers.<InterruptionEntity>lambdaQuery());
return new ArrayList<>();
Calendar calendar = Calendar.getInstance();
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY));
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE));
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND));
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
return this.list(Wrappers.<InterruptionEntity>lambdaQuery()
.in(InterruptionEntity::getStationId,stations)
.ge(InterruptionEntity::getCreateTime,start)
.le(InterruptionEntity::getCreateTime,end)
);
}
}
Loading…
Cancel
Save