适配推流列表信息
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
package com.genersoft.iot.vmp.streamPush.bean;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
public class BatchRemoveParam {
|
||||
private Set<Integer> ids;
|
||||
}
|
||||
@@ -83,13 +83,13 @@ public class StreamPush extends CommonGBChannel implements Comparable<StreamPush
|
||||
}
|
||||
|
||||
public StreamPush getInstance(StreamInfo streamInfo) {
|
||||
StreamPush streamPushItem = new StreamPush();
|
||||
streamPushItem.setApp(streamInfo.getApp());
|
||||
streamPushItem.setMediaServerId(streamInfo.getMediaServerId());
|
||||
streamPushItem.setStream(streamInfo.getStream());
|
||||
streamPushItem.setCreateTime(DateUtil.getNow());
|
||||
streamPushItem.setServerId(streamInfo.getMediaServerId());
|
||||
return streamPushItem;
|
||||
StreamPush streamPush = new StreamPush();
|
||||
streamPush.setApp(streamInfo.getApp());
|
||||
streamPush.setMediaServerId(streamInfo.getMediaServerId());
|
||||
streamPush.setStream(streamInfo.getStream());
|
||||
streamPush.setCreateTime(DateUtil.getNow());
|
||||
streamPush.setServerId(streamInfo.getMediaServerId());
|
||||
return streamPush;
|
||||
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public class StreamPush extends CommonGBChannel implements Comparable<StreamPush
|
||||
return streamPushItem;
|
||||
}
|
||||
|
||||
public CommonGBChannel getCommonGBChannel() {
|
||||
public CommonGBChannel buildCommonGBChannel() {
|
||||
if (ObjectUtils.isEmpty(this.getGbDeviceId())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
|
||||
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.service.IMediaService;
|
||||
import com.genersoft.iot.vmp.streamPush.bean.BatchRemoveParam;
|
||||
import com.genersoft.iot.vmp.streamPush.bean.StreamPush;
|
||||
import com.genersoft.iot.vmp.streamPush.bean.StreamPushExcelDto;
|
||||
import com.genersoft.iot.vmp.streamPush.enent.StreamPushUploadFileHandler;
|
||||
@@ -88,13 +89,12 @@ public class StreamPushController {
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/stop")
|
||||
@PostMapping(value = "/remove")
|
||||
@ResponseBody
|
||||
@Operation(summary = "中止一个推流", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "app", description = "应用名", required = true)
|
||||
@Parameter(name = "stream", description = "流id", required = true)
|
||||
public void stop(String app, String stream){
|
||||
if (!streamPushService.stopByAppAndStream(app, stream)){
|
||||
@Operation(summary = "删除", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "id", description = "应用名", required = true)
|
||||
public void delete(int id){
|
||||
if (streamPushService.delete(id) > 0){
|
||||
throw new ControllerException(ErrorCode.ERROR100);
|
||||
}
|
||||
}
|
||||
@@ -232,7 +232,7 @@ public class StreamPushController {
|
||||
@PostMapping(value = "/add")
|
||||
@ResponseBody
|
||||
@Operation(summary = "添加推流信息", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
public void add(@RequestBody StreamPush stream){
|
||||
public StreamPush add(@RequestBody StreamPush stream){
|
||||
if (ObjectUtils.isEmpty(stream.getGbId())) {
|
||||
throw new ControllerException(ErrorCode.ERROR400.getCode(), "国标ID不可为空");
|
||||
}
|
||||
@@ -244,5 +244,29 @@ public class StreamPushController {
|
||||
if (!streamPushService.add(stream)) {
|
||||
throw new ControllerException(ErrorCode.ERROR100);
|
||||
}
|
||||
stream.setStreamPushId(stream.getId());
|
||||
return stream;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/update")
|
||||
@ResponseBody
|
||||
@Operation(summary = "更新推流信息", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
public void update(@RequestBody StreamPush stream){
|
||||
if (ObjectUtils.isEmpty(stream.getId())) {
|
||||
throw new ControllerException(ErrorCode.ERROR400.getCode(), "ID不可为空");
|
||||
}
|
||||
if (!streamPushService.update(stream)) {
|
||||
throw new ControllerException(ErrorCode.ERROR100);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "/batchRemove")
|
||||
@ResponseBody
|
||||
@Operation(summary = "删除多个推流", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
public void batchStop(@RequestBody BatchRemoveParam ids){
|
||||
if(ids.getIds().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
streamPushService.batchRemove(ids.getIds());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.genersoft.iot.vmp.streamPush.dao;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
|
||||
import com.genersoft.iot.vmp.streamPush.bean.StreamPush;
|
||||
import com.genersoft.iot.vmp.service.bean.StreamPushItemFromRedis;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
@@ -8,207 +7,132 @@ import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface StreamPushMapper {
|
||||
|
||||
@Insert("INSERT INTO wvp_stream_push (app, stream, total_reader_count, origin_type, origin_type_str, " +
|
||||
"push_time, alive_second, media_server_id, server_id, update_time, create_time, push_ing, self) VALUES" +
|
||||
"(#{app}, #{stream}, #{totalReaderCount}, #{originType}, #{originTypeStr}, " +
|
||||
"#{pushTime}, #{aliveSecond}, #{mediaServerId} , #{serverId} , #{updateTime} , #{createTime}, " +
|
||||
"#{pushIng}, #{self} )")
|
||||
@Insert("INSERT INTO wvp_stream_push (app, stream, media_server_id, server_id, push_time, update_time, create_time, push_ing) VALUES" +
|
||||
"(#{app}, #{stream}, #{mediaServerId} , #{serverId} , #{pushTime} ,#{updateTime}, #{createTime}, #{pushIng})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
|
||||
int add(StreamPush streamPushItem);
|
||||
|
||||
|
||||
@Update(value = {" <script>" +
|
||||
"UPDATE wvp_stream_push " +
|
||||
"SET update_time=#{updateTime}" +
|
||||
"<if test=\"app != null\">, app=#{app}</if>" +
|
||||
"<if test=\"stream != null\">, stream=#{stream}</if>" +
|
||||
"<if test=\"mediaServerId != null\">, media_server_id=#{mediaServerId}</if>" +
|
||||
"<if test=\"serverId != null\">, server_id=#{serverId}</if>" +
|
||||
"<if test=\"totalReaderCount != null\">, total_reader_count=#{totalReaderCount}</if>" +
|
||||
"<if test=\"originType != null\">, origin_type=#{originType}</if>" +
|
||||
"<if test=\"originTypeStr != null\">, origin_type_str=#{originTypeStr}</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}"+
|
||||
"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 sp FROM wvp_stream_push sp left join wvp_gb_stream gs on sp.app = gs.app AND sp.stream = gs.stream where " +
|
||||
"<foreach collection='streamPushItems' item='item' separator='or'>" +
|
||||
"(sp.app=#{item.app} and sp.stream=#{item.stream} and gs.gb_id is null) " +
|
||||
"</foreach>" +
|
||||
"</script>")
|
||||
int delAllWithoutGBId(List<StreamPush> streamPushItems);
|
||||
|
||||
@Delete("<script> "+
|
||||
"DELETE FROM wvp_stream_push where " +
|
||||
"<foreach collection='streamPushItems' item='item' separator='or'>" +
|
||||
"(app=#{item.app} and stream=#{item.stream}) " +
|
||||
"</foreach>" +
|
||||
"</script>")
|
||||
int delAll(List<StreamPush> streamPushItems);
|
||||
|
||||
@Delete("<script> "+
|
||||
"DELETE FROM wvp_stream_push where " +
|
||||
"<foreach collection='gbStreams' item='item' separator='or'>" +
|
||||
"(app=#{item.app} and stream=#{item.stream}) " +
|
||||
"</foreach>" +
|
||||
"</script>")
|
||||
int delAllForGbStream(List<GbStream> gbStreams);
|
||||
|
||||
@Delete("DELETE FROM wvp_stream_push WHERE id=#{id}")
|
||||
int del(@Param("id") int id);
|
||||
|
||||
@Select(value = {" <script>" +
|
||||
"SELECT " +
|
||||
"st.*, " +
|
||||
"gs.gb_id, gs.name, gs.longitude, gs.latitude, gs.gb_stream_id " +
|
||||
"from " +
|
||||
"wvp_stream_push st " +
|
||||
"LEFT join wvp_gb_stream gs " +
|
||||
"on st.app = gs.app AND st.stream = gs.stream " +
|
||||
"WHERE " +
|
||||
"1=1 " +
|
||||
" <if test='query != null'> AND (st.app LIKE concat('%',#{query},'%') OR st.stream LIKE concat('%',#{query},'%') OR gs.gb_id LIKE concat('%',#{query},'%') OR gs.name LIKE concat('%',#{query},'%'))</if> " +
|
||||
" <if test='pushing == true' > AND (gs.gb_id is null OR st.push_ing=1)</if>" +
|
||||
" <if test='pushing == false' > AND (st.push_ing is null OR st.push_ing=0) </if>" +
|
||||
" SELECT " +
|
||||
" st.*, " +
|
||||
" st.id as stream_push_id, " +
|
||||
" wdc.*, " +
|
||||
" wdc.id as gb_id" +
|
||||
" from " +
|
||||
" wvp_stream_push st " +
|
||||
" LEFT join wvp_device_channel wdc " +
|
||||
" on st.id = wdc.stream_push_id " +
|
||||
" WHERE " +
|
||||
" 1=1 " +
|
||||
" <if test='query != null'> AND (st.app LIKE concat('%',#{query},'%') OR st.stream LIKE concat('%',#{query},'%') " +
|
||||
" OR wdc.gb_device_id LIKE concat('%',#{query},'%') OR wdc.gb_name LIKE concat('%',#{query},'%'))</if> " +
|
||||
" <if test='pushing == true' > AND st.push_ing=1</if>" +
|
||||
" <if test='pushing == false' > AND st.push_ing=0 </if>" +
|
||||
" <if test='mediaServerId != null' > AND st.media_server_id=#{mediaServerId} </if>" +
|
||||
"order by st.create_time desc" +
|
||||
" order by st.create_time desc" +
|
||||
" </script>"})
|
||||
List<StreamPush> selectAllForList(@Param("query") String query, @Param("pushing") Boolean pushing, @Param("mediaServerId") String mediaServerId);
|
||||
|
||||
@Select("SELECT st.*, gs.gb_id, gs.name, gs.longitude, gs.latitude FROM wvp_stream_push st LEFT join wvp_gb_stream gs on st.app = gs.app AND st.stream = gs.stream order by st.create_time desc")
|
||||
List<StreamPush> selectAll();
|
||||
|
||||
@Select("SELECT st.*, gs.gb_id, gs.name, gs.longitude, gs.latitude FROM wvp_stream_push st LEFT join wvp_gb_stream gs on st.app = gs.app AND st.stream = gs.stream WHERE st.app=#{app} AND st.stream=#{stream}")
|
||||
@Select("SELECT st.*, st.id as stream_push_id, wdc.*, wdc.id as gb_id FROM wvp_stream_push st LEFT join wvp_device_channel wdc on st.id = wdc.stream_push_id WHERE st.app=#{app} AND st.stream=#{stream}")
|
||||
StreamPush selectByAppAndStream(@Param("app") String app, @Param("stream") String stream);
|
||||
|
||||
@Insert("<script>" +
|
||||
"Insert INTO wvp_stream_push (app, stream, total_reader_count, origin_type, origin_type_str, " +
|
||||
"create_time, alive_second, media_server_id, server_id, status, push_ing) " +
|
||||
"VALUES <foreach collection='streamPushItems' item='item' index='index' separator=','>" +
|
||||
"( #{item.app}, #{item.stream}, #{item.totalReaderCount}, #{item.originType}, " +
|
||||
"#{item.originTypeStr},#{item.createTime}, #{item.aliveSecond}, #{item.mediaServerId},#{item.serverId}, #{item.status} ," +
|
||||
" #{item.pushIng} )" +
|
||||
"Insert INTO wvp_stream_push ( " +
|
||||
" app, stream, media_server_id, server_id, push_time, update_time, create_time, push_ing) " +
|
||||
" VALUES <foreach collection='streamPushItems' item='item' index='index' separator=','>" +
|
||||
" ( #{item.app}, #{item.stream}, #{item.mediaServerId},#{item.serverId} ,#{item.pushTime}, #{item.updateTime}, #{item.createTime}, #{item.pushIng} )" +
|
||||
" </foreach>" +
|
||||
"</script>")
|
||||
" </script>")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
|
||||
int addAll(List<StreamPush> streamPushItems);
|
||||
|
||||
@Delete("DELETE FROM wvp_stream_push")
|
||||
void clear();
|
||||
|
||||
@Delete("delete" +
|
||||
" from wvp_stream_push " +
|
||||
" where id in " +
|
||||
" (select temp.id from " +
|
||||
" (select wgs.gb_stream_id as id " +
|
||||
" from wvp_gb_stream wgs" +
|
||||
" left join wvp_stream_push sp on sp.id = wgs.gb_stream_id" +
|
||||
" where wgs.gb_id is null and wgs.media_server_id = #{mediaServerId}) temp)"
|
||||
)
|
||||
void deleteWithoutGBId(String mediaServerId);
|
||||
|
||||
@Select("SELECT * FROM wvp_stream_push WHERE media_server_id=#{mediaServerId}")
|
||||
@Select("SELECT st.*, st.id as stream_push_id, wdc.*, wdc.id as gb_id FROM wvp_stream_push st LEFT join wvp_device_channel wdc on st.id = wdc.stream_push_id WHERE st.media_server_id=#{mediaServerId}")
|
||||
List<StreamPush> selectAllByMediaServerId(String mediaServerId);
|
||||
|
||||
@Select("SELECT sp.* FROM wvp_stream_push sp left join wvp_gb_stream gs on gs.app = sp.app and gs.stream= sp.stream WHERE sp.media_server_id=#{mediaServerId} and gs.gb_id is null")
|
||||
@Select("SELECT st.*, st.id as stream_push_id, wdc.*, wdc.id as gb_id FROM wvp_stream_push st LEFT join wvp_device_channel wdc on st.id = wdc.stream_push_id WHERE st.media_server_id=#{mediaServerId} and wdc.gb_device_id is null")
|
||||
List<StreamPush> selectAllByMediaServerIdWithOutGbID(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);
|
||||
|
||||
@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);
|
||||
|
||||
@Update("UPDATE wvp_stream_push " +
|
||||
"SET status=#{status} " +
|
||||
"WHERE media_server_id=#{mediaServerId}")
|
||||
void updateStatusByMediaServerId(@Param("mediaServerId") String mediaServerId, @Param("status") boolean status);
|
||||
"WHERE id=#{id}")
|
||||
int updatePushStatus(@Param("id") int id, @Param("pushIng") boolean pushIng);
|
||||
|
||||
|
||||
@Select("<script> "+
|
||||
"SELECT gs.* FROM wvp_stream_push sp left join wvp_gb_stream gs on sp.app = gs.app AND sp.stream = gs.stream " +
|
||||
"where sp.status = true and (gs.app, gs.stream) in (" +
|
||||
"SELECT st.*, st.id as stream_push_id, wdc.*, wdc.id as gb_id FROM wvp_stream_push st LEFT join wvp_device_channel wdc on st.id = wdc.stream_push_id " +
|
||||
"where (st.app, st.stream) in (" +
|
||||
"<foreach collection='offlineStreams' item='item' separator=','>" +
|
||||
"(#{item.app}, #{item.stream}) " +
|
||||
"</foreach>" +
|
||||
")</script>")
|
||||
List<StreamPush> getOnlinePusherForGbInList(List<StreamPushItemFromRedis> offlineStreams);
|
||||
List<StreamPush> getListFromRedis(List<StreamPushItemFromRedis> offlineStreams);
|
||||
|
||||
@Update("<script> "+
|
||||
"UPDATE wvp_stream_push SET status=0 where (app, stream) in (" +
|
||||
"<foreach collection='offlineStreams' item='item' separator=','>" +
|
||||
"(#{item.app}, #{item.stream}) " +
|
||||
"</foreach>" +
|
||||
")</script>")
|
||||
void offline(List<StreamPushItemFromRedis> offlineStreams);
|
||||
|
||||
@Select("<script> "+
|
||||
"SELECT * FROM wvp_stream_push sp left join wvp_gb_stream gs on sp.app = gs.app AND sp.stream = gs.stream " +
|
||||
"where sp.status = 0 and (gs.app, gs.stream) in (" +
|
||||
"<foreach collection='onlineStreams' item='item' separator=','>" +
|
||||
"(#{item.app}, #{item.stream}) " +
|
||||
"</foreach>" +
|
||||
") </script>")
|
||||
List<StreamPush> getOfflinePusherForGbInList(List<StreamPushItemFromRedis> onlineStreams);
|
||||
|
||||
@Update("<script> "+
|
||||
"UPDATE wvp_stream_push SET status=1 where (app, stream) in (" +
|
||||
"<foreach collection='onlineStreams' item='item' separator=','>" +
|
||||
"(#{item.app}, #{item.stream}) " +
|
||||
"</foreach>" +
|
||||
")</script>")
|
||||
void online(List<StreamPushItemFromRedis> onlineStreams);
|
||||
|
||||
@Select("SELECT gs.* FROM wvp_stream_push sp left join wvp_gb_stream gs on sp.app = gs.app AND sp.stream = gs.stream where sp.status = true")
|
||||
List<StreamPush> getOnlinePusherForGb();
|
||||
|
||||
@Update("UPDATE wvp_stream_push SET status=0")
|
||||
void setAllStreamOffline();
|
||||
|
||||
@Select("SELECT CONCAT(app,stream) from wvp_gb_stream")
|
||||
@Select("SELECT CONCAT(app,stream) from wvp_stream_push")
|
||||
List<String> getAllAppAndStream();
|
||||
|
||||
@Select("select count(1) from wvp_stream_push ")
|
||||
int getAllCount();
|
||||
|
||||
@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>" +
|
||||
" select count(1) from wvp_stream_push where push_ing = true" +
|
||||
" </script>"})
|
||||
int getAllOnline(Boolean usePushingAsStatus);
|
||||
|
||||
@Select("<script> " +
|
||||
"select app, stream from wvp_stream_push where (app, stream) in " +
|
||||
"<foreach collection='streamPushItems' item='item' separator=','>" +
|
||||
"(#{item.app}, #{item.stream}) " +
|
||||
"</foreach>" +
|
||||
"</script>")
|
||||
List<StreamPush> getListIn(List<StreamPush> streamPushItems);
|
||||
int getAllPushing(Boolean usePushingAsStatus);
|
||||
|
||||
@MapKey("vhost")
|
||||
@Select("SELECT CONCAT(wsp.app, wsp.stream) as vhost, wsp.app, wsp.stream, wgs.gb_id, wgs.name " +
|
||||
@Select("SELECT CONCAT(wsp.app, wsp.stream) as vhost, wsp.*, wsp.* , wsp.id as gb_id " +
|
||||
" from wvp_stream_push wsp " +
|
||||
" left join wvp_gb_stream wgs on wgs.app = wsp.app and wgs.stream = wsp.stream")
|
||||
" LEFT join wvp_device_channel wdc on wsp.id = wdc.stream_push_id")
|
||||
Map<String, StreamPush> getAllAppAndStreamMap();
|
||||
|
||||
|
||||
@MapKey("gb_id")
|
||||
@Select("SELECT wgs.gb_id, wsp.app, wsp.stream, wgs.gb_id, wgs.name " +
|
||||
@MapKey("gb_device_id")
|
||||
@Select("SELECT wdc.gb_device_id, wsp.id as stream_push_id, wsp.*, wsp.* , wsp.id as gb_id " +
|
||||
" from wvp_stream_push wsp " +
|
||||
" left join wvp_gb_stream wgs on wgs.app = wsp.app and wgs.stream = wsp.stream")
|
||||
" LEFT join wvp_device_channel wdc on wsp.id = wdc.stream_push_id")
|
||||
Map<String, StreamPush> getAllGBId();
|
||||
|
||||
StreamPush select(Integer streamPushId);
|
||||
@Select("SELECT st.*, st.id as stream_push_id, wdc.*, wdc.id as gb_id FROM wvp_stream_push st LEFT join wvp_device_channel wdc on st.id = wdc.stream_push_id WHERE st.id=#{id}")
|
||||
StreamPush select(@Param("id") int id);
|
||||
|
||||
@Select("<script> "+
|
||||
"SELECT st.*, st.id as stream_push_id, wdc.*, wdc.id as gb_id FROM wvp_stream_push st LEFT join wvp_device_channel wdc on st.id = wdc.stream_push_id " +
|
||||
" where st.id in (" +
|
||||
" <foreach collection='ids' item='item' separator=','>" +
|
||||
" #{item} " +
|
||||
" </foreach>" +
|
||||
" )</script>")
|
||||
List<StreamPush> selectInSet(Set<Integer> ids);
|
||||
|
||||
@Delete("<script> "+
|
||||
"DELETE FROM wvp_stream_push WHERE" +
|
||||
" id in (" +
|
||||
"<foreach collection='streamPushList' item='item' separator=','>" +
|
||||
" #{item.id} " +
|
||||
"</foreach>" +
|
||||
")</script>")
|
||||
void batchDel(List<StreamPush> streamPushList);
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPus
|
||||
streamPush.setGbName(streamPushExcelDto.getName());
|
||||
streamPush.setGbLongitude(streamPushExcelDto.getLongitude());
|
||||
streamPush.setGbLatitude(streamPushExcelDto.getLatitude());
|
||||
|
||||
streamPush.setUpdateTime(DateUtil.getNow());
|
||||
streamPushItemForSave.put(streamPush.getApp() + streamPush.getStream(), streamPush);
|
||||
|
||||
loadedSize ++;
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.github.pagehelper.PageInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author lin
|
||||
@@ -92,4 +93,8 @@ public interface IStreamPushService {
|
||||
void updatePushStatus(Integer streamPushId, boolean pushIng);
|
||||
|
||||
void batchUpdate(List<StreamPush> streamPushItemForUpdate);
|
||||
|
||||
int delete(int id);
|
||||
|
||||
void batchRemove(Set<Integer> ids);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
|
||||
import com.genersoft.iot.vmp.media.bean.MediaInfo;
|
||||
@@ -21,6 +22,7 @@ import com.genersoft.iot.vmp.streamPush.bean.StreamPush;
|
||||
import com.genersoft.iot.vmp.streamPush.dao.StreamPushMapper;
|
||||
import com.genersoft.iot.vmp.streamPush.service.IStreamPushService;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
@@ -205,6 +207,10 @@ public class StreamPushServiceImpl implements IStreamPushService {
|
||||
@Transactional
|
||||
public boolean add(StreamPush stream) {
|
||||
log.info("[添加推流] app: {}, stream: {}, 国标编号: {}", stream.getApp(), stream.getStream(), stream.getGbDeviceId());
|
||||
StreamPush streamPushInDb = streamPushMapper.selectByAppAndStream(stream.getApp(), stream.getStream());
|
||||
if (streamPushInDb != null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "应用名+流ID已存在");
|
||||
}
|
||||
stream.setUpdateTime(DateUtil.getNow());
|
||||
stream.setCreateTime(DateUtil.getNow());
|
||||
int addResult = streamPushMapper.add(stream);
|
||||
@@ -218,7 +224,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
|
||||
if (channel != null) {
|
||||
log.info("[添加推流]失败,国标编号已存在: {} app: {}, stream: {}, ", stream.getGbDeviceId(), stream.getApp(), stream.getStream());
|
||||
}
|
||||
int addChannelResult = gbChannelService.add(stream.getCommonGBChannel());
|
||||
int addChannelResult = gbChannelService.add(stream.buildCommonGBChannel());
|
||||
return addChannelResult > 0;
|
||||
}
|
||||
|
||||
@@ -243,10 +249,18 @@ public class StreamPushServiceImpl implements IStreamPushService {
|
||||
public boolean update(StreamPush streamPush) {
|
||||
log.info("[更新推流]:id: {}, app: {}, stream: {}, ", streamPush.getId(), streamPush.getApp(), streamPush.getStream());
|
||||
assert streamPush.getId() != null;
|
||||
StreamPush streamPushInDb = streamPushMapper.select(streamPush.getId());
|
||||
if (!streamPushInDb.getApp().equals(streamPush.getApp()) || !streamPushInDb.getStream().equals(streamPush.getStream())) {
|
||||
// app或者stream变化
|
||||
StreamPush streamPushInDbForAppAndStream = streamPushMapper.selectByAppAndStream(streamPush.getApp(), streamPush.getStream());
|
||||
if (streamPushInDbForAppAndStream != null && !streamPushInDbForAppAndStream.getId().equals(streamPush.getId())) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "应用名+流ID已存在");
|
||||
}
|
||||
}
|
||||
streamPush.setUpdateTime(DateUtil.getNow());
|
||||
streamPushMapper.update(streamPush);
|
||||
if (streamPush.getGbId() > 0) {
|
||||
gbChannelService.update(streamPush.getCommonGBChannel());
|
||||
gbChannelService.update(streamPush.buildCommonGBChannel());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -282,7 +296,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
|
||||
}
|
||||
streamPush.setPushIng(false);
|
||||
if (userSetting.isUsePushingAsStatus()) {
|
||||
gbChannelService.offline(streamPush.getCommonGBChannel());
|
||||
gbChannelService.offline(streamPush.buildCommonGBChannel());
|
||||
}
|
||||
redisCatchStorage.deleteSendRTPServer(null, streamPush.getGbDeviceId(), null, streamPush.getStream());
|
||||
mediaServerService.stopSendRtp(mediaServer, streamPush.getApp(), streamPush.getStream(), null);
|
||||
@@ -440,8 +454,8 @@ public class StreamPushServiceImpl implements IStreamPushService {
|
||||
streamPushMapper.addAll(streamPushItems);
|
||||
List<CommonGBChannel> commonGBChannels = new ArrayList<>();
|
||||
for (StreamPush streamPush : streamPushItems) {
|
||||
if (ObjectUtils.isEmpty(streamPush.getGbDeviceId())) {
|
||||
commonGBChannels.add(streamPush.getCommonGBChannel());
|
||||
if (!ObjectUtils.isEmpty(streamPush.getGbDeviceId())) {
|
||||
commonGBChannels.add(streamPush.buildCommonGBChannel());
|
||||
}
|
||||
}
|
||||
gbChannelService.batchAdd(commonGBChannels);
|
||||
@@ -449,13 +463,13 @@ public class StreamPushServiceImpl implements IStreamPushService {
|
||||
|
||||
@Override
|
||||
public void allOffline() {
|
||||
List<StreamPush> onlinePushers = streamPushMapper.getOnlinePusherForGb();
|
||||
if (onlinePushers.isEmpty()) {
|
||||
List<StreamPush> streamPushList = streamPushMapper.selectAllForList(null, null, null);
|
||||
if (streamPushList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<CommonGBChannel> commonGBChannelList = new ArrayList<>();
|
||||
for (StreamPush onlinePusher : onlinePushers) {
|
||||
commonGBChannelList.add(onlinePusher.getCommonGBChannel());
|
||||
for (StreamPush streamPush : streamPushList) {
|
||||
commonGBChannelList.add(streamPush.buildCommonGBChannel());
|
||||
}
|
||||
gbChannelService.offline(commonGBChannelList);
|
||||
}
|
||||
@@ -463,10 +477,10 @@ public class StreamPushServiceImpl implements IStreamPushService {
|
||||
@Override
|
||||
public void offline(List<StreamPushItemFromRedis> offlineStreams) {
|
||||
// 更新部分设备离线
|
||||
List<StreamPush> onlinePushers = streamPushMapper.getOnlinePusherForGbInList(offlineStreams);
|
||||
List<StreamPush> streamPushList = streamPushMapper.getListFromRedis(offlineStreams);
|
||||
List<CommonGBChannel> commonGBChannelList = new ArrayList<>();
|
||||
for (StreamPush onlinePusher : onlinePushers) {
|
||||
commonGBChannelList.add(onlinePusher.getCommonGBChannel());
|
||||
for (StreamPush onlinePusher : streamPushList) {
|
||||
commonGBChannelList.add(onlinePusher.buildCommonGBChannel());
|
||||
}
|
||||
gbChannelService.offline(commonGBChannelList);
|
||||
}
|
||||
@@ -474,10 +488,10 @@ public class StreamPushServiceImpl implements IStreamPushService {
|
||||
@Override
|
||||
public void online(List<StreamPushItemFromRedis> onlineStreams) {
|
||||
// 更新部分设备上线streamPushService
|
||||
List<StreamPush> offlinePushers = streamPushMapper.getOfflinePusherForGbInList(onlineStreams);
|
||||
List<StreamPush> streamPushList = streamPushMapper.getListFromRedis(onlineStreams);
|
||||
List<CommonGBChannel> commonGBChannelList = new ArrayList<>();
|
||||
for (StreamPush onlinePusher : offlinePushers) {
|
||||
commonGBChannelList.add(onlinePusher.getCommonGBChannel());
|
||||
for (StreamPush onlinePusher : streamPushList) {
|
||||
commonGBChannelList.add(onlinePusher.buildCommonGBChannel());
|
||||
}
|
||||
gbChannelService.online(commonGBChannelList);
|
||||
}
|
||||
@@ -491,7 +505,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
|
||||
@Override
|
||||
public ResourceBaseInfo getOverview() {
|
||||
int total = streamPushMapper.getAllCount();
|
||||
int online = streamPushMapper.getAllOnline(userSetting.isUsePushingAsStatus());
|
||||
int online = streamPushMapper.getAllPushing(userSetting.isUsePushingAsStatus());
|
||||
|
||||
return new ResourceBaseInfo(total, online);
|
||||
}
|
||||
@@ -512,9 +526,9 @@ public class StreamPushServiceImpl implements IStreamPushService {
|
||||
return;
|
||||
}
|
||||
if ("ON".equalsIgnoreCase(push.getGbStatus())) {
|
||||
gbChannelService.online(push.getCommonGBChannel());
|
||||
gbChannelService.online(push.buildCommonGBChannel());
|
||||
}else {
|
||||
gbChannelService.offline(push.getCommonGBChannel());
|
||||
gbChannelService.offline(push.buildCommonGBChannel());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -556,4 +570,38 @@ public class StreamPushServiceImpl implements IStreamPushService {
|
||||
public void batchUpdate(List<StreamPush> streamPushItemForUpdate) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int delete(int id) {
|
||||
StreamPush streamPush = streamPushMapper.select(id);
|
||||
if (streamPush == null) {
|
||||
return 0;
|
||||
}
|
||||
if(streamPush.isPushIng()) {
|
||||
MediaServer mediaServer = mediaServerService.getOne(streamPush.getMediaServerId());
|
||||
mediaServerService.closeStreams(mediaServer, streamPush.getApp(), streamPush.getStream());
|
||||
}
|
||||
if (streamPush.getGbDeviceId() != null) {
|
||||
gbChannelService.delete(streamPush.getGbId());
|
||||
}
|
||||
return streamPushMapper.del(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void batchRemove(Set<Integer> ids) {
|
||||
List<StreamPush> streamPushList = streamPushMapper.selectInSet(ids);
|
||||
if (streamPushList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<CommonGBChannel> commonGBChannelList = new ArrayList<>();
|
||||
streamPushList.stream().forEach(streamPush -> {
|
||||
if (streamPush.getGbDeviceId() != null) {
|
||||
commonGBChannelList.add(streamPush.buildCommonGBChannel());
|
||||
}
|
||||
});
|
||||
streamPushMapper.batchDel(streamPushList);
|
||||
gbChannelService.delete(commonGBChannelList);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user