package com.yuchen.saas.park.service.task;

import com.yuchen.saas.park.service.service.EnergyConsumptionService;
import com.yuchen.saas.park.service.service.pldoor.PlDoorUserPointSetService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author 张逸飞
 * @Date: 2021/3/26 14:24
 * @Description: 定时任务处理类
 */
@Component
public class ParkTimedTask {

    /**
     * 设备统计接口
     */
    @Resource
    private EnergyConsumptionService energyConsumptionService;
    @Resource
    private PlDoorUserPointSetService plDoorUserPointSetService;

    /**
     * 每天的第 30 秒执行的定时任务
     */
    @Scheduled(cron = "30 0 0 * * ?")
    public void everyDay() {
        // 能耗管理: 重建统计缓存
        energyConsumptionService.resetDeviceCountCash();
    }

    /**
     * 定时检查门禁人员权限状态 0:未生效;1:正常;2:已过期;
     */
    @Scheduled(cron = "0 0 23 * * ?")
    public void taskPointPermission () {
        plDoorUserPointSetService.checkPointPermission();
    }
}
