BAOLH
2025-05-21 b84e5ae5d2301b3ca4389f9a971ce3ad6e6a4e51
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
36
37
38
39
package me.zhengjie.modules.quartz.task;
 
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.temporal.WeekFields;
 
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
 
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.project.service.ProjectProgressService;
 
/**
 * 钉钉定时任务(取考勤记录)
 */
@Service
@RequiredArgsConstructor
@Async
public class WeekReportMethod {
 
    private final ProjectProgressService projectProgressService;
 
    /**
     * 生成周报
     * @throws Exception
     */
    public void createWeekReport() throws Exception {
 
        // 当年第一周需满足四天。(例:2022年的第一周是从1月3号开始的,1号和2号并入到2021年度的最后一周里)
        WeekFields wfs = WeekFields.of(DayOfWeek.MONDAY, 4);
        // 取得当周的周一
        LocalDate localDate = LocalDate.now().with(wfs.dayOfWeek(), 1L);
 
        int year = localDate.minusDays(7).get(wfs.weekBasedYear());
        int weeks = localDate.minusDays(7).get(wfs.weekOfWeekBasedYear());
 
        projectProgressService.autoGenerateProjectProcess(localDate, year, weeks);
    }
}