|
|
@ -4,20 +4,18 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
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.TransitUserRecord;
|
|
|
|
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.text.SimpleDateFormat;
|
|
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
import java.time.LocalDate;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
@ -57,20 +55,20 @@ public class PeopleVehicleFlowTask {
|
|
|
|
// 将日期部分格式化为数据库存储格式
|
|
|
|
// 将日期部分格式化为数据库存储格式
|
|
|
|
String formattedDate = targetDate.format(formatter);
|
|
|
|
String formattedDate = targetDate.format(formatter);
|
|
|
|
|
|
|
|
|
|
|
|
queryWrapper.between("passtime", formattedDate,targetDate.plusDays(1).format(formatter));
|
|
|
|
queryWrapper.between("passtime", formattedDate, targetDate.plusDays(1).format(formatter));
|
|
|
|
int count = tMotorvehicleService.count(queryWrapper);
|
|
|
|
int count = tMotorvehicleService.count(queryWrapper);
|
|
|
|
PeopleVehicleFlow peopleVehicleFlow = new PeopleVehicleFlow();
|
|
|
|
PeopleVehicleFlow peopleVehicleFlow = new PeopleVehicleFlow();
|
|
|
|
peopleVehicleFlow.setStatistic_count(String.valueOf(count));
|
|
|
|
peopleVehicleFlow.setStatistic_count(String.valueOf(count));
|
|
|
|
peopleVehicleFlow.setStatistic_type(2);
|
|
|
|
peopleVehicleFlow.setStatistic_type(2);
|
|
|
|
peopleVehicleFlow.setStatistic_time(date.toString());
|
|
|
|
peopleVehicleFlow.setStatistic_time(date.toString());
|
|
|
|
PeopleVehicleFlow one = peopleVehicleFlowService.lambdaQuery().eq(PeopleVehicleFlow::getStatistic_time, date.toString())
|
|
|
|
PeopleVehicleFlow one = peopleVehicleFlowService.lambdaQuery().eq(PeopleVehicleFlow::getStatistic_time, date.toString())
|
|
|
|
.eq(PeopleVehicleFlow::getStatistic_type ,2).one();
|
|
|
|
.eq(PeopleVehicleFlow::getStatistic_type, 2).one();
|
|
|
|
if (one == null){
|
|
|
|
if (one == null) {
|
|
|
|
boolean save = peopleVehicleFlowService.save(peopleVehicleFlow);
|
|
|
|
boolean save = peopleVehicleFlowService.save(peopleVehicleFlow);
|
|
|
|
if (save) {
|
|
|
|
if (save) {
|
|
|
|
logger.info("Face-" + date + ":插入成功");
|
|
|
|
logger.info("Face-" + date + ":插入成功");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
UpdateWrapper<PeopleVehicleFlow> wrapper = new UpdateWrapper<>();
|
|
|
|
UpdateWrapper<PeopleVehicleFlow> wrapper = new UpdateWrapper<>();
|
|
|
|
wrapper.eq("statistic_time", date.toString());
|
|
|
|
wrapper.eq("statistic_time", date.toString());
|
|
|
|
wrapper.eq("statistic_type", 2);
|
|
|
|
wrapper.eq("statistic_type", 2);
|
|
|
@ -94,13 +92,14 @@ public class PeopleVehicleFlowTask {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
LocalDate localDate = LocalDate.now();
|
|
|
|
//获取当前日期
|
|
|
|
|
|
|
|
LocalDateTime localDate = LocalDateTime.now();
|
|
|
|
//循环迭代7天
|
|
|
|
//循环迭代7天
|
|
|
|
for (int i = 0; i < 7; i++) {
|
|
|
|
for (int i = 0; i < 7; i++) {
|
|
|
|
//构造查询条件
|
|
|
|
//构造查询条件
|
|
|
|
QueryWrapper<TStrhEntityInfoKs> queryWrapper = new QueryWrapper<>();
|
|
|
|
QueryWrapper<TStrhEntityInfoKs> queryWrapper = new QueryWrapper<>();
|
|
|
|
// 减去 i 天并设置查询条件的日期字段
|
|
|
|
// 减去 i 天并设置查询条件的日期字段
|
|
|
|
LocalDate date = localDate.minusDays(i);
|
|
|
|
LocalDateTime date = localDate.minusDays(i);
|
|
|
|
// 将日期部分格式化为数据库存储格式
|
|
|
|
// 将日期部分格式化为数据库存储格式
|
|
|
|
String formattedDate = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
String formattedDate = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
|
|
|
|
|
|
@ -109,7 +108,23 @@ public class PeopleVehicleFlowTask {
|
|
|
|
PeopleVehicleFlow peopleVehicleFlow = new PeopleVehicleFlow();
|
|
|
|
PeopleVehicleFlow peopleVehicleFlow = new PeopleVehicleFlow();
|
|
|
|
peopleVehicleFlow.setStatistic_count(String.valueOf(count));
|
|
|
|
peopleVehicleFlow.setStatistic_count(String.valueOf(count));
|
|
|
|
peopleVehicleFlow.setStatistic_type(1);
|
|
|
|
peopleVehicleFlow.setStatistic_type(1);
|
|
|
|
peopleVehicleFlow.setStatistic_time(localDate.toString());
|
|
|
|
peopleVehicleFlow.setStatistic_time(date.toString());
|
|
|
|
|
|
|
|
PeopleVehicleFlow one = peopleVehicleFlowService.lambdaQuery().eq(PeopleVehicleFlow::getStatistic_time, date.toString())
|
|
|
|
|
|
|
|
.eq(PeopleVehicleFlow::getStatistic_type, 1).one();
|
|
|
|
|
|
|
|
if (one == null) {
|
|
|
|
|
|
|
|
boolean save = peopleVehicleFlowService.save(peopleVehicleFlow);
|
|
|
|
|
|
|
|
if (save) {
|
|
|
|
|
|
|
|
logger.info("Face-" + date + ":插入成功");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
UpdateWrapper<PeopleVehicleFlow> wrapper = new UpdateWrapper<>();
|
|
|
|
|
|
|
|
wrapper.eq("statistic_time", date.toString());
|
|
|
|
|
|
|
|
wrapper.eq("statistic_type", 2);
|
|
|
|
|
|
|
|
boolean update = peopleVehicleFlowService.update(peopleVehicleFlow, wrapper);
|
|
|
|
|
|
|
|
if (update) {
|
|
|
|
|
|
|
|
logger.info("Face-" + date + ":更新成功");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
logger.info(StringKit.getTrace(e));
|
|
|
|
logger.info(StringKit.getTrace(e));
|
|
|
|