Commit 1faf1d59 authored by duanruiming's avatar duanruiming

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

parent dc3384a5
......@@ -31,6 +31,7 @@ import org.joda.time.format.DateTimeFormat;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.text.ParseException;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
......@@ -313,7 +314,13 @@ public class EventServiceImpl implements EventService {
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> countList = trafficStatusPOS.stream().map(x -> x.getCount()).collect(Collectors.toList());
eventInfoTrafficStatusVO.setEventCount(countList);
......
package net.wanji.common.utils.tool;
import java.text.MessageFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.*;
import java.time.format.DateTimeFormatter;
......@@ -25,6 +26,7 @@ public class LocalDateTimeUtil {
public static final String YEARFORMATTER = "yyyy";
public static final String SIMPLE = "yyyyMMddHHmmss";
public static final String TIMEFORMATTERTILT = "yyyy/MM/dd HH:mm:ss";
public static final String HOURMINITFORMATTER = "HH:mm";
private LocalDateTimeUtil() {
......@@ -156,6 +158,7 @@ public class LocalDateTimeUtil {
return LocalDateTime.parse(time, df);
}
/**
* 将日期字符串转化为LocalDateTime
*
......@@ -168,14 +171,12 @@ public class LocalDateTimeUtil {
return LocalDateTime.parse(checkFormat(time), df);
}
public static void main(String[] args) {
System.out.println("--"+new Date());
String date = "2021/10/22 17:45:20";
String nowStageStartTime = date == null ? "" : date.toString().replaceAll("\"", "");
LocalDateTime localDateTime = parseStringToDateTimeTwo(nowStageStartTime, LocalDateTimeUtil.TIMEFORMATTERTILT);
String time = nowStageStartTime.isEmpty() ? "0" : Long.toString(LocalDateTimeUtil.betweenTwoTime(localDateTime, LocalDateTime.now(), ChronoUnit.SECONDS));
System.out.println(time);
System.out.println(new Date().getTime());
public static void main(String[] args) throws ParseException {
//LocalDateTime localDateTime = parseStringToDateTime("08:00", LocalDateTimeUtil.HOURMINITFORMATTER);
//System.out.println(localDateTime);
Date parse = DateUtil.parse("08:00", LocalDateTimeUtil.HOURMINITFORMATTER);
System.out.println(parse);
}
/**
......
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