baolhyhzhg
2025-01-15 42532b2c12d2937cd60e13e400a7be5e25ce5269
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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);
    }
}