高章伟
2022-02-24 2aa8da8af66aa8ae00f25831aed6bb0364176e7b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
 * 通过NFM601ControllerTest进行测试
 */
global class Sfdc2PoAccountBatch implements Database.Batchable<sObject>, Database.AllowsCallouts {
    public String query;
    public List < String > accountIdList;
 
    global Sfdc2PoAccountBatch() {
        this.query = query;
    }
    // 指定 客户Id集合
    global Sfdc2PoAccountBatch(List < String > accountIdList) {
        this.accountIdList = accountIdList;
    }
 
    global Database.QueryLocator start(Database.BatchableContext bc) {
        if (accountIdList != null && accountIdList.size() > 0) {
            return Database.getQueryLocator([SELECT Id, RecordTypeId, Is_Active_Formula__c,AwaitToSendAWS__c
                    
                    FROM Account 
                    WHERE Id IN:accountIdList
                    ]);
        } else {
            // return Database.getQueryLocator(
            //      [SELECT Id, RecordTypeId,Is_Active_Formula__c,AwaitToSendAWS__c
                    
            //         FROM Account WHERE AwaitToSendAWS__c = true OR (RecordTypeId= '01210000000Qem1AAC' AND Ban_On_Use_Date__c = :Date.today()-1)
            //     ]);
                
                // 批量发送历史数据 Start
                return Database.getQueryLocator(
                 [SELECT Id, RecordType_DeveloperName__c, RecordTypeId,
                    Sap2sfdcDealers_ModifycationLogo__c, Is_Active_Formula__c,
                    ContractSfdc2SapLog__c,AwaitToSendAWS__c
                    FROM Account WHERE (RecordTypeId = '01210000000QemGAAS' OR RecordTypeId = '01210000000Qem1AAC') AND Is_Active_Formula__c = '有效'
                ]);
                // );
                // 批量发送历史数据 End
               
               //临时 发送给 AWS
               // [SELECT Id, RecordType_DeveloperName__c, RecordTypeId,
               //      Sap2sfdcDealers_ModifycationLogo__c, Is_Active_Formula__c,
               //      ContractSfdc2SapLog__c,AwaitToSendAWS__c
               //      FROM Account WHERE (RecordTypeId = '01210000000Qem1AAC') AND Is_Active_Formula__c = '有效'
               //  ]);
        }
    }
 
    global void execute(Database.BatchableContext BC, List < Account > accountList) {
 
        List < String > accIdList = new List < String > ();
        for (Account account: accountList) {
            accIdList.add(account.Id);
        }
 
        if (accIdList.size() > 0) {
            NFM601Controller.executefuture(null, accIdList);
        }
 
 
 
        // List < String > accIdList = new List < String > ();
        // for (Account account: accountList) {
        //     account.AwaitToSendAWS__c = false;
        //     accIdList.add(account.Id);
        // }
 
        // if (accIdList.size() > 0) {
 
        //     NFM601Controller.executefuture(null, accIdList);
        //     update accountList;
 
        // }
        
    }
 
    global void finish(Database.BatchableContext BC) {
    }
}