global class NFM402Batch implements Database.Batchable, Database.AllowsCallouts { public String query; global NFM402Batch() { this.query = query; } 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 scope) { List qisList = [ select id from QIS_Report__c where AsyncData__c = true and (Complaint_Number__c = null or Complaint_Number__c = '') ]; Set tempids = new Set(); 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 ids = new List(); for (String id : tempids ) { ids.add(id); } try { if (ids.size()>0) { NFM402Controller.sendRequest(ids); } } catch (Exception e) { System.debug(e.getStackTraceString()); } } global void finish(Database.BatchableContext BC) { // if (Test.isRunningTest() == false) { //update by rentongxiao 生成PDF // Database.executeBatch(new RepairToPDFBatch(), 100); // Database.executeBatch(new RepairToPDFBatch(), 50); // } } }