小时人的记录--修改

develop
Angel 9 months ago
parent 885cf99976
commit 7d07c8fb61

@ -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<PeopleVehicleHourFlow> 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<PeopleVehicleHourFlow> 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 + ":更新成功");
}
}

Loading…
Cancel
Save