From 5bcd8495e03b08ff417f74f816d20e028f9b1fe0 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期日, 20 二月 2022 16:22:43 +0800
Subject: [PATCH] 兼容海康不规范的xml,大幅度提高通道分页查询速度,优化节点的保活。
---
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java | 65 ++++++++++++++++++++++++++++++--
1 files changed, 60 insertions(+), 5 deletions(-)
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 06486c9..85310ed 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
@@ -1,9 +1,11 @@
package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
+import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog;
import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream;
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
+import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
@@ -14,9 +16,20 @@
@Repository
public interface PlatformGbStreamMapper {
- @Insert("INSERT INTO platform_gb_stream (app, stream, platformId, catalogId) VALUES" +
+ @Insert("REPLACE INTO platform_gb_stream (app, stream, platformId, catalogId) VALUES" +
"('${app}', '${stream}', '${platformId}', '${catalogId}')")
int add(PlatformGbStream platformGbStream);
+
+
+ @Insert("<script> " +
+ "REPLACE into platform_gb_stream " +
+ "(app, stream, platformId, catalogId) " +
+ "values " +
+ "<foreach collection='streamPushItems' index='index' item='item' separator=','> " +
+ "('${item.app}', '${item.stream}', '${platformId}', '${catalogId}')" +
+ "</foreach> " +
+ "</script>")
+ int batchAdd(String platformId, String catalogId, List<StreamPushItem> streamPushItems);
@Delete("DELETE FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream}")
int delByAppAndStream(String app, String stream);
@@ -24,10 +37,19 @@
@Delete("DELETE FROM platform_gb_stream WHERE platformId=#{platformId}")
int delByPlatformId(String platformId);
- @Select("SELECT * FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream}")
- List<StreamProxyItem> selectByAppAndStream(String app, String stream);
+ @Select("SELECT " +
+ "pp.* " +
+ "FROM " +
+ "platform_gb_stream pgs " +
+ "LEFT JOIN parent_platform pp ON pp.serverGBId = pgs.platformId " +
+ "WHERE " +
+ "pgs.app =#{app} " +
+ "AND pgs.stream =#{stream} ")
+ List<ParentPlatform> selectByAppAndStream(String app, String stream);
- @Select("SELECT * FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream} AND platformId=#{serverGBId}")
+ @Select("SELECT pgs.*, gs.gbId FROM platform_gb_stream pgs " +
+ "LEFT JOIN gb_stream gs ON pgs.app = gs.app AND pgs.stream = gs.stream " +
+ "WHERE pgs.app=#{app} AND pgs.stream=#{stream} AND pgs.platformId=#{serverGBId}")
StreamProxyItem selectOne(String app, String stream, String serverGBId);
@Select("select gs.* \n" +
@@ -42,9 +64,42 @@
" left join platform_gb_stream pgs\n" +
" on gs.app = pgs.app and gs.stream = pgs.stream\n" +
"where pgs.platformId=#{platformId} and pgs.catalogId=#{catalogId}")
- List<PlatformCatalog> queryChannelInParentPlatformAndCatalogForCatlog(String platformId, String catalogId);
+ List<PlatformCatalog> queryChannelInParentPlatformAndCatalogForCatalog(String platformId, String catalogId);
@Delete("DELETE FROM platform_gb_stream WHERE catalogId=#{id}")
int delByCatalogId(String id);
+ @Select("<script> " +
+ "SELECT " +
+ "pp.* " +
+ "FROM " +
+ "parent_platform pp " +
+ "left join platform_gb_stream pgs on " +
+ "pp.serverGBId = pgs.platformId " +
+ "WHERE " +
+ "pgs.app = #{app} " +
+ "AND pgs.stream = #{stream}" +
+ "AND pp.serverGBId IN" +
+ "<foreach collection='platforms' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
+ "</script> ")
+ List<ParentPlatform> queryPlatFormListForGBWithGBId(String app, String stream, List<String> platforms);
+
+ @Delete("DELETE FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream} AND platformId=#{platformId}")
+ int delByAppAndStreamAndPlatform(String app, String stream, String platformId);
+
+ @Delete("<script> "+
+ "DELETE FROM platform_gb_stream where " +
+ "<foreach collection='gbStreams' item='item' separator='or'>" +
+ "(app=#{item.app} and stream=#{item.stream}) " +
+ "</foreach>" +
+ "</script>")
+ void delByGbStreams(List<GbStream> gbStreams);
+
+ @Delete("<script> "+
+ "DELETE FROM platform_gb_stream where " +
+ "<foreach collection='gbStreams' item='item' separator='or'>" +
+ "(app=#{item.app} and stream=#{item.stream}) and platformId=#{platformId}" +
+ "</foreach>" +
+ "</script>")
+ void delByAppAndStreamsByPlatformId(List<GbStream> gbStreams, String platformId);
}
--
Gitblit v1.8.0