package com.bonus.sgzb.material.remind;

import com.bonus.sgzb.common.core.utils.StringUtils;
import com.bonus.sgzb.material.remind.service.CalcMonthlyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class Inform {

	@Autowired
	private CalcMonthlyService calcMonthlyService;

	@Value("${sgzb.job.settlementJobDay}")
	private String settlementJobDay;

//	@Scheduled(cron = "0 */5 * * * ? ") // 间隔5分钟执行
	@Scheduled(cron = "${sgzb.job.settlementJobCron}")  // 结算日次日凌晨执行
	@Async
	public void taskCycle() {
		System.out.println("===springMVC定时器启动====");
		try {

			if (StringUtils.isEmpty(settlementJobDay)) {
				calcMonthlyService.calcMonthInfo(1);
			} else {
				int calDay = Integer.parseInt(settlementJobDay);
				calcMonthlyService.calcMonthInfo(calDay);
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println("===springMVC定时器结束====");
	}

}