public class DecrptUpsertAgencyContact implements Schedulable { private String json_list; private String acList; private String sobject_name; public DecrptUpsertAgencyContact(string json_list,string acList,string sobject_name) { this.json_list = json_list; this.acList = acList; this.sobject_name = sobject_name; } public void execute(SchedulableContext sc) { // 在这里执行您的定时任务逻辑 System.debug('success enter DecrptUpsertAgencyContact Schedulable'); if(!Test.isRunningTest()){ AwsServiceTool2V2.EncryptPushFutureV2(json_list,acList, sobject_name); } // 取消任务的后续执行 System.abortJob(sc.getTriggerId()); } public static void assignOnceOneMinuteLater(String json_list,String acList,String sobject_name) { Datetime oneMinuteLaterTime = Datetime.now().addminutes(1); String hour = String.valueOf(oneMinuteLaterTime.hour()); String min = String.valueOf(oneMinuteLaterTime.minute()); String ss = String.valueOf(oneMinuteLaterTime.second()); String nextFireTime = ss + ' ' + min + ' ' + hour + ' * * ?'; DecrptUpsertAgencyContact scheduledJob = new DecrptUpsertAgencyContact(json_list,acList,sobject_name); System.debug('延迟一分钟执行'); //String uuid = generateUUID(); String year = String.valueOf(Datetime.now().year()); String month = String.valueOf(Datetime.now().month()); String day = String.valueOf(Datetime.now().day()); String t = year + month + day + hour + min; String uuid = generateUUID().substring(3); System.schedule(('DecrptUpsertAgencyContact' + t + uuid ), nextFireTime, scheduledJob); } public static String generateUUID() { String uid = ''; for (Integer i = 0; i < 8; i++) { Integer randomInt = Math.abs(Crypto.getRandomInteger()); uid += String.valueOf(randomInt).substring(0, 4); } return uid; } }