648540858 1 gadu atpakaļ
vecāks
revīzija
046e7802f3

+ 234 - 112
src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java

@@ -32,87 +32,138 @@ public interface DeviceChannelMapper {
     @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}"+
+            ", device_id=#{deviceId}" +
+            ", device_db_id=#{deviceDbId}" +
+            ", name=#{name}" +
+            ", manufacture=#{manufacture}" +
+            ", model=#{model}" +
+            ", owner=#{owner}" +
+            ", civil_code=#{civilCode}" +
+            ", block=#{block}" +
+            ", address=#{address}" +
+            ", parental=#{parental}" +
+            ", parent_id=#{parentId}" +
+            ", safety_way=#{safetyWay}" +
+            ", register_way=#{registerWay}" +
+            ", cert_num=#{certNum}" +
+            ", certifiable=#{certifiable}" +
+            ", err_code=#{errCode}" +
+            ", end_time=#{endTime}" +
+            ", secrecy=#{secrecy}" +
+            ", ip_address=#{ipAddress}" +
+            ", port=#{port}" +
+            ", password=#{password}" +
+            ", status=#{status}" +
+            ", longitude=#{longitude}" +
+            ", latitude=#{latitude}" +
+            ", ptz_type=#{ptzType}" +
+            ", position_type=#{positionType}" +
+            ", room_type=#{roomType}" +
+            ", use_type=#{useType}" +
+            ", supply_light_type=#{supplyLightType}" +
+            ", direction_type=#{directionType}" +
+            ", resolution=#{resolution}" +
+            ", business_group_id=#{businessGroupId}" +
+            ", download_speed=#{downloadSpeed}" +
+            ", svc_space_support_mod=#{svcSpaceSupportMod}" +
+            ", svc_time_support_mode=#{svcTimeSupportMode}" +
+            ", sub_count,stream_id=#{subCount,streamId}" +
+            ", has_audio=#{hasAudio}" +
+            ", gps_time=#{gpsTime}" +
+            ", stream_identification=#{streamIdentification}" +
+            "WHERE id=#{id}"+
             " </script>"})
     int update(DeviceChannel channel);
 
+    @Update(value = {" <script>" +
+            "UPDATE wvp_device_channel " +
+            "SET update_time=#{updateTime}" +
+            ", gb_name = #{gbName}" +
+            ", gb_manufacturer = #{gbManufacturer}" +
+            ", gb_model = #{gbModel}" +
+            ", gb_owner = #{gbOwner}" +
+            ", gb_civil_code = #{gbCivilCode}" +
+            ", gb_block = #{gbBlock}" +
+            ", gb_address = #{gbAddress}" +
+            ", gb_parental = #{gbParental}" +
+            ", gb_parent_id  = #{gbParentId}" +
+            ", gb_safety_way = #{gbSafetyWay}" +
+            ", gb_register_way = #{gbRegisterWay}" +
+            ", gb_cert_num = #{gbCertNum}" +
+            ", gb_certifiable = #{gbCertifiable}" +
+            ", gb_err_code = #{gbErrCode}" +
+            ", gb_end_time = #{gbEndTime}" +
+            ", gb_secrecy = #{gbSecrecy}" +
+            ", gb_ip_address = #{gbIpAddress}" +
+            ", gb_port = #{gbPort}" +
+            ", gb_password = #{gbPassword}" +
+            ", gb_status = #{gbStatus}" +
+            ", gb_longitude = #{gbLongitude}" +
+            ", gb_latitude = #{gbLatitude}" +
+            ", gb_ptz_type = #{gbPtzType}" +
+            ", gb_position_type = #{gbPositionType}" +
+            ", gb_room_type = #{gbRoomType}" +
+            ", gb_use_type = #{gbUseType}" +
+            ", gb_supply_light_type = #{gbSupplyLightType}" +
+            ", gb_direction_type = #{gbDirectionType}" +
+            ", gb_resolution = #{gbResolution}" +
+            ", gb_business_group_id = #{gbBusinessGroupId}" +
+            ", gb_download_speed = #{gbDownloadSpeed}" +
+            ", gb_svc_space_support_mod = #{gbSvcSpaceSupportMod}" +
+            ", gb_svc_time_support_mode = #{gbSvcTimeSupportMode}" +
+            "WHERE id = #{id}"+
+            " </script>"})
+    int updateCustomInfo(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} " +
+            "    dc.device_db_id,\n" +
+            "    dc.create_time,\n" +
+            "    dc.update_time,\n" +
+            "    dc.sub_count,\n" +
+            "    dc.stream_id,\n" +
+            "    dc.has_audio,\n" +
+            "    dc.gps_time,\n" +
+            "    dc.stream_identification,\n" +
+            "    coalesce(dc.gb_device_id, dc.device_id) as device_id,\n" +
+            "    coalesce(dc.gb_name, dc.name) as name,\n" +
+            "    coalesce(dc.gb_manufacturer, dc.manufacturer) as manufacturer,\n" +
+            "    coalesce(dc.gb_model, dc.model) as model,\n" +
+            "    coalesce(dc.gb_owner, dc.owner) as owner,\n" +
+            "    coalesce(dc.gb_civil_code, dc.civil_code) as civil_code,\n" +
+            "    coalesce(dc.gb_block, dc.block) as block,\n" +
+            "    coalesce(dc.gb_address, dc.address) as address,\n" +
+            "    coalesce(dc.gb_parental, dc.parental) as parental,\n" +
+            "    coalesce(dc.gb_parent_id, dc.parent_id) as parent_id,\n" +
+            "    coalesce(dc.gb_safety_way, dc.safety_way) as safety_way,\n" +
+            "    coalesce(dc.gb_register_way, dc.register_way) as register_way,\n" +
+            "    coalesce(dc.gb_cert_num, dc.cert_num) as cert_num,\n" +
+            "    coalesce(dc.gb_certifiable, dc.certifiable) as certifiable,\n" +
+            "    coalesce(dc.gb_err_code, dc.err_code) as err_code,\n" +
+            "    coalesce(dc.gb_end_time, dc.end_time) as end_time,\n" +
+            "    coalesce(dc.gb_secrecy, dc.secrecy) as secrecy,\n" +
+            "    coalesce(dc.gb_ip_address, dc.ip_address) as ip_address,\n" +
+            "    coalesce(dc.gb_port, dc.port) as port,\n" +
+            "    coalesce(dc.gb_password, dc.password) as password,\n" +
+            "    coalesce(dc.gb_status, dc.status) as status,\n" +
+            "    coalesce(dc.gb_longitude, dc.longitude) as longitude,\n" +
+            "    coalesce(dc.gb_latitude, dc.latitude) as latitude,\n" +
+            "    coalesce(dc.gb_ptz_type, dc.ptz_type) as ptz_type,\n" +
+            "    coalesce(dc.gb_position_type, dc.position_type) as position_type,\n" +
+            "    coalesce(dc.gb_room_type, dc.room_type) as room_type,\n" +
+            "    coalesce(dc.gb_use_type, dc.use_type) as use_type,\n" +
+            "    coalesce(dc.gb_supply_light_type, dc.supply_light_type) as supply_light_type,\n" +
+            "    coalesce(dc.gb_direction_type, dc.direction_type) as direction_type,\n" +
+            "    coalesce(dc.gb_resolution, dc.resolution) as resolution,\n" +
+            "    coalesce(dc.gb_business_group_id, dc.business_group_id) as business_group_id,\n" +
+            "    coalesce(dc.gb_download_speed, dc.download_speed) as download_speed,\n" +
+            "    coalesce(dc.gb_svc_space_support_mod, dc.svc_space_support_mod) as svc_space_support_mod,\n" +
+            "    coalesce(dc.gb_svc_time_support_mode dc.svc_time_support_mode) as svc_time_support_mode\n" +
+            " from " +
+            " wvp_device_channel dc " +
+            " left join wvp_device d on d.id=dc.device_db_id" +
+            " WHERE " +
+            " d.device_id = #{deviceId} " +
             " <if test='query != null'> AND (" +
             "dc.channel_id LIKE concat('%',#{query},'%') " +
             "OR dc.name LIKE concat('%',#{query},'%') " +
@@ -123,35 +174,62 @@ public interface DeviceChannelMapper {
             " <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=')'>" +
+            "<if test='channelIds != null'> AND dc.device_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("select\n" +
+            "    id,\n" +
+            "    device_db_id,\n" +
+            "    create_time,\n" +
+            "    update_time,\n" +
+            "    sub_count,\n" +
+            "    stream_id,\n" +
+            "    has_audio,\n" +
+            "    gps_time,\n" +
+            "    stream_identification,\n" +
+            "    coalesce(gb_device_id, device_id) as device_id,\n" +
+            "    coalesce(gb_name, name) as name,\n" +
+            "    coalesce(gb_manufacturer, manufacturer) as manufacturer,\n" +
+            "    coalesce(gb_model, model) as model,\n" +
+            "    coalesce(gb_owner, owner) as owner,\n" +
+            "    coalesce(gb_civil_code, civil_code) as civil_code,\n" +
+            "    coalesce(gb_block, block) as block,\n" +
+            "    coalesce(gb_address, address) as address,\n" +
+            "    coalesce(gb_parental, parental) as parental,\n" +
+            "    coalesce(gb_parent_id, parent_id) as parent_id,\n" +
+            "    coalesce(gb_safety_way, safety_way) as safety_way,\n" +
+            "    coalesce(gb_register_way, register_way) as register_way,\n" +
+            "    coalesce(gb_cert_num, cert_num) as cert_num,\n" +
+            "    coalesce(gb_certifiable, certifiable) as certifiable,\n" +
+            "    coalesce(gb_err_code, err_code) as err_code,\n" +
+            "    coalesce(gb_end_time, end_time) as end_time,\n" +
+            "    coalesce(gb_secrecy, secrecy) as secrecy,\n" +
+            "    coalesce(gb_ip_address, ip_address) as ip_address,\n" +
+            "    coalesce(gb_port, port) as port,\n" +
+            "    coalesce(gb_password, password) as password,\n" +
+            "    coalesce(gb_status, status) as status,\n" +
+            "    coalesce(gb_longitude, longitude) as longitude,\n" +
+            "    coalesce(gb_latitude, latitude) as latitude,\n" +
+            "    coalesce(gb_ptz_type, ptz_type) as ptz_type,\n" +
+            "    coalesce(gb_position_type, position_type) as position_type,\n" +
+            "    coalesce(gb_room_type, room_type) as room_type,\n" +
+            "    coalesce(gb_use_type, use_type) as use_type,\n" +
+            "    coalesce(gb_supply_light_type, supply_light_type) as supply_light_type,\n" +
+            "    coalesce(gb_direction_type, direction_type) as direction_type,\n" +
+            "    coalesce(gb_resolution, resolution) as resolution,\n" +
+            "    coalesce(gb_business_group_id, business_group_id) as business_group_id,\n" +
+            "    coalesce(gb_download_speed, download_speed) as download_speed,\n" +
+            "    coalesce(gb_svc_space_support_mod, svc_space_support_mod) as svc_space_support_mod,\n" +
+            "    coalesce(gb_svc_time_support_mode svc_time_support_mode) as svc_time_support_mode\n" +
+            "from wvp_device_channel\n" +
+            "where device_db_id = #{deviceDbId}")
+    List<DeviceChannel> queryChannelsByDeviceDbId(@Param("deviceDbId") int deviceDbId);
+
 
 
     @Select(value = {" <script>" +
@@ -161,31 +239,75 @@ public interface DeviceChannelMapper {
             "de.on_line as device_online " +
             "from " +
             "wvp_device_channel dc " +
-            "LEFT JOIN wvp_device de ON dc.device_id = de.device_id " +
+            "LEFT JOIN wvp_device de ON dc.device_db_id = de.id " +
             "WHERE 1=1" +
-            " <if test='deviceId != null'> AND dc.device_id = #{deviceId} </if> " +
+            " <if test='deviceId != null'> AND de.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='online == true' > AND dc.status=1</if>" +
+            " <if test='online == false' > AND dc.status=0</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=')'>" +
+            "<if test='channelIds != null'> AND dc.device_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}" +
+            "ORDER BY dc.channel_id ASC" +
             " </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);
+    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("SELECT * FROM wvp_device_channel WHERE device_id=#{deviceId} AND channel_id=#{channelId}")
+    @Select("SELECT " +
+            "    dc.device_db_id,\n" +
+            "    dc.create_time,\n" +
+            "    dc.update_time,\n" +
+            "    dc.sub_count,\n" +
+            "    dc.stream_id,\n" +
+            "    dc.has_audio,\n" +
+            "    dc.gps_time,\n" +
+            "    dc.stream_identification,\n" +
+            "    coalesce(dc.gb_device_id, dc.device_id) as device_id,\n" +
+            "    coalesce(dc.gb_name, dc.name) as name,\n" +
+            "    coalesce(dc.gb_manufacturer, dc.manufacturer) as manufacturer,\n" +
+            "    coalesce(dc.gb_model, dc.model) as model,\n" +
+            "    coalesce(dc.gb_owner, dc.owner) as owner,\n" +
+            "    coalesce(dc.gb_civil_code, dc.civil_code) as civil_code,\n" +
+            "    coalesce(dc.gb_block, dc.block) as block,\n" +
+            "    coalesce(dc.gb_address, dc.address) as address,\n" +
+            "    coalesce(dc.gb_parental, dc.parental) as parental,\n" +
+            "    coalesce(dc.gb_parent_id, dc.parent_id) as parent_id,\n" +
+            "    coalesce(dc.gb_safety_way, dc.safety_way) as safety_way,\n" +
+            "    coalesce(dc.gb_register_way, dc.register_way) as register_way,\n" +
+            "    coalesce(dc.gb_cert_num, dc.cert_num) as cert_num,\n" +
+            "    coalesce(dc.gb_certifiable, dc.certifiable) as certifiable,\n" +
+            "    coalesce(dc.gb_err_code, dc.err_code) as err_code,\n" +
+            "    coalesce(dc.gb_end_time, dc.end_time) as end_time,\n" +
+            "    coalesce(dc.gb_secrecy, dc.secrecy) as secrecy,\n" +
+            "    coalesce(dc.gb_ip_address, dc.ip_address) as ip_address,\n" +
+            "    coalesce(dc.gb_port, dc.port) as port,\n" +
+            "    coalesce(dc.gb_password, dc.password) as password,\n" +
+            "    coalesce(dc.gb_status, dc.status) as status,\n" +
+            "    coalesce(dc.gb_longitude, dc.longitude) as longitude,\n" +
+            "    coalesce(dc.gb_latitude, dc.latitude) as latitude,\n" +
+            "    coalesce(dc.gb_ptz_type, dc.ptz_type) as ptz_type,\n" +
+            "    coalesce(dc.gb_position_type, dc.position_type) as position_type,\n" +
+            "    coalesce(dc.gb_room_type, dc.room_type) as room_type,\n" +
+            "    coalesce(dc.gb_use_type, dc.use_type) as use_type,\n" +
+            "    coalesce(dc.gb_supply_light_type, dc.supply_light_type) as supply_light_type,\n" +
+            "    coalesce(dc.gb_direction_type, dc.direction_type) as direction_type,\n" +
+            "    coalesce(dc.gb_resolution, dc.resolution) as resolution,\n" +
+            "    coalesce(dc.gb_business_group_id, dc.business_group_id) as business_group_id,\n" +
+            "    coalesce(dc.gb_download_speed, dc.download_speed) as download_speed,\n" +
+            "    coalesce(dc.gb_svc_space_support_mod, dc.svc_space_support_mod) as svc_space_support_mod,\n" +
+            "    coalesce(dc.gb_svc_time_support_mode dc.svc_time_support_mode) as svc_time_support_mode\n" +
+            " FROM wvp_device_channel dc " +
+            " left join wvp_device d on d.id=dc.device_db_id" +
+            " WHERE d.device_id=#{deviceId} AND dc.device_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_db_id=#{deviceId}")
+    int cleanChannelsByDeviceId(@Param("deviceId") int 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);
+    @Delete("DELETE FROM wvp_device_channel WHERE id=#{id}")
+    int del(@Param("id") int id);
 
     @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);

+ 1 - 1
src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java

@@ -119,7 +119,7 @@ public class CatalogDataCatch {
                     if (catalogData.getTotal() == catalogData.getChannelList().size()) {
                         deviceChannelService.resetChannels(catalogData.getDevice().getDeviceId(), catalogData.getChannelList());
                     }else {
-                        deviceChannelService.updateChannels(catalogData.getDevice().getDeviceId(), catalogData.getChannelList());
+                        deviceChannelService.updateChannels(catalogData.getDevice(), catalogData.getChannelList());
                     }
                     String errorMsg = "更新成功,共" + catalogData.getTotal() + "条,已更新" + catalogData.getChannelList().size() + "条";
                     catalogData.setErrorMsg(errorMsg);

+ 4 - 1
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java

@@ -60,6 +60,9 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
 	@Autowired
 	private IDeviceService deviceService;
 
+	@Autowired
+	private IDeviceChannelService deviceChannelService;
+
 	@Autowired
 	private AudioBroadcastManager audioBroadcastManager;
 
@@ -216,7 +219,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
 					InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY,
 							device.getDeviceId(), channel.getDeviceId());
 					if (inviteInfo != null) {
-						storager.stopPlay(ssrcTransaction.getDeviceId(), channel.getDeviceId());
+						deviceChannelService.stopPlay(ssrcTransaction.getDeviceId(), channel.getDeviceId());
 						inviteStreamService.removeInviteInfo(inviteInfo);
 						if (inviteInfo.getStreamInfo() != null) {
 							mediaServerService.closeRTPServer(inviteInfo.getStreamInfo().getMediaServerId(), inviteInfo.getStreamInfo().getStream());

+ 1 - 1
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java

@@ -100,7 +100,7 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
                         if (sumNum == 0) {
                             log.info("[收到通道]设备:{}的: 0个", take.getDevice().getDeviceId());
                             // 数据已经完整接收
-                            deviceChannelService.cleanChannelsForDevice(take.getDevice().getDeviceId());
+                            deviceChannelService.cleanChannelsForDevice(take.getDevice().getId());
                             catalogDataCatch.setChannelSyncEnd(take.getDevice().getDeviceId(), null);
                         } else {
                             Iterator<Element> deviceListIterator = deviceListElement.elementIterator();

+ 7 - 5
src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java

@@ -24,11 +24,8 @@ public interface IDeviceChannelService {
 
     /**
      * 批量添加设备通道
-     *
-     * @param deviceId 设备id
-     * @param channels 多个通道
      */
-    int updateChannels(String deviceId, List<DeviceChannel> channels);
+    int updateChannels(Device device, List<DeviceChannel> channels);
 
     /**
      * 获取统计信息
@@ -93,7 +90,10 @@ public interface IDeviceChannelService {
 
     void updateChannelGPS(Device device, DeviceChannel deviceChannel, MobilePosition mobilePosition);
 
+    void startPlay(String deviceId, String channelId, String stream);
+
     void stopPlay(String deviceId, String channelId);
+
     void batchUpdateChannelGPS(List<DeviceChannel> channelList);
 
     void batchAddMobilePosition(List<MobilePosition> addMobilePositionList);
@@ -104,7 +104,9 @@ public interface IDeviceChannelService {
 
     void delete(DeviceChannel channel);
 
-    void cleanChannelsForDevice(String deviceId);
+    void cleanChannelsForDevice(int deviceId);
 
     boolean resetChannels(String deviceId, List<DeviceChannel> deviceChannels);
+
+
 }

+ 14 - 10
src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java

@@ -84,17 +84,16 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
     }
 
     @Override
-    public int updateChannels(String deviceId, List<DeviceChannel> channels) {
+    public int updateChannels(Device device, List<DeviceChannel> channels) {
         List<DeviceChannel> addChannels = new ArrayList<>();
         List<DeviceChannel> updateChannels = new ArrayList<>();
         HashMap<String, DeviceChannel> channelsInStore = new HashMap<>();
-        Device device = deviceMapper.getDeviceByDeviceId(deviceId);
         if (channels != null && channels.size() > 0) {
-            List<DeviceChannel> channelList = channelMapper.queryChannels(deviceId, null, null, null, null,null);
-            if (channelList.size() == 0) {
+            List<DeviceChannel> channelList = channelMapper.queryChannelsByDeviceDbId(device.getId());
+            if (channelList.isEmpty()) {
                 for (DeviceChannel channel : channels) {
-                    channel.setDeviceId(deviceId);
-                    InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channel.getDeviceId());
+                    channel.setDeviceDbId(device.getId());
+                    InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, device.getDeviceId(), channel.getDeviceId());
                     if (inviteInfo != null && inviteInfo.getStreamInfo() != null) {
                         channel.setStreamId(inviteInfo.getStreamInfo().getStream());
                     }
@@ -108,8 +107,8 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
                     channelsInStore.put(deviceChannel.getDeviceId(), deviceChannel);
                 }
                 for (DeviceChannel channel : channels) {
-                    channel.setDeviceId(deviceId);
-                    InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channel.getDeviceId());
+                    channel.setDeviceDbId(device.getId());
+                    InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, device.getDeviceId(), channel.getDeviceId());
                     if (inviteInfo != null && inviteInfo.getStreamInfo() != null) {
                         channel.setStreamId(inviteInfo.getStreamInfo().getStream());
                     }
@@ -231,7 +230,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
 
     @Override
     public void delete(DeviceChannel channel) {
-        channelMapper.del(channel.getDeviceId(), channel.getDeviceId());
+        channelMapper.del(channel.getId());
     }
 
     @Override
@@ -344,6 +343,11 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
         }
     }
 
+    @Override
+    public void startPlay(String deviceId, String channelId, String stream) {
+        channelMapper.startPlay(deviceId, channelId, stream);
+    }
+
     @Override
     public void stopPlay(String deviceId, String channelId) {
         channelMapper.stopPlay(deviceId, channelId);
@@ -393,7 +397,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
     }
 
     @Override
-    public void cleanChannelsForDevice(String deviceId) {
+    public void cleanChannelsForDevice(int deviceId) {
         channelMapper.cleanChannelsByDeviceId(deviceId);
     }
 

+ 8 - 2
src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java

@@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.common.CommonCallback;
 import com.genersoft.iot.vmp.common.VideoManagerConstants;
 import com.genersoft.iot.vmp.conf.DynamicTask;
 import com.genersoft.iot.vmp.conf.UserSetting;
+import com.genersoft.iot.vmp.conf.exception.ControllerException;
 import com.genersoft.iot.vmp.gb28181.bean.*;
 import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
 import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
@@ -24,6 +25,7 @@ import com.genersoft.iot.vmp.gb28181.dao.DeviceChannelMapper;
 import com.genersoft.iot.vmp.gb28181.dao.DeviceMapper;
 import com.genersoft.iot.vmp.gb28181.dao.PlatformChannelMapper;
 import com.genersoft.iot.vmp.utils.DateUtil;
+import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
 import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -409,7 +411,7 @@ public class DeviceServiceImpl implements IDeviceService {
        if (!deviceChannels.isEmpty()) {
            List<DeviceChannel> deviceChannelsForStore = new ArrayList<>();
            deviceChannelsForStore.addAll(deviceChannels);
-           deviceChannelService.updateChannels(device.getDeviceId(), deviceChannelsForStore);
+           deviceChannelService.updateChannels(device, deviceChannelsForStore);
        }
     }
 
@@ -545,11 +547,15 @@ public class DeviceServiceImpl implements IDeviceService {
 
     @Override
     public boolean delete(String deviceId) {
+        Device device = deviceMapper.getDeviceByDeviceId(deviceId);
+        if (device == null) {
+            throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到设备:" + deviceId);
+        }
         TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
         boolean result = false;
         try {
             platformChannelMapper.delChannelForDeviceId(deviceId);
-            deviceChannelMapper.cleanChannelsByDeviceId(deviceId);
+            deviceChannelMapper.cleanChannelsByDeviceId(device.getId());
             if ( deviceMapper.del(deviceId) < 0 ) {
                 //事务回滚
                 dataSourceTransactionManager.rollback(transactionStatus);

+ 5 - 1
src/main/java/com/genersoft/iot/vmp/service/impl/InviteStreamServiceImpl.java

@@ -9,6 +9,7 @@ import com.genersoft.iot.vmp.common.VideoManagerConstants;
 import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.media.event.media.MediaArrivalEvent;
 import com.genersoft.iot.vmp.media.event.media.MediaDepartureEvent;
+import com.genersoft.iot.vmp.service.IDeviceChannelService;
 import com.genersoft.iot.vmp.service.IInviteStreamService;
 import com.genersoft.iot.vmp.service.bean.ErrorCallback;
 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
@@ -39,6 +40,9 @@ public class InviteStreamServiceImpl implements IInviteStreamService {
     @Autowired
     private IVideoManagerStorage storage;
 
+    @Autowired
+    private IDeviceChannelService deviceChannelService;
+
     @Autowired
     private UserSetting userSetting;
 
@@ -63,7 +67,7 @@ public class InviteStreamServiceImpl implements IInviteStreamService {
             InviteInfo inviteInfo = getInviteInfoByStream(null, event.getStream());
             if (inviteInfo != null && (inviteInfo.getType() == InviteSessionType.PLAY || inviteInfo.getType() == InviteSessionType.PLAYBACK)) {
                 removeInviteInfo(inviteInfo);
-                storage.stopPlay(inviteInfo.getDeviceId(), inviteInfo.getChannelId());
+                deviceChannelService.stopPlay(inviteInfo.getDeviceId(), inviteInfo.getChannelId());
             }
         }
     }

+ 5 - 5
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java

@@ -13,10 +13,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
 import com.genersoft.iot.vmp.media.bean.MediaServer;
 import com.genersoft.iot.vmp.media.bean.ResultForOnPublish;
 import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
-import com.genersoft.iot.vmp.service.IDeviceService;
-import com.genersoft.iot.vmp.service.IInviteStreamService;
-import com.genersoft.iot.vmp.service.IMediaService;
-import com.genersoft.iot.vmp.service.IUserService;
+import com.genersoft.iot.vmp.service.*;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.streamProxy.bean.StreamProxy;
@@ -59,6 +56,9 @@ public class MediaServiceImpl implements IMediaService {
     @Autowired
     private IInviteStreamService inviteStreamService;
 
+    @Autowired
+    private IDeviceChannelService deviceChannelService;
+
     @Autowired
     private VideoStreamSessionManager sessionManager;
 
@@ -267,7 +267,7 @@ public class MediaServiceImpl implements IMediaService {
 
                 inviteStreamService.removeInviteInfo(inviteInfo.getType(), inviteInfo.getDeviceId(),
                         inviteInfo.getChannelId(), inviteInfo.getStream());
-                storager.stopPlay(inviteInfo.getDeviceId(), inviteInfo.getChannelId());
+                deviceChannelService.stopPlay(inviteInfo.getDeviceId(), inviteInfo.getChannelId());
                 return result;
             }
             SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, null, stream, null);

+ 4 - 4
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java

@@ -314,7 +314,7 @@ public class PlayServiceImpl implements IPlayService {
                 }else {
                     // 点播发起了但是尚未成功, 仅注册回调等待结果即可
                     inviteStreamService.once(InviteSessionType.PLAY, deviceId, channelId, null, callback);
-                    storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
+                    channelService.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
                     inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channelId);
                 }
             }
@@ -698,7 +698,7 @@ public class PlayServiceImpl implements IPlayService {
             DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
             if (deviceChannel != null) {
                 deviceChannel.setStreamId(streamInfo.getStream());
-                storager.startPlay(deviceId, channelId, streamInfo.getStream());
+                channelService.startPlay(deviceId, channelId, streamInfo.getStream());
             }
             InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channelId);
             if (inviteInfo != null) {
@@ -719,7 +719,7 @@ public class PlayServiceImpl implements IPlayService {
             DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
             if (deviceChannel != null) {
                 deviceChannel.setStreamId(streamInfo.getStream());
-                storager.startPlay(deviceId, channelId, streamInfo.getStream());
+                channelService.startPlay(deviceId, channelId, streamInfo.getStream());
             }
             InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(InviteSessionType.PLAYBACK, mediaInfo.getStream());
             if (inviteInfo != null) {
@@ -1638,7 +1638,7 @@ public class PlayServiceImpl implements IPlayService {
             }
         }
         inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, device.getDeviceId(), channelId);
-        storager.stopPlay(device.getDeviceId(), channelId);
+        channelService.stopPlay(device.getDeviceId(), channelId);
         channelService.stopPlay(device.getDeviceId(), channelId);
         if (inviteInfo.getStreamInfo() != null) {
             mediaServerService.closeRTPServer(inviteInfo.getStreamInfo().getMediaServerId(), inviteInfo.getStream());

+ 0 - 15
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java

@@ -24,21 +24,6 @@ public interface IVideoManagerStorage {
 	 * @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);
 	
 	/**   
 	 * 获取设备

+ 0 - 10
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java

@@ -104,16 +104,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
 	}
 
 
-	@Override
-	public void startPlay(String deviceId, String channelId, String streamId) {
-		deviceChannelMapper.startPlay(deviceId, channelId, streamId);
-	}
-
-	@Override
-	public void stopPlay(String deviceId, String channelId) {
-		deviceChannelMapper.stopPlay(deviceId, channelId);
-	}
-
 	/**
 	 * 获取设备
 	 *

+ 6 - 1
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java

@@ -15,6 +15,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
 import com.genersoft.iot.vmp.media.bean.MediaServer;
 import com.genersoft.iot.vmp.media.service.IMediaServerService;
+import com.genersoft.iot.vmp.service.IDeviceChannelService;
 import com.genersoft.iot.vmp.service.IInviteStreamService;
 import com.genersoft.iot.vmp.service.IPlayService;
 import com.genersoft.iot.vmp.service.bean.InviteErrorCode;
@@ -74,6 +75,10 @@ public class PlayController {
 	@Autowired
 	private UserSetting userSetting;
 
+
+	@Autowired
+	private IDeviceChannelService deviceChannelService;
+
 	@Operation(summary = "开始点播", security = @SecurityRequirement(name = JwtUtils.HEADER))
 	@Parameter(name = "deviceId", description = "设备国标编号", required = true)
 	@Parameter(name = "channelId", description = "通道国标编号", required = true)
@@ -102,7 +107,7 @@ public class PlayController {
 			requestMessage.setData(wvpResult);
 			resultHolder.invokeAllResult(requestMessage);
 			inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channelId);
-			storager.stopPlay(deviceId, channelId);
+			deviceChannelService.stopPlay(deviceId, channelId);
 		});
 
 		// 录像查询以channelId作为deviceId查询

+ 6 - 2
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java

@@ -10,6 +10,7 @@ import com.genersoft.iot.vmp.gb28181.bean.Device;
 import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
 import com.genersoft.iot.vmp.media.bean.MediaServer;
+import com.genersoft.iot.vmp.service.IDeviceChannelService;
 import com.genersoft.iot.vmp.service.IDeviceService;
 import com.genersoft.iot.vmp.service.IInviteStreamService;
 import com.genersoft.iot.vmp.service.IPlayService;
@@ -46,6 +47,9 @@ public class ApiStreamController {
     @Autowired
     private IDeviceService deviceService;
 
+    @Autowired
+    private IDeviceChannelService deviceChannelService;
+
     @Autowired
     private IPlayService playService;
 
@@ -96,7 +100,7 @@ public class ApiStreamController {
             resultJSON.put("error","timeout");
             result.setResult(resultJSON);
             inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, serial, code);
-            storager.stopPlay(serial, code);
+            deviceChannelService.stopPlay(serial, code);
              // 清理RTP server
         });
 
@@ -240,7 +244,7 @@ public class ApiStreamController {
             return result;
         }
         inviteStreamService.removeInviteInfo(inviteInfo);
-        storager.stopPlay(inviteInfo.getDeviceId(), inviteInfo.getChannelId());
+        deviceChannelService.stopPlay(inviteInfo.getDeviceId(), inviteInfo.getChannelId());
         return null;
     }