/** * 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); } } }