From 2a5404c68f387523a833b8e9f17cda5b0c9ad727 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期四, 26 五月 2022 13:45:57 +0800 Subject: [PATCH] 兼容海康信令问题 #493 --- src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java | 24 +++++------------------- 1 files changed, 5 insertions(+), 19 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..0edec51 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"); /** * 鍒嗛〉鏌ヨ鎶ヨ @@ -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