规范数据库,给各个标设置主键ID
This commit is contained in:
@@ -86,8 +86,6 @@ public interface DeviceChannelMapper {
|
||||
@Update(value = {"UPDATE device_channel SET streamId=#{streamId} WHERE deviceId=#{deviceId} AND channelId=#{channelId}"})
|
||||
void startPlay(String deviceId, String channelId, String streamId);
|
||||
|
||||
|
||||
|
||||
@Select(value = {" <script>" +
|
||||
"SELECT dc.channelId, "+
|
||||
"dc.deviceId, " +
|
||||
@@ -107,7 +105,7 @@ public interface DeviceChannelMapper {
|
||||
" <if test='online == false' > AND dc.status=0</if> " +
|
||||
" <if test='hasSubChannel!= null and hasSubChannel == true' > AND dc2.channelId is not null</if> " +
|
||||
" <if test='hasSubChannel!= null and hasSubChannel == false' > AND dc2.channelId is null</if> " +
|
||||
" <if test='catalogId == null ' > AND pgc.platformId is null AND pgc.catalogId is null</if> " +
|
||||
" <if test='catalogId == null ' > AND ((pgc.platformId IS NULL AND pgc.catalogId IS NULL) or (pgc.platformId != #{platformId}))</if> " +
|
||||
" <if test='catalogId != null ' > AND pgc.platformId =#{platformId} AND pgc.catalogId = #{catalogId}</if> " +
|
||||
" ORDER BY dc.deviceId, dc.channelId ASC" +
|
||||
" </script>"})
|
||||
|
||||
@@ -38,12 +38,13 @@ public interface GbStreamMapper {
|
||||
int del(String app, String stream);
|
||||
|
||||
@Select("<script> "+
|
||||
"SELECT gs.*, pgs.platformId AS platformId, pgs.catalogId AS catalogId FROM gb_stream gs " +
|
||||
"LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream " +
|
||||
"SELECT gs.* FROM gb_stream gs " +
|
||||
"WHERE " +
|
||||
"1=1 " +
|
||||
" <if test='catalogId != null'> AND pgs.platformId = #{platformId} AND pgs.catalogId = #{catalogId}</if> " +
|
||||
" <if test='catalogId == null'> AND pgs.platformId is null AND pgs.catalogId is null</if> " +
|
||||
" <if test='catalogId != null'> AND gs.id 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" +
|
||||
"(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>" +
|
||||
@@ -59,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.app = pgs.app AND gs.stream = pgs.stream " +
|
||||
"LEFT JOIN platform_gb_stream pgs ON gs.id = 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.app = pgs.app AND gs.stream = pgs.stream " +
|
||||
"WHERE pgs.platformId = '${platformId}'")
|
||||
"LEFT JOIN platform_gb_stream pgs ON gs.id = pgs.gbStreamId " +
|
||||
"WHERE pgs.platformId = #{platformId}")
|
||||
List<GbStream> queryGbStreamListInPlatform(String platformId);
|
||||
|
||||
|
||||
@Select("SELECT gs.*, pgs.platformId as platformId, pgs.catalogId as catalogId FROM gb_stream gs LEFT JOIN platform_gb_stream pgs " +
|
||||
"ON gs.app = pgs.app and gs.stream = pgs.stream WHERE pgs.app is NULL and pgs.stream is NULL")
|
||||
@Select("SELECT gs.* FROM gb_stream gs LEFT JOIN platform_gb_stream pgs " +
|
||||
"ON gs.id = pgs.gbStreamId WHERE pgs.gbStreamId is NULL")
|
||||
List<GbStream> queryStreamNotInPlatform();
|
||||
|
||||
@Update("UPDATE gb_stream " +
|
||||
@@ -124,4 +125,12 @@ public interface GbStreamMapper {
|
||||
"</foreach>" +
|
||||
"</script>"})
|
||||
int updateStreamGPS(List<GPSMsgInfo> gpsMsgInfos);
|
||||
|
||||
@Select("<script> "+
|
||||
"SELECT * FROM gb_stream where " +
|
||||
"<foreach collection='streamPushItems' item='item' separator='or'>" +
|
||||
"(app=#{item.app} and stream=#{item.stream}) " +
|
||||
"</foreach>" +
|
||||
"</script>")
|
||||
List<GbStream> selectAllForAppAndStream(List<StreamPushItem> streamPushItems);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ public interface LogMapper {
|
||||
"values ('${name}', '${type}', '${uri}', '${address}', '${result}', ${timing}, '${username}', '${createTime}')")
|
||||
int add(LogDto logDto);
|
||||
|
||||
|
||||
@Select(value = {"<script>" +
|
||||
" SELECT * FROM log " +
|
||||
" WHERE 1=1 " +
|
||||
@@ -33,7 +32,6 @@ public interface LogMapper {
|
||||
" </script>"})
|
||||
List<LogDto> query(String query, String type, String startTime, String endTime);
|
||||
|
||||
|
||||
@Delete("DELETE FROM log")
|
||||
int clear();
|
||||
}
|
||||
|
||||
@@ -54,7 +54,11 @@ public interface ParentPlatformMapper {
|
||||
" +\n" +
|
||||
" (SELECT count(0)\n" +
|
||||
" FROM platform_gb_stream pgs\n" +
|
||||
" WHERE pgs.platformId = pp.serverGBId)) as channelCount\n" +
|
||||
" WHERE pgs.platformId = pp.serverGBId)\n" +
|
||||
" +\n" +
|
||||
" (SELECT count(0)\n" +
|
||||
" FROM platform_catalog pgc\n" +
|
||||
" WHERE pgc.platformId = pp.serverGBId)) as channelCount\n" +
|
||||
"FROM parent_platform pp ")
|
||||
List<ParentPlatform> getParentPlatformList();
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ public interface PlatformChannelMapper {
|
||||
"</script>")
|
||||
int addChannels(String platformId, List<ChannelReduce> channelReducesToAdd);
|
||||
|
||||
|
||||
@Delete("<script> "+
|
||||
"DELETE FROM platform_gb_channel WHERE platformId='${platformId}' AND deviceAndChannelId in" +
|
||||
"<foreach collection='channelReducesToDel' item='item' open='(' separator=',' close=')' > '${item.deviceId}_${item.channelId}'</foreach>" +
|
||||
@@ -51,12 +50,10 @@ public interface PlatformChannelMapper {
|
||||
"</script>")
|
||||
int cleanChannelForGB(String platformId);
|
||||
|
||||
|
||||
@Select("SELECT * FROM device_channel WHERE deviceId = (SELECT deviceId FROM platform_gb_channel WHERE " +
|
||||
"platformId='${platformId}' AND channelId='${channelId}' ) AND channelId='${channelId}'")
|
||||
DeviceChannel queryChannelInParentPlatform(String platformId, String channelId);
|
||||
|
||||
|
||||
@Select("select dc.channelId as id, dc.name as name, pgc.platformId as platformId, pgc.catalogId as parentId, 0 as childrenCount, 1 as type " +
|
||||
"from device_channel dc left join platform_gb_channel pgc on dc.deviceId = pgc.deviceId and dc.channelId = pgc.channelId " +
|
||||
"where pgc.platformId=#{platformId} and pgc.catalogId=#{catalogId}")
|
||||
|
||||
@@ -16,22 +16,22 @@ import java.util.List;
|
||||
@Repository
|
||||
public interface PlatformGbStreamMapper {
|
||||
|
||||
@Insert("REPLACE INTO platform_gb_stream (app, stream, platformId, catalogId) VALUES" +
|
||||
"('${app}', '${stream}', '${platformId}', '${catalogId}')")
|
||||
@Insert("REPLACE INTO platform_gb_stream (gbStreamId, platformId, catalogId) VALUES" +
|
||||
"( #{id}, #{platformId}, #{catalogId})")
|
||||
int add(PlatformGbStream platformGbStream);
|
||||
|
||||
|
||||
@Insert("<script> " +
|
||||
"REPLACE into platform_gb_stream " +
|
||||
"(app, stream, platformId, catalogId) " +
|
||||
"(gbStreamId, platformId, catalogId) " +
|
||||
"values " +
|
||||
"<foreach collection='streamPushItems' index='index' item='item' separator=','> " +
|
||||
"('${item.app}', '${item.stream}', '${platformId}', '${catalogId}')" +
|
||||
"(#{item.id}, #{platformId}, #{catalogId})" +
|
||||
"</foreach> " +
|
||||
"</script>")
|
||||
int batchAdd(String platformId, String catalogId, List<StreamPushItem> streamPushItems);
|
||||
int batchAdd(String platformId, String catalogId, List<GbStream> streamPushItems);
|
||||
|
||||
@Delete("DELETE FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream}")
|
||||
@Delete("DELETE FROM platform_gb_stream WHERE gbStreamId = (select id 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,27 +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 " +
|
||||
"WHERE " +
|
||||
"pgs.app =#{app} " +
|
||||
"AND pgs.stream =#{stream} ")
|
||||
"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.app = gs.app AND pgs.stream = gs.stream " +
|
||||
"WHERE pgs.app=#{app} AND pgs.stream=#{stream} AND pgs.platformId=#{serverGBId}")
|
||||
"LEFT JOIN gb_stream gs ON pgs.gbStreamId = gs.id " +
|
||||
"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.app = pgs.app and gs.stream = pgs.stream\n" +
|
||||
" on gs.id = 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.app = pgs.app and gs.stream = pgs.stream\n" +
|
||||
" on gs.id = pgs.gbStreamId\n" +
|
||||
"where pgs.platformId=#{platformId} and pgs.catalogId=#{catalogId}")
|
||||
List<PlatformCatalog> queryChannelInParentPlatformAndCatalogForCatalog(String platformId, String catalogId);
|
||||
|
||||
@@ -76,29 +77,31 @@ public interface PlatformGbStreamMapper {
|
||||
"parent_platform pp " +
|
||||
"left join platform_gb_stream pgs on " +
|
||||
"pp.serverGBId = pgs.platformId " +
|
||||
"left join gb_stream gs " +
|
||||
"gs.id = pgs.gbStreamId " +
|
||||
"WHERE " +
|
||||
"pgs.app = #{app} " +
|
||||
"AND pgs.stream = #{stream}" +
|
||||
"gs.app = #{app} " +
|
||||
"AND gs.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}")
|
||||
@Delete("DELETE FROM platform_gb_stream WHERE gbStreamId = (select id from 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}) " +
|
||||
"DELETE FROM platform_gb_stream where gbStreamId in " +
|
||||
"<foreach collection='gbStreams' item='item' open='(' separator=',' close=')' >" +
|
||||
"#{item.id}" +
|
||||
"</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}" +
|
||||
"DELETE FROM platform_gb_stream where platformId=#{platformId} and gbStreamId in " +
|
||||
"<foreach collection='gbStreams' item='item' open='(' separator=',' close=')'>" +
|
||||
"#{item.id} " +
|
||||
"</foreach>" +
|
||||
"</script>")
|
||||
void delByAppAndStreamsByPlatformId(List<GbStream> gbStreams, String platformId);
|
||||
|
||||
@@ -61,7 +61,7 @@ public interface StreamPushMapper {
|
||||
@Select(value = {" <script>" +
|
||||
"SELECT " +
|
||||
"st.*, " +
|
||||
"pgs.gbId, pgs.status, pgs.name, pgs.longitude, pgs.latitude " +
|
||||
"pgs.gbId, pgs.status, pgs.name, pgs.longitude, pgs.latitude , pgs.id " +
|
||||
"from " +
|
||||
"stream_push st " +
|
||||
"LEFT JOIN gb_stream pgs " +
|
||||
|
||||
@@ -705,9 +705,18 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
streamProxyItem.setCreateTime(now);
|
||||
streamProxyItem.setCreateStamp(System.currentTimeMillis());
|
||||
try {
|
||||
if (gbStreamMapper.add(streamProxyItem)<0 || streamProxyMapper.add(streamProxyItem) < 0) {
|
||||
if (streamProxyMapper.add(streamProxyItem) > 0) {
|
||||
if (!StringUtils.isEmpty(streamProxyItem.getGbId())) {
|
||||
if (gbStreamMapper.add(streamProxyItem) > 0) {
|
||||
//事务回滚
|
||||
dataSourceTransactionManager.rollback(transactionStatus);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}else {
|
||||
//事务回滚
|
||||
dataSourceTransactionManager.rollback(transactionStatus);
|
||||
return false;
|
||||
}
|
||||
result = true;
|
||||
dataSourceTransactionManager.commit(transactionStatus); //手动提交
|
||||
@@ -731,10 +740,20 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
boolean result = false;
|
||||
streamProxyItem.setStreamType("proxy");
|
||||
try {
|
||||
if (gbStreamMapper.update(streamProxyItem)<0 || streamProxyMapper.update(streamProxyItem) < 0) {
|
||||
if (streamProxyMapper.update(streamProxyItem) > 0) {
|
||||
if (!StringUtils.isEmpty(streamProxyItem.getGbId())) {
|
||||
if (gbStreamMapper.update(streamProxyItem) > 0) {
|
||||
//事务回滚
|
||||
dataSourceTransactionManager.rollback(transactionStatus);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}else {
|
||||
//事务回滚
|
||||
dataSourceTransactionManager.rollback(transactionStatus);
|
||||
return false;
|
||||
}
|
||||
|
||||
dataSourceTransactionManager.commit(transactionStatus); //手动提交
|
||||
result = true;
|
||||
}catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user