package com.ics.quartz.task;

import cn.hutool.core.date.DateUtil;
import com.ics.admin.domain.meeting.Reservation;
import com.ics.admin.service.meeting.IReservationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;
@Slf4j
@Component("meetingStatusTask")
public class MeetingStatusTask {
    @Autowired
    private IReservationService iReservationService;

    /**
     * 开会开始状态
     */
    public void meetingEndStatus() {
        log.info("执行开会结束状态任务");
        Reservation reservation = new Reservation();

        reservation.setStatusValue(2);
        List<Reservation> reservations = iReservationService.selectReservationList(reservation);
        for (Reservation reservation1 : reservations) {
            Date endDate = reservation1.getEndDate();
            int compare = DateUtil.compare(DateUtil.date(), endDate);
            if (compare > 0) {
                reservation1.setStauts(Reservation.Status.ENDED);
                iReservationService.updateReservation(reservation1);
                log.info("执行开会结束状态任务");
            }
        }
    }
}
