Commit 3c9199e6 by 杨林龙

1.9.0 仲利车辆列表增加最后定位时间字段

1 parent d4ec6da1
......@@ -1219,6 +1219,15 @@ public class VehicleService extends AbstractCommonService {
}
}
// 查询设备最后定位点数据
List<String> snList = vehicleInfoList.stream().map(VehicleInfoExport::getSn).filter(Objects::nonNull)
.collect(Collectors.toList());
Map<String, DeviceLocation> deviceLocationMap = Maps.newHashMap();
List<DeviceLocation> deviceLocationList = deviceLocationMapper.findLocationListBySnList(snList);
if (CollectionUtils.isNotEmpty(deviceLocationList)) {
deviceLocationMap = deviceLocationList.stream().collect(Collectors.toMap(DeviceLocation::getSn, Function.identity(), (k1, k2) -> k2));
}
for (VehicleInfoExport vehicleInfo : vehicleInfoList) {
vehicleInfo.setCreator(vehicleInfo.getBelongLevels());
//设置车辆类型
......@@ -1256,12 +1265,36 @@ public class VehicleService extends AbstractCommonService {
}
// 设置调频数据
setAdjustFreq(vehicleInfo, localRelUserMap, wechatUserMap);
// 设置最后定位时间
setDeviceLocation(vehicleInfo, deviceLocationMap);
}
return vehicleInfoList;
}
/**
* 设置设备定位数据
*
* @param vehicleInfo 车辆设备数据
* @param deviceLocationMap 设备定位数据 map
*/
private void setDeviceLocation(VehicleInfoExport vehicleInfo, Map<String, DeviceLocation> deviceLocationMap) {
DeviceLocation deviceLocation = deviceLocationMap.get(vehicleInfo.getSn());
if (Objects.isNull(deviceLocation)) {
return;
}
if (Objects.isNull(deviceLocation.getLastGpsTime()) && Objects.nonNull(deviceLocation.getLastBsTime())) {
vehicleInfo.setLastPoiTime(DateUtil.formatDateTime(deviceLocation.getLastBsTime()));
} else if (Objects.nonNull(deviceLocation.getLastGpsTime()) && Objects.isNull(deviceLocation.getLastBsTime())) {
vehicleInfo.setLastPoiTime(DateUtil.formatDateTime(deviceLocation.getLastGpsTime()));
} else if (Objects.nonNull(deviceLocation.getLastGpsTime()) && Objects.nonNull(deviceLocation.getLastBsTime())) {
vehicleInfo.setLastPoiTime(DateUtil.formatDateTime(new Date(Math.max(deviceLocation.getLastGpsTime().getTime(), deviceLocation.getLastBsTime().getTime()))));
} else {
vehicleInfo.setLastPoiTime(null);
}
}
/**
* 设置调频信息
*
* @param model
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!