kongdeqiang
6 小时以前 970453ec0b28479ba9ba30280051932cec8e4666
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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<EnterPark> list = enterParkService.list();
        for(EnterPark enterPark:list){
            QueryWrapper<OutPark> queryWrapper = new QueryWrapper<>();
            queryWrapper.lambda()
                    .eq(OutPark::getEnterTime,enterPark.getCreateTime())
                    .eq(OutPark::getCarNo,enterPark.getCarNo())
                    .eq(OutPark::getParkId,enterPark.getParkId());
            List<OutPark> 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("结束执行场内车辆定时排查任务-------》");
    }
 
}