mirror of
https://gitee.com/pan648540858/wvp-GB28181-pro.git
synced 2026-05-06 06:06:08 +08:00
移除旧的报警信息表,增加报警管理页面
This commit is contained in:
parent
b476e08d19
commit
c2835db8d4
@ -1,9 +1,11 @@
|
||||
package com.genersoft.iot.vmp.conf;
|
||||
|
||||
import com.genersoft.iot.vmp.service.bean.AlarmType;
|
||||
import org.apache.ibatis.logging.stdout.StdOutImpl;
|
||||
import org.apache.ibatis.mapping.DatabaseIdProvider;
|
||||
import org.apache.ibatis.mapping.VendorDatabaseIdProvider;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.apache.ibatis.type.EnumOrdinalTypeHandler;
|
||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@ -54,6 +56,7 @@ public class MybatisConfig {
|
||||
config.setLogImpl(StdOutImpl.class);
|
||||
}
|
||||
config.setMapUnderscoreToCamelCase(true);
|
||||
config.getTypeHandlerRegistry().register(AlarmType.class, EnumOrdinalTypeHandler.class);
|
||||
sqlSessionFactory.setConfiguration(config);
|
||||
sqlSessionFactory.setDatabaseIdProvider(databaseIdProvider);
|
||||
return sqlSessionFactory.getObject();
|
||||
|
||||
@ -1,194 +0,0 @@
|
||||
package com.genersoft.iot.vmp.gb28181.controller;
|
||||
|
||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
import com.genersoft.iot.vmp.conf.security.JwtUtils;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Platform;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IDeviceAlarmService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IDeviceService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IPlatformService;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.sip.InvalidArgumentException;
|
||||
import javax.sip.SipException;
|
||||
import java.text.ParseException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "报警信息管理")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/alarm")
|
||||
public class AlarmController {
|
||||
|
||||
@Autowired
|
||||
private IDeviceAlarmService deviceAlarmService;
|
||||
|
||||
@Autowired
|
||||
private ISIPCommander commander;
|
||||
|
||||
@Autowired
|
||||
private ISIPCommanderForPlatform commanderForPlatform;
|
||||
|
||||
@Autowired
|
||||
private IPlatformService platformService;
|
||||
|
||||
@Autowired
|
||||
private IDeviceService deviceService;
|
||||
|
||||
|
||||
/**
|
||||
* 删除报警
|
||||
*
|
||||
* @param id 报警id
|
||||
* @param deviceIds 多个设备id,逗号分隔
|
||||
* @param time 结束时间(这个时间之前的报警会被删除)
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除报警", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "id", description = "ID")
|
||||
@Parameter(name = "deviceIds", description = "多个设备id,逗号分隔")
|
||||
@Parameter(name = "time", description = "结束时间")
|
||||
public Integer delete(
|
||||
@RequestParam(required = false) Integer id,
|
||||
@RequestParam(required = false) String deviceIds,
|
||||
@RequestParam(required = false) String time
|
||||
) {
|
||||
if (ObjectUtils.isEmpty(id)) {
|
||||
id = null;
|
||||
}
|
||||
if (ObjectUtils.isEmpty(deviceIds)) {
|
||||
deviceIds = null;
|
||||
}
|
||||
|
||||
if (ObjectUtils.isEmpty(time)) {
|
||||
time = null;
|
||||
}else if (!DateUtil.verification(time, DateUtil.formatter) ){
|
||||
throw new ControllerException(ErrorCode.ERROR400.getCode(), "time格式为" + DateUtil.PATTERN);
|
||||
}
|
||||
List<String> deviceIdList = null;
|
||||
if (deviceIds != null) {
|
||||
String[] deviceIdArray = deviceIds.split(",");
|
||||
deviceIdList = Arrays.asList(deviceIdArray);
|
||||
}
|
||||
|
||||
return deviceAlarmService.clearAlarmBeforeTime(id, deviceIdList, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试向上级/设备发送模拟报警通知
|
||||
*
|
||||
* @param deviceId 报警id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/test/notify/alarm")
|
||||
@Operation(summary = "测试向上级/设备发送模拟报警通知", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "deviceId", description = "设备国标编号")
|
||||
public void delete(@RequestParam String deviceId) {
|
||||
Device device = deviceService.getDeviceByDeviceId(deviceId);
|
||||
Platform platform = platformService.queryPlatformByServerGBId(deviceId);
|
||||
DeviceAlarm deviceAlarm = new DeviceAlarm();
|
||||
deviceAlarm.setChannelId(deviceId);
|
||||
deviceAlarm.setAlarmDescription("test");
|
||||
deviceAlarm.setAlarmMethod("1");
|
||||
deviceAlarm.setAlarmPriority("1");
|
||||
deviceAlarm.setAlarmTime(DateUtil.getNow());
|
||||
deviceAlarm.setAlarmType("1");
|
||||
deviceAlarm.setLongitude(115.33333);
|
||||
deviceAlarm.setLatitude(39.33333);
|
||||
|
||||
if (device != null && platform == null) {
|
||||
|
||||
try {
|
||||
commander.sendAlarmMessage(device, deviceAlarm);
|
||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||
|
||||
}
|
||||
}else if (device == null && platform != null){
|
||||
try {
|
||||
commanderForPlatform.sendAlarmMessage(platform, deviceAlarm);
|
||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||
log.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage());
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}else {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(),"无法确定" + deviceId + "是平台还是设备");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询报警
|
||||
*
|
||||
* @param deviceId 设备id
|
||||
* @param page 当前页
|
||||
* @param count 每页查询数量
|
||||
* @param alarmPriority 报警级别
|
||||
* @param alarmMethod 报警方式
|
||||
* @param alarmType 报警类型
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页查询报警", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "page",description = "当前页",required = true)
|
||||
@Parameter(name = "count",description = "每页查询数量",required = true)
|
||||
@Parameter(name = "deviceId",description = "设备id")
|
||||
@Parameter(name = "channelId",description = "通道id")
|
||||
@Parameter(name = "alarmPriority",description = "查询内容")
|
||||
@Parameter(name = "alarmMethod",description = "查询内容")
|
||||
@Parameter(name = "alarmType",description = "每页查询数量")
|
||||
@Parameter(name = "startTime",description = "开始时间")
|
||||
@Parameter(name = "endTime",description = "结束时间")
|
||||
@GetMapping("/all")
|
||||
public PageInfo<DeviceAlarm> getAll(
|
||||
@RequestParam int page,
|
||||
@RequestParam int count,
|
||||
@RequestParam(required = false) String deviceId,
|
||||
@RequestParam(required = false) String channelId,
|
||||
@RequestParam(required = false) String alarmPriority,
|
||||
@RequestParam(required = false) String alarmMethod,
|
||||
@RequestParam(required = false) String alarmType,
|
||||
@RequestParam(required = false) String startTime,
|
||||
@RequestParam(required = false) String endTime
|
||||
) {
|
||||
if (ObjectUtils.isEmpty(alarmPriority)) {
|
||||
alarmPriority = null;
|
||||
}
|
||||
if (ObjectUtils.isEmpty(alarmMethod)) {
|
||||
alarmMethod = null;
|
||||
}
|
||||
if (ObjectUtils.isEmpty(alarmType)) {
|
||||
alarmType = null;
|
||||
}
|
||||
|
||||
if (ObjectUtils.isEmpty(startTime)) {
|
||||
startTime = null;
|
||||
}else if (!DateUtil.verification(startTime, DateUtil.formatter) ){
|
||||
throw new ControllerException(ErrorCode.ERROR400.getCode(), "startTime格式为" + DateUtil.PATTERN);
|
||||
}
|
||||
|
||||
if (ObjectUtils.isEmpty(endTime)) {
|
||||
endTime = null;
|
||||
}else if (!DateUtil.verification(endTime, DateUtil.formatter) ){
|
||||
throw new ControllerException(ErrorCode.ERROR400.getCode(), "endTime格式为" + DateUtil.PATTERN);
|
||||
}
|
||||
|
||||
return deviceAlarmService.getAllAlarm(page, count, deviceId, channelId, alarmPriority, alarmMethod,
|
||||
alarmType, startTime, endTime);
|
||||
}
|
||||
}
|
||||
@ -1,43 +0,0 @@
|
||||
package com.genersoft.iot.vmp.gb28181.service;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 报警相关业务处理
|
||||
*/
|
||||
public interface IDeviceAlarmService {
|
||||
|
||||
/**
|
||||
* 根据多个添加获取报警列表
|
||||
* @param page 当前页
|
||||
* @param count 每页数量
|
||||
* @param deviceId 设备id
|
||||
* @param alarmPriority 报警级别, 1为一级警情, 2为二级警情, 3为三级警情, 4为四级 警情-
|
||||
* @param alarmMethod 报警方式 , 1为电话报警, 2为设备报警, 3为短信报警, 4为 GPS报警, 5为视频报警, 6为设备故障报警,
|
||||
* 7其他报警;可以为直接组合如12为电话报警或 设备报警-
|
||||
* @param alarmType 报警类型
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return 报警列表
|
||||
*/
|
||||
PageInfo<DeviceAlarm> getAllAlarm(int page, int count, String deviceId, String channelId, String alarmPriority, String alarmMethod,
|
||||
String alarmType, String startTime, String endTime);
|
||||
|
||||
/**
|
||||
* 添加一个报警
|
||||
* @param deviceAlarm 添加报警
|
||||
*/
|
||||
void add(DeviceAlarm deviceAlarm);
|
||||
|
||||
/**
|
||||
* 清空时间以前的报警
|
||||
* @param id 数据库id
|
||||
* @param deviceIdList 制定需要清理的设备id
|
||||
* @param time 不写时间则清空所有时间的
|
||||
*/
|
||||
int clearAlarmBeforeTime(Integer id, List<String> deviceIdList, String time);
|
||||
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
package com.genersoft.iot.vmp.gb28181.service.impl;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.DeviceAlarmMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IDeviceAlarmService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class DeviceAlarmServiceImpl implements IDeviceAlarmService {
|
||||
|
||||
@Autowired
|
||||
private DeviceAlarmMapper deviceAlarmMapper;
|
||||
|
||||
@Override
|
||||
public PageInfo<DeviceAlarm> getAllAlarm(int page, int count, String deviceId, String channelId, String alarmPriority, String alarmMethod, String alarmType, String startTime, String endTime) {
|
||||
PageHelper.startPage(page, count);
|
||||
List<DeviceAlarm> all = deviceAlarmMapper.query(deviceId, channelId, alarmPriority, alarmMethod, alarmType, startTime, endTime);
|
||||
return new PageInfo<>(all);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(DeviceAlarm deviceAlarm) {
|
||||
deviceAlarmMapper.add(deviceAlarm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int clearAlarmBeforeTime(Integer id, List<String> deviceIdList, String time) {
|
||||
return deviceAlarmMapper.clearAlarmBeforeTime(id, deviceIdList, time);
|
||||
}
|
||||
}
|
||||
@ -147,7 +147,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
|
||||
deviceAlarm.setLatitude(0.00);
|
||||
}
|
||||
log.info("[收到Notify-Alarm]:{}/{}", device.getDeviceId(), deviceAlarm.getChannelId());
|
||||
if ("4".equals(deviceAlarm.getAlarmMethod())) {
|
||||
if ("4".equals(deviceAlarm.getAlarmMethod())) { // GPS报警
|
||||
DeviceChannel deviceChannel = deviceChannelService.getOne(device.getDeviceId(), channelId);
|
||||
if (deviceChannel == null) {
|
||||
log.warn("[解析报警通知] 未找到通道:{}/{}", device.getDeviceId(), channelId);
|
||||
|
||||
@ -6,7 +6,6 @@ import com.genersoft.iot.vmp.conf.SipConfig;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IDeviceAlarmService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
|
||||
@ -59,9 +58,6 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
|
||||
@Autowired
|
||||
private IRedisCatchStorage redisCatchStorage;
|
||||
|
||||
@Autowired
|
||||
private IDeviceAlarmService deviceAlarmService;
|
||||
|
||||
@Autowired
|
||||
private IDeviceChannelService deviceChannelService;
|
||||
|
||||
@ -111,6 +107,7 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
|
||||
|
||||
try {
|
||||
Device device = sipMsgInfo.getDevice();
|
||||
System.out.println(device.getHostAddress() + ": " + evt.getRequest());
|
||||
Element deviceIdElement = sipMsgInfo.getRootElement().element("DeviceID");
|
||||
String channelId = deviceIdElement.getText();
|
||||
|
||||
@ -196,7 +193,7 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
|
||||
log.debug("存储报警信息、报警分类");
|
||||
// 存储报警信息、报警分类
|
||||
if (sipConfig.isAlarm()) {
|
||||
deviceAlarmService.add(deviceAlarm);
|
||||
// deviceAlarmService.add(deviceAlarm);
|
||||
}
|
||||
|
||||
if (redisCatchStorage.deviceIsOnline(sipMsgInfo.getDevice().getDeviceId())) {
|
||||
|
||||
@ -0,0 +1,25 @@
|
||||
package com.genersoft.iot.vmp.service;
|
||||
|
||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.service.bean.Alarm;
|
||||
import com.genersoft.iot.vmp.service.bean.AlarmType;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IAlarmService {
|
||||
// 保存报警信息
|
||||
void saveAlarmInfo(Alarm alarm);
|
||||
|
||||
// 分页获取报警信息
|
||||
PageInfo<Alarm> getAlarms(int page, int size, List<AlarmType> alarmType, String beginTime, String endTime);
|
||||
|
||||
// 删除报警信息
|
||||
void deleteAlarmInfo(List<Long> ids);
|
||||
|
||||
// 根据ID获取报警快照
|
||||
String getAlarmSnapById(Long id);
|
||||
|
||||
// 根据ID获取报警录像
|
||||
StreamInfo getAlarmRecordById(Long id);
|
||||
}
|
||||
44
src/main/java/com/genersoft/iot/vmp/service/bean/Alarm.java
Normal file
44
src/main/java/com/genersoft/iot/vmp/service/bean/Alarm.java
Normal file
@ -0,0 +1,44 @@
|
||||
package com.genersoft.iot.vmp.service.bean;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Schema(description = "报警信息")
|
||||
public class Alarm {
|
||||
|
||||
@Schema(description = "数据库id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "关联通道的数据库id")
|
||||
private int channelId;
|
||||
|
||||
@Schema(description = "报警描述")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "报警快照路径")
|
||||
private String snapPath;
|
||||
|
||||
@Schema(description = "报警录像路径")
|
||||
private String recordPath;
|
||||
|
||||
@Schema(description = "报警附带的经度")
|
||||
private String longitude;
|
||||
|
||||
@Schema(description = "报警附带的纬度")
|
||||
private String latitude;
|
||||
|
||||
@Schema(description = "报警类别")
|
||||
private AlarmType alarmType;
|
||||
|
||||
@Schema(description = "报警时间")
|
||||
private Long alarmTime;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
package com.genersoft.iot.vmp.service.bean;
|
||||
|
||||
public enum AlarmType {
|
||||
|
||||
// 视频丢失报警
|
||||
VideoLoss("视频丢失报警"),
|
||||
// 设备防拆报警
|
||||
DeviceTamper("设备防拆报警"),
|
||||
// 存储设备磁盘满报警
|
||||
StorageFull("存储设备磁盘满报警"),
|
||||
// 设备高温报警
|
||||
DeviceHighTemperature("设备高温报警"),
|
||||
// 设备低温报警
|
||||
DeviceLowTemperature("设备低温报警"),
|
||||
// 人工视频报警
|
||||
ManualVideo("人工视频报警"),
|
||||
// 运动目标检测报警
|
||||
MotionDetection("运动目标检测报警"),
|
||||
// 遗留物检测报警
|
||||
LeftObjectDetection("遗留物检测报警"),
|
||||
// 物体移除检测报警
|
||||
ObjectRemovalDetection("物体移除检测报警"),
|
||||
// 绊线检测报警
|
||||
TripwireDetection("绊线检测报警"),
|
||||
// 入侵检测报警
|
||||
IntrusionDetection("入侵检测报警"),
|
||||
// 移动侦测报警
|
||||
MobileDetection("移动侦测报警"),
|
||||
// 视频遮挡报警
|
||||
VideoOcclusion("视频遮挡报警"),
|
||||
// 逆行检测报警
|
||||
ReverseDetection("逆行检测报警"),
|
||||
// 徘徊检测报警
|
||||
LoiteringDetection("徘徊检测报警"),
|
||||
// 流量统计报警
|
||||
FlowStatistics("流量统计报警"),
|
||||
// 密度检测报警
|
||||
DensityDetection("密度检测报警"),
|
||||
// 视频异常检测报警
|
||||
VideoAbnormal("视频异常检测报警"),
|
||||
// 快速移动报警
|
||||
RapidMovement("快速移动报警"),
|
||||
// 存储设备磁盘故障报警
|
||||
StorageFault("存储设备磁盘故障报警"),
|
||||
// 存储设备风扇故障报警
|
||||
StorageFanFault("存储设备风扇故障报警"),
|
||||
// 声音异常报警
|
||||
SoundAbnormal("声音异常报警"),
|
||||
// 信号量异常报警
|
||||
SignalAbnormal("信号量异常报警"),
|
||||
// 非法访问报警
|
||||
IllegalAccess("非法访问报警"),
|
||||
// 虚焦报警
|
||||
Defocus("虚焦报警"),
|
||||
// 场景变更报警
|
||||
SceneChange("场景变更报警"),
|
||||
// 人员聚集报警
|
||||
CrowdGathering("人员聚集报警"),
|
||||
// 停车侦测报警
|
||||
ParkingDetection("停车侦测报警"),
|
||||
// 其他报警
|
||||
Other("其他报警");
|
||||
|
||||
private String description;
|
||||
|
||||
AlarmType(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
package com.genersoft.iot.vmp.service.impl;
|
||||
|
||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.service.IAlarmService;
|
||||
import com.genersoft.iot.vmp.service.bean.Alarm;
|
||||
import com.genersoft.iot.vmp.service.bean.AlarmType;
|
||||
import com.genersoft.iot.vmp.storager.dao.AlarmMapper;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AlarmServiceImpl implements IAlarmService {
|
||||
|
||||
private final AlarmMapper alarmMapper;
|
||||
|
||||
@Override
|
||||
public void saveAlarmInfo(Alarm alarm) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<Alarm> getAlarms(int page, int count, List<AlarmType> alarmType, String beginTime, String endTime) {
|
||||
PageHelper.startPage(page, count);
|
||||
Long beginTimeLong = null;
|
||||
Long endTimeLong = null;
|
||||
if (beginTime != null) {
|
||||
beginTimeLong = DateUtil.yyyy_MM_dd_HH_mm_ssToTimestampMs(beginTime);
|
||||
}
|
||||
if (endTime != null) {
|
||||
endTimeLong = DateUtil.yyyy_MM_dd_HH_mm_ssToTimestampMs(endTime);
|
||||
}
|
||||
List<Alarm> alarmList = alarmMapper.getAlarms(alarmType, beginTimeLong, endTimeLong);
|
||||
return new PageInfo<>(alarmList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAlarmInfo(List<Long> ids) {
|
||||
if (ids != null && !ids.isEmpty()) {
|
||||
alarmMapper.deleteAlarms(ids);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAlarmSnapById(Long id) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public StreamInfo getAlarmRecordById(Long id) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
package com.genersoft.iot.vmp.storager.dao;
|
||||
|
||||
import com.genersoft.iot.vmp.service.bean.Alarm;
|
||||
import com.genersoft.iot.vmp.service.bean.AlarmType;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface AlarmMapper {
|
||||
|
||||
@Select("<script>" +
|
||||
"SELECT * FROM wvp_alarm WHERE 1=1" +
|
||||
"<if test='alarmType != null and alarmType.size() > 0'>" +
|
||||
" AND alarmType IN " +
|
||||
"<foreach collection='alarmType' item='item' open='(' separator=',' close=')'>" +
|
||||
"#{item}" +
|
||||
"</foreach>" +
|
||||
"</if>" +
|
||||
"<if test='beginTimeLong != null'> AND alarmTime >= #{beginTimeLong}</if>" +
|
||||
"<if test='endTimeLong != null'> AND alarmTime <= #{endTimeLong}</if>" +
|
||||
" ORDER BY alarmTime DESC" +
|
||||
"</script>")
|
||||
List<Alarm> getAlarms(@Param("alarmType") List<AlarmType> alarmType,
|
||||
@Param("beginTimeLong") Long beginTimeLong,
|
||||
@Param("endTimeLong") Long endTimeLong);
|
||||
|
||||
@Delete("<script>" +
|
||||
"DELETE FROM wvp_alarm WHERE id IN " +
|
||||
"<foreach collection='ids' item='id' open='(' separator=',' close=')'>" +
|
||||
"#{id}" +
|
||||
"</foreach>" +
|
||||
"</script>")
|
||||
void deleteAlarms(@Param("ids") List<Long> ids);
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
package com.genersoft.iot.vmp.vmanager.alarm;
|
||||
|
||||
import com.genersoft.iot.vmp.conf.security.JwtUtils;
|
||||
import com.genersoft.iot.vmp.service.IAlarmService;
|
||||
import com.genersoft.iot.vmp.service.bean.AlarmType;
|
||||
import com.genersoft.iot.vmp.service.bean.Alarm;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "报警管理接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/alarm")
|
||||
@RequiredArgsConstructor
|
||||
public class AlarmController {
|
||||
|
||||
private final IAlarmService alarmService;
|
||||
|
||||
@ResponseBody
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "分页查询报警列表", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
@Parameter(name = "count", description = "每页查询数量", required = true)
|
||||
@Parameter(name = "alarmType", description = "报警类型列表,多个类型用逗号分隔")
|
||||
@Parameter(name = "beginTime", description = "开始时间,格式:yyyy-MM-dd HH:mm:ss")
|
||||
@Parameter(name = "endTime", description = "结束时间,格式:yyyy-MM-dd HH:mm:ss")
|
||||
public PageInfo<Alarm> list(@RequestParam Integer page,
|
||||
@RequestParam Integer count,
|
||||
@RequestParam(required = false) List<AlarmType> alarmType,
|
||||
@RequestParam(required = false) String beginTime,
|
||||
@RequestParam(required = false) String endTime) {
|
||||
return alarmService.getAlarms(page, count, alarmType, beginTime, endTime);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除报警信息", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "ids", description = "报警ID列表", required = true)
|
||||
public void delete(@RequestBody List<Long> ids) {
|
||||
alarmService.deleteAlarmInfo(ids);
|
||||
}
|
||||
}
|
||||
@ -163,6 +163,19 @@ export const constantRoutes = [
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/alarm',
|
||||
component: Layout,
|
||||
redirect: '/alarm',
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
name: 'AlarmManage',
|
||||
component: () => import('@/views/alarm/index'),
|
||||
meta: { title: '报警管理', icon: 'el-icon-bell' }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/recordPlan',
|
||||
component: Layout,
|
||||
|
||||
@ -23,6 +23,7 @@ import gbRecord from './modules/gbRecord'
|
||||
import log from './modules/log'
|
||||
import frontEnd from './modules/frontEnd'
|
||||
import jtDevice from './modules/jtDevice'
|
||||
import alarm from './modules/alarm'
|
||||
|
||||
Vue.use(Vuex)
|
||||
|
||||
@ -49,7 +50,8 @@ const store = new Vuex.Store({
|
||||
gbRecord,
|
||||
log,
|
||||
frontEnd,
|
||||
jtDevice
|
||||
jtDevice,
|
||||
alarm
|
||||
},
|
||||
getters
|
||||
})
|
||||
|
||||
@ -524,3 +524,17 @@ create table IF NOT EXISTS wvp_jt_channel (
|
||||
create_time character varying(50) not null COMMENT '创建时间',
|
||||
constraint uk_jt_channel_id_device_id unique (terminal_db_id, channel_id)
|
||||
);
|
||||
|
||||
-- 报警信息表,表结构参考alarm类
|
||||
drop table IF EXISTS wvp_alarm;
|
||||
create table IF NOT EXISTS wvp_alarm (
|
||||
id serial primary key COMMENT '主键ID',
|
||||
channelId integer COMMENT '关联通道的数据库id',
|
||||
description character varying(255) COMMENT '报警描述',
|
||||
snapPath character varying(255) COMMENT '报警快照路径',
|
||||
recordPath character varying(255) COMMENT '报警录像路径',
|
||||
longitude double precision COMMENT '报警附带的经度',
|
||||
latitude double precision COMMENT '报警附带的纬度',
|
||||
alarmType integer COMMENT '报警类别',
|
||||
alarmTime bigint COMMENT '报警时间'
|
||||
);
|
||||
|
||||
@ -918,3 +918,28 @@ COMMENT ON COLUMN wvp_jt_channel.has_audio IS '是否有音频';
|
||||
COMMENT ON COLUMN wvp_jt_channel.name IS '通道名称';
|
||||
COMMENT ON COLUMN wvp_jt_channel.update_time IS '更新时间';
|
||||
COMMENT ON COLUMN wvp_jt_channel.create_time IS '创建时间';
|
||||
|
||||
|
||||
drop table IF EXISTS wvp_alarm;
|
||||
create table IF NOT EXISTS wvp_alarm (
|
||||
id serial primary key,
|
||||
channelId integer,
|
||||
description character varying(255),
|
||||
snapPath character varying(255),
|
||||
recordPath character varying(255),
|
||||
longitude double precision,
|
||||
latitude double precision,
|
||||
alarmType integer,
|
||||
alarmTime bigint
|
||||
)
|
||||
COMMENT ON COLUMN wvp_alarm.id IS '主键ID';
|
||||
COMMENT ON COLUMN wvp_alarm.channelId IS '关联通道的数据库id';
|
||||
COMMENT ON COLUMN wvp_alarm.description IS '报警描述';
|
||||
COMMENT ON COLUMN wvp_alarm.snapPath IS '报警快照路径';
|
||||
COMMENT ON COLUMN wvp_alarm.recordPath IS '报警录像路径';
|
||||
COMMENT ON COLUMN wvp_alarm.longitude IS '报警附带的经度';
|
||||
COMMENT ON COLUMN wvp_alarm.latitude IS '报警附带的纬度';
|
||||
COMMENT ON COLUMN wvp_alarm.alarmType IS '报警类别';
|
||||
COMMENT ON COLUMN wvp_alarm.alarmTime IS '报警时间';
|
||||
|
||||
|
||||
|
||||
@ -142,6 +142,20 @@ DROP PROCEDURE wvp_202601025;
|
||||
DELIMITER ;
|
||||
|
||||
|
||||
drop table IF EXISTS wvp_alarm;
|
||||
create table IF NOT EXISTS wvp_alarm (
|
||||
id serial primary key COMMENT '主键ID',
|
||||
channelId integer COMMENT '关联通道的数据库id',
|
||||
description character varying(255) COMMENT '报警描述',
|
||||
snapPath character varying(255) COMMENT '报警快照路径',
|
||||
recordPath character varying(255) COMMENT '报警录像路径',
|
||||
longitude double precision COMMENT '报警附带的经度',
|
||||
latitude double precision COMMENT '报警附带的纬度',
|
||||
alarmType integer COMMENT '报警类别',
|
||||
alarmTime bigint COMMENT '报警时间'
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -47,3 +47,25 @@ drop index uk_media_server_unique_ip_http_port on wvp_media_server;
|
||||
|
||||
ALTER table wvp_device DROP COLUMN IF EXISTS register_time;
|
||||
ALTER table wvp_device DROP COLUMN IF EXISTS keepalive_time;
|
||||
|
||||
drop table IF EXISTS wvp_alarm;
|
||||
create table IF NOT EXISTS wvp_alarm (
|
||||
id serial primary key,
|
||||
channelId integer,
|
||||
description character varying(255),
|
||||
snapPath character varying(255),
|
||||
recordPath character varying(255),
|
||||
longitude double precision,
|
||||
latitude double precision,
|
||||
alarmType integer,
|
||||
alarmTime bigint
|
||||
)
|
||||
COMMENT ON COLUMN wvp_alarm.id IS '主键ID';
|
||||
COMMENT ON COLUMN wvp_alarm.channelId IS '关联通道的数据库id';
|
||||
COMMENT ON COLUMN wvp_alarm.description IS '报警描述';
|
||||
COMMENT ON COLUMN wvp_alarm.snapPath IS '报警快照路径';
|
||||
COMMENT ON COLUMN wvp_alarm.recordPath IS '报警录像路径';
|
||||
COMMENT ON COLUMN wvp_alarm.longitude IS '报警附带的经度';
|
||||
COMMENT ON COLUMN wvp_alarm.latitude IS '报警附带的纬度';
|
||||
COMMENT ON COLUMN wvp_alarm.alarmType IS '报警类别';
|
||||
COMMENT ON COLUMN wvp_alarm.alarmTime IS '报警时间';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user