Commit 9d4a4b3e authored by 赵啸非's avatar 赵啸非

添加告警日志信息

parent 5204032c
...@@ -28,3 +28,5 @@ ALTER TABLE mortals_xhx_device ADD COLUMN `productCode` varchar (64) default '' ...@@ -28,3 +28,5 @@ ALTER TABLE mortals_xhx_device ADD COLUMN `productCode` varchar (64) default ''
ALTER TABLE mortals_xhx_device ADD COLUMN `hallId` bigint(20) COMMENT '大厅Id' AFTER skinName; ALTER TABLE mortals_xhx_device ADD COLUMN `hallId` bigint(20) COMMENT '大厅Id' AFTER skinName;
ALTER TABLE mortals_xhx_device ADD COLUMN `hallName` varchar(256) default '' COMMENT '大厅名称' AFTER hallId; ALTER TABLE mortals_xhx_device ADD COLUMN `hallName` varchar(256) default '' COMMENT '大厅名称' AFTER hallId;
ALTER TABLE mortals_xhx_device_alarm_info ADD COLUMN `deviceCode` varchar(256) default '' COMMENT '设备编码' AFTER alarmDevice;
ALTER TABLE mortals_xhx_device_alarm_info ADD COLUMN `deviceName` varchar(256) default '' COMMENT '设备名称' AFTER deviceCode;
package com.mortals.xhx.base.framework.listener; package com.mortals.xhx.base.framework.listener;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.util.UuidUtil;
import com.mortals.xhx.common.code.*; import com.mortals.xhx.common.code.*;
import com.mortals.xhx.common.key.RedisKey; import com.mortals.xhx.common.key.RedisKey;
import com.mortals.xhx.common.pdu.RespData; import com.mortals.xhx.common.pdu.RespData;
...@@ -87,7 +85,9 @@ public class CustomerKeyExpirationListener implements MessageListener { ...@@ -87,7 +85,9 @@ public class CustomerKeyExpirationListener implements MessageListener {
alarmInfoEntity.initAttrValue(); alarmInfoEntity.initAttrValue();
alarmInfoEntity.setAlarmDevice(deviceEntity.getId()); alarmInfoEntity.setAlarmDevice(deviceEntity.getId());
alarmInfoEntity.setSiteId(deviceEntity.getSiteId()); alarmInfoEntity.setSiteId(deviceEntity.getSiteId());
alarmInfoEntity.setAlarmContent(String.format("设备告警:%s设备:%s已离线,请注意检查!",productEntity.getProductName(),deviceEntity.getDeviceName()+":"+deviceEntity.getDeviceName() )); alarmInfoEntity.setDeviceName(deviceEntity.getDeviceName());
alarmInfoEntity.setDeviceCode(deviceEntity.getDeviceCode());
alarmInfoEntity.setAlarmContent(String.format("设备告警:%s设备:%s已离线,请注意检查!", productEntity.getProductName(), deviceEntity.getDeviceName() + ":" + deviceEntity.getDeviceName()));
alarmInfoEntity.setAlarmType(AlarmTypeEnum.离线.getValue()); alarmInfoEntity.setAlarmType(AlarmTypeEnum.离线.getValue());
alarmInfoEntity.setAlarmLevel(AlarmLevelEnum.一般.getValue()); alarmInfoEntity.setAlarmLevel(AlarmLevelEnum.一般.getValue());
alarmInfoEntity.setAlarmStatus(AlarmStatusEnum.未清除.getValue()); alarmInfoEntity.setAlarmStatus(AlarmStatusEnum.未清除.getValue());
...@@ -118,8 +118,8 @@ public class CustomerKeyExpirationListener implements MessageListener { ...@@ -118,8 +118,8 @@ public class CustomerKeyExpirationListener implements MessageListener {
alarmSmsSendEntity.setMobile(deviceAlarmInfoEntity.getReceivePersonnelTelephone()); alarmSmsSendEntity.setMobile(deviceAlarmInfoEntity.getReceivePersonnelTelephone());
alarmSmsSendEntity.setReceiver(deviceAlarmInfoEntity.getAlarmReceivePersonnel()); alarmSmsSendEntity.setReceiver(deviceAlarmInfoEntity.getAlarmReceivePersonnel());
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("1",productEntity.getProductName()); map.put("1", productEntity.getProductName());
map.put("2",deviceEntity.getDeviceName()+":"+deviceEntity.getDeviceName()); map.put("2", deviceEntity.getDeviceName() + ":" + deviceEntity.getDeviceName());
alarmSmsSendEntity.setSendMess(JSON.toJSONString(map)); alarmSmsSendEntity.setSendMess(JSON.toJSONString(map));
alarmSmsSendEntity.setSendStatus(SendStatusEnum.未发送.getValue()); alarmSmsSendEntity.setSendStatus(SendStatusEnum.未发送.getValue());
alarmSmsSendService.save(alarmSmsSendEntity, null); alarmSmsSendService.save(alarmSmsSendEntity, null);
......
package com.mortals.xhx.module.device.model; package com.mortals.xhx.module.device.model;
import java.util.Date;
import java.util.List;
import java.util.ArrayList;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.device.model.vo.DeviceAlarmInfoVo; import com.mortals.xhx.module.device.model.vo.DeviceAlarmInfoVo;
import lombok.Data;
import java.util.Date;
/** /**
* 设备告警日志实体对象 * 设备告警日志实体对象
* *
* @author zxfei * @author zxfei
* @date 2022-08-22 * @date 2023-04-27
*/ */
@Data
public class DeviceAlarmInfoEntity extends DeviceAlarmInfoVo { public class DeviceAlarmInfoEntity extends DeviceAlarmInfoVo {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -25,10 +22,6 @@ public class DeviceAlarmInfoEntity extends DeviceAlarmInfoVo { ...@@ -25,10 +22,6 @@ public class DeviceAlarmInfoEntity extends DeviceAlarmInfoVo {
* 告警设备Id * 告警设备Id
*/ */
private Long alarmDevice; private Long alarmDevice;
/**
* 站点Id,来源基础服务平台
*/
private Long siteId;
/** /**
* 告警类型,(0.离线) * 告警类型,(0.离线)
*/ */
...@@ -53,140 +46,18 @@ public class DeviceAlarmInfoEntity extends DeviceAlarmInfoVo { ...@@ -53,140 +46,18 @@ public class DeviceAlarmInfoEntity extends DeviceAlarmInfoVo {
* 告警详细内容 * 告警详细内容
*/ */
private String alarmContent; private String alarmContent;
public DeviceAlarmInfoEntity(){}
/** /**
* 获取 告警时间 * 站点Id,来源基础服务平台
* @return Date
*/
public Date getAlarmTime(){
return alarmTime;
}
/**
* 设置 告警时间
* @param alarmTime
*/
public void setAlarmTime(Date alarmTime){
this.alarmTime = alarmTime;
}
/**
* 获取 告警设备Id
* @return Long
*/
public Long getAlarmDevice(){
return alarmDevice;
}
/**
* 设置 告警设备Id
* @param alarmDevice
*/
public void setAlarmDevice(Long alarmDevice){
this.alarmDevice = alarmDevice;
}
/**
* 获取 站点Id,来源基础服务平台
* @return Long
*/
public Long getSiteId(){
return siteId;
}
/**
* 设置 站点Id,来源基础服务平台
* @param siteId
*/
public void setSiteId(Long siteId){
this.siteId = siteId;
}
/**
* 获取 告警类型,(0.离线)
* @return Integer
*/
public Integer getAlarmType(){
return alarmType;
}
/**
* 设置 告警类型,(0.离线)
* @param alarmType
*/
public void setAlarmType(Integer alarmType){
this.alarmType = alarmType;
}
/**
* 获取 告警级别(0.危险,1.次要,2.一般)
* @return Integer
*/
public Integer getAlarmLevel(){
return alarmLevel;
}
/**
* 设置 告警级别(0.危险,1.次要,2.一般)
* @param alarmLevel
*/
public void setAlarmLevel(Integer alarmLevel){
this.alarmLevel = alarmLevel;
}
/**
* 获取 接收人员[设备管理的责任人]
* @return String
*/
public String getAlarmReceivePersonnel(){
return alarmReceivePersonnel;
}
/**
* 设置 接收人员[设备管理的责任人]
* @param alarmReceivePersonnel
*/
public void setAlarmReceivePersonnel(String alarmReceivePersonnel){
this.alarmReceivePersonnel = alarmReceivePersonnel;
}
/**
* 获取 接收人员电话
* @return String
*/
public String getReceivePersonnelTelephone(){
return receivePersonnelTelephone;
}
/**
* 设置 接收人员电话
* @param receivePersonnelTelephone
*/
public void setReceivePersonnelTelephone(String receivePersonnelTelephone){
this.receivePersonnelTelephone = receivePersonnelTelephone;
}
/**
* 获取 告警状态,来自工单系统(0.未清除,1.清除未确认,2.清除已确认)
* @return Integer
*/
public Integer getAlarmStatus(){
return alarmStatus;
}
/**
* 设置 告警状态,来自工单系统(0.未清除,1.清除未确认,2.清除已确认)
* @param alarmStatus
*/ */
public void setAlarmStatus(Integer alarmStatus){ private Long siteId;
this.alarmStatus = alarmStatus;
}
/** /**
* 获取 告警详细内容 * 设备编码
* @return String
*/ */
public String getAlarmContent(){ private String deviceCode;
return alarmContent;
}
/** /**
* 设置 告警详细内容 * 设备名称
* @param alarmContent
*/ */
public void setAlarmContent(String alarmContent){ private String deviceName;
this.alarmContent = alarmContent;
}
@Override @Override
public int hashCode() { public int hashCode() {
return this.getId().hashCode(); return this.getId().hashCode();
...@@ -203,28 +74,12 @@ public class DeviceAlarmInfoEntity extends DeviceAlarmInfoVo { ...@@ -203,28 +74,12 @@ public class DeviceAlarmInfoEntity extends DeviceAlarmInfoVo {
return false; return false;
} }
public String toString(){
StringBuilder sb = new StringBuilder("");
sb.append(",alarmTime:").append(getAlarmTime());
sb.append(",alarmDevice:").append(getAlarmDevice());
sb.append(",siteId:").append(getSiteId());
sb.append(",alarmType:").append(getAlarmType());
sb.append(",alarmLevel:").append(getAlarmLevel());
sb.append(",alarmReceivePersonnel:").append(getAlarmReceivePersonnel());
sb.append(",receivePersonnelTelephone:").append(getReceivePersonnelTelephone());
sb.append(",alarmStatus:").append(getAlarmStatus());
sb.append(",alarmContent:").append(getAlarmContent());
return sb.toString();
}
public void initAttrValue(){ public void initAttrValue(){
this.alarmTime = null; this.alarmTime = null;
this.alarmDevice = null; this.alarmDevice = null;
this.siteId = null;
this.alarmType = null; this.alarmType = null;
this.alarmLevel = null; this.alarmLevel = null;
...@@ -236,5 +91,11 @@ public class DeviceAlarmInfoEntity extends DeviceAlarmInfoVo { ...@@ -236,5 +91,11 @@ public class DeviceAlarmInfoEntity extends DeviceAlarmInfoVo {
this.alarmStatus = 0; this.alarmStatus = 0;
this.alarmContent = ""; this.alarmContent = "";
this.siteId = null;
this.deviceCode = "";
this.deviceName = "";
} }
} }
\ No newline at end of file
...@@ -2,17 +2,14 @@ package com.mortals.xhx.module.device.web; ...@@ -2,17 +2,14 @@ package com.mortals.xhx.module.device.web;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.model.OrderCol;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService; import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.DeviceStatusEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.device.model.DeviceAlarmInfoEntity; import com.mortals.xhx.module.device.model.DeviceAlarmInfoEntity;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceQuery; import com.mortals.xhx.module.device.model.DeviceQuery;
import com.mortals.xhx.module.device.service.DeviceAlarmInfoService; import com.mortals.xhx.module.device.service.DeviceAlarmInfoService;
import com.mortals.xhx.module.device.service.DeviceService; import com.mortals.xhx.module.device.service.DeviceService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -48,14 +45,22 @@ public class DeviceAlarmInfoController extends BaseCRUDJsonBodyMappingController ...@@ -48,14 +45,22 @@ public class DeviceAlarmInfoController extends BaseCRUDJsonBodyMappingController
super.init(model, context); super.init(model, context);
} }
@Override
protected void doListBefore(DeviceAlarmInfoEntity query, Map<String, Object> model, Context context) throws AppException {
query.setOrderField("createTime");
query.setOrderKind(OrderCol.DESCENDING);
super.doListBefore(query, model, context);
}
@Override @Override
protected int doListAfter(DeviceAlarmInfoEntity query, Map<String, Object> model, Context context) throws AppException { protected int doListAfter(DeviceAlarmInfoEntity query, Map<String, Object> model, Context context) throws AppException {
List<DeviceAlarmInfoEntity> alarmInfoEntityList = this.service.find(query, context); List<DeviceAlarmInfoEntity> alarmInfoEntityList = this.service.find(query, context);
Map<Integer, Long> collect = alarmInfoEntityList.stream().collect(Collectors.groupingBy(DeviceAlarmInfoEntity::getAlarmLevel, Collectors.counting())); Map<Integer, Long> collect = alarmInfoEntityList.stream().collect(Collectors.groupingBy(DeviceAlarmInfoEntity::getAlarmLevel, Collectors.counting()));
model.put("totalCount", alarmInfoEntityList.size()); model.put("totalCount", alarmInfoEntityList.size());
model.put("dangerCount", collect.getOrDefault(0,0L)); model.put("dangerCount", collect.getOrDefault(0, 0L));
model.put("subCount", collect.getOrDefault(1,0L)); model.put("subCount", collect.getOrDefault(1, 0L));
model.put("normalCount", collect.getOrDefault(2,0L)); model.put("normalCount", collect.getOrDefault(2, 0L));
return super.doListAfter(query, model, context); return super.doListAfter(query, model, context);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment