global class NFM402Batch implements Database.Batchable<sObject>, Database.AllowsCallouts {
|
public String query;
|
|
// public BatchIF_Log__c iflog;
|
global NFM402Batch() {
|
this.query = query;
|
// iflog = new BatchIF_Log__c();
|
// iflog.Type__c = 'NFM402Batch';
|
}
|
|
global Database.QueryLocator start(Database.BatchableContext bc) {
|
query = 'select id from Repair__c where AsyncData__c = true and (Complaint_Number__c = null or Complaint_Number__c = \'\')';
|
return Database.getQueryLocator(query);
|
}
|
|
global void execute(Database.BatchableContext BC, list<Repair__c> scope) {
|
List<QIS_Report__c> qisList = [
|
select id from QIS_Report__c where AsyncData__c = true and (Complaint_Number__c = null or Complaint_Number__c = '')
|
];
|
Set<String> tempids = new Set<String>();
|
if (scope.size() > 0) {
|
for(Repair__c rep : scope){
|
tempids.add(rep.Id);
|
}
|
}
|
if (qisList.size() > 0) {
|
for (QIS_Report__c qis : qisList) {
|
tempids.add(qis.Id);
|
}
|
}
|
List<String> ids = new List<String>();
|
for (String id : tempids ) {
|
ids.add(id);
|
}
|
// iflog.Log__c = 'ids '+ids;
|
|
try {
|
if (ids.size()>0) {
|
NFM402Controller.sendRequest(ids);
|
}
|
}
|
catch (Exception e) {
|
// iflog.Log__c += 'e:: '+e.getMessage();
|
// iflog.Log__c += 'e:getCause: '+e.getCause();
|
System.debug(e.getStackTraceString());
|
}
|
// insert iflog;
|
|
}
|
|
global void finish(Database.BatchableContext BC) {
|
// if (Test.isRunningTest() == false) {
|
//update by rentongxiao 生成PDF
|
// Database.executeBatch(new RepairToPDFBatch(), 100);
|
// Database.executeBatch(new RepairToPDFBatch(), 50);
|
// }
|
|
}
|
}
|