diff --git a/src/main/java/com/ssf/mysqloracletest/task/PeopleVehicleHourFlowTask.java b/src/main/java/com/ssf/mysqloracletest/task/PeopleVehicleHourFlowTask.java index 00e400b..3b0078a 100644 --- a/src/main/java/com/ssf/mysqloracletest/task/PeopleVehicleHourFlowTask.java +++ b/src/main/java/com/ssf/mysqloracletest/task/PeopleVehicleHourFlowTask.java @@ -103,19 +103,20 @@ public class PeopleVehicleHourFlowTask { //构造查询条件 QueryWrapper queryWrapper = new QueryWrapper<>(); //减去i小时 - LocalDateTime targetHour = startOfDay.minusHours(i); - LocalDateTime time = Hour.minusHours(i); + LocalDateTime targetHour = startOfDay.plusHours(i); + LocalDateTime time = Hour.plusHours(i + 1); //将日期部分格式化为数据库存储格式 // DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); String formattedDate = targetHour.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + String format = time.format(formatter1); - queryWrapper.between("capturetime", formattedDate, targetHour.plusHours(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + queryWrapper.between("capturetime", formattedDate, targetHour.plusHours(i+1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); int count = tStrhEntityInfoKsService.count(queryWrapper); PeopleVehicleHourFlow peopleVehicleHourFlow = new PeopleVehicleHourFlow(); peopleVehicleHourFlow.setStatistic_count(String.valueOf(count)); peopleVehicleHourFlow.setStatistic_type(1); - peopleVehicleHourFlow.setStatistic_time(time.toString()); - PeopleVehicleHourFlow one = peopleVehicleHourFlowService.lambdaQuery().eq(PeopleVehicleHourFlow::getStatistic_time, time.toString()) + peopleVehicleHourFlow.setStatistic_time(format); + PeopleVehicleHourFlow one = peopleVehicleHourFlowService.lambdaQuery().eq(PeopleVehicleHourFlow::getStatistic_time, time) .eq(PeopleVehicleHourFlow::getStatistic_type, 1).one(); if (one == null) { boolean save = peopleVehicleHourFlowService.save(peopleVehicleHourFlow);