global class NFM402Batch implements Database.Batchable, 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 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); } // 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); // } } }