临时提交

结构优化
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")
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;
}
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;
}

View File

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

View File

@ -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 = {" <script>" +
"UPDATE wvp_stream_push " +
"SET update_time=#{updateTime}" +
"<if test=\"name != null\">, name=#{name}</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=\"aliveSecond != null\">, alive_second=#{aliveSecond}</if>" +
"<if test=\"pushIng != null\">, push_ing=#{pushIng}</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>"})
int update(StreamPush streamPushItem);
@Delete("DELETE FROM wvp_stream_push WHERE app=#{app} AND stream=#{stream}")
int del(String app, String stream);
@Delete("<script> "+
@Delete("<script> " +
"DELETE sp FROM wvp_stream_push sp where " +
"<foreach collection='streamPushItems' item='item' separator='or'>" +
"(sp.app=#{item.app} and sp.stream=#{item.stream} and sp.gb_id is null) " +
@ -45,30 +48,27 @@ public interface StreamPushMapper {
"</script>")
int delAllWithoutGBId(List<StreamPush> streamPushItems);
@Delete("<script> "+
@Delete("<script> " +
"DELETE FROM wvp_stream_push where " +
"<foreach collection='streamPushItems' item='item' separator='or'>" +
"(app=#{item.app} and stream=#{item.stream}) " +
"(id=#{item.id}) " +
"</foreach>" +
"</script>")
int delAll(List<StreamPush> streamPushItems);
@Delete("<script> "+
@Delete("<script> " +
"DELETE FROM wvp_stream_push where " +
"<foreach collection='streamPushList' item='item' separator='or'>" +
"(app=#{item.app} and stream=#{item.stream}) " +
"</foreach>" +
"</script>")
int delAllForStream(List<StreamPush> streamPushList);
int delAllByAppAndStream(List<StreamPush> streamPushList);
@Select(value = {" <script>" +
"SELECT " +
"* " +
"from " +
"SELECT * from " +
"wvp_stream_push " +
"WHERE " +
"1=1 " +
"WHERE 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='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>" +
@ -77,19 +77,18 @@ public interface StreamPushMapper {
" </script>"})
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();
@Select("SELECT * from wvp_stream_push WHERE app=#{app} AND stream=#{stream}")
StreamPush selectOne(@Param("app") String app, @Param("stream") String stream);
@Insert("<script>" +
"Insert INTO wvp_stream_push (app, stream, total_reader_count, " +
"create_time, alive_second, media_server_id, status, push_ing) " +
"Insert INTO wvp_stream_push (name, app, stream, common_gb_channel_id, gb_id, longitude, " +
"latitude, create_time, media_server_id, status, push_ing) " +
"VALUES <foreach collection='streamPushItems' item='item' index='index' separator=','>" +
"( #{item.app}, #{item.stream}, #{item.totalReaderCount}, " +
"#{item.createTime}, #{item.aliveSecond}, #{item.mediaServerId}, #{item.status} ," +
" #{item.pushIng} )" +
"(#{item.name}, #{item.app}, #{item.stream}, #{item.commonGbChannelId}, #{item.gbId},#{item.longitude}, " +
"#{item.latitude}, #{item.createTime}, #{item.mediaServerId}, #{item.status}, #{item.pushIng} )" +
" </foreach>" +
"</script>")
@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"
@Delete("delete from wvp_stream_push " +
"where media_server_id = #{mediaServerId} and common_gb_channel_id = 0"
)
void deleteWithoutGBId(String mediaServerId);
void deleteWithoutGBId(@Param("mediaServerId") String 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")
List<StreamPush> selectAllByMediaServerIdWithOutGbID(String mediaServerId);
List<StreamPush> 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("<script> "+
@Update("<script> " +
"UPDATE wvp_stream_push SET status=0 where id in (" +
"<foreach collection='offlineStreams' item='item' separator=','>" +
"#{item.id} " +
@ -134,15 +131,15 @@ public interface StreamPushMapper {
")</script>")
void offline(List<StreamPush> offlineStreams);
@Update("<script> "+
"UPDATE wvp_stream_push SET status=1 where (app, stream) in (" +
@Update("<script> " +
"UPDATE wvp_stream_push SET status=1 where id in (" +
"<foreach collection='onlineStreams' item='item' separator=','>" +
"(#{item.app}, #{item.stream}) " +
"#{item.id} " +
"</foreach>" +
")</script>")
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();
@Update("UPDATE wvp_stream_push SET status=0")
@ -157,9 +154,9 @@ public interface StreamPushMapper {
@Select(value = {" <script>" +
" <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>"})
int getAllOnline(Boolean usePushingAsStatus);
int getAllOnline(@Param("pushIngAsOnline") Boolean pushIngAsOnline);
@Select("<script> " +
"select * from wvp_stream_push where (app, stream) in " +
@ -169,8 +166,8 @@ public interface StreamPushMapper {
"</script>")
List<StreamPush> getListIn(@Param("streamPushItems") List<StreamPushItemFromRedis> 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({"<script>" +
"<foreach collection='gpsMsgInfoList' item='item' separator=';'>" +

View File

@ -143,6 +143,12 @@ alter table wvp_stream_proxy
alter table wvp_device
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,
app 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),
alive_second integer,
media_server_id character varying(50),
push_time character varying(50),
status bool default false,
update_time character varying(50),
push_ing 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)
);
create table wvp_cloud_record (

View File

@ -225,9 +225,7 @@ create table wvp_stream_push (
name character varying(255) default NULL,
app character varying(255),
stream character varying(255),
total_reader_count character varying(50),
create_time character varying(50),
alive_second integer,
media_server_id character varying(50),
push_time character varying(50),
status bool default false,
@ -235,6 +233,9 @@ create table wvp_stream_push (
push_ing bool default false,
self bool default false,
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)
);
create table wvp_cloud_record (