Merge branch 'wvp-28181-2.0' into wvp-28181-record
commit
4d62f77025
|
@ -129,6 +129,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
|
||||||
|
|
||||||
List<DeviceChannel> updateChannels = new ArrayList<>();
|
List<DeviceChannel> updateChannels = new ArrayList<>();
|
||||||
List<DeviceChannel> addChannels = new ArrayList<>();
|
List<DeviceChannel> addChannels = new ArrayList<>();
|
||||||
|
List<DeviceChannel> deleteChannels = new ArrayList<>();
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
Map<String, Integer> subContMap = new HashMap<>();
|
Map<String, Integer> subContMap = new HashMap<>();
|
||||||
|
|
||||||
|
@ -159,6 +160,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
|
||||||
deviceChannel.setUpdateTime(DateUtil.getNow());
|
deviceChannel.setUpdateTime(DateUtil.getNow());
|
||||||
addChannels.add(deviceChannel);
|
addChannels.add(deviceChannel);
|
||||||
}
|
}
|
||||||
|
allChannelMap.remove(deviceChannel.getChannelId());
|
||||||
channels.add(deviceChannel);
|
channels.add(deviceChannel);
|
||||||
if (!ObjectUtils.isEmpty(deviceChannel.getParentId())) {
|
if (!ObjectUtils.isEmpty(deviceChannel.getParentId())) {
|
||||||
if (subContMap.get(deviceChannel.getParentId()) == null) {
|
if (subContMap.get(deviceChannel.getParentId()) == null) {
|
||||||
|
@ -169,6 +171,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
deleteChannels.addAll(allChannelMap.values());
|
||||||
if (!channels.isEmpty()) {
|
if (!channels.isEmpty()) {
|
||||||
for (DeviceChannel channel : channels) {
|
for (DeviceChannel channel : channels) {
|
||||||
if (subContMap.get(channel.getChannelId()) != null){
|
if (subContMap.get(channel.getChannelId()) != null){
|
||||||
|
@ -191,7 +194,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
|
||||||
try {
|
try {
|
||||||
int limitCount = 50;
|
int limitCount = 50;
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
if (!result && addChannels.size() > 0) {
|
if (!result && !addChannels.isEmpty()) {
|
||||||
if (addChannels.size() > limitCount) {
|
if (addChannels.size() > limitCount) {
|
||||||
for (int i = 0; i < addChannels.size(); i += limitCount) {
|
for (int i = 0; i < addChannels.size(); i += limitCount) {
|
||||||
int toIndex = i + limitCount;
|
int toIndex = i + limitCount;
|
||||||
|
@ -204,7 +207,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
|
||||||
result = result || deviceChannelMapper.batchAdd(addChannels) < 0;
|
result = result || deviceChannelMapper.batchAdd(addChannels) < 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!result && updateChannels.size() > 0) {
|
if (!result && !updateChannels.isEmpty()) {
|
||||||
if (updateChannels.size() > limitCount) {
|
if (updateChannels.size() > limitCount) {
|
||||||
for (int i = 0; i < updateChannels.size(); i += limitCount) {
|
for (int i = 0; i < updateChannels.size(); i += limitCount) {
|
||||||
int toIndex = i + limitCount;
|
int toIndex = i + limitCount;
|
||||||
|
@ -217,6 +220,20 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
|
||||||
result = result || deviceChannelMapper.batchUpdate(updateChannels) < 0;
|
result = result || deviceChannelMapper.batchUpdate(updateChannels) < 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!result && !deleteChannels.isEmpty()) {
|
||||||
|
System.out.println("删除: " + deleteChannels.size());
|
||||||
|
if (deleteChannels.size() > limitCount) {
|
||||||
|
for (int i = 0; i < deleteChannels.size(); i += limitCount) {
|
||||||
|
int toIndex = i + limitCount;
|
||||||
|
if (i + limitCount > deleteChannels.size()) {
|
||||||
|
toIndex = deleteChannels.size();
|
||||||
|
}
|
||||||
|
result = result || deviceChannelMapper.batchDel(deleteChannels.subList(i, toIndex)) < 0;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
result = result || deviceChannelMapper.batchDel(deleteChannels) < 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
//事务回滚
|
//事务回滚
|
||||||
|
|
Loading…
Reference in New Issue