调整数据库结构

结构优化
648540858 2023-12-04 21:56:21 +08:00
parent e44be505d9
commit c4aeef62ef
3 changed files with 43 additions and 48 deletions

View File

@ -1,4 +1,4 @@
CREATE TABLE `wvp_common_gb_channel` CREATE TABLE `wvp_common_channel`
( (
`common_gb_id` bigint unsigned NOT NULL AUTO_INCREMENT, `common_gb_id` bigint unsigned NOT NULL AUTO_INCREMENT,
`common_gb_device_id` varchar(50) NOT NULL, `common_gb_device_id` varchar(50) NOT NULL,
@ -67,11 +67,11 @@ CREATE TABLE `wvp_common_region`
UNIQUE KEY `common_region_device_id` (`common_region_device_id`) UNIQUE KEY `common_region_device_id` (`common_region_device_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `wvp_common_platform_channel` CREATE TABLE `wvp_common_channel_platform`
( (
`id` bigint unsigned NOT NULL AUTO_INCREMENT, `id` bigint unsigned NOT NULL AUTO_INCREMENT,
`platform_id` varchar(50) NOT NULL, `platform_id` bigint unsigned NOT NULL,
`common_gb_channel_id` varchar(50) NOT NULL, `common_gb_channel_id` bigint unsigned NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`), UNIQUE KEY `id` (`id`),
UNIQUE KEY `uk_platform_id_common_gb_channel_id` (`platform_id`,`common_gb_channel_id`) UNIQUE KEY `uk_platform_id_common_gb_channel_id` (`platform_id`,`common_gb_channel_id`)
@ -79,17 +79,12 @@ CREATE TABLE `wvp_common_platform_channel`
DEFAULT CHARSET = utf8mb4 DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci; COLLATE = utf8mb4_0900_ai_ci;
CREATE TABLE `wvp_common_platform_region`
( drop table wvp_platform_gb_stream;
`id` bigint unsigned NOT NULL AUTO_INCREMENT, drop table wvp_platform_gb_channel;
`platform_id` varchar(50) NOT NULL, drop table wvp_platform_catalog;
`region_id` varchar(50) NOT NULL, drop table wvp_platform_gb_channel;
PRIMARY KEY (`id`), drop table wvp_resources_tree;
UNIQUE KEY `id` (`id`),
UNIQUE KEY `uk_platform_region_id` (`platform_id`,`region_id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;

View File

@ -16,12 +16,12 @@ import java.util.Map;
@Repository @Repository
public interface CommonGbChannelMapper { public interface CommonGbChannelMapper {
@Select(value = "select * from wvp_common_gb_channel where common_gb_business_group_id = '#{commonGroupId}'") @Select(value = "select * from wvp_common_channel where common_gb_business_group_id = '#{commonGroupId}'")
List<CommonGbChannel> getChannels(String commonGroupId); List<CommonGbChannel> getChannels(String commonGroupId);
@Update(value = "<script>" + @Update(value = "<script>" +
"<foreach collection='channels' item='item' separator=';'>" + "<foreach collection='channels' item='item' separator=';'>" +
"UPDATE wvp_common_gb_channel SET " + "UPDATE wvp_common_channel SET " +
"update_time= #{ item.updateTime} " + "update_time= #{ item.updateTime} " +
" <if test='item.commonGbDeviceID != null' > ,common_gb_device_id= #{ item.commonGbDeviceID} </if>" + " <if test='item.commonGbDeviceID != null' > ,common_gb_device_id= #{ item.commonGbDeviceID} </if>" +
" <if test='item.commonGbName != null' > ,common_gb_name= #{ item.commonGbName} </if>" + " <if test='item.commonGbName != null' > ,common_gb_name= #{ item.commonGbName} </if>" +
@ -65,16 +65,16 @@ public interface CommonGbChannelMapper {
@Delete(value = "<script>" + @Delete(value = "<script>" +
"<foreach collection='channels' item='item' separator=';'>" + "<foreach collection='channels' item='item' separator=';'>" +
"delete from wvp_common_gb_channel WHERE common_gb_id=#{item.commonGbId}" + "delete from wvp_common_channel WHERE common_gb_id=#{item.commonGbId}" +
"</foreach>" + "</foreach>" +
"</script>") "</script>")
int removeChannelsForGroup(List<CommonGbChannel> channels); int removeChannelsForGroup(List<CommonGbChannel> channels);
@Select("select * from wvp_common_gb_channel where common_gb_device_id=#{channelId}") @Select("select * from wvp_common_channel where common_gb_device_id=#{channelId}")
CommonGbChannel queryByDeviceID(String channelId); CommonGbChannel queryByDeviceID(String channelId);
@Insert(value = "<script>" + @Insert(value = "<script>" +
"insert into wvp_common_gb_channel ( " + "insert into wvp_common_channel ( " +
"common_gb_device_id" + "common_gb_device_id" +
" <if test='common_gb_name != null' > ,common_gb_name </if>" + " <if test='common_gb_name != null' > ,common_gb_name </if>" +
" <if test='common_gb_manufacturer != null' > ,common_gb_manufacturer </if>" + " <if test='common_gb_manufacturer != null' > ,common_gb_manufacturer </if>" +
@ -152,11 +152,11 @@ public interface CommonGbChannelMapper {
"</script>") "</script>")
int add(CommonGbChannel channel); int add(CommonGbChannel channel);
@Delete("delete from wvp_common_gb_channel where common_gb_device_id = #{channelId}") @Delete("delete from wvp_common_channel where common_gb_device_id = #{channelId}")
int deleteByDeviceID(String channelId); int deleteByDeviceID(String channelId);
@Update(value = "<script>" + @Update(value = "<script>" +
"UPDATE wvp_common_gb_channel SET " + "UPDATE wvp_common_channel SET " +
"update_time= #{ updateTime} " + "update_time= #{ updateTime} " +
" <if test='commonGbDeviceID != null' > ,common_gb_device_id= #{ commonGbDeviceID} </if>" + " <if test='commonGbDeviceID != null' > ,common_gb_device_id= #{ commonGbDeviceID} </if>" +
" <if test='commonGbName != null' > ,common_gb_name= #{ commonGbName} </if>" + " <if test='commonGbName != null' > ,common_gb_name= #{ commonGbName} </if>" +
@ -197,14 +197,14 @@ public interface CommonGbChannelMapper {
int update(CommonGbChannel channel); int update(CommonGbChannel channel);
@Select("select count(1)\n" + @Select("select count(1)\n" +
"from wvp_common_gb_channel gc " + "from wvp_common_channel gc " +
"right join wvp_common_platform_channel pc " + "right join wvp_common_platform_channel pc " +
"on gc.common_gb_device_id = pc.common_gb_channel_id" + "on gc.common_gb_device_id = pc.common_gb_channel_id" +
"where gc.common_gb_device_id=#{channelId} and pc.platform_id=#{platformServerId}") "where gc.common_gb_device_id=#{channelId} and pc.platform_id=#{platformServerId}")
int checkChannelInPlatform(String channelId, String platformServerId); int checkChannelInPlatform(String channelId, String platformServerId);
@Insert(value = "<script>" + @Insert(value = "<script>" +
"insert into wvp_common_gb_channel ( " + "insert into wvp_common_channel ( " +
"common_gb_device_id, " + "common_gb_device_id, " +
"common_gb_name, " + "common_gb_name, " +
"common_gb_manufacturer, " + "common_gb_manufacturer, " +
@ -286,65 +286,65 @@ public interface CommonGbChannelMapper {
int addAll(List<CommonGbChannel> commonGbChannelList); int addAll(List<CommonGbChannel> commonGbChannelList);
@Delete("<script> "+ @Delete("<script> "+
"DELETE from wvp_common_gb_channel WHERE common_gb_device_id in (" + "DELETE from wvp_common_channel WHERE common_gb_device_id in (" +
"<foreach collection='clearChannels' item='item' separator=',' > #{item}</foreach>" + "<foreach collection='clearChannels' item='item' separator=',' > #{item}</foreach>" +
" )"+ " )"+
"</script>") "</script>")
int deleteByDeviceIDs(List<String> clearChannels); int deleteByDeviceIDs(List<String> clearChannels);
@Update("<script> "+ @Update("<script> "+
"UPDATE wvp_common_gb_channel SET commonGbStatus = true WHERE common_gb_id in" + "UPDATE wvp_common_channel SET commonGbStatus = true WHERE common_gb_id in" +
"<foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.commonGbChannelId}</foreach>" + "<foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.commonGbChannelId}</foreach>" +
"</script>") "</script>")
void channelsOnlineFromList(List<DeviceChannel> channelList); void channelsOnlineFromList(List<DeviceChannel> channelList);
@Update("<script> "+ @Update("<script> "+
"UPDATE wvp_common_gb_channel SET commonGbStatus = false WHERE common_gb_id in" + "UPDATE wvp_common_channel SET commonGbStatus = false WHERE common_gb_id in" +
"<foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.commonGbChannelId}</foreach>" + "<foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.commonGbChannelId}</foreach>" +
"</script>") "</script>")
void channelsOfflineFromList(List<DeviceChannel> channelList); void channelsOfflineFromList(List<DeviceChannel> channelList);
@Update("<script> "+ @Update("<script> "+
"UPDATE wvp_common_gb_channel SET common_gb_parent_id = null WHERE common_gb_id in" + "UPDATE wvp_common_channel SET common_gb_parent_id = null WHERE common_gb_id in" +
"<foreach collection='errorParentIdList' item='item' open='(' separator=',' close=')' > #{item}</foreach>" + "<foreach collection='errorParentIdList' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
"</script>") "</script>")
int clearParentIds(List<String> errorParentIdList); int clearParentIds(List<String> errorParentIdList);
@Update("<script> "+ @Update("<script> "+
"UPDATE wvp_common_gb_channel SET common_gb_civilCode = null WHERE common_gb_civilCode in" + "UPDATE wvp_common_channel SET common_gb_civilCode = null WHERE common_gb_civilCode in" +
"<foreach collection='errorCivilCodeList' item='item' open='(' separator=',' close=')' > #{item}</foreach>" + "<foreach collection='errorCivilCodeList' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
"</script>") "</script>")
void clearCivilCodes(List<String> errorCivilCodeList); void clearCivilCodes(List<String> errorCivilCodeList);
@Select("<script> "+ @Select("<script> "+
"SELECT * FROM wvp_common_gb_channel WHERE common_gb_device_id in" + "SELECT * FROM wvp_common_channel WHERE common_gb_device_id in" +
"<foreach collection='commonGbChannelList' item='item' open='(' separator=',' close=')' > #{item.commonGbDeviceID}</foreach>" + "<foreach collection='commonGbChannelList' item='item' open='(' separator=',' close=')' > #{item.commonGbDeviceID}</foreach>" +
"</script>") "</script>")
List<CommonGbChannel> queryInList(List<CommonGbChannel> commonGbChannelList); List<CommonGbChannel> queryInList(List<CommonGbChannel> commonGbChannelList);
@Update("<script> "+ @Update("<script> "+
"UPDATE wvp_common_gb_channel SET common_gb_civilCode = #{commonRegionDeviceIdForNew} WHERE common_gb_civilCode = #{commonRegionDeviceIdForOld}" + "UPDATE wvp_common_channel SET common_gb_civilCode = #{commonRegionDeviceIdForNew} WHERE common_gb_civilCode = #{commonRegionDeviceIdForOld}" +
"</script>") "</script>")
void updateChanelRegion(@Param("commonRegionDeviceIdForOld") String commonRegionDeviceIdForOld, void updateChanelRegion(@Param("commonRegionDeviceIdForOld") String commonRegionDeviceIdForOld,
@Param("commonRegionDeviceIdForNew") String commonRegionDeviceIdForNew); @Param("commonRegionDeviceIdForNew") String commonRegionDeviceIdForNew);
@Update("<script> "+ @Update("<script> "+
"UPDATE wvp_common_gb_channel SET common_gb_business_group_id = #{groupDeviceIdForNew} WHERE common_gb_business_group_id = #{groupDeviceIdForOld}" + "UPDATE wvp_common_channel SET common_gb_business_group_id = #{groupDeviceIdForNew} WHERE common_gb_business_group_id = #{groupDeviceIdForOld}" +
"</script>") "</script>")
void updateChanelGroup( void updateChanelGroup(
@Param("groupDeviceIdForOld") String groupDeviceIdForOld, @Param("groupDeviceIdForOld") String groupDeviceIdForOld,
@Param("groupDeviceIdForNew") String groupDeviceIdForNew); @Param("groupDeviceIdForNew") String groupDeviceIdForNew);
@Select("<script> "+ @Select("<script> "+
"select * from wvp_common_gb_channel where common_gb_civilCode = #{regionDeviceId}" + "select * from wvp_common_channel where common_gb_civilCode = #{regionDeviceId}" +
"<if test='query != null'> and ( common_gb_device_id LIKE concat('%',#{query},'%') or common_gb_name LIKE concat('%',#{query},'%') ) </if>" + "<if test='query != null'> and ( common_gb_device_id LIKE concat('%',#{query},'%') or common_gb_name LIKE concat('%',#{query},'%') ) </if>" +
"</script>") "</script>")
List<CommonGbChannel> getChannelsInRegion(@Param("regionDeviceId") String regionDeviceId, List<CommonGbChannel> getChannelsInRegion(@Param("regionDeviceId") String regionDeviceId,
@Param("query") String query); @Param("query") String query);
@Select("<script> "+ @Select("<script> "+
"select * from wvp_common_gb_channel where 1=1 " + "select * from wvp_common_channel where 1=1 " +
"<if test='groupDeviceId != null'> and common_gb_business_group_id = #{groupDeviceId} </if>" + "<if test='groupDeviceId != null'> and common_gb_business_group_id = #{groupDeviceId} </if>" +
"<if test='regionDeviceId != null'> and common_gb_civilCode = #{regionDeviceId} </if>" + "<if test='regionDeviceId != null'> and common_gb_civilCode = #{regionDeviceId} </if>" +
"<if test='inGroup != null &amp; inGroup'> and common_gb_business_group_id is not null </if>" + "<if test='inGroup != null &amp; inGroup'> and common_gb_business_group_id is not null </if>" +
@ -365,13 +365,13 @@ public interface CommonGbChannelMapper {
@Select("<script> "+ @Select("<script> "+
"select * from wvp_common_gb_channel where 1=1 " + "select * from wvp_common_channel where 1=1 " +
"<if test='query != null'> and ( common_gb_device_id LIKE concat('%',#{query},'%') or common_gb_name LIKE concat('%',#{query},'%') ) </if>" + "<if test='query != null'> and ( common_gb_device_id LIKE concat('%',#{query},'%') or common_gb_name LIKE concat('%',#{query},'%') ) </if>" +
"</script>") "</script>")
List<CommonGbChannel> query(@Param("query") String query); List<CommonGbChannel> query(@Param("query") String query);
@Select("<script> "+ @Select("<script> "+
"UPDATE wvp_common_gb_channel SET common_gb_business_group_id = null WHERE common_gb_business_group_id in" + "UPDATE wvp_common_channel SET common_gb_business_group_id = null WHERE common_gb_business_group_id in" +
"<foreach collection='groupList' item='item' open='(' separator=',' close=')' > #{item.commonGroupDeviceId}</foreach>" + "<foreach collection='groupList' item='item' open='(' separator=',' close=')' > #{item.commonGroupDeviceId}</foreach>" +
"</script>") "</script>")
void removeGroupInfo(@Param("groupList") List<Group> groupList); void removeGroupInfo(@Param("groupList") List<Group> groupList);
@ -379,7 +379,7 @@ public interface CommonGbChannelMapper {
@Update({"<script>" + @Update({"<script>" +
"<foreach collection='param.commonGbIds' item='item' separator=';'>" + "<foreach collection='param.commonGbIds' item='item' separator=';'>" +
" UPDATE" + " UPDATE" +
" wvp_common_gb_channel" + " wvp_common_channel" +
" SET common_gb_business_group_id = #{param.commonGbBusinessGroupID}" + " SET common_gb_business_group_id = #{param.commonGbBusinessGroupID}" +
" WHERE common_gb_id = #{item}" + " WHERE common_gb_id = #{item}" +
"</foreach>" + "</foreach>" +
@ -389,7 +389,7 @@ public interface CommonGbChannelMapper {
@Update({"<script>" + @Update({"<script>" +
"<foreach collection='commonGbIds' item='item' separator=';'>" + "<foreach collection='commonGbIds' item='item' separator=';'>" +
" UPDATE" + " UPDATE" +
" wvp_common_gb_channel" + " wvp_common_channel" +
" SET common_gb_business_group_id = null" + " SET common_gb_business_group_id = null" +
" WHERE common_gb_id = #{item}" + " WHERE common_gb_id = #{item}" +
"</foreach>" + "</foreach>" +
@ -398,14 +398,14 @@ public interface CommonGbChannelMapper {
@Update({"<script>" + @Update({"<script>" +
" UPDATE" + " UPDATE" +
" wvp_common_gb_channel" + " wvp_common_channel" +
" SET common_gb_business_group_id = null" + " SET common_gb_business_group_id = null" +
" WHERE common_gb_business_group_id = #{commonGbBusinessGroupID}" + " WHERE common_gb_business_group_id = #{commonGbBusinessGroupID}" +
"</script>"}) "</script>"})
void removeFromGroupByGroupId(@Param("commonGbBusinessGroupID") String commonGbBusinessGroupID); void removeFromGroupByGroupId(@Param("commonGbBusinessGroupID") String commonGbBusinessGroupID);
@Select("<script> "+ @Select("<script> "+
"UPDATE wvp_common_gb_channel SET common_gb_civilCode = null WHERE common_gb_civilCode in" + "UPDATE wvp_common_channel SET common_gb_civilCode = null WHERE common_gb_civilCode in" +
"<foreach collection='regionList' item='item' open='(' separator=',' close=')' > #{item.commonRegionDeviceId}</foreach>" + "<foreach collection='regionList' item='item' open='(' separator=',' close=')' > #{item.commonRegionDeviceId}</foreach>" +
"</script>") "</script>")
void removeRegionInfo(@Param("regionList") List<Region> regionList); void removeRegionInfo(@Param("regionList") List<Region> regionList);
@ -413,7 +413,7 @@ public interface CommonGbChannelMapper {
@Update({"<script>" + @Update({"<script>" +
"<foreach collection='commonGbIds' item='item' separator=';'>" + "<foreach collection='commonGbIds' item='item' separator=';'>" +
" UPDATE" + " UPDATE" +
" wvp_common_gb_channel" + " wvp_common_channel" +
" SET common_gb_civilCode = null" + " SET common_gb_civilCode = null" +
" WHERE common_gb_id = #{item}" + " WHERE common_gb_id = #{item}" +
"</foreach>" + "</foreach>" +
@ -422,7 +422,7 @@ public interface CommonGbChannelMapper {
@Update({"<script>" + @Update({"<script>" +
" UPDATE" + " UPDATE" +
" wvp_common_gb_channel" + " wvp_common_channel" +
" SET common_gb_civilCode = null" + " SET common_gb_civilCode = null" +
" WHERE common_gb_civilCode = #{commonGbCivilCode}" + " WHERE common_gb_civilCode = #{commonGbCivilCode}" +
"</script>"}) "</script>"})
@ -431,7 +431,7 @@ public interface CommonGbChannelMapper {
@Update({"<script>" + @Update({"<script>" +
"<foreach collection='param.commonGbIds' item='item' separator=';'>" + "<foreach collection='param.commonGbIds' item='item' separator=';'>" +
" UPDATE" + " UPDATE" +
" wvp_common_gb_channel" + " wvp_common_channel" +
" SET common_gb_civilCode = #{param.commonGbCivilCode}" + " SET common_gb_civilCode = #{param.commonGbCivilCode}" +
" WHERE common_gb_id = #{item}" + " WHERE common_gb_id = #{item}" +
"</foreach>" + "</foreach>" +
@ -439,7 +439,7 @@ public interface CommonGbChannelMapper {
void updateChannelToRegion(@Param("param") UpdateCommonChannelToRegion param); void updateChannelToRegion(@Param("param") UpdateCommonChannelToRegion param);
@Insert("<script> " + @Insert("<script> " +
"insert into wvp_common_gb_channel " + "insert into wvp_common_channel " +
"( common_gb_device_id, " + "( common_gb_device_id, " +
" common_gb_name, " + " common_gb_name, " +
" common_gb_manufacturer, " + " common_gb_manufacturer, " +
@ -522,7 +522,7 @@ public interface CommonGbChannelMapper {
@Update({"<script>" + @Update({"<script>" +
"<foreach collection='commonGbChannels' item='item' separator=';'>" + "<foreach collection='commonGbChannels' item='item' separator=';'>" +
" UPDATE" + " UPDATE" +
" wvp_common_gb_channel" + " wvp_common_channel" +
" SET update_time=#{item.updateTime}" + " SET update_time=#{item.updateTime}" +
" <if test='item.commonGbDeviceID != null' > ,common_gb_device_id = #{item.commonGbDeviceID} </if>" + " <if test='item.commonGbDeviceID != null' > ,common_gb_device_id = #{item.commonGbDeviceID} </if>" +
" <if test='item.commonGbName != null' > ,common_gb_name = #{item.commonGbName} </if>" + " <if test='item.commonGbName != null' > ,common_gb_name = #{item.commonGbName} </if>" +
@ -567,14 +567,14 @@ public interface CommonGbChannelMapper {
@Delete(value = {" <script>" + @Delete(value = {" <script>" +
"DELETE " + "DELETE " +
"from " + "from " +
"wvp_common_gb_channel " + "wvp_common_channel " +
"WHERE common_gb_id IN " + "WHERE common_gb_id IN " +
"<foreach collection='ids' item='item' open='(' separator=',' close=')' >#{item}</foreach>" + "<foreach collection='ids' item='item' open='(' separator=',' close=')' >#{item}</foreach>" +
" </script>"}) " </script>"})
int batchDelete(@Param("ids") List<Integer> ids); int batchDelete(@Param("ids") List<Integer> ids);
@MapKey("commonGbDeviceID") @MapKey("commonGbDeviceID")
@Select("select * from wvp_common_gb_channel") @Select("select * from wvp_common_channel")
Map<String, CommonGbChannel> queryAllChannelsForMap(); Map<String, CommonGbChannel> queryAllChannelsForMap();
} }

View File

@ -476,7 +476,7 @@ public interface DeviceChannelMapper {
@Update(" update wvp_device_channel wdc " + @Update(" update wvp_device_channel wdc " +
" set " + " set " +
" common_gb_channel_id=" + " common_gb_channel_id=" +
" (select wcgc.common_gb_id from wvp_common_gb_channel wcgc where wdc.channel_id = wcgc.common_gb_device_id) " + " (select wcgc.common_gb_id from wvp_common_channel wcgc where wdc.channel_id = wcgc.common_gb_device_id) " +
" where wdc.device_id = #{deviceId}") " where wdc.device_id = #{deviceId}")
int updateCommonChannelId(@Param("deviceId") String deviceId); int updateCommonChannelId(@Param("deviceId") String deviceId);