批处理作业的运行的sObject两次

问题描述 投票:0回答:1

我有在我的批处理作业的运行记录两次的问题,有人可以告诉我,我该如何检查?

global class SVMXC_BatchCallClosureGlobal implements Database.Batchable<sObject>, Database.AllowsCallouts {

    public String query = 'SELECT Id, Case__c, Case__r.Sales_Organisation_From_IP__c, Re_Update__c, SVMXC_Batch_Picked_Up__c, Result__c,SVMX_Retry_XML__c, CreatedDate ' +
                          'FROM OutBoundMWLog__c ' +
                          'WHERE ((SVMXC_Batch_Picked_Up__c = false AND Result__c = null) ' +
                          'OR Re_Update__c = false OR SVMX_Retry_XML__c =true) and Case__r.Sales_Organisation_From_IP__c IN :globalSap';

    Set<String>globalSap = new Set<String>();
    List<Sales_Org_with_Region_and_Country__c> settingValues = Sales_Org_with_Region_and_Country__c.getall().values();

    public SVMXC_BatchCallClosureGlobal() {
        for (Sales_Org_with_Region_and_Country__c setting : settingValues) {
            if (setting.SAP_Application__c != null && setting.SAP_Application__c.equals('Global SAP')) {
                globalSap.add(setting.Sales_Org__c);
            }
        }
    }

    global Database.Querylocator start(Database.BatchableContext BC) {
        return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext BC, List <sObject> scope) {
        Set<Id> caseIdSetforGlobal = new Set<Id>();
        Set<Id> caseIdSet = new Set<Id>();

        DateTime now = system.now().addMinutes(-3);

        for (OutBoundMWLog__c obound : (List<OutBoundMWLog__c>) scope) {
            if (obound.CreatedDate <= now || Test.isRunningTest()) {
                obound.SVMXC_Batch_Picked_Up__c = true;
                obound.Re_Update__c = true;
                caseIdSet.add(obound.Case__c);
            }
        }

        //Query for the case's Sales organisation from the caseIdSet.
        List<Case> caseList = new List<Case>([select id, Sales_Organisation_From_IP__c from case where id in: caseIdSet]);
        for (Case cs : caseList) {
            if (globalSap.contains(cs.Sales_Organisation_From_IP__c)) {
                caseIdSetforGlobal.add(cs.id);
            }
        }

        system.debug('******caseIdSetforGlobal*********' + caseIdSetforGlobal);

        if (!caseIdSetforGlobal.isEmpty()) {
            ServiceMaxPBIntegrationGlobal.ProcessFile(caseIdSetforGlobal);
        }

        update scope;
    }
}
salesforce batch-processing apex
1个回答
0
投票

如果批量作业正在运行一次以上,这意味着它已经从别的地方调用。

突出一定的可能性:

  • 它可能是一个触发器,工作流程或过程建设者谁可以调用它。
  • 它可能已被安排定期运行。
  • 它可以从可以从你的代码中调用电子邮件服务监听器被调用。
© www.soinside.com 2019 - 2024. All rights reserved.