临时提交

结构优化
648540858 2024-01-18 14:11:07 +08:00
parent 1538ad358d
commit 7200e56d59
6 changed files with 57 additions and 47 deletions

View File

@ -298,6 +298,11 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService {
@Override
public void batchUpdate(List<CommonGbChannel> commonGbChannels) {
for (CommonGbChannel commonGbChannel : commonGbChannels) {
if (commonGbChannel.getCommonGbDeviceID().equals("34020000001310000002")) {
System.out.println("34020000001310000002====" + commonGbChannel.getCommonGbStatus());
}
}
if (commonGbChannels.isEmpty()) {
return;
}

View File

@ -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);
}

View File

@ -146,6 +146,10 @@ public class DeviceServiceImpl implements IDeviceService {
device.setCreateTime(now);
deviceMapper.update(device);
redisCatchStorage.updateDevice(device);
List<Integer> 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<Integer> 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<Integer> ids = deviceChannelMapper.getCommonChannelIdList(device.getDeviceId());
// 设备离线则其下的全部通用通道设置为离线
List<Integer> 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<Integer> commonChannelIdList = deviceChannelMapper.getCommonChannelIdList(deviceId);
List<Integer> commonChannelIdList = deviceChannelMapper.getCommonChannelIdList(deviceId, null);
if (!commonChannelIdList.isEmpty()) {
commonGbChannelService.deleteByIdList(commonChannelIdList);
}

View File

@ -816,43 +816,43 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
/**
*
*/
@Scheduled(cron = "* 0/10 * * * ?")
@Transactional
public void asyncCheckStreamProxyStatus() {
List<MediaServerItem> all = mediaServerService.getAllOnline();
if (CollectionUtils.isEmpty(all)){
return;
}
Map<String, MediaServerItem> serverItemMap = all.stream().collect(
Collectors.toMap(MediaServerItem::getId, Function.identity(), (m1, m2) -> m1));
List<StreamProxy> 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<MediaServerItem> all = mediaServerService.getAllOnline();
// if (CollectionUtils.isEmpty(all)){
// return;
// }
// Map<String, MediaServerItem> serverItemMap = all.stream().collect(
// Collectors.toMap(MediaServerItem::getId, Function.identity(), (m1, m2) -> m1));
// List<StreamProxy> 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<GPSMsgInfo> gpsMsgInfoList) {

View File

@ -64,8 +64,8 @@ public interface CommonChannelMapper {
@Delete(value = "<script>" +
"<foreach collection='channels' item='item' separator=';'>" +
"delete from wvp_common_channel WHERE common_gb_id=#{item.commonGbId}" +
"<foreach collection='channels' item='item' separator=';'> " +
" delete from wvp_common_channel WHERE common_gb_id=#{item.commonGbId}" +
"</foreach>" +
"</script>")
int removeChannelsForGroup(List<CommonGbChannel> channels);

View File

@ -530,8 +530,9 @@ public interface DeviceChannelMapper {
"select common_gb_channel_id " +
"from wvp_device_channel " +
"where device_id=#{deviceId}" +
"<if test='online != null'> and status = #{online} </if>" +
" </script>"})
List<Integer> getCommonChannelIdList(@Param("deviceId") String deviceId);
List<Integer> 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);