| | |
| | | global class NFM402Batch implements Database.Batchable<sObject>, Database.AllowsCallouts { |
| | | //20230203 lt 计划的作业优化 --- 继承加“, Database.Stateful”,不然removeOtherSc方法空指针 |
| | | global class NFM402Batch implements Database.Batchable<sObject>, Database.AllowsCallouts, Database.Stateful { |
| | | public String query; |
| | | |
| | | // public BatchIF_Log__c iflog; |
| | | //20230203 lt 计划的作业优化 一小时两次 start |
| | | private BatchEmailUtil.ScBean scB1; |
| | | //20230203 lt 计划的作业优化 一小时两次 end |
| | | |
| | | global NFM402Batch() { |
| | | this.query = query; |
| | | // iflog = new BatchIF_Log__c(); |
| | | // iflog.Type__c = 'NFM402Batch'; |
| | | } |
| | | |
| | | global Database.QueryLocator start(Database.BatchableContext bc) { |
| | | |
| | | //20230203 lt 计划的作业优化 一小时两次 start |
| | | scB1 = BatchEmailUtil.setSc1('NFM402Schedule', 0, 23, 0, '0 30 *', null); |
| | | if (System.Test.isRunningTest() == false) { |
| | | for(CronTrigger ct : [SELECT Id FROM CronTrigger WHERE CronJobDetail.Name =: scB1.scName]) { |
| | | System.abortJob(ct.Id); |
| | | } |
| | | system.schedule(scB1.scName, scB1.scTime, new NFM402Schedule()); |
| | | } |
| | | //20230203 lt 计划的作业优化 一小时两次 end |
| | | |
| | | query = 'select id from Repair__c where AsyncData__c = true and (Complaint_Number__c = null or Complaint_Number__c = \'\')'; |
| | | return Database.getQueryLocator(query); |
| | | } |
| | |
| | | for (String id : tempids ) { |
| | | ids.add(id); |
| | | } |
| | | // iflog.Log__c = 'ids '+ids; |
| | | |
| | | try { |
| | | if (ids.size()>0) { |
| | |
| | | } |
| | | } |
| | | 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) { |
| | | BatchEmailUtil.removeOtherSc('NFM402Schedule', scB1.scName); //20230203 lt 计划的作业优化 |
| | | // if (Test.isRunningTest() == false) { |
| | | //update by rentongxiao 生成PDF |
| | | // Database.executeBatch(new RepairToPDFBatch(), 100); |