From 1421b4743ca8c6f32984bfd9e213f8018035e7ae Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期五, 31 三月 2023 08:59:03 +0800 Subject: [PATCH] 修复SQL错误 #802 --- src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 48 insertions(+), 1 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java index 99ad3de..336082f 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java @@ -9,6 +9,8 @@ import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; import com.genersoft.iot.vmp.storager.dao.DeviceMapper; import com.genersoft.iot.vmp.utils.DateUtil; +import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; +import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -17,6 +19,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; /** * @author lin @@ -97,7 +100,7 @@ HashMap<String, DeviceChannel> channelsInStore = new HashMap<>(); Device device = deviceMapper.getDeviceByDeviceId(deviceId); if (channels != null && channels.size() > 0) { - List<DeviceChannel> channelList = channelMapper.queryChannels(deviceId, null, null, null, null); + List<DeviceChannel> channelList = channelMapper.queryChannels(deviceId, null, null, null, null,null); if (channelList.size() == 0) { for (DeviceChannel channel : channels) { channel.setDeviceId(deviceId); @@ -162,4 +165,48 @@ } return addChannels.size() + updateChannels.size(); } + + @Override + public ResourceBaceInfo getOverview() { + return channelMapper.getOverview(); + } + + + @Override + public List<ChannelReduce> queryAllChannelList(String platformId) { + return channelMapper.queryChannelListInAll(null, null, null, platformId, null); + } + + @Override + public boolean updateAllGps(Device device) { + List<DeviceChannel> deviceChannels = channelMapper.getChannelsWithoutTransform(device.getDeviceId()); + List<DeviceChannel> result = new CopyOnWriteArrayList<>(); + if (deviceChannels.size() == 0) { + return true; + } + String now = DateUtil.getNow(); + deviceChannels.parallelStream().forEach(deviceChannel -> { + deviceChannel.setUpdateTime(now); + result.add(updateGps(deviceChannel, device)); + }); + int limitCount = 300; + if (result.size() > limitCount) { + for (int i = 0; i < result.size(); i += limitCount) { + int toIndex = i + limitCount; + if (i + limitCount > result.size()) { + toIndex = result.size(); + } + channelMapper.batchUpdate(result.subList(i, toIndex)); + } + }else { + channelMapper.batchUpdate(result); + } + + return true; + } + + @Override + public List<Device> getDeviceByChannelId(String channelId) { + return channelMapper.getDeviceByChannelId(channelId); + } } -- Gitblit v1.8.0