From bb609b7e09ada9ea9d2e5e2deea3a49de46242e1 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 10 Jul 2024 10:51:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gb28181/dao/CommonGBChannelMapper.java | 8 +- .../vmp/gb28181/dao/DeviceChannelMapper.java | 560 +++++++++--------- .../iot/vmp/gb28181/dao/DeviceMapper.java | 15 +- .../gb28181/dao/PlatformChannelMapper.java | 2 +- .../cmd/CatalogResponseMessageHandler.java | 5 +- .../impl/DeviceChannelServiceImpl.java | 35 +- .../iot/vmp/streamProxy/bean/StreamProxy.java | 3 + .../streamProxy/dao/StreamProxyMapper.java | 25 +- .../service/impl/StreamProxyServiceImpl.java | 30 +- 数据库/2.7.2-重构/初始化-mysql-2.7.2.sql | 1 + 10 files changed, 345 insertions(+), 339 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java index c100e9ab..29450730 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java @@ -55,7 +55,7 @@ public interface CommonGBChannelMapper { " coalesce(gb_business_group_id, business_group_id) as gb_business_group_id,\n" + " coalesce(gb_download_speed, download_speed) as gb_download_speed,\n" + " coalesce(gb_svc_space_support_mod, svc_space_support_mod) as gb_svc_space_support_mod,\n" + - " coalesce(gb_svc_time_support_mode svc_time_support_mode) as gb_svc_time_support_mode\n" + + " coalesce(gb_svc_time_support_mode,svc_time_support_mode) as gb_svc_time_support_mode\n" + "from wvp_device_channel\n" + "where gb_device_id = #{gbDeviceId} or device_id = #{gbDeviceId}") CommonGBChannel queryByDeviceId(@Param("gbDeviceId") String gbDeviceId); @@ -198,7 +198,7 @@ public interface CommonGBChannelMapper { " coalesce(gb_business_group_id, business_group_id) as gb_business_group_id,\n" + " coalesce(gb_download_speed, download_speed) as gb_download_speed,\n" + " coalesce(gb_svc_space_support_mod, svc_space_support_mod) as gb_svc_space_support_mod,\n" + - " coalesce(gb_svc_time_support_mode svc_time_support_mode) as gb_svc_time_support_mode\n" + + " coalesce(gb_svc_time_support_mode, svc_time_support_mode) as gb_svc_time_support_mode\n" + " from wvp_device_channel" + " where id = #{gbId}") CommonGBChannel queryById(@Param("gbId") int gbId); @@ -355,7 +355,7 @@ public interface CommonGBChannelMapper { " coalesce(gb_business_group_id, business_group_id) as gb_business_group_id,\n" + " coalesce(gb_download_speed, download_speed) as gb_download_speed,\n" + " coalesce(gb_svc_space_support_mod, svc_space_support_mod) as gb_svc_space_support_mod,\n" + - " coalesce(gb_svc_time_support_mode svc_time_support_mode) as gb_svc_time_support_mode\n" + + " coalesce(gb_svc_time_support_mode,svc_time_support_mode) as gb_svc_time_support_mode\n" + " from wvp_device_channel" + " where gb_status=#{status} and id in " + " #{item.gbId}" + @@ -471,7 +471,7 @@ public interface CommonGBChannelMapper { " coalesce(wpgc.business_group_id, wdc.gb_business_group_id, wdc.business_group_id) as gb_business_group_id,\n" + " coalesce(wdc.gb_download_speed, wdc.download_speed) as gb_download_speed,\n" + " coalesce(wdc.gb_svc_space_support_mod, wdc.svc_space_support_mod) as gb_svc_space_support_mod,\n" + - " coalesce(wdc.gb_svc_time_support_mode wdc.svc_time_support_mode) as gb_svc_time_support_mode\n" + + " coalesce(wdc.gb_svc_time_support_mode,wdc.svc_time_support_mode) as gb_svc_time_support_mode\n" + "from wvp_device_channel wdc left join wvp_platform_gb_channel wpgc on wdc.id = wpgc.device_channel_id\n" + "where wpgc.platform_id = #{platformId}"}) List queryByPlatformId(@Param("platformId") Integer platformId); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java index 3cbab872..325ec32a 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java @@ -17,12 +17,12 @@ import java.util.List; @Repository public interface DeviceChannelMapper { - @Insert("INSERT INTO wvp_device_channel (device_id, device_db_id, name, manufacture, model, owner, civil_code, block, " + + @Insert("INSERT INTO wvp_device_channel (device_id, device_db_id, name, manufacturer, model, owner, civil_code, block, " + "address, parental, parent_id, safety_way, register_way, cert_num, certifiable, err_code, end_time, secrecy, " + "ip_address, port, password, status, longitude, latitude, ptz_type, position_type, room_type, use_type, " + "supply_light_type, direction_type, resolution, business_group_id, download_speed, svc_space_support_mod, " + "svc_time_support_mode, create_time, update_time, sub_count,stream_id, has_audio, gps_time, stream_identification) " + - "VALUES (#{deviceId}, #{deviceDbId}, #{name}, #{manufacture}, #{model}, #{owner}, #{civilCode}, #{block}," + + "VALUES (#{deviceId}, #{deviceDbId}, #{name}, #{manufacturer}, #{model}, #{owner}, #{civilCode}, #{block}," + "#{address}, #{parental}, #{parentId}, #{safetyWay}, #{registerWay}, #{certNum}, #{certifiable}, #{errCode}, #{endTime}, #{secrecy}, " + "#{ipAddress}, #{port}, #{password}, #{status}, #{longitude}, #{latitude}, #{ptzType}, #{positionType}, #{roomType}, #{useType}, " + "#{supplyLightType}, #{directionType}, #{resolution}, #{businessGroupId}, #{downloadSpeed}, #{svcSpaceSupportMod}," + @@ -35,7 +35,7 @@ public interface DeviceChannelMapper { ", device_id=#{deviceId}" + ", device_db_id=#{deviceDbId}" + ", name=#{name}" + - ", manufacture=#{manufacture}" + + ", manufacturer#{manufacturer}" + ", model=#{model}" + ", owner=#{owner}" + ", civil_code=#{civilCode}" + @@ -118,55 +118,55 @@ public interface DeviceChannelMapper { @Select(value = {" "}) List queryChannels(@Param("deviceId") String deviceId, @Param("parentChannelId") String parentChannelId, @Param("query") String query, @Param("hasSubChannel") Boolean hasSubChannel, @Param("online") Boolean online, @Param("channelIds") List channelIds); @Select("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" + + " 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 queryChannelsByDeviceDbId(@Param("deviceDbId") int deviceDbId); @@ -242,7 +242,7 @@ public interface DeviceChannelMapper { "LEFT JOIN wvp_device de ON dc.device_db_id = de.id " + "WHERE 1=1" + " AND de.device_id = #{deviceId} " + - " AND (dc.channel_id LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%') " + + " AND (dc.device_id LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%') " + " AND dc.parent_id=#{parentChannelId} " + " AND dc.status=1" + " AND dc.status=0" + @@ -251,53 +251,53 @@ public interface DeviceChannelMapper { " AND dc.device_id in " + "#{item} " + " " + - "ORDER BY dc.channel_id ASC" + + "ORDER BY dc.device_id ASC" + " "}) List queryChannelsWithDeviceInfo(@Param("deviceId") String deviceId, @Param("parentChannelId") String parentChannelId, @Param("query") String query, @Param("hasSubChannel") Boolean hasSubChannel, @Param("online") Boolean online, @Param("channelIds") List channelIds); @Select("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" + + " 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}") @@ -318,14 +318,14 @@ public interface DeviceChannelMapper { @Select(value = {" "}) int batchUpdate(List updateChannels); @Update(" update wvp_device_channel" + " set sub_count = (select *" + - " from (select count(0)" + - " from wvp_device_channel" + - " where device_db_id = #{deviceDbId} and parent_id = #{channelId}) as temp)" + + " from (select count(0)" + + " from wvp_device_channel" + + " where device_db_id = #{deviceDbId} and parent_id = #{channelId}) as temp)" + " where device_db_id = #{deviceDbId} and device_id = #{channelId}") int updateChannelSubCount(@Param("deviceDbId") int deviceDbId, @Param("channelId") String channelId); @@ -485,53 +485,53 @@ public interface DeviceChannelMapper { int updatePosition(DeviceChannel deviceChannel); @Select("select " + - " 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" + + " 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 where device_db_id = #{deviceDbId}") List queryAllChannels(@Param("deviceDbId") int deviceDbId); - @Select("select de.* from wvp_device de left join wvp_device_channel dc on de.device_id = dc.deviceId where dc.channel_id=#{channelId}") + @Select("select de.* from wvp_device de left join wvp_device_channel dc on de.device_id = dc.deviceId where dc.device_id=#{channelId}") List getDeviceByChannelId(String channelId); @@ -565,49 +565,49 @@ public interface DeviceChannelMapper { @Select(value = {" " ) List getDevices(Boolean onLine); @@ -174,6 +176,7 @@ public interface DeviceMapper { int del(String deviceId); @Select("SELECT " + + "id, " + "device_id, " + "coalesce(custom_name, name) as name, " + "password, " + @@ -204,7 +207,9 @@ public interface DeviceMapper { "on_line"+ " FROM wvp_device WHERE on_line = true") List getOnlineDevices(); + @Select("SELECT " + + "id,"+ "device_id,"+ "coalesce(custom_name,name)as name,"+ "password,"+ diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformChannelMapper.java index 0fc0a0db..724215df 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformChannelMapper.java @@ -117,6 +117,6 @@ public interface PlatformChannelMapper { "where dc.channel_id = #{channelId} and pgc.platform_id=#{platformId}") List 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}") + @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.device_id=#{channelId}") List queryParentPlatformByChannelId(@Param("channelId") String channelId); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java index eee131f7..83e44b96 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java @@ -106,7 +106,6 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp Iterator deviceListIterator = deviceListElement.elementIterator(); if (deviceListIterator != null) { List channelList = new ArrayList<>(); - List parentChannelIds = new ArrayList<>(); // 遍历DeviceList while (deviceListIterator.hasNext()) { Element itemDevice = deviceListIterator.next(); @@ -115,16 +114,14 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp continue; } DeviceChannel channel = DeviceChannel.decode(itemDevice); -// DeviceChannel channel = XmlUtil.channelContentHandler(itemDevice, device, null); if (channel == null || channel.getDeviceId() == null) { log.info("[收到目录订阅]:但是解析失败 {}", new String(evt.getRequest().getRawContent())); continue; } + channel.setDeviceDbId(device.getId()); if (channel.getParentId() != null && channel.getParentId().equals(sipConfig.getId())) { channel.setParentId(null); } - channel.setDeviceId(take.getDevice().getDeviceId()); - channelList.add(channel); } int sn = Integer.parseInt(snElement.getText()); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java index d7a95eee..46ef5e78 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java @@ -9,15 +9,15 @@ import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.MobilePosition; +import com.genersoft.iot.vmp.gb28181.dao.DeviceChannelMapper; +import com.genersoft.iot.vmp.gb28181.dao.DeviceMapper; +import com.genersoft.iot.vmp.gb28181.dao.DeviceMobilePositionMapper; +import com.genersoft.iot.vmp.gb28181.dao.PlatformChannelMapper; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; import com.genersoft.iot.vmp.service.IDeviceChannelService; import com.genersoft.iot.vmp.service.IInviteStreamService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.gb28181.dao.DeviceChannelMapper; -import com.genersoft.iot.vmp.gb28181.dao.DeviceMapper; -import com.genersoft.iot.vmp.gb28181.dao.DeviceMobilePositionMapper; -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; @@ -31,7 +31,6 @@ import org.springframework.util.ObjectUtils; import java.util.*; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArrayList; /** * @author lin @@ -90,7 +89,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { List addChannels = new ArrayList<>(); List updateChannels = new ArrayList<>(); HashMap channelsInStore = new HashMap<>(); - if (channels != null && channels.size() > 0) { + if (channels != null && !channels.isEmpty()) { List channelList = channelMapper.queryChannelsByDeviceDbId(device.getId()); if (channelList.isEmpty()) { for (DeviceChannel channel : channels) { @@ -106,17 +105,18 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { } }else { for (DeviceChannel deviceChannel : channelList) { - channelsInStore.put(deviceChannel.getDeviceId(), deviceChannel); + channelsInStore.put(deviceChannel.getDeviceDbId() + deviceChannel.getDeviceId(), deviceChannel); } for (DeviceChannel channel : channels) { - 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()); } String now = DateUtil.getNow(); channel.setUpdateTime(now); - if (channelsInStore.get(channel.getDeviceId()) != null) { + DeviceChannel deviceChannelInDb = channelsInStore.get(channel.getDeviceDbId() + channel.getDeviceId()); + if ( deviceChannelInDb != null) { + channel.setId(deviceChannelInDb.getId()); updateChannels.add(channel); }else { addChannels.add(channel); @@ -399,9 +399,9 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { } List allChannels = channelMapper.queryAllChannels(device.getId()); Map allChannelMap = new ConcurrentHashMap<>(); - if (allChannels.size() > 0) { + if (!allChannels.isEmpty()) { for (DeviceChannel deviceChannel : allChannels) { - allChannelMap.put(deviceChannel.getDeviceId(), deviceChannel); + allChannelMap.put(deviceChannel.getDeviceDbId() + deviceChannel.getDeviceId(), deviceChannel); } } // 数据去重 @@ -421,17 +421,18 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { continue; } gbIdSet.add(deviceChannel.getDeviceId()); - if (allChannelMap.containsKey(deviceChannel.getDeviceId())) { - deviceChannel.setStreamId(allChannelMap.get(deviceChannel.getDeviceId()).getStreamId()); - deviceChannel.setHasAudio(allChannelMap.get(deviceChannel.getDeviceId()).getHasAudio()); - if (allChannelMap.get(deviceChannel.getDeviceId()).getStatus().equalsIgnoreCase(deviceChannel.getStatus())){ + DeviceChannel channelInDb = allChannelMap.get(deviceChannel.getDeviceDbId() + deviceChannel.getDeviceId()); + if (channelInDb != null) { + deviceChannel.setStreamId(channelInDb.getStreamId()); + deviceChannel.setHasAudio(channelInDb.getHasAudio()); + deviceChannel.setId(channelInDb.getId()); + if (channelInDb.getStatus().equalsIgnoreCase(deviceChannel.getStatus())){ List strings = platformChannelMapper.queryParentPlatformByChannelId(deviceChannel.getDeviceId()); if (!CollectionUtils.isEmpty(strings)){ strings.forEach(platformId->{ eventPublisher.catalogEventPublish(platformId, deviceChannel, deviceChannel.getStatus().equals("ON")? CatalogEvent.ON:CatalogEvent.OFF); }); } - } deviceChannel.setUpdateTime(DateUtil.getNow()); updateChannels.add(deviceChannel); @@ -440,7 +441,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { deviceChannel.setUpdateTime(DateUtil.getNow()); addChannels.add(deviceChannel); } - allChannelMap.remove(deviceChannel.getDeviceId()); + allChannelMap.remove(deviceChannel.getDeviceDbId() + deviceChannel.getDeviceId()); channels.add(deviceChannel); if (!ObjectUtils.isEmpty(deviceChannel.getParentId())) { if (subContMap.get(deviceChannel.getParentId()) == null) { diff --git a/src/main/java/com/genersoft/iot/vmp/streamProxy/bean/StreamProxy.java b/src/main/java/com/genersoft/iot/vmp/streamProxy/bean/StreamProxy.java index 0d7c97de..786ba39c 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamProxy/bean/StreamProxy.java +++ b/src/main/java/com/genersoft/iot/vmp/streamProxy/bean/StreamProxy.java @@ -62,6 +62,9 @@ public class StreamProxy extends CommonGBChannel { @Schema(description = "拉流代理时zlm返回的key,用于停止拉流代理") private String streamKey; + @Schema(description = "拉流状态") + private Boolean status; + @Schema(description = "更新时间") private String updateTime; diff --git a/src/main/java/com/genersoft/iot/vmp/streamProxy/dao/StreamProxyMapper.java b/src/main/java/com/genersoft/iot/vmp/streamProxy/dao/StreamProxyMapper.java index 004690a2..c1eccb5a 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamProxy/dao/StreamProxyMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/streamProxy/dao/StreamProxyMapper.java @@ -88,12 +88,25 @@ public interface StreamProxyMapper { @Select("select count(1) from wvp_stream_proxy where status = true") int getOnline(); - /** - * 查询设置了自动移除并且没有国标编号的代理 - */ - List selectWithAutoRemoveAndWithoutGbDeviceIdByMediaServerId(String mediaServerId); - - int delete(int id); + @Delete("DELETE FROM wvp_stream_proxy WHERE id=#{id}") + int delete(@Param("id") int id); + @Delete(value = "") void deleteByList(List streamProxiesForRemove); + + @Update("UPDATE wvp_stream_proxy " + + "SET status=true " + + "WHERE id=#{id}") + int online(@Param("id") int id); + + @Update("UPDATE wvp_stream_proxy " + + "SET status=false " + + "WHERE id=#{id}") + int offline(@Param("id") int id); } diff --git a/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java index 9b2e84ca..d5d45040 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java @@ -3,13 +3,11 @@ package com.genersoft.iot.vmp.streamProxy.service.impl; import com.alibaba.fastjson2.JSONObject; import com.baomidou.dynamic.datasource.annotation.DS; import com.genersoft.iot.vmp.common.StreamInfo; -import com.genersoft.iot.vmp.conf.DynamicTask; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; import com.genersoft.iot.vmp.gb28181.service.IGbChannelService; import com.genersoft.iot.vmp.media.bean.MediaServer; -import com.genersoft.iot.vmp.media.event.hook.HookSubscribe; import com.genersoft.iot.vmp.media.event.media.MediaArrivalEvent; import com.genersoft.iot.vmp.media.event.media.MediaDepartureEvent; import com.genersoft.iot.vmp.media.event.media.MediaNotFoundEvent; @@ -18,8 +16,6 @@ import com.genersoft.iot.vmp.media.event.mediaServer.MediaServerOnlineEvent; import com.genersoft.iot.vmp.media.service.IMediaServerService; import com.genersoft.iot.vmp.media.zlm.dto.hook.OriginType; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.gb28181.dao.PlatformGbStreamMapper; import com.genersoft.iot.vmp.streamProxy.bean.StreamProxy; import com.genersoft.iot.vmp.streamProxy.dao.StreamProxyMapper; import com.genersoft.iot.vmp.streamProxy.service.IStreamProxyService; @@ -57,27 +53,15 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @Autowired private IRedisCatchStorage redisCatchStorage; - @Autowired - private IVideoManagerStorage storager; - @Autowired private UserSetting userSetting; @Autowired private IGbChannelService gbChannelService; - @Autowired - private PlatformGbStreamMapper platformGbStreamMapper; - @Autowired private IMediaServerService mediaServerService; - @Autowired - private HookSubscribe hookSubscribe; - - @Autowired - private DynamicTask dynamicTask; - @Autowired DataSourceTransactionManager dataSourceTransactionManager; @@ -407,16 +391,18 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @Transactional public int updateStatusByAppAndStream(String app, String stream, boolean status) { // 状态变化时推送到国标上级 - StreamProxy streamProxyItem = streamProxyMapper.selectOne(app, stream); - if (streamProxyItem == null) { + StreamProxy streamProxy = streamProxyMapper.selectOne(app, stream); + if (streamProxy == null) { return 0; } - streamProxyItem.setGbStatus(status?1:0); - if (streamProxyItem.getGbId() > 0) { + streamProxy.setStatus(true); + streamProxyMapper.online(streamProxy.getId()); + streamProxy.setGbStatus(status?1:0); + if (streamProxy.getGbId() > 0) { if (status) { - gbChannelService.online(streamProxyItem.getCommonGBChannel()); + gbChannelService.online(streamProxy.getCommonGBChannel()); }else { - gbChannelService.offline(streamProxyItem.getCommonGBChannel()); + gbChannelService.offline(streamProxy.getCommonGBChannel()); } } diff --git a/数据库/2.7.2-重构/初始化-mysql-2.7.2.sql b/数据库/2.7.2-重构/初始化-mysql-2.7.2.sql index 46c5e7b0..dcca7599 100644 --- a/数据库/2.7.2-重构/初始化-mysql-2.7.2.sql +++ b/数据库/2.7.2-重构/初始化-mysql-2.7.2.sql @@ -292,6 +292,7 @@ create table wvp_stream_proxy ( media_server_id character varying(50), enable_audio bool default false, enable_mp4 bool default false, + status bool default false, enable bool default false, enable_remove_none_reader bool default false, create_time character varying(50),