优化notify消息中目录的处理

This commit is contained in:
648540858
2024-04-24 20:33:52 +08:00
parent 44aa37ad6e
commit 2113e8cf27
4 changed files with 165 additions and 203 deletions

View File

@@ -275,15 +275,23 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
}
@Override
public void batchUpdateChannel(List<DeviceChannel> channels) {
public synchronized void batchUpdateChannel(List<DeviceChannel> channels) {
String now = DateUtil.getNow();
for (DeviceChannel channel : channels) {
channel.setUpdateTime(now);
}
channelMapper.batchUpdate(channels);
for (DeviceChannel channel : channels) {
if (channel.getParentId() != null) {
channelMapper.updateChannelSubCount(channel.getDeviceId(), channel.getParentId());
int limitCount = 1000;
if (!channels.isEmpty()) {
if (channels.size() > limitCount) {
for (int i = 0; i < channels.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > channels.size()) {
toIndex = channels.size();
}
channelMapper.batchUpdate(channels.subList(i, toIndex));
}
}else {
channelMapper.batchUpdate(channels);
}
}
}