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
42
43
44
45
46
47
48
49
50
global class IsValidLicenseBatch implements Database.Batchable<sObject> {
    
    String query;
    Boolean IsNeedExecute = false; // 2021-03-10  mzy  WLIG-BYHD79  SFDC环境batch合并调查  是否符合执行条件
    
    global IsValidLicenseBatch() {
        
    }
    // 2021-03-10  mzy  WLIG-BYHD79  SFDC环境batch合并调查  start
    global IsValidLicenseBatch(Boolean NeedExecute) {
        this.IsNeedExecute = NeedExecute;
    }
    // 2021-03-10  mzy  WLIG-BYHD79  SFDC环境batch合并调查  end
    
    global Database.QueryLocator start(Database.BatchableContext BC) {
 
        return Database.getQueryLocator([select Id,Name,IsInquire__c from License_Information__c 
                                    where Is_Active_Formula__c = false
                                        AND IsInquire__c = false]);
    }
 
       global void execute(Database.BatchableContext BC, List<sObject> scope) {
           system.debug('licenseList__' + scope);
        List<License_Information__c> listLicense = new List<License_Information__c>();
        List<License_Information__c> licenseList = new List<License_Information__c>();
        licenseList = scope;
        
        for (License_Information__c li :licenseList) {
            li.IsInquire__c = true;
            listLicense.add(li);
        }
 
        if(licenseList.size() >0){
            update licenseList;
        }
    }
    
    global void finish(Database.BatchableContext BC) {
        //2021-03-05  mzy  WLIG-BYHD79  SFDC环境batch合并调查  start
        if(!Test.isRunningTest() &&IsNeedExecute==true){
            //batch里调用下一个batch时,希望跟原有的Schedule里面传的条数保持一致
            // 20220309 ljh  SFDC-CC73U5 132 动物实验&ET展箱 锁定已过期库存 start
            // Id execBTId = Database.executebatch(new ConsumAutoSelectBatch(true));
            Id execBTId = Database.executebatch(new SetOlympusCalendarWorkDayBatch(true),200);
            // 20220309 ljh  SFDC-CC73U5 132 动物实验&ET展箱 锁定已过期库存 end
        }
        //2021-03-05  mzy  WLIG-BYHD79  SFDC环境batch合并调查 end
    }
    
}