高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
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
global class RentalQueueShippmentDate0Batch implements Database.Batchable<sObject> {
    public String query;
 
    global RentalQueueShippmentDate0Batch() {
        this.query = query;
    }
 
    global Database.QueryLocator start(Database.BatchableContext bc) {
        query = 'select Id,QueueShippmentDate__c FROM Rental_Apply__c where Queue_Count__c > 0 AND QueueShippmentDate__c != null';
        return Database.getQueryLocator(query);
    }
 
    global void execute(Database.BatchableContext BC, list<Sobject> scope) {
        // 清空有排队明细的申请书汇总
        List<Rental_Apply__c> claerRaList = scope;
        for(Rental_Apply__c ra:claerRaList){
            ra.QueueShippmentDate__c = null;
        }
        update claerRaList;
        // 清空排队中有 排队备品预计出库时间 一览
        // 排队备品预计出库时间  QueueShippmentDate__c
        // 回寄日 Asset_return_Day__c
        // 欠品OK时间  Lost_item_check_OK__c
        // 排队备品预计明细    QueueDetail__c
        List<Rental_Apply_Equipment_Set__c> claerRaeList = [select Id,
                                                QueueShippmentDate__c,
                                                Asset_return_Day__c,
                                                Lost_item_check_OK__c,
                                                QueueDetail__c
                                                 from Rental_Apply_Equipment_Set__c  where  Rental_Apply__c in:claerRaList AND QueueShippmentDate__c != null and First_RAESD__r.RAESD_Status__c = '排队中'];
        for(Rental_Apply_Equipment_Set__c rae:claerRaeList){
            rae.QueueShippmentDate__c = null;
            rae.Asset_return_Day__c = null;
            rae.Lost_item_check_OK__c = null;
            rae.QueueDetail__c = '';
        }
        update claerRaeList;
        
    }
 
    global void finish(Database.BatchableContext BC) {
        database.executebatch(new RentalQueueShippmentDateBatch(),50);
    }
}