支持全局异常和统一返回结果,未完待续
This commit is contained in:
@@ -15,6 +15,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
@@ -58,7 +59,7 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
|
||||
ParentPlatform parentPlatform = null;
|
||||
|
||||
Map<String, List<ParentPlatform>> parentPlatformMap = new HashMap<>();
|
||||
if (!StringUtils.isEmpty(event.getPlatformId())) {
|
||||
if (!ObjectUtils.isEmpty(event.getPlatformId())) {
|
||||
subscribe = subscribeHolder.getCatalogSubscribe(event.getPlatformId());
|
||||
if (subscribe == null) {
|
||||
return;
|
||||
@@ -81,7 +82,7 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
|
||||
}else if (event.getGbStreams() != null) {
|
||||
if (platforms.size() > 0) {
|
||||
for (GbStream gbStream : event.getGbStreams()) {
|
||||
if (gbStream == null || StringUtils.isEmpty(gbStream.getGbId())) {
|
||||
if (gbStream == null || ObjectUtils.isEmpty(gbStream.getGbId())) {
|
||||
continue;
|
||||
}
|
||||
List<ParentPlatform> parentPlatformsForGB = storager.queryPlatFormListForStreamWithGBId(gbStream.getApp(),gbStream.getStream(), platforms);
|
||||
|
||||
@@ -60,16 +60,12 @@ public class RecordDataCatch {
|
||||
// 处理录像数据, 返回给前端
|
||||
String msgKey = DeferredResultHolder.CALLBACK_CMD_RECORDINFO + recordInfo.getDeviceId() + recordInfo.getSn();
|
||||
|
||||
WVPResult<RecordInfo> wvpResult = new WVPResult<>();
|
||||
wvpResult.setCode(0);
|
||||
wvpResult.setMsg("success");
|
||||
// 对数据进行排序
|
||||
Collections.sort(recordInfo.getRecordList());
|
||||
wvpResult.setData(recordInfo);
|
||||
|
||||
RequestMessage msg = new RequestMessage();
|
||||
msg.setKey(msgKey);
|
||||
msg.setData(wvpResult);
|
||||
msg.setData(recordInfo);
|
||||
deferredResultHolder.invokeAllResult(msg);
|
||||
data.remove(key);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.genersoft.iot.vmp.utils.redis.RedisUtil;
|
||||
import gov.nist.javax.sip.stack.SIPDialog;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -110,16 +111,16 @@ public class VideoStreamSessionManager {
|
||||
|
||||
public SsrcTransaction getSsrcTransaction(String deviceId, String channelId, String callId, String stream){
|
||||
|
||||
if (StringUtils.isEmpty(deviceId)) {
|
||||
if (ObjectUtils.isEmpty(deviceId)) {
|
||||
deviceId ="*";
|
||||
}
|
||||
if (StringUtils.isEmpty(channelId)) {
|
||||
if (ObjectUtils.isEmpty(channelId)) {
|
||||
channelId ="*";
|
||||
}
|
||||
if (StringUtils.isEmpty(callId)) {
|
||||
if (ObjectUtils.isEmpty(callId)) {
|
||||
callId ="*";
|
||||
}
|
||||
if (StringUtils.isEmpty(stream)) {
|
||||
if (ObjectUtils.isEmpty(stream)) {
|
||||
stream ="*";
|
||||
}
|
||||
String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream;
|
||||
@@ -131,16 +132,16 @@ public class VideoStreamSessionManager {
|
||||
}
|
||||
|
||||
public List<SsrcTransaction> getSsrcTransactionForAll(String deviceId, String channelId, String callId, String stream){
|
||||
if (StringUtils.isEmpty(deviceId)) {
|
||||
if (ObjectUtils.isEmpty(deviceId)) {
|
||||
deviceId ="*";
|
||||
}
|
||||
if (StringUtils.isEmpty(channelId)) {
|
||||
if (ObjectUtils.isEmpty(channelId)) {
|
||||
channelId ="*";
|
||||
}
|
||||
if (StringUtils.isEmpty(callId)) {
|
||||
if (ObjectUtils.isEmpty(callId)) {
|
||||
callId ="*";
|
||||
}
|
||||
if (StringUtils.isEmpty(stream)) {
|
||||
if (ObjectUtils.isEmpty(stream)) {
|
||||
stream ="*";
|
||||
}
|
||||
String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream;
|
||||
|
||||
@@ -3,8 +3,6 @@ package com.genersoft.iot.vmp.gb28181.transmit;
|
||||
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
||||
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.RegisterRequestProcessor;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd.KeepaliveNotifyMessageHandler;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.response.ISIPResponseProcessor;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.timeout.ITimeoutProcessor;
|
||||
import org.slf4j.Logger;
|
||||
@@ -14,13 +12,10 @@ import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.sip.*;
|
||||
import javax.sip.address.SipURI;
|
||||
import javax.sip.address.URI;
|
||||
import javax.sip.header.*;
|
||||
import javax.sip.message.Request;
|
||||
import javax.sip.message.Response;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
@@ -43,9 +38,6 @@ public class SIPProcessorObserver implements ISIPProcessorObserver {
|
||||
@Autowired
|
||||
private EventPublisher eventPublisher;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 添加 request订阅
|
||||
* @param method 方法名
|
||||
|
||||
@@ -96,7 +96,7 @@ public class DeferredResultHolder {
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
result.setResult(new ResponseEntity<>(msg.getData(),HttpStatus.OK));
|
||||
result.setResult(msg.getData());
|
||||
deferredResultMap.remove(msg.getId());
|
||||
if (deferredResultMap.size() == 0) {
|
||||
map.remove(msg.getKey());
|
||||
@@ -118,9 +118,8 @@ public class DeferredResultHolder {
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
result.setResult(ResponseEntity.ok().body(msg.getData()));
|
||||
result.setResult(msg.getData());
|
||||
}
|
||||
map.remove(msg.getKey());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.DependsOn;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.sip.*;
|
||||
@@ -856,7 +857,7 @@ public class SIPCommander implements ISIPCommander {
|
||||
cmdXml.append("<Control>\r\n");
|
||||
cmdXml.append("<CmdType>DeviceControl</CmdType>\r\n");
|
||||
cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
|
||||
if (StringUtils.isEmpty(channelId)) {
|
||||
if (ObjectUtils.isEmpty(channelId)) {
|
||||
cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
|
||||
} else {
|
||||
cmdXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
|
||||
@@ -959,16 +960,16 @@ public class SIPCommander implements ISIPCommander {
|
||||
cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
|
||||
cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
|
||||
cmdXml.append("<AlarmCmd>ResetAlarm</AlarmCmd>\r\n");
|
||||
if (!StringUtils.isEmpty(alarmMethod) || !StringUtils.isEmpty(alarmType)) {
|
||||
if (!ObjectUtils.isEmpty(alarmMethod) || !ObjectUtils.isEmpty(alarmType)) {
|
||||
cmdXml.append("<Info>\r\n");
|
||||
}
|
||||
if (!StringUtils.isEmpty(alarmMethod)) {
|
||||
if (!ObjectUtils.isEmpty(alarmMethod)) {
|
||||
cmdXml.append("<AlarmMethod>" + alarmMethod + "</AlarmMethod>\r\n");
|
||||
}
|
||||
if (!StringUtils.isEmpty(alarmType)) {
|
||||
if (!ObjectUtils.isEmpty(alarmType)) {
|
||||
cmdXml.append("<AlarmType>" + alarmType + "</AlarmType>\r\n");
|
||||
}
|
||||
if (!StringUtils.isEmpty(alarmMethod) || !StringUtils.isEmpty(alarmType)) {
|
||||
if (!ObjectUtils.isEmpty(alarmMethod) || !ObjectUtils.isEmpty(alarmType)) {
|
||||
cmdXml.append("</Info>\r\n");
|
||||
}
|
||||
cmdXml.append("</Control>\r\n");
|
||||
@@ -1002,7 +1003,7 @@ public class SIPCommander implements ISIPCommander {
|
||||
cmdXml.append("<Control>\r\n");
|
||||
cmdXml.append("<CmdType>DeviceControl</CmdType>\r\n");
|
||||
cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
|
||||
if (StringUtils.isEmpty(channelId)) {
|
||||
if (ObjectUtils.isEmpty(channelId)) {
|
||||
cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
|
||||
} else {
|
||||
cmdXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
|
||||
@@ -1041,7 +1042,7 @@ public class SIPCommander implements ISIPCommander {
|
||||
cmdXml.append("<Control>\r\n");
|
||||
cmdXml.append("<CmdType>DeviceControl</CmdType>\r\n");
|
||||
cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
|
||||
if (StringUtils.isEmpty(channelId)) {
|
||||
if (ObjectUtils.isEmpty(channelId)) {
|
||||
cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
|
||||
} else {
|
||||
cmdXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
|
||||
@@ -1110,13 +1111,13 @@ public class SIPCommander implements ISIPCommander {
|
||||
cmdXml.append("<Control>\r\n");
|
||||
cmdXml.append("<CmdType>DeviceConfig</CmdType>\r\n");
|
||||
cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
|
||||
if (StringUtils.isEmpty(channelId)) {
|
||||
if (ObjectUtils.isEmpty(channelId)) {
|
||||
cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
|
||||
} else {
|
||||
cmdXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
|
||||
}
|
||||
cmdXml.append("<BasicParam>\r\n");
|
||||
if (!StringUtils.isEmpty(name)) {
|
||||
if (!ObjectUtils.isEmpty(name)) {
|
||||
cmdXml.append("<Name>" + name + "</Name>\r\n");
|
||||
}
|
||||
if (NumericUtil.isInteger(expiration)) {
|
||||
@@ -1326,22 +1327,22 @@ public class SIPCommander implements ISIPCommander {
|
||||
cmdXml.append("<CmdType>Alarm</CmdType>\r\n");
|
||||
cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
|
||||
cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
|
||||
if (!StringUtils.isEmpty(startPriority)) {
|
||||
if (!ObjectUtils.isEmpty(startPriority)) {
|
||||
cmdXml.append("<StartAlarmPriority>" + startPriority + "</StartAlarmPriority>\r\n");
|
||||
}
|
||||
if (!StringUtils.isEmpty(endPriority)) {
|
||||
if (!ObjectUtils.isEmpty(endPriority)) {
|
||||
cmdXml.append("<EndAlarmPriority>" + endPriority + "</EndAlarmPriority>\r\n");
|
||||
}
|
||||
if (!StringUtils.isEmpty(alarmMethod)) {
|
||||
if (!ObjectUtils.isEmpty(alarmMethod)) {
|
||||
cmdXml.append("<AlarmMethod>" + alarmMethod + "</AlarmMethod>\r\n");
|
||||
}
|
||||
if (!StringUtils.isEmpty(alarmType)) {
|
||||
if (!ObjectUtils.isEmpty(alarmType)) {
|
||||
cmdXml.append("<AlarmType>" + alarmType + "</AlarmType>\r\n");
|
||||
}
|
||||
if (!StringUtils.isEmpty(startTime)) {
|
||||
if (!ObjectUtils.isEmpty(startTime)) {
|
||||
cmdXml.append("<StartAlarmTime>" + startTime + "</StartAlarmTime>\r\n");
|
||||
}
|
||||
if (!StringUtils.isEmpty(endTime)) {
|
||||
if (!ObjectUtils.isEmpty(endTime)) {
|
||||
cmdXml.append("<EndAlarmTime>" + endTime + "</EndAlarmTime>\r\n");
|
||||
}
|
||||
cmdXml.append("</Query>\r\n");
|
||||
@@ -1376,7 +1377,7 @@ public class SIPCommander implements ISIPCommander {
|
||||
cmdXml.append("<Query>\r\n");
|
||||
cmdXml.append("<CmdType>ConfigDownload</CmdType>\r\n");
|
||||
cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
|
||||
if (StringUtils.isEmpty(channelId)) {
|
||||
if (ObjectUtils.isEmpty(channelId)) {
|
||||
cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
|
||||
} else {
|
||||
cmdXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
|
||||
@@ -1412,7 +1413,7 @@ public class SIPCommander implements ISIPCommander {
|
||||
cmdXml.append("<Query>\r\n");
|
||||
cmdXml.append("<CmdType>PresetQuery</CmdType>\r\n");
|
||||
cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
|
||||
if (StringUtils.isEmpty(channelId)) {
|
||||
if (ObjectUtils.isEmpty(channelId)) {
|
||||
cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
|
||||
} else {
|
||||
cmdXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
|
||||
@@ -1543,22 +1544,22 @@ public class SIPCommander implements ISIPCommander {
|
||||
cmdXml.append("<CmdType>Alarm</CmdType>\r\n");
|
||||
cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
|
||||
cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
|
||||
if (!StringUtils.isEmpty(startPriority)) {
|
||||
if (!ObjectUtils.isEmpty(startPriority)) {
|
||||
cmdXml.append("<StartAlarmPriority>" + startPriority + "</StartAlarmPriority>\r\n");
|
||||
}
|
||||
if (!StringUtils.isEmpty(endPriority)) {
|
||||
if (!ObjectUtils.isEmpty(endPriority)) {
|
||||
cmdXml.append("<EndAlarmPriority>" + endPriority + "</EndAlarmPriority>\r\n");
|
||||
}
|
||||
if (!StringUtils.isEmpty(alarmMethod)) {
|
||||
if (!ObjectUtils.isEmpty(alarmMethod)) {
|
||||
cmdXml.append("<AlarmMethod>" + alarmMethod + "</AlarmMethod>\r\n");
|
||||
}
|
||||
if (!StringUtils.isEmpty(alarmType)) {
|
||||
if (!ObjectUtils.isEmpty(alarmType)) {
|
||||
cmdXml.append("<AlarmType>" + alarmType + "</AlarmType>\r\n");
|
||||
}
|
||||
if (!StringUtils.isEmpty(startTime)) {
|
||||
if (!ObjectUtils.isEmpty(startTime)) {
|
||||
cmdXml.append("<StartAlarmTime>" + startTime + "</StartAlarmTime>\r\n");
|
||||
}
|
||||
if (!StringUtils.isEmpty(endTime)) {
|
||||
if (!ObjectUtils.isEmpty(endTime)) {
|
||||
cmdXml.append("<EndAlarmTime>" + endTime + "</EndAlarmTime>\r\n");
|
||||
}
|
||||
cmdXml.append("</Query>\r\n");
|
||||
@@ -1639,7 +1640,7 @@ public class SIPCommander implements ISIPCommander {
|
||||
dragXml.append("<Control>\r\n");
|
||||
dragXml.append("<CmdType>DeviceControl</CmdType>\r\n");
|
||||
dragXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n");
|
||||
if (StringUtils.isEmpty(channelId)) {
|
||||
if (ObjectUtils.isEmpty(channelId)) {
|
||||
dragXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
|
||||
} else {
|
||||
dragXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.springframework.context.annotation.DependsOn;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.sip.*;
|
||||
@@ -728,10 +729,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
||||
recordXml.append("<EndTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(recordItem.getEndTime()) + "</EndTime>\r\n");
|
||||
recordXml.append("<Secrecy>" + recordItem.getSecrecy() + "</Secrecy>\r\n");
|
||||
recordXml.append("<Type>" + recordItem.getType() + "</Type>\r\n");
|
||||
if (!StringUtils.isEmpty(recordItem.getFileSize())) {
|
||||
if (!ObjectUtils.isEmpty(recordItem.getFileSize())) {
|
||||
recordXml.append("<FileSize>" + recordItem.getFileSize() + "</FileSize>\r\n");
|
||||
}
|
||||
if (!StringUtils.isEmpty(recordItem.getFilePath())) {
|
||||
if (!ObjectUtils.isEmpty(recordItem.getFilePath())) {
|
||||
recordXml.append("<FilePath>" + recordItem.getFilePath() + "</FilePath>\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.sip.InvalidArgumentException;
|
||||
@@ -157,7 +158,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
|
||||
String channelId = deviceIdElement.getTextTrim().toString();
|
||||
Device device = redisCatchStorage.getDevice(deviceId);
|
||||
if (device != null) {
|
||||
if (!StringUtils.isEmpty(device.getName())) {
|
||||
if (!ObjectUtils.isEmpty(device.getName())) {
|
||||
mobilePosition.setDeviceName(device.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.sip.InvalidArgumentException;
|
||||
@@ -81,7 +82,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
|
||||
String deviceId = uri.getUser();
|
||||
|
||||
AuthorizationHeader authHead = (AuthorizationHeader) request.getHeader(AuthorizationHeader.NAME);
|
||||
if (authHead == null && !StringUtils.isEmpty(sipConfig.getPassword())) {
|
||||
if (authHead == null && !ObjectUtils.isEmpty(sipConfig.getPassword())) {
|
||||
logger.info("[注册请求] 未携带授权头 回复401: {}", requestAddress);
|
||||
response = getMessageFactory().createResponse(Response.UNAUTHORIZED, request);
|
||||
new DigestServerAuthenticationHelper().generateChallenge(getHeaderFactory(), response, sipConfig.getDomain());
|
||||
@@ -90,7 +91,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
|
||||
}
|
||||
|
||||
// 校验密码是否正确
|
||||
passwordCorrect = StringUtils.isEmpty(sipConfig.getPassword()) ||
|
||||
passwordCorrect = ObjectUtils.isEmpty(sipConfig.getPassword()) ||
|
||||
new DigestServerAuthenticationHelper().doAuthenticatePlainTextPassword(request, sipConfig.getPassword());
|
||||
|
||||
if (!passwordCorrect) {
|
||||
@@ -132,7 +133,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
|
||||
String received = viaHeader.getReceived();
|
||||
int rPort = viaHeader.getRPort();
|
||||
// 解析本地地址替代
|
||||
if (StringUtils.isEmpty(received) || rPort == -1) {
|
||||
if (ObjectUtils.isEmpty(received) || rPort == -1) {
|
||||
received = viaHeader.getHost();
|
||||
rPort = viaHeader.getPort();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.sip.*;
|
||||
@@ -64,7 +65,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||
String targetGBId = ((SipURI) ((HeaderAddress) evt.getRequest().getHeader(ToHeader.NAME)).getAddress().getURI()).getUser();
|
||||
String channelId = getText(rootElement, "DeviceID");
|
||||
// 远程启动功能
|
||||
if (!StringUtils.isEmpty(getText(rootElement, "TeleBoot"))) {
|
||||
if (!ObjectUtils.isEmpty(getText(rootElement, "TeleBoot"))) {
|
||||
if (parentPlatform.getServerGBId().equals(targetGBId)) {
|
||||
// 远程启动本平台:需要在重新启动程序后先对SipStack解绑
|
||||
logger.info("执行远程启动本平台命令");
|
||||
@@ -101,7 +102,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||
}
|
||||
}
|
||||
// 云台/前端控制命令
|
||||
if (!StringUtils.isEmpty(getText(rootElement,"PTZCmd")) && !parentPlatform.getServerGBId().equals(targetGBId)) {
|
||||
if (!ObjectUtils.isEmpty(getText(rootElement,"PTZCmd")) && !parentPlatform.getServerGBId().equals(targetGBId)) {
|
||||
String cmdString = getText(rootElement,"PTZCmd");
|
||||
Device deviceForPlatform = storager.queryVideoDeviceByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId);
|
||||
if (deviceForPlatform == null) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.sip.InvalidArgumentException;
|
||||
@@ -114,7 +115,7 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
|
||||
deviceAlarm.setLatitude(0.00);
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(deviceAlarm.getAlarmMethod())) {
|
||||
if (!ObjectUtils.isEmpty(deviceAlarm.getAlarmMethod())) {
|
||||
if ( deviceAlarm.getAlarmMethod().contains(DeviceAlarmMethod.GPS.getVal() + "")) {
|
||||
MobilePosition mobilePosition = new MobilePosition();
|
||||
mobilePosition.setCreateTime(DateUtil.getNow());
|
||||
@@ -157,7 +158,7 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
|
||||
redisCatchStorage.sendMobilePositionMsg(jsonObject);
|
||||
}
|
||||
}
|
||||
if (!StringUtils.isEmpty(deviceAlarm.getDeviceId())) {
|
||||
if (!ObjectUtils.isEmpty(deviceAlarm.getDeviceId())) {
|
||||
if (deviceAlarm.getAlarmMethod().contains(DeviceAlarmMethod.Video.getVal() + "")) {
|
||||
deviceAlarm.setAlarmType(getText(rootElement.element("Info"), "AlarmType"));
|
||||
}
|
||||
@@ -231,7 +232,7 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
|
||||
deviceAlarm.setLatitude(0.00);
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(deviceAlarm.getAlarmMethod())) {
|
||||
if (!ObjectUtils.isEmpty(deviceAlarm.getAlarmMethod())) {
|
||||
|
||||
if (deviceAlarm.getAlarmMethod().contains(DeviceAlarmMethod.Video.getVal() + "")) {
|
||||
deviceAlarm.setAlarmType(getText(rootElement.element("Info"), "AlarmType"));
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.sip.InvalidArgumentException;
|
||||
@@ -58,7 +59,7 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
|
||||
String received = viaHeader.getReceived();
|
||||
int rPort = viaHeader.getRPort();
|
||||
// 解析本地地址替代
|
||||
if (StringUtils.isEmpty(received) || rPort == -1) {
|
||||
if (ObjectUtils.isEmpty(received) || rPort == -1) {
|
||||
received = viaHeader.getHost();
|
||||
rPort = viaHeader.getPort();
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.sip.InvalidArgumentException;
|
||||
@@ -69,7 +70,7 @@ public class MobilePositionNotifyMessageHandler extends SIPRequestProcessorParen
|
||||
}
|
||||
MobilePosition mobilePosition = new MobilePosition();
|
||||
mobilePosition.setCreateTime(DateUtil.getNow());
|
||||
if (!StringUtils.isEmpty(device.getName())) {
|
||||
if (!ObjectUtils.isEmpty(device.getName())) {
|
||||
mobilePosition.setDeviceName(device.getName());
|
||||
}
|
||||
mobilePosition.setDeviceId(device.getDeviceId());
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.sip.InvalidArgumentException;
|
||||
@@ -88,7 +89,7 @@ public class DeviceInfoResponseMessageHandler extends SIPRequestProcessorParent
|
||||
device.setManufacturer(getText(rootElement, "Manufacturer"));
|
||||
device.setModel(getText(rootElement, "Model"));
|
||||
device.setFirmware(getText(rootElement, "Firmware"));
|
||||
if (StringUtils.isEmpty(device.getStreamMode())) {
|
||||
if (ObjectUtils.isEmpty(device.getStreamMode())) {
|
||||
device.setStreamMode("UDP");
|
||||
}
|
||||
deviceService.updateDevice(device);
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.sip.InvalidArgumentException;
|
||||
@@ -72,7 +73,7 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar
|
||||
}
|
||||
MobilePosition mobilePosition = new MobilePosition();
|
||||
mobilePosition.setCreateTime(DateUtil.getNow());
|
||||
if (!StringUtils.isEmpty(device.getName())) {
|
||||
if (!ObjectUtils.isEmpty(device.getName())) {
|
||||
mobilePosition.setDeviceName(device.getName());
|
||||
}
|
||||
mobilePosition.setDeviceId(device.getDeviceId());
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.sip.InvalidArgumentException;
|
||||
@@ -93,7 +94,7 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent
|
||||
recordInfo.setName(getText(rootElementForCharset, "Name"));
|
||||
String sumNumStr = getText(rootElementForCharset, "SumNum");
|
||||
int sumNum = 0;
|
||||
if (!StringUtils.isEmpty(sumNumStr)) {
|
||||
if (!ObjectUtils.isEmpty(sumNumStr)) {
|
||||
sumNum = Integer.parseInt(sumNumStr);
|
||||
}
|
||||
recordInfo.setSumNum(sumNum);
|
||||
@@ -172,16 +173,12 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent
|
||||
|
||||
public void releaseRequest(String deviceId, String sn){
|
||||
String key = DeferredResultHolder.CALLBACK_CMD_RECORDINFO + deviceId + sn;
|
||||
WVPResult<RecordInfo> wvpResult = new WVPResult<>();
|
||||
wvpResult.setCode(0);
|
||||
wvpResult.setMsg("success");
|
||||
// 对数据进行排序
|
||||
Collections.sort(recordDataCatch.getRecordInfo(deviceId, sn).getRecordList());
|
||||
wvpResult.setData(recordDataCatch.getRecordInfo(deviceId, sn));
|
||||
|
||||
RequestMessage msg = new RequestMessage();
|
||||
msg.setKey(key);
|
||||
msg.setData(wvpResult);
|
||||
msg.setData(recordDataCatch.getRecordInfo(deviceId, sn));
|
||||
deferredResultHolder.invokeAllResult(msg);
|
||||
recordDataCatch.remove(deviceId, sn);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.dom4j.Element;
|
||||
import org.dom4j.io.SAXReader;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.sip.RequestEvent;
|
||||
@@ -118,12 +119,12 @@ public class XmlUtil {
|
||||
// 如果是属性
|
||||
for (Object o : element.attributes()) {
|
||||
Attribute attr = (Attribute) o;
|
||||
if (!StringUtils.isEmpty(attr.getValue())) {
|
||||
if (!ObjectUtils.isEmpty(attr.getValue())) {
|
||||
json.put("@" + attr.getName(), attr.getValue());
|
||||
}
|
||||
}
|
||||
List<Element> chdEl = element.elements();
|
||||
if (chdEl.isEmpty() && !StringUtils.isEmpty(element.getText())) {// 如果没有子元素,只有一个值
|
||||
if (chdEl.isEmpty() && !ObjectUtils.isEmpty(element.getText())) {// 如果没有子元素,只有一个值
|
||||
json.put(element.getName(), element.getText());
|
||||
}
|
||||
|
||||
@@ -154,7 +155,7 @@ public class XmlUtil {
|
||||
} else { // 子元素没有子元素
|
||||
for (Object o : element.attributes()) {
|
||||
Attribute attr = (Attribute) o;
|
||||
if (!StringUtils.isEmpty(attr.getValue())) {
|
||||
if (!ObjectUtils.isEmpty(attr.getValue())) {
|
||||
json.put("@" + attr.getName(), attr.getValue());
|
||||
}
|
||||
}
|
||||
@@ -197,7 +198,7 @@ public class XmlUtil {
|
||||
return null;
|
||||
}
|
||||
String channelId = channdelIdElement.getTextTrim();
|
||||
if (StringUtils.isEmpty(channelId)) {
|
||||
if (ObjectUtils.isEmpty(channelId)) {
|
||||
logger.warn("解析Catalog消息时发现缺少 DeviceID");
|
||||
return null;
|
||||
}
|
||||
@@ -316,7 +317,7 @@ public class XmlUtil {
|
||||
// 识别自带的目录标识
|
||||
String parental = XmlUtil.getText(itemDevice, "Parental");
|
||||
// 由于海康会错误的发送65535作为这里的取值,所以这里除非是0否则认为是1
|
||||
if (!StringUtils.isEmpty(parental) && parental.length() == 1 && Integer.parseInt(parental) == 0) {
|
||||
if (!ObjectUtils.isEmpty(parental) && parental.length() == 1 && Integer.parseInt(parental) == 0) {
|
||||
deviceChannel.setParental(0);
|
||||
}else {
|
||||
deviceChannel.setParental(1);
|
||||
@@ -332,14 +333,14 @@ public class XmlUtil {
|
||||
deviceChannel.setPassword(XmlUtil.getText(itemDevice, "Password"));
|
||||
|
||||
String safetyWay = XmlUtil.getText(itemDevice, "SafetyWay");
|
||||
if (StringUtils.isEmpty(safetyWay)) {
|
||||
if (ObjectUtils.isEmpty(safetyWay)) {
|
||||
deviceChannel.setSafetyWay(0);
|
||||
} else {
|
||||
deviceChannel.setSafetyWay(Integer.parseInt(safetyWay));
|
||||
}
|
||||
|
||||
String registerWay = XmlUtil.getText(itemDevice, "RegisterWay");
|
||||
if (StringUtils.isEmpty(registerWay)) {
|
||||
if (ObjectUtils.isEmpty(registerWay)) {
|
||||
deviceChannel.setRegisterWay(1);
|
||||
} else {
|
||||
deviceChannel.setRegisterWay(Integer.parseInt(registerWay));
|
||||
|
||||
Reference in New Issue
Block a user