twysparks
2023-05-24 f0adfc7326311c6ba40281ffe48437d41a79bd32
force-app/main/default/classes/buttonOnCallCtl.cls
@@ -7,9 +7,21 @@
    public static InitData init(String recordId){
        InitData res = new initData();
        try{
            On_Call__c report =  [SELECT Id FROM On_Call__c WHERE Id =: recordId LIMIT 1];
            On_Call__c report =  [SELECT Id,Name,Oncall_Equipment__r.Id,segment__r.Id,segment__c,HP__c,HospitalId__c,Salesdepartment_HP_ID__c,Salesdepartment_HP__c,Oncall_Equipment__c,Trable_occur_daY_collect_c__c FROM On_Call__c WHERE Id =: recordId LIMIT 1];
            System.debug(LoggingLevel.INFO, '*** opp: ' + report);
            res.Id = report.Id;
            res.Name = report.Name;
            res.SegmentC = report.segment__c;
            res.SegmentId = report.segment__r.Id;
            res.HPC = report.HP__c;
            res.HospitalIdC = report.HospitalId__c;
            res.SalesdepartmentHPIDC = report.Salesdepartment_HP_ID__c;
            res.SalesdepartmentHPC = report.Salesdepartment_HP__c;
            res.OncallEquipmentC = report.Oncall_Equipment__c;
            res.OncallEquipmentId = report.Oncall_Equipment__r.Id;
            res.TrableOccurdaYCollectC = report.Trable_occur_daY_collect_c__c;
            res.userID = UserInfo.getUserId();
            System.debug(LoggingLevel.INFO, '*** res: ' + res);
        }catch(Exception e){
@@ -18,8 +30,62 @@
        return res;
    }   
    @AuraEnabled
    public static List<Account> selecctAccountBySegmentId(String segmentId){
        try {
          List<Account> accounts = [SELECT ParentId,Parent.RecordTypeId,Parent.RecordType_DeveloperName__c ,Parent.Parent.FSE_GI_Main_Leader__c, Parent.Parent.FSE_GI_Main_Leader__r.Name,Parent.Parent.FSE_SP_Main_Leader__r.Name,Parent.Parent.FSE_SP_Main_Leader__c FROM Account WHERE Id=: segmentId];
          return accounts;
      } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
         }
     }
     @AuraEnabled
     public static List<Account> selecctAccountBySegmentId02(String segmentId){
         try {
           List<Account> accounts = [SELECT id,ParentId,Parent.RecordTypeId,Parent.RecordType_DeveloperName__c, Parent.Parent.FSE_GI_Main_Leader__r.Work_Location__c,Parent.Parent.FSE_SP_Main_Leader__r.Work_Location__c FROM Account WHERE Id=: segmentId];
           return accounts;
       } catch (Exception e) {
             throw new AuraHandledException(e.getMessage());
          }
      }
       // 查找UserName
    @AuraEnabled
    public static List<User> initUserName(String userId){
        List<User> res = new List<User>();
        try{
            res = [SELECT Id,name,RepairSalesPoint_Province_China__c,Employee_No__c FROM User WHERE Id=: userId ];
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }
    public class InitData{
        @AuraEnabled
        public String Id;
        @AuraEnabled
        public String Name;
        @AuraEnabled
        public String SegmentC;
        @AuraEnabled
        public String HPC;
        @AuraEnabled
        public String HospitalIdC;
        @AuraEnabled
        public String SalesdepartmentHPIDC;
        @AuraEnabled
        public String SalesdepartmentHPC;
        @AuraEnabled
        public String OncallEquipmentC;
        @AuraEnabled
        public Date TrableOccurdaYCollectC;
        @AuraEnabled
        public String userID;
        @AuraEnabled
        public String SegmentId;
        @AuraEnabled
        public String OncallEquipmentId;
     }
}