Commit 124d83fc0c0db5b319b2ae2bdc623890556b932f

Authored by xu-bin-bin
Committed by GitHub
2 parents 4084080a 78f628dd

Merge branch '648540858:wvp-28181-2.0' into wvp-28181-2.0

src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java
... ... @@ -162,7 +162,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
162 162 return 0;
163 163 }
164 164 if (ObjectUtils.isEmpty(catalogId)) {
165   - catalogId = platform.getDeviceGBId();
  165 + catalogId = null;
166 166 }
167 167  
168 168 if ((result = platformChannelMapper.delChannelForGBByCatalogId(platformId, catalogId)) > 0) {
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java
... ... @@ -31,8 +31,8 @@ public interface PlatformCatalogMapper {
31 31  
32 32 @Update(value = {" <script>" +
33 33 "UPDATE wvp_platform_catalog " +
34   - "SET name=#{name}" +
35   - "WHERE id=#{id} and platform_id=#{platformId}"+
  34 + "SET name=#{platformCatalog.name}" +
  35 + "WHERE id=#{platformCatalog.id} and platform_id=#{platformCatalog.platformId}"+
36 36 "</script>"})
37 37 int update(@Param("platformCatalog") PlatformCatalog platformCatalog);
38 38  
... ... @@ -51,4 +51,16 @@ public interface PlatformCatalogMapper {
51 51 " from wvp_platform_catalog pc " +
52 52 " WHERE pc.id=#{id} and pc.platform_id=#{platformId}")
53 53 PlatformCatalog selectByPlatFormAndCatalogId(@Param("platformId") String platformId, @Param("id") String id);
  54 +
  55 +
  56 + @Delete("<script> "+
  57 + "DELETE from wvp_platform_catalog where platform_id=#{platformId} and id in " +
  58 + "<foreach collection='ids' item='item' open='(' separator=',' close=')'>" +
  59 + "#{item} " +
  60 + "</foreach>" +
  61 + "</script>")
  62 + int deleteAll(String platformId, List<String> ids);
  63 +
  64 + @Select("SELECT id from wvp_platform_catalog WHERE platform_id=#{platformId} and parent_id = #{id}")
  65 + List<String> queryCatalogFromParent(@Param("id") String id, @Param("platformId") String platformId);
54 66 }
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java
... ... @@ -105,7 +105,8 @@ public interface PlatformChannelMapper {
105 105 void delByPlatformId(String serverGBId);
106 106  
107 107 @Delete("<script> " +
108   - "DELETE from wvp_platform_gb_channel WHERE platform_id=#{platformId} and catalog_id=#{catalogId}" +
  108 + "DELETE from wvp_platform_gb_channel WHERE platform_id=#{platformId} " +
  109 + " <if test=\"catalogId != null\" > and catalog_id=#{catalogId}</if>" +
109 110 "</script>")
110 111 int delChannelForGBByCatalogId(@Param("platformId") String platformId, @Param("catalogId") String catalogId);
111 112  
... ...
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
... ... @@ -74,6 +74,9 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
74 74 private PlatformChannelMapper platformChannelMapper;
75 75  
76 76 @Autowired
  77 + private PlatformCatalogMapper platformCatalogMapper;
  78 +
  79 + @Autowired
77 80 private StreamProxyMapper streamProxyMapper;
78 81  
79 82 @Autowired
... ... @@ -166,7 +169,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
166 169 }
167 170 }
168 171 }
169   - if (channels.size() > 0) {
  172 + if (!channels.isEmpty()) {
170 173 for (DeviceChannel channel : channels) {
171 174 if (subContMap.get(channel.getChannelId()) != null){
172 175 Integer count = subContMap.get(channel.getChannelId());
... ... @@ -187,19 +190,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
187 190 }
188 191 try {
189 192 int limitCount = 50;
190   - int cleanChannelsResult = 0;
191   - if (channels.size() > limitCount) {
192   - for (int i = 0; i < channels.size(); i += limitCount) {
193   - int toIndex = i + limitCount;
194   - if (i + limitCount > channels.size()) {
195   - toIndex = channels.size();
196   - }
197   - cleanChannelsResult += this.deviceChannelMapper.cleanChannelsNotInList(deviceId, channels.subList(i, toIndex));
198   - }
199   - } else {
200   - cleanChannelsResult = this.deviceChannelMapper.cleanChannelsNotInList(deviceId, channels);
201   - }
202   - boolean result = cleanChannelsResult < 0;
  193 + boolean result = false;
203 194 if (!result && addChannels.size() > 0) {
204 195 if (addChannels.size() > limitCount) {
205 196 for (int i = 0; i < addChannels.size(); i += limitCount) {
... ... @@ -910,9 +901,43 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
910 901 eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL);
911 902 }
912 903 int delChannelresult = platformChannelMapper.delByCatalogId(platformId, id);
  904 + // 查看是否存在子目录,如果存在一并删除
  905 + List<String> allChildCatalog = getAllChildCatalog(id, platformId);
  906 + if (!allChildCatalog.isEmpty()) {
  907 + int limitCount = 50;
  908 + if (allChildCatalog.size() > limitCount) {
  909 + for (int i = 0; i < allChildCatalog.size(); i += limitCount) {
  910 + int toIndex = i + limitCount;
  911 + if (i + limitCount > allChildCatalog.size()) {
  912 + toIndex = allChildCatalog.size();
  913 + }
  914 + delChannelresult += platformCatalogMapper.deleteAll(platformId, allChildCatalog.subList(i, toIndex));
  915 + }
  916 + }else {
  917 + delChannelresult += platformCatalogMapper.deleteAll(platformId, allChildCatalog);
  918 + }
  919 + }
913 920 return delresult + delChannelresult + delStreamresult;
914 921 }
915 922  
  923 + private List<String> getAllChildCatalog(String id, String platformId) {
  924 + List<String> catalogList = platformCatalogMapper.queryCatalogFromParent(id, platformId);
  925 + List<String> catalogListChild = new ArrayList<>();
  926 + if (catalogList != null && !catalogList.isEmpty()) {
  927 + for (String childId : catalogList) {
  928 + List<String> allChildCatalog = getAllChildCatalog(childId, platformId);
  929 + if (allChildCatalog != null && !allChildCatalog.isEmpty()) {
  930 + catalogListChild.addAll(allChildCatalog);
  931 + }
  932 +
  933 + }
  934 + }
  935 + if (!catalogListChild.isEmpty()) {
  936 + catalogList.addAll(catalogListChild);
  937 + }
  938 + return catalogList;
  939 + }
  940 +
916 941  
917 942 @Override
918 943 public int updateCatalog(PlatformCatalog platformCatalog) {
... ...