From 7d07c8fb617161258fe9af7c7cb2310e401e3904 Mon Sep 17 00:00:00 2001 From: Angel <1050374295@qq.com> Date: Sat, 6 Jan 2024 17:25:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E6=97=B6=E4=BA=BA=E7=9A=84=E8=AE=B0?= =?UTF-8?q?=E5=BD=95--=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../task/PeopleVehicleHourFlowTask.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/ssf/mysqloracletest/task/PeopleVehicleHourFlowTask.java b/src/main/java/com/ssf/mysqloracletest/task/PeopleVehicleHourFlowTask.java index 3b0078a..bdc7450 100644 --- a/src/main/java/com/ssf/mysqloracletest/task/PeopleVehicleHourFlowTask.java +++ b/src/main/java/com/ssf/mysqloracletest/task/PeopleVehicleHourFlowTask.java @@ -32,6 +32,7 @@ public class PeopleVehicleHourFlowTask { private final PeopleVehicleHourFlowService peopleVehicleHourFlowService; DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); DateTimeFormatter formatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); @Scheduled(initialDelay = 100, fixedDelay = 3000) public void setVehicleHourFlowService() { @@ -44,8 +45,6 @@ public class PeopleVehicleHourFlowTask { LocalDateTime currentDate = LocalDateTime.now();//例如:2023-10-10 00:00:00 LocalDateTime startOfDay = currentDate.withHour(0).withMinute(0).withSecond(0); LocalDateTime Hour = currentDate.withHour(0).withMinute(0).withSecond(0); - - //循环迭代24小时 for (int i = 0; i < 24; i++) { //构造查询条件 @@ -72,7 +71,7 @@ public class PeopleVehicleHourFlowTask { } } else { UpdateWrapper wrapper = new UpdateWrapper<>(); - wrapper.eq("statistic_time", time.toString()); + wrapper.eq("statistic_time", format); wrapper.eq("statistic_type", 2); boolean update = peopleVehicleHourFlowService.update(peopleVehicleHourFlow, wrapper); if (update) { @@ -106,30 +105,30 @@ public class PeopleVehicleHourFlowTask { 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")); + //DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + String formattedDate = targetHour.format(formatter2); String format = time.format(formatter1); - queryWrapper.between("capturetime", formattedDate, targetHour.plusHours(i+1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + queryWrapper.between("capturetime", formattedDate, targetHour.plusHours(i+1).format(formatter2)); int count = tStrhEntityInfoKsService.count(queryWrapper); PeopleVehicleHourFlow peopleVehicleHourFlow = new PeopleVehicleHourFlow(); peopleVehicleHourFlow.setStatistic_count(String.valueOf(count)); peopleVehicleHourFlow.setStatistic_type(1); peopleVehicleHourFlow.setStatistic_time(format); - PeopleVehicleHourFlow one = peopleVehicleHourFlowService.lambdaQuery().eq(PeopleVehicleHourFlow::getStatistic_time, time) + PeopleVehicleHourFlow one = peopleVehicleHourFlowService.lambdaQuery().eq(PeopleVehicleHourFlow::getStatistic_time, format) .eq(PeopleVehicleHourFlow::getStatistic_type, 1).one(); if (one == null) { boolean save = peopleVehicleHourFlowService.save(peopleVehicleHourFlow); if (save) { - logger.info("Face-" + time + ":插入成功"); + logger.info("Face-" + format + ":插入成功"); } } else { UpdateWrapper wrapper = new UpdateWrapper<>(); - wrapper.eq("statistic_time", time.toString()); + wrapper.eq("statistic_time", format); wrapper.eq("statistic_type", 1); boolean update = peopleVehicleHourFlowService.update(peopleVehicleHourFlow, wrapper); if (update) { - logger.info("Face-" + time + ":更新成功"); + logger.info("Face-" + format + ":更新成功"); } }