Commit 73c8147c by 向延琳

计算行驶时长

1 parent afedfe93
...@@ -19,6 +19,8 @@ import com.google.common.collect.Lists; ...@@ -19,6 +19,8 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DurationFormatUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StopWatch; import org.springframework.util.StopWatch;
...@@ -132,7 +134,30 @@ public class JourneyService { ...@@ -132,7 +134,30 @@ public class JourneyService {
} }
List<JourneyDetailExport> journeyDetailExportList = vehicleMapper.findJourneyDetailList(journeyDetailSearch); List<JourneyDetailExport> journeyDetailExportList = vehicleMapper.findJourneyDetailList(journeyDetailSearch);
log.info("journeyDetailExportList size()大小===" + journeyDetailExportList.size()); log.info("journeyDetailExportList size()大小===" + journeyDetailExportList.size());
return journeyDetailExportList; return journeyDetailExportList.stream()
.filter(e -> StringUtils.isNotEmpty(e.getJourneyStartTime()) && StringUtils.isNotEmpty(e.getJourneyEndTime()))
.peek(e -> e.setDurationStr(DateUtil.getDistanceTime(e.getJourneyStartTime(), e.getJourneyEndTime())))
.collect(Collectors.toList());
}
/**
* 时间戳格式化为时,分,秒
*
* @param duration 时间戳差
* @return
*/
protected String normalFormatDuration(long duration) {
if (duration == 0L) {
return "0 秒";
}
//小于0不合法
if (duration < 0L) {
return "";
}
if (duration < org.apache.commons.lang.time.DateUtils.MILLIS_IN_HOUR) {
return DurationFormatUtils.formatDuration(duration, "mm 分 ss 秒");
}
return DurationFormatUtils.formatDuration(duration, "HH 时 mm 分 ss 秒");
} }
public Integer countJourneyDetailList(JourneyDetailSearch journeyDetailSearch) { public Integer countJourneyDetailList(JourneyDetailSearch journeyDetailSearch) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!