Commit 1faf1d59 authored by duanruiming's avatar duanruiming

[add] 交通状态分布折线图优化

parent dc3384a5
...@@ -31,6 +31,7 @@ import org.joda.time.format.DateTimeFormat; ...@@ -31,6 +31,7 @@ import org.joda.time.format.DateTimeFormat;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.text.ParseException;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
...@@ -313,7 +314,13 @@ public class EventServiceImpl implements EventService { ...@@ -313,7 +314,13 @@ public class EventServiceImpl implements EventService {
eventInfoTrafficStatusPOS.add(eventInfoTrafficStatusPO); eventInfoTrafficStatusPOS.add(eventInfoTrafficStatusPO);
} }
} }
List<EventInfoTrafficStatusPO> trafficStatusPOS = eventInfoTrafficStatusPOS.stream().sorted(Comparator.comparing(time -> Integer.valueOf(time.getTimeAxisStart().split(":")[0]))).collect(Collectors.toList()); List<EventInfoTrafficStatusPO> trafficStatusPOS = eventInfoTrafficStatusPOS.stream().sorted(Comparator.comparing(time -> {
try {
return DateUtil.parse(time.getTimeAxisStart(),LocalDateTimeUtil.HOURMINITFORMATTER);
} catch (ParseException e) {
throw new RuntimeException(e);
}
})).collect(Collectors.toList());
List<Integer> durationList = trafficStatusPOS.stream().map(x -> x.getDuration()).collect(Collectors.toList()); List<Integer> durationList = trafficStatusPOS.stream().map(x -> x.getDuration()).collect(Collectors.toList());
List<Integer> countList = trafficStatusPOS.stream().map(x -> x.getCount()).collect(Collectors.toList()); List<Integer> countList = trafficStatusPOS.stream().map(x -> x.getCount()).collect(Collectors.toList());
eventInfoTrafficStatusVO.setEventCount(countList); eventInfoTrafficStatusVO.setEventCount(countList);
......
package net.wanji.common.utils.tool; package net.wanji.common.utils.tool;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.*; import java.time.*;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
...@@ -25,6 +26,7 @@ public class LocalDateTimeUtil { ...@@ -25,6 +26,7 @@ public class LocalDateTimeUtil {
public static final String YEARFORMATTER = "yyyy"; public static final String YEARFORMATTER = "yyyy";
public static final String SIMPLE = "yyyyMMddHHmmss"; public static final String SIMPLE = "yyyyMMddHHmmss";
public static final String TIMEFORMATTERTILT = "yyyy/MM/dd HH:mm:ss"; public static final String TIMEFORMATTERTILT = "yyyy/MM/dd HH:mm:ss";
public static final String HOURMINITFORMATTER = "HH:mm";
private LocalDateTimeUtil() { private LocalDateTimeUtil() {
...@@ -156,6 +158,7 @@ public class LocalDateTimeUtil { ...@@ -156,6 +158,7 @@ public class LocalDateTimeUtil {
return LocalDateTime.parse(time, df); return LocalDateTime.parse(time, df);
} }
/** /**
* 将日期字符串转化为LocalDateTime * 将日期字符串转化为LocalDateTime
* *
...@@ -168,14 +171,12 @@ public class LocalDateTimeUtil { ...@@ -168,14 +171,12 @@ public class LocalDateTimeUtil {
return LocalDateTime.parse(checkFormat(time), df); return LocalDateTime.parse(checkFormat(time), df);
} }
public static void main(String[] args) { public static void main(String[] args) throws ParseException {
System.out.println("--"+new Date()); //LocalDateTime localDateTime = parseStringToDateTime("08:00", LocalDateTimeUtil.HOURMINITFORMATTER);
String date = "2021/10/22 17:45:20"; //System.out.println(localDateTime);
String nowStageStartTime = date == null ? "" : date.toString().replaceAll("\"", ""); Date parse = DateUtil.parse("08:00", LocalDateTimeUtil.HOURMINITFORMATTER);
LocalDateTime localDateTime = parseStringToDateTimeTwo(nowStageStartTime, LocalDateTimeUtil.TIMEFORMATTERTILT); System.out.println(parse);
String time = nowStageStartTime.isEmpty() ? "0" : Long.toString(LocalDateTimeUtil.betweenTwoTime(localDateTime, LocalDateTime.now(), ChronoUnit.SECONDS));
System.out.println(time);
System.out.println(new Date().getTime());
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment