兼容不规范的时间格式iso8601格式;升级fastjson版本
| | |
| | | [hotcoffie](https://github.com/hotcoffie) [xiaomu](https://github.com/nikmu) [TristingChen](https://github.com/TristingChen) |
| | | [chenparty](https://github.com/chenparty) [Hotleave](https://github.com/hotleave) [ydwxb](https://github.com/ydwxb) |
| | | [ydpd](https://github.com/ydpd) [szy833](https://github.com/szy833) [ydwxb](https://github.com/ydwxb) [Albertzhu666](https://github.com/Albertzhu666) |
| | | [mk1990](https://github.com/mk1990) |
| | | |
| | | ps: 刚增加了这个名单,肯定遗漏了一些大佬,欢迎大佬联系我添加。 |
| | | |
| | |
| | | <dependency> |
| | | <groupId>com.alibaba</groupId> |
| | | <artifactId>fastjson</artifactId> |
| | | <version>1.2.73</version> |
| | | <version>1.2.83</version> |
| | | </dependency> |
| | | |
| | | |
| | | <!-- okhttp --> |
| | | <dependency> |
| | | <groupId>com.squareup.okhttp3</groupId> |
| | |
| | | return dialog;
|
| | | }
|
| | |
|
| | | public SIPDialog getDialogByCallId(String deviceId, String channelId, String callID){
|
| | | SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, callID, null);
|
| | | public SIPDialog getDialogByCallId(String deviceId, String channelId, String callId){
|
| | | SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, callId, null);
|
| | | if (ssrcTransaction == null) {
|
| | | return null;
|
| | | }
|
| | |
| | | if (dialogByteArray == null) {
|
| | | return null;
|
| | | }
|
| | | SIPDialog dialog = (SIPDialog)SerializeUtils.deSerialize(dialogByteArray);
|
| | | return dialog;
|
| | | return (SIPDialog)SerializeUtils.deSerialize(dialogByteArray);
|
| | | }
|
| | |
|
| | | public SsrcTransaction getSsrcTransaction(String deviceId, String channelId, String callId, String stream){
|
| | |
| | | import com.genersoft.iot.vmp.gb28181.bean.GbStream;
|
| | | import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
|
| | | import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
| | | import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
|
| | | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
| | | import com.genersoft.iot.vmp.media.zlm.dto.*;
|
| | | import com.genersoft.iot.vmp.service.*;
|
| | |
| | | logger.info("[ZLM] 上线 ID:" + event.getMediaServerId()); |
| | | streamPushService.zlmServerOnline(event.getMediaServerId()); |
| | | streamProxyService.zlmServerOnline(event.getMediaServerId()); |
| | | |
| | | playService.zlmServerOnline(event.getMediaServerId()); |
| | | } |
| | | |
| | | @Async |
| | |
| | | DeferredResult<ResponseEntity<String>> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); |
| | | |
| | | StreamInfo getDownLoadInfo(String deviceId, String channelId, String stream); |
| | | |
| | | void zlmServerOnline(String mediaServerId); |
| | | } |
| | |
| | | if (deviceInRedis != null && deviceInDb == null) { |
| | | // redis 存在脏数据 |
| | | redisCatchStorage.clearCatchByDeviceId(device.getDeviceId()); |
| | | |
| | | } |
| | | device.setUpdateTime(now); |
| | | device.setOnline(1); |
| | |
| | | import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| | | import com.genersoft.iot.vmp.conf.SipConfig; |
| | | import com.genersoft.iot.vmp.conf.UserSetting; |
| | | import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; |
| | | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| | | import com.genersoft.iot.vmp.gb28181.session.SsrcConfig; |
| | | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; |
| | |
| | | |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 媒体服务器节点管理 |
| | |
| | | public void clearRTPServer(MediaServerItem mediaServerItem) { |
| | | mediaServerItem.setSsrcConfig(new SsrcConfig(mediaServerItem.getId(), null, sipConfig.getDomain())); |
| | | redisUtil.zAdd(VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId(), mediaServerItem.getId(), 0); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | result.sort((serverItem1, serverItem2)->{ |
| | | int sortResult = 0; |
| | | try { |
| | | sortResult = DateUtil.format.parse(serverItem1.getCreateTime()).compareTo(DateUtil.format.parse(serverItem2.getCreateTime())); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | LocalDateTime localDateTime1 = LocalDateTime.parse(serverItem1.getCreateTime(), DateUtil.formatter); |
| | | LocalDateTime localDateTime2 = LocalDateTime.parse(serverItem2.getCreateTime(), DateUtil.formatter); |
| | | |
| | | sortResult = localDateTime1.compareTo(localDateTime2); |
| | | return sortResult; |
| | | }); |
| | | return result; |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void zlmServerOnline(String mediaServerId) { |
| | | // 似乎没啥需要做的 |
| | | } |
| | | } |
| | |
| | | */ |
| | | public class DateUtil { |
| | | |
| | | private static final String yyyy_MM_dd_T_HH_mm_ss_SSSXXX = "yyyy-MM-dd'T'HH:mm:ss"; |
| | | public static final String yyyy_MM_dd_HH_mm_ss = "yyyy-MM-dd HH:mm:ss"; |
| | | /** |
| | | * 兼容不规范的iso8601时间格式 |
| | | */ |
| | | private static final String ISO8601_COMPATIBLE_PATTERN = "yyyy-M-d'T'H:m:s"; |
| | | |
| | | public static final SimpleDateFormat formatISO8601 = new SimpleDateFormat(yyyy_MM_dd_T_HH_mm_ss_SSSXXX, Locale.getDefault()); |
| | | public static final SimpleDateFormat format = new SimpleDateFormat(yyyy_MM_dd_HH_mm_ss, Locale.getDefault()); |
| | | /** |
| | | * 用以输出标准的iso8601时间格式 |
| | | */ |
| | | private static final String ISO8601_PATTERN = "yyyy-MM-dd'T'HH:mm:ss"; |
| | | |
| | | public static final DateTimeFormatter formatterISO8601 = DateTimeFormatter.ofPattern(yyyy_MM_dd_T_HH_mm_ss_SSSXXX, Locale.getDefault()).withZone(ZoneId.systemDefault()); |
| | | public static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(yyyy_MM_dd_HH_mm_ss, Locale.getDefault()).withZone(ZoneId.systemDefault()); |
| | | /** |
| | | * wvp内部统一时间格式 |
| | | */ |
| | | public static final String PATTERN = "yyyy-MM-dd HH:mm:ss"; |
| | | |
| | | |
| | | public static final DateTimeFormatter formatterCompatibleISO8601 = DateTimeFormatter.ofPattern(ISO8601_COMPATIBLE_PATTERN, Locale.getDefault()).withZone(ZoneId.systemDefault()); |
| | | public static final DateTimeFormatter formatterISO8601 = DateTimeFormatter.ofPattern(ISO8601_PATTERN, Locale.getDefault()).withZone(ZoneId.systemDefault()); |
| | | public static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(PATTERN, Locale.getDefault()).withZone(ZoneId.systemDefault()); |
| | | |
| | | public static String yyyy_MM_dd_HH_mm_ssToISO8601(String formatTime) { |
| | | return formatterISO8601.format(formatter.parse(formatTime)); |
| | | } |
| | | |
| | | public static String ISO8601Toyyyy_MM_dd_HH_mm_ss(String formatTime) { |
| | | return formatter.format(formatterISO8601.parse(formatTime)); |
| | | return formatter.format(formatterCompatibleISO8601.parse(formatTime)); |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * yyyy_MM_dd_HH_mm_ss 转时间戳 |
| | | * @param formatTime |
| | | * @return |
| | | */ |
| | | public static long yyyy_MM_dd_HH_mm_ssToTimestamp(String formatTime) { |
| | | TemporalAccessor temporalAccessor = formatter.parse(formatTime); |
| | | Instant instant = Instant.from(temporalAccessor); |
| | | return instant.getEpochSecond(); |
| | | } |
| | | |
| | | /** |
| | | * 获取当前时间 |
| | | * @return |
| | | */ |
| | | public static String getNow() { |
| | | LocalDateTime nowDateTime = LocalDateTime.now(); |
| | | return formatter.format(nowDateTime); |
| | | } |
| | | |
| | | /** |
| | | * 格式校验 |
| | | * @param timeStr 时间字符串 |
| | | * @param dateTimeFormatter 待校验的格式 |
| | | * @return |
| | | */ |
| | | public static boolean verification(String timeStr, DateTimeFormatter dateTimeFormatter) { |
| | | try { |
| | | LocalDate.parse(timeStr, dateTimeFormatter); |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.text.ParseException; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | try { |
| | | if (startTime != null) { |
| | | DateUtil.format.parse(startTime); |
| | | } |
| | | if (endTime != null) { |
| | | DateUtil.format.parse(endTime); |
| | | } |
| | | } catch (ParseException e) { |
| | | if (!DateUtil.verification(startTime, DateUtil.formatter) || !DateUtil.verification(endTime, DateUtil.formatter)){ |
| | | return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST); |
| | | } |
| | | |
| | |
| | | if (StringUtils.isEmpty(time)) { |
| | | time = null; |
| | | } |
| | | try { |
| | | if (time != null) { |
| | | DateUtil.format.parse(time); |
| | | } |
| | | } catch (ParseException e) { |
| | | if (!DateUtil.verification(time, DateUtil.formatter) ){ |
| | | return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST); |
| | | } |
| | | List<String> deviceIdList = null; |
| | |
| | | deviceAlarm.setAlarmDescription("test"); |
| | | deviceAlarm.setAlarmMethod("1"); |
| | | deviceAlarm.setAlarmPriority("1"); |
| | | deviceAlarm.setAlarmTime(DateUtil.formatISO8601.format(System.currentTimeMillis())); |
| | | deviceAlarm.setAlarmTime(DateUtil.formatterISO8601.format(LocalDateTime.now())); |
| | | deviceAlarm.setAlarmType("1"); |
| | | deviceAlarm.setLongitude(115.33333); |
| | | deviceAlarm.setLatitude(39.33333); |
| | |
| | | if (!DateUtil.verification(startTime, DateUtil.formatter)){ |
| | | WVPResult<RecordInfo> wvpResult = new WVPResult<>(); |
| | | wvpResult.setCode(-1); |
| | | wvpResult.setMsg("startTime error, format is " + DateUtil.yyyy_MM_dd_HH_mm_ss); |
| | | wvpResult.setMsg("startTime error, format is " + DateUtil.PATTERN); |
| | | |
| | | ResponseEntity<WVPResult<RecordInfo>> resultResponseEntity = new ResponseEntity<>(wvpResult, HttpStatus.OK); |
| | | result.setResult(resultResponseEntity); |
| | |
| | | if (!DateUtil.verification(endTime, DateUtil.formatter)){ |
| | | WVPResult<RecordInfo> wvpResult = new WVPResult<>(); |
| | | wvpResult.setCode(-1); |
| | | wvpResult.setMsg("endTime error, format is " + DateUtil.yyyy_MM_dd_HH_mm_ss); |
| | | wvpResult.setMsg("endTime error, format is " + DateUtil.PATTERN); |
| | | ResponseEntity<WVPResult<RecordInfo>> resultResponseEntity = new ResponseEntity<>(wvpResult, HttpStatus.OK); |
| | | result.setResult(resultResponseEntity); |
| | | return result; |
| | |
| | | logger.warn("自动记录日志功能已关闭,查询结果可能不完整。"); |
| | | } |
| | | |
| | | try { |
| | | if (startTime != null) { |
| | | DateUtil.format.parse(startTime); |
| | | } |
| | | if (endTime != null) { |
| | | DateUtil.format.parse(endTime); |
| | | } |
| | | } catch (ParseException e) { |
| | | if (!DateUtil.verification(startTime, DateUtil.formatter) || !DateUtil.verification(endTime, DateUtil.formatter)){ |
| | | return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST); |
| | | } |
| | | |
| | |
| | | import org.springframework.test.context.junit4.SpringRunner; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.Instant; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneOffset; |
| | | import java.time.temporal.TemporalAccessor; |
| | | import java.util.Date; |
| | | |
| | | |
| | |
| | | * * 7其他报警;可以为直接组合如12为电话报警或 设备报警- |
| | | */ |
| | | deviceAlarm.setAlarmMethod((int)(Math.random()*7 + 1) + ""); |
| | | Date date = randomDate("2021-01-01 00:00:00", "2021-06-01 00:00:00"); |
| | | deviceAlarm.setAlarmTime(DateUtil.format.format(date)); |
| | | Instant date = randomDate("2021-01-01 00:00:00", "2021-06-01 00:00:00"); |
| | | deviceAlarm.setAlarmTime(DateUtil.formatter.format(date)); |
| | | /** |
| | | * 报警级别, 1为一级警情, 2为二级警情, 3为三级警情, 4为四级 警情- |
| | | */ |
| | |
| | | |
| | | |
| | | |
| | | private Date randomDate(String beginDate, String endDate) { |
| | | private Instant randomDate(String beginDate, String endDate) { |
| | | try { |
| | | |
| | | Date start = DateUtil.format.parse(beginDate);//构造开始日期 |
| | | Date end = DateUtil.format.parse(endDate);//构造结束日期 |
| | | //构造开始日期 |
| | | LocalDateTime start = LocalDateTime.parse(beginDate, DateUtil.formatter); |
| | | |
| | | //构造结束日期 |
| | | LocalDateTime end = LocalDateTime.parse(endDate, DateUtil.formatter); |
| | | //getTime()表示返回自 1970 年 1 月 1 日 00:00:00 GMT 以来此 Date 对象表示的毫秒数。 |
| | | if (start.getTime() >= end.getTime()) { |
| | | if (start.isAfter(end)) { |
| | | return null; |
| | | } |
| | | long date = random(start.getTime(), end.getTime()); |
| | | return new Date(date); |
| | | long date = random(start.toInstant(ZoneOffset.of("+8")).toEpochMilli(), end.toInstant(ZoneOffset.of("+8")).toEpochMilli()); |
| | | return Instant.ofEpochMilli(date); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | if (typeof (errorCallback) == "function") errorCallback(error) |
| | | }); |
| | | } |
| | | getAllDeviceList(callback, errorCallback) { |
| | | getAllDeviceList(callback,endCallback, errorCallback) { |
| | | let currentPage = 1; |
| | | let count = 100; |
| | | let deviceList = [] |
| | | this.getAllDeviceListIteration(deviceList, currentPage, count, (data) => { |
| | | if (typeof (callback) == "function") callback(data) |
| | | }, errorCallback) |
| | | this.getAllDeviceListIteration(deviceList, currentPage, count, callback, endCallback, errorCallback) |
| | | } |
| | | |
| | | getAllDeviceListIteration(deviceList, currentPage, count, callback, errorCallback) { |
| | | getAllDeviceListIteration(deviceList, currentPage, count, callback, endCallback, errorCallback) { |
| | | this.getDeviceList(currentPage, count, (data) => { |
| | | if (data.list) { |
| | | if (typeof (callback) == "function") callback(data.list) |
| | | deviceList = deviceList.concat(data.list); |
| | | if (deviceList.length < data.total) { |
| | | currentPage ++ |
| | | this.getAllDeviceListIteration(deviceList, currentPage, count, callback, errorCallback) |
| | | this.getAllDeviceListIteration(deviceList, currentPage, count, callback, endCallback, errorCallback) |
| | | }else { |
| | | if (typeof (callback) == "function") callback(deviceList) |
| | | if (typeof (endCallback) == "function") endCallback(deviceList) |
| | | } |
| | | } |
| | | }, errorCallback) |
| | | } |
| | | |
| | | |
| | | getAllChannel(isCatalog, catalogUnderDevice, deviceId, callback, errorCallback) { |
| | | getAllChannel(isCatalog, catalogUnderDevice, deviceId, callback, endCallback, errorCallback) { |
| | | let currentPage = 1; |
| | | let count = 100; |
| | | let catalogList = [] |
| | | this.getAllChannelIteration(isCatalog, catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, errorCallback) |
| | | this.getAllChannelIteration(isCatalog, catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, endCallback, errorCallback) |
| | | } |
| | | |
| | | getAllChannelIteration(isCatalog, catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, errorCallback) { |
| | | getAllChannelIteration(isCatalog, catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, endCallback, errorCallback) { |
| | | this.getChanel(isCatalog, catalogUnderDevice, deviceId, currentPage, count, (data) => { |
| | | if (data.list) { |
| | | if (typeof (callback) == "function") callback(data.list) |
| | | catalogList = catalogList.concat(data.list); |
| | | if (catalogList.length < data.total) { |
| | | currentPage ++ |
| | | this.getAllChannelIteration(isCatalog,catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, errorCallback) |
| | | }else { |
| | | console.log(1) |
| | | if (typeof (callback) == "function") callback(catalogList) |
| | | if (typeof (endCallback) == "function") endCallback(catalogList) |
| | | } |
| | | } |
| | | }, errorCallback) |
| | |
| | | } |
| | | |
| | | |
| | | getAllSubChannel(isCatalog, deviceId, channelId, callback, errorCallback) { |
| | | getAllSubChannel(isCatalog, deviceId, channelId, callback, endCallback, errorCallback) { |
| | | let currentPage = 1; |
| | | let count = 100; |
| | | let catalogList = [] |
| | | this.getAllSubChannelIteration(isCatalog, deviceId, channelId, catalogList, currentPage, count, callback, errorCallback) |
| | | this.getAllSubChannelIteration(isCatalog, deviceId, channelId, catalogList, currentPage, count, callback, endCallback, errorCallback) |
| | | } |
| | | |
| | | getAllSubChannelIteration(isCatalog, deviceId,channelId, catalogList, currentPage, count, callback, errorCallback) { |
| | | getAllSubChannelIteration(isCatalog, deviceId,channelId, catalogList, currentPage, count, callback, endCallback, errorCallback) { |
| | | this.getSubChannel(isCatalog, deviceId, channelId, currentPage, count, (data) => { |
| | | if (data.list) { |
| | | if (typeof (callback) == "function") callback(data.list) |
| | | catalogList = catalogList.concat(data.list); |
| | | if (catalogList.length < data.total) { |
| | | currentPage ++ |
| | | this.getAllSubChannelIteration(isCatalog, deviceId, channelId, catalogList, currentPage, count, callback, errorCallback) |
| | | this.getAllSubChannelIteration(isCatalog, deviceId, channelId, catalogList, currentPage, count, callback, endCallback, errorCallback) |
| | | }else { |
| | | if (typeof (callback) == "function") callback(catalogList) |
| | | if (typeof (endCallback) == "function") endCallback(catalogList) |
| | | } |
| | | } |
| | | }, errorCallback) |