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 = {" "}) int update(DeviceChannel channel); @Select(value = {" "}) List queryChannels(@Param("deviceId") String deviceId, @Param("parentChannelId") String parentChannelId, @Param("query") String query, @Param("hasSubChannel") Boolean hasSubChannel, @Param("online") Boolean online, @Param("channelIds") List channelIds); @Select(value = {" "}) List queryChannelsWithDeviceInfo(@Param("deviceId") String deviceId, @Param("parentChannelId") String parentChannelId, @Param("query") String query, @Param("hasSubChannel") Boolean hasSubChannel, @Param("online") Boolean online, @Param("channelIds") List channelIds); @Select(value = {" "}) List queryChannelsByDeviceIdWithStartAndLimit(@Param("deviceId") String deviceId, @Param("channelIds") List 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 = {" "}) List queryChannelListInAll(@Param("query") String query, @Param("online") Boolean online, @Param("hasSubChannel") Boolean hasSubChannel, @Param("platformId") String platformId, @Param("catalogId") String catalogId); @Select(value = {" "}) List queryChannelByPlatformId(String platformId); @Select("SELECT * FROM wvp_device_channel WHERE channel_id=#{channelId}") List 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("") int batchAdd(@Param("addChannels") List addChannels); @Insert("") int batchAddOrUpdate(List 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({""}) int batchUpdate(List updateChannels); @Select("SELECT * FROM wvp_device_channel WHERE device_id=#{deviceId} AND status=true") List queryOnlineChannelsByDeviceId(String deviceId); @Delete(value = {" "}) int cleanChannelsNotInList(@Param("deviceId") String deviceId, @Param("channels") List 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 = {" "}) int updatePosition(DeviceChannel deviceChannel); @Update({""}) int batchUpdatePosition(List deviceChannelList); @Select("SELECT * FROM wvp_device_channel WHERE length(trim(stream_id)) > 0") List getAllChannelInPlay(); @Select("select * from wvp_device_channel where longitude*latitude > 0 and device_id = #{deviceId}") List getAllChannelWithCoordinate(String deviceId); @Select(value = {" "}) List getChannelsWithCivilCodeAndLength(@Param("deviceId") String deviceId, @Param("parentId") String parentId, @Param("length") Integer length); @Select(value = {" "}) List 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 getChannelWithoutCivilCode(String deviceId); @Select("select * from wvp_device_channel where device_id=#{deviceId} and SUBSTRING(channel_id, 11, 3)=#{typeCode}") List 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 queryChannelWithCatalog(String serverGBId); @Select("select * from wvp_device_channel where device_id = #{deviceId}") List 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 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 getDeviceByChannelId(String channelId); @Delete({""}) int batchDel(@Param("deleteChannelList") List deleteChannelList); @Update({""}) int batchOnline(@Param("channels") List channels); @Update({""}) int batchOffline(List 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 = {" "}) List getSubChannelsByDeviceId(@Param("deviceId") String deviceId, @Param("parentId") String parentId, @Param("onlyCatalog") boolean onlyCatalog); @Update("") void updateChannelStreamIdentification(DeviceChannel channel); }