diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/CommonChannelController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/CommonChannelController.java index 167e05cc..ee9f99f7 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/CommonChannelController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/CommonChannelController.java @@ -78,4 +78,11 @@ public class CommonChannelController { public void reset(Integer id){ channelService.reset(id); } + + @Operation(summary = "增加通道", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @ResponseBody + @PostMapping("/add") + public void add(@RequestBody CommonGBChannel channel){ + channelService.add(channel); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java index 529f0432..67208316 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java @@ -67,11 +67,6 @@ public interface CommonGBChannelMapper { " stream_push_id," + "create_time," + "update_time," + - "sub_count," + - "stream_id," + - "has_audio," + - "gps_time," + - "stream_identification," + "gb_name," + "gb_manufacturer," + "gb_model," + @@ -111,11 +106,6 @@ public interface CommonGBChannelMapper { " #{streamPushId}," + "#{createTime}, " + "#{updateTime}, " + - "#{subCount}, " + - "#{streamId}, " + - "#{hasAudio}, " + - "#{gpsTime}, " + - "#{streamIdentification}, " + "#{gbName}, " + "#{gbManufacturer}, " + "#{gbModel}, " + @@ -351,11 +341,6 @@ public interface CommonGBChannelMapper { "stream_push_id," + "create_time," + "update_time," + - "sub_count," + - "stream_id," + - "has_audio," + - "gps_time," + - "stream_identification," + "gb_name," + "gb_manufacturer," + "gb_model," + @@ -391,8 +376,8 @@ public interface CommonGBChannelMapper { "gb_svc_time_support_mode ) " + "VALUES" + " " + - "(#{item.gbDeviceId}, #{item.streamProxyId}, #{item.streamPushId},#{item.createTime},#{item.updateTime},#{item.subCount}," + - "#{item.streamId},#{item.hasAudio},#{item.gpsTime},#{item.streamIdentification},#{item.gbName},#{item.gbManufacturer}, #{item.gbModel}," + + "(#{item.gbDeviceId}, #{item.streamProxyId}, #{item.streamPushId},#{item.createTime},#{item.updateTime}," + + "#{item.gbName},#{item.gbManufacturer}, #{item.gbModel}," + "#{item.gbOwner},#{item.gbCivilCode},#{item.gbBlock}, #{item.gbAddress}, #{item.gbParental}, #{item.gbParentId},#{item.gbSafetyWay}, " + "#{item.gbRegisterWay},#{item.gbCertNum},#{item.gbCertifiable},#{item.gbErrCode},#{item.gbEndTime}, #{item.gbSecrecy},#{item.gbIpAddress}," + "#{item.gbPort},#{item.gbPassword},#{item.gbStatus},#{item.gbLongitude}, #{item.gbLatitude},#{item.gbPtzType},#{item.gbPositionType},#{item.gbRoomType}," + @@ -473,4 +458,64 @@ public interface CommonGBChannelMapper { " "}) void reset(@Param("id") int id, @Param("gbDeviceDbId") int gbDeviceDbId, @Param("updateTime") String updateTime); + + @Select(value = {" "}) + List queryByIds(List commonGBChannelList); + + @Delete(value = {" "}) + void batchDelete(List channelListInDb); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java index fc921b62..192b3360 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java @@ -15,6 +15,8 @@ public interface IGbChannelService { int delete(int gbId); + void delete(List commonGBChannelList); + int update(CommonGBChannel commonGBChannel); int offline(CommonGBChannel commonGBChannel); @@ -40,4 +42,5 @@ public interface IGbChannelService { List getNetworkIdentificationTypeList(); void reset(int id); + } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java index b9da0445..d861f530 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java @@ -52,9 +52,24 @@ public class GbChannelServiceImpl implements IGbChannelService { return 1; } + @Override + public void delete(List commonGBChannelList) { + List channelListInDb = commonGBChannelMapper.queryByIds(commonGBChannelList); + if (channelListInDb.isEmpty()) { + return; + } + commonGBChannelMapper.batchDelete(channelListInDb); + try { + // 发送通知 + eventPublisher.catalogEventPublish(null, channelListInDb, CatalogEvent.DEL); + }catch (Exception e) { + log.warn("[通道移除通知] 发送失败,{}条", channelListInDb.size(), e); + } + } + @Override public int update(CommonGBChannel commonGBChannel) { - log.warn("[更新通道] 通道ID: {}, ", commonGBChannel.getGbId()); + log.info("[更新通道] 通道ID: {}, ", commonGBChannel.getGbId()); if (commonGBChannel.getGbId() <= 0) { log.warn("[更新通道] 未找到数据库ID,更新失败, {}", commonGBChannel.getGbDeviceDbId()); return 0; diff --git a/src/main/java/com/genersoft/iot/vmp/streamProxy/bean/StreamProxy.java b/src/main/java/com/genersoft/iot/vmp/streamProxy/bean/StreamProxy.java index 786ba39c..055b3024 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamProxy/bean/StreamProxy.java +++ b/src/main/java/com/genersoft/iot/vmp/streamProxy/bean/StreamProxy.java @@ -71,7 +71,7 @@ public class StreamProxy extends CommonGBChannel { @Schema(description = "创建时间") private String createTime; - public CommonGBChannel getCommonGBChannel() { + public CommonGBChannel buildCommonGBChannel() { if (ObjectUtils.isEmpty(this.getGbDeviceId())) { return null; } diff --git a/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java index c038a845..9ad5ad66 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java @@ -169,7 +169,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { streamProxy.setUpdateTime(now); if (streamProxyMapper.add(streamProxy) > 0 && !ObjectUtils.isEmpty(streamProxy.getGbDeviceId())) { - gbChannelService.add(streamProxy.getCommonGBChannel()); + gbChannelService.add(streamProxy.buildCommonGBChannel()); } return true; } @@ -183,9 +183,9 @@ public class StreamProxyServiceImpl implements IStreamProxyService { if (streamProxyMapper.update(streamProxy) > 0 && !ObjectUtils.isEmpty(streamProxy.getGbDeviceId())) { if (streamProxy.getGbId() > 0) { - gbChannelService.update(streamProxy.getCommonGBChannel()); + gbChannelService.update(streamProxy.buildCommonGBChannel()); }else { - gbChannelService.add(streamProxy.getCommonGBChannel()); + gbChannelService.add(streamProxy.buildCommonGBChannel()); } } return true; @@ -303,7 +303,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { redisCatchStorage.addStream(mediaServer, "pull", streamInfo.getApp(), streamInfo.getStream(), streamInfo.getMediaInfo()); if ("OFF".equalsIgnoreCase(streamProxy.getGbStatus()) && streamProxy.getGbId() > 0) { streamProxy.setGbStatus("ON"); - channelListForOnline.add(streamProxy.getCommonGBChannel()); + channelListForOnline.add(streamProxy.buildCommonGBChannel()); } streamProxyMapForDb.remove(key); } @@ -319,7 +319,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { for (StreamProxy streamProxy : streamProxyMapForDb.values()) { if ("ON".equalsIgnoreCase(streamProxy.getGbStatus()) && streamProxy.getGbId() > 0) { streamProxy.setGbStatus("OFF"); - channelListForOffline.add(streamProxy.getCommonGBChannel()); + channelListForOffline.add(streamProxy.buildCommonGBChannel()); } // 移除开启了无人观看自动移除的流 if (streamProxy.getGbDeviceId() == null && streamProxy.isEnableRemoveNoneReader()) { @@ -360,7 +360,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { for (StreamProxy streamProxy : streamProxies) { if (streamProxy.getGbId() > 0 && "ON".equalsIgnoreCase(streamProxy.getGbStatus())) { - channelListForOffline.add(streamProxy.getCommonGBChannel()); + channelListForOffline.add(streamProxy.buildCommonGBChannel()); } if (streamProxy.getGbId() == 0 && streamProxy.isEnableRemoveNoneReader()) { streamProxiesForRemove.add(streamProxy); @@ -400,9 +400,9 @@ public class StreamProxyServiceImpl implements IStreamProxyService { streamProxy.setGbStatus(status?"ON":"OFF"); if (streamProxy.getGbId() > 0) { if (status) { - gbChannelService.online(streamProxy.getCommonGBChannel()); + gbChannelService.online(streamProxy.buildCommonGBChannel()); }else { - gbChannelService.offline(streamProxy.getCommonGBChannel()); + gbChannelService.offline(streamProxy.buildCommonGBChannel()); } } diff --git a/src/main/java/com/genersoft/iot/vmp/streamPush/bean/BatchRemoveParam.java b/src/main/java/com/genersoft/iot/vmp/streamPush/bean/BatchRemoveParam.java new file mode 100644 index 00000000..307ef547 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/streamPush/bean/BatchRemoveParam.java @@ -0,0 +1,10 @@ +package com.genersoft.iot.vmp.streamPush.bean; + +import lombok.Data; + +import java.util.Set; + +@Data +public class BatchRemoveParam { + private Set ids; +} diff --git a/src/main/java/com/genersoft/iot/vmp/streamPush/bean/StreamPush.java b/src/main/java/com/genersoft/iot/vmp/streamPush/bean/StreamPush.java index 0a2da30b..dbd3dcc9 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamPush/bean/StreamPush.java +++ b/src/main/java/com/genersoft/iot/vmp/streamPush/bean/StreamPush.java @@ -83,13 +83,13 @@ public class StreamPush extends CommonGBChannel implements Comparable 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()); } } diff --git a/src/main/java/com/genersoft/iot/vmp/streamPush/dao/StreamPushMapper.java b/src/main/java/com/genersoft/iot/vmp/streamPush/dao/StreamPushMapper.java index 0a812069..ca2eddbe 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamPush/dao/StreamPushMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/streamPush/dao/StreamPushMapper.java @@ -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 = {" "}) 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 delAllForGbStream(List gbStreams); - + @Delete("DELETE FROM wvp_stream_push WHERE id=#{id}") + int del(@Param("id") int id); @Select(value = {" "}) List 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 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("") + " ") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") int addAll(List 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 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 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("") - List getOnlinePusherForGbInList(List offlineStreams); + List getListFromRedis(List offlineStreams); - @Update("") - void offline(List offlineStreams); - @Select("") - List getOfflinePusherForGbInList(List onlineStreams); - - @Update("") - void online(List 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 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 getAllAppAndStream(); @Select("select count(1) from wvp_stream_push ") int getAllCount(); @Select(value = {" "}) - int getAllOnline(Boolean usePushingAsStatus); - - @Select("") - List getListIn(List 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 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 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("") + List selectInSet(Set ids); + + @Delete("") + void batchDel(List streamPushList); } diff --git a/src/main/java/com/genersoft/iot/vmp/streamPush/enent/StreamPushUploadFileHandler.java b/src/main/java/com/genersoft/iot/vmp/streamPush/enent/StreamPushUploadFileHandler.java index f03abff6..9ccc8c8c 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamPush/enent/StreamPushUploadFileHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/streamPush/enent/StreamPushUploadFileHandler.java @@ -110,7 +110,7 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener streamPushItemForUpdate); + + int delete(int id); + + void batchRemove(Set ids); } diff --git a/src/main/java/com/genersoft/iot/vmp/streamPush/service/impl/StreamPushServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/streamPush/service/impl/StreamPushServiceImpl.java index 6e6dddca..4460563e 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamPush/service/impl/StreamPushServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/streamPush/service/impl/StreamPushServiceImpl.java @@ -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 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 onlinePushers = streamPushMapper.getOnlinePusherForGb(); - if (onlinePushers.isEmpty()) { + List streamPushList = streamPushMapper.selectAllForList(null, null, null); + if (streamPushList.isEmpty()) { return; } List 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 offlineStreams) { // 更新部分设备离线 - List onlinePushers = streamPushMapper.getOnlinePusherForGbInList(offlineStreams); + List streamPushList = streamPushMapper.getListFromRedis(offlineStreams); List 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 onlineStreams) { // 更新部分设备上线streamPushService - List offlinePushers = streamPushMapper.getOfflinePusherForGbInList(onlineStreams); + List streamPushList = streamPushMapper.getListFromRedis(onlineStreams); List 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 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 ids) { + List streamPushList = streamPushMapper.selectInSet(ids); + if (streamPushList.isEmpty()) { + return; + } + List commonGBChannelList = new ArrayList<>(); + streamPushList.stream().forEach(streamPush -> { + if (streamPush.getGbDeviceId() != null) { + commonGBChannelList.add(streamPush.buildCommonGBChannel()); + } + }); + streamPushMapper.batchDel(streamPushList); + gbChannelService.delete(commonGBChannelList); + } } diff --git a/web_src/src/components/ChannelEdit.vue b/web_src/src/components/ChannelEdit.vue index fafdff6a..80f116e6 100644 --- a/web_src/src/components/ChannelEdit.vue +++ b/web_src/src/components/ChannelEdit.vue @@ -1,6 +1,6 @@ - diff --git a/web_src/src/components/PushVideoList.vue b/web_src/src/components/PushVideoList.vue deleted file mode 100755 index e69f56da..00000000 --- a/web_src/src/components/PushVideoList.vue +++ /dev/null @@ -1,359 +0,0 @@ - - - - - diff --git a/web_src/src/components/StreamPushEdit.vue b/web_src/src/components/StreamPushEdit.vue new file mode 100644 index 00000000..7b9e3794 --- /dev/null +++ b/web_src/src/components/StreamPushEdit.vue @@ -0,0 +1,108 @@ + + + + diff --git a/web_src/src/components/StreamPushList.vue b/web_src/src/components/StreamPushList.vue new file mode 100755 index 00000000..b10d2af8 --- /dev/null +++ b/web_src/src/components/StreamPushList.vue @@ -0,0 +1,374 @@ + + + + + diff --git a/web_src/src/components/common/CommonChannelEdit.vue b/web_src/src/components/common/CommonChannelEdit.vue new file mode 100644 index 00000000..2e026fa1 --- /dev/null +++ b/web_src/src/components/common/CommonChannelEdit.vue @@ -0,0 +1,372 @@ + + + + diff --git a/web_src/src/components/dialog/channelCode.vue b/web_src/src/components/dialog/channelCode.vue index ddb14a88..5f0927ff 100644 --- a/web_src/src/components/dialog/channelCode.vue +++ b/web_src/src/components/dialog/channelCode.vue @@ -15,7 +15,7 @@
{{ allVal[0].meaning }}
- + {{ item.commonRegionName }} - {{ item.commonRegionDeviceId }} @@ -26,7 +26,7 @@
{{ allVal[1].meaning }}
- + {{ item.commonRegionName }} - {{ item.commonRegionDeviceId.substring(2) }} @@ -37,7 +37,7 @@
{{ allVal[2].meaning }}
- + {{ item.commonRegionName }} - {{ item.commonRegionDeviceId.substring(4) }} @@ -75,7 +75,7 @@
{{ allVal[5].meaning }}
- + {{ item.name }} - {{ item.code }} @@ -86,7 +86,7 @@
{{ allVal[6].meaning }}
- + {{ item.name }} - {{ item.code }} @@ -195,6 +195,7 @@ export default { }, methods: { openDialog: function (endCallBck, code, lockIndex, lockContent) { + console.log(code) this.showVideoDialog = true this.activeKey= '0'; this.regionList = [] diff --git a/web_src/src/layout/UiHeader.vue b/web_src/src/layout/UiHeader.vue index fdfcb9f9..2bd5fee3 100755 --- a/web_src/src/layout/UiHeader.vue +++ b/web_src/src/layout/UiHeader.vue @@ -8,7 +8,7 @@ 分屏监控 国标设备 电子地图 - 推流列表 + 推流列表 拉流代理 云端录像 节点管理 diff --git a/web_src/src/router/index.js b/web_src/src/router/index.js index fa96b2b5..7ae87740 100755 --- a/web_src/src/router/index.js +++ b/web_src/src/router/index.js @@ -6,7 +6,7 @@ import console from '../components/console.vue' import deviceList from '../components/DeviceList.vue' import channelList from '../components/channelList.vue' import gbRecordDetail from '../components/GBRecordDetail.vue' -import pushVideoList from '../components/PushVideoList.vue' +import streamPushList from '../components/StreamPushList.vue' import streamProxyList from '../components/StreamProxyList.vue' import map from '../components/map.vue' import login from '../components/Login.vue' @@ -54,8 +54,8 @@ export default new VueRouter({ component: deviceList, }, { - path: '/pushVideoList', - component: pushVideoList, + path: '/streamPushList', + component: streamPushList, }, { path: '/streamProxyList', diff --git a/数据库/2.7.2-重构/初始化-mysql-2.7.2.sql b/数据库/2.7.2-重构/初始化-mysql-2.7.2.sql index dfb0f852..94268d5a 100644 --- a/数据库/2.7.2-重构/初始化-mysql-2.7.2.sql +++ b/数据库/2.7.2-重构/初始化-mysql-2.7.2.sql @@ -98,7 +98,7 @@ create table wvp_log ( create table wvp_device_channel ( id serial primary key , device_db_id integer, - device_id character varying(50) not null, + device_id character varying(50), name character varying(255), manufacturer character varying(50), model character varying(50),