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
/**
 * *
    ODescription:
    GAuthor: sun xia
    @Date: 2023-07-11 15:31:56
    GIastEditors: sun xia
    @IastEditTime: 2023-07-11 15:31:56
 * */
public with sharing class LexAllReceivedFseController {
    @AuraEnabled
    public static InitData init(String recordId){
        InitData res = new InitData();
        try{
            List<Rental_Apply__c> raList = [SELECT Id, Loaner_received_ng_num__c from Rental_Apply__c where Id = :recordId];
            if(raList.size()>0){
                Rental_Apply__c ra = raList[0];
                res.id = ra.Id;
                res.loanerReceivedNgNum = Integer.valueOf(ra.Loaner_received_ng_num__c); 
            }
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '****e:' + e);
        }
        return res;
    }
 
    @AuraEnabled
    public static String getRaeSet(String recordId){
        List<Rental_Apply_Equipment_Set__c> raeList = [SELECT Id, RAES_Status__c, Loaner_received_time__c from Rental_Apply_Equipment_Set__c WHERE Rental_Apply__c = :recordId];
        List<Rental_Apply_Equipment_Set__c> updateList = new List<Rental_Apply_Equipment_Set__c>();
        for(Integer i=0; i<raeList.size(); i++){
            System.debug('状态打印:'+raeList[i].RAES_Status__c);
            if(raeList[i].Loaner_received_time__c == null && raeList[i].RAES_Status__c == '已出库'){
                Rental_Apply_Equipment_Set__c tempRAE = new Rental_Apply_Equipment_Set__c();
                tempRAE.Id = raeList[i].Id;
                tempRAE.Received_Confirm__c = 'OK';
                updateList.add(tempRAE);
            }
        }
 
        if(updateList.size()>0){
            try {
                Update updateList;
                return 'SUCCESS';
            }
            catch (Exception e) {
                return e.getMessage();
            }            
        }
 
        return '不存在更新明细';
    }
 
    public Class InitData{
        @AuraEnabled
        public String id;
        @AuraEnabled
        public Integer loanerReceivedNgNum;
    }
}