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

import com.xxl.job.core.handler.annotation.XxlJob;
import com.yuchen.saas.park.api.entity.park.PmgBatParkInfo;
import com.yuchen.saas.park.service.service.PmgBatParkInfoService;
import com.yuchen.saas.park.service.service.PmgBatParkPeopleService;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: baichaojie
 * @CreateTime: 2024/11/06 20:41
 * @Description: TODO
 * @Version: 1.0
 */
public class SyncPersonJob {


    @Resource
    private PmgBatParkPeopleService pmgBatParkPeopleService;


    @Resource
    private PmgBatParkInfoService pmgBatParkInfoService;

    /**
     * 定时同步人员到门禁
     */
    @XxlJob("syncDoorPerson")
    public void syncDoorPerson() {
        //获取所有项目的parkId
        List<PmgBatParkInfo> allPark = pmgBatParkInfoService.getAllPark();
        for (PmgBatParkInfo pmgBatParkInfo : allPark) {
            if (pmgBatParkInfo.getId() != null) {
                pmgBatParkPeopleService.syncDoorPerson(pmgBatParkInfo.getId(),null);
            }
        }
    }

    /**
     * 定时同步人员到梯控
     */
    @XxlJob("syncElevatorPerson")
    public void syncElevatorPerson() {
        //获取所有项目的parkId
        List<PmgBatParkInfo> allPark = pmgBatParkInfoService.getAllPark();
        for (PmgBatParkInfo pmgBatParkInfo : allPark) {
            if (pmgBatParkInfo.getId() != null) {
                pmgBatParkPeopleService.syncElevatorPerson(pmgBatParkInfo.getId(),null);
            }
        }
    }
}