规范数据库,添加必要约束,优化通道批量导入功能

This commit is contained in:
648540858
2022-02-24 16:55:06 +08:00
parent 2157bb0270
commit a42dda2bd3
13 changed files with 205 additions and 133 deletions

View File

@@ -5,7 +5,7 @@ package com.genersoft.iot.vmp.gb28181.bean;
*/
public class GbStream extends PlatformGbStream{
private int id;
private Integer gbStreamId;
private String app;
private String stream;
private String gbId;
@@ -20,12 +20,13 @@ public class GbStream extends PlatformGbStream{
*/
public Long createStamp;
public int getId() {
return id;
@Override
public Integer getGbStreamId() {
return gbStreamId;
}
public void setId(int id) {
this.id = id;
public void setGbStreamId(Integer gbStreamId) {
this.gbStreamId = gbStreamId;
}
public String getApp() {

View File

@@ -1,15 +1,15 @@
package com.genersoft.iot.vmp.gb28181.bean;
public class PlatformGbStream {
private String gbStreamId;
private Integer gbStreamId;
private String platformId;
private String catalogId;
public String getGbStreamId() {
public Integer getGbStreamId() {
return gbStreamId;
}
public void setGbStreamId(String gbStreamId) {
public void setGbStreamId(Integer gbStreamId) {
this.gbStreamId = gbStreamId;
}

View File

@@ -8,6 +8,11 @@ import java.util.List;
public class StreamPushItem extends GbStream implements Comparable<StreamPushItem>{
/**
* id
*/
private Integer id;
/**
* 应用名
*/
@@ -111,6 +116,13 @@ public class StreamPushItem extends GbStream implements Comparable<StreamPushIte
}
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getApp() {
return app;

View File

@@ -9,6 +9,7 @@ import com.genersoft.iot.vmp.vmanager.bean.StreamPushExcelDto;
import com.github.pagehelper.PageInfo;
import java.util.List;
import java.util.Map;
public interface IStreamPushService {
@@ -69,5 +70,5 @@ public interface IStreamPushService {
boolean batchStop(List<GbStream> streamPushItems);
void batchAddForUpload(String platformId, String catalogId, List<StreamPushItem> streamPushItems);
void batchAddForUpload(List<StreamPushItem> streamPushItems, Map<String, List<String[]>> streamPushItemsForAll);
}

View File

@@ -159,7 +159,9 @@ public class GbStreamServiceImpl implements IGbStreamService {
List<ParentPlatform> parentPlatforms = platformGbStreamMapper.selectByAppAndStream(gs.getApp(), gs.getStream());
if (parentPlatforms.size() > 0) {
for (ParentPlatform parentPlatform : parentPlatforms) {
eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), gs, type);
if (parentPlatform != null) {
eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), gs, type);
}
}
}
}

View File

@@ -28,6 +28,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class StreamPushServiceImpl implements IStreamPushService {
@@ -359,23 +360,63 @@ public class StreamPushServiceImpl implements IStreamPushService {
}
@Override
public void batchAddForUpload(String platformId, String catalogId, List<StreamPushItem> streamPushItems) {
public void batchAddForUpload(List<StreamPushItem> streamPushItems, Map<String, List<String[]>> streamPushItemsForAll ) {
// 存储数据到stream_push表
streamPushMapper.addAll(streamPushItems);
gbStreamMapper.batchAdd(streamPushItems);
if (platformId != null) {
ParentPlatform platform = parentPlatformMapper.getParentPlatByServerGBId(platformId);
if (platform != null) {
if (catalogId == null) {
catalogId = platform.getCatalogId();
}else {
PlatformCatalog catalog = platformCatalogMapper.select(catalogId);
if (catalog == null) {
return;
List<StreamPushItem> streamPushItemForGbStream = streamPushItems.stream()
.filter(streamPushItem-> streamPushItem.getId() != null)
.collect(Collectors.toList());
// 存储数据到gb_stream表 id会返回到streamPushItemForGbStream里
if (streamPushItemForGbStream.size() > 0) {
gbStreamMapper.batchAdd(streamPushItemForGbStream);
}
// 去除没有ID也就是没有存储到数据库的数据
List<StreamPushItem> streamPushItemsForPlatform = streamPushItemForGbStream.stream()
.filter(streamPushItem-> streamPushItem.getGbStreamId() != null)
.collect(Collectors.toList());
if (streamPushItemsForPlatform.size() > 0) {
List<StreamPushItem> streamPushItemListFroPlatform = new ArrayList<>();
Map<String, List<StreamPushItem>> platformForEvent = new HashMap<>();
// 遍历存储结果查找app+Stream->platformId+catalogId的对应关系然后执行批量写入
for (StreamPushItem streamPushItem : streamPushItemsForPlatform) {
List<String[]> platFormInfoList = streamPushItemsForAll.get(streamPushItem.getApp() + streamPushItem.getStream());
if (platFormInfoList != null) {
if (platFormInfoList.size() > 0) {
for (String[] platFormInfoArray : platFormInfoList) {
StreamPushItem streamPushItemForPlatform = new StreamPushItem();
streamPushItemForPlatform.setGbStreamId(streamPushItem.getGbStreamId());
if (platFormInfoArray.length > 0) {
// 数组 platFormInfoArray 0 为平台ID。 1为目录ID
streamPushItemForPlatform.setPlatformId(platFormInfoArray[0]);
List<StreamPushItem> streamPushItemsInPlatform = platformForEvent.get(streamPushItem.getPlatformId());
if (streamPushItemsInPlatform == null) {
streamPushItemsInPlatform = new ArrayList<>();
platformForEvent.put(platFormInfoArray[0], streamPushItemsInPlatform);
}
// 为发送通知整理数据
streamPushItemForPlatform.setApp(streamPushItem.getApp());
streamPushItemForPlatform.setStream(streamPushItem.getStream());
streamPushItemForPlatform.setGbId(streamPushItem.getGbId());
streamPushItemsInPlatform.add(streamPushItemForPlatform);
}
if (platFormInfoArray.length > 1) {
streamPushItemForPlatform.setCatalogId(platFormInfoArray[1]);
}
streamPushItemListFroPlatform.add(streamPushItemForPlatform);
}
}
}
List<GbStream> gbStreamList = gbStreamMapper.selectAllForAppAndStream(streamPushItems);
platformGbStreamMapper.batchAdd(platformId, catalogId, gbStreamList);
eventPublisher.catalogEventPublishForStream(platformId, streamPushItems.toArray(new GbStream[0]), CatalogEvent.ADD);
}
platformGbStreamMapper.batchAdd(streamPushItemListFroPlatform);
// 发送通知
for (String platformId : platformForEvent.keySet()) {
eventPublisher.catalogEventPublishForStream(
platformId, platformForEvent.get(platformId).toArray(new GbStream[0]), CatalogEvent.ADD);
}
}
}

View File

@@ -5,21 +5,45 @@ import com.alibaba.excel.event.AnalysisEventListener;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import com.genersoft.iot.vmp.service.IStreamPushService;
import com.genersoft.iot.vmp.vmanager.bean.StreamPushExcelDto;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import org.springframework.util.StringUtils;
import java.util.*;
public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPushExcelDto> {
// 错误数据的回调,用于将错误数据发送给页面
private ErrorDataHandler errorDataHandler;
// 推流的业务类用于存储数据
private IStreamPushService pushService;
// 默认流媒体节点ID
private String defaultMediaServerId;
// 用于存储不加过滤的所有数据
private List<StreamPushItem> streamPushItems = new ArrayList<>();
private Map<String, UploadData> streamPushItemsForPlatform = new HashMap<>();
// 用于存储更具APP+Stream过滤后的数据可以直接存入stream_push表与gb_stream表
private Map<String,StreamPushItem> streamPushItemForSave = new HashMap<>();
// 用于存储按照APP+Stream为KEY 平台ID+目录Id 为value的数据用于存储到gb_stream表后获取app+Stream对应的平台与目录信息然后存入关联表
private Map<String, List<String[]>> streamPushItemsForPlatform = new HashMap<>();
// 用于判断文件是否存在重复的app+Stream+平台ID
private Set<String> streamPushStreamSet = new HashSet<>();
private Map<String,String> streamPushGBMap = new HashMap<>();
// 用于存储APP+Stream->国标ID 的数据结构, 数据一一对应全局判断APP+Stream->国标ID是否存在不对应
private BiMap<String,String> gBMap = HashBiMap.create();
// 记录错误的APP+Stream
private List<String> errorStreamList = new ArrayList<>();
// 记录错误的国标ID
private List<String> errorGBList = new ArrayList<>();
// 读取数量计数器
private int loadedSize = 0;
@@ -33,16 +57,6 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPus
void handle(List<String> streams, List<String> gbId);
}
private class UploadData{
public String platformId;
public Map<String, List<StreamPushItem>> catalogData = new HashMap<>();
public List<StreamPushItem> streamPushItems = new ArrayList<>();
public UploadData(String platformId) {
this.platformId = platformId;
}
}
@Override
public void invoke(StreamPushExcelDto streamPushExcelDto, AnalysisContext analysisContext) {
if (StringUtils.isEmpty(streamPushExcelDto.getApp())
@@ -50,18 +64,28 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPus
|| StringUtils.isEmpty(streamPushExcelDto.getGbId())) {
return;
}
if (streamPushGBMap.get(streamPushExcelDto.getApp() + streamPushExcelDto.getStream()) == null) {
streamPushGBMap.put(streamPushExcelDto.getApp() + streamPushExcelDto.getStream(), streamPushExcelDto.getGbId());
if (gBMap.get(streamPushExcelDto.getApp() + streamPushExcelDto.getStream()) == null) {
try {
gBMap.put(streamPushExcelDto.getApp() + streamPushExcelDto.getStream(), streamPushExcelDto.getGbId());
}catch (IllegalArgumentException e) {
e.printStackTrace();
errorGBList.add(streamPushExcelDto.getGbId() + "(不同的app+stream使用了相同的国标ID)");
return;
}
}else {
if (!streamPushGBMap.get(streamPushExcelDto.getApp() + streamPushExcelDto.getStream()).equals(streamPushExcelDto.getGbId())) {
errorGBList.add(streamPushExcelDto.getGbId() + "(同一组app+stream使用了不同国标ID)");
if (!gBMap.get(streamPushExcelDto.getApp() + streamPushExcelDto.getStream()).equals(streamPushExcelDto.getGbId())) {
errorGBList.add(streamPushExcelDto.getGbId() + "(同一组app+stream使用了不同国标ID)");
return;
}
}
if (streamPushStreamSet.contains(streamPushExcelDto.getApp() + streamPushExcelDto.getStream() + streamPushExcelDto.getPlatformId())) {
errorStreamList.add(streamPushExcelDto.getApp() + "/" + streamPushExcelDto.getStream()+ "/" + streamPushExcelDto.getPlatformId() + "(同一组app+stream添加在了同一个平台下)");
errorStreamList.add(streamPushExcelDto.getApp() + "/" + streamPushExcelDto.getStream()+ "/" +
streamPushExcelDto.getPlatformId() + "(同一组app+stream添加在了同一个平台下)");
return;
}else {
streamPushStreamSet.add(streamPushExcelDto.getApp()+streamPushExcelDto.getStream() + streamPushExcelDto.getPlatformId());
}
StreamPushItem streamPushItem = new StreamPushItem();
@@ -78,32 +102,31 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPus
streamPushItem.setTotalReaderCount("0");
streamPushItem.setPlatformId(streamPushExcelDto.getPlatformId());
streamPushItem.setCatalogId(streamPushExcelDto.getCatalogId());
if (StringUtils.isEmpty(streamPushExcelDto.getPlatformId())) {
streamPushItems.add(streamPushItem);
}else {
UploadData uploadData = streamPushItemsForPlatform.get(streamPushExcelDto.getPlatformId());
if (uploadData == null) {
uploadData = new UploadData(streamPushExcelDto.getPlatformId());
streamPushItemsForPlatform.put(streamPushExcelDto.getPlatformId(), uploadData);
}
if (!StringUtils.isEmpty(streamPushExcelDto.getCatalogId())) {
List<StreamPushItem> streamPushItems = uploadData.catalogData.get(streamPushExcelDto.getCatalogId());
if (streamPushItems == null) {
streamPushItems = new ArrayList<>();
uploadData.catalogData.put(streamPushExcelDto.getCatalogId(), streamPushItems);
}
streamPushItems.add(streamPushItem);
}else {
uploadData.streamPushItems.add(streamPushItem);
}
// 存入所有的通道信息
streamPushItems.add(streamPushItem);
streamPushItemForSave.put(streamPushItem.getApp() + streamPushItem.getStream(), streamPushItem);
if (!StringUtils.isEmpty(streamPushExcelDto.getPlatformId())) {
List<String[]> platformList = streamPushItemsForPlatform.get(streamPushItem.getApp() + streamPushItem.getStream());
if (platformList == null) {
platformList = new ArrayList<>();
streamPushItemsForPlatform.put(streamPushItem.getApp() + streamPushItem.getStream(), platformList);
}
String platformId = streamPushExcelDto.getPlatformId();
String catalogId = streamPushExcelDto.getCatalogId();
if (StringUtils.isEmpty(streamPushExcelDto.getCatalogId())) {
catalogId = null;
}
String[] platFormInfoArray = new String[]{platformId, catalogId};
platformList.add(platFormInfoArray);
}
streamPushStreamSet.add(streamPushExcelDto.getApp()+streamPushExcelDto.getStream() + streamPushExcelDto.getPlatformId());
loadedSize ++;
if (loadedSize > 1000) {
saveData();
streamPushItems.clear();
streamPushItemForSave.clear();
streamPushItemsForPlatform.clear();
loadedSize = 0;
}
@@ -114,30 +137,18 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPus
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
// 这里也要保存数据,确保最后遗留的数据也存储到数据库
saveData();
streamPushGBMap.clear();
streamPushItems.clear();
streamPushItemForSave.clear();
gBMap.clear();
streamPushStreamSet.clear();
streamPushItemsForPlatform.clear();
errorDataHandler.handle(errorStreamList, errorGBList);
}
private void saveData(){
if (streamPushItems.size() > 0) {
pushService.batchAddForUpload(null, null, streamPushItems);
}
// 处理已分配到平台的流
if (streamPushItemsForPlatform.size() > 0){
for (String platformId : streamPushItemsForPlatform.keySet()) {
UploadData uploadData = streamPushItemsForPlatform.get(platformId);
if (uploadData.streamPushItems.size() > 0) {
pushService.batchAddForUpload(platformId, null, uploadData.streamPushItems);
}
if (uploadData.catalogData.size() > 0) {
for (String catalogId : uploadData.catalogData.keySet()) {
if (uploadData.catalogData.get(catalogId).size() > 0) {
pushService.batchAddForUpload(platformId, catalogId, uploadData.catalogData.get(catalogId));
}
}
}
}
if (streamPushItemForSave.size() > 0) {
// 向数据库查询是否存在重复的app
pushService.batchAddForUpload(new ArrayList<>(streamPushItemForSave.values()), streamPushItemsForPlatform);
}
}
}

View File

@@ -41,15 +41,15 @@ public interface GbStreamMapper {
"SELECT gs.* FROM gb_stream gs " +
"WHERE " +
"1=1 " +
" <if test='catalogId != null'> AND gs.id in" +
" <if test='catalogId != null'> AND gs.gbStreamId in" +
"(select pgs.gbStreamId from platform_gb_stream pgs where pgs.platformId = #{platformId} and pgs.catalogId=#{catalogId})</if> " +
" <if test='catalogId == null'> AND gs.id not in" +
" <if test='catalogId == null'> AND gs.gbStreamId not in" +
"(select pgs.gbStreamId from platform_gb_stream pgs where pgs.platformId = #{platformId}) </if> " +
" <if test='query != null'> AND (gs.app LIKE '%${query}%' OR gs.stream LIKE '%${query}%' OR gs.gbId LIKE '%${query}%' OR gs.name LIKE '%${query}%')</if> " +
" <if test='pushing == true' > AND gs.status=1</if>" +
" <if test='pushing == false' > AND gs.status=0</if>" +
" <if test='mediaServerId != null' > AND gs.mediaServerId=#{mediaServerId} </if>" +
" order by gs.id asc " +
" order by gs.gbStreamId asc " +
"</script>")
List<GbStream> selectAll(String platformId, String catalogId, String query, Boolean pushing, String mediaServerId);
@@ -60,18 +60,18 @@ public interface GbStreamMapper {
List<GbStream> 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.id = pgs.catalogId " +
"LEFT JOIN platform_gb_stream pgs ON gs.gbStreamId = pgs.catalogId " +
"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.id = pgs.gbStreamId " +
"LEFT JOIN platform_gb_stream pgs ON gs.gbStreamId = pgs.gbStreamId " +
"WHERE pgs.platformId = #{platformId}")
List<GbStream> queryGbStreamListInPlatform(String platformId);
@Select("SELECT gs.* FROM gb_stream gs LEFT JOIN platform_gb_stream pgs " +
"ON gs.id = pgs.gbStreamId WHERE pgs.gbStreamId is NULL")
"ON gs.gbStreamId = pgs.gbStreamId WHERE pgs.gbStreamId is NULL")
List<GbStream> queryStreamNotInPlatform();
@Update("UPDATE gb_stream " +
@@ -104,7 +104,7 @@ public interface GbStreamMapper {
void batchDelForGbStream(List<GbStream> gbStreams);
@Insert("<script> " +
"REPLACE into gb_stream " +
"INSERT IGNORE into gb_stream " +
"(app, stream, gbId, name, " +
"longitude, latitude, streamType, mediaServerId, status, createStamp)" +
"values " +
@@ -114,6 +114,7 @@ public interface GbStreamMapper {
"'${item.mediaServerId}', ${item.status}, ${item.createStamp}) "+
"</foreach> " +
"</script>")
@Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gbStreamId")
void batchAdd(List<StreamPushItem> subList);
@Update({"<script>" +

View File

@@ -17,21 +17,21 @@ import java.util.List;
public interface PlatformGbStreamMapper {
@Insert("REPLACE INTO platform_gb_stream (gbStreamId, platformId, catalogId) VALUES" +
"( #{id}, #{platformId}, #{catalogId})")
"( #{gbStreamId}, #{platformId}, #{catalogId})")
int add(PlatformGbStream platformGbStream);
@Insert("<script> " +
"REPLACE into platform_gb_stream " +
"INSERT into platform_gb_stream " +
"(gbStreamId, platformId, catalogId) " +
"values " +
"<foreach collection='streamPushItems' index='index' item='item' separator=','> " +
"(#{item.id}, #{platformId}, #{catalogId})" +
"(${item.gbStreamId}, '${item.platformId}', '${item.catalogId}')" +
"</foreach> " +
"</script>")
int batchAdd(String platformId, String catalogId, List<GbStream> streamPushItems);
int batchAdd(List<StreamPushItem> streamPushItems);
@Delete("DELETE FROM platform_gb_stream WHERE gbStreamId = (select id from gb_stream where app=#{app} AND stream=#{stream})")
@Delete("DELETE FROM platform_gb_stream WHERE gbStreamId = (select gbStreamId 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.id = pgs.gbStreamId " +
"LEFT JOIN gb_stream gs ON gs.gbStreamId = pgs.gbStreamId " +
"WHERE " +
"gs.app =#{app} " +
"AND gs.stream =#{stream} ")
List<ParentPlatform> selectByAppAndStream(String app, String stream);
@Select("SELECT pgs.*, gs.gbId FROM platform_gb_stream pgs " +
"LEFT JOIN gb_stream gs ON pgs.gbStreamId = gs.id " +
"LEFT JOIN gb_stream gs ON pgs.gbStreamId = gs.gbStreamId " +
"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.id = pgs.gbStreamId\n" +
" on gs.gbStreamId = pgs.gbStreamId\n" +
"where pgs.platformId=#{platformId} and pgs.catalogId=#{catalogId}")
List<GbStream> 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.id = pgs.gbStreamId\n" +
" on gs.gbStreamId = pgs.gbStreamId\n" +
"where pgs.platformId=#{platformId} and pgs.catalogId=#{catalogId}")
List<PlatformCatalog> 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.id = pgs.gbStreamId " +
"gs.gbStreamId = pgs.gbStreamId " +
"WHERE " +
"gs.app = #{app} " +
"AND gs.stream = #{stream}" +
@@ -93,7 +93,7 @@ public interface PlatformGbStreamMapper {
@Delete("<script> "+
"DELETE FROM platform_gb_stream where gbStreamId in " +
"<foreach collection='gbStreams' item='item' open='(' separator=',' close=')' >" +
"#{item.id}" +
"#{item.gbStreamId}" +
"</foreach>" +
"</script>")
void delByGbStreams(List<GbStream> gbStreams);
@@ -101,7 +101,7 @@ public interface PlatformGbStreamMapper {
@Delete("<script> "+
"DELETE FROM platform_gb_stream where platformId=#{platformId} and gbStreamId in " +
"<foreach collection='gbStreams' item='item' open='(' separator=',' close=')'>" +
"#{item.id} " +
"#{item.gbStreamId} " +
"</foreach>" +
"</script>")
void delByAppAndStreamsByPlatformId(List<GbStream> gbStreams, String platformId);

View File

@@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import org.apache.ibatis.annotations.*;
import org.omg.PortableInterceptor.INACTIVE;
import org.springframework.stereotype.Repository;
import java.util.Collection;
@@ -61,39 +62,37 @@ public interface StreamPushMapper {
@Select(value = {" <script>" +
"SELECT " +
"st.*, " +
"pgs.gbId, pgs.status, pgs.name, pgs.longitude, pgs.latitude , pgs.id " +
"gs.gbId, gs.status, gs.name, gs.longitude, gs.latitude, gs.gbStreamId " +
"from " +
"stream_push st " +
"LEFT JOIN gb_stream pgs " +
"on st.app = pgs.app AND st.stream = pgs.stream " +
"LEFT JOIN gb_stream gs " +
"on st.app = gs.app AND st.stream = gs.stream " +
"WHERE " +
"1=1 " +
" <if test='query != null'> AND (st.app LIKE '%${query}%' OR st.stream LIKE '%${query}%' OR pgs.gbId LIKE '%${query}%' OR pgs.name LIKE '%${query}%')</if> " +
" <if test='pushing == true' > AND (pgs.gbId is null OR pgs.status=1)</if>" +
" <if test='pushing == false' > AND pgs.status=0</if>" +
" <if test='query != null'> AND (st.app LIKE '%${query}%' OR st.stream LIKE '%${query}%' OR gs.gbId LIKE '%${query}%' OR gs.name LIKE '%${query}%')</if> " +
" <if test='pushing == true' > AND (gs.gbId is null OR gs.status=1)</if>" +
" <if test='pushing == false' > AND gs.status=0</if>" +
" <if test='mediaServerId != null' > AND st.mediaServerId=#{mediaServerId} </if>" +
"order by st.createStamp desc" +
" </script>"})
List<StreamPushItem> selectAllForList(String query, Boolean pushing, String mediaServerId);
@Select("SELECT st.*, pgs.gbId, pgs.status, pgs.name, pgs.longitude, pgs.latitude FROM stream_push st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream order by st.createStamp desc")
@Select("SELECT st.*, gs.gbId, gs.status, gs.name, gs.longitude, gs.latitude FROM stream_push st LEFT JOIN gb_stream gs on st.app = gs.app AND st.stream = gs.stream order by st.createStamp desc")
List<StreamPushItem> selectAll();
@Select("SELECT st.*, pgs.gbId, pgs.status, pgs.name, pgs.longitude, pgs.latitude FROM stream_push st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream WHERE st.enable=${enable}")
List<StreamPushItem> selectForEnable(boolean enable);
@Select("SELECT st.*, pgs.gbId, pgs.status, pgs.name, pgs.longitude, pgs.latitude FROM stream_push st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream WHERE st.app=#{app} AND st.stream=#{stream}")
@Select("SELECT st.*, gs.gbId, gs.status, gs.name, gs.longitude, gs.latitude FROM stream_push st LEFT JOIN gb_stream gs on st.app = gs.app AND st.stream = gs.stream WHERE st.app=#{app} AND st.stream=#{stream}")
StreamPushItem selectOne(String app, String stream);
@Insert("<script>" +
"REPLACE INTO stream_push (app, stream, totalReaderCount, originType, originTypeStr, " +
"Insert IGNORE INTO stream_push (app, stream, totalReaderCount, originType, originTypeStr, " +
"createStamp, aliveSecond, mediaServerId) " +
"VALUES <foreach collection='streamPushItems' item='item' index='index' separator=','>" +
"( '${item.app}', '${item.stream}', '${item.totalReaderCount}', #{item.originType}, " +
"'${item.originTypeStr}',#{item.createStamp}, #{item.aliveSecond}, '${item.mediaServerId}' )" +
" </foreach>" +
"</script>")
void addAll(List<StreamPushItem> streamPushItems);
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
int addAll(List<StreamPushItem> streamPushItems);
@Delete("DELETE FROM stream_push")
void clear();

View File

@@ -748,7 +748,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
return false;
}
}
}else {
} else {
//事务回滚
dataSourceTransactionManager.rollback(transactionStatus);
return false;