old mode 100644
new mode 100755
|  |  |  | 
|---|
|  |  |  | package com.genersoft.iot.vmp.vmanager.gb28181.alarm; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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.ParentPlatform; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookListener; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.service.IDeviceAlarmService; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.utils.DateUtil; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; | 
|---|
|  |  |  | 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.responses.ApiResponse; | 
|---|
|  |  |  | import io.swagger.v3.oas.annotations.security.SecurityRequirement; | 
|---|
|  |  |  | import io.swagger.v3.oas.annotations.tags.Tag; | 
|---|
|  |  |  | import org.slf4j.Logger; | 
|---|
|  |  |  | import org.slf4j.LoggerFactory; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.http.HttpStatus; | 
|---|
|  |  |  | import org.springframework.http.ResponseEntity; | 
|---|
|  |  |  | import org.springframework.util.ObjectUtils; | 
|---|
|  |  |  | import org.springframework.util.StringUtils; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.sip.InvalidArgumentException; | 
|---|
|  |  |  | import javax.sip.SipException; | 
|---|
|  |  |  | import java.text.ParseException; | 
|---|
|  |  |  | import java.time.LocalDateTime; | 
|---|
|  |  |  | import java.util.Arrays; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Tag(name = "报警信息管理") | 
|---|
|  |  |  | @CrossOrigin | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @RequestMapping("/api/alarm") | 
|---|
|  |  |  | public class AlarmController { | 
|---|
|  |  |  | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @DeleteMapping("/delete") | 
|---|
|  |  |  | @Operation(summary = "删除报警") | 
|---|
|  |  |  | @Operation(summary = "删除报警", security = @SecurityRequirement(name = JwtUtils.HEADER)) | 
|---|
|  |  |  | @Parameter(name = "id", description = "ID") | 
|---|
|  |  |  | @Parameter(name = "deviceIds", description = "多个设备id,逗号分隔") | 
|---|
|  |  |  | @Parameter(name = "time", description = "结束时间") | 
|---|
|  |  |  | 
|---|
|  |  |  | if (ObjectUtils.isEmpty(deviceIds)) { | 
|---|
|  |  |  | deviceIds = null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (ObjectUtils.isEmpty(time)) { | 
|---|
|  |  |  | time = null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!DateUtil.verification(time, DateUtil.formatter) ){ | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | }else if (!DateUtil.verification(time, DateUtil.formatter) ){ | 
|---|
|  |  |  | throw new ControllerException(ErrorCode.ERROR400.getCode(), "time格式为" + DateUtil.PATTERN); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<String> deviceIdList = null; | 
|---|
|  |  |  | if (deviceIds != null) { | 
|---|
|  |  |  | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @GetMapping("/test/notify/alarm") | 
|---|
|  |  |  | @Operation(summary = "测试向上级/设备发送模拟报警通知") | 
|---|
|  |  |  | @Operation(summary = "测试向上级/设备发送模拟报警通知", security = @SecurityRequirement(name = JwtUtils.HEADER)) | 
|---|
|  |  |  | @Parameter(name = "deviceId", description = "设备国标编号") | 
|---|
|  |  |  | public void delete(@RequestParam String deviceId) { | 
|---|
|  |  |  | Device device = storage.queryVideoDevice(deviceId); | 
|---|
|  |  |  | 
|---|
|  |  |  | deviceAlarm.setAlarmDescription("test"); | 
|---|
|  |  |  | deviceAlarm.setAlarmMethod("1"); | 
|---|
|  |  |  | deviceAlarm.setAlarmPriority("1"); | 
|---|
|  |  |  | deviceAlarm.setAlarmTime(DateUtil.formatterISO8601.format(LocalDateTime.now())); | 
|---|
|  |  |  | deviceAlarm.setAlarmTime(DateUtil.getNow()); | 
|---|
|  |  |  | deviceAlarm.setAlarmType("1"); | 
|---|
|  |  |  | deviceAlarm.setLongitude(115.33333); | 
|---|
|  |  |  | deviceAlarm.setLatitude(39.33333); | 
|---|
|  |  |  | 
|---|
|  |  |  | * @param endTime 结束时间 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Operation(summary = "分页查询报警") | 
|---|
|  |  |  | @Operation(summary = "分页查询报警", security = @SecurityRequirement(name = JwtUtils.HEADER)) | 
|---|
|  |  |  | @Parameter(name = "page",description = "当前页",required = true) | 
|---|
|  |  |  | @Parameter(name = "count",description = "每页查询数量",required = true) | 
|---|
|  |  |  | @Parameter(name = "deviceId",description = "设备id") | 
|---|
|  |  |  | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!DateUtil.verification(startTime, DateUtil.formatter) || !DateUtil.verification(endTime, DateUtil.formatter)){ | 
|---|
|  |  |  | throw new ControllerException(ErrorCode.ERROR100.getCode(), "开始时间或结束时间格式有误"); | 
|---|
|  |  |  | }else if (!DateUtil.verification(endTime, DateUtil.formatter) ){ | 
|---|
|  |  |  | throw new ControllerException(ErrorCode.ERROR400.getCode(), "endTime格式为" + DateUtil.PATTERN); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return deviceAlarmService.getAllAlarm(page, count, deviceId, alarmPriority, alarmMethod, | 
|---|