|
|
@ -3,20 +3,19 @@ package com.ssf.mysqloracletest.task;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.ssf.mysqloracletest.domain.PeopleVehicleFlow;
|
|
|
|
import com.ssf.mysqloracletest.domain.PeopleVehicleFlow;
|
|
|
|
import com.ssf.mysqloracletest.domain.TMotorvehicle;
|
|
|
|
import com.ssf.mysqloracletest.domain.TMotorvehicle;
|
|
|
|
|
|
|
|
import com.ssf.mysqloracletest.domain.TStrhEntityInfoKs;
|
|
|
|
import com.ssf.mysqloracletest.service.PeopleVehicleFlowService;
|
|
|
|
import com.ssf.mysqloracletest.service.PeopleVehicleFlowService;
|
|
|
|
import com.ssf.mysqloracletest.service.TMotorvehicleService;
|
|
|
|
import com.ssf.mysqloracletest.service.TMotorvehicleService;
|
|
|
|
import com.ssf.mysqloracletest.service.TStrhEntityInfoKsService;
|
|
|
|
import com.ssf.mysqloracletest.service.TStrhEntityInfoKsService;
|
|
|
|
import com.ssf.mysqloracletest.utils.ConfigParam;
|
|
|
|
import com.ssf.mysqloracletest.utils.ConfigParam;
|
|
|
|
import com.ssf.mysqloracletest.utils.StringKit;
|
|
|
|
import com.ssf.mysqloracletest.utils.StringKit;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
import java.time.LocalDate;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
|
|
|
|
|
|
|
@Component
|
|
|
|
@Component
|
|
|
@ -38,8 +37,6 @@ public class PeopleVehicleFlowTask {
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
//获取当前日期
|
|
|
|
//获取当前日期
|
|
|
|
// LocalDateTime currentDate = LocalDateTime.now();//例如:2023-10-10 00:00:00
|
|
|
|
|
|
|
|
// LocalDateTime startOfDay = currentDate.withHour(0).withMinute(0).withSecond(0);
|
|
|
|
|
|
|
|
LocalDate localDate = LocalDate.now();
|
|
|
|
LocalDate localDate = LocalDate.now();
|
|
|
|
//循环迭代7天
|
|
|
|
//循环迭代7天
|
|
|
|
for (int i = 0; i < 7; i++) {
|
|
|
|
for (int i = 0; i < 7; i++) {
|
|
|
@ -63,4 +60,33 @@ public class PeopleVehicleFlowTask {
|
|
|
|
logger.info(StringKit.getTrace(e));
|
|
|
|
logger.info(StringKit.getTrace(e));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Scheduled(initialDelay = 100, fixedDelay = 3000)
|
|
|
|
|
|
|
|
public void setPeopleFlowService() {
|
|
|
|
|
|
|
|
if (!"true".equals(ConfigParam.PeopleFlowSwitch)) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
LocalDate localDate = LocalDate.now();
|
|
|
|
|
|
|
|
//循环迭代7天
|
|
|
|
|
|
|
|
for (int i = 0; i < 7; i++) {
|
|
|
|
|
|
|
|
//构造查询条件
|
|
|
|
|
|
|
|
QueryWrapper<TStrhEntityInfoKs> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
|
|
|
// 减去 i 天并设置查询条件的日期字段
|
|
|
|
|
|
|
|
LocalDate date = localDate.minusDays(i);
|
|
|
|
|
|
|
|
// 将日期部分格式化为数据库存储格式
|
|
|
|
|
|
|
|
String formattedDate = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
queryWrapper.between("capturetime", formattedDate, date.plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
|
|
|
|
|
|
int count = tStrhEntityInfoKsService.count(queryWrapper);
|
|
|
|
|
|
|
|
PeopleVehicleFlow peopleVehicleFlow = new PeopleVehicleFlow();
|
|
|
|
|
|
|
|
peopleVehicleFlow.setStatistic_count(String.valueOf(count));
|
|
|
|
|
|
|
|
peopleVehicleFlow.setStatistic_type(1);
|
|
|
|
|
|
|
|
peopleVehicleFlow.setStatistic_time(localDate.toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
logger.info(StringKit.getTrace(e));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|