使用阿里代码规范。规范代码写法
This commit is contained in:
@@ -103,7 +103,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||
*/
|
||||
@Override
|
||||
public boolean stopPlay(StreamInfo streamInfo) {
|
||||
if (streamInfo == null) return false;
|
||||
if (streamInfo == null) {
|
||||
return false;
|
||||
}
|
||||
return redis.del(String.format("%S_%s_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX,
|
||||
userSetting.getServerId(),
|
||||
streamInfo.getStream(),
|
||||
@@ -127,7 +129,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||
@Override
|
||||
public StreamInfo queryPlayByStreamId(String streamId) {
|
||||
List<Object> playLeys = redis.scan(String.format("%S_%s_%s_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), streamId));
|
||||
if (playLeys == null || playLeys.size() == 0) return null;
|
||||
if (playLeys == null || playLeys.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
return (StreamInfo)redis.get(playLeys.get(0).toString());
|
||||
}
|
||||
|
||||
@@ -137,7 +141,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||
userSetting.getServerId(),
|
||||
deviceId,
|
||||
channelId));
|
||||
if (playLeys == null || playLeys.size() == 0) return null;
|
||||
if (playLeys == null || playLeys.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
return (StreamInfo)redis.get(playLeys.get(0).toString());
|
||||
}
|
||||
|
||||
@@ -146,7 +152,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||
Map<String, StreamInfo> streamInfos = new HashMap<>();
|
||||
// List<Object> playLeys = redis.keys(String.format("%S_*_%S_*", VideoManagerConstants.PLAYER_PREFIX, deviceId));
|
||||
List<Object> players = redis.scan(String.format("%S_%s_*_%S_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(),deviceId));
|
||||
if (players.size() == 0) return streamInfos;
|
||||
if (players.size() == 0) {
|
||||
return streamInfos;
|
||||
}
|
||||
for (Object player : players) {
|
||||
String key = (String) player;
|
||||
StreamInfo streamInfo = (StreamInfo) redis.get(key);
|
||||
@@ -182,10 +190,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||
deviceChannel.setDeviceId(deviceId);
|
||||
deviceChannelMapper.update(deviceChannel);
|
||||
}
|
||||
if (deviceId == null) deviceId = "*";
|
||||
if (channelId == null) channelId = "*";
|
||||
if (stream == null) stream = "*";
|
||||
if (callId == null) callId = "*";
|
||||
if (deviceId == null) {
|
||||
deviceId = "*";
|
||||
}
|
||||
if (channelId == null) {
|
||||
channelId = "*";
|
||||
}
|
||||
if (stream == null) {
|
||||
stream = "*";
|
||||
}
|
||||
if (callId == null) {
|
||||
callId = "*";
|
||||
}
|
||||
String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX,
|
||||
userSetting.getServerId(),
|
||||
deviceId,
|
||||
@@ -210,10 +226,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||
deviceChannel.setDeviceId(deviceId);
|
||||
deviceChannelMapper.update(deviceChannel);
|
||||
}
|
||||
if (deviceId == null) deviceId = "*";
|
||||
if (channelId == null) channelId = "*";
|
||||
if (stream == null) stream = "*";
|
||||
if (callId == null) callId = "*";
|
||||
if (deviceId == null) {
|
||||
deviceId = "*";
|
||||
}
|
||||
if (channelId == null) {
|
||||
channelId = "*";
|
||||
}
|
||||
if (stream == null) {
|
||||
stream = "*";
|
||||
}
|
||||
if (callId == null) {
|
||||
callId = "*";
|
||||
}
|
||||
String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX,
|
||||
userSetting.getServerId(),
|
||||
deviceId,
|
||||
@@ -235,10 +259,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||
if (stream == null && callId == null) {
|
||||
return null;
|
||||
}
|
||||
if (deviceId == null) deviceId = "*";
|
||||
if (channelId == null) channelId = "*";
|
||||
if (stream == null) stream = "*";
|
||||
if (callId == null) callId = "*";
|
||||
if (deviceId == null) {
|
||||
deviceId = "*";
|
||||
}
|
||||
if (channelId == null) {
|
||||
channelId = "*";
|
||||
}
|
||||
if (stream == null) {
|
||||
stream = "*";
|
||||
}
|
||||
if (callId == null) {
|
||||
callId = "*";
|
||||
}
|
||||
String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX,
|
||||
userSetting.getServerId(),
|
||||
deviceId,
|
||||
@@ -328,10 +360,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||
|
||||
@Override
|
||||
public SendRtpItem querySendRTPServer(String platformGbId, String channelId, String streamId, String callId) {
|
||||
if (platformGbId == null) platformGbId = "*";
|
||||
if (channelId == null) channelId = "*";
|
||||
if (streamId == null) streamId = "*";
|
||||
if (callId == null) callId = "*";
|
||||
if (platformGbId == null) {
|
||||
platformGbId = "*";
|
||||
}
|
||||
if (channelId == null) {
|
||||
channelId = "*";
|
||||
}
|
||||
if (streamId == null) {
|
||||
streamId = "*";
|
||||
}
|
||||
if (callId == null) {
|
||||
callId = "*";
|
||||
}
|
||||
String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + platformGbId
|
||||
+ "_" + channelId + "_" + streamId + "_" + callId;
|
||||
List<Object> scan = redis.scan(key);
|
||||
@@ -344,7 +384,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||
|
||||
@Override
|
||||
public List<SendRtpItem> querySendRTPServer(String platformGbId) {
|
||||
if (platformGbId == null) platformGbId = "*";
|
||||
if (platformGbId == null) {
|
||||
platformGbId = "*";
|
||||
}
|
||||
String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + platformGbId + "_*" + "_*" + "_*";
|
||||
List<Object> queryResult = redis.scan(key);
|
||||
List<SendRtpItem> result= new ArrayList<>();
|
||||
@@ -364,8 +406,12 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||
*/
|
||||
@Override
|
||||
public void deleteSendRTPServer(String platformGbId, String channelId, String callId, String streamId) {
|
||||
if (streamId == null) streamId = "*";
|
||||
if (callId == null) callId = "*";
|
||||
if (streamId == null) {
|
||||
streamId = "*";
|
||||
}
|
||||
if (callId == null) {
|
||||
callId = "*";
|
||||
}
|
||||
String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + platformGbId
|
||||
+ "_" + channelId + "_" + streamId + "_" + callId;
|
||||
List<Object> scan = redis.scan(key);
|
||||
@@ -473,10 +519,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||
if (stream == null && callId == null) {
|
||||
return null;
|
||||
}
|
||||
if (deviceId == null) deviceId = "*";
|
||||
if (channelId == null) channelId = "*";
|
||||
if (stream == null) stream = "*";
|
||||
if (callId == null) callId = "*";
|
||||
if (deviceId == null) {
|
||||
deviceId = "*";
|
||||
}
|
||||
if (channelId == null) {
|
||||
channelId = "*";
|
||||
}
|
||||
if (stream == null) {
|
||||
stream = "*";
|
||||
}
|
||||
if (callId == null) {
|
||||
callId = "*";
|
||||
}
|
||||
String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX,
|
||||
userSetting.getServerId(),
|
||||
deviceId,
|
||||
|
||||
@@ -460,7 +460,9 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
|
||||
public synchronized boolean outline(String deviceId) {
|
||||
logger.info("更新设备离线: " + deviceId);
|
||||
Device device = deviceMapper.getDeviceByDeviceId(deviceId);
|
||||
if (device == null) return false;
|
||||
if (device == null) {
|
||||
return false;
|
||||
}
|
||||
device.setOnline(0);
|
||||
redisCatchStorage.updateDevice(device);
|
||||
return deviceMapper.update(device) > 0;
|
||||
@@ -714,6 +716,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
|
||||
* 删除指定设备的所有移动位置
|
||||
* @param deviceId
|
||||
*/
|
||||
@Override
|
||||
public int clearMobilePositionsByDeviceId(String deviceId) {
|
||||
return deviceMobilePositionMapper.clearMobilePositionsByDeviceId(deviceId);
|
||||
}
|
||||
@@ -859,7 +862,9 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
|
||||
|
||||
@Override
|
||||
public void updateMediaList(List<StreamPushItem> streamPushItems) {
|
||||
if (streamPushItems == null || streamPushItems.size() == 0) return;
|
||||
if (streamPushItems == null || streamPushItems.size() == 0) {
|
||||
return;
|
||||
}
|
||||
logger.info("updateMediaList: " + streamPushItems.size());
|
||||
streamPushMapper.addAll(streamPushItems);
|
||||
// TODO 待优化
|
||||
|
||||
Reference in New Issue
Block a user