From 7fd03a50a0adb6281045ad5ef86c786c4e714fab Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Fri, 5 Jan 2024 16:58:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/media/zlm/dto/StreamPush.java | 29 ------- .../service/impl/StreamPushServiceImpl.java | 7 +- .../vmp/storager/dao/StreamPushMapper.java | 85 +++++++++---------- 数据库/结构优化/common.sql | 6 ++ 数据库/结构优化/初始化-mysql.sql | 7 +- .../结构优化/初始化-postgresql-kingbase.sql | 5 +- 6 files changed, 55 insertions(+), 84 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamPush.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamPush.java index ad96d5a3..ddd80909 100755 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamPush.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamPush.java @@ -30,19 +30,6 @@ public class StreamPush implements Comparable{ @Schema(description = "流id") private String stream; - /** - * 观看总人数,包括hls/rtsp/rtmp/http-flv/ws-flv - */ - @Schema(description = "观看总人数") - private String totalReaderCount; - - - /** - * 存活时间,单位秒 - */ - @Schema(description = "存活时间,单位秒") - private Long aliveSecond; - /** * 音视频轨道 */ @@ -164,22 +151,6 @@ public class StreamPush implements Comparable{ this.stream = stream; } - public String getTotalReaderCount() { - return totalReaderCount; - } - - public void setTotalReaderCount(String totalReaderCount) { - this.totalReaderCount = totalReaderCount; - } - - public Long getAliveSecond() { - return aliveSecond; - } - - public void setAliveSecond(Long aliveSecond) { - this.aliveSecond = aliveSecond; - } - public String getVhost() { return vhost; } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java index eb65c579..900f8fa5 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java @@ -101,10 +101,7 @@ public class StreamPushServiceImpl implements IStreamPushService { streamPushItem.setApp(item.getApp()); streamPushItem.setMediaServerId(item.getMediaServerId()); streamPushItem.setStream(item.getStream()); - streamPushItem.setAliveSecond(item.getAliveSecond()); - streamPushItem.setTotalReaderCount(item.getTotalReaderCount()); streamPushItem.setCreateTime(DateUtil.getNow()); - streamPushItem.setAliveSecond(item.getAliveSecond()); streamPushItem.setVhost(item.getVhost()); streamPushItem.setServerId(item.getSeverId()); return streamPushItem; @@ -369,7 +366,7 @@ public class StreamPushServiceImpl implements IStreamPushService { if (streamPushList == null || streamPushList.size() == 0) { return false; } - int delStream = streamPushMapper.delAllForStream(streamPushList); + int delStream = streamPushMapper.delAllByAppAndStream(streamPushList); if (delStream > 0) { for (StreamPush streamPush : streamPushList) { MediaServerItem mediaServerItem = mediaServerService.getOne(streamPush.getMediaServerId()); @@ -448,7 +445,7 @@ public class StreamPushServiceImpl implements IStreamPushService { @Transactional public void update(StreamPush streamPush) { assert streamPush.getId() > 0; - StreamPush streamPushIDb = streamPushMapper.query(streamPush.getId()); + StreamPush streamPushIDb = streamPushMapper.getOne(streamPush.getId()); assert streamPushIDb != null; if (streamPushIDb.getCommonGbChannelId() > 0 && streamPush.getCommonGbChannelId() == 0) { commonGbChannelService.deleteById(streamPushIDb.getCommonGbChannelId()); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java index 411f8171..1ecd108e 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java @@ -13,31 +13,34 @@ import java.util.Map; @Repository public interface StreamPushMapper { - @Insert("INSERT INTO wvp_stream_push (app, stream, total_reader_count, " + - "push_time, alive_second, media_server_id, update_time, create_time, push_ing, self) VALUES" + - "(#{app}, #{stream}, #{totalReaderCount}, " + - "#{pushTime}, #{aliveSecond}, #{mediaServerId} , #{updateTime} , #{createTime}, " + - "#{pushIng}, #{self} )") + @Insert("INSERT INTO wvp_stream_push (name, app, stream, common_gb_channel_id, gb_id, longitude, latitude, " + + "push_time, media_server_id, update_time, create_time, push_ing, self, status) VALUES" + + "(#{name}, #{app}, #{stream}, #{commonGbChannelId}, #{gbId},#{longitude},#{latitude}, " + + "#{pushTime}, #{mediaServerId} , #{updateTime} , #{createTime}, #{pushIng}, #{self}, #{status} )") int add(StreamPush streamPushItem); @Update(value = {" "}) int update(StreamPush streamPushItem); @Delete("DELETE FROM wvp_stream_push WHERE app=#{app} AND stream=#{stream}") int del(String app, String stream); - @Delete("") int delAllWithoutGBId(List streamPushItems); - @Delete("") int delAll(List streamPushItems); - @Delete("") - int delAllForStream(List streamPushList); + int delAllByAppAndStream(List streamPushList); @Select(value = {" "}) List selectAllForList(@Param("query") String query, @Param("pushing") Boolean pushing, @Param("mediaServerId") String mediaServerId); - @Select("SELECT * from wvp_stream_push order by create_time desc") + @Select("SELECT * from wvp_stream_push order by push_time desc") List selectAll(); @Select("SELECT * from wvp_stream_push WHERE app=#{app} AND stream=#{stream}") StreamPush selectOne(@Param("app") String app, @Param("stream") String stream); - @Insert("") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") @@ -98,35 +97,33 @@ public interface StreamPushMapper { @Delete("DELETE FROM wvp_stream_push") void clear(); - @Delete( - "delete" + - " from wvp_stream_push " + - " where media_server_id = #{mediaServerId} and common_gb_channel_id = 0" - ) - void deleteWithoutGBId(String mediaServerId); + @Delete("delete from wvp_stream_push " + + "where media_server_id = #{mediaServerId} and common_gb_channel_id = 0" + ) + void deleteWithoutGBId(@Param("mediaServerId") String mediaServerId); @Select("SELECT * FROM wvp_stream_push WHERE media_server_id=#{mediaServerId}") - List selectAllByMediaServerId(String mediaServerId); + List selectAllByMediaServerId(@Param("mediaServerId") String mediaServerId); @Select("SELECT * FROM wvp_stream_push WHERE media_server_id=#{mediaServerId} and gb_id is null") - List selectAllByMediaServerIdWithOutGbID(String mediaServerId); + List selectAllByMediaServerIdWithOutGbID(@Param("mediaServerId") String mediaServerId); @Update("UPDATE wvp_stream_push " + "SET status=#{status} " + "WHERE app=#{app} AND stream=#{stream}") - int updateStatus(@Param("app") String app, @Param("stream") String stream, @Param("status") boolean status); + int updateStatusByAppAndStream(@Param("app") String app, @Param("stream") String stream, @Param("status") boolean status); @Update("UPDATE wvp_stream_push " + "SET push_ing=#{pushIng} " + "WHERE app=#{app} AND stream=#{stream}") - int updatePushStatus(@Param("app") String app, @Param("stream") String stream, @Param("pushIng") boolean pushIng); + int updatePushStatusByAppAndStream(@Param("app") String app, @Param("stream") String stream, @Param("pushIng") boolean pushIng); @Update("UPDATE wvp_stream_push " + "SET status=#{status} " + "WHERE media_server_id=#{mediaServerId}") void updateStatusByMediaServerId(@Param("mediaServerId") String mediaServerId, @Param("status") boolean status); - @Update("") void offline(List offlineStreams); - @Update("") void online(List onlineStreams); - @Select("SELECT common_gb_channel_id FROM wvp_stream_push gb_id > 0") + @Select("SELECT common_gb_channel_id FROM wvp_stream_push where status> 0") List getOnlinePusherForGb(); @Update("UPDATE wvp_stream_push SET status=0") @@ -157,9 +154,9 @@ public interface StreamPushMapper { @Select(value = {" "}) - int getAllOnline(Boolean usePushingAsStatus); + int getAllOnline(@Param("pushIngAsOnline") Boolean pushIngAsOnline); @Select("") List getListIn(@Param("streamPushItems") List streamPushItems); - @Select("select* from wvp_stream_push where id = #{id}") - StreamPush query(@Param("id") Integer id); + @Select("select * from wvp_stream_push where id = #{id}") + StreamPush getOne(@Param("id") Integer id); @Update({"