liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
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
/* 2021-07-29  mzy  
*  勾选 服务合同报告书上的是否已过或当前季度
*  报告书的季度开始日小于今天 , 已过或当前季度 未勾选
*/
global class UpdateNewMaintenanceTaskBatch implements Database.Batchable<sObject> {
    Boolean IsNeedExecute = false;
 
    global UpdateNewMaintenanceTaskBatch() {
        
    }
 
    global UpdateNewMaintenanceTaskBatch(Boolean NeedExecute) {
        this.IsNeedExecute = NeedExecute;
    }
 
    global Database.QueryLocator start(Database.BatchableContext bc) {        
        Date today = Date.today();
        String query = 'SELECT Id,OverOrCurrent__c FROM NewMaintenanceReport_Task__c where Distribution_Start_Date__c <= :today  And OverOrCurrent__c = false';
        return Database.getQueryLocator(query);
    }
 
    global void execute(Database.BatchableContext BC, list<NewMaintenanceReport_Task__c> NMCReportT) {
        //勾选   已过或当前季度
        for(NewMaintenanceReport_Task__c tempMCT:NMCReportT){
            tempMCT.OverOrCurrent__c = true;
        }
 
        update NMCReportT;
    }
 
    global void finish(Database.BatchableContext BC) {
 
    }
}