|  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.HashMap; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.concurrent.CopyOnWriteArrayList; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @author lin | 
|---|
|  |  |  | 
|---|
|  |  |  | if (device == null) { | 
|---|
|  |  |  | device = deviceMapper.getDeviceByDeviceId(deviceChannel.getDeviceId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if ("WGS84".equals(device.getGeoCoordSys())) { | 
|---|
|  |  |  | deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude()); | 
|---|
|  |  |  | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|