人车当日修改

develop
hanrenchun 9 months ago
parent edceb73517
commit a3bd93932d

@ -31,7 +31,7 @@ public class PeopleVehicleHourFlowTask {
//人车流量业表
private final PeopleVehicleHourFlowService peopleVehicleHourFlowService;
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
DateTimeFormatter formatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
@Scheduled(initialDelay = 100, fixedDelay = 3000)
public void setVehicleHourFlowService() {
@ -50,19 +50,20 @@ public class PeopleVehicleHourFlowTask {
for (int i = 0; i < 24; i++) {
//构造查询条件
QueryWrapper<TMotorvehicle> queryWrapper = new QueryWrapper<>();
//减去i小时
LocalDateTime targetHour = startOfDay.minusHours(i);
LocalDateTime time = Hour.minusHours(i);
//i小时
LocalDateTime targetHour = startOfDay.plusHours(i);
LocalDateTime time = Hour.plusHours(i + 1);
//将日期部分格式化为数据库存储格式
String formattedDate = targetHour.format(formatter);
String format = time.format(formatter1);
queryWrapper.between("passtime",formattedDate,targetHour.plusHours(1).format(formatter));
queryWrapper.between("passtime", formattedDate, targetHour.plusHours(i + 1).format(formatter));
int count = tMotorvehicleService.count(queryWrapper);
PeopleVehicleHourFlow peopleVehicleHourFlow = new PeopleVehicleHourFlow();
peopleVehicleHourFlow.setStatistic_count(String.valueOf(count));
peopleVehicleHourFlow.setStatistic_type(2);
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, format)
.eq(PeopleVehicleHourFlow::getStatistic_type, 2).one();
if (one == null) {
boolean save = peopleVehicleHourFlowService.save(peopleVehicleHourFlow);
@ -108,14 +109,14 @@ public class PeopleVehicleHourFlowTask {
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String formattedDate = targetHour.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
queryWrapper.between("capturetime",formattedDate,targetHour.plusHours(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
queryWrapper.between("capturetime", formattedDate, targetHour.plusHours(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(2);
peopleVehicleHourFlow.setStatistic_type(1);
peopleVehicleHourFlow.setStatistic_time(time.toString());
PeopleVehicleHourFlow one = peopleVehicleHourFlowService.lambdaQuery().eq(PeopleVehicleHourFlow::getStatistic_time, time.toString())
.eq(PeopleVehicleHourFlow::getStatistic_type, 2).one();
.eq(PeopleVehicleHourFlow::getStatistic_type, 1).one();
if (one == null) {
boolean save = peopleVehicleHourFlowService.save(peopleVehicleHourFlow);
if (save) {
@ -124,7 +125,7 @@ public class PeopleVehicleHourFlowTask {
} else {
UpdateWrapper<PeopleVehicleHourFlow> wrapper = new UpdateWrapper<>();
wrapper.eq("statistic_time", time.toString());
wrapper.eq("statistic_type", 2);
wrapper.eq("statistic_type", 1);
boolean update = peopleVehicleHourFlowService.update(peopleVehicleHourFlow, wrapper);
if (update) {
logger.info("Face-" + time + ":更新成功");

Loading…
Cancel
Save