临时提交

结构优化
648540858 2024-01-05 16:58:31 +08:00
parent 6bfc75286b
commit 7fd03a50a0
6 changed files with 55 additions and 84 deletions

View File

@ -30,19 +30,6 @@ public class StreamPush implements Comparable<StreamPush>{
@Schema(description = "流id") @Schema(description = "流id")
private String stream; 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<StreamPush>{
this.stream = stream; 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() { public String getVhost() {
return vhost; return vhost;
} }

View File

@ -101,10 +101,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
streamPushItem.setApp(item.getApp()); streamPushItem.setApp(item.getApp());
streamPushItem.setMediaServerId(item.getMediaServerId()); streamPushItem.setMediaServerId(item.getMediaServerId());
streamPushItem.setStream(item.getStream()); streamPushItem.setStream(item.getStream());
streamPushItem.setAliveSecond(item.getAliveSecond());
streamPushItem.setTotalReaderCount(item.getTotalReaderCount());
streamPushItem.setCreateTime(DateUtil.getNow()); streamPushItem.setCreateTime(DateUtil.getNow());
streamPushItem.setAliveSecond(item.getAliveSecond());
streamPushItem.setVhost(item.getVhost()); streamPushItem.setVhost(item.getVhost());
streamPushItem.setServerId(item.getSeverId()); streamPushItem.setServerId(item.getSeverId());
return streamPushItem; return streamPushItem;
@ -369,7 +366,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
if (streamPushList == null || streamPushList.size() == 0) { if (streamPushList == null || streamPushList.size() == 0) {
return false; return false;
} }
int delStream = streamPushMapper.delAllForStream(streamPushList); int delStream = streamPushMapper.delAllByAppAndStream(streamPushList);
if (delStream > 0) { if (delStream > 0) {
for (StreamPush streamPush : streamPushList) { for (StreamPush streamPush : streamPushList) {
MediaServerItem mediaServerItem = mediaServerService.getOne(streamPush.getMediaServerId()); MediaServerItem mediaServerItem = mediaServerService.getOne(streamPush.getMediaServerId());
@ -448,7 +445,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
@Transactional @Transactional
public void update(StreamPush streamPush) { public void update(StreamPush streamPush) {
assert streamPush.getId() > 0; assert streamPush.getId() > 0;
StreamPush streamPushIDb = streamPushMapper.query(streamPush.getId()); StreamPush streamPushIDb = streamPushMapper.getOne(streamPush.getId());
assert streamPushIDb != null; assert streamPushIDb != null;
if (streamPushIDb.getCommonGbChannelId() > 0 && streamPush.getCommonGbChannelId() == 0) { if (streamPushIDb.getCommonGbChannelId() > 0 && streamPush.getCommonGbChannelId() == 0) {
commonGbChannelService.deleteById(streamPushIDb.getCommonGbChannelId()); commonGbChannelService.deleteById(streamPushIDb.getCommonGbChannelId());

View File

@ -13,31 +13,34 @@ import java.util.Map;
@Repository @Repository
public interface StreamPushMapper { public interface StreamPushMapper {
@Insert("INSERT INTO wvp_stream_push (app, stream, total_reader_count, " + @Insert("INSERT INTO wvp_stream_push (name, app, stream, common_gb_channel_id, gb_id, longitude, latitude, " +
"push_time, alive_second, media_server_id, update_time, create_time, push_ing, self) VALUES" + "push_time, media_server_id, update_time, create_time, push_ing, self, status) VALUES" +
"(#{app}, #{stream}, #{totalReaderCount}, " + "(#{name}, #{app}, #{stream}, #{commonGbChannelId}, #{gbId},#{longitude},#{latitude}, " +
"#{pushTime}, #{aliveSecond}, #{mediaServerId} , #{updateTime} , #{createTime}, " + "#{pushTime}, #{mediaServerId} , #{updateTime} , #{createTime}, #{pushIng}, #{self}, #{status} )")
"#{pushIng}, #{self} )")
int add(StreamPush streamPushItem); int add(StreamPush streamPushItem);
@Update(value = {" <script>" + @Update(value = {" <script>" +
"UPDATE wvp_stream_push " + "UPDATE wvp_stream_push " +
"SET update_time=#{updateTime}" + "SET update_time=#{updateTime}" +
"<if test=\"name != null\">, name=#{name}</if>" +
"<if test=\"mediaServerId != null\">, media_server_id=#{mediaServerId}</if>" + "<if test=\"mediaServerId != null\">, media_server_id=#{mediaServerId}</if>" +
"<if test=\"totalReaderCount != null\">, total_reader_count=#{totalReaderCount}</if>" + "<if test=\"commonGbChannelId != null\">, common_gb_channel_id=#{commonGbChannelId}</if>" +
"<if test=\"gbId != null\">, gb_id=#{gbId}</if>" +
"<if test=\"longitude != null\">, longitude=#{longitude}</if>" +
"<if test=\"latitude != null\">, latitude=#{latitude}</if>" +
"<if test=\"pushTime != null\">, push_time=#{pushTime}</if>" + "<if test=\"pushTime != null\">, push_time=#{pushTime}</if>" +
"<if test=\"aliveSecond != null\">, alive_second=#{aliveSecond}</if>" +
"<if test=\"pushIng != null\">, push_ing=#{pushIng}</if>" + "<if test=\"pushIng != null\">, push_ing=#{pushIng}</if>" +
"<if test=\"self != null\">, self=#{self}</if>" + "<if test=\"self != null\">, self=#{self}</if>" +
"WHERE app=#{app} AND stream=#{stream}"+ "<if test=\"status != null\">, status=#{status}</if>" +
"WHERE id=#{id}" +
" </script>"}) " </script>"})
int update(StreamPush streamPushItem); int update(StreamPush streamPushItem);
@Delete("DELETE FROM wvp_stream_push WHERE app=#{app} AND stream=#{stream}") @Delete("DELETE FROM wvp_stream_push WHERE app=#{app} AND stream=#{stream}")
int del(String app, String stream); int del(String app, String stream);
@Delete("<script> "+ @Delete("<script> " +
"DELETE sp FROM wvp_stream_push sp where " + "DELETE sp FROM wvp_stream_push sp where " +
"<foreach collection='streamPushItems' item='item' separator='or'>" + "<foreach collection='streamPushItems' item='item' separator='or'>" +
"(sp.app=#{item.app} and sp.stream=#{item.stream} and sp.gb_id is null) " + "(sp.app=#{item.app} and sp.stream=#{item.stream} and sp.gb_id is null) " +
@ -45,30 +48,27 @@ public interface StreamPushMapper {
"</script>") "</script>")
int delAllWithoutGBId(List<StreamPush> streamPushItems); int delAllWithoutGBId(List<StreamPush> streamPushItems);
@Delete("<script> "+ @Delete("<script> " +
"DELETE FROM wvp_stream_push where " + "DELETE FROM wvp_stream_push where " +
"<foreach collection='streamPushItems' item='item' separator='or'>" + "<foreach collection='streamPushItems' item='item' separator='or'>" +
"(app=#{item.app} and stream=#{item.stream}) " + "(id=#{item.id}) " +
"</foreach>" + "</foreach>" +
"</script>") "</script>")
int delAll(List<StreamPush> streamPushItems); int delAll(List<StreamPush> streamPushItems);
@Delete("<script> "+ @Delete("<script> " +
"DELETE FROM wvp_stream_push where " + "DELETE FROM wvp_stream_push where " +
"<foreach collection='streamPushList' item='item' separator='or'>" + "<foreach collection='streamPushList' item='item' separator='or'>" +
"(app=#{item.app} and stream=#{item.stream}) " + "(app=#{item.app} and stream=#{item.stream}) " +
"</foreach>" + "</foreach>" +
"</script>") "</script>")
int delAllForStream(List<StreamPush> streamPushList); int delAllByAppAndStream(List<StreamPush> streamPushList);
@Select(value = {" <script>" + @Select(value = {" <script>" +
"SELECT " + "SELECT * from " +
"* " +
"from " +
"wvp_stream_push " + "wvp_stream_push " +
"WHERE " + "WHERE 1=1 " +
"1=1 " +
" <if test='query != null'> AND (app LIKE concat('%',#{query},'%') OR stream LIKE concat('%',#{query},'%') OR gb_id LIKE concat('%',#{query},'%') OR name LIKE concat('%',#{query},'%'))</if> " + " <if test='query != null'> AND (app LIKE concat('%',#{query},'%') OR stream LIKE concat('%',#{query},'%') OR gb_id LIKE concat('%',#{query},'%') OR name LIKE concat('%',#{query},'%'))</if> " +
" <if test='pushing == true' > AND (gb_id is null OR push_ing=1)</if>" + " <if test='pushing == true' > AND (gb_id is null OR push_ing=1)</if>" +
" <if test='pushing == false' > AND (push_ing is null OR push_ing=0) </if>" + " <if test='pushing == false' > AND (push_ing is null OR push_ing=0) </if>" +
@ -77,19 +77,18 @@ public interface StreamPushMapper {
" </script>"}) " </script>"})
List<StreamPush> selectAllForList(@Param("query") String query, @Param("pushing") Boolean pushing, @Param("mediaServerId") String mediaServerId); List<StreamPush> 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<StreamPush> selectAll(); List<StreamPush> selectAll();
@Select("SELECT * from wvp_stream_push WHERE app=#{app} AND stream=#{stream}") @Select("SELECT * from wvp_stream_push WHERE app=#{app} AND stream=#{stream}")
StreamPush selectOne(@Param("app") String app, @Param("stream") String stream); StreamPush selectOne(@Param("app") String app, @Param("stream") String stream);
@Insert("<script>" + @Insert("<script>" +
"Insert INTO wvp_stream_push (app, stream, total_reader_count, " + "Insert INTO wvp_stream_push (name, app, stream, common_gb_channel_id, gb_id, longitude, " +
"create_time, alive_second, media_server_id, status, push_ing) " + "latitude, create_time, media_server_id, status, push_ing) " +
"VALUES <foreach collection='streamPushItems' item='item' index='index' separator=','>" + "VALUES <foreach collection='streamPushItems' item='item' index='index' separator=','>" +
"( #{item.app}, #{item.stream}, #{item.totalReaderCount}, " + "(#{item.name}, #{item.app}, #{item.stream}, #{item.commonGbChannelId}, #{item.gbId},#{item.longitude}, " +
"#{item.createTime}, #{item.aliveSecond}, #{item.mediaServerId}, #{item.status} ," + "#{item.latitude}, #{item.createTime}, #{item.mediaServerId}, #{item.status}, #{item.pushIng} )" +
" #{item.pushIng} )" +
" </foreach>" + " </foreach>" +
"</script>") "</script>")
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
@ -98,35 +97,33 @@ public interface StreamPushMapper {
@Delete("DELETE FROM wvp_stream_push") @Delete("DELETE FROM wvp_stream_push")
void clear(); void clear();
@Delete( @Delete("delete from wvp_stream_push " +
"delete" + "where media_server_id = #{mediaServerId} and common_gb_channel_id = 0"
" from wvp_stream_push " + )
" where media_server_id = #{mediaServerId} and common_gb_channel_id = 0" void deleteWithoutGBId(@Param("mediaServerId") String mediaServerId);
)
void deleteWithoutGBId(String mediaServerId);
@Select("SELECT * FROM wvp_stream_push WHERE media_server_id=#{mediaServerId}") @Select("SELECT * FROM wvp_stream_push WHERE media_server_id=#{mediaServerId}")
List<StreamPush> selectAllByMediaServerId(String mediaServerId); List<StreamPush> selectAllByMediaServerId(@Param("mediaServerId") String mediaServerId);
@Select("SELECT * FROM wvp_stream_push WHERE media_server_id=#{mediaServerId} and gb_id is null") @Select("SELECT * FROM wvp_stream_push WHERE media_server_id=#{mediaServerId} and gb_id is null")
List<StreamPush> selectAllByMediaServerIdWithOutGbID(String mediaServerId); List<StreamPush> selectAllByMediaServerIdWithOutGbID(@Param("mediaServerId") String mediaServerId);
@Update("UPDATE wvp_stream_push " + @Update("UPDATE wvp_stream_push " +
"SET status=#{status} " + "SET status=#{status} " +
"WHERE app=#{app} AND stream=#{stream}") "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 " + @Update("UPDATE wvp_stream_push " +
"SET push_ing=#{pushIng} " + "SET push_ing=#{pushIng} " +
"WHERE app=#{app} AND stream=#{stream}") "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 " + @Update("UPDATE wvp_stream_push " +
"SET status=#{status} " + "SET status=#{status} " +
"WHERE media_server_id=#{mediaServerId}") "WHERE media_server_id=#{mediaServerId}")
void updateStatusByMediaServerId(@Param("mediaServerId") String mediaServerId, @Param("status") boolean status); void updateStatusByMediaServerId(@Param("mediaServerId") String mediaServerId, @Param("status") boolean status);
@Update("<script> "+ @Update("<script> " +
"UPDATE wvp_stream_push SET status=0 where id in (" + "UPDATE wvp_stream_push SET status=0 where id in (" +
"<foreach collection='offlineStreams' item='item' separator=','>" + "<foreach collection='offlineStreams' item='item' separator=','>" +
"#{item.id} " + "#{item.id} " +
@ -134,15 +131,15 @@ public interface StreamPushMapper {
")</script>") ")</script>")
void offline(List<StreamPush> offlineStreams); void offline(List<StreamPush> offlineStreams);
@Update("<script> "+ @Update("<script> " +
"UPDATE wvp_stream_push SET status=1 where (app, stream) in (" + "UPDATE wvp_stream_push SET status=1 where id in (" +
"<foreach collection='onlineStreams' item='item' separator=','>" + "<foreach collection='onlineStreams' item='item' separator=','>" +
"(#{item.app}, #{item.stream}) " + "#{item.id} " +
"</foreach>" + "</foreach>" +
")</script>") ")</script>")
void online(List<StreamPushItemFromRedis> onlineStreams); void online(List<StreamPushItemFromRedis> 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<Integer> getOnlinePusherForGb(); List<Integer> getOnlinePusherForGb();
@Update("UPDATE wvp_stream_push SET status=0") @Update("UPDATE wvp_stream_push SET status=0")
@ -157,9 +154,9 @@ public interface StreamPushMapper {
@Select(value = {" <script>" + @Select(value = {" <script>" +
" <if test='pushIngAsOnline == true'> select count(1) from wvp_stream_push where push_ing = true </if>" + " <if test='pushIngAsOnline == true'> select count(1) from wvp_stream_push where push_ing = true </if>" +
" <if test='pushIngAsOnline == false'> select count(1)from wvp_stream_push where status = true </if>" + " <if test='pushIngAsOnline == false'> select count(1) from wvp_stream_push where status = true </if>" +
" </script>"}) " </script>"})
int getAllOnline(Boolean usePushingAsStatus); int getAllOnline(@Param("pushIngAsOnline") Boolean pushIngAsOnline);
@Select("<script> " + @Select("<script> " +
"select * from wvp_stream_push where (app, stream) in " + "select * from wvp_stream_push where (app, stream) in " +
@ -169,8 +166,8 @@ public interface StreamPushMapper {
"</script>") "</script>")
List<StreamPush> getListIn(@Param("streamPushItems") List<StreamPushItemFromRedis> streamPushItems); List<StreamPush> getListIn(@Param("streamPushItems") List<StreamPushItemFromRedis> streamPushItems);
@Select("select* from wvp_stream_push where id = #{id}") @Select("select * from wvp_stream_push where id = #{id}")
StreamPush query(@Param("id") Integer id); StreamPush getOne(@Param("id") Integer id);
@Update({"<script>" + @Update({"<script>" +
"<foreach collection='gpsMsgInfoList' item='item' separator=';'>" + "<foreach collection='gpsMsgInfoList' item='item' separator=';'>" +

View File

@ -143,6 +143,12 @@ alter table wvp_stream_proxy
alter table wvp_device alter table wvp_device
drop column auto_sync_channel; drop column auto_sync_channel;
alter table wvp_stream_push
drop column total_reader_count;
alter table wvp_stream_push
drop column alive_second;

View File

@ -255,17 +255,16 @@ create table wvp_stream_push (
id serial primary key, id serial primary key,
app character varying(255), app character varying(255),
stream character varying(255), stream character varying(255),
total_reader_count character varying(50),
origin_type integer,
origin_type_str character varying(50),
create_time character varying(50), create_time character varying(50),
alive_second integer,
media_server_id character varying(50), media_server_id character varying(50),
push_time character varying(50), push_time character varying(50),
status bool default false, status bool default false,
update_time character varying(50), update_time character varying(50),
push_ing bool default false, push_ing bool default false,
self bool default false, self bool default false,
gb_id varchar(50) default NULL
longitude double precision,
latitude double precision,
constraint uk_stream_push_app_stream unique (app, stream) constraint uk_stream_push_app_stream unique (app, stream)
); );
create table wvp_cloud_record ( create table wvp_cloud_record (

View File

@ -225,9 +225,7 @@ create table wvp_stream_push (
name character varying(255) default NULL, name character varying(255) default NULL,
app character varying(255), app character varying(255),
stream character varying(255), stream character varying(255),
total_reader_count character varying(50),
create_time character varying(50), create_time character varying(50),
alive_second integer,
media_server_id character varying(50), media_server_id character varying(50),
push_time character varying(50), push_time character varying(50),
status bool default false, status bool default false,
@ -235,6 +233,9 @@ create table wvp_stream_push (
push_ing bool default false, push_ing bool default false,
self bool default false, self bool default false,
common_gb_channel_id integer, common_gb_channel_id integer,
gb_id character varying(50) default NULL
longitude double precision,
latitude double precision,
constraint uk_stream_push_app_stream unique (app, stream) constraint uk_stream_push_app_stream unique (app, stream)
); );
create table wvp_cloud_record ( create table wvp_cloud_record (