Merge branch 'master' into dev/abl支持

# Conflicts:
#	src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MediaStatusNotifyMessageHandler.java
#	src/main/java/com/genersoft/iot/vmp/media/bean/MediaInfo.java
#	src/main/java/com/genersoft/iot/vmp/media/bean/MediaServer.java
#	src/main/java/com/genersoft/iot/vmp/media/bean/RecordInfo.java
#	src/main/java/com/genersoft/iot/vmp/service/bean/CloudRecordItem.java
#	src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
#	src/main/java/com/genersoft/iot/vmp/storager/dao/CloudRecordServiceMapper.java
#	src/main/resources/application.yml
This commit is contained in:
lin
2025-07-03 14:58:24 +08:00
922 changed files with 75892 additions and 44475 deletions

View File

@@ -1,16 +1,14 @@
package com.genersoft.iot.vmp.storager;
import com.alibaba.fastjson2.JSONObject;
import com.genersoft.iot.vmp.common.ServerInfo;
import com.genersoft.iot.vmp.common.SystemAllInfo;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.media.bean.MediaInfo;
import com.genersoft.iot.vmp.media.bean.MediaServer;
import com.genersoft.iot.vmp.media.event.media.MediaArrivalEvent;
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
import com.genersoft.iot.vmp.storager.dao.dto.PlatformRegisterInfo;
import java.util.List;
import java.util.Map;
@@ -24,53 +22,12 @@ public interface IRedisCatchStorage {
*/
Long getCSEQ();
void updatePlatformCatchInfo(ParentPlatformCatch parentPlatformCatch);
ParentPlatformCatch queryPlatformCatchInfo(String platformGbId);
void delPlatformCatchInfo(String platformGbId);
void delPlatformKeepalive(String platformGbId);
void delPlatformRegister(String platformGbId);
void updatePlatformRegisterInfo(String callId, PlatformRegisterInfo platformRegisterInfo);
PlatformRegisterInfo queryPlatformRegisterInfo(String callId);
void delPlatformRegisterInfo(String callId);
void updateSendRTPSever(SendRtpItem sendRtpItem);
List<SendRtpItem> querySendRTPServer(String platformGbId, String channelId, String streamId);
/**
* 查询RTP推送信息缓存
* @param platformGbId
* @param channelId
* @return sendRtpItem
*/
SendRtpItem querySendRTPServer(String platformGbId, String channelId, String streamId, String callId);
List<SendRtpItem> querySendRTPServer(String platformGbId);
/**
* 删除RTP推送信息缓存
* @param platformGbId
* @param channelId
*/
void deleteSendRTPServer(String platformGbId, String channelId, String callId, String streamId);
/**
* 查询某个通道是否存在上级点播RTP推送
* @param channelId
*/
boolean isChannelSendingRTP(String channelId);
/**
* 在redis添加wvp的信息
*/
void updateWVPInfo(JSONObject jsonObject, int time);
void updateWVPInfo(ServerInfo serverInfo, int time);
void removeOfflineWVPInfo(String serverId);
/**
* 发送推流生成与推流消失消息
@@ -127,14 +84,13 @@ public interface IRedisCatchStorage {
void updateGpsMsgInfo(GPSMsgInfo gpsMsgInfo);
GPSMsgInfo getGpsMsgInfo(String gbId);
List<GPSMsgInfo> getAllGpsMsgInfo();
Long getSN(String method);
void resetAllSN();
MediaInfo getStreamInfo(String app, String streamId, String mediaServerId);
MediaInfo getProxyStream(String app, String streamId);
void addCpuInfo(double cpuInfo);
void addMemInfo(double memInfo);
@@ -182,10 +138,6 @@ public interface IRedisCatchStorage {
*/
void sendStreamPushRequestedMsgForStatus();
List<SendRtpItem> querySendRTPServerByChannelId(String channelId);
List<SendRtpItem> querySendRTPServerByStream(String stream);
SystemAllInfo getSystemInfo();
int getPushStreamCount(String id);
@@ -196,9 +148,7 @@ public interface IRedisCatchStorage {
void addDiskInfo(List<Map<String, Object>> diskInfo);
void deleteSendRTPServer(SendRtpItem sendRtpItem);
List<SendRtpItem> queryAllSendRTPServer();
List<SendRtpInfo> queryAllSendRTPServer();
List<Device> getAllDevices();
@@ -208,23 +158,29 @@ public interface IRedisCatchStorage {
void sendChannelAddOrDelete(String deviceId, String channelId, boolean add);
void sendPlatformStartPlayMsg(SendRtpItem sendRtpItem, ParentPlatform platform);
void sendPlatformStartPlayMsg(SendRtpInfo sendRtpItem, DeviceChannel channel, Platform platform);
void sendPlatformStopPlayMsg(SendRtpItem sendRtpItem, ParentPlatform platform);
void sendPlatformStopPlayMsg(SendRtpInfo sendRtpItem, Platform platform, CommonGBChannel channel);
void addPushListItem(String app, String stream, MediaArrivalEvent param);
void addPushListItem(String app, String stream, MediaInfo param);
StreamPushItem getPushListItem(String app, String stream);
MediaInfo getPushListItem(String app, String stream);
void removePushListItem(String app, String stream, String mediaServerId);
void sendPushStreamClose(MessageForPushChannel messageForPushChannel);
void addWaiteSendRtpItem(SendRtpItem sendRtpItem, int platformPlayTimeout);
void addWaiteSendRtpItem(SendRtpInfo sendRtpItem, int platformPlayTimeout);
SendRtpItem getWaiteSendRtpItem(String app, String stream);
SendRtpInfo getWaiteSendRtpItem(String app, String stream);
void sendStartSendRtp(SendRtpInfo sendRtpItem);
void sendPushStreamOnline(SendRtpInfo sendRtpItem);
ServerInfo queryServerInfo(String serverId);
String chooseOneServer(String serverId);
void sendStartSendRtp(SendRtpItem sendRtpItem);
void sendPushStreamOnline(SendRtpItem sendRtpItem);
}

View File

@@ -1,384 +0,0 @@
package com.genersoft.iot.vmp.storager;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend;
import com.github.pagehelper.PageInfo;
import java.util.List;
/**
* @description:视频设备数据存储接口
* @author: swwheihei
* @date: 2020年5月6日 下午2:14:31
*/
@SuppressWarnings("rawtypes")
public interface IVideoManagerStorage {
/**
* 根据设备ID判断设备是否存在
*
* @param deviceId 设备ID
* @return true:存在 false不存在
*/
public boolean exists(String deviceId);
/**
* 开始播放
* @param deviceId 设备id
* @param channelId 通道ID
* @param streamId 流地址
*/
public void startPlay(String deviceId, String channelId, String streamId);
/**
* 停止播放
* @param deviceId 设备id
* @param channelId 通道ID
*/
public void stopPlay(String deviceId, String channelId);
/**
* 获取设备
*
* @param deviceId 设备ID
* @return DShadow 设备对象
*/
public Device queryVideoDevice(String deviceId);
/**
* 获取某个设备的通道列表
*
* @param deviceId 设备ID
* @param page 分页 当前页
* @param count 每页数量
* @return
*/
public PageInfo<DeviceChannel> queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, Boolean catalogUnderDevice, int page, int count);
public List<DeviceChannelExtend> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, List<String> channelIds, String query, Boolean hasSubChannel, Boolean online, int start, int limit);
/**
* 获取某个设备的通道列表
*
* @param deviceId 设备ID
* @return
*/
public List<DeviceChannel> queryChannelsByDeviceId(String deviceId,Boolean online,List<String> channelIds);
public List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId);
/**
* 获取某个设备的通道
* @param deviceId 设备ID
* @param channelId 通道ID
*/
public DeviceChannel queryChannel(String deviceId, String channelId);
/**
* 删除通道
* @param deviceId 设备ID
* @param channelId 通道ID
*/
public int delChannel(String deviceId, String channelId);
/**
* 获取多个设备
* @param page 当前页数
* @param count 每页数量
* @return List<Device> 设备对象数组
*/
public PageInfo<Device> queryVideoDeviceList(int page, int count,Boolean online);
/**
* 获取多个设备
*
* @return List<Device> 设备对象数组
*/
public List<Device> queryVideoDeviceList(Boolean online);
/**
* 查询子设备
*
* @param deviceId
* @param channelId
* @param page
* @param count
* @return
*/
PageInfo querySubChannels(String deviceId, String channelId, String query, Boolean hasSubChannel, Boolean online, int page, int count);
/**
* 清空通道
* @param deviceId
*/
void cleanChannelsForDevice(String deviceId);
/**
* 更新上级平台
* @param parentPlatform
*/
boolean updateParentPlatform(ParentPlatform parentPlatform);
/**
* 添加上级平台
* @param parentPlatform
*/
boolean addParentPlatform(ParentPlatform parentPlatform);
/**
* 删除上级平台
* @param parentPlatform
*/
boolean deleteParentPlatform(ParentPlatform parentPlatform);
/**
* 获取所有已启用的平台
* @return
*/
List<ParentPlatform> queryEnableParentPlatformList(boolean enable);
/**
* 获取上级平台
* @param platformGbId
* @return
*/
ParentPlatform queryParentPlatByServerGBId(String platformGbId);
/**
* 所有平台离线
*/
void outlineForAllParentPlatform();
/**
* 查询通道信息,不区分设备(已关联平台或全部)
*/
PageInfo<ChannelReduce> queryAllChannelList(int page, int count, String query, Boolean online, Boolean channelType, String platformId, String catalogId);
/**
* 查询设备的通道信息
*/
List<DeviceChannelInPlatform> queryChannelListInParentPlatform(String platformId);
/**
* 移除上级平台的通道信息
* @param platformId
* @param channelReduces
* @return
*/
int delChannelForGB(String platformId, List<ChannelReduce> channelReduces);
DeviceChannel queryChannelInParentPlatform(String platformId, String channelId);
List<PlatformCatalog> queryChannelInParentPlatformAndCatalog(String platformId, String catalogId);
List<PlatformCatalog> queryStreamInParentPlatformAndCatalog(String platformId, String catalogId);
Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId);
/**
* 针对deviceinfo指令的查询接口
* @param platformId 平台id
* @param channelId 通道id
* @return 设备信息
*/
Device queryDeviceInfoByPlatformIdAndChannelId(String platformId, String channelId);
/**
* 添加Mobile Position设备移动位置
* @param mobilePosition
* @return
*/
public boolean insertMobilePosition(MobilePosition mobilePosition);
/**
* 查询移动位置轨迹
* @param deviceId
* @param startTime
* @param endTime
*/
public List<MobilePosition> queryMobilePositions(String deviceId, String channelId, String startTime, String endTime);
/**
* 查询最新移动位置
* @param deviceId
*/
public MobilePosition queryLatestPosition(String deviceId);
/**
* 删除指定设备的所有移动位置
* @param deviceId
*/
public int clearMobilePositionsByDeviceId(String deviceId);
/**
* 移除代理流
* @param app
* @param stream
* @return
*/
public int deleteStreamProxy(String app, String stream);
/**
* 按照是否启用获取代理流
* @param enable
* @return
*/
public List<StreamProxyItem> getStreamProxyListForEnable(boolean enable);
/**
* 按照是app和stream获取代理流
* @param app
* @param stream
* @return
*/
public StreamProxyItem queryStreamProxy(String app, String stream);
/**
* 获取代理流
* @param page
* @param count
* @return
*/
PageInfo<StreamProxyItem> queryStreamProxyList(Integer page, Integer count);
/**
* 根据国标ID获取平台关联的直播流
* @param platformId
* @param channelId
* @return
*/
GbStream queryStreamInParentPlatform(String platformId, String channelId);
/**
* 获取平台关联的直播流
* @param platformId
* @return
*/
List<DeviceChannel> queryGbStreamListInPlatform(String platformId);
/**
* 移除单个推流
* @param app
* @param stream
*/
int removeMedia(String app, String stream);
/**
* 设置流离线
*/
int mediaOffline(String app, String streamId);
/**
* 设置流上线
*/
int mediaOnline(String app, String streamId);
/**
* 设置平台在线/离线
*/
void updateParentPlatformStatus(String platformGbID, boolean online);
/**
* 根据媒体ID获取启用/不启用的代理列表
* @param id 媒体ID
* @param enable 启用/不启用
* @return
*/
List<StreamProxyItem> getStreamProxyListForEnableInMediaServer(String id, boolean enable);
/**
* 根据通道ID获取其所在设备
* @param channelId 通道ID
* @return
*/
Device queryVideoDeviceByChannelId(String channelId);
/**
* 通道上线
* @param channelId 通道ID
*/
void deviceChannelOnline(String deviceId, String channelId);
/**
* 通道离线
* @param channelId 通道ID
*/
void deviceChannelOffline(String deviceId, String channelId);
/**
* 通过app与stream获取StreamProxy
* @param app
* @param streamId
* @return
*/
StreamProxyItem getStreamProxyByAppAndStream(String app, String streamId);
/**
* catlog查询结束后完全重写通道信息
* @param deviceId
* @param deviceChannelList
*/
boolean resetChannels(String deviceId, List<DeviceChannel> deviceChannelList);
boolean updateChannels(String deviceId, List<DeviceChannel> deviceChannelList);
/**
* 获取目录信息
* @param platformId
* @param parentId
* @return
*/
List<PlatformCatalog> getChildrenCatalogByPlatform(String platformId, String parentId);
int addCatalog(PlatformCatalog platformCatalog);
PlatformCatalog getCatalog(String platformId, String id);
int delCatalog(String platformId, String id);
int updateCatalog(PlatformCatalog platformCatalog);
int setDefaultCatalog(String platformId, String catalogId);
List<DeviceChannel> queryCatalogInPlatform(String serverGBId);
int delRelation(PlatformCatalog platformCatalog);
int updateStreamGPS(List<GPSMsgInfo> gpsMsgInfo);
List<ParentPlatform> queryPlatFormListForGBWithGBId(String channelId, List<String> platforms);
List<ParentPlatform> queryPlatFormListForStreamWithGBId(String app, String stream, List<String> platforms);
GbStream getGbStream(String app, String streamId);
void delCatalogByPlatformId(String serverGBId);
void delRelationByPlatformId(String serverGBId);
PlatformCatalog queryDefaultCatalogInPlatform(String platformId);
List<ChannelSourceInfo> getChannelSource(String platformId, String gbId);
void updateChannelPosition(DeviceChannel deviceChannel);
void cleanContentForPlatform(String serverGBId);
List<DeviceChannel> queryChannelWithCatalog(String serverGBId);
List<DeviceChannelExtend> queryChannelsByDeviceId(String serial, List<String> channelIds, Boolean online);
List<ParentPlatform> queryEnablePlatformListWithAsMessageChannel();
List<Device> queryDeviceWithAsMessageChannel();
}

View File

@@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.service.bean.CloudRecordItem;
import org.apache.ibatis.annotations.*;
import java.util.List;
import java.util.Set;
@Mapper
public interface CloudRecordServiceMapper {
@@ -21,6 +22,7 @@ public interface CloudRecordServiceMapper {
" folder," +
" file_path," +
" file_size," +
" server_id," +
" time_len ) " +
"VALUES (" +
" #{app}," +
@@ -33,6 +35,7 @@ public interface CloudRecordServiceMapper {
" #{folder}," +
" #{filePath}," +
" #{fileSize}," +
" #{serverId}," +
" #{timeLen})" +
" </script>")
int add(CloudRecordItem cloudRecordItem);
@@ -40,8 +43,8 @@ public interface CloudRecordServiceMapper {
@Select(" <script>" +
"select * " +
" from wvp_cloud_record " +
" where 0 = 0" +
" <if test='query != null'> AND (app LIKE concat('%',#{query},'%') OR stream LIKE concat('%',#{query},'%') )</if> " +
" where 1 = 1" +
" <if test='query != null'> AND (app LIKE concat('%',#{query},'%') escape '/' OR stream LIKE concat('%',#{query},'%') escape '/' )</if> " +
" <if test= 'app != null '> and app=#{app}</if>" +
" <if test= 'stream != null '> and stream=#{stream}</if>" +
" <if test= 'startTimeStamp != null '> and end_time &gt;= #{startTimeStamp}</if>" +
@@ -53,12 +56,13 @@ public interface CloudRecordServiceMapper {
" <if test= 'ids != null ' > and id in " +
" <foreach collection='ids' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
" </if>" +
" order by start_time DESC" +
" <if test= 'ascOrder != null and ascOrder == true'> order by start_time asc</if>" +
" <if test= 'ascOrder == null or ascOrder == false'> order by start_time desc</if>" +
" </script>")
List<CloudRecordItem> getList(@Param("query") String query, @Param("app") String app, @Param("stream") String stream,
@Param("startTimeStamp")Long startTimeStamp, @Param("endTimeStamp")Long endTimeStamp,
@Param("callId")String callId, List<MediaServer> mediaServerItemList,
List<Integer> ids);
List<Integer> ids, @Param("ascOrder") Boolean ascOrder);
@Select(" <script>" +
@@ -134,4 +138,26 @@ public interface CloudRecordServiceMapper {
"update wvp_cloud_record set time_len = #{time}, end_time = #{endTime} where id = #{id} " +
" </script>")
void updateTimeLen(@Param("id") int id, @Param("time") Long time, @Param("endTime") long endTime);
@Select(" <script>" +
"select media_server_id " +
" from wvp_cloud_record " +
" where 0 = 0" +
" <if test= 'app != null '> and app=#{app}</if>" +
" <if test= 'stream != null '> and stream=#{stream}</if>" +
" <if test= 'startTimeStamp != null '> and end_time &gt;= #{startTimeStamp}</if>" +
" <if test= 'endTimeStamp != null '> and start_time &lt;= #{endTimeStamp}</if>" +
" group by media_server_id" +
" </script>")
List<String> queryMediaServerId(@Param("app") String app,
@Param("stream") String stream,
@Param("startTimeStamp")Long startTimeStamp,
@Param("endTimeStamp")Long endTimeStamp);
@Select(" <script>" +
"select * " +
" from wvp_cloud_record where id in " +
" <foreach collection='ids' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
" </script>")
List<CloudRecordItem> queryRecordByIds(Set<Integer> ids);
}

View File

@@ -1,50 +0,0 @@
package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 用于存储设备的报警信息
*/
@Mapper
@Repository
public interface DeviceAlarmMapper {
@Insert("INSERT INTO wvp_device_alarm (device_id, channel_id, alarm_priority, alarm_method, alarm_time, alarm_description, longitude, latitude, alarm_type , create_time ) " +
"VALUES (#{deviceId}, #{channelId}, #{alarmPriority}, #{alarmMethod}, #{alarmTime}, #{alarmDescription}, #{longitude}, #{latitude}, #{alarmType}, #{createTime})")
int add(DeviceAlarm alarm);
@Select( value = {" <script>" +
" SELECT * FROM wvp_device_alarm " +
" WHERE 1=1 " +
" <if test=\"deviceId != null\" > AND device_id = #{deviceId}</if>" +
" <if test=\"alarmPriority != null\" > AND alarm_priority = #{alarmPriority} </if>" +
" <if test=\"alarmMethod != null\" > AND alarm_method = #{alarmMethod} </if>" +
" <if test=\"alarmType != null\" > AND alarm_type = #{alarmType} </if>" +
" <if test=\"startTime != null\" > AND alarm_time &gt;= #{startTime} </if>" +
" <if test=\"endTime != null\" > AND alarm_time &lt;= #{endTime} </if>" +
" ORDER BY alarm_time ASC " +
" </script>"})
List<DeviceAlarm> query(@Param("deviceId") String deviceId, @Param("alarmPriority") String alarmPriority, @Param("alarmMethod") String alarmMethod,
@Param("alarmType") String alarmType, @Param("startTime") String startTime, @Param("endTime") String endTime);
@Delete(" <script>" +
"DELETE FROM wvp_device_alarm WHERE 1=1 " +
" <if test=\"deviceIdList != null and id == null \" > AND device_id in " +
"<foreach collection='deviceIdList' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
"</if>" +
" <if test=\"time != null and id == null \" > AND alarm_time &lt;= #{time}</if>" +
" <if test=\"id != null\" > AND id = #{id}</if>" +
" </script>"
)
int clearAlarmBeforeTime(@Param("id") Integer id, @Param("deviceIdList") List<String> deviceIdList, @Param("time") String time);
}

View File

@@ -1,578 +0,0 @@
package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannelInPlatform;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 用于存储设备通道信息
*/
@Mapper
@Repository
public interface DeviceChannelMapper {
@Insert("INSERT INTO wvp_device_channel (channel_id, device_id, name, manufacture, model, owner, civil_code, block, " +
"address, parental, parent_id, safety_way, register_way, cert_num, certifiable, err_code, secrecy, " +
"ip_address, port, password, ptz_type, status, stream_id, longitude, latitude, longitude_gcj02, latitude_gcj02, " +
"longitude_wgs84, latitude_wgs84, has_audio, create_time, update_time, business_group_id, gps_time, stream_identification) " +
"VALUES (#{channelId}, #{deviceId}, #{name}, #{manufacture}, #{model}, #{owner}, #{civilCode}, #{block}," +
"#{address}, #{parental}, #{parentId}, #{safetyWay}, #{registerWay}, #{certNum}, #{certifiable}, #{errCode}, #{secrecy}, " +
"#{ipAddress}, #{port}, #{password}, #{ptzType}, #{status}, #{streamId}, #{longitude}, #{latitude}, #{longitudeGcj02}, " +
"#{latitudeGcj02}, #{longitudeWgs84}, #{latitudeWgs84}, #{hasAudio}, #{createTime}, #{updateTime}, #{businessGroupId}, #{gpsTime}, #{streamIdentification})")
int add(DeviceChannel channel);
@Update(value = {" <script>" +
"UPDATE wvp_device_channel " +
"SET update_time=#{updateTime}" +
", custom_name=#{name}" +
"<if test='manufacture != null'>, manufacture=#{manufacture}</if>" +
"<if test='model != null'>, model=#{model}</if>" +
"<if test='owner != null'>, owner=#{owner}</if>" +
"<if test='civilCode != null'>, civil_code=#{civilCode}</if>" +
"<if test='block != null'>, block=#{block}</if>" +
"<if test='address != null'>, address=#{address}</if>" +
"<if test='parental != null'>, parental=#{parental}</if>" +
"<if test='parentId != null'>, parent_id=#{parentId}</if>" +
"<if test='safetyWay != null'>, safety_way=#{safetyWay}</if>" +
"<if test='registerWay != null'>, register_way=#{registerWay}</if>" +
"<if test='certNum != null'>, cert_num=#{certNum}</if>" +
"<if test='certifiable != null'>, certifiable=#{certifiable}</if>" +
"<if test='errCode != null'>, err_code=#{errCode}</if>" +
"<if test='secrecy != null'>, secrecy=#{secrecy}</if>" +
"<if test='ipAddress != null'>, ip_address=#{ipAddress}</if>" +
"<if test='port != null'>, port=#{port}</if>" +
"<if test='password != null'>, password=#{password}</if>" +
"<if test='ptzType != null'>, custom_ptz_type=#{ptzType}</if>" +
"<if test='status != null'>, status=#{status}</if>" +
"<if test='streamId != null'>, stream_id=#{streamId}</if>" +
"<if test='hasAudio != null'>, has_audio=#{hasAudio}</if>" +
"<if test='customLongitude != null'>, custom_longitude=#{customLongitude}</if>" +
"<if test='customLatitude != null'>, custom_latitude=#{customLatitude}</if>" +
"<if test='longitudeGcj02 != null'>, longitude_gcj02=#{longitudeGcj02}</if>" +
"<if test='latitudeGcj02 != null'>, latitude_gcj02=#{latitudeGcj02}</if>" +
"<if test='longitudeWgs84 != null'>, longitude_wgs84=#{longitudeWgs84}</if>" +
"<if test='latitudeWgs84 != null'>, latitude_wgs84=#{latitudeWgs84}</if>" +
"<if test='businessGroupId != null'>, business_group_id=#{businessGroupId}</if>" +
"<if test='gpsTime != null'>, gps_time=#{gpsTime}</if>" +
"<if test='streamIdentification != null'>, stream_identification=#{streamIdentification}</if>" +
"WHERE device_id=#{deviceId} AND channel_id=#{channelId}"+
" </script>"})
int update(DeviceChannel channel);
@Select(value = {" <script>" +
"SELECT " +
"dc.id, " +
"dc.channel_id, " +
"COALESCE(dc.custom_name, dc.name) AS name, " +
"dc.manufacture, " +
"dc.model, " +
"dc.owner, " +
"dc.civil_code, " +
"dc.block, " +
"dc.address, " +
"dc.parent_id, " +
"dc.safety_way, " +
"dc.register_way, " +
"dc.cert_num, " +
"dc.certifiable, " +
"dc.err_code, " +
"dc.end_time, " +
"dc.secrecy, " +
"dc.ip_address, " +
"dc.port, " +
"dc.password, " +
"COALESCE(dc.custom_ptz_type, dc.ptz_type) AS ptz_type, " +
"dc.status, " +
"dc.longitude, " +
"dc.latitude, " +
"dc.custom_longitude, " +
"dc.custom_latitude, " +
"dc.stream_id, " +
"dc.device_id, " +
"dc.parental, " +
"dc.has_audio, " +
"dc.create_time, " +
"dc.update_time, " +
"dc.sub_count, " +
"dc.longitude_gcj02, " +
"dc.latitude_gcj02, " +
"dc.longitude_wgs84, " +
"dc.latitude_wgs84, " +
"dc.business_group_id, " +
"dc.stream_identification, " +
"dc.gps_time " +
"from " +
"wvp_device_channel dc " +
"WHERE " +
"dc.device_id = #{deviceId} " +
" <if test='query != null'> AND (" +
"dc.channel_id LIKE concat('%',#{query},'%') " +
"OR dc.name LIKE concat('%',#{query},'%') " +
"OR dc.custom_name LIKE concat('%',#{query},'%')" +
")</if> " +
" <if test='parentChannelId != null'> AND (dc.parent_id=#{parentChannelId} OR dc.civil_code = #{parentChannelId}) </if> " +
" <if test='online == true' > AND dc.status= true</if>" +
" <if test='online == false' > AND dc.status= false</if>" +
" <if test='hasSubChannel == true' > AND dc.sub_count > 0 </if>" +
" <if test='hasSubChannel == false' > AND dc.sub_count = 0 </if>" +
"<if test='channelIds != null'> AND dc.channel_id in <foreach item='item' index='index' collection='channelIds' open='(' separator=',' close=')'>" +
"#{item} " +
"</foreach> </if>" +
"ORDER BY dc.channel_id " +
" </script>"})
List<DeviceChannel> queryChannels(@Param("deviceId") String deviceId, @Param("parentChannelId") String parentChannelId, @Param("query") String query, @Param("hasSubChannel") Boolean hasSubChannel, @Param("online") Boolean online, @Param("channelIds") List<String> channelIds);
@Select(value = {" <script>" +
"SELECT " +
"dc.*, " +
"de.name as device_name, " +
"de.on_line as device_online " +
"from " +
"wvp_device_channel dc " +
"LEFT JOIN wvp_device de ON dc.device_id = de.device_id " +
"WHERE 1=1" +
" <if test='deviceId != null'> AND dc.device_id = #{deviceId} </if> " +
" <if test='query != null'> AND (dc.channel_id LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
" <if test='parentChannelId != null'> AND dc.parent_id=#{parentChannelId} </if> " +
" <if test='online == true' > AND dc.status=true</if>" +
" <if test='online == false' > AND dc.status=false</if>" +
" <if test='hasSubChannel == true' > AND dc.sub_count > 0 </if>" +
" <if test='hasSubChannel == false' > AND dc.sub_count = 0 </if>" +
"<if test='channelIds != null'> AND dc.channel_id in <foreach item='item' index='index' collection='channelIds' open='(' separator=',' close=')'>" +
"#{item} " +
"</foreach> </if>" +
"ORDER BY dc.channel_id ASC" +
" </script>"})
List<DeviceChannelExtend> queryChannelsWithDeviceInfo(@Param("deviceId") String deviceId, @Param("parentChannelId") String parentChannelId, @Param("query") String query, @Param("hasSubChannel") Boolean hasSubChannel, @Param("online") Boolean online, @Param("channelIds") List<String> channelIds);
@Select(value = {" <script>" +
"SELECT " +
"dc.*, " +
"de.name as device_name, " +
"de.on_line as device_online " +
"from " +
"wvp_device_channel dc " +
"LEFT JOIN wvp_device de ON dc.device_id = de.device_id " +
"WHERE 1=1" +
" <if test='deviceId != null'> AND dc.device_id = #{deviceId} </if> " +
" <if test='query != null'> AND (dc.channel_id LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
" <if test='parentChannelId != null'> AND dc.parent_id=#{parentChannelId} </if> " +
" <if test='online == true' > AND dc.status=true</if>" +
" <if test='online == false' > AND dc.status=false</if>" +
" <if test='hasSubChannel == true' > AND dc.sub_count > 0 </if>" +
" <if test='hasSubChannel == false' > AND dc.sub_count = 0 </if>" +
"<if test='channelIds != null'> AND dc.channel_id in <foreach item='item' index='index' collection='channelIds' open='(' separator=',' close=')'>" +
"#{item} " +
"</foreach> </if>" +
"ORDER BY dc.channel_id ASC " +
"Limit #{limit} OFFSET #{start}" +
" </script>"})
List<DeviceChannelExtend> queryChannelsByDeviceIdWithStartAndLimit(@Param("deviceId") String deviceId, @Param("channelIds") List<String> channelIds, @Param("parentChannelId") String parentChannelId, @Param("query") String query, @Param("hasSubChannel") Boolean hasSubChannel, @Param("online") Boolean online, @Param("start") int start, @Param("limit") int limit);
@Select("SELECT * FROM wvp_device_channel WHERE device_id=#{deviceId} AND channel_id=#{channelId}")
DeviceChannel queryChannel(@Param("deviceId") String deviceId,@Param("channelId") String channelId);
@Delete("DELETE FROM wvp_device_channel WHERE device_id=#{deviceId}")
int cleanChannelsByDeviceId(@Param("deviceId") String deviceId);
@Delete("DELETE FROM wvp_device_channel WHERE device_id=#{deviceId} AND channel_id=#{channelId}")
int del(@Param("deviceId") String deviceId, @Param("channelId") String channelId);
@Update(value = {"UPDATE wvp_device_channel SET stream_id=null WHERE device_id=#{deviceId} AND channel_id=#{channelId}"})
void stopPlay(@Param("deviceId") String deviceId, @Param("channelId") String channelId);
@Update(value = {"UPDATE wvp_device_channel SET stream_id=#{streamId} WHERE device_id=#{deviceId} AND channel_id=#{channelId}"})
void startPlay(@Param("deviceId") String deviceId, @Param("channelId") String channelId, @Param("streamId") String streamId);
@Select(value = {" <script>" +
"SELECT " +
" dc.id,\n" +
" dc.channel_id,\n" +
" dc.device_id,\n" +
" COALESCE(dc.custom_name, dc.name) AS name,\n" +
" de.manufacturer,\n" +
" de.host_address,\n" +
" dc.sub_count,\n" +
" pgc.platform_id as platform_id,\n" +
" pgc.catalog_id as catalog_id " +
" FROM wvp_device_channel dc " +
" LEFT JOIN wvp_device de ON dc.device_id = de.device_id " +
" LEFT JOIN wvp_platform_gb_channel pgc on pgc.device_channel_id = dc.id " +
" WHERE 1=1 " +
" <if test='query != null'> AND (dc.channel_id LIKE concat('%',#{query},'%') OR dc.name LIKE concat('%',#{query},'%') OR dc.name LIKE concat('%',#{query},'%'))</if> " +
" <if test='online == true' > AND dc.status=true</if> " +
" <if test='online == false' > AND dc.status=false</if> " +
" <if test='hasSubChannel!= null and hasSubChannel == true' > AND dc.sub_count > 0</if> " +
" <if test='hasSubChannel!= null and hasSubChannel == false' > AND dc.sub_count = 0</if> " +
" <if test='catalogId == null ' > AND dc.id not in (select device_channel_id from wvp_platform_gb_channel where platform_id=#{platformId} ) </if> " +
" <if test='catalogId != null ' > AND pgc.platform_id = #{platformId} and pgc.catalog_id=#{catalogId} </if> " +
" ORDER BY dc.device_id, dc.channel_id ASC" +
" </script>"})
List<ChannelReduce> queryChannelListInAll(@Param("query") String query, @Param("online") Boolean online, @Param("hasSubChannel") Boolean hasSubChannel, @Param("platformId") String platformId, @Param("catalogId") String catalogId);
@Select(value = {" <script>" +
"SELECT " +
" dc.*,\n" +
" pgc.platform_id as platform_id,\n" +
" pgc.catalog_id as catalog_id " +
" FROM wvp_device_channel dc " +
" LEFT JOIN wvp_platform_gb_channel pgc on pgc.device_channel_id = dc.id " +
" WHERE pgc.platform_id = #{platformId} " +
" ORDER BY dc.device_id, dc.channel_id ASC" +
" </script>"})
List<DeviceChannelInPlatform> queryChannelByPlatformId(String platformId);
@Select("SELECT * FROM wvp_device_channel WHERE channel_id=#{channelId}")
List<DeviceChannel> queryChannelByChannelId( String channelId);
@Update(value = {"UPDATE wvp_device_channel SET status=false WHERE device_id=#{deviceId} AND channel_id=#{channelId}"})
void offline(@Param("deviceId") String deviceId, @Param("channelId") String channelId);
@Update(value = {"UPDATE wvp_device_channel SET status=false WHERE device_id=#{deviceId}"})
void offlineByDeviceId(String deviceId);
@Insert("<script> " +
"insert into wvp_device_channel " +
"(channel_id, device_id, name, manufacture, model, owner, civil_code, block, sub_count, " +
" address, parental, parent_id, safety_way, register_way, cert_num, certifiable, err_code, secrecy, " +
" ip_address,port,password,ptz_type,status,stream_id,longitude,latitude,longitude_gcj02,latitude_gcj02,"+
" longitude_wgs84,latitude_wgs84,has_audio,create_time,update_time,business_group_id,gps_time,stream_identification)"+
"values " +
"<foreach collection='addChannels' index='index' item='item' separator=','> " +
"(#{item.channelId}, #{item.deviceId}, #{item.name}, #{item.manufacture}, #{item.model}, " +
"#{item.owner}, #{item.civilCode}, #{item.block},#{item.subCount}," +
"#{item.address}, #{item.parental}, #{item.parentId}, #{item.safetyWay}, #{item.registerWay}, " +
"#{item.certNum}, #{item.certifiable}, #{item.errCode}, #{item.secrecy}, " +
"#{item.ipAddress}, #{item.port}, #{item.password}, #{item.ptzType}, #{item.status}, " +
"#{item.streamId}, #{item.longitude}, #{item.latitude},#{item.longitudeGcj02}, " +
"#{item.latitudeGcj02},#{item.longitudeWgs84}, #{item.latitudeWgs84}, #{item.hasAudio}, now(), now(), " +
"#{item.businessGroupId}, #{item.gpsTime}, #{item.streamIdentification}) " +
"</foreach> " +
"</script>")
int batchAdd(@Param("addChannels") List<DeviceChannel> addChannels);
@Insert("<script> " +
"insert into wvp_device_channel " +
"(channel_id,device_id,name,manufacture,model,owner,civil_code,block,sub_count,"+
" address,parental,parent_id,safety_way,register_way,cert_num,certifiable,err_code,secrecy,"+
" ip_address,port,password,ptz_type,status,stream_id,longitude,latitude,longitude_gcj02,latitude_gcj02,"+
" longitude_wgs84,latitude_wgs84,has_audio,create_time,update_time,business_group_id,gps_time)"+
"values " +
"<foreach collection='addChannels' index='index' item='item' separator=','> " +
"(#{item.channelId}, #{item.deviceId}, #{item.name}, #{item.manufacture}, #{item.model}, " +
"#{item.owner}, #{item.civilCode}, #{item.block},#{item.subCount}," +
"#{item.address}, #{item.parental}, #{item.parentId}, #{item.safetyWay}, #{item.registerWay}, " +
"#{item.certNum}, #{item.certifiable}, #{item.errCode}, #{item.secrecy}, " +
"#{item.ipAddress}, #{item.port}, #{item.password}, #{item.ptzType}, #{item.status}, " +
"#{item.streamId}, #{item.longitude}, #{item.latitude},#{item.longitudeGcj02}, " +
"#{item.latitudeGcj02},#{item.longitudeWgs84}, #{item.latitudeWgs84}, #{item.hasAudio}, now(), now(), " +
"#{item.businessGroupId}, #{item.gpsTime}) " +
"</foreach> " +
"ON DUPLICATE KEY UPDATE " +
"update_time=VALUES(update_time), " +
"name=VALUES(name), " +
"manufacture=VALUES(manufacture), " +
"model=VALUES(model), " +
"owner=VALUES(owner), " +
"civil_code=VALUES(civil_code), " +
"block=VALUES(block), " +
"sub_count=VALUES(sub_count), " +
"address=VALUES(address), " +
"parental=VALUES(parental), " +
"parent_id=VALUES(parent_id), " +
"safety_way=VALUES(safety_way), " +
"register_way=VALUES(register_way), " +
"cert_num=VALUES(cert_num), " +
"certifiable=VALUES(certifiable), " +
"err_code=VALUES(err_code), " +
"secrecy=VALUES(secrecy), " +
"ip_address=VALUES(ip_address), " +
"port=VALUES(port), " +
"password=VALUES(password), " +
"ptz_type=VALUES(ptz_type), " +
"status=VALUES(status), " +
"stream_id=VALUES(stream_id), " +
"longitude=VALUES(longitude), " +
"latitude=VALUES(latitude), " +
"longitude_gcj02=VALUES(longitude_gcj02), " +
"latitude_gcj02=VALUES(latitude_gcj02), " +
"longitude_wgs84=VALUES(longitude_wgs84), " +
"latitude_wgs84=VALUES(latitude_wgs84), " +
"has_audio=VALUES(has_audio), " +
"business_group_id=VALUES(business_group_id), " +
"gps_time=VALUES(gps_time)" +
"</script>")
int batchAddOrUpdate(List<DeviceChannel> addChannels);
@Update(value = {"UPDATE wvp_device_channel SET status=true WHERE device_id=#{deviceId} AND channel_id=#{channelId}"})
void online(@Param("deviceId") String deviceId, @Param("channelId") String channelId);
@Update({"<script>" +
"<foreach collection='updateChannels' item='item' separator=';'>" +
" UPDATE" +
" wvp_device_channel" +
" SET update_time=#{item.updateTime}" +
"<if test='item.name != null'>, name=#{item.name}</if>" +
"<if test='item.manufacture != null'>, manufacture=#{item.manufacture}</if>" +
"<if test='item.model != null'>, model=#{item.model}</if>" +
"<if test='item.owner != null'>, owner=#{item.owner}</if>" +
"<if test='item.civilCode != null'>, civil_code=#{item.civilCode}</if>" +
"<if test='item.block != null'>, block=#{item.block}</if>" +
"<if test='item.subCount != null'>, sub_count=#{item.subCount}</if>" +
"<if test='item.address != null'>, address=#{item.address}</if>" +
"<if test='item.parental != null'>, parental=#{item.parental}</if>" +
"<if test='item.parentId != null'>, parent_id=#{item.parentId}</if>" +
"<if test='item.safetyWay != null'>, safety_way=#{item.safetyWay}</if>" +
"<if test='item.registerWay != null'>, register_way=#{item.registerWay}</if>" +
"<if test='item.certNum != null'>, cert_num=#{item.certNum}</if>" +
"<if test='item.certifiable != null'>, certifiable=#{item.certifiable}</if>" +
"<if test='item.errCode != null'>, err_code=#{item.errCode}</if>" +
"<if test='item.secrecy != null'>, secrecy=#{item.secrecy}</if>" +
"<if test='item.ipAddress != null'>, ip_address=#{item.ipAddress}</if>" +
"<if test='item.port != null'>, port=#{item.port}</if>" +
"<if test='item.password != null'>, password=#{item.password}</if>" +
"<if test='item.ptzType != null'>, ptz_type=#{item.ptzType}</if>" +
"<if test='item.status != null'>, status=#{item.status}</if>" +
"<if test='item.streamId != null'>, stream_id=#{item.streamId}</if>" +
"<if test='item.hasAudio != null'>, has_audio=#{item.hasAudio}</if>" +
"<if test='item.longitude != null'>, longitude=#{item.longitude}</if>" +
"<if test='item.latitude != null'>, latitude=#{item.latitude}</if>" +
"<if test='item.customLongitude != null'>, custom_longitude=#{item.customLongitude}</if>" +
"<if test='item.customLatitude != null'>, custom_latitude=#{item.customLatitude}</if>" +
"<if test='item.longitudeGcj02 != null'>, longitude_gcj02=#{item.longitudeGcj02}</if>" +
"<if test='item.latitudeGcj02 != null'>, latitude_gcj02=#{item.latitudeGcj02}</if>" +
"<if test='item.longitudeWgs84 != null'>, longitude_wgs84=#{item.longitudeWgs84}</if>" +
"<if test='item.latitudeWgs84 != null'>, latitude_wgs84=#{item.latitudeWgs84}</if>" +
"<if test='item.businessGroupId != null'>, business_group_id=#{item.businessGroupId}</if>" +
"<if test='item.gpsTime != null'>, gps_time=#{item.gpsTime}</if>" +
"<if test='item.streamIdentification != null'>, stream_identification=#{item.streamIdentification}</if>" +
"<if test='item.id > 0'>WHERE id=#{item.id}</if>" +
"<if test='item.id == 0 and item.channelId != null '>WHERE device_id=#{item.deviceId} AND channel_id=#{item.channelId}</if>" +
"<if test='item.id == 0 and item.channelId == null '>WHERE device_id=#{item.deviceId}</if>" +
"</foreach>" +
"</script>"})
int batchUpdate(List<DeviceChannel> updateChannels);
@Select("SELECT * FROM wvp_device_channel WHERE device_id=#{deviceId} AND status=true")
List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId);
@Delete(value = {" <script>" +
"DELETE " +
"from " +
"wvp_device_channel " +
"WHERE " +
"device_id = #{deviceId} " +
" AND channel_id NOT IN " +
"<foreach collection='channels' item='item' open='(' separator=',' close=')' > #{item.channelId}</foreach>" +
" </script>"})
int cleanChannelsNotInList(@Param("deviceId") String deviceId, @Param("channels") List<DeviceChannel> channels);
@Update(" update wvp_device_channel" +
" set sub_count = (select *" +
" from (select count(0)" +
" from wvp_device_channel" +
" where device_id = #{deviceId} and parent_id = #{channelId}) as temp)" +
" where device_id = #{deviceId} " +
" and channel_id = #{channelId}")
int updateChannelSubCount(@Param("deviceId") String deviceId, @Param("channelId") String channelId);
@Update(value = {" <script>" +
"UPDATE wvp_device_channel " +
"SET " +
"latitude=#{latitude}, " +
"longitude=#{longitude}, " +
"longitude_gcj02=#{longitudeGcj02}, " +
"latitude_gcj02=#{latitudeGcj02}, " +
"longitude_wgs84=#{longitudeWgs84}, " +
"latitude_wgs84=#{latitudeWgs84}, " +
"gps_time=#{gpsTime} " +
"WHERE device_id=#{deviceId} " +
" <if test='channelId != null' > AND channel_id=#{channelId}</if>" +
" </script>"})
int updatePosition(DeviceChannel deviceChannel);
@Select("SELECT * FROM wvp_device_channel WHERE length(trim(stream_id)) > 0")
List<DeviceChannel> getAllChannelInPlay();
@Select("select * from wvp_device_channel where longitude*latitude > 0 and device_id = #{deviceId}")
List<DeviceChannel> getAllChannelWithCoordinate(String deviceId);
@Select(value = {" <script>" +
"select * " +
"from wvp_device_channel " +
"where device_id=#{deviceId}" +
" <if test='parentId != null and length != null' > and parent_id= #{parentId} or left(channel_id, LENGTH(#{parentId})) = #{parentId} and length(channel_id)=#{length} </if>" +
" <if test='parentId == null and length != null' > and parent_id= #{parentId} or length(channel_id)=#{length} </if>" +
" <if test='parentId == null and length == null' > and parent_id= #{parentId} </if>" +
" <if test='parentId != null and length == null' > and parent_id= #{parentId} or left(channel_id, LENGTH(#{parentId})) = #{parentId} </if>" +
" </script>"})
List<DeviceChannel> getChannelsWithCivilCodeAndLength(@Param("deviceId") String deviceId, @Param("parentId") String parentId, @Param("length") Integer length);
@Select(value = {" <script>" +
"select * " +
"from wvp_device_channel " +
"where device_id=#{deviceId} and length(channel_id)>14 and civil_code=#{parentId}" +
" </script>"})
List<DeviceChannel> getChannelsByCivilCode(@Param("deviceId") String deviceId, @Param("parentId") String parentId);
@Select("select min(length(channel_id)) as minLength " +
"from wvp_device_channel " +
"where device_id=#{deviceId}")
Integer getChannelMinLength(String deviceId);
@Select("select * from wvp_device_channel where device_id=#{deviceId} and civil_code not in " +
"(select civil_code from wvp_device_channel where device_id=#{deviceId} group by civil_code)")
List<DeviceChannel> getChannelWithoutCivilCode(String deviceId);
@Select("select * from wvp_device_channel where device_id=#{deviceId} and SUBSTRING(channel_id, 11, 3)=#{typeCode}")
List<DeviceChannel> getBusinessGroups(@Param("deviceId") String deviceId, @Param("typeCode") String typeCode);
@Select("select dc.id, dc.channel_id, dc.device_id, COALESCE(dc.custom_name, dc.name) AS name, dc.manufacture,dc.model,dc.owner, pc.civil_code,dc.block, " +
" dc.address, '0' as parental,'0' as channel_type, pc.id as parent_id, dc.safety_way, dc.register_way,dc.cert_num, dc.certifiable, " +
" dc.err_code,dc.end_time, dc.secrecy, dc.ip_address, dc.port, COALESCE(dc.custom_ptz_type, dc.ptz_type) AS ptz_type, dc.password, dc.status, " +
" COALESCE(dc.custom_longitude, dc.longitude) AS longitude, COALESCE(dc.custom_latitude, dc.latitude) AS latitude, pc.business_group_id " +
" from wvp_device_channel dc" +
" LEFT JOIN wvp_platform_gb_channel pgc on dc.id = pgc.device_channel_id" +
" LEFT JOIN wvp_platform_catalog pc on pgc.catalog_id = pc.id and pgc.platform_id = pc.platform_id" +
" where pgc.platform_id=#{serverGBId}")
List<DeviceChannel> queryChannelWithCatalog(String serverGBId);
@Select("select * from wvp_device_channel where device_id = #{deviceId}")
List<DeviceChannel> queryAllChannels(String deviceId);
@Select("select channelId" +
", device_id" +
", latitude" +
", longitude"+
",latitude_wgs84"+
",longitude_wgs84"+
",latitude_gcj02"+
",longitude_gcj02"+
"from wvp_device_channel where device_id = #{deviceId} " +
"and latitude != 0 " +
"and longitude != 0 " +
"and(latitude_gcj02=0 or latitude_wgs84=0 or longitude_wgs84= 0 or longitude_gcj02 = 0)")
List<DeviceChannel> getChannelsWithoutTransform(String deviceId);
@Select("select de.* from wvp_device de left join wvp_device_channel dc on de.device_id = dc.deviceId where dc.channel_id=#{channelId}")
List<Device> getDeviceByChannelId(String channelId);
@Delete({"<script>" +
"<foreach collection='deleteChannelList' item='item' separator=';'>" +
"DELETE FROM wvp_device_channel WHERE device_id=#{item.deviceId} AND channel_id=#{item.channelId}" +
"</foreach>" +
"</script>"})
int batchDel(@Param("deleteChannelList") List<DeviceChannel> deleteChannelList);
@Update({"<script>" +
"<foreach collection='channels' item='item' separator=';'>" +
"UPDATE wvp_device_channel SET status=true WHERE device_id=#{item.deviceId} AND channel_id=#{item.channelId}" +
"</foreach>" +
"</script>"})
int batchOnline(@Param("channels") List<DeviceChannel> channels);
@Update({"<script>" +
"<foreach collection='channels' item='item' separator=';'>" +
"UPDATE wvp_device_channel SET status= false WHERE device_id=#{item.deviceId} AND channel_id=#{item.channelId}" +
"</foreach>" +
"</script>"})
int batchOffline(List<DeviceChannel> channels);
@Select("select count(1) from wvp_device_channel where status = true")
int getOnlineCount();
@Select("select count(1) from wvp_device_channel")
int getAllChannelCount();
// 设备主子码流逻辑START
@Update(value = {"UPDATE wvp_device_channel SET stream_id=null WHERE device_id=#{deviceId}"})
void clearPlay(String deviceId);
// 设备主子码流逻辑END
@Select(value = {" <script>" +
"SELECT id,\n" +
" channel_id,\n" +
" COALESCE(custom_name, name) AS name,\n" +
" custom_name,\n" +
" manufacture,\n" +
" model,\n" +
" owner,\n" +
" civil_code,\n" +
" block,\n" +
" address,\n" +
" parent_id,\n" +
" safety_way,\n" +
" register_way,\n" +
" cert_num,\n" +
" certifiable,\n" +
" err_code,\n" +
" end_time,\n" +
" secrecy,\n" +
" ip_address,\n" +
" port,\n" +
" password,\n" +
" COALESCE(custom_ptz_type, ptz_type) AS ptz_type,\n" +
" status,\n" +
" COALESCE(custom_longitude, longitude) AS longitude,\n" +
" COALESCE(custom_latitude, latitude) AS latitude,\n" +
" stream_id,\n" +
" device_id,\n" +
" parental,\n" +
" has_audio,\n" +
" create_time,\n" +
" update_time,\n" +
" sub_count,\n" +
" longitude_gcj02,\n" +
" latitude_gcj02,\n" +
" longitude_wgs84,\n" +
" latitude_wgs84,\n" +
" business_group_id,\n" +
" gps_time\n" +
"from wvp_device_channel " +
"where device_id=#{deviceId}" +
" <if test='parentId != null and parentId != deviceId'> and parent_id = #{parentId} </if>" +
" <if test='parentId == null or parentId == deviceId'> and parent_id is null or parent_id = #{deviceId}</if>" +
" <if test='onlyCatalog == true '> and parental = 1 </if>" +
" </script>"})
List<DeviceChannel> getSubChannelsByDeviceId(@Param("deviceId") String deviceId, @Param("parentId") String parentId, @Param("onlyCatalog") boolean onlyCatalog);
@Update("<script>" +
"UPDATE wvp_device_channel SET stream_identification=#{streamIdentification} WHERE device_id=#{deviceId}" +
" <if test='channelId != null'> and channel_id = #{channelId} </if>" +
"</script>")
void updateChannelStreamIdentification(DeviceChannel channel);
@Update({"<script>" +
"<foreach collection='channelList' item='item' separator=';'>" +
" UPDATE" +
" wvp_device_channel" +
" SET update_time=#{item.updateTime}" +
"<if test='item.longitude != null'>, longitude=#{item.longitude}</if>" +
"<if test='item.latitude != null'>, latitude=#{item.latitude}</if>" +
"<if test='item.longitudeGcj02 != null'>, longitude_gcj02=#{item.longitudeGcj02}</if>" +
"<if test='item.latitudeGcj02 != null'>, latitude_gcj02=#{item.latitudeGcj02}</if>" +
"<if test='item.longitudeWgs84 != null'>, longitude_wgs84=#{item.longitudeWgs84}</if>" +
"<if test='item.latitudeWgs84 != null'>, latitude_wgs84=#{item.latitudeWgs84}</if>" +
"<if test='item.gpsTime != null'>, gps_time=#{item.gpsTime}</if>" +
"<if test='item.id > 0'>WHERE id=#{item.id}</if>" +
"<if test='item.id == 0'>WHERE device_id=#{item.deviceId} AND channel_id=#{item.channelId}</if>" +
"</foreach>" +
"</script>"})
void batchUpdatePosition(List<DeviceChannel> channelList);
}

View File

@@ -1,298 +0,0 @@
package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 用于存储设备信息
*/
@Mapper
@Repository
public interface DeviceMapper {
@Select("SELECT " +
"device_id, " +
"coalesce(custom_name, name) as name, " +
"password, " +
"manufacturer, " +
"model, " +
"firmware, " +
"transport," +
"stream_mode," +
"ip," +
"sdp_ip," +
"local_ip," +
"port," +
"host_address," +
"expires," +
"register_time," +
"keepalive_time," +
"create_time," +
"update_time," +
"charset," +
"subscribe_cycle_for_catalog," +
"subscribe_cycle_for_mobile_position," +
"mobile_position_submission_interval," +
"subscribe_cycle_for_alarm," +
"ssrc_check," +
"as_message_channel," +
"geo_coord_sys," +
"on_line," +
"media_server_id," +
"broadcast_push_after_ack," +
"(SELECT count(0) FROM wvp_device_channel WHERE device_id=wvp_device.device_id) as channel_count "+
" FROM wvp_device WHERE device_id = #{deviceId}")
Device getDeviceByDeviceId(String deviceId);
@Insert("INSERT INTO wvp_device (" +
"device_id, " +
"name, " +
"manufacturer, " +
"model, " +
"firmware, " +
"transport," +
"stream_mode," +
"ip," +
"sdp_ip," +
"local_ip," +
"port," +
"host_address," +
"expires," +
"register_time," +
"keepalive_time," +
"keepalive_interval_time," +
"create_time," +
"update_time," +
"charset," +
"subscribe_cycle_for_catalog," +
"subscribe_cycle_for_mobile_position,"+
"mobile_position_submission_interval,"+
"subscribe_cycle_for_alarm,"+
"ssrc_check,"+
"as_message_channel,"+
"broadcast_push_after_ack,"+
"geo_coord_sys,"+
"on_line"+
") VALUES (" +
"#{deviceId}," +
"#{name}," +
"#{manufacturer}," +
"#{model}," +
"#{firmware}," +
"#{transport}," +
"#{streamMode}," +
"#{ip}," +
"#{sdpIp}," +
"#{localIp}," +
"#{port}," +
"#{hostAddress}," +
"#{expires}," +
"#{registerTime}," +
"#{keepaliveTime}," +
"#{keepaliveIntervalTime}," +
"#{createTime}," +
"#{updateTime}," +
"#{charset}," +
"#{subscribeCycleForCatalog}," +
"#{subscribeCycleForMobilePosition}," +
"#{mobilePositionSubmissionInterval}," +
"#{subscribeCycleForAlarm}," +
"#{ssrcCheck}," +
"#{asMessageChannel}," +
"#{broadcastPushAfterAck}," +
"#{geoCoordSys}," +
"#{onLine}" +
")")
int add(Device device);
@Update(value = {" <script>" +
"UPDATE wvp_device " +
"SET update_time=#{updateTime}" +
"<if test=\"name != null\">, name=#{name}</if>" +
"<if test=\"manufacturer != null\">, manufacturer=#{manufacturer}</if>" +
"<if test=\"model != null\">, model=#{model}</if>" +
"<if test=\"firmware != null\">, firmware=#{firmware}</if>" +
"<if test=\"transport != null\">, transport=#{transport}</if>" +
"<if test=\"ip != null\">, ip=#{ip}</if>" +
"<if test=\"localIp != null\">, local_ip=#{localIp}</if>" +
"<if test=\"port != null\">, port=#{port}</if>" +
"<if test=\"hostAddress != null\">, host_address=#{hostAddress}</if>" +
"<if test=\"onLine != null\">, on_line=#{onLine}</if>" +
"<if test=\"registerTime != null\">, register_time=#{registerTime}</if>" +
"<if test=\"keepaliveTime != null\">, keepalive_time=#{keepaliveTime}</if>" +
"<if test=\"keepaliveIntervalTime != null\">, keepalive_interval_time=#{keepaliveIntervalTime}</if>" +
"<if test=\"expires != null\">, expires=#{expires}</if>" +
"WHERE device_id=#{deviceId}"+
" </script>"})
int update(Device device);
@Select(
" <script>" +
"SELECT " +
"device_id, " +
"coalesce(custom_name, name) as name, " +
"password, " +
"manufacturer, " +
"model, " +
"firmware, " +
"transport," +
"stream_mode," +
"ip,"+
"sdp_ip,"+
"local_ip,"+
"port,"+
"host_address,"+
"expires,"+
"register_time,"+
"keepalive_time,"+
"create_time,"+
"update_time,"+
"charset,"+
"subscribe_cycle_for_catalog,"+
"subscribe_cycle_for_mobile_position,"+
"mobile_position_submission_interval,"+
"subscribe_cycle_for_alarm,"+
"ssrc_check,"+
"as_message_channel,"+
"broadcast_push_after_ack,"+
"geo_coord_sys,"+
"on_line,"+
"media_server_id,"+
"(SELECT count(0) FROM wvp_device_channel WHERE device_id=de.device_id) as channel_count " +
"FROM wvp_device de" +
"<if test=\"onLine != null\"> where on_line=${onLine}</if>"+
" order by create_time desc "+
" </script>"
)
List<Device> getDevices(Boolean onLine);
@Delete("DELETE FROM wvp_device WHERE device_id=#{deviceId}")
int del(String deviceId);
@Select("SELECT " +
"device_id, " +
"coalesce(custom_name, name) as name, " +
"password, " +
"manufacturer, " +
"model, " +
"firmware, " +
"transport," +
"stream_mode," +
"ip," +
"sdp_ip,"+
"local_ip,"+
"port,"+
"host_address,"+
"expires,"+
"register_time,"+
"keepalive_time,"+
"create_time,"+
"update_time,"+
"charset,"+
"subscribe_cycle_for_catalog,"+
"subscribe_cycle_for_mobile_position,"+
"mobile_position_submission_interval,"+
"subscribe_cycle_for_alarm,"+
"ssrc_check,"+
"as_message_channel,"+
"broadcast_push_after_ack,"+
"geo_coord_sys,"+
"on_line"+
" FROM wvp_device WHERE on_line = true")
List<Device> getOnlineDevices();
@Select("SELECT " +
"device_id,"+
"coalesce(custom_name,name)as name,"+
"password,"+
"manufacturer,"+
"model,"+
"firmware,"+
"transport,"+
"stream_mode,"+
"ip,"+
"sdp_ip,"+
"local_ip,"+
"port,"+
"host_address,"+
"expires,"+
"register_time,"+
"keepalive_time,"+
"create_time,"+
"update_time,"+
"charset,"+
"subscribe_cycle_for_catalog,"+
"subscribe_cycle_for_mobile_position,"+
"mobile_position_submission_interval,"+
"subscribe_cycle_for_alarm,"+
"ssrc_check,"+
"as_message_channel,"+
"broadcast_push_after_ack,"+
"geo_coord_sys,"+
"on_line"+
" FROM wvp_device WHERE ip = #{host} AND port=#{port}")
Device getDeviceByHostAndPort(@Param("host") String host, @Param("port") int port);
@Update(value = {" <script>" +
"UPDATE wvp_device " +
"SET update_time=#{updateTime}" +
"<if test=\"name != null\">, custom_name=#{name}</if>" +
"<if test=\"password != null\">, password=#{password}</if>" +
"<if test=\"streamMode != null\">, stream_mode=#{streamMode}</if>" +
"<if test=\"ip != null\">, ip=#{ip}</if>" +
"<if test=\"sdpIp != null\">, sdp_ip=#{sdpIp}</if>" +
"<if test=\"port != null\">, port=#{port}</if>" +
"<if test=\"charset != null\">, charset=#{charset}</if>" +
"<if test=\"subscribeCycleForCatalog != null\">, subscribe_cycle_for_catalog=#{subscribeCycleForCatalog}</if>" +
"<if test=\"subscribeCycleForMobilePosition != null\">, subscribe_cycle_for_mobile_position=#{subscribeCycleForMobilePosition}</if>" +
"<if test=\"mobilePositionSubmissionInterval != null\">, mobile_position_submission_interval=#{mobilePositionSubmissionInterval}</if>" +
"<if test=\"subscribeCycleForAlarm != null\">, subscribe_cycle_for_alarm=#{subscribeCycleForAlarm}</if>" +
"<if test=\"ssrcCheck != null\">, ssrc_check=#{ssrcCheck}</if>" +
"<if test=\"asMessageChannel != null\">, as_message_channel=#{asMessageChannel}</if>" +
"<if test=\"broadcastPushAfterAck != null\">, broadcast_push_after_ack=#{broadcastPushAfterAck}</if>" +
"<if test=\"geoCoordSys != null\">, geo_coord_sys=#{geoCoordSys}</if>" +
"<if test=\"mediaServerId != null\">, media_server_id=#{mediaServerId}</if>" +
"WHERE device_id=#{deviceId}"+
" </script>"})
void updateCustom(Device device);
@Insert("INSERT INTO wvp_device (" +
"device_id,"+
"custom_name,"+
"password,"+
"sdp_ip,"+
"create_time,"+
"update_time,"+
"charset,"+
"ssrc_check,"+
"as_message_channel,"+
"broadcast_push_after_ack,"+
"geo_coord_sys,"+
"on_line,"+
"media_server_id"+
") VALUES (" +
"#{deviceId}," +
"#{name}," +
"#{password}," +
"#{sdpIp}," +
"#{createTime}," +
"#{updateTime}," +
"#{charset}," +
"#{ssrcCheck}," +
"#{asMessageChannel}," +
"#{broadcastPushAfterAck}," +
"#{geoCoordSys}," +
"#{onLine}," +
"#{mediaServerId}" +
")")
void addCustomDevice(Device device);
@Select("select * FROM wvp_device")
List<Device> getAll();
@Select("select * FROM wvp_device where as_message_channel = true")
List<Device> queryDeviceWithAsMessageChannel();
}

View File

@@ -1,65 +0,0 @@
package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@Mapper
public interface DeviceMobilePositionMapper {
@Insert("INSERT INTO wvp_device_mobile_position (device_id,channel_id, device_name,time,longitude,latitude,altitude,speed,direction,report_source,longitude_gcj02,latitude_gcj02,longitude_wgs84,latitude_wgs84,create_time)"+
"VALUES (#{deviceId}, #{channelId}, #{deviceName}, #{time}, #{longitude}, #{latitude}, #{altitude}, #{speed}, #{direction}, #{reportSource}, #{longitudeGcj02}, #{latitudeGcj02}, #{longitudeWgs84}, #{latitudeWgs84}, #{createTime})")
int insertNewPosition(MobilePosition mobilePosition);
@Select(value = {" <script>" +
"SELECT * FROM wvp_device_mobile_position" +
" WHERE device_id = #{deviceId}" +
"<if test=\"channelId != null\"> and channel_id = #{channelId}</if>" +
"<if test=\"startTime != null\"> AND time&gt;=#{startTime}</if>" +
"<if test=\"endTime != null\"> AND time&lt;=#{endTime}</if>" +
" ORDER BY time ASC" +
" </script>"})
List<MobilePosition> queryPositionByDeviceIdAndTime(@Param("deviceId") String deviceId, @Param("channelId") String channelId, @Param("startTime") String startTime, @Param("endTime") String endTime);
@Select("SELECT * FROM wvp_device_mobile_position WHERE device_id = #{deviceId}" +
" ORDER BY time DESC LIMIT 1")
MobilePosition queryLatestPositionByDevice(String deviceId);
@Delete("DELETE FROM wvp_device_mobile_position WHERE device_id = #{deviceId}")
int clearMobilePositionsByDeviceId(String deviceId);
@Insert("<script> " +
"insert into wvp_device_mobile_position " +
"(device_id,channel_id, device_name,time,longitude,latitude,altitude,speed,direction,report_source," +
"longitude_gcj02,latitude_gcj02,longitude_wgs84,latitude_wgs84,create_time)"+
"values " +
"<foreach collection='mobilePositions' index='index' item='item' separator=','> " +
"(#{item.deviceId}, #{item.channelId}, #{item.deviceName}, #{item.time}, #{item.longitude}, " +
"#{item.latitude}, #{item.altitude}, #{item.speed},#{item.direction}," +
"#{item.reportSource}, #{item.longitudeGcj02}, #{item.latitudeGcj02}, #{item.longitudeWgs84}, #{item.latitudeWgs84}, " +
"#{item.createTime}) " +
"</foreach> " +
"</script>")
void batchadd2(List<MobilePosition> mobilePositions);
@Insert("<script> " +
"<foreach collection='mobilePositions' index='index' item='item' separator=';'> " +
"insert into wvp_device_mobile_position " +
"(device_id,channel_id, device_name,time,longitude,latitude,altitude,speed,direction,report_source," +
"longitude_gcj02,latitude_gcj02,longitude_wgs84,latitude_wgs84,create_time)"+
"values " +
"(#{item.deviceId}, #{item.channelId}, #{item.deviceName}, #{item.time}, #{item.longitude}, " +
"#{item.latitude}, #{item.altitude}, #{item.speed},#{item.direction}," +
"#{item.reportSource}, #{item.longitudeGcj02}, #{item.latitudeGcj02}, #{item.longitudeWgs84}, #{item.latitudeWgs84}, " +
"#{item.createTime}) " +
"</foreach> " +
"</script>")
void batchadd(List<MobilePosition> mobilePositions);
}

View File

@@ -1,177 +0,0 @@
package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
@Mapper
@Repository
public interface GbStreamMapper {
@Insert("INSERT INTO wvp_gb_stream (app, stream, gb_id, name, " +
"longitude, latitude, stream_type,media_server_id,create_time) VALUES" +
"(#{app}, #{stream}, #{gbId}, #{name}, " +
"#{longitude}, #{latitude}, #{streamType}, " +
"#{mediaServerId}, #{createTime})")
@Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gb_stream_id")
int add(GbStream gbStream);
@Update("UPDATE wvp_gb_stream " +
"SET app=#{app}," +
"stream=#{stream}," +
"gb_id=#{gbId}," +
"name=#{name}," +
"stream_type=#{streamType}," +
"longitude=#{longitude}, " +
"latitude=#{latitude}," +
"media_server_id=#{mediaServerId}" +
"WHERE app=#{app} AND stream=#{stream}")
int updateByAppAndStream(GbStream gbStream);
@Update("UPDATE wvp_gb_stream " +
"SET app=#{app}," +
"stream=#{stream}," +
"gb_id=#{gbId}," +
"name=#{name}," +
"stream_type=#{streamType}," +
"longitude=#{longitude}, " +
"latitude=#{latitude}," +
"media_server_id=#{mediaServerId}" +
"WHERE gb_stream_id=#{gbStreamId}")
int update(GbStream gbStream);
@Delete("DELETE FROM wvp_gb_stream WHERE app=#{app} AND stream=#{stream}")
int del(@Param("app") String app, @Param("stream") String stream);
@Select("<script> "+
"SELECT gs.* FROM wvp_gb_stream gs " +
"WHERE " +
"1=1 " +
" <if test='catalogId != null'> AND gs.gb_stream_id in" +
"(select pgs.gb_stream_id from wvp_platform_gb_stream pgs where pgs.platform_id = #{platformId} and pgs.catalog_id=#{catalogId})</if> " +
" <if test='catalogId == null'> AND gs.gb_stream_id not in" +
"(select pgs.gb_stream_id from wvp_platform_gb_stream pgs where pgs.platform_id = #{platformId}) </if> " +
" <if test='query != null'> AND (gs.app LIKE concat('%',#{query},'%') OR gs.stream LIKE concat('%',#{query},'%') OR gs.gb_id LIKE concat('%',#{query},'%') OR gs.name LIKE concat('%',#{query},'%'))</if> " +
" <if test='mediaServerId != null' > AND gs.media_server_id=#{mediaServerId} </if>" +
" order by gs.gb_stream_id asc " +
"</script>")
List<GbStream> selectAll(@Param("platformId") String platformId, @Param("catalogId") String catalogId, @Param("query") String query, @Param("mediaServerId") String mediaServerId);
@Select("SELECT * FROM wvp_gb_stream WHERE app=#{app} AND stream=#{stream}")
GbStream selectOne(@Param("app") String app, @Param("stream") String stream);
@Select("SELECT * FROM wvp_gb_stream WHERE gb_id=#{gbId}")
List<GbStream> selectByGBId(String gbId);
@Select("SELECT gs.*, pgs.platform_id as platform_id, pgs.catalog_id as catalog_id FROM wvp_gb_stream gs " +
"LEFT JOIN wvp_platform_gb_stream pgs ON gs.gb_stream_id = pgs.gb_stream_id " +
"WHERE gs.gb_id = #{gbId} AND pgs.platform_id = #{platformId}")
GbStream queryStreamInPlatform(@Param("platformId") String platformId, @Param("gbId") String gbId);
@Select("<script> "+
"select gt.gb_id as channel_id, gt.name, 'wvp-pro' as manufacture, st.status, gt.longitude, gt.latitude, pc.id as parent_id," +
" '1' as register_way, pc.civil_code, 'live' as model, 'wvp-pro' as owner, '0' as parental,'0' as secrecy" +
" from wvp_gb_stream gt " +
" left join (" +
" select " +
" <if test='usPushingAsStatus != true'> sp.status as status, </if>" +
" <if test='usPushingAsStatus == true'> sp.push_ing as status, </if>" +
"sp.app, sp.stream from wvp_stream_push sp" +
" union all" +
" select spxy.status, spxy.app, spxy.stream from wvp_stream_proxy spxy" +
" ) st on st.app = gt.app and st.stream = gt.stream" +
" left join wvp_platform_gb_stream pgs on gt.gb_stream_id = pgs.gb_stream_id" +
" left join wvp_platform_catalog pc on pgs.catalog_id = pc.id and pgs.platform_id = pc.platform_id" +
" where pgs.platform_id=#{platformId}" +
"</script>")
List<DeviceChannel> queryGbStreamListInPlatform(String platformId, @Param("usPushingAsStatus") boolean usPushingAsStatus);
@Select("SELECT gs.* FROM wvp_gb_stream gs left join wvp_platform_gb_stream pgs " +
"ON gs.gb_stream_id = pgs.gb_stream_id WHERE pgs.gb_stream_id is NULL")
List<GbStream> queryStreamNotInPlatform();
@Delete("DELETE FROM wvp_gb_stream WHERE stream_type=#{type} AND gb_id=NULL AND media_server_id=#{mediaServerId}")
void deleteWithoutGBId(@Param("type") String type, @Param("mediaServerId") String mediaServerId);
@Delete("<script> "+
"DELETE FROM wvp_gb_stream where " +
"<foreach collection='streamProxyItemList' item='item' separator='or'>" +
"(app=#{item.app} and stream=#{item.stream}) " +
"</foreach>" +
"</script>")
void batchDel(List<StreamProxyItem> streamProxyItemList);
@Delete("<script> "+
"DELETE FROM wvp_gb_stream where " +
"<foreach collection='gbStreams' item='item' separator='or'>" +
"(app=#{item.app} and stream=#{item.stream}) " +
"</foreach>" +
"</script>")
void batchDelForGbStream(List<GbStream> gbStreams);
@Insert("<script> " +
"INSERT into wvp_gb_stream " +
"(app, stream, gb_id, name, " +
"longitude, latitude, stream_type,media_server_id,create_time)" +
"values " +
"<foreach collection='subList' index='index' item='item' separator=','> " +
"(#{item.app}, #{item.stream}, #{item.gbId}, #{item.name}, " +
"#{item.longitude}, #{item.latitude}, #{item.streamType}, " +
"#{item.mediaServerId}, #{item.createTime}) "+
"</foreach> " +
"</script>")
@Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gb_stream_id")
void batchAdd(@Param("subList") List<StreamPushItem> subList);
@Update({"<script>" +
"<foreach collection='gpsMsgInfos' item='item' separator=';'>" +
" UPDATE" +
" wvp_gb_stream" +
" SET longitude=#{item.lng}, latitude=#{item.lat} " +
"WHERE gb_id=#{item.id}"+
"</foreach>" +
"</script>"})
int updateStreamGPS(List<GPSMsgInfo> gpsMsgInfos);
@Select("<script> "+
"SELECT * FROM wvp_gb_stream where " +
"<foreach collection='streamPushItems' item='item' separator='or'>" +
"(app=#{item.app} and stream=#{item.stream}) " +
"</foreach>" +
"</script>")
List<GbStream> selectAllForAppAndStream(List<StreamPushItem> streamPushItems);
@Update("UPDATE wvp_gb_stream " +
"SET media_server_id=#{mediaServerId}" +
"WHERE app=#{app} AND stream=#{stream}")
void updateMediaServer(String app, String stream, String mediaServerId);
@Update("<script> "+
" <foreach collection='list' item='item' index='index' separator=';'>"+
"UPDATE wvp_gb_stream " +
" SET name=#{item.name},"+
" gb_id=#{item.gbId}"+
" WHERE app=#{item.app} and stream=#{item.stream}"+
"</foreach>"+
"</script>")
int updateGbIdOrName(List<StreamPushItem> streamPushItemForUpdate);
@Select("SELECT status FROM wvp_stream_proxy WHERE app=#{app} AND stream=#{stream}")
Boolean selectStatusForProxy(@Param("app") String app, @Param("stream") String stream);
@Select("SELECT status FROM wvp_stream_push WHERE app=#{app} AND stream=#{stream}")
Boolean selectStatusForPush(@Param("app") String app, @Param("stream") String stream);
@MapKey("gbId")
@Select("SELECT * from wvp_gb_stream")
Map<String, GbStream> getAllGBId();
}

View File

@@ -1,37 +0,0 @@
package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.storager.dao.dto.LogDto;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 用于存储设服务的日志
*/
@Mapper
@Repository
public interface LogMapper {
@Insert("insert into wvp_log ( name,type,uri,address,result,timing,username,create_time) " +
"values (#{name}, #{type}, #{uri}, #{address}, #{result}, #{timing}, #{username}, #{createTime})")
int add(LogDto logDto);
@Select(value = {"<script>" +
" SELECT * FROM wvp_log " +
" WHERE 1=1 " +
" <if test=\"query != null\"> AND (name LIKE concat('%',#{query},'%'))</if> " +
" <if test=\"type != null\" > AND type = #{type}</if>" +
" <if test=\"startTime != null\" > AND create_time &gt;= #{startTime} </if>" +
" <if test=\"endTime != null\" > AND create_time &lt;= #{endTime} </if>" +
" ORDER BY create_time DESC " +
" </script>"})
List<LogDto> query(@Param("query") String query, @Param("type") String type, @Param("startTime") String startTime, @Param("endTime") String endTime);
@Delete("DELETE FROM wvp_log")
int clear();
}

View File

@@ -42,6 +42,7 @@ public interface MediaServerMapper {
"create_time,"+
"update_time,"+
"transcode_suffix,"+
"server_id,"+
"hook_alive_interval"+
") VALUES " +
"(" +
@@ -74,12 +75,13 @@ public interface MediaServerMapper {
"#{createTime}, " +
"#{updateTime}, " +
"#{transcodeSuffix}, " +
"#{serverId}, " +
"#{hookAliveInterval})")
int add(MediaServer mediaServerItem);
@Update(value = {" <script>" +
"UPDATE wvp_media_server " +
"SET update_time=#{updateTime}" +
"SET update_time=#{updateTime}, transcode_suffix=#{transcodeSuffix} " +
"<if test=\"ip != null\">, ip=#{ip}</if>" +
"<if test=\"hookIp != null\">, hook_ip=#{hookIp}</if>" +
"<if test=\"sdpIp != null\">, sdp_ip=#{sdpIp}</if>" +
@@ -104,7 +106,7 @@ public interface MediaServerMapper {
"<if test=\"hookAliveInterval != null\">, hook_alive_interval=#{hookAliveInterval}</if>" +
"<if test=\"recordDay != null\">, record_day=#{recordDay}</if>" +
"<if test=\"recordPath != null\">, record_path=#{recordPath}</if>" +
"<if test=\"transcodeSuffix != null\">, transcode_suffix=#{transcodeSuffix}</if>" +
"<if test=\"serverId != null\">, server_id=#{serverId}</if>" +
"<if test=\"type != null\">, type=#{type}</if>" +
"WHERE id=#{id}"+
" </script>"})
@@ -138,32 +140,27 @@ public interface MediaServerMapper {
"<if test=\"type != null\">, type=#{type}</if>" +
"<if test=\"transcodeSuffix != null\">, transcode_suffix=#{transcodeSuffix}</if>" +
"<if test=\"hookAliveInterval != null\">, hook_alive_interval=#{hookAliveInterval}</if>" +
"<if test=\"serverId != null\">, server_id=#{serverId}</if>" +
"WHERE ip=#{ip} and http_port=#{httpPort}"+
" </script>"})
int updateByHostAndPort(MediaServer mediaServerItem);
@Select("SELECT * FROM wvp_media_server WHERE id=#{id}")
MediaServer queryOne(String id);
@Select("SELECT * FROM wvp_media_server WHERE id=#{id} and server_id = #{serverId}")
MediaServer queryOne(@Param("id") String id, @Param("serverId") String serverId);
@Select("SELECT * FROM wvp_media_server")
List<MediaServer> queryAll();
@Select("SELECT * FROM wvp_media_server where server_id = #{serverId}")
List<MediaServer> queryAll(@Param("serverId") String serverId);
@Delete("DELETE FROM wvp_media_server WHERE id=#{id}")
void delOne(String id);
@Delete("DELETE FROM wvp_media_server WHERE id=#{id} and server_id = #{serverId}")
void delOne(String id, @Param("serverId") String serverId);
@Select("DELETE FROM wvp_media_server WHERE ip=#{host} and http_port=#{port}")
void delOneByIPAndPort(@Param("host") String host, @Param("port") int port);
@Select("SELECT * FROM wvp_media_server WHERE ip=#{host} and http_port=#{port} and server_id = #{serverId}")
MediaServer queryOneByHostAndPort(@Param("host") String host, @Param("port") int port, @Param("serverId") String serverId);
@Delete("DELETE FROM wvp_media_server WHERE default_server=true")
int delDefault();
@Select("SELECT * FROM wvp_media_server WHERE default_server=true and server_id = #{serverId}")
MediaServer queryDefault(@Param("serverId") String serverId);
@Select("SELECT * FROM wvp_media_server WHERE ip=#{host} and http_port=#{port}")
MediaServer queryOneByHostAndPort(@Param("host") String host, @Param("port") int port);
@Select("SELECT * FROM wvp_media_server WHERE default_server=true")
MediaServer queryDefault();
@Select("SELECT * FROM wvp_media_server WHERE record_assist_port > 0")
List<MediaServer> queryAllWithAssistPort();
@Select("SELECT * FROM wvp_media_server WHERE record_assist_port > 0 and server_id = #{serverId}")
List<MediaServer> queryAllWithAssistPort(@Param("serverId") String serverId);
}

View File

@@ -1,103 +0,0 @@
package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 用于存储上级平台
*/
@Mapper
@Repository
public interface ParentPlatformMapper {
@Insert("INSERT INTO wvp_platform (enable, name, server_gb_id, server_gb_domain, server_ip, server_port,device_gb_id,device_ip,"+
"device_port,username,password,expires,keep_timeout,transport,character_set,ptz,rtcp,as_message_channel,auto_push_channel,"+
"status,start_offline_push,catalog_id,administrative_division,catalog_group,create_time,update_time,send_stream_ip) " +
" VALUES (#{enable}, #{name}, #{serverGBId}, #{serverGBDomain}, #{serverIP}, #{serverPort}, #{deviceGBId}, #{deviceIp}, " +
" #{devicePort}, #{username}, #{password}, #{expires}, #{keepTimeout}, #{transport}, #{characterSet}, #{ptz}, #{rtcp}, #{asMessageChannel}, #{autoPushChannel}, " +
" #{status}, #{startOfflinePush}, #{catalogId}, #{administrativeDivision}, #{catalogGroup}, #{createTime}, #{updateTime}, #{sendStreamIp})")
int addParentPlatform(ParentPlatform parentPlatform);
@Update("UPDATE wvp_platform " +
"SET enable=#{enable}, " +
"name=#{name}," +
"device_gb_id=#{deviceGBId}," +
"server_gb_id=#{serverGBId}, " +
"server_gb_domain=#{serverGBDomain}, " +
"server_ip=#{serverIP}," +
"server_port=#{serverPort}, " +
"device_ip=#{deviceIp}, " +
"device_port=#{devicePort}, " +
"username=#{username}, " +
"password=#{password}, " +
"expires=#{expires}, " +
"keep_timeout=#{keepTimeout}, " +
"transport=#{transport}, " +
"character_set=#{characterSet}, " +
"ptz=#{ptz}, " +
"rtcp=#{rtcp}, " +
"as_message_channel=#{asMessageChannel}, " +
"auto_push_channel=#{autoPushChannel}, " +
"status=#{status}, " +
"start_offline_push=#{startOfflinePush}, " +
"catalog_group=#{catalogGroup}, " +
"administrative_division=#{administrativeDivision}, " +
"create_time=#{createTime}, " +
"update_time=#{updateTime}, " +
"send_stream_ip=#{sendStreamIp}, " +
"catalog_id=#{catalogId} " +
"WHERE id=#{id}")
int updateParentPlatform(ParentPlatform parentPlatform);
@Delete("DELETE FROM wvp_platform WHERE server_gb_id=#{serverGBId}")
int delParentPlatform(ParentPlatform parentPlatform);
@Select("SELECT *, ((SELECT count(0)\n" +
" FROM wvp_platform_gb_channel pc\n" +
" WHERE pc.platform_id = pp.server_gb_id)\n" +
" +\n" +
" (SELECT count(0)\n" +
" FROM wvp_platform_gb_stream pgs\n" +
" WHERE pgs.platform_id = pp.server_gb_id)\n" +
" +\n" +
" (SELECT count(0)\n" +
" FROM wvp_platform_catalog pgc\n" +
" WHERE pgc.platform_id = pp.server_gb_id)) as channel_count\n" +
"FROM wvp_platform pp ")
List<ParentPlatform> getParentPlatformList();
@Select("SELECT * FROM wvp_platform WHERE enable=#{enable} ")
List<ParentPlatform> getEnableParentPlatformList(boolean enable);
@Select("SELECT * FROM wvp_platform WHERE enable=true and as_message_channel=true")
List<ParentPlatform> queryEnablePlatformListWithAsMessageChannel();
@Select("SELECT * FROM wvp_platform WHERE server_gb_id=#{platformGbId}")
ParentPlatform getParentPlatByServerGBId(String platformGbId);
@Select("SELECT * FROM wvp_platform WHERE id=#{id}")
ParentPlatform getParentPlatById(int id);
@Update("UPDATE wvp_platform SET status=false" )
int outlineForAllParentPlatform();
@Update("UPDATE wvp_platform SET status=#{online} WHERE server_gb_id=#{platformGbID}" )
int updateParentPlatformStatus(@Param("platformGbID") String platformGbID, @Param("online") boolean online);
@Update(value = {" <script>" +
"UPDATE wvp_platform " +
"SET catalog_id=#{catalogId}, update_time=#{updateTime}" +
"WHERE server_gb_id=#{platformId}"+
"</script>"})
int setDefaultCatalog(@Param("platformId") String platformId, @Param("catalogId") String catalogId, @Param("updateTime") String updateTime);
@Select("select 'channel' as name, count(pgc.platform_id) count from wvp_platform_gb_channel pgc left join wvp_device_channel dc on dc.id = pgc.device_channel_id where pgc.platform_id=#{platform_id} and dc.channel_id =#{gbId} " +
"union " +
"select 'stream' as name, count(pgs.platform_id) count from wvp_platform_gb_stream pgs left join wvp_gb_stream gs on pgs.gb_stream_id = gs.gb_stream_id where pgs.platform_id=#{platform_id} and gs.gb_id =#{gbId}")
List<ChannelSourceInfo> getChannelSource(@Param("platform_id") String platform_id, @Param("gbId") String gbId);
}

View File

@@ -1,66 +0,0 @@
package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
@Repository
public interface PlatformCatalogMapper {
@Insert("INSERT INTO wvp_platform_catalog (id, name, platform_id, parent_id, civil_code, business_group_id) VALUES" +
"(#{id}, #{name}, #{platformId}, #{parentId}, #{civilCode}, #{businessGroupId})")
int add(PlatformCatalog platformCatalog);
@Delete("DELETE from wvp_platform_catalog WHERE platform_id=#{platformId} and id=#{id}")
int del(@Param("platformId") String platformId, @Param("id") String id);
@Delete("DELETE from wvp_platform_catalog WHERE platform_id=#{platformId}")
int delByPlatformId(@Param("platformId") String platformId);
@Select("SELECT pc.*, count(pc2.id) as children_count from wvp_platform_catalog pc " +
"left join wvp_platform_catalog pc2 on pc.id = pc2.parent_id " +
"WHERE pc.parent_id=#{parentId} AND pc.platform_id=#{platformId} " +
"group by pc.id, pc.name, pc.platform_id, pc.business_group_id, pc.civil_code, pc.parent_id")
List<PlatformCatalog> selectByParentId(@Param("platformId") String platformId, @Param("parentId") String parentId);
@Update(value = {" <script>" +
"UPDATE wvp_platform_catalog " +
"SET name=#{platformCatalog.name}" +
"WHERE id=#{platformCatalog.id} and platform_id=#{platformCatalog.platformId}"+
"</script>"})
int update(@Param("platformCatalog") PlatformCatalog platformCatalog);
@Select("SELECT *, (SELECT COUNT(1) from wvp_platform_catalog where parent_id = pc.id) as children_count from wvp_platform_catalog pc WHERE pc.platform_id=#{platformId}")
List<PlatformCatalog> selectByPlatForm(@Param("platformId") String platformId);
@Select("SELECT pc.* FROM wvp_platform_catalog pc WHERE pc.id = (SELECT pp.catalog_id from wvp_platform pp WHERE pp.server_gb_id=#{platformId})")
PlatformCatalog selectDefaultByPlatFormId(@Param("platformId") String platformId);
@Select("SELECT pc.id as channel_id, pc.name, pc.civil_code, pc.business_group_id,'1' as parental, pc.parent_id " +
" from wvp_platform_catalog pc WHERE pc.platform_id=#{platformId}")
List<DeviceChannel> queryCatalogInPlatform(@Param("platformId") String platformId);
@Select("SELECT *, " +
"(SELECT COUNT(1) from wvp_platform_catalog where parent_id = pc.id) as children_count " +
" from wvp_platform_catalog pc " +
" WHERE pc.id=#{id} and pc.platform_id=#{platformId}")
PlatformCatalog selectByPlatFormAndCatalogId(@Param("platformId") String platformId, @Param("id") String id);
@Delete("<script> "+
"DELETE from wvp_platform_catalog where platform_id=#{platformId} and id in " +
"<foreach collection='ids' item='item' open='(' separator=',' close=')'>" +
"#{item} " +
"</foreach>" +
"</script>")
int deleteAll(String platformId, List<String> ids);
@Select("SELECT id from wvp_platform_catalog WHERE platform_id=#{platformId} and parent_id = #{id}")
List<String> queryCatalogFromParent(@Param("id") String id, @Param("platformId") String platformId);
}

View File

@@ -1,125 +0,0 @@
package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
@Repository
public interface PlatformChannelMapper {
/**
* 查询列表里已经关联的
*/
@Select("<script> "+
"SELECT device_channel_id from wvp_platform_gb_channel WHERE platform_id=#{platformId} AND device_channel_id in" +
"<foreach collection='channelReduces' open='(' item='item' separator=',' close=')'> #{item.id}</foreach>" +
"</script>")
List<Integer> findChannelRelatedPlatform(@Param("platformId") String platformId, @Param("channelReduces") List<ChannelReduce> channelReduces);
@Insert("<script> "+
"INSERT INTO wvp_platform_gb_channel (platform_id, device_channel_id, catalog_id) VALUES" +
"<foreach collection='channelReducesToAdd' item='item' separator=','>" +
" (#{platformId}, #{item.id} , #{item.catalogId} )" +
"</foreach>" +
"</script>")
int addChannels(@Param("platformId") String platformId, @Param("channelReducesToAdd") List<ChannelReduce> channelReducesToAdd);
@Delete("<script> "+
"DELETE from wvp_platform_gb_channel WHERE platform_id=#{platformId} AND device_channel_id in" +
"<foreach collection='channelReducesToDel' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
"</script>")
int delChannelForGB(@Param("platformId") String platformId, @Param("channelReducesToDel") List<ChannelReduce> channelReducesToDel);
@Delete("<script> "+
"DELETE from wvp_platform_gb_channel WHERE device_channel_id in " +
"( select temp.device_channel_id from " +
"(select pgc.device_channel_id from wvp_platform_gb_channel pgc " +
"left join wvp_device_channel dc on dc.id = pgc.device_channel_id where dc.device_id =#{deviceId} " +
") temp)" +
"</script>")
int delChannelForDeviceId(String deviceId);
@Delete("<script> "+
"DELETE from wvp_platform_gb_channel WHERE platform_id=#{platformId}" +
"</script>")
int cleanChannelForGB(String platformId);
@Select("SELECT dc.* from wvp_platform_gb_channel pgc left join wvp_device_channel dc on dc.id = pgc.device_channel_id WHERE dc.channel_id=#{channelId} and pgc.platform_id=#{platformId}")
List<DeviceChannel> queryChannelInParentPlatform(@Param("platformId") String platformId, @Param("channelId") String channelId);
@Select("<script> "+
"SELECT dc.* from wvp_platform_gb_channel pgc left join wvp_device_channel dc on dc.id = pgc.device_channel_id WHERE pgc.platform_id=#{platformId} " +
" <if test='catalogId != null' > and pgc.catalog_id=#{catalogId}</if>" +
"</script>")
List<DeviceChannel> queryAllChannelInCatalog(@Param("platformId") String platformId, @Param("catalogId") String catalogId);
@Select(" select dc.channel_id as id, dc.name as name, pgc.platform_id as platform_id, pgc.catalog_id as parent_id, 0 as children_count, 1 as type " +
" from wvp_device_channel dc left join wvp_platform_gb_channel pgc on dc.id = pgc.device_channel_id " +
" where pgc.platform_id=#{platformId} and pgc.catalog_id=#{catalogId}")
List<PlatformCatalog> queryChannelInParentPlatformAndCatalog(@Param("platformId") String platformId, @Param("catalogId") String catalogId);
@Select("select d.*\n" +
"from wvp_platform_gb_channel pgc\n" +
" left join wvp_device_channel dc on dc.id = pgc.device_channel_id\n" +
" left join wvp_device d on dc.device_id = d.device_id\n" +
"where dc.channel_id = #{channelId} and pgc.platform_id=#{platformId}")
List<Device> queryVideoDeviceByPlatformIdAndChannelId(@Param("platformId") String platformId, @Param("channelId") String channelId);
@Delete("<script> "+
"DELETE from wvp_platform_gb_channel WHERE platform_id=#{platformId} and catalog_id=#{id}" +
"</script>")
int delByCatalogId(@Param("platformId") String platformId, @Param("id") String id);
@Delete("<script> "+
"DELETE from wvp_platform_gb_channel WHERE catalog_id=#{parentId} AND platform_id=#{platformId} AND channel_id=#{id}" +
"</script>")
int delByCatalogIdAndChannelIdAndPlatformId(PlatformCatalog platformCatalog);
@Select("<script> " +
"SELECT " +
"pp.* " +
"FROM " +
"wvp_platform pp " +
"left join wvp_platform_gb_channel pgc on " +
"pp.server_gb_id = pgc.platform_id " +
"left join wvp_device_channel dc on " +
"dc.id = pgc.device_channel_id " +
"WHERE " +
"dc.channel_id = #{channelId} and pp.status = true " +
"AND pp.server_gb_id IN" +
"<foreach collection='platforms' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
"</script> ")
List<ParentPlatform> queryPlatFormListForGBWithGBId(@Param("channelId") String channelId, @Param("platforms") List<String> platforms);
@Delete("<script> " +
"DELETE from wvp_platform_gb_channel WHERE platform_id=#{serverGBId}" +
"</script>")
void delByPlatformId(String serverGBId);
@Delete("<script> " +
"DELETE from wvp_platform_gb_channel WHERE platform_id=#{platformId} " +
" <if test=\"catalogId != null\" > and catalog_id=#{catalogId}</if>" +
"</script>")
int delChannelForGBByCatalogId(@Param("platformId") String platformId, @Param("catalogId") String catalogId);
@Select("select dc.channel_id dc.device_id,dc.name,d.manufacturer,d.model,d.firmware\n" +
"from wvp_platform_gb_channel pgc\n" +
" left join wvp_device_channel dc on dc.id = pgc.device_channel_id\n" +
" left join wvp_device d on dc.device_id = d.device_id\n" +
"where dc.channel_id = #{channelId} and pgc.platform_id=#{platformId}")
List<Device> queryDeviceInfoByPlatformIdAndChannelId(@Param("platformId") String platformId, @Param("channelId") String channelId);
@Select("SELECT pgc.platform_id from wvp_platform_gb_channel pgc left join wvp_device_channel dc on dc.id = pgc.device_channel_id WHERE dc.channel_id=#{channelId}")
List<String> queryParentPlatformByChannelId(@Param("channelId") String channelId);
}

View File

@@ -1,114 +0,0 @@
package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog;
import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream;
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
@Repository
public interface PlatformGbStreamMapper {
@Insert("INSERT INTO wvp_platform_gb_stream (gb_stream_id, platform_id, catalog_id) VALUES" +
"( #{gbStreamId}, #{platformId}, #{catalogId})")
int add(PlatformGbStream platformGbStream);
@Insert("<script> " +
"INSERT into wvp_platform_gb_stream " +
"(gb_stream_id, platform_id, catalog_id) " +
"values " +
"<foreach collection='streamPushItems' index='index' item='item' separator=','> " +
"(#{item.gbStreamId}, #{item.platform_id}, #{item.catalogId})" +
"</foreach> " +
"</script>")
int batchAdd(List<StreamPushItem> streamPushItems);
@Delete("DELETE from wvp_platform_gb_stream WHERE gb_stream_id = (select gb_stream_id from wvp_gb_stream where app=#{app} AND stream=#{stream})")
int delByAppAndStream(@Param("app") String app, @Param("stream") String stream);
@Delete("DELETE from wvp_platform_gb_stream WHERE platform_id=#{platformId}")
int delByPlatformId(String platformId);
@Select("SELECT " +
"pp.* " +
"FROM " +
"wvp_platform_gb_stream pgs " +
"LEFT JOIN wvp_platform pp ON pp.server_gb_id = pgs.platform_id " +
"LEFT join wvp_gb_stream gs ON gs.gb_stream_id = pgs.gb_stream_id " +
"WHERE " +
"gs.app =#{app} " +
"AND gs.stream =#{stream} ")
List<ParentPlatform> selectByAppAndStream(@Param("app") String app, @Param("stream") String stream);
@Select("SELECT pgs.*, gs.gb_id from wvp_platform_gb_stream pgs " +
"LEFT join wvp_gb_stream gs ON pgs.gb_stream_id = gs.gb_stream_id " +
"WHERE gs.app=#{app} AND gs.stream=#{stream} AND pgs.platform_id=#{platformId}")
StreamProxyItem selectOne(@Param("app") String app, @Param("stream") String stream, @Param("platformId") String platformId);
@Select("<script> " +
"select gs.* " +
" from wvp_gb_stream gs\n" +
" left join wvp_platform_gb_stream pgs\n" +
" on gs.gb_stream_id = pgs.gb_stream_id\n" +
" where pgs.platform_id=#{platformId} " +
" <if test='catalogId != null' > and pgs.catalog_id=#{catalogId}</if>" +
"</script>")
List<GbStream> queryChannelInParentPlatformAndCatalog(@Param("platformId") String platformId, @Param("catalogId") String catalogId);
@Select("select gs.gb_id as id, gs.name as name, pgs.platform_id as platform_id, pgs.catalog_id as catalog_id , 0 as children_count, 2 as type\n" +
"from wvp_gb_stream gs\n" +
" left join wvp_platform_gb_stream pgs\n" +
" on gs.gb_stream_id = pgs.gb_stream_id\n" +
"where pgs.platform_id=#{platformId} and pgs.catalog_id=#{catalogId}")
List<PlatformCatalog> queryChannelInParentPlatformAndCatalogForCatalog(@Param("platformId") String platformId, @Param("catalogId") String catalogId);
@Select("<script> " +
"SELECT " +
"pp.* " +
"FROM " +
"wvp_platform pp " +
"left join wvp_platform_gb_stream pgs on " +
"pp.server_gb_id = pgs.platform_id " +
"left join wvp_gb_stream gs " +
"on gs.gb_stream_id = pgs.gb_stream_id " +
"WHERE " +
"gs.app = #{app} " +
"AND gs.stream = #{stream}" +
"AND pp.server_gb_id IN" +
"<foreach collection='platforms' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
"</script> ")
List<ParentPlatform> queryPlatFormListForGBWithGBId(@Param("app") String app, @Param("stream") String stream, @Param("platforms") List<String> platforms);
@Delete("DELETE from wvp_platform_gb_stream WHERE gb_stream_id = (select id from wvp_gb_stream where app=#{app} AND stream=#{stream}) AND platform_id=#{platformId}")
int delByAppAndStreamAndPlatform(String app, String stream, String platformId);
@Delete("<script> "+
"DELETE from wvp_platform_gb_stream where gb_stream_id in " +
"<foreach collection='gbStreams' item='item' open='(' separator=',' close=')' >" +
"#{item.gbStreamId}" +
"</foreach>" +
"</script>")
void delByGbStreams(List<GbStream> gbStreams);
@Delete("<script> "+
"DELETE from wvp_platform_gb_stream where platform_id=#{platformId} and gb_stream_id in " +
"<foreach collection='gbStreams' item='item' open='(' separator=',' close=')'>" +
"#{item.gbStreamId} " +
"</foreach>" +
"</script>")
void delByAppAndStreamsByPlatformId(@Param("gbStreams") List<GbStream> gbStreams, @Param("platformId") String platformId);
@Delete("<script> "+
"DELETE from wvp_platform_gb_stream WHERE platform_id=#{platformId}" +
" <if test='catalogId != null' > and catalog_id=#{catalogId}</if>" +
"</script>")
int delByPlatformAndCatalogId(@Param("platformId") String platformId, @Param("catalogId") String catalogId);
}

View File

@@ -0,0 +1,67 @@
package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.service.bean.RecordPlan;
import com.genersoft.iot.vmp.service.bean.RecordPlanItem;
import org.apache.ibatis.annotations.*;
import java.util.List;
@Mapper
public interface RecordPlanMapper {
@Insert(" <script>" +
"INSERT INTO wvp_record_plan (" +
" name," +
" snap," +
" create_time," +
" update_time) " +
"VALUES (" +
" #{name}," +
" #{snap}," +
" #{createTime}," +
" #{updateTime})" +
" </script>")
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
void add(RecordPlan plan);
@Insert(" <script>" +
"INSERT INTO wvp_record_plan_item (" +
"start," +
"stop, " +
"week_day," +
"plan_id) " +
"VALUES" +
"<foreach collection='planItemList' index='index' item='item' separator=','> " +
"(#{item.start}, #{item.stop}, #{item.weekDay},#{planId})" +
"</foreach> " +
" </script>")
void batchAddItem(@Param("planId") int planId, List<RecordPlanItem> planItemList);
@Select("select * from wvp_record_plan where id = #{planId}")
RecordPlan get(@Param("planId") Integer planId);
@Select(" <script>" +
" SELECT wrp.*, (select count(1) from wvp_device_channel where record_plan_id = wrp.id) AS channelCount\n" +
" FROM wvp_record_plan wrp where 1=1" +
" <if test='query != null'> AND (name LIKE concat('%',#{query},'%') escape '/' )</if> " +
" </script>")
List<RecordPlan> query(@Param("query") String query);
@Update("UPDATE wvp_record_plan SET update_time=#{updateTime}, name=#{name}, snap=#{snap} WHERE id=#{id}")
void update(RecordPlan plan);
@Delete("DELETE FROM wvp_record_plan WHERE id=#{planId}")
void delete(@Param("planId") Integer planId);
@Select("select * from wvp_record_plan_item where plan_id = #{planId}")
List<RecordPlanItem> getItemList(@Param("planId") Integer planId);
@Delete("DELETE FROM wvp_record_plan_item WHERE plan_id = #{planId}")
void cleanItems(@Param("planId") Integer planId);
@Select(" <script>" +
" select wdc.id from wvp_device_channel wdc left join wvp_record_plan_item wrpi on wrpi.plan_id = wdc.record_plan_id " +
" where wrpi.week_day = #{week} and wrpi.start &lt;= #{index} and stop &gt;= #{index} group by wdc.id" +
" </script>")
List<Integer> queryRecordIng(@Param("week") int week, @Param("index") int index);
}

View File

@@ -1,90 +0,0 @@
package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
@Repository
public interface StreamProxyMapper {
@Insert("INSERT INTO wvp_stream_proxy (type, name, app, stream,media_server_id, url, src_url, dst_url, " +
"timeout_ms, ffmpeg_cmd_key, rtp_type, enable_audio, enable_mp4, enable, status, stream_key, enable_remove_none_reader, enable_disable_none_reader, create_time) VALUES" +
"(#{type}, #{name}, #{app}, #{stream}, #{mediaServerId}, #{url}, #{srcUrl}, #{dstUrl}, " +
"#{timeoutMs}, #{ffmpegCmdKey}, #{rtpType}, #{enableAudio}, #{enableMp4}, #{enable}, #{status}, #{streamKey}, " +
"#{enableRemoveNoneReader}, #{enableDisableNoneReader}, #{createTime} )")
int add(StreamProxyItem streamProxyDto);
@Update("UPDATE wvp_stream_proxy " +
"SET type=#{type}, " +
"name=#{name}," +
"app=#{app}," +
"stream=#{stream}," +
"url=#{url}, " +
"media_server_id=#{mediaServerId}, " +
"src_url=#{srcUrl}," +
"dst_url=#{dstUrl}, " +
"timeout_ms=#{timeoutMs}, " +
"ffmpeg_cmd_key=#{ffmpegCmdKey}, " +
"rtp_type=#{rtpType}, " +
"enable_audio=#{enableAudio}, " +
"enable=#{enable}, " +
"status=#{status}, " +
"stream_key=#{streamKey}, " +
"enable_remove_none_reader=#{enableRemoveNoneReader}, " +
"enable_disable_none_reader=#{enableDisableNoneReader}, " +
"enable_mp4=#{enableMp4} " +
"WHERE app=#{app} AND stream=#{stream}")
int update(StreamProxyItem streamProxyDto);
@Delete("DELETE FROM wvp_stream_proxy WHERE app=#{app} AND stream=#{stream}")
int del(String app, String stream);
@Select("SELECT st.*, pgs.gb_id, pgs.name, pgs.longitude, pgs.latitude FROM wvp_stream_proxy st LEFT join wvp_gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream order by st.create_time desc")
List<StreamProxyItem> selectAll();
@Select("SELECT st.*, pgs.gb_id, pgs.name, pgs.longitude, pgs.latitude, 'proxy' as streamType FROM wvp_stream_proxy st LEFT join wvp_gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream WHERE st.enable=#{enable} order by st.create_time desc")
List<StreamProxyItem> selectForEnable(boolean enable);
@Select("SELECT st.*, pgs.gb_id, pgs.name, pgs.longitude, pgs.latitude FROM wvp_stream_proxy st LEFT join wvp_gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream WHERE st.app=#{app} AND st.stream=#{stream} order by st.create_time desc")
StreamProxyItem selectOne(@Param("app") String app, @Param("stream") String stream);
@Select("SELECT st.*, pgs.gb_id, pgs.name, pgs.longitude, pgs.latitude FROM wvp_stream_proxy st " +
"LEFT join wvp_gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream " +
"WHERE st.enable=#{enable} and st.media_server_id= #{id} order by st.create_time desc")
List<StreamProxyItem> selectForEnableInMediaServer( @Param("id") String id, @Param("enable") boolean enable);
@Select("SELECT st.*, pgs.gb_id, pgs.name, pgs.longitude, pgs.latitude FROM wvp_stream_proxy st " +
"LEFT join wvp_gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream " +
"WHERE st.media_server_id= #{id} order by st.create_time desc")
List<StreamProxyItem> selectInMediaServer(String id);
@Update("UPDATE wvp_stream_proxy " +
"SET status=#{status} " +
"WHERE media_server_id=#{mediaServerId}")
void updateStatusByMediaServerId(@Param("mediaServerId") String mediaServerId, @Param("status") boolean status);
@Update("UPDATE wvp_stream_proxy " +
"SET status=#{status} " +
"WHERE app=#{app} AND stream=#{stream}")
int updateStatus(@Param("app") String app, @Param("stream") String stream, @Param("status") boolean status);
@Delete("DELETE FROM wvp_stream_proxy WHERE enable_remove_none_reader=true AND media_server_id=#{mediaServerId}")
void deleteAutoRemoveItemByMediaServerId(String mediaServerId);
@Select("SELECT st.*, pgs.gb_id, pgs.name, pgs.longitude, pgs.latitude FROM wvp_stream_proxy st LEFT join wvp_gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream WHERE st.enable_remove_none_reader=true AND st.media_server_id=#{mediaServerId} order by st.create_time desc")
List<StreamProxyItem> selectAutoRemoveItemByMediaServerId(String mediaServerId);
@Select("select count(1) as total, sum(status) as online from wvp_stream_proxy")
ResourceBaseInfo getOverview();
@Select("select count(1) from wvp_stream_proxy")
int getAllCount();
@Select("select count(1) from wvp_stream_proxy where status = true")
int getOnline();
}

View File

@@ -1,207 +0,0 @@
package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import com.genersoft.iot.vmp.service.bean.StreamPushItemFromRedis;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
@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} )")
int add(StreamPushItem streamPushItem);
@Update(value = {" <script>" +
"UPDATE wvp_stream_push " +
"SET update_time=#{updateTime}" +
"<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}"+
" </script>"})
int update(StreamPushItem 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<StreamPushItem> 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<StreamPushItem> 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);
@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>" +
" <if test='mediaServerId != null' > AND st.media_server_id=#{mediaServerId} </if>" +
"order by st.create_time desc" +
" </script>"})
List<StreamPushItem> 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<StreamPushItem> 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}")
StreamPushItem selectOne(@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} )" +
" </foreach>" +
"</script>")
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
int addAll(List<StreamPushItem> 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}")
List<StreamPushItem> 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")
List<StreamPushItem> 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);
@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 (" +
"<foreach collection='offlineStreams' item='item' separator=','>" +
"(#{item.app}, #{item.stream}) " +
"</foreach>" +
")</script>")
List<GbStream> getOnlinePusherForGbInList(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<GbStream> 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<GbStream> getOnlinePusherForGb();
@Update("UPDATE wvp_stream_push SET status=0")
void setAllStreamOffline();
@Select("SELECT CONCAT(app,stream) from wvp_gb_stream")
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>" +
" </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<StreamPushItem> getListIn(List<StreamPushItem> streamPushItems);
@MapKey("vhost")
@Select("SELECT CONCAT(wsp.app, wsp.stream) as vhost, wsp.app, wsp.stream, wgs.gb_id, wgs.name " +
" from wvp_stream_push wsp " +
" left join wvp_gb_stream wgs on wgs.app = wsp.app and wgs.stream = wsp.stream")
Map<String, StreamPushItem> getAllAppAndStreamMap();
}

View File

@@ -29,7 +29,7 @@ public interface UserMapper {
@Delete("DELETE from wvp_user WHERE id != 1 and id=#{id}")
int delete(int id);
@Select("select u.*, r.id as role_id, r.name as roleName, r.authority as roleAuthority , r.create_time as role_create_time , r.update_time as role_update_time from wvp_user u, wvp_user_role r WHERE u.role_id=r.id and u.username=#{username} AND u.password=#{password}")
@Select("select u.*, r.name as roleName, r.authority as roleAuthority , r.create_time as role_create_time , r.update_time as role_update_time from wvp_user u, wvp_user_role r WHERE u.role_id=r.id and u.username=#{username} AND u.password=#{password}")
@Results(id = "roleMap", value = {
@Result(column = "role_id", property = "role.id"),
@Result(column = "role_name", property = "role.name"),
@@ -39,19 +39,19 @@ public interface UserMapper {
})
User select(@Param("username") String username, @Param("password") String password);
@Select("select u.*, r.id as role_id, r.name as role_name, r.authority as role_authority , r.create_time as role_create_time , r.update_time as role_update_time from wvp_user u, wvp_user_role r WHERE u.role_id=r.id and u.id=#{id}")
@Select("select u.*, r.name as role_name, r.authority as role_authority , r.create_time as role_create_time , r.update_time as role_update_time from wvp_user u, wvp_user_role r WHERE u.role_id=r.id and u.id=#{id}")
@ResultMap(value="roleMap")
User selectById(int id);
@Select("select u.*, r.id as role_id, r.name as role_name, r.authority as role_authority , r.create_time as role_create_time , r.update_time as role_update_time from wvp_user u, wvp_user_role r WHERE u.role_id=r.id and u.username=#{username}")
@Select("select u.*, r.name as role_name, r.authority as role_authority , r.create_time as role_create_time , r.update_time as role_update_time from wvp_user u, wvp_user_role r WHERE u.role_id=r.id and u.username=#{username}")
@ResultMap(value="roleMap")
User getUserByUsername(String username);
@Select("select u.*, r.id as role_id, r.name as role_name, r.authority as role_authority , r.create_time as role_create_time , r.update_time as role_update_time from wvp_user u, wvp_user_role r WHERE u.role_id=r.id")
@Select("select u.*, r.name as role_name, r.authority as role_authority , r.create_time as role_create_time , r.update_time as role_update_time from wvp_user u, wvp_user_role r WHERE u.role_id=r.id")
@ResultMap(value="roleMap")
List<User> selectAll();
@Select("select u.id, u.username,u.push_key,u.role_id, r.id as role_id, r.name as role_name, r.authority as role_authority , r.create_time as role_create_time , r.update_time as role_update_time from wvp_user u join wvp_user_role r on u.role_id=r.id")
@Select("select u.id, u.username,u.push_key,u.role_id, r.name as role_name, r.authority as role_authority , r.create_time as role_create_time , r.update_time as role_update_time from wvp_user u join wvp_user_role r on u.role_id=r.id")
@ResultMap(value="roleMap")
List<User> getUsers();

View File

@@ -2,31 +2,24 @@ package com.genersoft.iot.vmp.storager.impl;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.genersoft.iot.vmp.common.ServerInfo;
import com.genersoft.iot.vmp.common.SystemAllInfo;
import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.bean.AlarmChannelMessage;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.dao.DeviceChannelMapper;
import com.genersoft.iot.vmp.gb28181.dao.DeviceMapper;
import com.genersoft.iot.vmp.media.bean.MediaInfo;
import com.genersoft.iot.vmp.media.bean.MediaServer;
import com.genersoft.iot.vmp.media.event.media.MediaArrivalEvent;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
import com.genersoft.iot.vmp.storager.dao.DeviceMapper;
import com.genersoft.iot.vmp.storager.dao.dto.PlatformRegisterInfo;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.utils.JsonUtil;
import com.genersoft.iot.vmp.utils.SystemInfoUtils;
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
@@ -36,10 +29,10 @@ import java.time.Duration;
import java.util.*;
@SuppressWarnings("rawtypes")
@Slf4j
@Component
public class RedisCatchStorageImpl implements IRedisCatchStorage {
private final Logger logger = LoggerFactory.getLogger(RedisCatchStorageImpl.class);
@Autowired
private DeviceChannelMapper deviceChannelMapper;
@@ -57,20 +50,13 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
private StringRedisTemplate stringRedisTemplate;
@Override
public Long getCSEQ() {
String key = VideoManagerConstants.SIP_CSEQ_PREFIX + userSetting.getServerId();
Long result = redisTemplate.opsForValue().increment(key, 1L);
if (result != null && result > Integer.MAX_VALUE) {
redisTemplate.opsForValue().set(key, 1);
result = 1L;
}
return result;
public List<SendRtpInfo> queryAllSendRTPServer() {
return Collections.emptyList();
}
@Override
public Long getSN(String method) {
String key = VideoManagerConstants.SIP_SN_PREFIX + userSetting.getServerId() + "_" + method;
public Long getCSEQ() {
String key = VideoManagerConstants.SIP_CSEQ_PREFIX + userSetting.getServerId();
Long result = redisTemplate.opsForValue().increment(key, 1L);
if (result != null && result > Integer.MAX_VALUE) {
@@ -86,248 +72,29 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
redisTemplate.opsForValue().set(key, 1);
}
@Override
public void resetAllSN() {
String scanKey = VideoManagerConstants.SIP_SN_PREFIX + userSetting.getServerId() + "_*";
List<Object> keys = RedisUtil.scan(redisTemplate, scanKey);
for (Object o : keys) {
String key = (String) o;
redisTemplate.opsForValue().set(key, 1);
}
}
@Override
public void updatePlatformCatchInfo(ParentPlatformCatch parentPlatformCatch) {
String key = VideoManagerConstants.PLATFORM_CATCH_PREFIX + userSetting.getServerId() + "_" + parentPlatformCatch.getId();
redisTemplate.opsForValue().set(key, parentPlatformCatch);
}
@Override
public ParentPlatformCatch queryPlatformCatchInfo(String platformGbId) {
return (ParentPlatformCatch)redisTemplate.opsForValue().get(VideoManagerConstants.PLATFORM_CATCH_PREFIX + userSetting.getServerId() + "_" + platformGbId);
}
@Override
public void delPlatformCatchInfo(String platformGbId) {
redisTemplate.delete(VideoManagerConstants.PLATFORM_CATCH_PREFIX + userSetting.getServerId() + "_" + platformGbId);
}
@Override
public void delPlatformKeepalive(String platformGbId) {
redisTemplate.delete(VideoManagerConstants.PLATFORM_KEEPALIVE_PREFIX + userSetting.getServerId() + "_" + platformGbId);
}
@Override
public void delPlatformRegister(String platformGbId) {
redisTemplate.delete(VideoManagerConstants.PLATFORM_REGISTER_PREFIX + userSetting.getServerId() + "_" + platformGbId);
}
@Override
public void updatePlatformRegisterInfo(String callId, PlatformRegisterInfo platformRegisterInfo) {
String key = VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetting.getServerId() + "_" + callId;
Duration duration = Duration.ofSeconds(30L);
redisTemplate.opsForValue().set(key, platformRegisterInfo, duration);
}
@Override
public PlatformRegisterInfo queryPlatformRegisterInfo(String callId) {
return (PlatformRegisterInfo)redisTemplate.opsForValue().get(VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetting.getServerId() + "_" + callId);
}
@Override
public void delPlatformRegisterInfo(String callId) {
redisTemplate.delete(VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetting.getServerId() + "_" + callId);
}
@Override
public void updateSendRTPSever(SendRtpItem sendRtpItem) {
redisTemplate.opsForValue().set(sendRtpItem.getRedisKey(), sendRtpItem);
}
@Override
public List<SendRtpItem> querySendRTPServer(String platformGbId, String channelId, String streamId) {
String scanKey = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX
+ userSetting.getServerId() + "_*_"
+ platformGbId + "_"
+ channelId + "_"
+ streamId + "_"
+ "*";
List<SendRtpItem> result = new ArrayList<>();
List<Object> scan = RedisUtil.scan(redisTemplate, scanKey);
if (!scan.isEmpty()) {
for (Object o : scan) {
String key = (String) o;
result.add(JsonUtil.redisJsonToObject(redisTemplate, key, SendRtpItem.class));
}
}
return result;
}
@Override
public SendRtpItem querySendRTPServer(String platformGbId, String channelId, String streamId, String callId) {
if (platformGbId == null) {
platformGbId = "*";
}
if (channelId == null) {
channelId = "*";
}
if (streamId == null) {
streamId = "*";
}
if (callId == null) {
callId = "*";
}
String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX
+ "*_*_"
+ platformGbId + "_"
+ channelId + "_"
+ streamId + "_"
+ callId;
List<Object> scan = RedisUtil.scan(redisTemplate, key);
if (scan.size() > 0) {
return (SendRtpItem)redisTemplate.opsForValue().get(scan.get(0));
}else {
return null;
}
}
@Override
public List<SendRtpItem> querySendRTPServerByChannelId(String channelId) {
if (channelId == null) {
return null;
}
String platformGbId = "*";
String callId = "*";
String streamId = "*";
String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX
+ userSetting.getServerId() + "_*_"
+ platformGbId + "_"
+ channelId + "_"
+ streamId + "_"
+ callId;
List<Object> scan = RedisUtil.scan(redisTemplate, key);
List<SendRtpItem> result = new ArrayList<>();
for (Object o : scan) {
result.add((SendRtpItem) redisTemplate.opsForValue().get(o));
}
return result;
}
@Override
public List<SendRtpItem> querySendRTPServerByStream(String stream) {
if (stream == null) {
return null;
}
String platformGbId = "*";
String callId = "*";
String channelId = "*";
String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX
+ userSetting.getServerId() + "_*_"
+ platformGbId + "_"
+ channelId + "_"
+ stream + "_"
+ callId;
List<Object> scan = RedisUtil.scan(redisTemplate, key);
List<SendRtpItem> result = new ArrayList<>();
for (Object o : scan) {
result.add((SendRtpItem) redisTemplate.opsForValue().get(o));
}
return result;
}
@Override
public List<SendRtpItem> querySendRTPServer(String platformGbId) {
if (platformGbId == null) {
platformGbId = "*";
}
String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX
+ userSetting.getServerId() + "_*_"
+ platformGbId + "_*" + "_*" + "_*";
List<Object> queryResult = RedisUtil.scan(redisTemplate, key);
List<SendRtpItem> result= new ArrayList<>();
for (Object o : queryResult) {
String keyItem = (String) o;
result.add((SendRtpItem) redisTemplate.opsForValue().get(keyItem));
}
return result;
}
/**
* 删除RTP推送信息缓存
*/
@Override
public void deleteSendRTPServer(String platformGbId, String channelId, String callId, String streamId) {
if (streamId == null) {
streamId = "*";
}
if (callId == null) {
callId = "*";
}
String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX
+ userSetting.getServerId() + "_*_"
+ platformGbId + "_"
+ channelId + "_"
+ streamId + "_"
+ callId;
List<Object> scan = RedisUtil.scan(redisTemplate, key);
if (scan.size() > 0) {
for (Object keyStr : scan) {
logger.info("[删除 redis的SendRTP] {}", keyStr.toString());
redisTemplate.delete(keyStr);
}
}
}
/**
* 删除RTP推送信息缓存
*/
@Override
public void deleteSendRTPServer(SendRtpItem sendRtpItem) {
deleteSendRTPServer(sendRtpItem.getPlatformId(), sendRtpItem.getChannelId(),sendRtpItem.getCallId(), sendRtpItem.getStream());
}
@Override
public List<SendRtpItem> queryAllSendRTPServer() {
String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX
+ userSetting.getServerId() + "_*";
List<Object> queryResult = RedisUtil.scan(redisTemplate, key);
List<SendRtpItem> result= new ArrayList<>();
for (Object o : queryResult) {
String keyItem = (String) o;
result.add((SendRtpItem) redisTemplate.opsForValue().get(keyItem));
}
return result;
}
/**
* 查询某个通道是否存在上级点播RTP推送
*/
@Override
public boolean isChannelSendingRTP(String channelId) {
String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX
+ userSetting.getServerId() + "_*_*_"
+ channelId + "*_" + "*_";
List<Object> RtpStreams = RedisUtil.scan(redisTemplate, key);
return RtpStreams.size() > 0;
}
@Override
public void updateWVPInfo(JSONObject jsonObject, int time) {
public void updateWVPInfo(ServerInfo serverInfo, int time) {
String key = VideoManagerConstants.WVP_SERVER_PREFIX + userSetting.getServerId();
Duration duration = Duration.ofSeconds(time);
redisTemplate.opsForValue().set(key, jsonObject, duration);
redisTemplate.opsForValue().set(key, serverInfo, duration);
// 设置平台的分数值
String setKey = VideoManagerConstants.WVP_SERVER_LIST;
// 首次设置就设置为0, 后续值越小说明越是最近启动的
redisTemplate.opsForZSet().add(setKey, userSetting.getServerId(), System.currentTimeMillis());
}
@Override
public void removeOfflineWVPInfo(String serverId) {
String setKey = VideoManagerConstants.WVP_SERVER_LIST;
// 首次设置就设置为0, 后续值越小说明越是最近启动的
redisTemplate.opsForZSet().remove(setKey, serverId);
}
@Override
public void sendStreamChangeMsg(String type, JSONObject jsonObject) {
String key = VideoManagerConstants.WVP_MSG_STREAM_CHANGE_PREFIX + type;
logger.info("[redis 流变化事件] 发送 {}: {}", key, jsonObject.toString());
log.info("[redis 流变化事件] 发送 {}: {}", key, jsonObject.toString());
redisTemplate.convertAndSend(key, jsonObject);
}
@@ -335,7 +102,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
public void addStream(MediaServer mediaServerItem, String type, String app, String streamId, MediaInfo mediaInfo) {
// 查找是否使用了callID
StreamAuthorityInfo streamAuthorityInfo = getStreamAuthorityInfo(app, streamId);
String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_" + type + "_" + app + "_" + streamId + "_" + mediaServerItem.getId();
String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_" + type.toUpperCase() + "_" + app + "_" + streamId + "_" + mediaServerItem.getId();
if (streamAuthorityInfo != null) {
mediaInfo.setCallId(streamAuthorityInfo.getCallId());
}
@@ -344,13 +111,13 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
@Override
public void removeStream(String mediaServerId, String type, String app, String streamId) {
String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_" + type + "_" + app + "_" + streamId + "_" + mediaServerId;
String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_" + type.toUpperCase() + "_" + app + "_" + streamId + "_" + mediaServerId;
redisTemplate.delete(key);
}
@Override
public void removeStream(String mediaServerId, String type) {
String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_" + type + "_*_*_" + mediaServerId;
String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_" + type.toUpperCase() + "_*_*_" + mediaServerId;
List<Object> streams = RedisUtil.scan(redisTemplate, key);
for (Object stream : streams) {
redisTemplate.delete(stream);
@@ -360,7 +127,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
@Override
public List<MediaInfo> getStreams(String mediaServerId, String type) {
List<MediaInfo> result = new ArrayList<>();
String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_" + type + "_*_*_" + mediaServerId;
String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_" + type.toUpperCase() + "_*_*_" + mediaServerId;
List<Object> streams = RedisUtil.scan(redisTemplate, key);
for (Object stream : streams) {
MediaInfo mediaInfo = (MediaInfo)redisTemplate.opsForValue().get(stream);
@@ -371,112 +138,106 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
@Override
public void updateDevice(Device device) {
String key = VideoManagerConstants.DEVICE_PREFIX + userSetting.getServerId() + "_" + device.getDeviceId();
redisTemplate.opsForValue().set(key, device);
String key = VideoManagerConstants.DEVICE_PREFIX;
redisTemplate.opsForHash().put(key, device.getDeviceId(), device);
}
@Override
public void removeDevice(String deviceId) {
String key = VideoManagerConstants.DEVICE_PREFIX + userSetting.getServerId() + "_" + deviceId;
redisTemplate.delete(key);
String key = VideoManagerConstants.DEVICE_PREFIX;
redisTemplate.opsForHash().delete(key, deviceId);
}
@Override
public void removeAllDevice() {
String scanKey = VideoManagerConstants.DEVICE_PREFIX + userSetting.getServerId() + "_*";
List<Object> keys = RedisUtil.scan(redisTemplate, scanKey);
for (Object key : keys) {
redisTemplate.delete(key);
}
String key = VideoManagerConstants.DEVICE_PREFIX;
redisTemplate.delete(key);
}
@Override
public List<Device> getAllDevices() {
String scanKey = VideoManagerConstants.DEVICE_PREFIX + userSetting.getServerId() + "_*";
String key = VideoManagerConstants.DEVICE_PREFIX;
List<Device> result = new ArrayList<>();
List<Object> keys = RedisUtil.scan(redisTemplate, scanKey);
for (Object o : keys) {
String key = (String) o;
Device device = JsonUtil.redisJsonToObject(redisTemplate, key, Device.class);
if (Objects.nonNull(device)) {
// 只取没有存过得
result.add(JsonUtil.redisJsonToObject(redisTemplate, key, Device.class));
List<Object> values = redisTemplate.opsForHash().values(key);
for (Object value : values) {
if (Objects.nonNull(value)) {
result.add((Device)value);
}
}
return result;
}
@Override
public Device getDevice(String deviceId) {
String key = VideoManagerConstants.DEVICE_PREFIX + userSetting.getServerId() + "_" + deviceId;
Device device = JsonUtil.redisJsonToObject(redisTemplate, key, Device.class);
if (device == null){
String key = VideoManagerConstants.DEVICE_PREFIX;
Device device;
Object object = redisTemplate.opsForHash().get(key, deviceId);
if (object == null){
device = deviceMapper.getDeviceByDeviceId(deviceId);
if (device != null) {
updateDevice(device);
}
}else {
device = (Device)object;
}
return device;
}
@Override
public void updateGpsMsgInfo(GPSMsgInfo gpsMsgInfo) {
String key = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetting.getServerId() + "_" + gpsMsgInfo.getId();
String key = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetting.getServerId();
Duration duration = Duration.ofSeconds(60L);
redisTemplate.opsForValue().set(key, gpsMsgInfo, duration);
redisTemplate.opsForHash().put(key, gpsMsgInfo.getId(),gpsMsgInfo);
redisTemplate.expire(key, duration);
// 默认GPS消息保存1分钟
}
@Override
public GPSMsgInfo getGpsMsgInfo(String gbId) {
String key = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetting.getServerId() + "_" + gbId;
return JsonUtil.redisJsonToObject(redisTemplate, key, GPSMsgInfo.class);
public GPSMsgInfo getGpsMsgInfo(String channelId) {
String key = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetting.getServerId();
return (GPSMsgInfo) redisTemplate.opsForHash().get(key, channelId);
}
@Override
public List<GPSMsgInfo> getAllGpsMsgInfo() {
String scanKey = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetting.getServerId() + "_*";
String key = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetting.getServerId();
List<GPSMsgInfo> result = new ArrayList<>();
List<Object> keys = RedisUtil.scan(redisTemplate, scanKey);
for (Object o : keys) {
String key = (String) o;
GPSMsgInfo gpsMsgInfo = JsonUtil.redisJsonToObject(redisTemplate, key, GPSMsgInfo.class);
if (Objects.nonNull(gpsMsgInfo) && !gpsMsgInfo.isStored()) { // 只取没有存过得
result.add(JsonUtil.redisJsonToObject(redisTemplate, key, GPSMsgInfo.class));
}
List<Object> values = redisTemplate.opsForHash().values(key);
for (Object value : values) {
result.add((GPSMsgInfo)value);
}
return result;
}
@Override
public void updateStreamAuthorityInfo(String app, String stream, StreamAuthorityInfo streamAuthorityInfo) {
String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId() + "_" + app+ "_" + stream;
redisTemplate.opsForValue().set(key, streamAuthorityInfo);
String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId();
String objectKey = app+ "_" + stream;
redisTemplate.opsForHash().put(key, objectKey, streamAuthorityInfo);
}
@Override
public void removeStreamAuthorityInfo(String app, String stream) {
String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId() + "_" + app+ "_" + stream ;
redisTemplate.delete(key);
String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId();
String objectKey = app+ "_" + stream;
redisTemplate.opsForHash().delete(key, objectKey);
}
@Override
public StreamAuthorityInfo getStreamAuthorityInfo(String app, String stream) {
String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId() + "_" + app+ "_" + stream ;
return JsonUtil.redisJsonToObject(redisTemplate, key, StreamAuthorityInfo.class);
String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId();
String objectKey = app+ "_" + stream;
return (StreamAuthorityInfo)redisTemplate.opsForHash().get(key, objectKey);
}
@Override
public List<StreamAuthorityInfo> getAllStreamAuthorityInfo() {
String scanKey = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId() + "_*_*" ;
String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId();
List<StreamAuthorityInfo> result = new ArrayList<>();
List<Object> keys = RedisUtil.scan(redisTemplate, scanKey);
for (Object o : keys) {
String key = (String) o;
result.add(JsonUtil.redisJsonToObject(redisTemplate, key, StreamAuthorityInfo.class));
List<Object> values = redisTemplate.opsForHash().values(key);
for (Object value : values) {
result.add((StreamAuthorityInfo)value);
}
return result;
}
@@ -496,6 +257,20 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
return result;
}
@Override
public MediaInfo getProxyStream(String app, String streamId) {
String scanKey = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_PULL_" + app + "_" + streamId + "_*";
MediaInfo result = null;
List<Object> keys = RedisUtil.scan(redisTemplate, scanKey);
if (keys.size() > 0) {
String key = (String) keys.get(0);
result = JsonUtil.redisJsonToObject(redisTemplate, key, MediaInfo.class);
}
return result;
}
@Override
public void addCpuInfo(double cpuInfo) {
String key = VideoManagerConstants.SYSTEM_INFO_CPU_PREFIX + userSetting.getServerId();
@@ -572,14 +347,14 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
@Override
public void sendMobilePositionMsg(JSONObject jsonObject) {
String key = VideoManagerConstants.VM_MSG_SUBSCRIBE_MOBILE_POSITION;
logger.debug("[redis发送通知] 发送 移动位置 {}: {}", key, jsonObject.toString());
log.debug("[redis发送通知] 发送 移动位置 {}: {}", key, jsonObject.toString());
redisTemplate.convertAndSend(key, jsonObject);
}
@Override
public void sendStreamPushRequestedMsg(MessageForPushChannel msg) {
String key = VideoManagerConstants.VM_MSG_STREAM_PUSH_REQUESTED;
logger.info("[redis发送通知] 发送 推流被请求 {}: {}/{}", key, msg.getApp(), msg.getStream());
log.info("[redis发送通知] 发送 推流被请求 {}: {}/{}", key, msg.getApp(), msg.getStream());
redisTemplate.convertAndSend(key, JSON.toJSON(msg));
}
@@ -587,7 +362,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
public void sendAlarmMsg(AlarmChannelMessage msg) {
// 此消息用于对接第三方服务下级来的消息内容
String key = VideoManagerConstants.VM_MSG_SUBSCRIBE_ALARM;
logger.info("[redis发送通知] 发送 报警{}: {}", key, JSON.toJSON(msg));
log.info("[redis发送通知] 发送 报警{}: {}", key, JSON.toJSON(msg));
redisTemplate.convertAndSend(key, JSON.toJSON(msg));
}
@@ -600,7 +375,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
@Override
public void sendStreamPushRequestedMsgForStatus() {
String key = VideoManagerConstants.VM_MSG_GET_ALL_ONLINE_REQUESTED;
logger.info("[redis通知] 发送 获取所有推流设备的状态");
log.info("[redis通知] 发送 获取所有推流设备的状态");
JSONObject jsonObject = new JSONObject();
jsonObject.put(key, key);
redisTemplate.convertAndSend(key, jsonObject);
@@ -620,9 +395,8 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
@Override
public int getGbSendCount(String id) {
String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX
+ userSetting.getServerId() + "_*_" + id + "_*";
return RedisUtil.scan(redisTemplate, key).size();
String key = VideoManagerConstants.SEND_RTP_INFO_CALLID;
return redisTemplate.opsForHash().size(key).intValue();
}
@Override
@@ -634,7 +408,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
msg.append(":").append(channelId);
}
msg.append(" ").append(online? "ON":"OFF");
logger.info("[redis通知] 推送设备/通道状态-> {} ", msg);
log.info("[redis通知] 推送设备/通道状态-> {} ", msg);
// 使用 RedisTemplate<Object, Object> 发送字符串消息会导致发送的消息多带了双引号
stringRedisTemplate.convertAndSend(key, msg.toString());
}
@@ -650,90 +424,105 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
msg.append(":").append(channelId);
}
msg.append(" ").append(add? "ADD":"DELETE");
logger.info("[redis通知] 推送通道-> {}", msg);
log.info("[redis通知] 推送通道-> {}", msg);
// 使用 RedisTemplate<Object, Object> 发送字符串消息会导致发送的消息多带了双引号
stringRedisTemplate.convertAndSend(key, msg.toString());
}
@Override
public void sendPlatformStartPlayMsg(SendRtpItem sendRtpItem, ParentPlatform platform) {
public void sendPlatformStartPlayMsg(SendRtpInfo sendRtpItem, DeviceChannel channel, Platform platform) {
if (sendRtpItem.getPlayType() == InviteStreamType.PUSH && platform != null) {
MessageForPushChannel messageForPushChannel = MessageForPushChannel.getInstance(0, sendRtpItem.getApp(), sendRtpItem.getStream(),
sendRtpItem.getChannelId(), platform.getServerGBId(), platform.getName(), userSetting.getServerId(),
channel.getDeviceId(), platform.getServerGBId(), platform.getName(), userSetting.getServerId(),
sendRtpItem.getMediaServerId());
messageForPushChannel.setPlatFormIndex(platform.getId());
String key = VideoManagerConstants.VM_MSG_STREAM_START_PLAY_NOTIFY;
logger.info("[redis发送通知] 发送 推流被上级平台观看 {}: {}/{}->{}", key, sendRtpItem.getApp(), sendRtpItem.getStream(), platform.getServerGBId());
log.info("[redis发送通知] 发送 推流被上级平台观看 {}: {}/{}->{}", key, sendRtpItem.getApp(), sendRtpItem.getStream(), platform.getServerGBId());
redisTemplate.convertAndSend(key, JSON.toJSON(messageForPushChannel));
}
}
@Override
public void sendPlatformStopPlayMsg(SendRtpItem sendRtpItem, ParentPlatform platform) {
public void sendPlatformStopPlayMsg(SendRtpInfo sendRtpItem, Platform platform, CommonGBChannel channel) {
MessageForPushChannel msg = MessageForPushChannel.getInstance(0,
sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getChannelId(),
sendRtpItem.getPlatformId(), platform.getName(), userSetting.getServerId(), sendRtpItem.getMediaServerId());
sendRtpItem.getApp(), sendRtpItem.getStream(), channel.getGbDeviceId(),
sendRtpItem.getTargetId(), platform.getName(), userSetting.getServerId(), sendRtpItem.getMediaServerId());
msg.setPlatFormIndex(platform.getId());
String key = VideoManagerConstants.VM_MSG_STREAM_STOP_PLAY_NOTIFY;
logger.info("[redis发送通知] 发送 上级平台停止观看 {}: {}/{}->{}", key, sendRtpItem.getApp(), sendRtpItem.getStream(), platform.getServerGBId());
log.info("[redis发送通知] 发送 上级平台停止观看 {}: {}/{}->{}", key, sendRtpItem.getApp(), sendRtpItem.getStream(), platform.getServerGBId());
redisTemplate.convertAndSend(key, JSON.toJSON(msg));
}
@Override
public void addPushListItem(String app, String stream, MediaArrivalEvent event) {
public void addPushListItem(String app, String stream, MediaInfo mediaInfo) {
String key = VideoManagerConstants.PUSH_STREAM_LIST + app + "_" + stream;
StreamPushItem streamPushItem = StreamPushItem.getInstance(event, userSetting.getServerId());
redisTemplate.opsForValue().set(key, streamPushItem);
redisTemplate.opsForValue().set(key, mediaInfo);
}
@Override
public StreamPushItem getPushListItem(String app, String stream) {
public MediaInfo getPushListItem(String app, String stream) {
String key = VideoManagerConstants.PUSH_STREAM_LIST + app + "_" + stream;
return (StreamPushItem)redisTemplate.opsForValue().get(key);
return (MediaInfo)redisTemplate.opsForValue().get(key);
}
@Override
public void removePushListItem(String app, String stream, String mediaServerId) {
String key = VideoManagerConstants.PUSH_STREAM_LIST + app + "_" + stream;
StreamPushItem param = (StreamPushItem)redisTemplate.opsForValue().get(key);
if (param != null && param.getMediaServerId().equalsIgnoreCase(mediaServerId)) {
MediaInfo param = (MediaInfo)redisTemplate.opsForValue().get(key);
if (param != null) {
redisTemplate.delete(key);
}
}
@Override
public void sendPushStreamClose(MessageForPushChannel msg) {
String key = VideoManagerConstants.VM_MSG_STREAM_PUSH_CLOSE_REQUESTED;
logger.info("[redis发送通知] 发送 停止向上级推流 {}: {}/{}->{}", key, msg.getApp(), msg.getStream(), msg.getPlatFormId());
log.info("[redis发送通知] 发送 停止向上级推流 {}: {}/{}->{}", key, msg.getApp(), msg.getStream(), msg.getPlatFormId());
redisTemplate.convertAndSend(key, JSON.toJSON(msg));
}
@Override
public void addWaiteSendRtpItem(SendRtpItem sendRtpItem, int platformPlayTimeout) {
public void addWaiteSendRtpItem(SendRtpInfo sendRtpItem, int platformPlayTimeout) {
String key = VideoManagerConstants.WAITE_SEND_PUSH_STREAM + sendRtpItem.getApp() + "_" + sendRtpItem.getStream();
redisTemplate.opsForValue().set(key, sendRtpItem);
}
@Override
public SendRtpItem getWaiteSendRtpItem(String app, String stream) {
public SendRtpInfo getWaiteSendRtpItem(String app, String stream) {
String key = VideoManagerConstants.WAITE_SEND_PUSH_STREAM + app + "_" + stream;
return JsonUtil.redisJsonToObject(redisTemplate, key, SendRtpItem.class);
return JsonUtil.redisJsonToObject(redisTemplate, key, SendRtpInfo.class);
}
@Override
public void sendStartSendRtp(SendRtpItem sendRtpItem) {
public void sendStartSendRtp(SendRtpInfo sendRtpItem) {
String key = VideoManagerConstants.START_SEND_PUSH_STREAM + sendRtpItem.getApp() + "_" + sendRtpItem.getStream();
logger.info("[redis发送通知] 通知其他WVP推流 {}: {}/{}->{}", key, sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getPlatformId());
log.info("[redis发送通知] 通知其他WVP推流 {}: {}/{}->{}", key, sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getTargetId());
redisTemplate.convertAndSend(key, JSON.toJSON(sendRtpItem));
}
@Override
public void sendPushStreamOnline(SendRtpItem sendRtpItem) {
public void sendPushStreamOnline(SendRtpInfo sendRtpItem) {
String key = VideoManagerConstants.VM_MSG_STREAM_PUSH_CLOSE_REQUESTED;
logger.info("[redis发送通知] 流上线 {}: {}/{}->{}", key, sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getPlatformId());
log.info("[redis发送通知] 流上线 {}: {}/{}->{}", key, sendRtpItem.getApp(), sendRtpItem.getStream(), sendRtpItem.getTargetId());
redisTemplate.convertAndSend(key, JSON.toJSON(sendRtpItem));
}
@Override
public ServerInfo queryServerInfo(String serverId) {
String key = VideoManagerConstants.WVP_SERVER_PREFIX + serverId;
return (ServerInfo)redisTemplate.opsForValue().get(key);
}
@Override
public String chooseOneServer(String serverId) {
String key = VideoManagerConstants.WVP_SERVER_LIST;
redisTemplate.opsForZSet().remove(key, serverId);
Set<Object> range = redisTemplate.opsForZSet().range(key, 0, 0);
if (range == null || range.isEmpty()) {
return null;
}
return (String) range.iterator().next();
}
}