package com.ruoyi.gysl.regular;

import com.ruoyi.gysl.entity.Notice;
import com.ruoyi.gysl.service.NoticeService;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import javax.annotation.Resource;
import java.time.LocalDate;

/**
 * 每月固定时间定时任务
 * @author du
 * @since 2025/3/23 16:35
 */
@Configuration
@EnableScheduling
public class NoticeTiming {

    @Resource
    private NoticeService noticeService;

    /**
     * 每个月固定发一次政务通知
     */
    @Scheduled(cron = "0 0 0 1 * ?")
    private void configureTasks() {
        Notice notice = new Notice();
        notice.setType(1);
        notice.setContent(LocalDate.now().getYear() +
                "年"+
                LocalDate.now().getMonth().getValue()+
                "月"+
                "项目进展未填写");
        noticeService.save(notice);
    }
}
