global class CloseTaskUpdateBatch implements Database.Batchable<sObject> {
    List<String> userIds = new List<String>();
    global CloseTaskUpdateBatch(List<String> 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<sObject> scope) {
        List<task__c> updateList = new List<task__c>();
        List<task__c> 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) {
        //
    }
}