规范数据库,解决bug
This commit is contained in:
@@ -87,26 +87,27 @@ public interface DeviceChannelMapper {
|
||||
void startPlay(String deviceId, String channelId, String streamId);
|
||||
|
||||
@Select(value = {" <script>" +
|
||||
"SELECT dc.channelId, "+
|
||||
"dc.deviceId, " +
|
||||
"dc.name, " +
|
||||
"de.manufacturer, " +
|
||||
"de.hostAddress, " +
|
||||
"dc.subCount, " +
|
||||
"pgc.platformId as platformId, " +
|
||||
"pgc.catalogId as catalogId " +
|
||||
"FROM device_channel dc " +
|
||||
"LEFT JOIN device de ON dc.deviceId = de.deviceId " +
|
||||
"LEFT JOIN platform_gb_channel pgc on de.deviceId = pgc.deviceId and pgc.channelId = dc.channelId " +
|
||||
"LEFT JOIN device_channel dc2 ON dc2.deviceId = de.deviceId AND dc2.parentId = dc.channelId " +
|
||||
"SELECT " +
|
||||
" dc.id,\n" +
|
||||
" dc.channelId,\n" +
|
||||
" dc.deviceId,\n" +
|
||||
" dc.name,\n" +
|
||||
" de.manufacturer,\n" +
|
||||
" de.hostAddress,\n" +
|
||||
" dc.subCount,\n" +
|
||||
" pgc.platformId as platformId,\n" +
|
||||
" pgc.catalogId as catalogId " +
|
||||
" FROM device_channel dc " +
|
||||
" LEFT JOIN device de ON dc.deviceId = de.deviceId " +
|
||||
" LEFT JOIN platform_gb_channel pgc on pgc.deviceChannelId = dc.id " +
|
||||
" WHERE 1=1 " +
|
||||
" <if test='query != null'> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
|
||||
" <if test='online == true' > AND dc.status=1</if> " +
|
||||
" <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) or (pgc.platformId != #{platformId}))</if> " +
|
||||
" <if test='catalogId != null ' > AND pgc.platformId =#{platformId} AND pgc.catalogId = #{catalogId}</if> " +
|
||||
" <if test='hasSubChannel!= null and hasSubChannel == true' > AND dc.subCount > 0</if> " +
|
||||
" <if test='hasSubChannel!= null and hasSubChannel == false' > AND dc.subCount == 0</if> " +
|
||||
" <if test='catalogId == null ' > AND dc.id not in (select deviceChannelId from platform_gb_channel where platformId=#{platformId} ) </if> " +
|
||||
" <if test='catalogId != null ' > AND pgc.platformId = #{platformId} and pgc.catalogId=#{catalogId} </if> " +
|
||||
" ORDER BY dc.deviceId, dc.channelId ASC" +
|
||||
" </script>"})
|
||||
List<ChannelReduce> queryChannelListInAll(String query, Boolean online, Boolean hasSubChannel, String platformId, String catalogId);
|
||||
@@ -196,8 +197,8 @@ public interface DeviceChannelMapper {
|
||||
List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId);
|
||||
|
||||
@Select(" SELECT\n" +
|
||||
" id,\n" +
|
||||
" channelId,\n" +
|
||||
" channelId as id,\n" +
|
||||
" deviceId,\n" +
|
||||
" parentId,\n" +
|
||||
" status,\n" +
|
||||
|
||||
@@ -19,6 +19,7 @@ public interface GbStreamMapper {
|
||||
"('${app}', '${stream}', '${gbId}', '${name}', " +
|
||||
"'${longitude}', '${latitude}', '${streamType}', " +
|
||||
"'${mediaServerId}', ${status}, ${createStamp})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gbStreamId")
|
||||
int add(GbStream gbStream);
|
||||
|
||||
@Update("UPDATE gb_stream " +
|
||||
|
||||
@@ -21,22 +21,22 @@ public interface PlatformChannelMapper {
|
||||
* 查询列表里已经关联的
|
||||
*/
|
||||
@Select("<script> "+
|
||||
"SELECT deviceAndChannelId FROM platform_gb_channel WHERE platformId='${platformId}' AND deviceAndChannelId in" +
|
||||
"<foreach collection='deviceAndChannelIds' open='(' item='id_' separator=',' close=')'> '${id_}'</foreach> ORDER BY deviceAndChannelId ASC" +
|
||||
"SELECT deviceChannelId FROM platform_gb_channel WHERE platformId='${platformId}' AND deviceChannelId in" +
|
||||
"<foreach collection='channelReduces' open='(' item='item' separator=',' close=')'> '${item.id}'</foreach>" +
|
||||
"</script>")
|
||||
List<String> findChannelRelatedPlatform(String platformId, List<String> deviceAndChannelIds);
|
||||
List<Integer> findChannelRelatedPlatform(String platformId, List<ChannelReduce> channelReduces);
|
||||
|
||||
@Insert("<script> "+
|
||||
"INSERT INTO platform_gb_channel (channelId, deviceId, platformId, deviceAndChannelId, catalogId) VALUES" +
|
||||
"INSERT INTO platform_gb_channel (platformId, deviceChannelId, catalogId) VALUES" +
|
||||
"<foreach collection='channelReducesToAdd' item='item' separator=','>" +
|
||||
" ('${item.channelId}','${item.deviceId}', '${platformId}', '${item.deviceId}_${item.channelId}' , '${item.catalogId}' )" +
|
||||
" ('${platformId}', '${item.id}' , '${item.catalogId}' )" +
|
||||
"</foreach>" +
|
||||
"</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>" +
|
||||
"DELETE FROM platform_gb_channel WHERE platformId='${platformId}' AND deviceChannelId in" +
|
||||
"<foreach collection='channelReducesToDel' item='item' open='(' separator=',' close=')' > '${item.id}'</foreach>" +
|
||||
"</script>")
|
||||
int delChannelForGB(String platformId, List<ChannelReduce> channelReducesToDel);
|
||||
|
||||
@@ -79,8 +79,10 @@ public interface PlatformChannelMapper {
|
||||
"parent_platform pp " +
|
||||
"left join platform_gb_channel pgc on " +
|
||||
"pp.serverGBId = pgc.platformId " +
|
||||
"left join device_channel dc on " +
|
||||
"dc.id = pgc.deviceChannelId " +
|
||||
"WHERE " +
|
||||
"pgc.channelId = #{channelId} and pp.status = true " +
|
||||
"dc.channelId = #{channelId} and pp.status = true " +
|
||||
"AND pp.serverGBId IN" +
|
||||
"<foreach collection='platforms' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
|
||||
"</script> ")
|
||||
|
||||
@@ -607,19 +607,19 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
@Override
|
||||
public int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces, String catalogId) {
|
||||
|
||||
Map<String, ChannelReduce> deviceAndChannels = new HashMap<>();
|
||||
Map<Integer, ChannelReduce> deviceAndChannels = new HashMap<>();
|
||||
for (ChannelReduce channelReduce : channelReduces) {
|
||||
channelReduce.setCatalogId(catalogId);
|
||||
deviceAndChannels.put(channelReduce.getDeviceId() + "_" + channelReduce.getChannelId(), channelReduce);
|
||||
deviceAndChannels.put(channelReduce.getId(), channelReduce);
|
||||
}
|
||||
List<String> deviceAndChannelList = new ArrayList<>(deviceAndChannels.keySet());
|
||||
List<Integer> deviceAndChannelList = new ArrayList<>(deviceAndChannels.keySet());
|
||||
// 查询当前已经存在的
|
||||
List<String> relatedPlatformchannels = platformChannelMapper.findChannelRelatedPlatform(platformId, deviceAndChannelList);
|
||||
if (relatedPlatformchannels != null) {
|
||||
deviceAndChannelList.removeAll(relatedPlatformchannels);
|
||||
List<Integer> channelIds = platformChannelMapper.findChannelRelatedPlatform(platformId, channelReduces);
|
||||
if (deviceAndChannelList != null) {
|
||||
deviceAndChannelList.removeAll(channelIds);
|
||||
}
|
||||
for (String relatedPlatformchannel : relatedPlatformchannels) {
|
||||
deviceAndChannels.remove(relatedPlatformchannel);
|
||||
for (Integer channelId : channelIds) {
|
||||
deviceAndChannels.remove(channelId);
|
||||
}
|
||||
List<ChannelReduce> channelReducesToAdd = new ArrayList<>(deviceAndChannels.values());
|
||||
// 对剩下的数据进行存储
|
||||
|
||||
Reference in New Issue
Block a user