From c2835db8d4ae4ec891ae69c63041db76209cdadb Mon Sep 17 00:00:00 2001 From: lin <648540858@qq.com> Date: Thu, 2 Apr 2026 16:33:50 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=97=A7=E7=9A=84=E6=8A=A5?= =?UTF-8?q?=E8=AD=A6=E4=BF=A1=E6=81=AF=E8=A1=A8=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=8A=A5=E8=AD=A6=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../genersoft/iot/vmp/conf/MybatisConfig.java | 3 + .../gb28181/controller/AlarmController.java | 194 ------------------ .../gb28181/service/IDeviceAlarmService.java | 43 ---- .../service/impl/DeviceAlarmServiceImpl.java | 35 ---- .../request/impl/NotifyRequestProcessor.java | 2 +- .../notify/cmd/AlarmNotifyMessageHandler.java | 7 +- .../iot/vmp/service/IAlarmService.java | 25 +++ .../genersoft/iot/vmp/service/bean/Alarm.java | 44 ++++ .../iot/vmp/service/bean/AlarmType.java | 69 +++++++ .../vmp/service/impl/AlarmServiceImpl.java | 58 ++++++ .../iot/vmp/storager/dao/AlarmMapper.java | 38 ++++ .../vmp/vmanager/alarm/AlarmController.java | 50 +++++ web/src/router/index.js | 13 ++ web/src/store/index.js | 4 +- 数据库/2.7.4/初始化-mysql-2.7.4.sql | 14 ++ .../2.7.4/初始化-postgresql-kingbase-2.7.4.sql | 25 +++ 数据库/2.7.4/更新-mysql-2.7.4.sql | 14 ++ .../2.7.4/更新-postgresql-kingbase-2.7.4.sql | 22 ++ 18 files changed, 381 insertions(+), 279 deletions(-) delete mode 100755 src/main/java/com/genersoft/iot/vmp/gb28181/controller/AlarmController.java delete mode 100755 src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceAlarmService.java delete mode 100755 src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceAlarmServiceImpl.java create mode 100644 src/main/java/com/genersoft/iot/vmp/service/IAlarmService.java create mode 100644 src/main/java/com/genersoft/iot/vmp/service/bean/Alarm.java create mode 100644 src/main/java/com/genersoft/iot/vmp/service/bean/AlarmType.java create mode 100644 src/main/java/com/genersoft/iot/vmp/service/impl/AlarmServiceImpl.java create mode 100644 src/main/java/com/genersoft/iot/vmp/storager/dao/AlarmMapper.java create mode 100644 src/main/java/com/genersoft/iot/vmp/vmanager/alarm/AlarmController.java diff --git a/src/main/java/com/genersoft/iot/vmp/conf/MybatisConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/MybatisConfig.java index 7f25a3629..14e74c3ed 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/MybatisConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/MybatisConfig.java @@ -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(); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/AlarmController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/AlarmController.java deleted file mode 100755 index c219d9632..000000000 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/AlarmController.java +++ /dev/null @@ -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 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 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); - } -} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceAlarmService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceAlarmService.java deleted file mode 100755 index 3677188cd..000000000 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceAlarmService.java +++ /dev/null @@ -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 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 deviceIdList, String time); - -} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceAlarmServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceAlarmServiceImpl.java deleted file mode 100755 index 7f73ddf3a..000000000 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceAlarmServiceImpl.java +++ /dev/null @@ -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 getAllAlarm(int page, int count, String deviceId, String channelId, String alarmPriority, String alarmMethod, String alarmType, String startTime, String endTime) { - PageHelper.startPage(page, count); - List 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 deviceIdList, String time) { - return deviceAlarmMapper.clearAlarmBeforeTime(id, deviceIdList, time); - } -} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java index 91dcfeb67..b50247ebd 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java @@ -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); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java index a0c24645c..fd892e310 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java @@ -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())) { diff --git a/src/main/java/com/genersoft/iot/vmp/service/IAlarmService.java b/src/main/java/com/genersoft/iot/vmp/service/IAlarmService.java new file mode 100644 index 000000000..2c158360c --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/IAlarmService.java @@ -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 getAlarms(int page, int size, List alarmType, String beginTime, String endTime); + + // 删除报警信息 + void deleteAlarmInfo(List ids); + + // 根据ID获取报警快照 + String getAlarmSnapById(Long id); + + // 根据ID获取报警录像 + StreamInfo getAlarmRecordById(Long id); +} diff --git a/src/main/java/com/genersoft/iot/vmp/service/bean/Alarm.java b/src/main/java/com/genersoft/iot/vmp/service/bean/Alarm.java new file mode 100644 index 000000000..7a5f1d4f2 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/bean/Alarm.java @@ -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; + + + +} diff --git a/src/main/java/com/genersoft/iot/vmp/service/bean/AlarmType.java b/src/main/java/com/genersoft/iot/vmp/service/bean/AlarmType.java new file mode 100644 index 000000000..7b7051541 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/bean/AlarmType.java @@ -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; + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/AlarmServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/AlarmServiceImpl.java new file mode 100644 index 000000000..b7fcdd275 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/AlarmServiceImpl.java @@ -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 getAlarms(int page, int count, List 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 alarmList = alarmMapper.getAlarms(alarmType, beginTimeLong, endTimeLong); + return new PageInfo<>(alarmList); + } + + @Override + public void deleteAlarmInfo(List ids) { + if (ids != null && !ids.isEmpty()) { + alarmMapper.deleteAlarms(ids); + } + } + + @Override + public String getAlarmSnapById(Long id) { + return ""; + } + + @Override + public StreamInfo getAlarmRecordById(Long id) { + return null; + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/AlarmMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/AlarmMapper.java new file mode 100644 index 000000000..c334159b5 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/AlarmMapper.java @@ -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("") + List getAlarms(@Param("alarmType") List alarmType, + @Param("beginTimeLong") Long beginTimeLong, + @Param("endTimeLong") Long endTimeLong); + + @Delete("") + void deleteAlarms(@Param("ids") List ids); +} diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/alarm/AlarmController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/alarm/AlarmController.java new file mode 100644 index 000000000..a817c56a7 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/alarm/AlarmController.java @@ -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 list(@RequestParam Integer page, + @RequestParam Integer count, + @RequestParam(required = false) List 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 ids) { + alarmService.deleteAlarmInfo(ids); + } +} diff --git a/web/src/router/index.js b/web/src/router/index.js index 1d844fa93..d89643fec 100644 --- a/web/src/router/index.js +++ b/web/src/router/index.js @@ -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, diff --git a/web/src/store/index.js b/web/src/store/index.js index 138c4abed..cbd5dd8a9 100644 --- a/web/src/store/index.js +++ b/web/src/store/index.js @@ -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 }) diff --git a/数据库/2.7.4/初始化-mysql-2.7.4.sql b/数据库/2.7.4/初始化-mysql-2.7.4.sql index 594f77c4d..b38a3ad02 100644 --- a/数据库/2.7.4/初始化-mysql-2.7.4.sql +++ b/数据库/2.7.4/初始化-mysql-2.7.4.sql @@ -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 '报警时间' +); diff --git a/数据库/2.7.4/初始化-postgresql-kingbase-2.7.4.sql b/数据库/2.7.4/初始化-postgresql-kingbase-2.7.4.sql index 34b291a0c..8ff24201d 100644 --- a/数据库/2.7.4/初始化-postgresql-kingbase-2.7.4.sql +++ b/数据库/2.7.4/初始化-postgresql-kingbase-2.7.4.sql @@ -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 '报警时间'; + + diff --git a/数据库/2.7.4/更新-mysql-2.7.4.sql b/数据库/2.7.4/更新-mysql-2.7.4.sql index 823c9a074..e269c351a 100644 --- a/数据库/2.7.4/更新-mysql-2.7.4.sql +++ b/数据库/2.7.4/更新-mysql-2.7.4.sql @@ -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 '报警时间' +); + + diff --git a/数据库/2.7.4/更新-postgresql-kingbase-2.7.4.sql b/数据库/2.7.4/更新-postgresql-kingbase-2.7.4.sql index c88765ccb..c5818daef 100644 --- a/数据库/2.7.4/更新-postgresql-kingbase-2.7.4.sql +++ b/数据库/2.7.4/更新-postgresql-kingbase-2.7.4.sql @@ -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 '报警时间';