Commit 98bdb8b6 by 杨林龙

优化Gps基站落库数据

1 parent bc15f57b
......@@ -50,6 +50,9 @@ public class TransitHandleService {
public void handleGpsAndBsData(DeviceLocationDto deviceLocationDto) {
DeviceLocationDto deviceLocationCache = (DeviceLocationDto) redisUtils.get(setKey(deviceLocationDto.getSn()));
if (ObjectUtil.isNull(deviceLocationCache)) {
// 缓存中没有 就是第一次插入数据 设置创建时间同步更新时间
deviceLocationDto.setCreatedTime(new Date());
deviceLocationDto.setUpdatedTime(new Date());
redisUtils.set(setKey(deviceLocationDto.getSn()), deviceLocationDto);
deviceLocationMap.put(deviceLocationDto.getSn(), deviceLocationDto);
} else {
......@@ -72,6 +75,8 @@ public class TransitHandleService {
// 判断是否有数据更新 有数据更新重新设置回缓存
if (flag) {
// 同步更新时间
deviceLocationCache.setUpdatedTime(new Date());
redisUtils.set(setKey(deviceLocationDto.getSn()), deviceLocationCache);
deviceLocationMap.put(deviceLocationDto.getSn(), deviceLocationCache);
}
......
......@@ -36,6 +36,8 @@ public class RemoteDeviceLocationServiceTest {
deviceLocationDto.setSn("123456789");
deviceLocationDto.setLastGpsTime(new Date());
deviceLocationDto.setLastBsTime(new Date());
deviceLocationDto.setCreatedTime(new Date());
deviceLocationDto.setUpdatedTime(new Date());
deviceLocationDtos.add(deviceLocationDto);
remoteDeviceLocationService.saveOrUpdateDeviceLocationData(deviceLocationDtos);
System.out.println("更新成功===");
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!