package me.zhengjie.modules.quartz.task;
|
|
import lombok.RequiredArgsConstructor;
|
import lombok.extern.slf4j.Slf4j;
|
import me.zhengjie.modules.quartz.service.impl.CapitalServiceImpl;
|
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.stereotype.Service;
|
|
import java.text.ParseException;
|
import java.text.SimpleDateFormat;
|
import java.util.Calendar;
|
|
/**
|
* 月报定时任务,每月初执行
|
*/
|
@Slf4j
|
@Service
|
@RequiredArgsConstructor
|
@Async
|
public class CapitalMethod {
|
|
private final CapitalServiceImpl capitalService;
|
|
public void getCapital() throws ParseException {
|
// 日历类
|
Calendar cal = Calendar.getInstance();
|
cal.add(Calendar.MONTH, -1);
|
// 格式化日期
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
// 目标年月
|
String targetYearMonth = sdf.format(cal.getTime());
|
// 调用方法
|
capitalService.getCapitalInfo(null, targetYearMonth);
|
}
|
}
|