From 4ee8924bd9dbd36046d922d9480de310ee16b6ac Mon Sep 17 00:00:00 2001 From: zx <zuoxue@qq.com> Date: 星期五, 19 八月 2022 21:55:59 +0800 Subject: [PATCH] fix PlatformKeepaliveExpireEvent typo --- src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java | 218 ++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 137 insertions(+), 81 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java index 434bbd4..79b7d58 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java @@ -1,28 +1,29 @@ package com.genersoft.iot.vmp.vmanager.gb28181.alarm; +import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; +import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; +import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; +import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; import com.genersoft.iot.vmp.service.IDeviceAlarmService; -import com.genersoft.iot.vmp.service.IGbStreamService; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; +import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.github.pagehelper.PageInfo; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; -import io.swagger.models.auth.In; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; -import java.text.ParseException; -import java.text.SimpleDateFormat; +import java.time.LocalDateTime; import java.util.Arrays; -import java.util.Date; import java.util.List; -@Api(tags = "鎶ヨ淇℃伅绠$悊") +@Tag(name = "鎶ヨ淇℃伅绠$悊") @CrossOrigin @RestController @RequestMapping("/api/alarm") @@ -31,62 +32,14 @@ @Autowired private IDeviceAlarmService deviceAlarmService; - private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + @Autowired + private ISIPCommander commander; - /** - * 鍒嗛〉鏌ヨ鎶ヨ - * - * @param deviceId 璁惧id - * @param page 褰撳墠椤� - * @param count 姣忛〉鏌ヨ鏁伴噺 - * @param alarmPriority 鎶ヨ绾у埆 - * @param alarmMethod 鎶ヨ鏂瑰紡 - * @param alarmType 鎶ヨ绫诲瀷 - * @param startTime 寮�濮嬫椂闂� - * @param endTime 缁撴潫鏃堕棿 - * @return - */ - @ApiOperation("鍒嗛〉鏌ヨ鎶ヨ") - @GetMapping("/all") - @ApiImplicitParams({ - @ApiImplicitParam(name="deviceId", value = "璁惧id", dataTypeClass = String.class), - @ApiImplicitParam(name="page", value = "褰撳墠椤�", required = true ,dataTypeClass = Integer.class), - @ApiImplicitParam(name="count", value = "姣忛〉鏌ヨ鏁伴噺", required = true ,dataTypeClass = Integer.class), - @ApiImplicitParam(name="alarmPriority", value = "鏌ヨ鍐呭" ,dataTypeClass = String.class), - @ApiImplicitParam(name="alarmMethod", value = "鏌ヨ鍐呭" ,dataTypeClass = String.class), - @ApiImplicitParam(name="alarmMethod", value = "鏌ヨ鍐呭" ,dataTypeClass = String.class), - @ApiImplicitParam(name="alarmType", value = "鏌ヨ鍐呭" ,dataTypeClass = String.class), - @ApiImplicitParam(name="startTime", value = "鏌ヨ鍐呭" ,dataTypeClass = String.class), - @ApiImplicitParam(name="endTime", value = "鏌ヨ鍐呭" ,dataTypeClass = String.class), - }) - public ResponseEntity<PageInfo<DeviceAlarm>> getAll( - @RequestParam int page, - @RequestParam int count, - @RequestParam(required = false) String deviceId, - @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 (StringUtils.isEmpty(alarmPriority)) alarmPriority = null; - if (StringUtils.isEmpty(alarmMethod)) alarmMethod = null; - if (StringUtils.isEmpty(alarmType)) alarmType = null; - if (StringUtils.isEmpty(startTime)) startTime = null; - if (StringUtils.isEmpty(endTime)) endTime = null; + @Autowired + private ISIPCommanderForPlatform commanderForPlatform; - - try { - if (startTime != null) format.parse(startTime); - if (endTime != null) format.parse(endTime); - } catch (ParseException e) { - return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST); - } - - PageInfo<DeviceAlarm> allAlarm = deviceAlarmService.getAllAlarm(page, count, deviceId, alarmPriority, alarmMethod, - alarmType, startTime, endTime); - return new ResponseEntity<>(allAlarm, HttpStatus.OK); - } + @Autowired + private IVideoManagerStorage storage; /** @@ -97,26 +50,26 @@ * @param time 缁撴潫鏃堕棿(杩欎釜鏃堕棿涔嬪墠鐨勬姤璀︿細琚垹闄�) * @return */ - @ApiOperation("鍒犻櫎鎶ヨ") @DeleteMapping("/delete") - @ApiImplicitParams({ - @ApiImplicitParam(name="id", value = "ID", required = false ,dataTypeClass = Integer.class), - @ApiImplicitParam(name="deviceIds", value = "澶氫釜璁惧id,閫楀彿鍒嗛殧", required = false ,dataTypeClass = String.class), - @ApiImplicitParam(name="time", value = "缁撴潫鏃堕棿", required = false ,dataTypeClass = String.class), - }) + @Operation(summary = "鍒犻櫎鎶ヨ") + @Parameter(name = "id", description = "ID") + @Parameter(name = "deviceIds", description = "澶氫釜璁惧id,閫楀彿鍒嗛殧") + @Parameter(name = "time", description = "缁撴潫鏃堕棿") public ResponseEntity<WVPResult<String>> delete( - @RequestParam(required = false) Integer id, - @RequestParam(required = false) String deviceIds, - @RequestParam(required = false) String time + @RequestParam(required = false) Integer id, + @RequestParam(required = false) String deviceIds, + @RequestParam(required = false) String time ) { - if (StringUtils.isEmpty(id)) id = null; - if (StringUtils.isEmpty(deviceIds)) deviceIds = null; - if (StringUtils.isEmpty(time)) time = null; - try { - if (time != null) { - format.parse(time); - } - } catch (ParseException e) { + if (StringUtils.isEmpty(id)) { + id = null; + } + if (StringUtils.isEmpty(deviceIds)) { + deviceIds = null; + } + if (StringUtils.isEmpty(time)) { + time = null; + } + if (!DateUtil.verification(time, DateUtil.formatter) ){ return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST); } List<String> deviceIdList = null; @@ -133,5 +86,108 @@ return new ResponseEntity<WVPResult<String>>(wvpResult, HttpStatus.OK); } + /** + * 娴嬭瘯鍚戜笂绾�/璁惧鍙戦�佹ā鎷熸姤璀﹂�氱煡 + * + * @param deviceId 鎶ヨid + * @return + */ + @GetMapping("/test/notify/alarm") + @Operation(summary = "娴嬭瘯鍚戜笂绾�/璁惧鍙戦�佹ā鎷熸姤璀﹂�氱煡") + @Parameter(name = "deviceId", description = "璁惧鍥芥爣缂栧彿") + public ResponseEntity<WVPResult<String>> delete( + @RequestParam(required = false) String deviceId + ) { + if (StringUtils.isEmpty(deviceId)) { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + Device device = storage.queryVideoDevice(deviceId); + ParentPlatform platform = storage.queryParentPlatByServerGBId(deviceId); + DeviceAlarm deviceAlarm = new DeviceAlarm(); + deviceAlarm.setChannelId(deviceId); + deviceAlarm.setAlarmDescription("test"); + deviceAlarm.setAlarmMethod("1"); + deviceAlarm.setAlarmPriority("1"); + deviceAlarm.setAlarmTime(DateUtil.formatterISO8601.format(LocalDateTime.now())); + deviceAlarm.setAlarmType("1"); + deviceAlarm.setLongitude(115.33333); + deviceAlarm.setLatitude(39.33333); + + if (device != null && platform == null) { + commander.sendAlarmMessage(device, deviceAlarm); + }else if (device == null && platform != null){ + commanderForPlatform.sendAlarmMessage(platform, deviceAlarm); + }else { + WVPResult wvpResult = new WVPResult(); + wvpResult.setCode(0); + wvpResult.setMsg("鏃犳硶纭畾" + deviceId + "鏄钩鍙拌繕鏄澶�"); + return new ResponseEntity<WVPResult<String>>(wvpResult, HttpStatus.OK); + } + + WVPResult wvpResult = new WVPResult(); + wvpResult.setCode(0); + wvpResult.setMsg("success"); + return new ResponseEntity<WVPResult<String>>(wvpResult, HttpStatus.OK); + } + + /** + * 鍒嗛〉鏌ヨ鎶ヨ + * + * @param deviceId 璁惧id + * @param page 褰撳墠椤� + * @param count 姣忛〉鏌ヨ鏁伴噺 + * @param alarmPriority 鎶ヨ绾у埆 + * @param alarmMethod 鎶ヨ鏂瑰紡 + * @param alarmType 鎶ヨ绫诲瀷 + * @param startTime 寮�濮嬫椂闂� + * @param endTime 缁撴潫鏃堕棿 + * @return + */ + @Operation(summary = "鍒嗛〉鏌ヨ鎶ヨ") + @Parameter(name = "page",description = "褰撳墠椤�",required = true) + @Parameter(name = "count",description = "姣忛〉鏌ヨ鏁伴噺",required = true) + @Parameter(name = "deviceId",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 ResponseEntity<PageInfo<DeviceAlarm>> getAll( + @RequestParam int page, + @RequestParam int count, + @RequestParam(required = false) String deviceId, + @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 (StringUtils.isEmpty(alarmPriority)) { + alarmPriority = null; + } + if (StringUtils.isEmpty(alarmMethod)) { + alarmMethod = null; + } + if (StringUtils.isEmpty(alarmType)) { + alarmType = null; + } + if (StringUtils.isEmpty(startTime)) { + startTime = null; + } + if (StringUtils.isEmpty(endTime)) { + endTime = null; + } + + + if (!DateUtil.verification(startTime, DateUtil.formatter) || !DateUtil.verification(endTime, DateUtil.formatter)){ + return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST); + } + + PageInfo<DeviceAlarm> allAlarm = deviceAlarmService.getAllAlarm(page, count, deviceId, alarmPriority, alarmMethod, + alarmType, startTime, endTime); + return new ResponseEntity<>(allAlarm, HttpStatus.OK); + } + } -- Gitblit v1.8.0