Merge branch 'master' into 重构/1078
This commit is contained in:
@@ -26,7 +26,7 @@ public interface IRedisRpcPlayService {
|
||||
|
||||
String frontEndCommand(String serverId, Integer channelId, int cmdCode, int parameter1, int parameter2, int combindCode2);
|
||||
|
||||
void playPush(Integer id, ErrorCallback<StreamInfo> callback);
|
||||
void playPush(String serverId, Integer id, ErrorCallback<StreamInfo> callback);
|
||||
|
||||
StreamInfo playProxy(String serverId, int id);
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Platform;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IDeviceService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IPlatformChannelService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IPlatformService;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
||||
@@ -55,6 +56,9 @@ public class RedisAlarmMsgListener implements MessageListener {
|
||||
@Autowired
|
||||
private IPlatformService platformService;
|
||||
|
||||
@Autowired
|
||||
private IPlatformChannelService platformChannelService;
|
||||
|
||||
private final ConcurrentLinkedQueue<Message> taskQueue = new ConcurrentLinkedQueue<>();
|
||||
|
||||
@Autowired
|
||||
@@ -89,11 +93,11 @@ public class RedisAlarmMsgListener implements MessageListener {
|
||||
log.warn("[REDIS的ALARM通知]消息解析失败");
|
||||
continue;
|
||||
}
|
||||
String gbId = alarmChannelMessage.getGbId();
|
||||
String chanelId = alarmChannelMessage.getGbId();
|
||||
|
||||
DeviceAlarm deviceAlarm = new DeviceAlarm();
|
||||
deviceAlarm.setCreateTime(DateUtil.getNow());
|
||||
deviceAlarm.setChannelId(gbId);
|
||||
deviceAlarm.setChannelId(chanelId);
|
||||
deviceAlarm.setAlarmDescription(alarmChannelMessage.getAlarmDescription());
|
||||
deviceAlarm.setAlarmMethod("" + alarmChannelMessage.getAlarmSn());
|
||||
deviceAlarm.setAlarmType("" + alarmChannelMessage.getAlarmType());
|
||||
@@ -102,7 +106,7 @@ public class RedisAlarmMsgListener implements MessageListener {
|
||||
deviceAlarm.setLongitude(0);
|
||||
deviceAlarm.setLatitude(0);
|
||||
|
||||
if (ObjectUtils.isEmpty(gbId)) {
|
||||
if (ObjectUtils.isEmpty(chanelId)) {
|
||||
if (userSetting.getSendToPlatformsWhenIdLost()) {
|
||||
// 发送给所有的上级
|
||||
List<Platform> parentPlatforms = platformService.queryEnablePlatformList(userSetting.getServerId());
|
||||
@@ -129,7 +133,6 @@ public class RedisAlarmMsgListener implements MessageListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// 获取开启了消息推送的设备和平台
|
||||
List<Device> devices = channelService.queryDeviceWithAsMessageChannel();
|
||||
@@ -143,24 +146,28 @@ public class RedisAlarmMsgListener implements MessageListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
Device device = deviceService.getDeviceByDeviceId(gbId);
|
||||
Platform platform = platformService.queryPlatformByServerGBId(gbId);
|
||||
if (device != null && platform == null) {
|
||||
// 获取该通道ID是属于设备还是对应的上级平台
|
||||
Device device = deviceService.getDeviceBySourceChannelDeviceId(chanelId);
|
||||
List<Platform> platforms = platformChannelService.queryByPlatformBySharChannelId(chanelId);
|
||||
if (device != null && device.getServerId().equals(userSetting.getServerId()) && (platforms == null || platforms.isEmpty())) {
|
||||
try {
|
||||
commander.sendAlarmMessage(device, deviceAlarm);
|
||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||
log.error("[命令发送失败] 发送报警: {}", e.getMessage());
|
||||
}
|
||||
} else if (device == null && platform != null) {
|
||||
try {
|
||||
commanderForPlatform.sendAlarmMessage(platform, deviceAlarm);
|
||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||
log.error("[命令发送失败] 发送报警: {}", e.getMessage());
|
||||
} else if (device == null && (platforms != null && !platforms.isEmpty() )) {
|
||||
for (Platform platform : platforms) {
|
||||
if (platform.getServerId().equals(userSetting.getServerId())) {
|
||||
try {
|
||||
commanderForPlatform.sendAlarmMessage(platform, deviceAlarm);
|
||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||
log.error("[命令发送失败] 发送报警: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("无法确定" + gbId + "是平台还是设备");
|
||||
log.warn("[REDIS的ALARM通知] 未查询到" + chanelId + "所属的平台或设备");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -48,7 +48,7 @@ public class RedisPushStreamStatusMsgListener implements MessageListener, Applic
|
||||
|
||||
@Override
|
||||
public void onMessage(Message message, byte[] bytes) {
|
||||
log.info("[REDIS: 流设备状态变化]: {}", new String(message.getBody()));
|
||||
log.info("[REDIS: 推流设备状态变化]: {}", new String(message.getBody()));
|
||||
taskQueue.offer(message);
|
||||
}
|
||||
|
||||
@@ -84,11 +84,13 @@ public class RedisPushStreamStatusMsgListener implements MessageListener, Applic
|
||||
if (streamStatusMessage.getOfflineStreams() != null
|
||||
&& !streamStatusMessage.getOfflineStreams().isEmpty()) {
|
||||
// 更新部分设备离线
|
||||
log.info("[REDIS: 推流设备状态变化] 更新部分设备离线: {}个", streamStatusMessage.getOfflineStreams().size());
|
||||
streamPushService.offline(streamStatusMessage.getOfflineStreams());
|
||||
}
|
||||
if (streamStatusMessage.getOnlineStreams() != null &&
|
||||
!streamStatusMessage.getOnlineStreams().isEmpty()) {
|
||||
// 更新部分设备上线
|
||||
log.info("[REDIS: 推流设备状态变化] 更新部分设备上线: {}个", streamStatusMessage.getOnlineStreams().size());
|
||||
streamPushService.online(streamStatusMessage.getOnlineStreams());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcResponse;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Platform;
|
||||
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
||||
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IPlatformChannelService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IPlatformService;
|
||||
import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcController;
|
||||
@@ -72,6 +71,7 @@ public class RedisRpcPlatformController extends RpcController {
|
||||
public RedisRpcResponse catalogEventPublish(RedisRpcRequest request) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(request.getParam().toString());
|
||||
Platform platform = jsonObject.getObject("platform", Platform.class);
|
||||
|
||||
List<CommonGBChannel> channels = jsonObject.getJSONArray("channels").toJavaList(CommonGBChannel.class);
|
||||
String type = jsonObject.getString("type");
|
||||
eventPublisher.catalogEventPublish(platform, channels, type, false);
|
||||
|
||||
@@ -181,7 +181,8 @@ public class RedisRpcStreamPushController extends RpcController {
|
||||
*/
|
||||
@RedisRpcMapping("play")
|
||||
public RedisRpcResponse play(RedisRpcRequest request) {
|
||||
int id = Integer.parseInt(request.getParam().toString());
|
||||
JSONObject paramJson = JSONObject.parseObject(request.getParam().toString());
|
||||
int id = paramJson.getInteger("id");
|
||||
RedisRpcResponse response = request.getResponse();
|
||||
if (id <= 0) {
|
||||
response.setStatusCode(ErrorCode.ERROR400.getCode());
|
||||
|
||||
@@ -193,8 +193,11 @@ public class RedisRpcPlayServiceImpl implements IRedisRpcPlayService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playPush(Integer id, ErrorCallback<StreamInfo> callback) {
|
||||
RedisRpcRequest request = buildRequest("streamPush/play", id);
|
||||
public void playPush(String serverId, Integer id, ErrorCallback<StreamInfo> callback) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("id", id);
|
||||
RedisRpcRequest request = buildRequest("streamPush/play", jsonObject);
|
||||
request.setToId(serverId);
|
||||
RedisRpcResponse response = redisRpcConfig.request(request, userSetting.getPlayTimeout(), TimeUnit.SECONDS);
|
||||
if (response == null) {
|
||||
callback.run(ErrorCode.ERROR100.getCode(), ErrorCode.ERROR100.getMsg(), null);
|
||||
|
||||
@@ -231,6 +231,9 @@ public class RedisRpcServiceImpl implements IRedisRpcService {
|
||||
RedisRpcRequest request = buildRequest("platform/update", platform);
|
||||
request.setToId(serverId);
|
||||
RedisRpcResponse response = redisRpcConfig.request(request, 40, TimeUnit.MILLISECONDS);
|
||||
if(response == null) {
|
||||
return false;
|
||||
}
|
||||
return Boolean.parseBoolean(response.getBody().toString());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user