完成向上级联->保活
This commit is contained in:
@@ -2,6 +2,9 @@ package com.genersoft.iot.vmp.storager;
|
||||
|
||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.conf.MediaServerConfig;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.PlatformRegister;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -55,4 +58,13 @@ public interface IRedisCatchStorage {
|
||||
boolean stopPlayback(StreamInfo streamInfo);
|
||||
|
||||
StreamInfo queryPlaybackByDevice(String deviceId, String code);
|
||||
|
||||
void updatePlatformCatchInfo(ParentPlatformCatch parentPlatformCatch);
|
||||
|
||||
ParentPlatformCatch queryPlatformCatchInfo(String platformGbId);
|
||||
|
||||
void updatePlatformKeepalive(ParentPlatform parentPlatform);
|
||||
|
||||
void updatePlatformRegister(ParentPlatform parentPlatform);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.genersoft.iot.vmp.storager;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
/**
|
||||
@@ -136,4 +139,39 @@ public interface IVideoManagerStorager {
|
||||
*/
|
||||
void cleanChannelsForDevice(String deviceId);
|
||||
|
||||
|
||||
/**
|
||||
* 更新上级平台
|
||||
* @param parentPlatform
|
||||
*/
|
||||
boolean updateParentPlatform(ParentPlatform parentPlatform);
|
||||
|
||||
|
||||
/**
|
||||
* 添加上级平台
|
||||
* @param parentPlatform
|
||||
*/
|
||||
boolean addParentPlatform(ParentPlatform parentPlatform);
|
||||
|
||||
/**
|
||||
* 删除上级平台
|
||||
* @param parentPlatform
|
||||
*/
|
||||
boolean deleteParentPlatform(ParentPlatform parentPlatform);
|
||||
|
||||
|
||||
/**
|
||||
* 分页获取上级平台
|
||||
* @param page
|
||||
* @param count
|
||||
* @return
|
||||
*/
|
||||
PageInfo<ParentPlatform> queryParentPlatformList(int page, int count);
|
||||
|
||||
/**
|
||||
* 获取上级平台
|
||||
* @param platformGbId
|
||||
* @return
|
||||
*/
|
||||
ParentPlatform queryParentPlatById(String platformGbId);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.genersoft.iot.vmp.storager.dao;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
@@ -48,4 +49,6 @@ public interface DeviceChannelMapper {
|
||||
@Delete("DELETE FROM device_channel WHERE deviceId=#{deviceId}")
|
||||
int cleanChannelsByDeviceId(String deviceId);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.genersoft.iot.vmp.storager.dao;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -63,4 +64,5 @@ public interface DeviceMapper {
|
||||
|
||||
@Delete("DELETE FROM device WHERE deviceId=#{deviceId}")
|
||||
int del(String deviceId);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.genersoft.iot.vmp.storager.dao;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用于存储上级平台
|
||||
*/
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface ParentPlatformMapper {
|
||||
|
||||
@Insert("INSERT INTO parent_platform (enable, name, serverGBId, serverGBDomain, serverIP, serverPort, deviceGBId, deviceIp, " +
|
||||
" devicePort, username, password, expires, keepTimeout, transport, characterSet, PTZEnable, rtcp, " +
|
||||
" status) " +
|
||||
" VALUES (${enable}, '${name}', '${serverGBId}', '${serverGBDomain}', '${serverIP}', ${serverPort}, '${deviceGBId}', '${deviceIp}', " +
|
||||
" '${devicePort}', '${username}', '${password}', '${expires}', '${keepTimeout}', '${transport}', '${characterSet}', ${PTZEnable}, ${rtcp}, " +
|
||||
" ${status})")
|
||||
int addParentPlatform(ParentPlatform parentPlatform);
|
||||
|
||||
@Update("UPDATE parent_platform " +
|
||||
"SET enable=#{enable}, " +
|
||||
"name=#{name}," +
|
||||
"serverGBId=#{serverGBId}," +
|
||||
"serverGBDomain=#{serverGBDomain}, " +
|
||||
"serverIP=#{serverIP}," +
|
||||
"serverPort=#{serverPort}, " +
|
||||
"deviceIp=#{deviceIp}, " +
|
||||
"devicePort=#{devicePort}, " +
|
||||
"username=#{username}, " +
|
||||
"password=#{password}, " +
|
||||
"expires=#{expires}, " +
|
||||
"keepTimeout=#{keepTimeout}, " +
|
||||
"transport=#{transport}, " +
|
||||
"characterSet=#{characterSet}, " +
|
||||
"PTZEnable=#{PTZEnable}, " +
|
||||
"rtcp=#{rtcp}, " +
|
||||
"status=#{status} " +
|
||||
"WHERE deviceGBId=#{deviceGBId}")
|
||||
int updateParentPlatform(ParentPlatform parentPlatform);
|
||||
|
||||
@Delete("DELETE FROM parent_platform WHERE deviceGBId=#{deviceGBId}")
|
||||
int delParentPlatform(ParentPlatform parentPlatform);
|
||||
|
||||
|
||||
@Select("SELECT * FROM parent_platform")
|
||||
List<ParentPlatform> getParentPlatformList();
|
||||
|
||||
@Select("SELECT * FROM parent_platform WHERE deviceGBId=#{platformGbId}")
|
||||
ParentPlatform getParentPlatById(String platformGbId);
|
||||
}
|
||||
@@ -4,6 +4,9 @@ import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.common.VideoManagerConstants;
|
||||
import com.genersoft.iot.vmp.conf.MediaServerConfig;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.PlatformRegister;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
|
||||
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
|
||||
@@ -163,4 +166,27 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||
if (playLeys == null || playLeys.size() == 0) return null;
|
||||
return (StreamInfo)redis.get(playLeys.get(0).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePlatformCatchInfo(ParentPlatformCatch parentPlatformCatch) {
|
||||
String key = VideoManagerConstants.PLATFORM_CATCH_PREFIX + parentPlatformCatch.getId();
|
||||
redis.set(key, parentPlatformCatch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePlatformKeepalive(ParentPlatform parentPlatform) {
|
||||
String key = VideoManagerConstants.PLATFORM_KEEPLIVEKEY_PREFIX + parentPlatform.getDeviceGBId();
|
||||
redis.set(key, "", Integer.parseInt(parentPlatform.getKeepTimeout()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePlatformRegister(ParentPlatform parentPlatform) {
|
||||
String key = VideoManagerConstants.PLATFORM_REGISTER_PREFIX + parentPlatform.getDeviceGBId();
|
||||
redis.set(key, "", Integer.parseInt(parentPlatform.getExpires()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParentPlatformCatch queryPlatformCatchInfo(String platformGbId) {
|
||||
return (ParentPlatformCatch)redis.get(VideoManagerConstants.PLATFORM_CATCH_PREFIX + platformGbId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,17 +3,17 @@ package com.genersoft.iot.vmp.storager.impl;
|
||||
import java.util.*;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
|
||||
import com.genersoft.iot.vmp.storager.dao.DeviceMapper;
|
||||
import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import io.swagger.models.auth.In;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @Description:视频设备数据存储-jdbc实现
|
||||
@@ -29,6 +29,9 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
@Autowired
|
||||
private DeviceChannelMapper deviceChannelMapper;
|
||||
|
||||
@Autowired
|
||||
private ParentPlatformMapper platformMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 根据设备ID判断设备是否存在
|
||||
@@ -198,5 +201,40 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
int result = deviceChannelMapper.cleanChannelsByDeviceId(deviceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addParentPlatform(ParentPlatform parentPlatform) {
|
||||
int result = platformMapper.addParentPlatform(parentPlatform);
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateParentPlatform(ParentPlatform parentPlatform) {
|
||||
int result = 0;
|
||||
if ( platformMapper.getParentPlatById(parentPlatform.getDeviceGBId()) == null) {
|
||||
result = platformMapper.addParentPlatform(parentPlatform);
|
||||
}else {
|
||||
result = platformMapper.updateParentPlatform(parentPlatform);
|
||||
}
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteParentPlatform(ParentPlatform parentPlatform) {
|
||||
int result = platformMapper.delParentPlatform(parentPlatform);
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<ParentPlatform> queryParentPlatformList(int page, int count) {
|
||||
PageHelper.startPage(page, count);
|
||||
List<ParentPlatform> all = platformMapper.getParentPlatformList();
|
||||
return new PageInfo<>(all);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParentPlatform queryParentPlatById(String platformGbId) {
|
||||
return platformMapper.getParentPlatById(platformGbId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user