Salesforce Apex-可调度类无法执行可批处理类

Salesforce Apex-可调度类无法执行可批处理类,salesforce,apex,Salesforce,Apex,我在编写一个可批处理和可调度的Apex类时遇到了问题。基本上,可调度类不会调用可批处理类来运行其中的代码。以下是我写的: rw_billingVoiceCreationSchedulable.apxc global class rw_BillingInvoiceCreationSchedulable implements Schedulable { global void execute(SchedulableContext sc) { System.debug('Bat

我在编写一个可批处理和可调度的Apex类时遇到了问题。基本上,可调度类不会调用可批处理类来运行其中的代码。以下是我写的:

rw_billingVoiceCreationSchedulable.apxc

global class rw_BillingInvoiceCreationSchedulable implements Schedulable {
    global void execute(SchedulableContext sc) {
        System.debug('Batchable queued for execution');
        rw_BillingInvoiceCreationBatchable b = new rw_BillingInvoiceCreationBatchable();
        Id batchId = Database.executeBatch(b);
        System.debug('Batchable was executed: ' + JSON.serialize(b));
    }
}
global class rw_BillingInvoiceCreationBatchable implements Database.batchable<SObject> {

    global Database.QueryLocator start(Database.BatchableContext BC) {
        System.debug('Batch Apex called');
        Date closingTime = date.today().toStartOfWeek();
        return Database.getQueryLocator([SELECT Id, Name, rw_Batch_Sequence__c, rw_End_Date__c, rw_Closed__c, rw_Customer__c, rw_Start_Date__c, rw_Warehouse__c
                                        FROM rw_Invoice_Batch__c
                                        WHERE rw_Closed__c = FALSE]);
        // AND rw_End_Date__c < :closingTime
    }

    global void execute(Database.BatchableContext info, List<rw_Invoice_Batch__c> scope) {
        System.debug('Invoices about to be updated');
        List<rw_Invoice_Batch__c> invoices = new List<rw_Invoice_Batch__c>();
        List<Account> activeCustomers = [SELECT Id, Name
                                         FROM Account
                                         WHERE Inventory_Management__c = TRUE OR Order_Management__c = TRUE];
        for(rw_Invoice_Batch__c i : scope) {
            i.rw_Closed__c = TRUE;
            invoices.add(i);
            rw_InvoiceGenerator.generateInvoice(i);
        }
        update invoices;
        System.debug('Invoices updated to closed');
    }

    global void finish(Database.BatchableContext BC) {

    }
}
rw\u billingVoiceCreationBatchable.apxc

global class rw_BillingInvoiceCreationSchedulable implements Schedulable {
    global void execute(SchedulableContext sc) {
        System.debug('Batchable queued for execution');
        rw_BillingInvoiceCreationBatchable b = new rw_BillingInvoiceCreationBatchable();
        Id batchId = Database.executeBatch(b);
        System.debug('Batchable was executed: ' + JSON.serialize(b));
    }
}
global class rw_BillingInvoiceCreationBatchable implements Database.batchable<SObject> {

    global Database.QueryLocator start(Database.BatchableContext BC) {
        System.debug('Batch Apex called');
        Date closingTime = date.today().toStartOfWeek();
        return Database.getQueryLocator([SELECT Id, Name, rw_Batch_Sequence__c, rw_End_Date__c, rw_Closed__c, rw_Customer__c, rw_Start_Date__c, rw_Warehouse__c
                                        FROM rw_Invoice_Batch__c
                                        WHERE rw_Closed__c = FALSE]);
        // AND rw_End_Date__c < :closingTime
    }

    global void execute(Database.BatchableContext info, List<rw_Invoice_Batch__c> scope) {
        System.debug('Invoices about to be updated');
        List<rw_Invoice_Batch__c> invoices = new List<rw_Invoice_Batch__c>();
        List<Account> activeCustomers = [SELECT Id, Name
                                         FROM Account
                                         WHERE Inventory_Management__c = TRUE OR Order_Management__c = TRUE];
        for(rw_Invoice_Batch__c i : scope) {
            i.rw_Closed__c = TRUE;
            invoices.add(i);
            rw_InvoiceGenerator.generateInvoice(i);
        }
        update invoices;
        System.debug('Invoices updated to closed');
    }

    global void finish(Database.BatchableContext BC) {

    }
}
全局类rw\u billingVoiceCreationBatchable实现Database.batchable{
global Database.QueryLocator启动(Database.BatchableContext BC){
调试('Batch-Apex-called');
Date closingTime=Date.today().toStartOfWeek();
return Database.getQueryLocator([选择Id、名称、rw\U批处理顺序、rw\U结束日期、rw\U关闭日期、rw\U客户日期、rw\U开始日期、rw\U仓库日期]
来自rw\U发票\U批次\U c
其中rw_闭合(c=FALSE));
//和rw_End_Date__c<:closingTime
}
全局void execute(Database.BatchableContext信息,列表范围){
System.debug(“即将更新的发票”);
列表发票=新列表();
List activeCustomers=[选择Id、名称]
从帐户
其中,库存管理=TRUE或订单管理=TRUE];
适用于(rw\ U发票\批次\ c i:范围){
i、 rw_Closed_uc=真;
发票。添加(i);
rw_发票生成器。生成发票(i);
}
更新发票;
系统调试(“发票更新为已关闭”);
}
全局void完成(Database.BatchableContext BC){
}
}

就测试类而言,我可以确认Batchable类正在工作。我运行了它的测试类,它总是返回成功,但是对于可调度类,测试类或实际运行它总是会产生相同的结果:没有。我不确定是否存在允许代码运行的任何限制或调整,但我愿意接受关于它是什么的任何建议或想法。

您如何安排这项工作?或者这只是测试上下文中的问题?