xuhy
2026-03-12 edc78d01b5a0d9c3bcd12b457a0a2b54dc109a07
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.xiaopeng.maintenance.schedule;
 
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xiaopeng.api.feignClient.account.XpOperationUserClient;
import com.xiaopeng.api.feignClient.vehicleConvoy.XpVehicleClient;
import com.xiaopeng.api.model.maintenance.XpClockIn;
import com.xiaopeng.api.model.maintenance.XpSchedulingDetail;
import com.xiaopeng.maintenance.mapper.XpClockInMapper;
import com.xiaopeng.maintenance.mapper.XpTaskMapper;
import com.xiaopeng.maintenance.mapper.XpTaskRuleMapper;
import com.xiaopeng.maintenance.mapper.XpTaskRuleRoleMapper;
import com.xiaopeng.maintenance.service.IXpClockInService;
import com.xiaopeng.maintenance.service.IXpSchedulingDetailService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
 
import java.time.LocalDate;
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * 打卡定时任务
 * <p>
 * 判断是否迟到或者缺卡
 * </p>
 *
 * @author xiaochen
 * @since 2026-02-27
 */
@Component
public class ClockInScheduleTask {
 
    private static final Logger log = LoggerFactory.getLogger(ClockInScheduleTask.class);
 
    @Autowired
    private IXpClockInService xpClockInService;
    @Autowired
    private IXpSchedulingDetailService xpSchedulingDetailService;
 
 
    /**
     * 每5分钟执行一次
     */
    @Scheduled(cron = "0 */5 * * * ?")
    public void clockInScheduleTask() {
        log.info("========== 开始执行打卡检查 ==========");
        try {
 
            // 查询上班卡在今天的
            List<XpSchedulingDetail> clockInPlanList = xpSchedulingDetailService.list(Wrappers.lambdaQuery(XpSchedulingDetail.class)
                    .likeRight(XpSchedulingDetail::getPlanTime, LocalDate.now()));
            if(!CollectionUtils.isEmpty(clockInPlanList)){
                List<Long> fleetIds = clockInPlanList.stream().map(XpSchedulingDetail::getFleetId).collect(Collectors.toList());
                // 查询所有车队
 
            }
 
            // 查询下班卡在今天的
            List<XpSchedulingDetail> clockOutPlanList = xpSchedulingDetailService.list(Wrappers.lambdaQuery(XpSchedulingDetail.class)
                    .likeRight(XpSchedulingDetail::getPlanTime, LocalDate.now()));
 
        } catch (Exception e) {
            log.error("执行打卡检查任务执行失败", e);
        }
    }
}