package com.sky.ioc.job;

import com.sky.ioc.service.parking.ParkService;
import com.sky.ioc.service.meeting.MeetingRecordService;
import com.sky.ioc.service.parking.ParkingService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;

@Slf4j
public class MeetingRecordJob implements Job {

    @Autowired
    MeetingRecordService recordService;

    @Autowired
    ParkService parkService;

    @Autowired
    ParkingService parkingService;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        log.info(String.format("同步会议数据!  时间:" + new Date()));
        recordService.getMeetingRecordList();
        log.info(String.format("同步停车数据!  时间:" + new Date()));
        parkService.getParkData();
        log.info(String.format("同步车位数据!  时间:" + new Date()));
        parkingService.getParkingData();
    }

    public static void main(String[] args) {
        String url ="/api/meeting/MEETING/record/list";
        url = StringUtils.removeStart(url, "/");
        String baseUrl = StringUtils.appendIfMissing("http://"+"192.168.1.45:9001", "/");
        System.out.println(baseUrl+url);
    }
}
