buli
2023-06-05 3962c2bb0435484b60a3e408e4738d792e249a53
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
public without sharing class LexLicenceReminderController {
    
    @AuraEnabled
    public static Results initReminder(){
        Results results = new Results();
        try {
            User useracc = [SELECT AccountId, Work_Location__c,UserPro_Type__c FROM user WHERE id =:UserInfo.getUserId()];
            String accountId = useracc.AccountId;
            List<Account> accList = [SELECT Name,Medical_Equipment_Expiration_Date__c FROM Account WHERE Id =:accountId];
            Account accountInfo = new Account();
            if(accList.size() == 1){
                accountInfo = accList[0];
            }else{
                results.result = 'Fail';
                results.isShowReminder = false;
                results.errorMsg = '未获取到经销商信息';
                return results;
            }
            if(accountInfo.Medical_Equipment_Expiration_Date__c != null){
                Integer days = LexUtility.getLicenceReminderDays();
                Date today = Date.today();
                // Date today = Date.newInstance(2024, 7, 21);
                Integer numberDaysDue = today.daysBetween(accountInfo.Medical_Equipment_Expiration_Date__c);
                if(numberDaysDue > days){
                    results.isShowReminder = false;
                }else{
                    results.isShowReminder = true;
                    results.days = numberDaysDue;
                }
                results.result = 'Success';
            }else {
                results.result = 'Fail';
                results.errorMsg = '未获取到医疗器械经营企业许可证有效期限';
            }
        } catch (Exception e) {
            results.result = 'Fail';
            results.isShowReminder = false;
            results.errorMsg = e.getLineNumber()+'---'+e.getMessage();
        }
        return results;
    }
 
    public class Results {
        @AuraEnabled
        public String result;
        @AuraEnabled
        public String errorMsg;
        @AuraEnabled
        public Boolean isShowReminder;
        @AuraEnabled
        public Integer days;
    }
}