global class CloseTaskUpdateBatch implements Database.Batchable { List userIds = new List(); global CloseTaskUpdateBatch(List uIds){ userIds = uIds; } global Database.QueryLocator start(Database.BatchableContext BC) { //查询离职人员下未完成/取消的任务 String query = 'SELECT Id,Name,taskStatus__c,assignee__c FROM task__c ' +'WHERE assignee__c IN :userIds ' +'AND taskStatus__c NOT IN (\'03 完成\',\'07 未执行\')'; return Database.getQueryLocator(query); } global void execute(Database.BatchableContext BC, List scope) { List updateList = new List(); List tasks = scope; for (task__c task : tasks) { task.taskStatus__c = '06 关闭'; updateList.add(task); System.debug('status------'+task.taskStatus__c); } update updateList; } global void finish(Database.BatchableContext BC) { // } }