package org.wcs.quartzJob;

import lombok.RequiredArgsConstructor;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.wcs.constant.enums.business.SseEventTypeEnum;
import org.wcs.helper.SseHelper;
import org.wcs.model.pojo.serve.NotificationInfo;
import org.wcs.model.pojo.serve.RunningEventInfo;
import org.wcs.utils.AppStringUtils;
import org.wcs.utils.AppTimeUtils;

import java.time.LocalDateTime;

/**
 * 测试定时任务
 */
@RequiredArgsConstructor
public class TestQuartzJob implements Job {

    private final SseHelper sseHelper;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        System.out.println("测试定时任务");
        RunningEventInfo runningEventInfo = new RunningEventInfo();
        runningEventInfo.setEventTime(AppTimeUtils.formatLocalDatetime(LocalDateTime.now()));
        runningEventInfo.setEventMsg("测试数据");
        sseHelper.SendEventToAll(SseEventTypeEnum.RUNNING_INFO, AppStringUtils.objectToString(runningEventInfo));
        NotificationInfo notificationInfo = NotificationInfo.info("测试数据", "提示", 5000);
        sseHelper.SendEventToAll(SseEventTypeEnum.SYSTEM_INFO, AppStringUtils.objectToString(notificationInfo));

    }
}
