package com.boying.job; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.boying.entity.EnterPark; import com.boying.entity.OutPark; import com.boying.service.EnterParkService; import com.boying.service.OutParkService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import java.io.IOException; import java.util.List; /** * @author kdq * @version 1.0.0 * @ClassName ParkCarScheduled.java * @Description TODO 场内车辆定时排查 * @createTime 2025年12月29日 08:50:00 */ @Component public class ParkCarScheduled { @Autowired private OutParkService outParkService; @Autowired private EnterParkService enterParkService; @Scheduled(cron = "0 0 1 * * ? ") public void execute() throws IOException { System.out.println("开始执行场内车辆定时排查任务-------》"); List list = enterParkService.list(); for(EnterPark enterPark:list){ QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.lambda() .eq(OutPark::getEnterTime,enterPark.getCreateTime()) .eq(OutPark::getCarNo,enterPark.getCarNo()) .eq(OutPark::getParkId,enterPark.getParkId()); List outParks = outParkService.list(queryWrapper); if(outParks.size() == 0){ for (OutPark outPark : outParks) { if(outPark.getPrice() == 0 || outPark.getStatus2()==1){ enterParkService.deleteById(enterPark.getId()); } } } } System.out.println("结束执行场内车辆定时排查任务-------》"); } }