修复数据库语法兼容以及redis接收推流信息导入

pull/1642/head
648540858 2024-09-14 15:19:07 +08:00
parent a36c427394
commit 800d6c926a
21 changed files with 120 additions and 274 deletions

View File

@ -32,7 +32,7 @@ public class RedisMsgListenConfig {
private RedisPushStreamStatusMsgListener redisPushStreamStatusMsgListener;
@Autowired
private RedisPushStreamStatusListMsgListener redisPushStreamListMsgListener;
private RedisPushStreamListMsgListener pushStreamListMsgListener;
@Autowired
@ -61,7 +61,7 @@ public class RedisMsgListenConfig {
container.addMessageListener(redisGPSMsgListener, new PatternTopic(VideoManagerConstants.VM_MSG_GPS));
container.addMessageListener(redisAlarmMsgListener, new PatternTopic(VideoManagerConstants.VM_MSG_SUBSCRIBE_ALARM_RECEIVE));
container.addMessageListener(redisPushStreamStatusMsgListener, new PatternTopic(VideoManagerConstants.VM_MSG_PUSH_STREAM_STATUS_CHANGE));
container.addMessageListener(redisPushStreamListMsgListener, new PatternTopic(VideoManagerConstants.VM_MSG_PUSH_STREAM_LIST_CHANGE));
container.addMessageListener(pushStreamListMsgListener, new PatternTopic(VideoManagerConstants.VM_MSG_PUSH_STREAM_LIST_CHANGE));
container.addMessageListener(redisCloseStreamMsgListener, new PatternTopic(VideoManagerConstants.VM_MSG_STREAM_PUSH_CLOSE));
container.addMessageListener(redisRpcConfig, new PatternTopic(RedisRpcConfig.REDIS_REQUEST_CHANNEL_KEY));
container.addMessageListener(redisPushStreamCloseResponseListener, new PatternTopic(VideoManagerConstants.VM_MSG_STREAM_PUSH_RESPONSE));

View File

@ -51,7 +51,7 @@ public class CommonGBChannel {
// 2016
@Schema(description = "国标-证书序列号")
private Integer gbCertNum;
private String gbCertNum;
// 2016
@Schema(description = "国标-证书有效标识")
@ -63,7 +63,7 @@ public class CommonGBChannel {
// 2016
@Schema(description = "国标-证书终止有效期(有证书且证书无效的设备必选)")
private Integer gbEndTime;
private String gbEndTime;
// 2022
@Schema(description = "国标-摄像机安全能力等级代码")

View File

@ -97,14 +97,14 @@ public class Platform {
@Schema(description = "是否自动推送通道变化")
private Boolean autoPushChannel;
@Schema(description = "目录信息包含平台信息")
private Boolean catalogWithPlatform;
@Schema(description = "目录信息包含平台信息, 0关闭1打开")
private int catalogWithPlatform;
@Schema(description = "目录信息包含分组信息")
private Boolean catalogWithGroup;
@Schema(description = "目录信息包含分组信息, 0关闭1打开")
private int catalogWithGroup;
@Schema(description = "目录信息包含行政区划")
private Boolean catalogWithRegion;
@Schema(description = "目录信息包含行政区划, 0关闭1打开")
private int catalogWithRegion;
@Schema(description = "行政区划")
private String civilCode;

View File

@ -154,13 +154,13 @@ public interface CommonGBChannelMapper {
@Update("<script> " +
"<foreach collection='commonGBChannels' index='index' item='item' separator=';'> " +
"UPDATE wvp_device_channel SET gb_status = #{gbStatus} WHERE id = #{item.gbId}" +
"UPDATE wvp_device_channel SET gb_status = #{status} WHERE id = #{item.gbId}" +
"</foreach> " +
"</script>")
int updateStatusForListById(List<CommonGBChannel> commonGBChannels, @Param("status") int status);
int updateStatusForListById(List<CommonGBChannel> commonGBChannels, @Param("status") String status);
@SelectProvider(type = ChannelProvider.class, method = "queryInListByStatus")
List<CommonGBChannel> queryInListByStatus(List<CommonGBChannel> commonGBChannelList, @Param("status") int status);
List<CommonGBChannel> queryInListByStatus(List<CommonGBChannel> commonGBChannelList, @Param("status") String status);
@Insert(" <script>" +
@ -411,7 +411,7 @@ public interface CommonGBChannelMapper {
", gb_download_speed=#{item.gbDownloadSpeed}" +
", gb_svc_space_support_mod=#{item.gbSvcSpaceSupportMod}" +
", gb_svc_time_support_mode=#{item.gbSvcTimeSupportMode}" +
" WHERE id=#{item.id}" +
" WHERE id=#{item.gbId}" +
"</foreach>" +
"</script>"})
int batchUpdate(List<CommonGBChannel> commonGBChannels);

View File

@ -612,7 +612,7 @@ public interface DeviceChannelMapper {
int batchOffline(List<DeviceChannel> channels);
@Select("select count(1) from wvp_device_channel where status = true")
@Select("select count(1) from wvp_device_channel where status = 'ON'")
int getOnlineCount();
@Select("select count(1) from wvp_device_channel")

View File

@ -153,7 +153,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
log.warn("[多个通道离线] 通道数量为0更新失败");
return 0;
}
List<CommonGBChannel> onlineChannelList = commonGBChannelMapper.queryInListByStatus(commonGBChannelList, 1);
List<CommonGBChannel> onlineChannelList = commonGBChannelMapper.queryInListByStatus(commonGBChannelList, "ON");
if (onlineChannelList.isEmpty()) {
log.warn("[多个通道离线] 更新失败, 参数内通道已经离线");
return 0;
@ -166,10 +166,10 @@ public class GbChannelServiceImpl implements IGbChannelService {
if (i + limitCount > onlineChannelList.size()) {
toIndex = onlineChannelList.size();
}
result += commonGBChannelMapper.updateStatusForListById(onlineChannelList.subList(i, toIndex), 0);
result += commonGBChannelMapper.updateStatusForListById(onlineChannelList.subList(i, toIndex), "OFF");
}
} else {
result += commonGBChannelMapper.updateStatusForListById(onlineChannelList, 0);
result += commonGBChannelMapper.updateStatusForListById(onlineChannelList, "OFF");
}
if (result > 0) {
try {
@ -207,7 +207,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
log.warn("[多个通道上线] 通道数量为0更新失败");
return 0;
}
List<CommonGBChannel> offlineChannelList = commonGBChannelMapper.queryInListByStatus(commonGBChannelList, 0);
List<CommonGBChannel> offlineChannelList = commonGBChannelMapper.queryInListByStatus(commonGBChannelList, "OFF");
if (offlineChannelList.isEmpty()) {
log.warn("[多个通道上线] 更新失败, 参数内通道已经上线线");
return 0;
@ -221,10 +221,10 @@ public class GbChannelServiceImpl implements IGbChannelService {
if (i + limitCount > offlineChannelList.size()) {
toIndex = offlineChannelList.size();
}
result += commonGBChannelMapper.updateStatusForListById(offlineChannelList.subList(i, toIndex), 1);
result += commonGBChannelMapper.updateStatusForListById(offlineChannelList.subList(i, toIndex), "ON");
}
} else {
result += commonGBChannelMapper.updateStatusForListById(offlineChannelList, 1);
result += commonGBChannelMapper.updateStatusForListById(offlineChannelList, "ON");
}
if (result > 0) {
try {
@ -282,7 +282,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
} else {
result += commonGBChannelMapper.batchUpdate(commonGBChannels);
}
log.warn("[更新多个通道] 通道数量为{},成功保存:{}", commonGBChannels.size(), result);
log.info("[更新多个通道] 通道数量为{},成功保存:{}", commonGBChannels.size(), result);
// 发送通过更新通知
try {
// 发送通知

View File

@ -376,19 +376,19 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
}
List<CommonGBChannel> channelList = new ArrayList<>();
// 是否包含平台信息
if (platform.getCatalogWithPlatform()) {
if (platform.getCatalogWithPlatform() > 0) {
CommonGBChannel channel = CommonGBChannel.build(platform);
channelList.add(channel);
}
// 关联的行政区划信息
if (platform.getCatalogWithRegion()) {
if (platform.getCatalogWithRegion() > 0) {
// 查询关联平台的行政区划信息
List<CommonGBChannel> regionChannelList = regionMapper.queryByPlatform(platform.getId());
if (!regionChannelList.isEmpty()) {
channelList.addAll(regionChannelList);
}
}
if (platform.getCatalogWithGroup()) {
if (platform.getCatalogWithGroup() > 0) {
// 关联的分组信息
List<CommonGBChannel> groupChannelList = groupMapper.queryForPlatform(platform.getId());
if (!groupChannelList.isEmpty()) {

View File

@ -27,7 +27,6 @@ import com.genersoft.iot.vmp.media.service.IMediaServerService;
import com.genersoft.iot.vmp.service.ISendRtpServerService;
import com.genersoft.iot.vmp.service.bean.*;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.dao.GbStreamMapper;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@ -83,9 +82,6 @@ public class PlatformServiceImpl implements IPlatformService {
@Autowired
private SubscribeHolder subscribeHolder;
@Autowired
private GbStreamMapper gbStreamMapper;
@Autowired
private UserSetting userSetting;
@ -457,27 +453,21 @@ public class PlatformServiceImpl implements IPlatformService {
SubscribeInfo subscribe = subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId());
if (subscribe != null) {
// TODO 暂时只处理视频流的回复,后续增加对国标设备的支持
List<DeviceChannel> gbStreams = gbStreamMapper.queryGbStreamListInPlatform(platform.getServerGBId(), userSetting.isUsePushingAsStatus());
if (gbStreams.size() == 0) {
List<CommonGBChannel> channelList = platformChannelMapper.queryShare(platform.getId(), null);
if (channelList.isEmpty()) {
return;
}
for (DeviceChannel deviceChannel : gbStreams) {
String gbId = deviceChannel.getDeviceId();
GPSMsgInfo gpsMsgInfo = redisCatchStorage.getGpsMsgInfo(gbId);
for (CommonGBChannel channel : channelList) {
GPSMsgInfo gpsMsgInfo = redisCatchStorage.getGpsMsgInfo(channel.getGbId());
// 无最新位置不发送
if (gpsMsgInfo != null) {
// 经纬度都为0不发送
if (gpsMsgInfo.getLng() == 0 && gpsMsgInfo.getLat() == 0) {
continue;
}
CommonGBChannel commonGBChannel = platformChannelMapper.queryShareChannel(platform.getId(), deviceChannel.getId());
if (commonGBChannel == null) {
continue;
}
// 发送GPS消息
try {
commanderForPlatform.sendNotifyMobilePosition(platform, gpsMsgInfo, commonGBChannel, subscribe);
commanderForPlatform.sendNotifyMobilePosition(platform, gpsMsgInfo, channel, subscribe);
} catch (InvalidArgumentException | ParseException | NoSuchFieldException | SipException |
IllegalAccessException e) {
log.error("[命令发送失败] 国标级联 移动位置通知: {}", e.getMessage());

View File

@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.service.redisMsg;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.genersoft.iot.vmp.media.service.IMediaServerService;
import com.genersoft.iot.vmp.streamPush.bean.RedisPushStreamMessage;
import com.genersoft.iot.vmp.streamPush.bean.StreamPush;
import com.genersoft.iot.vmp.streamPush.service.IStreamPushService;
import com.genersoft.iot.vmp.utils.DateUtil;
@ -24,10 +25,12 @@ import java.util.concurrent.ConcurrentLinkedQueue;
* @Auther: JiangFeng
* @Date: 2022/8/16 11:32
* @Description: redis
* SUBSCRIBE VM_MSG_PUSH_STREAM_LIST_CHANGE
* PUBLISH VM_MSG_PUSH_STREAM_LIST_CHANGE '[{"app":1000,"stream":10000000,"gbId":"12345678901234567890","name":"A6","status":false},{"app":1000,"stream":10000021,"gbId":"24212345671381000021","name":"终端9273","status":false},{"app":1000,"stream":10000022,"gbId":"24212345671381000022","name":"终端9434","status":true},{"app":1000,"stream":10000025,"gbId":"24212345671381000025","name":"华为M10","status":false},{"app":1000,"stream":10000051,"gbId":"11111111111381111122","name":"终端9720","status":false}]'
*/
@Slf4j
@Component
public class RedisPushStreamStatusListMsgListener implements MessageListener {
public class RedisPushStreamListMsgListener implements MessageListener {
@Resource
private IMediaServerService mediaServerService;
@ -51,7 +54,7 @@ public class RedisPushStreamStatusListMsgListener implements MessageListener {
while (!taskQueue.isEmpty()) {
Message msg = taskQueue.poll();
try {
List<StreamPush> streamPushItems = JSON.parseArray(new String(msg.getBody()), StreamPush.class);
List<RedisPushStreamMessage> streamPushItems = JSON.parseArray(new String(msg.getBody()), RedisPushStreamMessage.class);
//查询全部的app+stream 用于判断是添加还是修改
Map<String, StreamPush> allAppAndStream = streamPushService.getAllAppAndStreamMap();
Map<String, StreamPush> allGBId = streamPushService.getAllGBId();
@ -61,31 +64,39 @@ public class RedisPushStreamStatusListMsgListener implements MessageListener {
*/
List<StreamPush> streamPushItemForSave = new ArrayList<>();
List<StreamPush> streamPushItemForUpdate = new ArrayList<>();
for (StreamPush streamPush : streamPushItems) {
String app = streamPush.getApp();
String stream = streamPush.getStream();
for (RedisPushStreamMessage pushStreamMessage : streamPushItems) {
String app = pushStreamMessage.getApp();
String stream = pushStreamMessage.getStream();
boolean contains = allAppAndStream.containsKey(app + stream);
//不存在就添加
if (!contains) {
if (allGBId.containsKey(streamPush.getGbDeviceId())) {
StreamPush streamPushInDb = allGBId.get(streamPush.getGbDeviceId());
if (allGBId.containsKey(pushStreamMessage.getGbId())) {
StreamPush streamPushInDb = allGBId.get(pushStreamMessage.getGbId());
log.warn("[REDIS消息-推流设备列表更新-INSERT] 国标编号重复: {}, 已分配给{}/{}",
streamPushInDb.getGbDeviceId(), streamPushInDb.getApp(), streamPushInDb.getStream());
continue;
}
StreamPush streamPush = pushStreamMessage.buildstreamPush();
streamPush.setCreateTime(DateUtil.getNow());
streamPush.setUpdateTime(DateUtil.getNow());
streamPush.setMediaServerId(mediaServerService.getDefaultMediaServer().getId());
streamPushItemForSave.add(streamPush);
allGBId.put(streamPush.getGbDeviceId(), streamPush);
} else {
if (allGBId.containsKey(streamPush.getGbDeviceId())
&& (!allGBId.get(streamPush.getGbDeviceId()).getApp().equals(streamPush.getApp())
|| !allGBId.get(streamPush.getGbDeviceId()).getStream().equals(streamPush.getStream()))) {
StreamPush streamPushInDb = allGBId.get(streamPush.getGbDeviceId());
StreamPush streamPushForGbDeviceId = allGBId.get(pushStreamMessage.getGbId());
if (streamPushForGbDeviceId != null
&& (!streamPushForGbDeviceId.getApp().equals(pushStreamMessage.getApp())
|| !streamPushForGbDeviceId.getStream().equals(pushStreamMessage.getStream()))) {
StreamPush streamPushInDb = allGBId.get(pushStreamMessage.getGbId());
log.warn("[REDIS消息-推流设备列表更新-UPDATE] 国标编号重复: {}, 已分配给{}/{}",
streamPush.getGbDeviceId(), streamPushInDb.getApp(), streamPushInDb.getStream());
pushStreamMessage.getGbId(), streamPushInDb.getApp(), streamPushInDb.getStream());
continue;
}
StreamPush streamPush = allAppAndStream.get(app + stream);
streamPush.setUpdateTime(DateUtil.getNow());
streamPush.setGbDeviceId(pushStreamMessage.getGbId());
streamPush.setGbName(pushStreamMessage.getName());
streamPush.setGbStatus(pushStreamMessage.isStatus()?"ON":"OFF");
//存在就只修改 name和gbId
streamPushItemForUpdate.add(streamPush);
}

View File

@ -97,7 +97,7 @@ public interface IRedisCatchStorage {
void updateGpsMsgInfo(GPSMsgInfo gpsMsgInfo);
GPSMsgInfo getGpsMsgInfo(String gbId);
GPSMsgInfo getGpsMsgInfo(Integer gbId);
List<GPSMsgInfo> getAllGpsMsgInfo();
Long getSN(String method);

View File

@ -1,177 +0,0 @@
package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import com.genersoft.iot.vmp.streamProxy.bean.StreamProxy;
import com.genersoft.iot.vmp.streamPush.bean.StreamPush;
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
@Mapper
@Repository
public interface GbStreamMapper {
@Insert("INSERT INTO wvp_gb_stream (app, stream, gb_id, name, " +
"longitude, latitude, stream_type,media_server_id,create_time) VALUES" +
"(#{app}, #{stream}, #{gbId}, #{name}, " +
"#{longitude}, #{latitude}, #{streamType}, " +
"#{mediaServerId}, #{createTime})")
@Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gb_stream_id")
int add(GbStream gbStream);
@Update("UPDATE wvp_gb_stream " +
"SET app=#{app}," +
"stream=#{stream}," +
"gb_id=#{gbId}," +
"name=#{name}," +
"stream_type=#{streamType}," +
"longitude=#{longitude}, " +
"latitude=#{latitude}," +
"media_server_id=#{mediaServerId}" +
"WHERE app=#{app} AND stream=#{stream}")
int updateByAppAndStream(GbStream gbStream);
@Update("UPDATE wvp_gb_stream " +
"SET app=#{app}," +
"stream=#{stream}," +
"gb_id=#{gbId}," +
"name=#{name}," +
"stream_type=#{streamType}," +
"longitude=#{longitude}, " +
"latitude=#{latitude}," +
"media_server_id=#{mediaServerId}" +
"WHERE gb_stream_id=#{gbStreamId}")
int update(GbStream gbStream);
@Delete("DELETE FROM wvp_gb_stream WHERE app=#{app} AND stream=#{stream}")
int del(@Param("app") String app, @Param("stream") String stream);
@Select("<script> "+
"SELECT gs.* FROM wvp_gb_stream gs " +
"WHERE " +
"1=1 " +
" <if test='catalogId != null'> AND gs.gb_stream_id in" +
"(select pgs.gb_stream_id from wvp_platform_gb_stream pgs where pgs.platform_id = #{platformId} and pgs.catalog_id=#{catalogId})</if> " +
" <if test='catalogId == null'> AND gs.gb_stream_id not in" +
"(select pgs.gb_stream_id from wvp_platform_gb_stream pgs where pgs.platform_id = #{platformId}) </if> " +
" <if test='query != null'> AND (gs.app LIKE concat('%',#{query},'%') OR gs.stream LIKE concat('%',#{query},'%') OR gs.gb_id LIKE concat('%',#{query},'%') OR gs.name LIKE concat('%',#{query},'%'))</if> " +
" <if test='mediaServerId != null' > AND gs.media_server_id=#{mediaServerId} </if>" +
" order by gs.gb_stream_id asc " +
"</script>")
List<GbStream> selectAll(@Param("platformId") String platformId, @Param("catalogId") String catalogId, @Param("query") String query, @Param("mediaServerId") String mediaServerId);
@Select("SELECT * FROM wvp_gb_stream WHERE app=#{app} AND stream=#{stream}")
GbStream selectOne(@Param("app") String app, @Param("stream") String stream);
@Select("SELECT * FROM wvp_gb_stream WHERE gb_id=#{gbId}")
List<GbStream> selectByGBId(String gbId);
@Select("SELECT gs.*, pgs.platform_id as platform_id, pgs.catalog_id as catalog_id FROM wvp_gb_stream gs " +
"LEFT JOIN wvp_platform_gb_stream pgs ON gs.gb_stream_id = pgs.gb_stream_id " +
"WHERE gs.gb_id = #{gbId} AND pgs.platform_id = #{platformId}")
GbStream queryStreamInPlatform(@Param("platformId") String platformId, @Param("gbId") String gbId);
@Select("<script> "+
"select gt.gb_id as channel_id, gt.name, 'wvp-pro' as manufacture, st.status, gt.longitude, gt.latitude, pc.id as parent_id," +
" '1' as register_way, pc.civil_code, 'live' as model, 'wvp-pro' as owner, '0' as parental,'0' as secrecy" +
" from wvp_gb_stream gt " +
" left join (" +
" select " +
" <if test='usPushingAsStatus != true'> sp.status as status, </if>" +
" <if test='usPushingAsStatus == true'> sp.push_ing as status, </if>" +
"sp.app, sp.stream from wvp_stream_push sp" +
" union all" +
" select spxy.status, spxy.app, spxy.stream from wvp_stream_proxy spxy" +
" ) st on st.app = gt.app and st.stream = gt.stream" +
" left join wvp_platform_gb_stream pgs on gt.gb_stream_id = pgs.gb_stream_id" +
" left join wvp_platform_catalog pc on pgs.catalog_id = pc.id and pgs.platform_id = pc.platform_id" +
" where pgs.platform_id=#{platformId}" +
"</script>")
List<DeviceChannel> queryGbStreamListInPlatform(String platformId, @Param("usPushingAsStatus") boolean usPushingAsStatus);
@Select("SELECT gs.* FROM wvp_gb_stream gs left join wvp_platform_gb_stream pgs " +
"ON gs.gb_stream_id = pgs.gb_stream_id WHERE pgs.gb_stream_id is NULL")
List<GbStream> queryStreamNotInPlatform();
@Delete("DELETE FROM wvp_gb_stream WHERE stream_type=#{type} AND gb_id=NULL AND media_server_id=#{mediaServerId}")
void deleteWithoutGBId(@Param("type") String type, @Param("mediaServerId") String mediaServerId);
@Delete("<script> "+
"DELETE FROM wvp_gb_stream where " +
"<foreach collection='streamProxyItemList' item='item' separator='or'>" +
"(app=#{item.app} and stream=#{item.stream}) " +
"</foreach>" +
"</script>")
void batchDel(List<StreamProxy> streamProxyItemList);
@Delete("<script> "+
"DELETE FROM wvp_gb_stream where " +
"<foreach collection='gbStreams' item='item' separator='or'>" +
"(app=#{item.app} and stream=#{item.stream}) " +
"</foreach>" +
"</script>")
void batchDelForGbStream(List<GbStream> gbStreams);
@Insert("<script> " +
"INSERT into wvp_gb_stream " +
"(app, stream, gb_id, name, " +
"longitude, latitude, stream_type,media_server_id,create_time)" +
"values " +
"<foreach collection='subList' index='index' item='item' separator=','> " +
"(#{item.app}, #{item.stream}, #{item.gbId}, #{item.name}, " +
"#{item.longitude}, #{item.latitude}, #{item.streamType}, " +
"#{item.mediaServerId}, #{item.createTime}) "+
"</foreach> " +
"</script>")
@Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gb_stream_id")
void batchAdd(@Param("subList") List<StreamPush> subList);
@Update({"<script>" +
"<foreach collection='gpsMsgInfos' item='item' separator=';'>" +
" UPDATE" +
" wvp_gb_stream" +
" SET longitude=#{item.lng}, latitude=#{item.lat} " +
"WHERE gb_id=#{item.id}"+
"</foreach>" +
"</script>"})
int updateStreamGPS(List<GPSMsgInfo> gpsMsgInfos);
@Select("<script> "+
"SELECT * FROM wvp_gb_stream where " +
"<foreach collection='streamPushItems' item='item' separator='or'>" +
"(app=#{item.app} and stream=#{item.stream}) " +
"</foreach>" +
"</script>")
List<GbStream> selectAllForAppAndStream(List<StreamPush> streamPushItems);
@Update("UPDATE wvp_gb_stream " +
"SET media_server_id=#{mediaServerId}" +
"WHERE app=#{app} AND stream=#{stream}")
void updateMediaServer(String app, String stream, String mediaServerId);
@Update("<script> "+
" <foreach collection='list' item='item' index='index' separator=';'>"+
"UPDATE wvp_gb_stream " +
" SET name=#{item.name},"+
" gb_id=#{item.gbId}"+
" WHERE app=#{item.app} and stream=#{item.stream}"+
"</foreach>"+
"</script>")
int updateGbIdOrName(List<StreamPush> streamPushItemForUpdate);
@Select("SELECT status FROM wvp_stream_proxy WHERE app=#{app} AND stream=#{stream}")
Boolean selectStatusForProxy(@Param("app") String app, @Param("stream") String stream);
@Select("SELECT status FROM wvp_stream_push WHERE app=#{app} AND stream=#{stream}")
Boolean selectStatusForPush(@Param("app") String app, @Param("stream") String stream);
@MapKey("gbId")
@Select("SELECT * from wvp_gb_stream")
Map<String, GbStream> getAllGBId();
}

View File

@ -253,8 +253,8 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
}
@Override
public GPSMsgInfo getGpsMsgInfo(String gbId) {
String key = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetting.getServerId() + "_" + gbId;
public GPSMsgInfo getGpsMsgInfo(Integer channelId) {
String key = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetting.getServerId() + "_" + channelId;
return JsonUtil.redisJsonToObject(redisTemplate, key, GPSMsgInfo.class);
}

View File

@ -24,8 +24,6 @@ public interface StreamProxyMapper {
"SET type=#{type}, " +
"app=#{app}," +
"stream=#{stream}," +
"app=#{app}," +
"stream=#{stream}," +
"media_server_id=#{mediaServerId}, " +
"src_url=#{srcUrl}," +
"timeout=#{timeout}, " +

View File

@ -0,0 +1,24 @@
package com.genersoft.iot.vmp.streamPush.bean;
import lombok.Data;
@Data
public class RedisPushStreamMessage {
private String gbId;
private String app;
private String stream;
private String name;
private boolean status;
public StreamPush buildstreamPush() {
StreamPush push = new StreamPush();
push.setApp(app);
push.setStream(stream);
push.setGbName(name);
push.setGbDeviceId(gbId);
push.setStartOfflinePush(true);
push.setGbStatus(status?"ON":"OFF");
return push;
}
}

View File

@ -76,6 +76,8 @@ public class StreamPush extends CommonGBChannel implements Comparable<StreamPush
@Schema(description = "拉起离线推流")
private boolean startOfflinePush;
private String uniqueKey;
@Override
public int compareTo(@NotNull StreamPush streamPushItem) {
return Long.valueOf(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(this.createTime)

View File

@ -103,15 +103,15 @@ public interface StreamPushMapper {
" </script>"})
int getAllPushing(Boolean usePushingAsStatus);
@MapKey("vhost")
@Select("SELECT CONCAT(wsp.app, wsp.stream) as vhost, wsp.*, wsp.* , wsp.id as gb_id " +
@MapKey("uniqueKey")
@Select("SELECT CONCAT(wsp.app, wsp.stream) as unique_key, wsp.*, wsp.* , wdc.id as gb_id " +
" from wvp_stream_push wsp " +
" LEFT join wvp_device_channel wdc on wsp.id = wdc.stream_push_id")
Map<String, StreamPush> getAllAppAndStreamMap();
@MapKey("gb_device_id")
@Select("SELECT wdc.gb_device_id, wsp.id as stream_push_id, wsp.*, wsp.* , wsp.id as gb_id " +
@MapKey("gbDeviceId")
@Select("SELECT wdc.gb_device_id, wsp.id as stream_push_id, wsp.*, wsp.* , wdc.id as gb_id " +
" from wvp_stream_push wsp " +
" LEFT join wvp_device_channel wdc on wsp.id = wdc.stream_push_id")
Map<String, StreamPush> getAllGBId();
@ -150,7 +150,7 @@ public interface StreamPushMapper {
", push_time=#{item.pushTime}" +
", pushing=#{item.pushing}" +
", start_offline_push=#{item.startOfflinePush}" +
" WHERE id=#{item.item.id}" +
" WHERE id=#{item.id}" +
"</foreach>" +
"</script>"})
int batchUpdate(List<StreamPush> streamPushItemForUpdate);

View File

@ -542,16 +542,14 @@ public class StreamPushServiceImpl implements IStreamPushService {
@Override
public void batchUpdate(List<StreamPush> streamPushItemForUpdate) {
int result = streamPushMapper.batchUpdate(streamPushItemForUpdate);
if (result > 0) {
List<CommonGBChannel> commonGBChannels = new ArrayList<>();
for (StreamPush streamPush : streamPushItemForUpdate) {
if (!ObjectUtils.isEmpty(streamPush.getGbDeviceId())) {
commonGBChannels.add(streamPush.buildCommonGBChannel());
}
streamPushMapper.batchUpdate(streamPushItemForUpdate);
List<CommonGBChannel> commonGBChannels = new ArrayList<>();
for (StreamPush streamPush : streamPushItemForUpdate) {
if (!ObjectUtils.isEmpty(streamPush.getGbDeviceId())) {
commonGBChannels.add(streamPush.buildCommonGBChannel());
}
gbChannelService.batchUpdate(commonGBChannels);
}
gbChannelService.batchUpdate(commonGBChannels);
}
@Override

View File

@ -2,4 +2,4 @@ spring:
application:
name: wvp
profiles:
active: 272重构
active: 272重构-postgre

View File

@ -124,9 +124,9 @@
<el-checkbox label="RTCP保活" v-model="value.rtcp" @change="rtcpCheckBoxChange"></el-checkbox>
<el-checkbox label="消息通道" v-model="value.asMessageChannel"></el-checkbox>
<el-checkbox label="主动推送通道" v-model="value.autoPushChannel"></el-checkbox>
<el-checkbox label="推送平台信息" v-model="value.catalogWithPlatform"></el-checkbox>
<el-checkbox label="推送分组信息" v-model="value.catalogWithGroup"></el-checkbox>
<el-checkbox label="推送行政区划" v-model="value.catalogWithRegion"></el-checkbox>
<el-checkbox label="推送平台信息" :true-label="1" :false-label="0" v-model="value.catalogWithPlatform"></el-checkbox>
<el-checkbox label="推送分组信息" :true-label="1" :false-label="0" v-model="value.catalogWithGroup"></el-checkbox>
<el-checkbox label="推送行政区划" :true-label="1" :false-label="0" v-model="value.catalogWithRegion"></el-checkbox>
</div>

View File

@ -158,10 +158,10 @@ create table wvp_device_channel
gb_parent_id character varying(255),
gb_safety_way integer,
gb_register_way integer,
gb_cert_num integer,
gb_cert_num character varying(50),
gb_certifiable integer,
gb_err_code integer,
gb_end_time integer,
gb_end_time character varying(50),
gb_security_level_code character varying(255),
gb_secrecy integer,
gb_ip_address character varying(50),
@ -274,9 +274,9 @@ create table wvp_platform
create_time character varying(50),
update_time character varying(50),
as_message_channel bool default false,
catalog_with_platform bool default true,
catalog_with_group bool default true,
catalog_with_region bool default true,
catalog_with_platform integer default 1,
catalog_with_group integer default 1,
catalog_with_region integer default 1,
auto_push_channel bool default true,
send_stream_ip character varying(50),
constraint uk_platform_unique_server_gb_id unique (server_gb_id)
@ -331,7 +331,7 @@ create table wvp_platform_group
id serial primary key,
platform_id integer,
group_id integer,
constraint uk_wvp_platform_group_id_catalog_platform_id_group_id unique (platform_id, group_id)
constraint uk_wvp_platform_group_platform_id_group_id unique (platform_id, group_id)
);
create table wvp_platform_region
@ -339,7 +339,7 @@ create table wvp_platform_region
id serial primary key,
platform_id integer,
region_id integer,
constraint uk_wvp_platform_group_id_catalog_platform_id_group_id unique (platform_id, region_id)
constraint uk_wvp_platform_region_platform_id_group_id unique (platform_id, region_id)
);
create table wvp_stream_proxy
@ -463,7 +463,7 @@ CREATE TABLE wvp_common_group
create_time varchar(50) NOT NULL,
update_time varchar(50) NOT NULL,
civil_code varchar(50) default null,
UNIQUE KEY common_group_device_platform (device_id)
constraint uk_common_group_device_platform unique (device_id)
);
CREATE TABLE wvp_common_region
@ -475,6 +475,6 @@ CREATE TABLE wvp_common_region
parent_device_id varchar(50) DEFAULT NULL,
create_time varchar(50) NOT NULL,
update_time varchar(50) NOT NULL,
UNIQUE KEY common_region_device_id (device_id)
constraint uk_common_region_device_id unique (device_id)
);

View File

@ -158,18 +158,18 @@ create table wvp_device_channel
gb_parent_id character varying(255),
gb_safety_way integer,
gb_register_way integer,
gb_cert_num integer,
gb_cert_num character varying(50),
gb_certifiable integer,
gb_err_code integer,
gb_end_time integer,
gb_end_time character varying(50),
gb_security_level_code character varying(255),
gb_secrecy integer,
gb_ip_address character varying(50),
gb_port integer,
gb_password character varying(50),
gb_status character varying(50),
gb_longitude double,
gb_latitude double,
gb_longitude double precision,
gb_latitude double precision,
gb_business_group_id character varying(50),
gb_ptz_type integer,
gb_position_type integer,
@ -186,9 +186,9 @@ create table wvp_device_channel
gb_svc_time_support_mode integer,
gb_ssvc_ratio_support_list character varying(255),
gb_mobile_device_type integer,
gb_horizontal_field_angle double,
gb_vertical_field_angle double,
gb_max_view_distance double,
gb_horizontal_field_angle double precision,
gb_vertical_field_angle double precision,
gb_max_view_distance double precision,
gb_grassroots_code character varying(255),
gb_po_type integer,
gb_po_common_name character varying(255),
@ -274,9 +274,9 @@ create table wvp_platform
create_time character varying(50),
update_time character varying(50),
as_message_channel bool default false,
catalog_with_platform bool default true,
catalog_with_group bool default true,
catalog_with_region bool default true,
catalog_with_platform integer default 1,
catalog_with_group integer default 1,
catalog_with_region integer default 1,
auto_push_channel bool default true,
send_stream_ip character varying(50),
constraint uk_platform_unique_server_gb_id unique (server_gb_id)
@ -331,7 +331,7 @@ create table wvp_platform_group
id serial primary key,
platform_id integer,
group_id integer,
constraint uk_wvp_platform_group_id_catalog_platform_id_group_id unique (platform_id, group_id)
constraint uk_wvp_platform_group_platform_id_group_id unique (platform_id, group_id)
);
create table wvp_platform_region
@ -339,7 +339,7 @@ create table wvp_platform_region
id serial primary key,
platform_id integer,
region_id integer,
constraint uk_wvp_platform_group_id_catalog_platform_id_group_id unique (platform_id, region_id)
constraint uk_wvp_platform_region_platform_id_group_id unique (platform_id, region_id)
);
create table wvp_stream_proxy
@ -463,7 +463,7 @@ CREATE TABLE wvp_common_group
create_time varchar(50) NOT NULL,
update_time varchar(50) NOT NULL,
civil_code varchar(50) default null,
UNIQUE KEY common_group_device_platform (device_id)
constraint uk_common_group_device_platform unique (device_id)
);
CREATE TABLE wvp_common_region
@ -475,6 +475,6 @@ CREATE TABLE wvp_common_region
parent_device_id varchar(50) DEFAULT NULL,
create_time varchar(50) NOT NULL,
update_time varchar(50) NOT NULL,
UNIQUE KEY common_region_device_id (device_id)
constraint uk_common_region_device_id unique (device_id)
);