|
@ -8,6 +8,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
|
import com.google.gson.Gson; |
|
|
|
|
|
import com.google.gson.reflect.TypeToken; |
|
|
import com.jiagutech.ams.constant.UserConstants; |
|
|
import com.jiagutech.ams.constant.UserConstants; |
|
|
import com.jiagutech.ams.mapper.DeviceMapper; |
|
|
import com.jiagutech.ams.mapper.DeviceMapper; |
|
|
import com.jiagutech.ams.model.LoginUser; |
|
|
import com.jiagutech.ams.model.LoginUser; |
|
@ -22,9 +24,11 @@ import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.data.redis.core.StringRedisTemplate; |
|
|
import org.springframework.data.redis.core.StringRedisTemplate; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Type; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
import java.util.function.Consumer; |
|
|
import java.util.function.Consumer; |
|
|
import java.util.function.Predicate; |
|
|
import java.util.function.Predicate; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @ClassName DeviceServiceImpl |
|
|
* @ClassName DeviceServiceImpl |
|
@ -50,9 +54,15 @@ public class DeviceServiceImpl implements DeviceService { |
|
|
deviceInfos.add(deviceInfo1); |
|
|
deviceInfos.add(deviceInfo1); |
|
|
if (CollectionUtils.isNotEmpty(keys)) { |
|
|
if (CollectionUtils.isNotEmpty(keys)) { |
|
|
List<String> values = stringRedisTemplate.opsForValue().multiGet(keys); |
|
|
List<String> values = stringRedisTemplate.opsForValue().multiGet(keys); |
|
|
List<TrackDataJG> trackDataJGS = JSON.parseArray(JSON.toJSONString(values), TrackDataJG.class); |
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(values)) { |
|
|
|
|
|
return deviceInfos; |
|
|
|
|
|
} |
|
|
|
|
|
List<TrackDataJG> trackDataJGS = values.stream().map(s -> JSON.parseObject(s, TrackDataJG.class)).collect(Collectors.toList()); |
|
|
Predicate<TrackDataJG> predicate = t -> t.getLat() <= maxLat && t.getLat() >= minLat |
|
|
Predicate<TrackDataJG> predicate = t -> t.getLat() <= maxLat && t.getLat() >= minLat |
|
|
&& ((t.getLng() >= -180 && t.getLng() <= maxLng) || (t.getLng() >= minLng && t.getLng() <= 180)); |
|
|
&& ((t.getLng() >= -180 && t.getLng() <= maxLng) || (t.getLng() >= minLng && t.getLng() <= 180)); |
|
|
|
|
|
if (maxLat==0 && minLat==0 && maxLng==0 && minLng==0){ |
|
|
|
|
|
predicate = t-> true; |
|
|
|
|
|
} |
|
|
Consumer<TrackDataJG> consumer = t -> deviceInfos.add(new DeviceInfo().setBoxNum(t.getDroneId()).setLng(t.getLng()).setLat(t.getLat())); |
|
|
Consumer<TrackDataJG> consumer = t -> deviceInfos.add(new DeviceInfo().setBoxNum(t.getDroneId()).setLng(t.getLng()).setLat(t.getLat())); |
|
|
trackDataJGS.stream().filter(predicate).forEach(consumer); |
|
|
trackDataJGS.stream().filter(predicate).forEach(consumer); |
|
|
LoginUser loginUser = StpUtil.getSession().get(UserConstants.SYS_SESSION, new LoginUser()); |
|
|
LoginUser loginUser = StpUtil.getSession().get(UserConstants.SYS_SESSION, new LoginUser()); |
|
@ -81,7 +91,7 @@ public class DeviceServiceImpl implements DeviceService { |
|
|
Page<DeviceDTO> page = new Page(pageRequest.getPageNum(), pageRequest.getPageSize()); |
|
|
Page<DeviceDTO> page = new Page(pageRequest.getPageNum(), pageRequest.getPageSize()); |
|
|
QueryWrapper<DeviceDTO> queryWrapper = Wrappers.query(); |
|
|
QueryWrapper<DeviceDTO> queryWrapper = Wrappers.query(); |
|
|
LoginUser loginUser = StpUtil.getSession().get(UserConstants.SYS_SESSION, new LoginUser()); |
|
|
LoginUser loginUser = StpUtil.getSession().get(UserConstants.SYS_SESSION, new LoginUser()); |
|
|
queryWrapper.eq("dept_id",loginUser.getDept().getId()); |
|
|
|
|
|
|
|
|
queryWrapper.eq("dept_id", loginUser.getDept().getId()); |
|
|
Page<DeviceDTO> result = deviceMapper.selectPage(page, queryWrapper); |
|
|
Page<DeviceDTO> result = deviceMapper.selectPage(page, queryWrapper); |
|
|
return PageResult.of((int) result.getTotal(), (int) pageRequest.getPageSize(), (int) result.getCurrent(), result.getRecords()); |
|
|
return PageResult.of((int) result.getTotal(), (int) pageRequest.getPageSize(), (int) result.getCurrent(), result.getRecords()); |
|
|
} |
|
|
} |
|
|