Commit 5c7e8740 by levphon

修复bug:代码优化

1 parent 39b69a48
......@@ -122,11 +122,16 @@ public class OpereportService extends AbstractCommonService {
List<ReportDeviceDTO> list = vehicleDeviceMapper.searchReportDevice(search);
List<String> snList = list.stream().map(ReportDeviceDTO::getSns).collect(Collectors.toList());
//过滤有上点时间的sn(如果大数据有位置点数据,t_device_location则看消费是否有问题)
List<String> snList = list.stream().filter(rdd -> StringUtils.isNotEmpty(rdd.getGpsTime())).map(ReportDeviceDTO::getSns).collect(Collectors.toList());
Map<String, GpsBsData> gpsBsDataMap = remoteGpsBsService.getLastGpsBsBatchBySns(snList);
list.forEach(rdd -> {
if (StringUtils.isNullOrEmpty(rdd.getGpsTime())) {
rdd.setGpsTime("--");
return;
}
GpsBsData gpsBsData = gpsBsDataMap.get(rdd.getSns());
if (gpsBsData != null) {
long gpsDateLong = 0;
......@@ -146,7 +151,7 @@ public class OpereportService extends AbstractCommonService {
gpsDateLong = DateUtils.parse(gpsBsData.getGpsLocation().getDateTime()).getTime();
}
long trackTime = Math.max(gpsDateLong, bsDateLong);
if (trackTime != 0) {
if (trackTime > 0) {
rdd.setGpsTime(DateUtils.formatNormal(new Date(trackTime)));
}
}
......@@ -187,7 +192,7 @@ public class OpereportService extends AbstractCommonService {
return;
}
List<String> snList = dataList.stream().map(ReportDeviceExport::getSns).collect(Collectors.toList());
List<String> snList = dataList.stream().filter(rdd -> StringUtils.isNotEmpty(rdd.getGpsTime())).map(ReportDeviceExport::getSns).collect(Collectors.toList());
//切分成一个list去请求
List<List<String>> partList = Lists.partition(snList, 1000);
......@@ -219,6 +224,10 @@ public class OpereportService extends AbstractCommonService {
}
dataList.forEach(rdd -> {
if (StringUtils.isNullOrEmpty(rdd.getGpsTime())) {
rdd.setGpsTime("--");
return;
}
GpsBsData gpsBsData = gpsBsDataMap.get(rdd.getSns());
if (gpsBsData != null) {
long gpsDateLong = 0;
......@@ -236,9 +245,8 @@ public class OpereportService extends AbstractCommonService {
gpsDateLong = DateUtils.parse(gpsBsData.getGpsLocation().getDateTime()).getTime();
}
long trackTime = Math.max(gpsDateLong, bsDateLong);
if (trackTime != 0) {
if (trackTime > 0) {
rdd.setGpsTime(DateUtils.formatNormal(new Date(trackTime)));
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!