diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/CommonGbChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/CommonGbChannelServiceImpl.java index ff264026..9c9f9a55 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/CommonGbChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/CommonGbChannelServiceImpl.java @@ -298,6 +298,11 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService { @Override public void batchUpdate(List commonGbChannels) { + for (CommonGbChannel commonGbChannel : commonGbChannels) { + if (commonGbChannel.getCommonGbDeviceID().equals("34020000001310000002")) { + System.out.println("34020000001310000002====" + commonGbChannel.getCommonGbStatus()); + } + } if (commonGbChannels.isEmpty()) { return; } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java index f48a2936..24a09ffd 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java @@ -592,7 +592,10 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { }); if (!addChannelList.isEmpty()) { addChannelList.stream().forEach(channel ->{ - channel.setCommonGbChannelId(commonChannelDeviceAndIdMap.get(channel.getChannelId())); + Integer commonGbChannelId = commonChannelDeviceAndIdMap.get(channel.getChannelId()); + if (commonGbChannelId != null) { + channel.setCommonGbChannelId(commonGbChannelId); + } }); addChannelHandler(addChannelList); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java index 63e32df3..23c1267b 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java @@ -146,6 +146,10 @@ public class DeviceServiceImpl implements IDeviceService { device.setCreateTime(now); deviceMapper.update(device); redisCatchStorage.updateDevice(device); + List ids = deviceChannelMapper.getCommonChannelIdList(device.getDeviceId(), true); + if (!ids.isEmpty()) { + commonGbChannelService.onlineForList(ids); + } if (userSetting.getSyncChannelOnDeviceOnline()) { logger.info("[设备上线,离线状态下重新注册]: {},查询设备信息以及通道信息", device.getDeviceId()); try { @@ -155,10 +159,6 @@ public class DeviceServiceImpl implements IDeviceService { } sync(device); } - List ids = deviceChannelMapper.getCommonChannelIdList(device.getDeviceId()); - if (!ids.isEmpty()) { - commonGbChannelService.onlineForList(ids); - } // 上线添加订阅 if (device.getSubscribeCycleForCatalog() > 0) { // 查询在线设备那些开启了订阅,为设备开启定时的目录订阅 @@ -216,7 +216,8 @@ public class DeviceServiceImpl implements IDeviceService { // 发送redis消息 redisCatchStorage.sendDeviceOrChannelStatus(device.getDeviceId(), null, false); } - List ids = deviceChannelMapper.getCommonChannelIdList(device.getDeviceId()); + // 设备离线则其下的全部通用通道设置为离线 + List ids = deviceChannelMapper.getCommonChannelIdList(device.getDeviceId(), null); if (!ids.isEmpty()) { commonGbChannelService.offlineForList(ids); } @@ -588,7 +589,7 @@ public class DeviceServiceImpl implements IDeviceService { @Override @Transactional public boolean delete(String deviceId) { - List commonChannelIdList = deviceChannelMapper.getCommonChannelIdList(deviceId); + List commonChannelIdList = deviceChannelMapper.getCommonChannelIdList(deviceId, null); if (!commonChannelIdList.isEmpty()) { commonGbChannelService.deleteByIdList(commonChannelIdList); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java index 3c38b343..280dbeaa 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java @@ -816,43 +816,43 @@ public class StreamProxyServiceImpl implements IStreamProxyService { /** * 检查拉流代理状态 */ - @Scheduled(cron = "* 0/10 * * * ?") - @Transactional - public void asyncCheckStreamProxyStatus() { - - List all = mediaServerService.getAllOnline(); - if (CollectionUtils.isEmpty(all)){ - return; - } - Map serverItemMap = all.stream().collect( - Collectors.toMap(MediaServerItem::getId, Function.identity(), (m1, m2) -> m1)); - List list = getAllForEnable(); - - if (CollectionUtils.isEmpty(list)){ - return; - } - for (StreamProxy streamProxyItem : list) { - MediaServerItem mediaServerItem = serverItemMap.get(streamProxyItem.getMediaServerId()); - JSONObject mediaInfo = zlmresTfulUtils.isMediaOnline(mediaServerItem, streamProxyItem.getApp(), - streamProxyItem.getStream(), "rtsp"); - if (mediaInfo == null){ - if (streamProxyItem.isStatus()) { - updateStatusById(streamProxyItem, false); - } - } else { - if (mediaInfo.getInteger("code") == 0 && mediaInfo.getBoolean("online")) { - if (!streamProxyItem.isStatus()) { - updateStatusById(streamProxyItem, true); - } - } else { - if (streamProxyItem.isStatus()) { - updateStatusById(streamProxyItem, false); - } - } - } - - } - } +// @Scheduled(cron = "* 0/10 * * * ?") +// @Transactional +// public void asyncCheckStreamProxyStatus() { +// +// List all = mediaServerService.getAllOnline(); +// if (CollectionUtils.isEmpty(all)){ +// return; +// } +// Map serverItemMap = all.stream().collect( +// Collectors.toMap(MediaServerItem::getId, Function.identity(), (m1, m2) -> m1)); +// List list = getAllForEnable(); +// +// if (CollectionUtils.isEmpty(list)){ +// return; +// } +// for (StreamProxy streamProxyItem : list) { +// MediaServerItem mediaServerItem = serverItemMap.get(streamProxyItem.getMediaServerId()); +// JSONObject mediaInfo = zlmresTfulUtils.isMediaOnline(mediaServerItem, streamProxyItem.getApp(), +// streamProxyItem.getStream(), "rtsp"); +// if (mediaInfo == null){ +// if (streamProxyItem.isStatus()) { +// updateStatusById(streamProxyItem, false); +// } +// } else { +// if (mediaInfo.getInteger("code") == 0 && mediaInfo.getBoolean("online")) { +// if (!streamProxyItem.isStatus()) { +// updateStatusById(streamProxyItem, true); +// } +// } else { +// if (streamProxyItem.isStatus()) { +// updateStatusById(streamProxyItem, false); +// } +// } +// } +// +// } +// } @Override public void updateStreamGPS(List gpsMsgInfoList) { diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/CommonChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/CommonChannelMapper.java index 22c406d8..19db3a6c 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/CommonChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/CommonChannelMapper.java @@ -64,8 +64,8 @@ public interface CommonChannelMapper { @Delete(value = "") int removeChannelsForGroup(List channels); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java index 2fd34559..de213bb9 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java @@ -530,8 +530,9 @@ public interface DeviceChannelMapper { "select common_gb_channel_id " + "from wvp_device_channel " + "where device_id=#{deviceId}" + + " and status = #{online} " + " "}) - List getCommonChannelIdList(@Param("deviceId") String deviceId); + List getCommonChannelIdList(@Param("deviceId") String deviceId, @Param("online") Boolean online); @Select("select de.* from wvp_device de left join wvp_device_channel dc on de.device_id = dc.deviceId where dc.common_gb_channel_id=#{commonGbId}") Device getDeviceByChannelCommonGbId(@Param("commonGbId") int commonGbId);