/**
 * *
    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 LexReturnDeliverySlipController {
    @AuraEnabled
    public static InitData init(String recordId){
        InitData res = new InitData();
        try {
            List<Rental_Apply__c> raList = [SELECT Id, Name, Rental_Apply_Equipment_Set_Cnt__c, Loaner_received_ng_num__c from Rental_Apply__c where Id = :recordId];
            
            if(raList.size()>0){
                Rental_Apply__c ra = raList[0];
                if(ra.Rental_Apply_Equipment_Set_Cnt__c > 0){
                    List<Rental_Apply_Equipment_Set_Detail__c> raSet = [SELECT Id, Name from Rental_Apply_Equipment_Set_Detail__c WHERE Received_Confirm_F__c = 'NG' AND Cancel_Select__c = false AND Rental_Apply__c = :recordId];
                    res.raeSet = raSet;
                }
                res.name = ra.Name;
                res.rentalApplyEquipmentSetCnt = Integer.valueOf(ra.Rental_Apply_Equipment_Set_Cnt__c);
                res.loanerReceivedNgNum = Integer.valueOf(ra.Loaner_received_ng_num__c);   
            }
            
        }
        catch (Exception e) {
            system.debug('INFO****' + e);
        }
        return res;
    }

    public class InitData{
        @AuraEnabled
        public Integer rentalApplyEquipmentSetCnt;
        @AuraEnabled
        public Integer loanerReceivedNgNum;
        @AuraEnabled
        public String name;
        @AuraEnabled
        public List<Rental_Apply_Equipment_Set_Detail__c> raeSet;
    }
}