From 28df05e261c0d63050d0bd938b7a6a2c2938b8e9 Mon Sep 17 00:00:00 2001 From: mrjackwang <30337754+mrjackwang@users.noreply.github.com> Date: 星期六, 06 八月 2022 09:42:28 +0800 Subject: [PATCH] Merge branch '648540858:wvp-28181-2.0' into wvp-28181-2.0 --- src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java | 28 +++++++--------------------- 1 files changed, 7 insertions(+), 21 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 addc431..509c988 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 @@ -9,6 +9,7 @@ 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; @@ -23,9 +24,8 @@ 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 = "鎶ヨ淇℃伅绠$悊") @@ -45,9 +45,6 @@ @Autowired private IVideoManagerStorage storage; - - private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - private SimpleDateFormat formatForGB = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); /** * 鍒嗛〉鏌ヨ鎶ヨ @@ -72,8 +69,8 @@ @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), + @ApiImplicitParam(name="startTime", value = "寮�濮嬫椂闂�" ,dataTypeClass = String.class), + @ApiImplicitParam(name="endTime", value = "缁撴潫鏃堕棿" ,dataTypeClass = String.class), }) public ResponseEntity<PageInfo<DeviceAlarm>> getAll( @RequestParam int page, @@ -102,14 +99,7 @@ } - try { - if (startTime != null) { - format.parse(startTime); - } - if (endTime != null) { - format.parse(endTime); - } - } catch (ParseException e) { + if (!DateUtil.verification(startTime, DateUtil.formatter) || !DateUtil.verification(endTime, DateUtil.formatter)){ return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST); } @@ -148,11 +138,7 @@ if (StringUtils.isEmpty(time)) { time = null; } - try { - if (time != null) { - format.parse(time); - } - } catch (ParseException e) { + if (!DateUtil.verification(time, DateUtil.formatter) ){ return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST); } List<String> deviceIdList = null; @@ -193,7 +179,7 @@ deviceAlarm.setAlarmDescription("test"); deviceAlarm.setAlarmMethod("1"); deviceAlarm.setAlarmPriority("1"); - deviceAlarm.setAlarmTime(formatForGB.format(System.currentTimeMillis())); + deviceAlarm.setAlarmTime(DateUtil.formatterISO8601.format(LocalDateTime.now())); deviceAlarm.setAlarmType("1"); deviceAlarm.setLongitude(115.33333); deviceAlarm.setLatitude(39.33333); -- Gitblit v1.8.0