临时提交
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package com.genersoft.iot.vmp.gb28181.dao;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface CommonGBChannelMapper {
|
||||
|
||||
@Select()
|
||||
CommonGBChannel queryByDeviceId(String gbDeviceId);
|
||||
}
|
||||
50
src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceAlarmMapper.java
Executable file
50
src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceAlarmMapper.java
Executable file
@@ -0,0 +1,50 @@
|
||||
package com.genersoft.iot.vmp.gb28181.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 >= #{startTime} </if>" +
|
||||
" <if test=\"endTime != null\" > AND alarm_time <= #{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 <= #{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);
|
||||
}
|
||||
578
src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java
Executable file
578
src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java
Executable file
@@ -0,0 +1,578 @@
|
||||
package com.genersoft.iot.vmp.gb28181.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);
|
||||
|
||||
}
|
||||
298
src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java
Executable file
298
src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java
Executable file
@@ -0,0 +1,298 @@
|
||||
package com.genersoft.iot.vmp.gb28181.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();
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.genersoft.iot.vmp.gb28181.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>=#{startTime}</if>" +
|
||||
"<if test=\"endTime != null\"> AND time<=#{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);
|
||||
|
||||
}
|
||||
103
src/main/java/com/genersoft/iot/vmp/gb28181/dao/ParentPlatformMapper.java
Executable file
103
src/main/java/com/genersoft/iot/vmp/gb28181/dao/ParentPlatformMapper.java
Executable file
@@ -0,0 +1,103 @@
|
||||
package com.genersoft.iot.vmp.gb28181.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);
|
||||
}
|
||||
66
src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformCatalogMapper.java
Executable file
66
src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformCatalogMapper.java
Executable file
@@ -0,0 +1,66 @@
|
||||
package com.genersoft.iot.vmp.gb28181.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);
|
||||
}
|
||||
122
src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformChannelMapper.java
Executable file
122
src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformChannelMapper.java
Executable file
@@ -0,0 +1,122 @@
|
||||
package com.genersoft.iot.vmp.gb28181.dao;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
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<CommonGBChannel> 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);
|
||||
}
|
||||
114
src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformGbStreamMapper.java
Executable file
114
src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformGbStreamMapper.java
Executable file
@@ -0,0 +1,114 @@
|
||||
package com.genersoft.iot.vmp.gb28181.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.streamProxy.bean.StreamProxy;
|
||||
import com.genersoft.iot.vmp.streamPush.bean.StreamPush;
|
||||
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<StreamPush> 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}")
|
||||
StreamProxy 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);
|
||||
}
|
||||
@@ -1,12 +1,79 @@
|
||||
package com.genersoft.iot.vmp.gb28181.service.impl;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class GbChannelServiceImpl implements IGbChannelService {
|
||||
|
||||
@Autowired
|
||||
private CommonGBChannelMapper commonGBChannelMapper;
|
||||
|
||||
@Override
|
||||
public CommonGBChannel queryByDeviceId(String gbDeviceId) {
|
||||
return commonGBChannelMapper.queryByDeviceId(gbDeviceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int add(CommonGBChannel commonGBChannel) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(int gbId) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(CommonGBChannel commonGBChannel) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int offline(CommonGBChannel commonGBChannel) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int offline(List<CommonGBChannel> commonGBChannelList) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int online(CommonGBChannel commonGBChannel) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int online(List<CommonGBChannel> commonGBChannelList) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeSend(CommonGBChannel commonGBChannel) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchAdd(List<CommonGBChannel> commonGBChannels) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus(List<CommonGBChannel> channelList) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommonGBChannel> queryByPlatformId(Integer platformId) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user