liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
public with sharing class lexSolutionProgrammeController {
    @AuraEnabled
    public static InitData initSubmitSolutionSchemeForApprovalButton(String recordId){
        InitData res = new InitData();
        try {
            Solution_Programme__c so = [
                select
                Scheme_Type__c,
                Confirmation_Result__c
                from Solution_Programme__c where Id =: recordId
            ];
            res.schemeType = so.Scheme_Type__c;
            res.confirmationResult = so.Confirmation_Result__c;
        } catch (Exception e) {
            System.debug(e.getMessage());
        }
        return res;
    }
    @AuraEnabled
    public static List<solutionClosingAttachment__c> queryForAttachments(String Id){
        List<solutionClosingAttachment__c> so = new List<solutionClosingAttachment__c>();
        try {
            so = [select id,name from solutionClosingAttachment__c where Solution_Programme__c =: Id];
        } catch (Exception e) {
            System.debug(e.getMessage());
        }
        return so;
    }
 
    @AuraEnabled
    public static string updateSubmitSolutionSchemeForApprovalButton(String recordId){
        Solution_Programme__c so = new Solution_Programme__c();
        try {
            so.Id = recordId;
            so.Submint_TF__c = true;
            update so;
            return '';
        } catch (Exception e) {
            if (e.getMessage().contains(',')) {
                System.debug(LoggingLevel.INFO, '*** e: ' + e);
                String exc = '' + e.getMessage();
                Integer left = exc.indexOf(':') + 1;
                Integer right = exc.lastIndexOf(':');
                String str = exc.substring(left,right);
                left = str.indexOf(',') +  1;
                String newStr = str.substring(left);
                return newStr;
            }else {
                return e.getMessage();   
            } 
        }
    }
    //提交审批
    @AuraEnabled
    public static String submitApproval(String recordId){
        Savepoint sp = Database.setSavepoint();
        try {
            Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
            req1.setObjectId(recordId);
            Approval.ProcessResult submitResult = Approval.process(req1);
            return 'OK';
        }
        catch (Exception e) {
            Database.rollback(sp);
            if (e.getMessage().contains(',')) {
                System.debug(LoggingLevel.INFO, '*** e: ' + e);
                String exc = '' + e.getMessage();
                Integer left = exc.indexOf(':') + 1;
                Integer right = exc.lastIndexOf(':');
                String str = exc.substring(left,right);
                left = str.indexOf(',') +  1;
                String newStr = str.substring(left);
                return newStr;
            }else {
                return e.getMessage();   
            }
        }
    }
    public class InitData{
        @AuraEnabled
        public String schemeType;
        @AuraEnabled
        public String confirmationResult;
    }
}