global class OPDIsAccountBatch implements Database.Batchable<sObject> {
|
public String query;
|
public String Id;
|
global OPDIsAccountBatch() {
|
this.query = query;
|
}
|
global OPDIsAccountBatch(String Id) {
|
this.query = query;
|
this.Id = Id;
|
}
|
global Database.QueryLocator start(Database.BatchableContext bc) {
|
query = 'SELECT Id, Name,IsOPD_Account__c,Rental_Apply__c FROM Rental_Apply_Equipment_Set__c ';
|
query += ' WHERE (Bollow_Date__c > 2020-04-01 or createddate > 2020-03-31T23:59:59.000+0000 ) '+
|
' and IsOPD_Account__c = 1 and Cancel_Select__c = false ';
|
if(String.isNotBlank(this.Id)){
|
query += ' AND Rental_Apply__c = \''+this.Id+'\'';
|
}
|
return Database.getQueryLocator(query);
|
}
|
global void execute(Database.BatchableContext BC, list<Sobject> scope) {
|
List<Rental_Apply_Equipment_Set__c> RAES_objs = new List<Rental_Apply_Equipment_Set__c>();
|
RAES_objs = scope;
|
Map<String,Rental_Apply__c> raMap = new Map<String,Rental_Apply__c>();
|
if(RAES_objs.size()>0){
|
Boolean IsOPDAccountFlag = false;
|
for (Rental_Apply_Equipment_Set__c rAES_obj: RAES_objs) {
|
Rental_Apply__c ra= new Rental_Apply__c();
|
ra.Id = rAES_obj.Rental_Apply__c;
|
if(rAES_obj.IsOPD_Account__c !=null && rAES_obj.IsOPD_Account__c.intValue()==1){
|
ra.IsOPD_Account__c = 1;
|
}
|
if(!raMap.containsKey(rAES_obj.Rental_Apply__c)){
|
raMap.put(rAES_obj.Rental_Apply__c,ra);
|
}
|
}
|
if(raMap.size()>0){
|
List<Rental_Apply__c> raList = (List<Rental_Apply__c>)raMap.values();
|
update raList;
|
}
|
}
|
}
|
global void finish(Database.BatchableContext BC) {
|
}
|
public static void test1111111(){
|
integer i =0;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
i++;
|
|
}
|
}
|