diff --git a/sql/mysql.sql b/sql/mysql.sql index f2e358fc..b4c38a2a 100644 --- a/sql/mysql.sql +++ b/sql/mysql.sql @@ -389,7 +389,7 @@ DROP TABLE IF EXISTS `platform_gb_stream`; CREATE TABLE `platform_gb_stream` ( `platformId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `catalogId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `gbStreamId` int NOT NULL, + `gbStreamId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `id` int NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`), UNIQUE KEY `platform_gb_stream_pk` (`platformId`,`catalogId`,`gbStreamId`) diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java index 55b53793..593b78a7 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java @@ -41,15 +41,15 @@ public interface GbStreamMapper { "SELECT gs.* FROM gb_stream gs " + "WHERE " + "1=1 " + - " AND gs.gbStreamId in" + + " AND gs.gbId in" + "(select pgs.gbStreamId from platform_gb_stream pgs where pgs.platformId = #{platformId} and pgs.catalogId=#{catalogId}) " + - " AND gs.gbStreamId not in" + + " AND gs.gbId not in" + "(select pgs.gbStreamId from platform_gb_stream pgs where pgs.platformId = #{platformId}) " + " AND (gs.app LIKE '%${query}%' OR gs.stream LIKE '%${query}%' OR gs.gbId LIKE '%${query}%' OR gs.name LIKE '%${query}%') " + " AND gs.status=1" + " AND gs.status=0" + " AND gs.mediaServerId=#{mediaServerId} " + - " order by gs.gbStreamId asc " + + " order by gs.gbId asc " + "") List selectAll(String platformId, String catalogId, String query, Boolean pushing, String mediaServerId); @@ -60,18 +60,18 @@ public interface GbStreamMapper { List selectByGBId(String gbId); @Select("SELECT gs.*, pgs.platformId as platformId, pgs.catalogId as catalogId FROM gb_stream gs " + - "LEFT JOIN platform_gb_stream pgs ON gs.gbStreamId = pgs.catalogId " + + "LEFT JOIN platform_gb_stream pgs ON gs.gbId = pgs.gbStreamId " + "WHERE gs.gbId = '${gbId}' AND pgs.platformId = '${platformId}'") GbStream queryStreamInPlatform(String platformId, String gbId); @Select("SELECT gs.*, pgs.platformId as platformId, pgs.catalogId as catalogId FROM gb_stream gs " + - "LEFT JOIN platform_gb_stream pgs ON gs.gbStreamId = pgs.gbStreamId " + + "LEFT JOIN platform_gb_stream pgs ON gs.gbId = pgs.gbStreamId " + "WHERE pgs.platformId = #{platformId}") List queryGbStreamListInPlatform(String platformId); @Select("SELECT gs.* FROM gb_stream gs LEFT JOIN platform_gb_stream pgs " + - "ON gs.gbStreamId = pgs.gbStreamId WHERE pgs.gbStreamId is NULL") + "ON gs.gbId = pgs.gbStreamId WHERE pgs.gbStreamId is NULL") List queryStreamNotInPlatform(); @Update("UPDATE gb_stream " + @@ -128,10 +128,10 @@ public interface GbStreamMapper { int updateStreamGPS(List gpsMsgInfos); @Select("") + "SELECT * FROM gb_stream where " + + "" + + "(app=#{item.app} and stream=#{item.stream}) " + + "" + + "") List selectAllForAppAndStream(List streamPushItems); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java index a4950980..b411b599 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java @@ -17,7 +17,7 @@ import java.util.List; public interface PlatformGbStreamMapper { @Insert("REPLACE INTO platform_gb_stream (gbStreamId, platformId, catalogId) VALUES" + - "( #{gbStreamId}, #{platformId}, #{catalogId})") + "( #{gbId}, #{platformId}, #{catalogId})") int add(PlatformGbStream platformGbStream); @@ -26,12 +26,12 @@ public interface PlatformGbStreamMapper { "(gbStreamId, platformId, catalogId) " + "values " + " " + - "(${item.gbStreamId}, '${item.platformId}', '${item.catalogId}')" + + "(#{item.gbId}, #{item.platformId}, #{item.catalogId})" + " " + "") int batchAdd(List streamPushItems); - @Delete("DELETE FROM platform_gb_stream WHERE gbStreamId = (select gbStreamId from gb_stream where app=#{app} AND stream=#{stream})") + @Delete("DELETE FROM platform_gb_stream WHERE gbStreamId = (select gbId from gb_stream where app=#{app} AND stream=#{stream})") int delByAppAndStream(String app, String stream); @Delete("DELETE FROM platform_gb_stream WHERE platformId=#{platformId}") @@ -42,28 +42,28 @@ public interface PlatformGbStreamMapper { "FROM " + "platform_gb_stream pgs " + "LEFT JOIN parent_platform pp ON pp.serverGBId = pgs.platformId " + - "LEFT JOIN gb_stream gs ON gs.gbStreamId = pgs.gbStreamId " + + "LEFT JOIN gb_stream gs ON gs.gbId = pgs.gbStreamId " + "WHERE " + "gs.app =#{app} " + "AND gs.stream =#{stream} ") List selectByAppAndStream(String app, String stream); @Select("SELECT pgs.*, gs.gbId FROM platform_gb_stream pgs " + - "LEFT JOIN gb_stream gs ON pgs.gbStreamId = gs.gbStreamId " + + "LEFT JOIN gb_stream gs ON pgs.gbStreamId = gs.gbId " + "WHERE gs.app=#{app} AND gs.stream=#{stream} AND pgs.platformId=#{serverGBId}") StreamProxyItem selectOne(String app, String stream, String serverGBId); @Select("select gs.* \n" + "from gb_stream gs\n" + " left join platform_gb_stream pgs\n" + - " on gs.gbStreamId = pgs.gbStreamId\n" + + " on gs.gbId = pgs.gbStreamId\n" + "where pgs.platformId=#{platformId} and pgs.catalogId=#{catalogId}") List queryChannelInParentPlatformAndCatalog(String platformId, String catalogId); @Select("select gs.gbId as id, gs.name as name, pgs.platformId as platformId, pgs.catalogId as catalogId , 0 as childrenCount, 2 as type\n" + "from gb_stream gs\n" + " left join platform_gb_stream pgs\n" + - " on gs.gbStreamId = pgs.gbStreamId\n" + + " on gs.gbId = pgs.gbStreamId\n" + "where pgs.platformId=#{platformId} and pgs.catalogId=#{catalogId}") List queryChannelInParentPlatformAndCatalogForCatalog(String platformId, String catalogId); @@ -78,7 +78,7 @@ public interface PlatformGbStreamMapper { "left join platform_gb_stream pgs on " + "pp.serverGBId = pgs.platformId " + "left join gb_stream gs " + - "gs.gbStreamId = pgs.gbStreamId " + + "gs.gbId = pgs.gbStreamId " + "WHERE " + "gs.app = #{app} " + "AND gs.stream = #{stream}" + @@ -87,13 +87,13 @@ public interface PlatformGbStreamMapper { " ") List queryPlatFormListForGBWithGBId(String app, String stream, List platforms); - @Delete("DELETE FROM platform_gb_stream WHERE gbStreamId = (select id from gb_stream where app=#{app} AND stream=#{stream}) AND platformId=#{platformId}") + @Delete("DELETE FROM platform_gb_stream WHERE gbStreamId = (select gbId from gb_stream where app=#{app} AND stream=#{stream}) AND platformId=#{platformId}") int delByAppAndStreamAndPlatform(String app, String stream, String platformId); @Delete("") void delByGbStreams(List gbStreams); @@ -101,7 +101,7 @@ public interface PlatformGbStreamMapper { @Delete("") void delByAppAndStreamsByPlatformId(List gbStreams, String platformId); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java index 1d04c82d..77164c28 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java @@ -707,7 +707,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { try { if (streamProxyMapper.add(streamProxyItem) > 0) { if (!StringUtils.isEmpty(streamProxyItem.getGbId())) { - if (gbStreamMapper.add(streamProxyItem) > 0) { + if (gbStreamMapper.add(streamProxyItem) < 0) { //事务回滚 dataSourceTransactionManager.rollback(transactionStatus); return false; @@ -742,7 +742,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { try { if (streamProxyMapper.update(streamProxyItem) > 0) { if (!StringUtils.isEmpty(streamProxyItem.getGbId())) { - if (gbStreamMapper.update(streamProxyItem) > 0) { + if (gbStreamMapper.update(streamProxyItem) < 0) { //事务回滚 dataSourceTransactionManager.rollback(transactionStatus); return false;