haungxing
8 months ago
17 changed files with 498 additions and 49 deletions
@ -0,0 +1,53 @@
|
||||
package com.hnac.hzims.alarm.config.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; |
||||
|
||||
|
||||
/** |
||||
* @author ysj |
||||
*/ |
||||
@Data |
||||
@TableName("hzims_alarm_defaul_config") |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "站点告警配置详情对象", description = "站点告警配置详情对象") |
||||
public class AlarmDefaultConfigEntity extends TenantEntity { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
@ApiModelProperty(value = "告警源类型") |
||||
private Integer source; |
||||
|
||||
@ApiModelProperty(value = "告警子类") |
||||
private Integer alarmChiledType; |
||||
|
||||
|
||||
@ApiModelProperty(value = "是否集中监控右侧列表展示 : 0-展示 1-不展示") |
||||
private Integer isRightTabulation; |
||||
|
||||
@ApiModelProperty(value = "是否集中监控弹窗展示 : 0-展示 1-不展示") |
||||
private Integer isShowAlert; |
||||
|
||||
@ApiModelProperty(value = "是否集中监控铃铛展示 : 0-展示 1-不展示") |
||||
private Integer isSmallBell; |
||||
|
||||
@ApiModelProperty(value = "是否集中监控遮罩展示 : 0-展示 1-不展示") |
||||
private Integer isMask; |
||||
|
||||
@ApiModelProperty(value = "是否语音播报 : 0-播报 1-不播报") |
||||
private Integer isBroadcast; |
||||
|
||||
@ApiModelProperty(value = "是否进行平台消息推送 : 0-推送 1-不推送") |
||||
private Integer isPlatformMessage; |
||||
|
||||
@ApiModelProperty(value = "是否短信推送 :0-推送 1-不推送") |
||||
private Integer isShortMessage; |
||||
|
||||
@ApiModelProperty(value = "是否微信公众号消息推送 :0-推送 1-不推送") |
||||
private Integer isWxMessage; |
||||
} |
||||
|
@ -0,0 +1,42 @@
|
||||
package com.hnac.hzims.alarm.config.vo; |
||||
|
||||
import io.swagger.annotations.ApiModel; |
||||
import lombok.Data; |
||||
|
||||
import java.util.Date; |
||||
|
||||
|
||||
/** |
||||
* @author ty |
||||
*/ |
||||
@Data |
||||
@ApiModel(value = "规则预警对象", description = "规则预警对象") |
||||
public class DroolsAlarmVo { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
private String excitationvoltage; |
||||
|
||||
private String deviceCode; |
||||
|
||||
private String level; |
||||
|
||||
private String type; |
||||
|
||||
private String deviceName; |
||||
|
||||
private String tenantId; |
||||
|
||||
private String name; |
||||
|
||||
private String context; |
||||
|
||||
private String guideopening; |
||||
|
||||
private String signage; |
||||
|
||||
private String projectId; |
||||
|
||||
private String currentValue; |
||||
|
||||
private Date ts; |
||||
} |
@ -0,0 +1,36 @@
|
||||
package com.hnac.hzims.alarm.config.vo; |
||||
|
||||
import io.swagger.annotations.ApiModel; |
||||
import lombok.Data; |
||||
|
||||
import java.util.Date; |
||||
|
||||
|
||||
/** |
||||
* @author ty |
||||
*/ |
||||
@Data |
||||
@ApiModel(value = "规则预警对象", description = "规则预警对象") |
||||
public class SoeAlarmVo { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
|
||||
private String ts; |
||||
|
||||
private String station; |
||||
|
||||
private String sid; |
||||
private String id; |
||||
private String realId; |
||||
private String type; |
||||
private String kind; |
||||
private String level; |
||||
private String state; |
||||
private String stateLabel; |
||||
private String context; |
||||
private String opvalue; |
||||
private String trace; |
||||
private String duration; |
||||
private String traceCount; |
||||
|
||||
} |
@ -0,0 +1,23 @@
|
||||
package com.hnac.hzims.safeproduct.risk.vo; |
||||
|
||||
import com.hnac.hzims.safeproduct.risk.entity.HazardWork; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
/** |
||||
* @author liwen |
||||
* @date 2024-04-09 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "作业区域管理页面VO类") |
||||
public class HazardWorkVO extends HazardWork { |
||||
|
||||
@ApiModelProperty("负责人名称") |
||||
private String headName; |
||||
|
||||
@ApiModelProperty("分管领导名称") |
||||
private String managerName; |
||||
} |
@ -0,0 +1,10 @@
|
||||
package com.hnac.hzims.alarm.config.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.hnac.hzims.alarm.config.entity.AlarmDefaultConfigEntity; |
||||
/** |
||||
* @author ysj |
||||
*/ |
||||
public interface AlarmDefaultConfigMapper extends BaseMapper<AlarmDefaultConfigEntity> { |
||||
|
||||
} |
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.hnac.hzims.alarm.config.mapper.AlarmDefaultConfigMapper"> |
||||
|
||||
</mapper> |
@ -0,0 +1,42 @@
|
||||
package com.hnac.hzims.alarm.mqtt; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hnac.hzims.alarm.config.entity.AlarmEntity; |
||||
import com.hnac.hzims.alarm.monitor.service.AlarmSaveService; |
||||
import com.hnac.hzims.alarm.source.service.DroolsAlarmService; |
||||
import com.hnac.hzims.alarm.source.service.SoeAlarmService; |
||||
import com.hnac.hzinfo.subscribe.SubscribeCallBack; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* |
||||
* @Author: ty |
||||
*/ |
||||
|
||||
@Service |
||||
@Slf4j |
||||
public class SoeMqttConsumer implements SubscribeCallBack { |
||||
@Autowired |
||||
private SoeAlarmService soeAlarmService; |
||||
@Autowired |
||||
private AlarmSaveService alarmSaveService; |
||||
@Override |
||||
public void onMessage(Map<String, Object> data) { |
||||
System.out.println("监听到消息"+data.toString()); |
||||
String s = JSONObject.toJSONString(data); |
||||
//消费代码
|
||||
List<AlarmEntity> alarmEntities = soeAlarmService.receiveMessage(s); |
||||
//统一数据处理
|
||||
try { |
||||
alarmSaveService.save(alarmEntities); |
||||
}catch (Exception e){ |
||||
log.error("条件告警数据处理报错(SoeAlarm):"+e); |
||||
System.out.println("规则引擎告警数据处理报错(SoeAlarm):"+e); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,14 @@
|
||||
package com.hnac.hzims.alarm.source.service; |
||||
|
||||
import com.hnac.hzims.alarm.config.entity.AlarmEntity; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 等级处理接口 |
||||
* @author ysj |
||||
*/ |
||||
public interface SoeAlarmService { |
||||
|
||||
List<AlarmEntity> receiveMessage(String message); |
||||
} |
@ -0,0 +1,88 @@
|
||||
package com.hnac.hzims.alarm.source.service.impl; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
||||
import com.hnac.hzims.alarm.config.entity.AlarmEntity; |
||||
import com.hnac.hzims.alarm.config.vo.DroolsAlarmVo; |
||||
import com.hnac.hzims.alarm.config.vo.SoeAlarmVo; |
||||
import com.hnac.hzims.alarm.show.service.AlarmService; |
||||
import com.hnac.hzims.alarm.source.service.DroolsAlarmService; |
||||
import com.hnac.hzims.alarm.source.service.MessageService; |
||||
import com.hnac.hzims.alarm.source.service.SoeAlarmService; |
||||
import com.hnac.hzims.common.utils.DateUtil; |
||||
import com.hnac.hzims.operational.station.entity.StationEntity; |
||||
import com.hnac.hzims.operational.station.feign.IStationClient; |
||||
import lombok.RequiredArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.CollectionUtil; |
||||
import org.springframework.data.redis.core.RedisTemplate; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Arrays; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.stream.Collectors; |
||||
|
||||
import static com.hnac.hzims.alarm.config.constants.AlarmConstants.*; |
||||
|
||||
/** |
||||
* 等级告警实现类 |
||||
* @author ysj |
||||
*/ |
||||
@Slf4j |
||||
@Service |
||||
@RequiredArgsConstructor |
||||
public class SoeAlarmServiceImpl implements SoeAlarmService { |
||||
|
||||
private final AlarmService alarmService; |
||||
|
||||
private final MessageService messageService; |
||||
|
||||
private final RedisTemplate redisTemplate; |
||||
|
||||
private final IStationClient stationClient; |
||||
|
||||
|
||||
/** |
||||
* 转换接收服务推送消息 |
||||
* @param message |
||||
*/ |
||||
@Override |
||||
public List<AlarmEntity> receiveMessage(String message) { |
||||
// 对象转换
|
||||
SoeAlarmVo parseObject = JSONObject.parseObject(message, SoeAlarmVo.class); |
||||
List<SoeAlarmVo> alarms = Arrays.asList(parseObject); |
||||
if (CollectionUtil.isEmpty(alarms)) { |
||||
return new ArrayList<>(); |
||||
} |
||||
List<AlarmEntity> res = alarms.stream().map(s -> { |
||||
AlarmEntity entity = getAlarmEntity(s); |
||||
return entity; |
||||
}).collect(Collectors.toList()); |
||||
return res; |
||||
} |
||||
|
||||
private AlarmEntity getAlarmEntity(SoeAlarmVo item) { |
||||
AlarmEntity entity = new AlarmEntity(); |
||||
entity.setAlarmSource(LEVEL_ALARM); |
||||
entity.setAlarmType(ONE_LEVEL); |
||||
entity.setAlarmContext(item.getContext()); |
||||
Date date = new Date(Long.valueOf(item.getTs())); |
||||
entity.setAlarmTime(date); |
||||
entity.setAlarmValue(item.getOpvalue()); |
||||
entity.setAlarmSignage(item.getSid()); |
||||
entity.setAlarmLevel(Integer.valueOf(item.getLevel())); |
||||
entity.setAlarmCount(Integer.valueOf(item.getTraceCount())); |
||||
entity.setAlarmStatus(1); |
||||
entity.setDeviceCode(item.getRealId()); |
||||
entity.setTenantId("200000"); |
||||
R<StationEntity> stationByCode = stationClient.getStationByCode(item.getStation()); |
||||
if (stationByCode.isSuccess()&& ObjectUtils.isNotEmpty(stationByCode.getData())){ |
||||
entity.setCreateDept(stationByCode.getData().getCreateDept()); |
||||
entity.setStationName(stationByCode.getData().getName()); |
||||
} |
||||
return entity; |
||||
} |
||||
} |
@ -0,0 +1,25 @@
|
||||
|
||||
DROP TABLE IF EXISTS `BLADE_MODULE_VERSION`; |
||||
CREATE TABLE `hzims_alarm_defaul_config` ( |
||||
`ID` bigint(20) NOT NULL COMMENT '主键ID', |
||||
`SOURCE` bigint(4) DEFAULT NULL COMMENT '告警来源', |
||||
`ALARM_CHILED_TYPE` bigint(4) DEFAULT NULL COMMENT '告警子类', |
||||
`IS_RIGHT_TABULATION` tinyint(4) DEFAULT NULL COMMENT '是否集中监控右侧列表展示 : 0-展示 1-不展示', |
||||
`IS_SHOW_ALERT` tinyint(4) DEFAULT NULL COMMENT '是否集中监控弹窗展示 : 0-展示 1-不展示', |
||||
`IS_SMALL_BELL` tinyint(4) DEFAULT NULL COMMENT '是否集中监控铃铛展示 : 0-展示 1-不展示', |
||||
`IS_MASK` tinyint(4) DEFAULT NULL COMMENT '是否集中监控遮罩展示 : 0-展示 1-不展示', |
||||
`IS_BROADCAST` tinyint(4) DEFAULT NULL COMMENT '是否语音播报 : 0-播报 1-不播报', |
||||
`IS_PLATFORM_MESSAGE` tinyint(4) DEFAULT NULL COMMENT '是否进行平台消息推送 : 0-推送 1-不推送', |
||||
`IS_SHORT_MESSAGE` tinyint(4) DEFAULT NULL COMMENT '是否短信推送 :0-推送 1-不推送', |
||||
`IS_WX_MESSAGE` tinyint(4) DEFAULT NULL COMMENT '是否微信公众号消息推送 :0-推送 1-不推送', |
||||
`TENANT_ID` varchar(12) NOT NULL COMMENT '租户ID', |
||||
`CREATE_DEPT` bigint(20) DEFAULT NULL COMMENT '创建部门ID', |
||||
`CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', |
||||
`UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', |
||||
`CREATE_USER` bigint(20) DEFAULT NULL COMMENT '创建人', |
||||
`UPDATE_USER` bigint(20) DEFAULT NULL COMMENT '更新人', |
||||
`IS_DELETED` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否删除', |
||||
`STATUS` tinyint(4) DEFAULT NULL COMMENT '状态', |
||||
PRIMARY KEY (`ID`) USING BTREE |
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; |
||||
|
Loading…
Reference in new issue