package com.xjrsoft.module.job;

import cn.hutool.extra.spring.SpringUtil;
import com.xjrsoft.module.hikvision.util.OutInRecordUtil;
import com.xjrsoft.module.teacher.mapper.FaceImportMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author dzx
 * @date 2024/5/8
 */
@Component
@Slf4j
public class InsertOutInRecordTask {
    @Autowired
    private FaceImportMapper faceImportMapper;

    OutInRecordUtil out_in_recordUtil = new OutInRecordUtil();

    @Scheduled(cron = "0 */30 * * * ?")
    public void RefreshConnectionPool() {
        String active = SpringUtil.getActiveProfile();
        if(!"prod".equals(active)){
            log.info("非正式环境，无法执行数据推送");
            return;
        }
        log.info("开始拉取海康威视基础数据");
        try {
            //教师&学生拉取数据
//            out_in_recordUtil.GetTeacherAndStudentRecords(use, faceImportMapper);
            //拉取车辆数据
//            out_in_recordUtil.GetVehicleRecord(use, faceImportMapper);
            //拉取访客数据
            out_in_recordUtil.GetVisitRecord(faceImportMapper);

            log.info("数据拉取完成");
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }
}

