|
@@ -29,6 +29,7 @@ import java.math.RoundingMode;
|
|
|
import java.time.DayOfWeek;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.LocalTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.time.temporal.TemporalAdjusters;
|
|
|
import java.util.ArrayList;
|
|
@@ -110,30 +111,44 @@ public class StatisticsServiceImpl implements IStatisticsService {
|
|
|
String startDate = "";
|
|
|
String endDate = "";
|
|
|
|
|
|
- LocalDate now = LocalDate.now();
|
|
|
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
+ LocalTime startOfDayTime = LocalTime.MIN;
|
|
|
+ LocalTime endOfDayTime = LocalTime.of(23, 59, 59);
|
|
|
|
|
|
if(0 == type){
|
|
|
- startDate = now.format(formatter);
|
|
|
- endDate = now.format(formatter);
|
|
|
+ LocalDateTime startOfDay = now.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfDay = now.with(endOfDayTime);
|
|
|
+ startDate = startOfDay.format(formatter);
|
|
|
+ endDate = endOfDay.format(formatter);
|
|
|
} else if(1 == type){
|
|
|
- LocalDate yesterday = now.minusDays(1);
|
|
|
- startDate = yesterday.format(formatter);
|
|
|
- endDate = yesterday.format(formatter);
|
|
|
+ LocalDateTime yesterday = now.minusDays(1);
|
|
|
+ LocalDateTime startOfYesterday = yesterday.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfYesterday = yesterday.with(endOfDayTime);
|
|
|
+ startDate = startOfYesterday.format(formatter);
|
|
|
+ endDate = endOfYesterday.format(formatter);
|
|
|
} else if(2 == type) {
|
|
|
- LocalDate startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
|
|
|
- startDate = startOfWeek.format(formatter);
|
|
|
- endDate = now.format(formatter);
|
|
|
+ LocalDateTime startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
|
|
|
+ LocalDateTime startOfStartOfWeek = startOfWeek.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfToday = now.with(endOfDayTime);
|
|
|
+ startDate = startOfStartOfWeek.format(formatter);
|
|
|
+ endDate = endOfToday.format(formatter);
|
|
|
} else if(3 == type) {
|
|
|
- LocalDate startOfMonth = now.withDayOfMonth(1);
|
|
|
- startDate = startOfMonth.format(formatter);
|
|
|
- endDate = now.format(formatter);
|
|
|
+ LocalDateTime startOfMonth = now.withDayOfMonth(1);
|
|
|
+ LocalDateTime startOfStartOfMonth = startOfMonth.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfToday = now.with(endOfDayTime);
|
|
|
+ startDate = startOfStartOfMonth.format(formatter);
|
|
|
+ endDate = endOfToday.format(formatter);
|
|
|
} else if(4 == type) {
|
|
|
- LocalDate firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1);
|
|
|
- LocalDate lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1);
|
|
|
- startDate = firstDayOfPreviousMonth.format(formatter);
|
|
|
- endDate = lastDayOfPreviousMonth.format(formatter);
|
|
|
+ LocalDateTime firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1);
|
|
|
+ LocalDateTime lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1);
|
|
|
+
|
|
|
+ LocalDateTime startOfPrevMonthStart = firstDayOfPreviousMonth.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfPrevMonthEnd = lastDayOfPreviousMonth.with(endOfDayTime);
|
|
|
+
|
|
|
+ startDate = startOfPrevMonthStart.format(formatter);
|
|
|
+ endDate = endOfPrevMonthEnd.format(formatter);
|
|
|
}
|
|
|
|
|
|
AnalysisPreviewQueryDTO param = new AnalysisPreviewQueryDTO();
|
|
@@ -174,27 +189,41 @@ public class StatisticsServiceImpl implements IStatisticsService {
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
+ LocalTime startOfDayTime = LocalTime.MIN;
|
|
|
+ LocalTime endOfDayTime = LocalTime.of(23, 59, 59);
|
|
|
|
|
|
if(0 == type){
|
|
|
- startDate = now.format(formatter);
|
|
|
- endDate = now.format(formatter);
|
|
|
+ LocalDateTime startOfDay = now.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfDay = now.with(endOfDayTime);
|
|
|
+ startDate = startOfDay.format(formatter);
|
|
|
+ endDate = endOfDay.format(formatter);
|
|
|
} else if(1 == type){
|
|
|
LocalDateTime yesterday = now.minusDays(1);
|
|
|
- startDate = yesterday.format(formatter);
|
|
|
- endDate = yesterday.format(formatter);
|
|
|
+ LocalDateTime startOfYesterday = yesterday.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfYesterday = yesterday.with(endOfDayTime);
|
|
|
+ startDate = startOfYesterday.format(formatter);
|
|
|
+ endDate = endOfYesterday.format(formatter);
|
|
|
} else if(2 == type) {
|
|
|
LocalDateTime startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
|
|
|
- startDate = startOfWeek.format(formatter);
|
|
|
- endDate = now.format(formatter);
|
|
|
+ LocalDateTime startOfStartOfWeek = startOfWeek.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfToday = now.with(endOfDayTime);
|
|
|
+ startDate = startOfStartOfWeek.format(formatter);
|
|
|
+ endDate = endOfToday.format(formatter);
|
|
|
} else if(3 == type) {
|
|
|
LocalDateTime startOfMonth = now.withDayOfMonth(1);
|
|
|
- startDate = startOfMonth.format(formatter);
|
|
|
- endDate = now.format(formatter);
|
|
|
+ LocalDateTime startOfStartOfMonth = startOfMonth.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfToday = now.with(endOfDayTime);
|
|
|
+ startDate = startOfStartOfMonth.format(formatter);
|
|
|
+ endDate = endOfToday.format(formatter);
|
|
|
} else if(4 == type) {
|
|
|
LocalDateTime firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1);
|
|
|
LocalDateTime lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1);
|
|
|
- startDate = firstDayOfPreviousMonth.format(formatter);
|
|
|
- endDate = lastDayOfPreviousMonth.format(formatter);
|
|
|
+
|
|
|
+ LocalDateTime startOfPrevMonthStart = firstDayOfPreviousMonth.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfPrevMonthEnd = lastDayOfPreviousMonth.with(endOfDayTime);
|
|
|
+
|
|
|
+ startDate = startOfPrevMonthStart.format(formatter);
|
|
|
+ endDate = endOfPrevMonthEnd.format(formatter);
|
|
|
}
|
|
|
|
|
|
AnalysisPreviewQueryDTO param = new AnalysisPreviewQueryDTO();
|
|
@@ -254,27 +283,41 @@ public class StatisticsServiceImpl implements IStatisticsService {
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
+ LocalTime startOfDayTime = LocalTime.MIN;
|
|
|
+ LocalTime endOfDayTime = LocalTime.of(23, 59, 59);
|
|
|
|
|
|
if(0 == type){
|
|
|
- startDate = now.format(formatter);
|
|
|
- endDate = now.format(formatter);
|
|
|
+ LocalDateTime startOfDay = now.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfDay = now.with(endOfDayTime);
|
|
|
+ startDate = startOfDay.format(formatter);
|
|
|
+ endDate = endOfDay.format(formatter);
|
|
|
} else if(1 == type){
|
|
|
LocalDateTime yesterday = now.minusDays(1);
|
|
|
- startDate = yesterday.format(formatter);
|
|
|
- endDate = yesterday.format(formatter);
|
|
|
+ LocalDateTime startOfYesterday = yesterday.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfYesterday = yesterday.with(endOfDayTime);
|
|
|
+ startDate = startOfYesterday.format(formatter);
|
|
|
+ endDate = endOfYesterday.format(formatter);
|
|
|
} else if(2 == type) {
|
|
|
LocalDateTime startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
|
|
|
- startDate = startOfWeek.format(formatter);
|
|
|
- endDate = now.format(formatter);
|
|
|
+ LocalDateTime startOfStartOfWeek = startOfWeek.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfToday = now.with(endOfDayTime);
|
|
|
+ startDate = startOfStartOfWeek.format(formatter);
|
|
|
+ endDate = endOfToday.format(formatter);
|
|
|
} else if(3 == type) {
|
|
|
LocalDateTime startOfMonth = now.withDayOfMonth(1);
|
|
|
- startDate = startOfMonth.format(formatter);
|
|
|
- endDate = now.format(formatter);
|
|
|
+ LocalDateTime startOfStartOfMonth = startOfMonth.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfToday = now.with(endOfDayTime);
|
|
|
+ startDate = startOfStartOfMonth.format(formatter);
|
|
|
+ endDate = endOfToday.format(formatter);
|
|
|
} else if(4 == type) {
|
|
|
LocalDateTime firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1);
|
|
|
LocalDateTime lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1);
|
|
|
- startDate = firstDayOfPreviousMonth.format(formatter);
|
|
|
- endDate = lastDayOfPreviousMonth.format(formatter);
|
|
|
+
|
|
|
+ LocalDateTime startOfPrevMonthStart = firstDayOfPreviousMonth.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfPrevMonthEnd = lastDayOfPreviousMonth.with(endOfDayTime);
|
|
|
+
|
|
|
+ startDate = startOfPrevMonthStart.format(formatter);
|
|
|
+ endDate = endOfPrevMonthEnd.format(formatter);
|
|
|
}
|
|
|
|
|
|
dto.setStartTime(startDate);
|
|
@@ -298,29 +341,42 @@ public class StatisticsServiceImpl implements IStatisticsService {
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
+ LocalTime startOfDayTime = LocalTime.MIN;
|
|
|
+ LocalTime endOfDayTime = LocalTime.of(23, 59, 59);
|
|
|
|
|
|
if(0 == type){
|
|
|
- startDate = now.format(formatter);
|
|
|
- endDate = now.format(formatter);
|
|
|
+ LocalDateTime startOfDay = now.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfDay = now.with(endOfDayTime);
|
|
|
+ startDate = startOfDay.format(formatter);
|
|
|
+ endDate = endOfDay.format(formatter);
|
|
|
} else if(1 == type){
|
|
|
LocalDateTime yesterday = now.minusDays(1);
|
|
|
- startDate = yesterday.format(formatter);
|
|
|
- endDate = yesterday.format(formatter);
|
|
|
+ LocalDateTime startOfYesterday = yesterday.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfYesterday = yesterday.with(endOfDayTime);
|
|
|
+ startDate = startOfYesterday.format(formatter);
|
|
|
+ endDate = endOfYesterday.format(formatter);
|
|
|
} else if(2 == type) {
|
|
|
LocalDateTime startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
|
|
|
- startDate = startOfWeek.format(formatter);
|
|
|
- endDate = now.format(formatter);
|
|
|
+ LocalDateTime startOfStartOfWeek = startOfWeek.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfToday = now.with(endOfDayTime);
|
|
|
+ startDate = startOfStartOfWeek.format(formatter);
|
|
|
+ endDate = endOfToday.format(formatter);
|
|
|
} else if(3 == type) {
|
|
|
LocalDateTime startOfMonth = now.withDayOfMonth(1);
|
|
|
- startDate = startOfMonth.format(formatter);
|
|
|
- endDate = now.format(formatter);
|
|
|
+ LocalDateTime startOfStartOfMonth = startOfMonth.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfToday = now.with(endOfDayTime);
|
|
|
+ startDate = startOfStartOfMonth.format(formatter);
|
|
|
+ endDate = endOfToday.format(formatter);
|
|
|
} else if(4 == type) {
|
|
|
LocalDateTime firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1);
|
|
|
LocalDateTime lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1);
|
|
|
- startDate = firstDayOfPreviousMonth.format(formatter);
|
|
|
- endDate = lastDayOfPreviousMonth.format(formatter);
|
|
|
- }
|
|
|
|
|
|
+ LocalDateTime startOfPrevMonthStart = firstDayOfPreviousMonth.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfPrevMonthEnd = lastDayOfPreviousMonth.with(endOfDayTime);
|
|
|
+
|
|
|
+ startDate = startOfPrevMonthStart.format(formatter);
|
|
|
+ endDate = endOfPrevMonthEnd.format(formatter);
|
|
|
+ }
|
|
|
dto.setStartTime(startDate);
|
|
|
dto.setEndTime(endDate);
|
|
|
dto.setUserType(userType);
|
|
@@ -508,27 +564,41 @@ public class StatisticsServiceImpl implements IStatisticsService {
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
+ LocalTime startOfDayTime = LocalTime.MIN;
|
|
|
+ LocalTime endOfDayTime = LocalTime.of(23, 59, 59);
|
|
|
|
|
|
if(0 == type){
|
|
|
- startDate = now.format(formatter);
|
|
|
- endDate = now.format(formatter);
|
|
|
+ LocalDateTime startOfDay = now.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfDay = now.with(endOfDayTime);
|
|
|
+ startDate = startOfDay.format(formatter);
|
|
|
+ endDate = endOfDay.format(formatter);
|
|
|
} else if(1 == type){
|
|
|
LocalDateTime yesterday = now.minusDays(1);
|
|
|
- startDate = yesterday.format(formatter);
|
|
|
- endDate = yesterday.format(formatter);
|
|
|
+ LocalDateTime startOfYesterday = yesterday.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfYesterday = yesterday.with(endOfDayTime);
|
|
|
+ startDate = startOfYesterday.format(formatter);
|
|
|
+ endDate = endOfYesterday.format(formatter);
|
|
|
} else if(2 == type) {
|
|
|
LocalDateTime startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
|
|
|
- startDate = startOfWeek.format(formatter);
|
|
|
- endDate = now.format(formatter);
|
|
|
+ LocalDateTime startOfStartOfWeek = startOfWeek.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfToday = now.with(endOfDayTime);
|
|
|
+ startDate = startOfStartOfWeek.format(formatter);
|
|
|
+ endDate = endOfToday.format(formatter);
|
|
|
} else if(3 == type) {
|
|
|
LocalDateTime startOfMonth = now.withDayOfMonth(1);
|
|
|
- startDate = startOfMonth.format(formatter);
|
|
|
- endDate = now.format(formatter);
|
|
|
+ LocalDateTime startOfStartOfMonth = startOfMonth.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfToday = now.with(endOfDayTime);
|
|
|
+ startDate = startOfStartOfMonth.format(formatter);
|
|
|
+ endDate = endOfToday.format(formatter);
|
|
|
} else if(4 == type) {
|
|
|
LocalDateTime firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1);
|
|
|
LocalDateTime lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1);
|
|
|
- startDate = firstDayOfPreviousMonth.format(formatter);
|
|
|
- endDate = lastDayOfPreviousMonth.format(formatter);
|
|
|
+
|
|
|
+ LocalDateTime startOfPrevMonthStart = firstDayOfPreviousMonth.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfPrevMonthEnd = lastDayOfPreviousMonth.with(endOfDayTime);
|
|
|
+
|
|
|
+ startDate = startOfPrevMonthStart.format(formatter);
|
|
|
+ endDate = endOfPrevMonthEnd.format(formatter);
|
|
|
}
|
|
|
|
|
|
dto.setStartTime(startDate);
|
|
@@ -552,27 +622,41 @@ public class StatisticsServiceImpl implements IStatisticsService {
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
+ LocalTime startOfDayTime = LocalTime.MIN;
|
|
|
+ LocalTime endOfDayTime = LocalTime.of(23, 59, 59);
|
|
|
|
|
|
if(0 == type){
|
|
|
- startDate = now.format(formatter);
|
|
|
- endDate = now.format(formatter);
|
|
|
+ LocalDateTime startOfDay = now.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfDay = now.with(endOfDayTime);
|
|
|
+ startDate = startOfDay.format(formatter);
|
|
|
+ endDate = endOfDay.format(formatter);
|
|
|
} else if(1 == type){
|
|
|
LocalDateTime yesterday = now.minusDays(1);
|
|
|
- startDate = yesterday.format(formatter);
|
|
|
- endDate = yesterday.format(formatter);
|
|
|
+ LocalDateTime startOfYesterday = yesterday.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfYesterday = yesterday.with(endOfDayTime);
|
|
|
+ startDate = startOfYesterday.format(formatter);
|
|
|
+ endDate = endOfYesterday.format(formatter);
|
|
|
} else if(2 == type) {
|
|
|
LocalDateTime startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
|
|
|
- startDate = startOfWeek.format(formatter);
|
|
|
- endDate = now.format(formatter);
|
|
|
+ LocalDateTime startOfStartOfWeek = startOfWeek.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfToday = now.with(endOfDayTime);
|
|
|
+ startDate = startOfStartOfWeek.format(formatter);
|
|
|
+ endDate = endOfToday.format(formatter);
|
|
|
} else if(3 == type) {
|
|
|
LocalDateTime startOfMonth = now.withDayOfMonth(1);
|
|
|
- startDate = startOfMonth.format(formatter);
|
|
|
- endDate = now.format(formatter);
|
|
|
+ LocalDateTime startOfStartOfMonth = startOfMonth.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfToday = now.with(endOfDayTime);
|
|
|
+ startDate = startOfStartOfMonth.format(formatter);
|
|
|
+ endDate = endOfToday.format(formatter);
|
|
|
} else if(4 == type) {
|
|
|
LocalDateTime firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1);
|
|
|
LocalDateTime lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1);
|
|
|
- startDate = firstDayOfPreviousMonth.format(formatter);
|
|
|
- endDate = lastDayOfPreviousMonth.format(formatter);
|
|
|
+
|
|
|
+ LocalDateTime startOfPrevMonthStart = firstDayOfPreviousMonth.with(startOfDayTime);
|
|
|
+ LocalDateTime endOfPrevMonthEnd = lastDayOfPreviousMonth.with(endOfDayTime);
|
|
|
+
|
|
|
+ startDate = startOfPrevMonthStart.format(formatter);
|
|
|
+ endDate = endOfPrevMonthEnd.format(formatter);
|
|
|
}
|
|
|
|
|
|
dto.setStartTime(startDate);
|