高章伟
2022-02-24 2aa8da8af66aa8ae00f25831aed6bb0364176e7b
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
40
41
/**
 * Created by shentianyi on 2019/08/07.
 */
 
global class ET_Batch3_Scheduler implements Schedulable {
    private final Integer BATCH_SIZE = 200;
 
    // 毎週一回実行します 過去残りの10月分の実績
    // system.schedule('ET_Batch_Transaction','0 0 5 ? * 7', new ET_Batch3_Scheduler());
    global void execute(SchedulableContext ctx) {
        Date date_limit_h = Date.today().addDays(-1).addMonths(-2);
        // 经销商实绩Batchと直销实绩Batch 過去10月分
        for (Integer index = 0; index < 10; index++) {
            ET_Agency_Target_Result_Table_Batch bat = new ET_Agency_Target_Result_Table_Batch ();
            bat.isAllFlag = true;
            bat.cstYear = date_limit_h.year();
            bat.cstMonth = date_limit_h.month();
            Database.executeBatch(bat, BATCH_SIZE);
 
            ET_Agency_Target_Result_Table_Batch2 bat2 = new ET_Agency_Target_Result_Table_Batch2 ();
            bat2.isAllFlag = true;
            bat2.cstYear = date_limit_h.year();
            bat2.cstMonth = date_limit_h.month();
            Database.executeBatch(bat2, BATCH_SIZE);
 
            ET_Product_ScoreTableHistory_Batch2 bat3 = new ET_Product_ScoreTableHistory_Batch2 ();
            bat3.isAllFlag = true;
            bat3.cstYear = date_limit_h.year();
            bat3.cstMonth = date_limit_h.month();
            Database.executeBatch(bat3, BATCH_SIZE);
 
            ET_Product_ScoreTableHistory_Batch3 bat4 = new ET_Product_ScoreTableHistory_Batch3 ();
            bat4.isAllFlag = true;
            bat4.cstYear = date_limit_h.year();
            bat4.cstMonth = date_limit_h.month();
            Database.executeBatch(bat4, BATCH_SIZE);
 
            date_limit_h = date_limit_h.addMonths(-1);
        }
    }
}