diff --git a/src/main/java/com/genersoft/iot/vmp/common/enums/ChannelDataType.java b/src/main/java/com/genersoft/iot/vmp/common/enums/ChannelDataType.java index 07e3a92a9..5ca590252 100644 --- a/src/main/java/com/genersoft/iot/vmp/common/enums/ChannelDataType.java +++ b/src/main/java/com/genersoft/iot/vmp/common/enums/ChannelDataType.java @@ -10,7 +10,6 @@ import lombok.Getter; public enum ChannelDataType { GB28181(1,"国标28181"), - STREAM_PUSH(2,"推流设备"), STREAM_PROXY(3,"拉流代理"); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java index 28eb01a8e..924a8ca72 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java @@ -1,5 +1,6 @@ package com.genersoft.iot.vmp.gb28181.bean; +import com.genersoft.iot.vmp.common.enums.ChannelDataType; import com.genersoft.iot.vmp.gb28181.utils.MessageElementForCatalog; import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; import io.swagger.v3.oas.annotations.media.Schema; @@ -20,9 +21,6 @@ public class DeviceChannel extends CommonGBChannel { @Schema(description = "数据库自增ID") private int id; - @Schema(description = "设备的数据库自增ID") - private Integer deviceDbId; - @MessageElementForCatalog("DeviceID") @Schema(description = "编码") private String deviceId; @@ -191,6 +189,8 @@ public class DeviceChannel extends CommonGBChannel { @Schema(description = "通道类型, 默认0, 0: 普通通道,1 行政区划 2 业务分组/虚拟组织") private int channelType; + private Integer dataType = ChannelDataType.GB28181.value; + public void setPtzType(int ptzType) { this.ptzType = ptzType; switch (ptzType) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceQuery.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceQuery.java index 5e9ee17e7..226e51d8b 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceQuery.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceQuery.java @@ -241,7 +241,7 @@ public class DeviceQuery { return deviceChannelPageResult; } - return deviceChannelService.getSubChannels(deviceChannel.getDeviceDbId(), channelId, query, channelType, online, page, count); + return deviceChannelService.getSubChannels(deviceChannel.getDataDeviceId(), channelId, query, channelType, online, page, count); } @Operation(summary = "开启/关闭通道的音频", security = @SecurityRequirement(name = JwtUtils.HEADER)) 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 507f8dd8d..a00ef36e6 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 @@ -20,8 +20,8 @@ public interface CommonGBChannelMapper { @Insert(" <script>" + "INSERT INTO wvp_device_channel (" + "gb_device_id," + - " <if test='streamProxyId != null' > stream_proxy_id,</if>" + - " <if test='streamPushId != null' > stream_push_id,</if>" + + "data_type," + + "data_device_id," + "create_time," + "update_time," + "gb_name," + @@ -59,8 +59,8 @@ public interface CommonGBChannelMapper { "gb_svc_time_support_mode ) " + "VALUES (" + "#{gbDeviceId}, " + - " <if test='streamProxyId != null' > #{streamProxyId},</if>" + - " <if test='streamPushId != null' > #{streamPushId},</if>" + + "#{dataType}, " + + "#{dataDeviceId}, " + "#{createTime}, " + "#{updateTime}, " + "#{gbName}, " + @@ -168,8 +168,8 @@ public interface CommonGBChannelMapper { @Insert(" <script>" + "INSERT INTO wvp_device_channel (" + "gb_device_id," + - "stream_proxy_id, " + - "stream_push_id," + + "data_type, " + + "data_device_id," + "create_time," + "update_time," + "gb_name," + @@ -207,7 +207,7 @@ public interface CommonGBChannelMapper { "gb_svc_time_support_mode ) " + "VALUES" + "<foreach collection='commonGBChannels' index='index' item='item' separator=','> " + - "(#{item.gbDeviceId}, #{item.streamProxyId}, #{item.streamPushId},#{item.createTime},#{item.updateTime}," + + "(#{item.gbDeviceId}, #{item.dataType}, #{item.dataDeviceId},#{item.createTime},#{item.updateTime}," + "#{item.gbName},#{item.gbManufacturer}, #{item.gbModel}," + "#{item.gbOwner},#{item.gbCivilCode},#{item.gbBlock}, #{item.gbAddress}, #{item.gbParental}, #{item.gbParentId},#{item.gbSafetyWay}, " + "#{item.gbRegisterWay},#{item.gbCertNum},#{item.gbCertifiable},#{item.gbErrCode},#{item.gbEndTime}, #{item.gbSecrecy},#{item.gbIpAddress}," + @@ -235,9 +235,9 @@ public interface CommonGBChannelMapper { " gb_ptz_type = null, gb_position_type = null, gb_room_type = null, gb_use_type = null, gb_supply_light_type = null, " + " gb_direction_type = null, gb_resolution = null, gb_business_group_id = null, gb_download_speed = null, gb_svc_space_support_mod = null, " + " gb_svc_time_support_mode = null" + - " WHERE id = #{id} and device_db_id = #{gbDeviceDbId}"+ + " WHERE id = #{id} and data_type = #{dataType} and data_device_id = #{dataDeviceId}"+ " </script>"}) - void reset(@Param("id") int id, @Param("gbDeviceDbId") int gbDeviceDbId, @Param("updateTime") String updateTime); + void reset(@Param("id") int id, @Param("dataType") Integer dataType, @Param("dataDeviceId") int dataDeviceId, @Param("updateTime") String updateTime); @SelectProvider(type = ChannelProvider.class, method = "queryByIds") @@ -252,13 +252,13 @@ public interface CommonGBChannelMapper { @SelectProvider(type = ChannelProvider.class, method = "queryListByCivilCode") List<CommonGBChannel> queryListByCivilCode(@Param("query") String query, @Param("online") Boolean online, - @Param("channelType") Integer channelType, @Param("civilCode") String civilCode); + @Param("dataType") Integer dataType, @Param("civilCode") String civilCode); @SelectProvider(type = ChannelProvider.class, method = "queryListByParentId") List<CommonGBChannel> queryListByParentId(@Param("query") String query, @Param("online") Boolean online, - @Param("channelType") Integer channelType, @Param("groupDeviceId") String groupDeviceId); + @Param("dataType") Integer dataType, @Param("groupDeviceId") String groupDeviceId); @@ -311,14 +311,14 @@ public interface CommonGBChannelMapper { List<CommonGBChannel> queryByCivilCode(@Param("civilCode") String civilCode); @SelectProvider(type = ChannelProvider.class, method = "queryByGbDeviceIds") - List<CommonGBChannel> queryByGbDeviceIds(List<Integer> deviceIds); + List<CommonGBChannel> queryByGbDeviceIds(@Param("dataType") Integer dataType, List<Integer> deviceIds); @Select(value = {" <script>" + " select id from wvp_device_channel " + - " where channel_type = 0 and device_db_id in "+ + " where channel_type = 0 and data_type = #{dataType} and data_device_id in "+ " <foreach collection='deviceIds' item='item' open='(' separator=',' close=')' > #{item}</foreach>" + " </script>"}) - List<Integer> queryByGbDeviceIdsForIds(List<Integer> deviceIds); + List<Integer> queryByGbDeviceIdsForIds(@Param("dataType") Integer dataType, List<Integer> deviceIds); @SelectProvider(type = ChannelProvider.class, method = "queryByGroupList") List<CommonGBChannel> queryByGroupList(List<Group> groupList); @@ -440,19 +440,20 @@ public interface CommonGBChannelMapper { int updateCivilCodeByChannelList(@Param("civilCode") String civilCode, List<CommonGBChannel> channelList); @SelectProvider(type = ChannelProvider.class, method = "queryListByStreamPushList") - List<CommonGBChannel> queryListByStreamPushList(List<StreamPush> streamPushList); + List<CommonGBChannel> queryListByStreamPushList(@Param("dataType") Integer dataType, List<StreamPush> streamPushList); @Update(value = {" <script>" + " <foreach collection='channels' item='item' separator=';' >" + " UPDATE wvp_device_channel " + " SET gb_longitude=#{item.gbLongitude}, gb_latitude=#{item.gbLatitude} " + - " WHERE stream_push_id IS NOT NULL AND gb_device_id=#{item.gbDeviceId} "+ + " WHERE data_type = #{dataType} AND gb_device_id=#{item.gbDeviceId} "+ "</foreach>"+ " </script>"}) - void updateGpsByDeviceIdForStreamPush(List<CommonGBChannel> channels); + void updateGpsByDeviceIdForStreamPush(@Param("dataType") Integer dataType, List<CommonGBChannel> channels); @SelectProvider(type = ChannelProvider.class, method = "queryList") - List<CommonGBChannel> queryList(@Param("query") String query, @Param("online") Boolean online, @Param("hasRecordPlan") Boolean hasRecordPlan, @Param("channelType") Integer channelType); + List<CommonGBChannel> queryList(@Param("query") String query, @Param("online") Boolean online, + @Param("hasRecordPlan") Boolean hasRecordPlan, @Param("dataType") Integer dataType); @Update(value = {" <script>" + " UPDATE wvp_device_channel " + @@ -487,9 +488,8 @@ public interface CommonGBChannelMapper { @Select("<script>" + " select " + " wdc.id as gb_id,\n" + - " wdc.device_db_id as gb_device_db_id,\n" + - " wdc.stream_push_id,\n" + - " wdc.stream_proxy_id,\n" + + " wdc.data_type,\n" + + " wdc.data_device_id,\n" + " wdc.create_time,\n" + " wdc.update_time,\n" + " wdc.record_plan_id,\n" + @@ -536,12 +536,10 @@ public interface CommonGBChannelMapper { " <if test='online == false'> AND coalesce(wdc.gb_status, wdc.status) = 'OFF'</if> " + " <if test='hasLink == true'> AND wdc.record_plan_id = #{planId}</if> " + " <if test='hasLink == false'> AND wdc.record_plan_id is null</if> " + - " <if test='channelType == 0'> AND wdc.device_db_id is not null</if> " + - " <if test='channelType == 1'> AND wdc.stream_push_id is not null</if> " + - " <if test='channelType == 2'> AND wdc.stream_proxy_id is not null</if> " + + " <if test='dataType != null'> AND wdc.data_type = #{dataType}</if> " + "</script>") List<CommonGBChannel> queryForRecordPlanForWebList(@Param("planId") Integer planId, @Param("query") String query, - @Param("channelType") Integer channelType, @Param("online") Boolean online, + @Param("dataType") Integer dataType, @Param("online") Boolean online, @Param("hasLink") Boolean hasLink); @SelectProvider(type = ChannelProvider.class, method = "queryByDataId") 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 068eb4b79..b33a7dc02 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 @@ -21,13 +21,13 @@ public interface DeviceChannelMapper { @Insert("<script> " + "insert into wvp_device_channel " + - "(device_id, device_db_id, name, manufacturer, model, owner, civil_code, block, " + + "(device_id, data_type, data_device_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, channel_type) " + "values " + - "(#{deviceId}, #{deviceDbId}, #{name}, #{manufacturer}, #{model}, #{owner}, #{civilCode}, #{block}, " + + "(#{deviceId}, #{dataType}, #{dataDeviceId}, #{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}," + @@ -40,7 +40,8 @@ public interface DeviceChannelMapper { "UPDATE wvp_device_channel " + "SET update_time=#{updateTime}" + ", device_id=#{deviceId}" + - ", device_db_id=#{deviceDbId}" + + ", data_type=#{dataType}" + + ", data_device_id=#{dataDeviceId}" + ", name=#{name}" + ", manufacturer=#{manufacturer}" + ", model=#{model}" + @@ -85,22 +86,22 @@ public interface DeviceChannelMapper { int update(DeviceChannel channel); @SelectProvider(type = DeviceChannelProvider.class, method = "queryChannels") - List<DeviceChannel> queryChannels(@Param("deviceDbId") int deviceDbId, @Param("civilCode") String civilCode, + List<DeviceChannel> queryChannels(@Param("dataDeviceId") int dataDeviceId, @Param("civilCode") String civilCode, @Param("businessGroupId") String businessGroupId, @Param("parentChannelId") String parentChannelId, @Param("query") String query, @Param("hasSubChannel") Boolean hasSubChannel, @Param("online") Boolean online, @Param("channelIds") List<String> channelIds); @SelectProvider(type = DeviceChannelProvider.class, method = "queryChannelsByDeviceDbId") - List<DeviceChannel> queryChannelsByDeviceDbId(@Param("deviceDbId") int deviceDbId); + List<DeviceChannel> queryChannelsByDeviceDbId(@Param("dataDeviceId") int dataDeviceId); - @Select(value = {" <script> " + - "select id from wvp_device_channel where device_db_id in " + + @Select("<script> " + + "select id from wvp_device_channel where data_type =1 and data_device_id in " + " <foreach item='item' index='index' collection='deviceDbIds' open='(' separator=',' close=')'> #{item} </foreach>" + - " </script>"}) + " </script>") List<Integer> queryChaneIdListByDeviceDbIds(List<Integer> deviceDbIds); - @Delete("DELETE FROM wvp_device_channel WHERE device_db_id=#{deviceId}") - int cleanChannelsByDeviceId(@Param("deviceId") int deviceId); + @Delete("DELETE FROM wvp_device_channel WHERE data_type =1 and data_device_id=#{deviceId}") + int cleanChannelsByDeviceId(@Param("dataDeviceId") int dataDeviceId); @Delete("DELETE FROM wvp_device_channel WHERE id=#{id}") int del(@Param("id") int id); @@ -141,8 +142,8 @@ public interface DeviceChannelMapper { " coalesce(dc.gb_business_group_id, dc.business_group_id) as business_group_id " + " from " + " wvp_device_channel dc " + - " LEFT JOIN wvp_device de ON dc.device_db_id = de.id " + - " WHERE 1=1" + + " LEFT JOIN wvp_device de ON dc.data_device_id = de.id " + + " WHERE dc.data_type = 1 " + " <if test='deviceId != null'> AND de.device_id = #{deviceId} </if> " + " <if test='query != null'> AND (dc.device_id LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " + " <if test='parentChannelId != null'> AND dc.parent_id=#{parentChannelId} </if> " + @@ -155,7 +156,7 @@ public interface DeviceChannelMapper { "</foreach> </if>" + "ORDER BY dc.device_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); + 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); @Update(value = {"UPDATE wvp_device_channel SET stream_id=#{streamId} WHERE id=#{channelId}"}) void startPlay(@Param("channelId") Integer channelId, @Param("streamId") String streamId); @@ -172,9 +173,9 @@ public interface DeviceChannelMapper { " 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_db_id = de.id " + + " LEFT JOIN wvp_device de ON dc.data_device_id = de.id " + " LEFT JOIN wvp_platform_channel pgc on pgc.device_channel_id = dc.id " + - " WHERE 1=1 " + + " WHERE dc.data_type = 1 " + " <if test='query != null'> " + "AND " + "(COALESCE(dc.gb_device_id, dc.device_id) LIKE concat('%',#{query},'%') " + @@ -195,14 +196,14 @@ public interface DeviceChannelMapper { @Insert("<script> " + "insert into wvp_device_channel " + - "(device_id, device_db_id, name, manufacturer, model, owner, civil_code, block, " + + "(device_id, data_type, data_device_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, channel_type) " + "values " + "<foreach collection='addChannels' index='index' item='item' separator=','> " + - "(#{item.deviceId}, #{item.deviceDbId}, #{item.name}, #{item.manufacturer}, #{item.model}, #{item.owner}, #{item.civilCode}, #{item.block}, " + + "(#{item.deviceId}, #{item.dataType}, #{item.dataDeviceId}, #{item.name}, #{item.manufacturer}, #{item.model}, #{item.owner}, #{item.civilCode}, #{item.block}, " + "#{item.address}, #{item.parental}, #{item.parentId}, #{item.safetyWay}, #{item.registerWay}, #{item.certNum}, #{item.certifiable}, #{item.errCode}, #{item.endTime}, #{item.secrecy}, " + "#{item.ipAddress}, #{item.port}, #{item.password}, #{item.status}, #{item.longitude}, #{item.latitude}, #{item.ptzType}, #{item.positionType}, #{item.roomType}, #{item.useType}, " + "#{item.supplyLightType}, #{item.directionType}, #{item.resolution}, #{item.businessGroupId}, #{item.downloadSpeed}, #{item.svcSpaceSupportMod}," + @@ -221,7 +222,8 @@ public interface DeviceChannelMapper { " wvp_device_channel" + " SET update_time=#{item.updateTime}" + ", device_id=#{item.deviceId}" + - ", device_db_id=#{item.deviceDbId}" + + ", data_type=#{item.dataType}" + + ", data_device_id=#{item.dataDeviceId}" + ", name=#{item.name}" + ", manufacturer=#{item.manufacturer}" + ", model=#{item.model}" + @@ -273,7 +275,8 @@ public interface DeviceChannelMapper { " wvp_device_channel" + " SET update_time=#{item.updateTime}" + ", device_id=#{item.deviceId}" + - ", device_db_id=#{item.deviceDbId}" + + ", data_type=#{item.dataType}" + + ", data_device_id=#{item.dataDeviceId}" + ", name=#{item.name}" + ", manufacturer=#{item.manufacturer}" + ", model=#{item.model}" + @@ -313,7 +316,7 @@ public interface DeviceChannelMapper { ", gps_time=#{item.gpsTime}" + ", stream_identification=#{item.streamIdentification}" + ", channel_type=#{item.channelType}" + - " WHERE device_db_id = #{item.deviceDbId} and device_id=#{item.deviceId}" + + " WHERE data_type = #{item.dataType} and data_device_id = #{item.dataDeviceId} and device_id=#{item.deviceId}" + "</foreach>" + "</script>"}) int batchUpdateForNotify(List<DeviceChannel> updateChannels); @@ -322,9 +325,9 @@ public interface DeviceChannelMapper { " set sub_count = (select *" + " 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); + " where data_type = 1 and data_device_id = #{dataDeviceId} and parent_id = #{channelId}) as temp)" + + " where data_type = 1 and data_device_id = #{dataDeviceId} and device_id = #{channelId}") + int updateChannelSubCount(@Param("dataDeviceId") int dataDeviceId, @Param("channelId") String channelId); @Update(value = {" <script>" + " UPDATE wvp_device_channel " + @@ -338,7 +341,7 @@ public interface DeviceChannelMapper { @Select("select " + " id,\n" + - " device_db_id,\n" + + " data_device_id,\n" + " create_time,\n" + " update_time,\n" + " sub_count,\n" + @@ -381,11 +384,11 @@ public interface DeviceChannelMapper { " download_speed,\n" + " svc_space_support_mod,\n" + " svc_time_support_mode\n" + - " from wvp_device_channel where device_db_id = #{deviceDbId}") - List<DeviceChannel> queryAllChannelsForRefresh(@Param("deviceDbId") int deviceDbId); + " from wvp_device_channel where data_type = 1 and data_device_id = #{dataDeviceId}") + List<DeviceChannel> queryAllChannelsForRefresh(@Param("dataDeviceId") int dataDeviceId); - @Select("select de.* from wvp_device de left join wvp_device_channel dc on de.device_id = dc.device_id where dc.device_id=#{channelId}") - List<Device> getDeviceByChannelDeviceId(String channelId); + @Select("select de.* from wvp_device de left join wvp_device_channel dc on de.device_id = dc.device_id where dc.data_type = 1 and dc.device_id=#{channelId}") + List<Device> getDeviceByChannelDeviceId(@Param("channelId") String channelId); @Delete({"<script>" + @@ -397,7 +400,7 @@ public interface DeviceChannelMapper { @Update({"<script>" + "<foreach collection='channels' item='item' separator=';'>" + - "UPDATE wvp_device_channel SET status=#{item.status} WHERE device_id=#{item.deviceId}" + + "UPDATE wvp_device_channel SET status=#{item.status} WHERE data_type = #{item.dataType} and device_id=#{item.deviceId}" + "</foreach>" + "</script>"}) int batchUpdateStatus(List<DeviceChannel> channels); @@ -427,7 +430,7 @@ public interface DeviceChannelMapper { "<if test='item.latitude != null'>, latitude=#{item.latitude}</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_db_id=#{item.deviceDbId} AND device_id=#{item.deviceId}</if>" + + "<if test='item.id == 0'>WHERE data_type = #{item.dataType} and data_device_id=#{item.dataDeviceId} AND device_id=#{item.deviceId}</if>" + "</foreach>" + "</script>"}) void batchUpdatePosition(List<DeviceChannel> channelList); @@ -438,7 +441,7 @@ public interface DeviceChannelMapper { @Select(value = {" <script>" + " SELECT " + " id,\n" + - " device_db_id,\n" + + " data_device_id,\n" + " create_time,\n" + " update_time,\n" + " sub_count,\n" + @@ -487,13 +490,13 @@ public interface DeviceChannelMapper { DeviceChannel getOneForSource(@Param("id") int id); @SelectProvider(type = DeviceChannelProvider.class, method = "getOneByDeviceId") - DeviceChannel getOneByDeviceId(@Param("deviceDbId") int deviceDbId, @Param("channelId") String channelId); + DeviceChannel getOneByDeviceId(@Param("dataDeviceId") int dataDeviceId, @Param("channelId") String channelId); @Select(value = {" <script>" + " SELECT " + " id,\n" + - " device_db_id,\n" + + " data_device_id,\n" + " create_time,\n" + " update_time,\n" + " sub_count,\n" + @@ -537,9 +540,9 @@ public interface DeviceChannelMapper { " svc_space_support_mod,\n" + " svc_time_support_mode\n" + " from wvp_device_channel " + - " where device_db_id=#{deviceDbId} and coalesce(gb_device_id, device_id) = #{channelId}" + + " where data_type = 1 and data_device_id=#{dataDeviceId} and coalesce(gb_device_id, device_id) = #{channelId}" + " </script>"}) - DeviceChannel getOneByDeviceIdForSource(@Param("deviceDbId") int deviceDbId, @Param("channelId") String channelId); + DeviceChannel getOneByDeviceIdForSource(@Param("dataDeviceId") int dataDeviceId, @Param("channelId") String channelId); @Update(value = {"UPDATE wvp_device_channel SET stream_id=null WHERE id=#{channelId}"}) @@ -559,7 +562,7 @@ public interface DeviceChannelMapper { "</script>") void updateStreamGPS(List<GPSMsgInfo> gpsMsgInfoList); - @Update("UPDATE wvp_device_channel SET status=#{status} WHERE device_db_id=#{deviceDbId} AND device_id=#{deviceId}") + @Update("UPDATE wvp_device_channel SET status=#{status} WHERE data_type=#{dataType} and data_device_id=#{dataDeviceId} AND device_id=#{deviceId}") void updateStatus(DeviceChannel channel); @@ -568,7 +571,7 @@ public interface DeviceChannelMapper { " wvp_device_channel" + " SET update_time=#{updateTime}" + ", device_id=#{deviceId}" + - ", device_db_id=#{deviceDbId}" + + ", data_device_id=#{dataDeviceId}" + ", name=#{name}" + ", manufacturer=#{manufacturer}" + ", model=#{model}" + @@ -616,7 +619,7 @@ public interface DeviceChannelMapper { @Select(value = {" <script>" + " SELECT " + " id,\n" + - " device_db_id,\n" + + " data_device_id,\n" + " create_time,\n" + " update_time,\n" + " sub_count,\n" + @@ -660,7 +663,7 @@ public interface DeviceChannelMapper { " svc_space_support_mod,\n" + " svc_time_support_mode\n" + " from wvp_device_channel " + - " where device_db_id=#{deviceDbId} and device_id = #{channelId}" + + " where data_type = 1 and data_device_id=#{dataDeviceId} and device_id = #{channelId}" + " </script>"}) - DeviceChannel getOneBySourceChannelId(int deviceDbId, String channelId); + DeviceChannel getOneBySourceChannelId(@Param("dataDeviceId") int dataDeviceId, @Param("channelId") String channelId); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java index abac64bb5..9eec2a9af 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java @@ -45,9 +45,9 @@ public interface DeviceMapper { "on_line," + "media_server_id," + "broadcast_push_after_ack," + - "(SELECT count(0) FROM wvp_device_channel dc WHERE dc.device_db_id= de.id) as channel_count "+ + "(SELECT count(0) FROM wvp_device_channel dc WHERE dc.data_type = 1 and dc.data_device_id= de.id) as channel_count "+ " FROM wvp_device de WHERE de.device_id = #{deviceId}") - Device getDeviceByDeviceId(String deviceId); + Device getDeviceByDeviceId( @Param("deviceId") String deviceId); @Insert("INSERT INTO wvp_device (" + "device_id, " + @@ -167,13 +167,13 @@ public interface DeviceMapper { "geo_coord_sys,"+ "on_line,"+ "media_server_id,"+ - "(SELECT count(0) FROM wvp_device_channel dc WHERE dc.device_db_id= de.id) as channel_count " + + "(SELECT count(0) FROM wvp_device_channel dc WHERE dc.data_type = #{dataType} and dc.data_device_id= de.id) as channel_count " + "FROM wvp_device de" + - "<if test=\"onLine != null\"> where de.on_line=${onLine}</if>"+ + "<if test='online != null'> where de.on_line=${online}</if>"+ " order by de.create_time desc "+ " </script>" ) - List<Device> getDevices(Boolean onLine); + List<Device> getDevices(@Param("dataType") Integer dataType, @Param("online") Boolean online); @Delete("DELETE FROM wvp_device WHERE device_id=#{deviceId}") int del(String deviceId); @@ -326,7 +326,7 @@ public interface DeviceMapper { "geo_coord_sys,"+ "on_line,"+ "media_server_id,"+ - "(SELECT count(0) FROM wvp_device_channel dc WHERE dc.device_db_id= de.id) as channel_count " + + "(SELECT count(0) FROM wvp_device_channel dc WHERE dc.data_type = #{dataType} and dc.data_device_id= de.id) as channel_count " + " FROM wvp_device de" + " where 1 = 1 "+ " <if test='status != null'> AND de.on_line=${status}</if>"+ @@ -337,7 +337,7 @@ public interface DeviceMapper { "</if> " + " order by create_time desc "+ " </script>") - List<Device> getDeviceList(@Param("query") String query, @Param("status") Boolean status); + List<Device> getDeviceList(@Param("dataType") Integer dataType, @Param("query") String query, @Param("status") Boolean status); @Select("select * from wvp_device_channel where id = #{id}") DeviceChannel getRawChannel(@Param("id") int id); @@ -345,10 +345,10 @@ public interface DeviceMapper { @Select("select * from wvp_device where id = #{id}") Device query(@Param("id") Integer id); - @Select("select wd.* from wvp_device wd left join wvp_device_channel wdc on wd.id = wdc.device_db_id where wdc.id = #{channelId}") - Device queryByChannelId(@Param("channelId") Integer channelId); + @Select("select wd.* from wvp_device wd left join wvp_device_channel wdc on wdc.data_type = #{dataType} and wd.id = wdc.data_device_id where wdc.id = #{channelId}") + Device queryByChannelId(@Param("dataType") Integer dataType, @Param("channelId") Integer channelId); - @Select("select wd.* from wvp_device wd left join wvp_device_channel wdc on wd.id = wdc.device_db_id where wdc.device_id = #{channelDeviceId}") - Device getDeviceBySourceChannelDeviceId(@Param("channelDeviceId") String channelDeviceId); + @Select("select wd.* from wvp_device wd left join wvp_device_channel wdc on wdc.data_type = #{dataType} and wd.id = wdc.data_device_id where wdc.device_id = #{channelDeviceId}") + Device getDeviceBySourceChannelDeviceId(@Param("dataType") Integer dataType, @Param("channelDeviceId") String channelDeviceId); } 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 d23eec4ba..52c129366 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 @@ -65,9 +65,8 @@ public interface PlatformChannelMapper { " select " + " wpgc.id ,\n" + " wdc.id as gb_id,\n" + - " wdc.device_db_id as gb_device_db_id,\n" + - " wdc.stream_push_id,\n" + - " wdc.stream_proxy_id,\n" + + " wdc.data_type ,\n" + + " wdc.data_device_id,\n" + " wdc.create_time,\n" + " wdc.update_time,\n" + " wpgc.custom_device_id, \n" + @@ -149,19 +148,16 @@ public interface PlatformChannelMapper { " <if test='online == false'> AND coalesce(wpgc.status, wdc.gb_status, wdc.status) = 'OFF'</if> " + " <if test='hasShare == true'> AND wpgc.platform_id = #{platformId}</if> " + " <if test='hasShare == false'> AND wpgc.platform_id is null</if> " + - " <if test='channelType == 0'> AND wdc.device_db_id is not null</if> " + - " <if test='channelType == 1'> AND wdc.stream_push_id is not null</if> " + - " <if test='channelType == 2'> AND wdc.stream_proxy_id is not null</if> " + + " <if test='dataType != null'> AND wdc.data_type = #{dataType}</if> " + "</script>") List<PlatformChannel> queryForPlatformForWebList(@Param("platformId") Integer platformId, @Param("query") String query, - @Param("channelType") Integer channelType, @Param("online") Boolean online, + @Param("dataType") Integer dataType, @Param("online") Boolean online, @Param("hasShare") Boolean hasShare); @Select("select\n" + " wdc.id as gb_id,\n" + - " wdc.device_db_id as gb_device_db_id,\n" + - " wdc.stream_push_id,\n" + - " wdc.stream_proxy_id,\n" + + " wdc.data_type,\n" + + " wdc.data_device_id,\n" + " wdc.create_time,\n" + " wdc.update_time,\n" + " coalesce(wpgc.custom_device_id, wdc.gb_device_id, wdc.device_id) as gb_device_id,\n" + @@ -209,9 +205,8 @@ public interface PlatformChannelMapper { @Select("<script>" + " select " + " wdc.id as gb_id,\n" + - " wdc.device_db_id as gb_device_db_id,\n" + - " wdc.stream_push_id,\n" + - " wdc.stream_proxy_id,\n" + + " wdc.data_type,\n" + + " wdc.data_device_id,\n" + " wdc.create_time,\n" + " wdc.update_time,\n" + " coalesce(wpgc.custom_device_id, wdc.gb_device_id, wdc.device_id) as gb_device_id,\n" + @@ -260,9 +255,8 @@ public interface PlatformChannelMapper { @Select("<script>" + " select " + " wdc.id as gb_id,\n" + - " wdc.device_db_id as gb_device_db_id,\n" + - " wdc.stream_push_id,\n" + - " wdc.stream_proxy_id,\n" + + " wdc.data_type,\n" + + " wdc.data_device_id,\n" + " wdc.create_time,\n" + " wdc.update_time,\n" + " coalesce(wpgc.custom_device_id, wdc.gb_device_id, wdc.device_id) as gb_device_id,\n" + @@ -485,9 +479,8 @@ public interface PlatformChannelMapper { @Select("<script>" + " select " + " wdc.id as gb_id,\n" + - " wdc.device_db_id as gb_device_db_id,\n" + - " wdc.stream_push_id,\n" + - " wdc.stream_proxy_id,\n" + + " wdc.data_type,\n" + + " wdc.data_device_id,\n" + " wdc.create_time,\n" + " wdc.update_time,\n" + " coalesce(wpgc.custom_device_id, wdc.gb_device_id, wdc.device_id) as gb_device_id,\n" + diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java index 8997dcb6c..245adbc0f 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java @@ -12,7 +12,6 @@ public class ChannelProvider { public final static String BASE_SQL = "select\n" + " id as gb_id,\n" + - " device_db_id as gb_device_db_id,\n" + " data_type,\n" + " data_device_id,\n" + " create_time,\n" + @@ -58,8 +57,7 @@ public class ChannelProvider { private final static String BASE_SQL_FOR_PLATFORM = "select\n" + " wdc.id as gb_id,\n" + - " wdc.device_db_id as gb_device_db_id,\n" + - " wdc.stream_push_id,\n" + + " wdc.data_type,\n" + " wdc.data_device_id,\n" + " wdc.create_time,\n" + " wdc.update_time,\n" + @@ -133,14 +131,8 @@ public class ChannelProvider { }else { sqlBuild.append(" AND coalesce(gb_civil_code, civil_code) is null"); } - if (params.get("channelType") != null) { - if ((Integer)params.get("channelType") == 0) { - sqlBuild.append(" AND device_db_id is not null"); - }else if ((Integer)params.get("channelType") == 1) { - sqlBuild.append(" AND stream_push_id is not null"); - }else if ((Integer)params.get("channelType") == 2) { - sqlBuild.append(" AND stream_proxy_id is not null"); - } + if (params.get("dataType") != null) { + sqlBuild.append(" AND data_type = #{dataType}"); } return sqlBuild.toString(); } @@ -165,15 +157,8 @@ public class ChannelProvider { }else { sqlBuild.append(" AND coalesce(gb_parent_id, parent_id) is null"); } - - if (params.get("channelType") != null) { - if ((Integer)params.get("channelType") == 0) { - sqlBuild.append(" AND device_db_id is not null"); - }else if ((Integer)params.get("channelType") == 1) { - sqlBuild.append(" AND stream_push_id is not null"); - }else if ((Integer)params.get("channelType") == 2) { - sqlBuild.append(" AND stream_proxy_id is not null"); - } + if (params.get("dataType") != null) { + sqlBuild.append(" AND data_type = #{dataType}"); } return sqlBuild.toString(); } @@ -196,15 +181,8 @@ public class ChannelProvider { if (params.get("hasRecordPlan") != null && (Boolean)params.get("hasRecordPlan")) { sqlBuild.append(" AND record_plan_id > 0"); } - - if (params.get("channelType") != null) { - if ((Integer)params.get("channelType") == 0) { - sqlBuild.append(" AND device_db_id is not null"); - }else if ((Integer)params.get("channelType") == 1) { - sqlBuild.append(" AND stream_push_id is not null"); - }else if ((Integer)params.get("channelType") == 2) { - sqlBuild.append(" AND stream_proxy_id is not null"); - } + if (params.get("dataType") != null) { + sqlBuild.append(" AND data_type = #{dataType}"); } return sqlBuild.toString(); } @@ -248,7 +226,7 @@ public class ChannelProvider { public String queryByGbDeviceIds(Map<String, Object> params ){ StringBuilder sqlBuild = new StringBuilder(); sqlBuild.append(BASE_SQL); - sqlBuild.append("where channel_type = 0 and device_db_id in ( "); + sqlBuild.append("where channel_type = 0 and data_type = #{dataType} and data_device_id in ( "); Collection<Integer> ids = (Collection<Integer>)params.get("deviceIds"); boolean first = true; @@ -351,7 +329,7 @@ public class ChannelProvider { StringBuilder sqlBuild = new StringBuilder(); sqlBuild.append(BASE_SQL); - sqlBuild.append(" where channel_type = 0 and stream_push_id in ( "); + sqlBuild.append(" where channel_type = 0 and data_type = #{dataType} and data_device_id in ( "); Collection<StreamPush> ids = (Collection<StreamPush>)params.get("streamPushList"); boolean first = true; for (StreamPush streamPush : ids) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/DeviceChannelProvider.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/DeviceChannelProvider.java index 719ad2845..eece8399e 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/DeviceChannelProvider.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/DeviceChannelProvider.java @@ -1,5 +1,6 @@ package com.genersoft.iot.vmp.gb28181.dao.provider; +import com.genersoft.iot.vmp.common.enums.ChannelDataType; import org.springframework.util.ObjectUtils; import java.util.List; @@ -10,7 +11,7 @@ public class DeviceChannelProvider { public String getBaseSelectSql(){ return "SELECT " + " dc.id,\n" + - " dc.device_db_id,\n" + + " dc.data_device_id,\n" + " dc.create_time,\n" + " dc.update_time,\n" + " dc.sub_count,\n" + @@ -60,7 +61,7 @@ public class DeviceChannelProvider { public String queryChannels(Map<String, Object> params ){ StringBuilder sqlBuild = new StringBuilder(); sqlBuild.append(getBaseSelectSql()); - sqlBuild.append(" where dc.device_db_id = #{deviceDbId} "); + sqlBuild.append(" where data_type = " + ChannelDataType.GB28181.value + " and dc.data_device_id = #{dataDeviceId} "); if (params.get("businessGroupId") != null ) { sqlBuild.append(" AND coalesce(dc.gb_business_group_id, dc.business_group_id)=#{businessGroupId} AND coalesce(dc.gb_parent_id, dc.parent_id) is null"); }else if (params.get("parentChannelId") != null ) { @@ -107,14 +108,14 @@ public class DeviceChannelProvider { public String queryChannelsByDeviceDbId(Map<String, Object> params ){ StringBuilder sqlBuild = new StringBuilder(); sqlBuild.append(getBaseSelectSql()); - sqlBuild.append(" where dc.device_db_id = #{deviceDbId}"); + sqlBuild.append(" where data_type = " + ChannelDataType.GB28181.value + " and dc.data_device_id = #{dataDeviceId}"); return sqlBuild.toString(); } public String queryAllChannels(Map<String, Object> params ){ StringBuilder sqlBuild = new StringBuilder(); sqlBuild.append(getBaseSelectSql()); - sqlBuild.append(" where dc.device_db_id = #{deviceDbId}"); + sqlBuild.append(" where data_type = " + ChannelDataType.GB28181.value + " and dc.data_device_id = #{dataDeviceId}"); return sqlBuild.toString(); } @@ -128,33 +129,25 @@ public class DeviceChannelProvider { public String getOneByDeviceId(Map<String, Object> params ){ StringBuilder sqlBuild = new StringBuilder(); sqlBuild.append(getBaseSelectSql()); - sqlBuild.append(" where dc.device_db_id=#{deviceDbId} and coalesce(dc.gb_device_id, dc.device_id) = #{channelId}"); + sqlBuild.append(" where data_type = " + ChannelDataType.GB28181.value + " and dc.data_device_id=#{dataDeviceId} and coalesce(dc.gb_device_id, dc.device_id) = #{channelId}"); return sqlBuild.toString(); } public String queryByDeviceId(Map<String, Object> params ){ - return getBaseSelectSql() + " where channel_type = 0 and coalesce(gb_device_id, device_id) = #{gbDeviceId}"; + return getBaseSelectSql() + " where data_type = " + ChannelDataType.GB28181.value + " and channel_type = 0 and coalesce(gb_device_id, device_id) = #{gbDeviceId}"; } public String queryById(Map<String, Object> params ){ - return getBaseSelectSql() + " where channel_type = 0 and id = #{gbId}"; - } - - public String queryByStreamPushId(Map<String, Object> params ){ - return getBaseSelectSql() + " where channel_type = 0 and stream_push_id = #{streamPushId}"; - } - - public String queryByStreamProxyId(Map<String, Object> params ){ - return getBaseSelectSql() + " where channel_type = 0 and stream_proxy_id = #{streamProxyId}"; + return getBaseSelectSql() + " where data_type = " + ChannelDataType.GB28181.value + " and channel_type = 0 and id = #{gbId}"; } public String queryList(Map<String, Object> params ){ StringBuilder sqlBuild = new StringBuilder(); sqlBuild.append(getBaseSelectSql()); - sqlBuild.append(" where channel_type = 0 "); + sqlBuild.append(" where channel_type = 0 and data_type = " + ChannelDataType.GB28181.value); if (params.get("query") != null) { sqlBuild.append(" AND (coalesce(gb_device_id, device_id) LIKE concat('%',#{query},'%')" + " OR coalesce(gb_name, name) LIKE concat('%',#{query},'%') )") diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java index e375db87b..6c6bfa142 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject; import com.baomidou.dynamic.datasource.annotation.DS; import com.genersoft.iot.vmp.common.InviteInfo; import com.genersoft.iot.vmp.common.InviteSessionType; +import com.genersoft.iot.vmp.common.enums.ChannelDataType; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.gb28181.bean.Device; @@ -84,7 +85,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { List<DeviceChannel> channelList = channelMapper.queryChannelsByDeviceDbId(device.getId()); if (channelList.isEmpty()) { for (DeviceChannel channel : channels) { - channel.setDeviceDbId(device.getId()); + channel.setDataDeviceId(device.getId()); InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, channel.getId()); if (inviteInfo != null && inviteInfo.getStreamInfo() != null) { channel.setStreamId(inviteInfo.getStreamInfo().getStream()); @@ -96,7 +97,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { } }else { for (DeviceChannel deviceChannel : channelList) { - channelsInStore.put(deviceChannel.getDeviceDbId() + deviceChannel.getDeviceId(), deviceChannel); + channelsInStore.put(deviceChannel.getDataDeviceId() + deviceChannel.getDeviceId(), deviceChannel); } for (DeviceChannel channel : channels) { InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, channel.getId()); @@ -105,7 +106,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { } String now = DateUtil.getNow(); channel.setUpdateTime(now); - DeviceChannel deviceChannelInDb = channelsInStore.get(channel.getDeviceDbId() + channel.getDeviceId()); + DeviceChannel deviceChannelInDb = channelsInStore.get(channel.getDataDeviceId() + channel.getDeviceId()); if ( deviceChannelInDb != null) { channel.setId(deviceChannelInDb.getId()); channel.setUpdateTime(now); @@ -324,7 +325,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { } for (DeviceChannel channel : channels) { if (channel.getParentId() != null) { - channelMapper.updateChannelSubCount(channel.getDeviceDbId(), channel.getParentId()); + channelMapper.updateChannelSubCount(channel.getDataDeviceId(), channel.getParentId()); } } } @@ -487,7 +488,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { Map<String,DeviceChannel> allChannelMap = new HashMap<>(); if (!allChannels.isEmpty()) { for (DeviceChannel deviceChannel : allChannels) { - allChannelMap.put(deviceChannel.getDeviceDbId() + deviceChannel.getDeviceId(), deviceChannel); + allChannelMap.put(deviceChannel.getDataDeviceId() + deviceChannel.getDeviceId(), deviceChannel); } } // 数据去重 @@ -500,7 +501,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { Map<String, Integer> subContMap = new HashMap<>(); for (DeviceChannel deviceChannel : deviceChannelList) { - DeviceChannel channelInDb = allChannelMap.get(deviceChannel.getDeviceDbId() + deviceChannel.getDeviceId()); + DeviceChannel channelInDb = allChannelMap.get(deviceChannel.getDataDeviceId() + deviceChannel.getDeviceId()); if (channelInDb != null) { deviceChannel.setStreamId(channelInDb.getStreamId()); deviceChannel.setHasAudio(channelInDb.isHasAudio()); @@ -520,7 +521,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { deviceChannel.setUpdateTime(DateUtil.getNow()); addChannels.add(deviceChannel); } - allChannelMap.remove(deviceChannel.getDeviceDbId() + deviceChannel.getDeviceId()); + allChannelMap.remove(deviceChannel.getDataDeviceId() + deviceChannel.getDeviceId()); channels.add(deviceChannel); if (!ObjectUtils.isEmpty(deviceChannel.getParentId())) { if (subContMap.get(deviceChannel.getParentId()) == null) { @@ -700,6 +701,8 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { @Override public void addChannel(DeviceChannel channel) { + channel.setDataType(ChannelDataType.GB28181.value); + channel.setDataDeviceId(channel.getDataDeviceId()); channelMapper.add(channel); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java index c5be6386b..9747cf883 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSON; import com.baomidou.dynamic.datasource.annotation.DS; import com.genersoft.iot.vmp.common.CommonCallback; import com.genersoft.iot.vmp.common.VideoManagerConstants; +import com.genersoft.iot.vmp.common.enums.ChannelDataType; import com.genersoft.iot.vmp.conf.DynamicTask; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.exception.ControllerException; @@ -71,9 +72,6 @@ public class DeviceServiceImpl implements IDeviceService { @Autowired private PlatformChannelMapper platformChannelMapper; - @Autowired - private IDeviceChannelService deviceChannelService; - @Autowired private DeviceChannelMapper deviceChannelMapper; @@ -95,11 +93,15 @@ public class DeviceServiceImpl implements IDeviceService { @Autowired private AudioBroadcastManager audioBroadcastManager; + private Device getDeviceByDeviceIdFromDb(String deviceId) { + return deviceMapper.getDeviceByDeviceId(deviceId); + } + @Override public void online(Device device, SipTransactionInfo sipTransactionInfo) { log.info("[设备上线] deviceId:{}->{}:{}", device.getDeviceId(), device.getIp(), device.getPort()); Device deviceInRedis = redisCatchStorage.getDevice(device.getDeviceId()); - Device deviceInDb = deviceMapper.getDeviceByDeviceId(device.getDeviceId()); + Device deviceInDb = getDeviceByDeviceIdFromDb(device.getDeviceId()); String now = DateUtil.getNow(); if (deviceInRedis != null && deviceInDb == null) { @@ -194,7 +196,7 @@ public class DeviceServiceImpl implements IDeviceService { @Override public void offline(String deviceId, String reason) { log.warn("[设备离线],{}, device:{}", reason, deviceId); - Device device = deviceMapper.getDeviceByDeviceId(deviceId); + Device device = getDeviceByDeviceIdFromDb(deviceId); if (device == null) { return; } @@ -346,7 +348,7 @@ public class DeviceServiceImpl implements IDeviceService { public Device getDeviceByDeviceId(String deviceId) { Device device = redisCatchStorage.getDevice(deviceId); if (device == null) { - device = deviceMapper.getDeviceByDeviceId(deviceId); + device = getDeviceByDeviceIdFromDb(deviceId); if (device != null) { redisCatchStorage.updateDevice(device); } @@ -361,7 +363,7 @@ public class DeviceServiceImpl implements IDeviceService { @Override public List<Device> getAllByStatus(Boolean status) { - return deviceMapper.getDevices(status); + return deviceMapper.getDevices(ChannelDataType.GB28181.value, status); } @Override @@ -403,7 +405,7 @@ public class DeviceServiceImpl implements IDeviceService { @Override public boolean isExist(String deviceId) { - return deviceMapper.getDeviceByDeviceId(deviceId) != null; + return getDeviceByDeviceIdFromDb(deviceId) != null; } @Override @@ -496,7 +498,7 @@ public class DeviceServiceImpl implements IDeviceService { @Override @Transactional public boolean delete(String deviceId) { - Device device = deviceMapper.getDeviceByDeviceId(deviceId); + Device device = getDeviceByDeviceIdFromDb(deviceId); if (device == null) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到设备:" + deviceId); } @@ -527,7 +529,7 @@ public class DeviceServiceImpl implements IDeviceService { .replaceAll("%", "/%") .replaceAll("_", "/_"); } - List<Device> all = deviceMapper.getDeviceList(query, status); + List<Device> all = deviceMapper.getDeviceList(ChannelDataType.GB28181.value, query, status); return new PageInfo<>(all); } @@ -538,11 +540,11 @@ public class DeviceServiceImpl implements IDeviceService { @Override public Device getDeviceByChannelId(Integer channelId) { - return deviceMapper.queryByChannelId(channelId); + return deviceMapper.queryByChannelId(ChannelDataType.GB28181.value,channelId); } @Override public Device getDeviceBySourceChannelDeviceId(String channelId) { - return deviceMapper.getDeviceBySourceChannelDeviceId(channelId); + return deviceMapper.getDeviceBySourceChannelDeviceId(ChannelDataType.GB28181.value,channelId); } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java index 96bda5ce9..29d658076 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java @@ -372,7 +372,7 @@ public class GbChannelServiceImpl implements IGbChannelService { throw new ControllerException(ErrorCode.ERROR100.getCode(), "非国标下级通道无法重置"); } // 这个多加一个参数,为了防止将非国标的通道通过此方法清空内容,导致意外发生 - commonGBChannelMapper.reset(id, channel.getDataDeviceId(), DateUtil.getNow()); + commonGBChannelMapper.reset(id, ChannelDataType.GB28181.value, channel.getDataDeviceId(), DateUtil.getNow()); CommonGBChannel channelNew = getOne(id); // 发送通过更新通知 try { @@ -495,7 +495,7 @@ public class GbChannelServiceImpl implements IGbChannelService { @Override public void addChannelToRegionByGbDevice(String civilCode, List<Integer> deviceIds) { - List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(deviceIds); + List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(ChannelDataType.GB28181.value, deviceIds); if (channelList.isEmpty()) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在"); } @@ -516,7 +516,7 @@ public class GbChannelServiceImpl implements IGbChannelService { @Override public void deleteChannelToRegionByGbDevice(List<Integer> deviceIds) { - List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(deviceIds); + List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(ChannelDataType.GB28181.value, deviceIds); if (channelList.isEmpty()) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在"); } @@ -633,7 +633,7 @@ public class GbChannelServiceImpl implements IGbChannelService { @Override @Transactional public void addChannelToGroupByGbDevice(String parentId, String businessGroup, List<Integer> deviceIds) { - List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(deviceIds); + List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(ChannelDataType.GB28181.value, deviceIds); if (channelList.isEmpty()) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在"); } @@ -661,7 +661,7 @@ public class GbChannelServiceImpl implements IGbChannelService { @Override public void deleteChannelToGroupByGbDevice(List<Integer> deviceIds) { - List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(deviceIds); + List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(ChannelDataType.GB28181.value, deviceIds); if (channelList.isEmpty()) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在"); } @@ -703,12 +703,12 @@ public class GbChannelServiceImpl implements IGbChannelService { @Override public List<CommonGBChannel> queryListByStreamPushList(List<StreamPush> streamPushList) { - return commonGBChannelMapper.queryListByStreamPushList(streamPushList); + return commonGBChannelMapper.queryListByStreamPushList(ChannelDataType.STREAM_PUSH.value, streamPushList); } @Override public void updateGpsByDeviceIdForStreamPush(List<CommonGBChannel> channels) { - commonGBChannelMapper.updateGpsByDeviceIdForStreamPush(channels); + commonGBChannelMapper.updateGpsByDeviceIdForStreamPush(ChannelDataType.STREAM_PUSH.value, channels); } @Override diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java index 15d0142b3..66e784a59 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java @@ -1,6 +1,7 @@ package com.genersoft.iot.vmp.gb28181.service.impl; import com.baomidou.dynamic.datasource.annotation.DS; +import com.genersoft.iot.vmp.common.enums.ChannelDataType; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.dao.*; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; @@ -288,14 +289,14 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { @Override @Transactional public void addChannelByDevice(Integer platformId, List<Integer> deviceIds) { - List<Integer> channelList = commonGBChannelMapper.queryByGbDeviceIdsForIds(deviceIds); + List<Integer> channelList = commonGBChannelMapper.queryByGbDeviceIdsForIds(ChannelDataType.GB28181.value, deviceIds); addChannels(platformId, channelList); } @Override @Transactional public void removeChannelByDevice(Integer platformId, List<Integer> deviceIds) { - List<Integer> channelList = commonGBChannelMapper.queryByGbDeviceIdsForIds(deviceIds); + List<Integer> channelList = commonGBChannelMapper.queryByGbDeviceIdsForIds(ChannelDataType.GB28181.value, deviceIds); removeChannels(platformId, channelList); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java index 5533ad8d7..98fb6fba6 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java @@ -1623,7 +1623,7 @@ public class PlayServiceImpl implements IPlayService { log.warn("[停止点播] 发现通道不存在"); return; } - Device device = deviceService.getDevice(channel.getDeviceDbId()); + Device device = deviceService.getDevice(channel.getDataDeviceId()); if (device == null) { log.warn("[停止点播] 发现设备不存在"); return; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java index 86be394a8..8861282f8 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java @@ -115,7 +115,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent log.info("[解析CatalogChannelEvent]成功:但是解析通道信息失败, 原文如下: \n{}", new String(evt.getRequest().getRawContent())); continue; } - catalogChannelEvent.getChannel().setDeviceDbId(device.getId()); + catalogChannelEvent.getChannel().setDataDeviceId(device.getId()); } catch (InvocationTargetException | NoSuchMethodException | InstantiationException | IllegalAccessException e) { log.error("[解析CatalogChannelEvent]失败,", e); 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 0dc38a4ac..1f6961fb1 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 @@ -139,7 +139,7 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp log.info("[收到目录订阅]:但是解析失败 {}", new String(evt.getRequest().getRawContent())); continue; } - channel.setDeviceDbId(take.getDevice().getId()); + channel.setDataDeviceId(take.getDevice().getId()); if (channel.getParentId() != null && channel.getParentId().equals(sipConfig.getId())) { channel.setParentId(null); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java index ca55b4d3a..1b5317a0c 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java @@ -266,14 +266,14 @@ public class RecordPlanServiceImpl implements IRecordPlanService { } @Override - public PageInfo<CommonGBChannel> queryChannelList(int page, int count, String query, Integer channelType, Boolean online, Integer planId, Boolean hasLink) { + public PageInfo<CommonGBChannel> queryChannelList(int page, int count, String query, Integer dataType, Boolean online, Integer planId, Boolean hasLink) { PageHelper.startPage(page, count); if (query != null) { query = query.replaceAll("/", "//") .replaceAll("%", "/%") .replaceAll("_", "/_"); } - List<CommonGBChannel> all = channelMapper.queryForRecordPlanForWebList(planId, query, channelType, online, hasLink); + List<CommonGBChannel> all = channelMapper.queryForRecordPlanForWebList(planId, query, dataType, online, hasLink); return new PageInfo<>(all); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java index be73a17cb..b97c9cf06 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.genersoft.iot.vmp.common.SystemAllInfo; import com.genersoft.iot.vmp.common.VideoManagerConstants; +import com.genersoft.iot.vmp.common.enums.ChannelDataType; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.dao.DeviceChannelMapper; diff --git a/src/main/java/com/genersoft/iot/vmp/streamProxy/dao/provider/StreamProxyProvider.java b/src/main/java/com/genersoft/iot/vmp/streamProxy/dao/provider/StreamProxyProvider.java index 071d7d556..968a74b70 100644 --- a/src/main/java/com/genersoft/iot/vmp/streamProxy/dao/provider/StreamProxyProvider.java +++ b/src/main/java/com/genersoft/iot/vmp/streamProxy/dao/provider/StreamProxyProvider.java @@ -1,5 +1,7 @@ package com.genersoft.iot.vmp.streamProxy.dao.provider; +import com.genersoft.iot.vmp.common.enums.ChannelDataType; + import java.util.Map; public class StreamProxyProvider { @@ -7,12 +9,13 @@ public class StreamProxyProvider { public String getBaseSelectSql(){ return "SELECT " + " st.*, " + - " st.id as stream_proxy_id, " + + ChannelDataType.STREAM_PROXY.value + " as data_type, " + + " st.id as data_device_id, " + " wdc.*, " + " wdc.id as gb_id" + " FROM wvp_stream_proxy st " + " LEFT join wvp_device_channel wdc " + - " on st.id = wdc.stream_proxy_id "; + " on wdc.data_type = 3 and st.id = wdc.data_device_id "; } public String select(Map<String, Object> params ){ diff --git a/src/main/java/com/genersoft/iot/vmp/streamPush/bean/StreamPush.java b/src/main/java/com/genersoft/iot/vmp/streamPush/bean/StreamPush.java index 0e7b91658..ef4517bdd 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamPush/bean/StreamPush.java +++ b/src/main/java/com/genersoft/iot/vmp/streamPush/bean/StreamPush.java @@ -79,6 +79,8 @@ public class StreamPush extends CommonGBChannel implements Comparable<StreamPush private String uniqueKey; + private Integer dataType = ChannelDataType.STREAM_PUSH.value; + @Override public int compareTo(@NotNull StreamPush streamPushItem) { return Long.valueOf(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(this.createTime) diff --git a/src/main/java/com/genersoft/iot/vmp/streamPush/dao/StreamPushMapper.java b/src/main/java/com/genersoft/iot/vmp/streamPush/dao/StreamPushMapper.java index 64b81d587..8c3758ae9 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamPush/dao/StreamPushMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/streamPush/dao/StreamPushMapper.java @@ -1,5 +1,6 @@ package com.genersoft.iot.vmp.streamPush.dao; +import com.genersoft.iot.vmp.common.enums.ChannelDataType; import com.genersoft.iot.vmp.streamPush.bean.StreamPush; import com.genersoft.iot.vmp.service.bean.StreamPushItemFromRedis; import org.apache.ibatis.annotations.*; @@ -13,6 +14,8 @@ import java.util.Set; @Repository public interface StreamPushMapper { + Integer dataType = ChannelDataType.GB28181.value; + @Insert("INSERT INTO wvp_stream_push (app, stream, media_server_id, server_id, push_time, update_time, create_time, pushing, start_offline_push) VALUES" + "(#{app}, #{stream}, #{mediaServerId} , #{serverId} , #{pushTime} ,#{updateTime}, #{createTime}, #{pushing}, #{startOfflinePush})") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") @@ -39,13 +42,13 @@ public interface StreamPushMapper { @Select(value = {" <script>" + " SELECT " + " st.*, " + - " st.id as stream_push_id, " + + " st.id as data_device_id, " + " wdc.*, " + " wdc.id as gb_id" + " from " + " wvp_stream_push st " + " LEFT join wvp_device_channel wdc " + - " on st.id = wdc.stream_push_id " + + " on st.id = wdc.data_device_id " + " WHERE " + " 1=1 " + " <if test='query != null'> AND (st.app LIKE concat('%',#{query},'%') escape '/' OR st.stream LIKE concat('%',#{query},'%') escape '/' " + @@ -57,7 +60,7 @@ public interface StreamPushMapper { " </script>"}) List<StreamPush> selectAll(@Param("query") String query, @Param("pushing") Boolean pushing, @Param("mediaServerId") String mediaServerId); - @Select("SELECT st.*, st.id as stream_push_id, wdc.*, wdc.id as gb_id FROM wvp_stream_push st LEFT join wvp_device_channel wdc on st.id = wdc.stream_push_id WHERE st.app=#{app} AND st.stream=#{stream}") + @Select("SELECT st.*, st.id as data_device_id, wdc.*, wdc.id as gb_id FROM wvp_stream_push st LEFT join wvp_device_channel wdc on wdc.data_type = 2 and st.id = wdc.data_device_id WHERE st.app=#{app} AND st.stream=#{stream}") StreamPush selectByAppAndStream(@Param("app") String app, @Param("stream") String stream); @Insert("<script>" + @@ -70,10 +73,10 @@ public interface StreamPushMapper { @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") int addAll(List<StreamPush> streamPushItems); - @Select("SELECT st.*, st.id as stream_push_id, wdc.*, wdc.id as gb_id FROM wvp_stream_push st LEFT join wvp_device_channel wdc on st.id = wdc.stream_push_id WHERE st.media_server_id=#{mediaServerId}") + @Select("SELECT st.*, st.id as data_device_id, wdc.*, wdc.id as gb_id FROM wvp_stream_push st LEFT join wvp_device_channel wdc on wdc.data_type = 2 and st.id = wdc.data_device_id WHERE st.media_server_id=#{mediaServerId}") List<StreamPush> selectAllByMediaServerId(String mediaServerId); - @Select("SELECT st.*, st.id as stream_push_id, wdc.*, wdc.id as gb_id FROM wvp_stream_push st LEFT join wvp_device_channel wdc on st.id = wdc.stream_push_id WHERE st.media_server_id=#{mediaServerId} and wdc.gb_device_id is null") + @Select("SELECT st.*, st.id as data_device_id, wdc.*, wdc.id as gb_id FROM wvp_stream_push st LEFT join wvp_device_channel wdc on wdc.data_type = 2 and st.id = wdc.data_device_id WHERE st.media_server_id=#{mediaServerId} and wdc.gb_device_id is null") List<StreamPush> selectAllByMediaServerIdWithOutGbID(String mediaServerId); @Update("UPDATE wvp_stream_push " + @@ -83,7 +86,7 @@ public interface StreamPushMapper { @Select("<script> "+ - "SELECT st.*, st.id as stream_push_id, wdc.*, wdc.id as gb_id FROM wvp_stream_push st LEFT join wvp_device_channel wdc on st.id = wdc.stream_push_id " + + "SELECT st.*, st.id as data_device_id, wdc.*, wdc.id as gb_id FROM wvp_stream_push st LEFT join wvp_device_channel wdc on wdc.data_type = 2 and st.id = wdc.data_device_id " + "where (st.app, st.stream) in (" + "<foreach collection='offlineStreams' item='item' separator=','>" + "(#{item.app}, #{item.stream}) " + @@ -106,21 +109,21 @@ public interface StreamPushMapper { @MapKey("uniqueKey") @Select("SELECT CONCAT(wsp.app, wsp.stream) as unique_key, wsp.*, wsp.* , wdc.id as gb_id " + " from wvp_stream_push wsp " + - " LEFT join wvp_device_channel wdc on wsp.id = wdc.stream_push_id") + " LEFT join wvp_device_channel wdc on wdc.data_type = 2 and wsp.id = wdc.data_device_id") Map<String, StreamPush> getAllAppAndStreamMap(); @MapKey("gbDeviceId") - @Select("SELECT wdc.gb_device_id, wsp.id as stream_push_id, wsp.*, wsp.* , wdc.id as gb_id " + + @Select("SELECT wdc.gb_device_id, wsp.id as data_device_id, wsp.*, wsp.* , wdc.id as gb_id " + " from wvp_stream_push wsp " + - " LEFT join wvp_device_channel wdc on wsp.id = wdc.stream_push_id") + " LEFT join wvp_device_channel wdc on wdc.data_type = 2 and wsp.id = wdc.data_device_id") Map<String, StreamPush> getAllGBId(); - @Select("SELECT st.*, st.id as stream_push_id, wdc.*, wdc.id as gb_id FROM wvp_stream_push st LEFT join wvp_device_channel wdc on st.id = wdc.stream_push_id WHERE st.id=#{id}") + @Select("SELECT st.*, st.id as data_device_id, wdc.*, wdc.id as gb_id FROM wvp_stream_push st LEFT join wvp_device_channel wdc on wdc.data_type = 2 and st.id = wdc.data_device_id WHERE st.id=#{id}") StreamPush queryOne(@Param("id") int id); @Select("<script> "+ - "SELECT st.*, st.id as stream_push_id, wdc.*, wdc.id as gb_id FROM wvp_stream_push st LEFT join wvp_device_channel wdc on st.id = wdc.stream_push_id " + + "SELECT st.*, st.id as data_device_id, wdc.*, wdc.id as gb_id FROM wvp_stream_push st LEFT join wvp_device_channel wdc on wdc.data_type = 2 and st.id = wdc.data_device_id " + " where st.id in (" + " <foreach collection='ids' item='item' separator=','>" + " #{item} " + diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java index 7292c9bd2..c9e7252a0 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java @@ -4,6 +4,8 @@ import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.genersoft.iot.vmp.common.SystemAllInfo; import com.genersoft.iot.vmp.common.VersionPo; +import com.genersoft.iot.vmp.common.enums.ChannelDataType; +import com.genersoft.iot.vmp.common.enums.DeviceControlType; import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.VersionInfo; @@ -42,10 +44,7 @@ import oshi.software.os.OperatingSystem; import java.io.File; import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.util.*; @SuppressWarnings("rawtypes") @Tag(name = "服务控制") @@ -346,6 +345,20 @@ public class ServerController { return result; } + @GetMapping(value = "/channel/datatype") + @ResponseBody + @Operation(summary = "获取系统接入的数据类型") + public List<Map<String, Object>> getDataType() { + List<Map<String, Object>> result = new LinkedList<>(); + for (ChannelDataType item : ChannelDataType.values()) { + Map<String, Object> map = new LinkedHashMap<>(); + map.put("key", item.desc); + map.put("value", item.value); + result.add(map); + } + return result; + } + /** * 单位转换 */ diff --git a/web_src/src/components/common/CommonChannelEdit.vue b/web_src/src/components/common/CommonChannelEdit.vue index 73f98e00e..b17abb8d4 100644 --- a/web_src/src/components/common/CommonChannelEdit.vue +++ b/web_src/src/components/common/CommonChannelEdit.vue @@ -206,7 +206,7 @@ <div style="float: right;"> <el-button type="primary" @click="onSubmit">保存</el-button> <el-button v-if="cancel" @click="cancelSubmit">取消</el-button> - <el-button v-if="form.gbDeviceDbId" @click="reset">重置</el-button> + <el-button v-if="form.dataType === 1" @click="reset">重置</el-button> </div> </div> diff --git a/web_src/src/components/common/channelDataTypeSelect.vue b/web_src/src/components/common/channelDataTypeSelect.vue new file mode 100644 index 000000000..b0ee132c0 --- /dev/null +++ b/web_src/src/components/common/channelDataTypeSelect.vue @@ -0,0 +1,63 @@ +<template> + <div id="channelDataTypeSelect" > + <el-select size="mini" @change="$emit('change', $event.target.value)" v-model="dataType" placeholder="请选择" + default-first-option> + <el-option label="全部" value=""></el-option> + <el-option + v-for="item in dataTypeArray" + :key="item.key" + :label="item.key" + :value="item.value"> + </el-option> + </el-select> + </div> +</template> + +<script> + +export default { + name: "channelDataTypeSelect", + model: { + prop: 'dataType', + event: 'change' + }, + props: { + dataType: { + type: String, + default: '' + } + }, + components: {}, + created() { + this.init() + }, + data() { + return { + dataTypeArray: [] + }; + }, + methods: { + init: function (){ + this.$axios({ + method: 'get', + url: `/api/server/channel/datatype`, + params: {} + }).then((res)=> { + if (res.data.code === 0) { + this.dataTypeArray = res.data.data; + } + }) + }, + }, +}; +</script> +<style> +.channel-form { + display: grid; + background-color: #FFFFFF; + padding: 1rem 2rem 0 2rem; + grid-template-columns: 1fr 1fr 1fr; + gap: 1rem; +} + +</style> diff --git a/web_src/src/components/dialog/GbChannelSelect.vue b/web_src/src/components/dialog/GbChannelSelect.vue index 258e313ec..6c781ce86 100644 --- a/web_src/src/components/dialog/GbChannelSelect.vue +++ b/web_src/src/components/dialog/GbChannelSelect.vue @@ -23,13 +23,7 @@ <el-option label="离线" value="false"></el-option> </el-select> 类型: - <el-select size="mini" style="width: 8rem; margin-right: 1rem;" @change="getChannelList" v-model="channelType" placeholder="请选择" - default-first-option> - <el-option label="全部" value=""></el-option> - <el-option label="国标设备" :value="0"></el-option> - <el-option label="推流设备" :value="1"></el-option> - <el-option label="拉流代理" :value="2"></el-option> - </el-select> + <channelDataTypeSelect style="width: 8rem; margin-right: 1rem;" @change="getChannelList" v-model="channelType"></channelDataTypeSelect> <el-button size="mini" :loading="getChannelListLoading" @click="getChannelList()">刷新</el-button> <el-button type="primary" size="mini" style="float: right" @click="onSubmit">确 定</el-button> @@ -49,9 +43,9 @@ <el-table-column label="类型" min-width="100"> <template v-slot:default="scope"> <div slot="reference" class="name-wrapper"> - <el-tag size="medium" effect="plain" v-if="scope.row.gbDeviceDbId">国标设备</el-tag> - <el-tag size="medium" effect="plain" type="success" v-if="scope.row.streamPushId">推流设备</el-tag> - <el-tag size="medium" effect="plain" type="warning" v-if="scope.row.streamProxyId">拉流代理</el-tag> + <el-tag size="medium" effect="plain" v-if="scope.row.dataType === 1">国标设备</el-tag> + <el-tag size="medium" effect="plain" type="success" v-else-if="scope.row.dataType === 2" >推流设备</el-tag> + <el-tag size="medium" effect="plain" type="warning" v-else-if="scope.row.dataType === 3">拉流代理</el-tag> </div> </template> </el-table-column> @@ -86,8 +80,11 @@ <script> +import ChannelDataTypeSelect from "../common/channelDataTypeSelect.vue"; + export default { name: "gbChannelSelect", + components: {ChannelDataTypeSelect}, props: ['dataType', "selected"], computed: {}, data() { diff --git a/web_src/src/components/dialog/linkChannelRecord.vue b/web_src/src/components/dialog/linkChannelRecord.vue index d30e25bcf..38522dafb 100755 --- a/web_src/src/components/dialog/linkChannelRecord.vue +++ b/web_src/src/components/dialog/linkChannelRecord.vue @@ -22,13 +22,7 @@ <el-option label="离线" value="false"></el-option> </el-select> 类型: - <el-select size="mini" style="width: 8rem; margin-right: 1rem;" @change="search" v-model="channelType" placeholder="请选择" - default-first-option> - <el-option label="全部" value=""></el-option> - <el-option label="国标设备" :value="0"></el-option> - <el-option label="推流设备" :value="1"></el-option> - <el-option label="拉流代理" :value="2"></el-option> - </el-select> + <channelDataTypeSelect style="width: 8rem; margin-right: 1rem;" @change="search" v-model="channelType"></channelDataTypeSelect> <el-button v-if="hasLink !=='true'" size="mini" type="primary" @click="add()"> 添加 </el-button> @@ -56,9 +50,9 @@ <el-table-column label="类型" min-width="100"> <template v-slot:default="scope"> <div slot="reference" class="name-wrapper"> - <el-tag size="medium" effect="plain" v-if="scope.row.gbDeviceDbId">国标设备</el-tag> - <el-tag size="medium" effect="plain" type="success" v-if="scope.row.streamPushId">推流设备</el-tag> - <el-tag size="medium" effect="plain" type="warning" v-if="scope.row.streamProxyId">拉流代理</el-tag> + <el-tag size="medium" effect="plain" v-if="scope.row.dataType === 1">国标设备</el-tag> + <el-tag size="medium" effect="plain" type="success" v-else-if="scope.row.dataType === 2" >推流设备</el-tag> + <el-tag size="medium" effect="plain" type="warning" v-else-if="scope.row.dataType === 3">拉流代理</el-tag> </div> </template> </el-table-column> @@ -91,10 +85,11 @@ <script> import gbDeviceSelect from "./GbDeviceSelect.vue"; +import ChannelDataTypeSelect from "../common/channelDataTypeSelect.vue"; export default { name: 'linkChannelRecord', - components: {gbDeviceSelect}, + components: {ChannelDataTypeSelect, gbDeviceSelect}, data() { return { dialogLoading: false, diff --git a/web_src/src/components/dialog/shareChannelAdd.vue b/web_src/src/components/dialog/shareChannelAdd.vue index b49623450..976a8a79a 100755 --- a/web_src/src/components/dialog/shareChannelAdd.vue +++ b/web_src/src/components/dialog/shareChannelAdd.vue @@ -20,13 +20,7 @@ <el-option label="离线" value="false"></el-option> </el-select> 类型: - <el-select size="mini" style="width: 8rem; margin-right: 1rem;" @change="search" v-model="channelType" placeholder="请选择" - default-first-option> - <el-option label="全部" value=""></el-option> - <el-option label="国标设备" :value="0"></el-option> - <el-option label="推流设备" :value="1"></el-option> - <el-option label="拉流代理" :value="2"></el-option> - </el-select> + <channelDataTypeSelect style="width: 8rem; margin-right: 1rem;" @change="search" v-model="channelType"></channelDataTypeSelect> <el-button v-if="hasShare !=='true'" size="mini" type="primary" @click="add()"> 添加 </el-button> @@ -74,9 +68,9 @@ <el-table-column label="类型" min-width="100"> <template v-slot:default="scope"> <div slot="reference" class="name-wrapper"> - <el-tag size="medium" effect="plain" v-if="scope.row.gbDeviceDbId">国标设备</el-tag> - <el-tag size="medium" effect="plain" type="success" v-if="scope.row.streamPushId">推流设备</el-tag> - <el-tag size="medium" effect="plain" type="warning" v-if="scope.row.streamProxyId">拉流代理</el-tag> + <el-tag size="medium" effect="plain" v-if="scope.row.dataType === 1">国标设备</el-tag> + <el-tag size="medium" effect="plain" type="success" v-else-if="scope.row.dataType === 2" >推流设备</el-tag> + <el-tag size="medium" effect="plain" type="warning" v-else-if="scope.row.dataType === 3">拉流代理</el-tag> </div> </template> </el-table-column> @@ -107,10 +101,11 @@ <script> import gbDeviceSelect from "./GbDeviceSelect.vue"; +import ChannelDataTypeSelect from "../common/channelDataTypeSelect.vue"; export default { name: 'shareChannelAdd', - components: {gbDeviceSelect}, + components: {ChannelDataTypeSelect, gbDeviceSelect}, props: [ 'platformId'], data() { return { diff --git a/web_src/src/components/group.vue b/web_src/src/components/group.vue index 85fb134e0..2173b7883 100755 --- a/web_src/src/components/group.vue +++ b/web_src/src/components/group.vue @@ -28,14 +28,7 @@ <el-option label="离线" value="false"></el-option> </el-select> 类型: - <el-select size="mini" style="width: 8rem; margin-right: 1rem;" @change="getChannelList" - v-model="channelType" placeholder="请选择" - default-first-option> - <el-option label="全部" value=""></el-option> - <el-option label="国标设备" :value="0"></el-option> - <el-option label="推流设备" :value="1"></el-option> - <el-option label="拉流代理" :value="2"></el-option> - </el-select> + <channelDataTypeSelect style="width: 8rem; margin-right: 1rem;" @change="getChannelList" v-model="channelType"></channelDataTypeSelect> <el-button size="mini" type="primary" @click="add()"> 添加通道 </el-button> @@ -60,9 +53,9 @@ <el-table-column label="类型" min-width="100"> <template v-slot:default="scope"> <div slot="reference" class="name-wrapper"> - <el-tag size="medium" effect="plain" v-if="scope.row.gbDeviceDbId">国标设备</el-tag> - <el-tag size="medium" effect="plain" type="success" v-if="scope.row.streamPushId">推流设备</el-tag> - <el-tag size="medium" effect="plain" type="warning" v-if="scope.row.streamProxyId">拉流代理</el-tag> + <el-tag size="medium" effect="plain" v-if="scope.row.dataType === 1">国标设备</el-tag> + <el-tag size="medium" effect="plain" type="success" v-else-if="scope.row.dataType === 2" >推流设备</el-tag> + <el-tag size="medium" effect="plain" type="warning" v-else-if="scope.row.dataType === 3">拉流代理</el-tag> </div> </template> </el-table-column> @@ -97,10 +90,12 @@ import DeviceService from "./service/DeviceService"; import GroupTree from "./common/GroupTree.vue"; import GbChannelSelect from "./dialog/GbChannelSelect.vue"; import RegionTree from "./common/RegionTree.vue"; +import ChannelDataTypeSelect from "./common/channelDataTypeSelect.vue"; export default { name: 'channelList', components: { + ChannelDataTypeSelect, RegionTree, GbChannelSelect, uiHeader, diff --git a/web_src/src/components/region.vue b/web_src/src/components/region.vue index b2c80dbe4..6f951287b 100755 --- a/web_src/src/components/region.vue +++ b/web_src/src/components/region.vue @@ -28,13 +28,7 @@ <el-option label="离线" value="false"></el-option> </el-select> 类型: - <el-select size="mini" style="width: 8rem; margin-right: 1rem;" @change="getChannelList" v-model="channelType" placeholder="请选择" - default-first-option> - <el-option label="全部" value=""></el-option> - <el-option label="国标设备" :value="0"></el-option> - <el-option label="推流设备" :value="1"></el-option> - <el-option label="拉流代理" :value="2"></el-option> - </el-select> + <channelDataTypeSelect style="width: 8rem; margin-right: 1rem;" @change="getChannelList" v-model="channelType"></channelDataTypeSelect> <el-button size="mini" type="primary" @click="add()"> 添加通道 </el-button> @@ -59,9 +53,9 @@ <el-table-column label="类型" min-width="100"> <template v-slot:default="scope"> <div slot="reference" class="name-wrapper"> - <el-tag size="medium" effect="plain" v-if="scope.row.gbDeviceDbId">国标设备</el-tag> - <el-tag size="medium" effect="plain" type="success" v-if="scope.row.streamPushId">推流设备</el-tag> - <el-tag size="medium" effect="plain" type="warning" v-if="scope.row.streamProxyId">拉流代理</el-tag> + <el-tag size="medium" effect="plain" v-if="scope.row.dataType === 1">国标设备</el-tag> + <el-tag size="medium" effect="plain" type="success" v-else-if="scope.row.dataType === 2" >推流设备</el-tag> + <el-tag size="medium" effect="plain" type="warning" v-else-if="scope.row.dataType === 3">拉流代理</el-tag> </div> </template> </el-table-column> @@ -95,10 +89,12 @@ import uiHeader from '../layout/UiHeader.vue' import DeviceService from "./service/DeviceService"; import RegionTree from "./common/RegionTree.vue"; import GbChannelSelect from "./dialog/GbChannelSelect.vue"; +import ChannelDataTypeSelect from "./common/channelDataTypeSelect.vue"; export default { name: 'channelList', components: { + ChannelDataTypeSelect, GbChannelSelect, uiHeader, RegionTree,