Commit 14d554987685d7a8cfef0b95edca6c7d744c6a53

Authored by 648540858
2 parents 2673fbb0 12c4128e

Merge branch 'wvp-28181-2.0' into main-dev

src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
@@ -124,6 +124,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { @@ -124,6 +124,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
124 124
125 List<DeviceChannel> updateChannels = new ArrayList<>(); 125 List<DeviceChannel> updateChannels = new ArrayList<>();
126 List<DeviceChannel> addChannels = new ArrayList<>(); 126 List<DeviceChannel> addChannels = new ArrayList<>();
  127 + List<DeviceChannel> deleteChannels = new ArrayList<>();
127 StringBuilder stringBuilder = new StringBuilder(); 128 StringBuilder stringBuilder = new StringBuilder();
128 Map<String, Integer> subContMap = new HashMap<>(); 129 Map<String, Integer> subContMap = new HashMap<>();
129 130
@@ -154,6 +155,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { @@ -154,6 +155,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
154 deviceChannel.setUpdateTime(DateUtil.getNow()); 155 deviceChannel.setUpdateTime(DateUtil.getNow());
155 addChannels.add(deviceChannel); 156 addChannels.add(deviceChannel);
156 } 157 }
  158 + allChannelMap.remove(deviceChannel.getChannelId());
157 channels.add(deviceChannel); 159 channels.add(deviceChannel);
158 if (!ObjectUtils.isEmpty(deviceChannel.getParentId())) { 160 if (!ObjectUtils.isEmpty(deviceChannel.getParentId())) {
159 if (subContMap.get(deviceChannel.getParentId()) == null) { 161 if (subContMap.get(deviceChannel.getParentId()) == null) {
@@ -164,6 +166,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { @@ -164,6 +166,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
164 } 166 }
165 } 167 }
166 } 168 }
  169 + deleteChannels.addAll(allChannelMap.values());
167 if (!channels.isEmpty()) { 170 if (!channels.isEmpty()) {
168 for (DeviceChannel channel : channels) { 171 for (DeviceChannel channel : channels) {
169 if (subContMap.get(channel.getChannelId()) != null){ 172 if (subContMap.get(channel.getChannelId()) != null){
@@ -186,7 +189,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { @@ -186,7 +189,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
186 try { 189 try {
187 int limitCount = 50; 190 int limitCount = 50;
188 boolean result = false; 191 boolean result = false;
189 - if (!result && addChannels.size() > 0) { 192 + if (!result && !addChannels.isEmpty()) {
190 if (addChannels.size() > limitCount) { 193 if (addChannels.size() > limitCount) {
191 for (int i = 0; i < addChannels.size(); i += limitCount) { 194 for (int i = 0; i < addChannels.size(); i += limitCount) {
192 int toIndex = i + limitCount; 195 int toIndex = i + limitCount;
@@ -199,7 +202,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { @@ -199,7 +202,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
199 result = result || deviceChannelMapper.batchAdd(addChannels) < 0; 202 result = result || deviceChannelMapper.batchAdd(addChannels) < 0;
200 } 203 }
201 } 204 }
202 - if (!result && updateChannels.size() > 0) { 205 + if (!result && !updateChannels.isEmpty()) {
203 if (updateChannels.size() > limitCount) { 206 if (updateChannels.size() > limitCount) {
204 for (int i = 0; i < updateChannels.size(); i += limitCount) { 207 for (int i = 0; i < updateChannels.size(); i += limitCount) {
205 int toIndex = i + limitCount; 208 int toIndex = i + limitCount;
@@ -212,6 +215,20 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { @@ -212,6 +215,20 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
212 result = result || deviceChannelMapper.batchUpdate(updateChannels) < 0; 215 result = result || deviceChannelMapper.batchUpdate(updateChannels) < 0;
213 } 216 }
214 } 217 }
  218 + if (!result && !deleteChannels.isEmpty()) {
  219 + System.out.println("删除: " + deleteChannels.size());
  220 + if (deleteChannels.size() > limitCount) {
  221 + for (int i = 0; i < deleteChannels.size(); i += limitCount) {
  222 + int toIndex = i + limitCount;
  223 + if (i + limitCount > deleteChannels.size()) {
  224 + toIndex = deleteChannels.size();
  225 + }
  226 + result = result || deviceChannelMapper.batchDel(deleteChannels.subList(i, toIndex)) < 0;
  227 + }
  228 + }else {
  229 + result = result || deviceChannelMapper.batchDel(deleteChannels) < 0;
  230 + }
  231 + }
215 232
216 if (result) { 233 if (result) {
217 //事务回滚 234 //事务回滚