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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
public with sharing class lexSolutionProjectRequirementsController {
    @AuraEnabled
    public static Map<String,Object> initSubmitSolutionForApprovalButton(String recordId){
        InitData res = new InitData();
        Map<String,Object> maps = new Map<String,Object>();
        try {
            SolutionProjectRequirements__c so = [
                select
                Status__c,
                Submit_Date_YouWant__c,
                CreatedDate,
                Department_Class__c,
                Product_Leader__c
                from SolutionProjectRequirements__c where Id =: recordId
            ];
            res.status = so.Status__c;
            res.submitDateYouWant = so.Submit_Date_YouWant__c;
            res.createdDate = so.CreatedDate;
            res.departmentClassId = so.Department_Class__c;
            res.productLeader = so.Product_Leader__c;
            res.userId = UserInfo.getUserId();
            res.userName = [select Name from User where Id =: res.userId].Name;
            maps.put('res', res);
        } catch (Exception e) {
            String message = e.getMessage();
            maps.put('error', message);
            return maps;
        }
        return maps;
    }
    @AuraEnabled
    public static InitData initForApplyAgainButton(String recordId){
        InitData res = new InitData();
        try {
            SolutionProjectRequirements__c so = [
                select
                Department_Class__c,
                Hospital__c
                from SolutionProjectRequirements__c where Id =: recordId
            ];
            res.hospital = so.Hospital__c;
            res.departmentClass = so.Department_Class__c;
        } catch (Exception e) {
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }
 
    @AuraEnabled
    public static InitData initForClosingCaseFlowButton(String recordId){
        InitData res = new InitData();
        try {
            SolutionProjectRequirements__c so = [
                select
                Status__c
                from SolutionProjectRequirements__c where Id =: recordId
            ]; 
            res.status = so.Status__c;
            res.profileId = UserInfo.getProfileId();
            res.m2ProfileId = [select Id from Profile where Name =: lexLightingButtonConstant.M2_PROFILE_NAME].Id;
        } catch (Exception e) {
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }
 
 
 
    @AuraEnabled
    public static string updateSubmitSolutionForApprovalButton(String recordId){
        SolutionProjectRequirements__c so = new SolutionProjectRequirements__c();
        try {
            so.Id = recordId;
            so.Submint_TF__c = true;
            so.Submitter__c = UserInfo.getUserId();
            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 updateForClosingCaseFlowButton(String recordId){
        SolutionProjectRequirements__c so = new SolutionProjectRequirements__c();
        try {
            so.Id = recordId;
            so.Status__c = '07结案';
            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 List<Account> queryForAttachments(String Id){
        List<Account> accList = null;
        try {
            accList = [
                select id,
                Department_Class__r.OwnerId,
                Department_Class__r.Owner.SalesManager__c 
                from Account where id =: Id
            ];
            
        } catch (Exception e) {
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return accList;
    }
 
    @AuraEnabled
    public static List<Solution_Programme__c> queryForSolutionProgramme(String recordId){
        List<Solution_Programme__c> so = new List<Solution_Programme__c>();
        try {
            so = [
                select id,
                Scheme_Type__c,
                ApprovalClosingProgramme__c 
                from Solution_Programme__c where SolutionProjectRequirements__c =: recordId and Scheme_Type__c = '结案' 
            ];
        } catch (Exception e) {
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return so;
    }
 
    @AuraEnabled
    public static List<solutionClosingAttachment__c> queryForAttachments1(String solprogrammeId){
        List<solutionClosingAttachment__c> so = new List<solutionClosingAttachment__c>();
        try {
            so = [
                select id,name from solutionClosingAttachment__c where Solution_Programme__c =: solprogrammeId
            ];
        } catch (Exception e) {
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return so;
    }
    public class InitData{
        @AuraEnabled
        public String status;
        @AuraEnabled
        public Date submitDateYouWant;
        @AuraEnabled
        public Datetime createdDate;
        @AuraEnabled
        public String departmentClassId;
        @AuraEnabled
        public String userId;
        @AuraEnabled
        public String userName;
        @AuraEnabled
        public String productLeader;
        @AuraEnabled
        public String profileId;
        @AuraEnabled
        public String m2ProfileId;
        @AuraEnabled
        public String oldProjectNo;
        @AuraEnabled
        public String departmentClass;
        @AuraEnabled
        public String hospital;
    }
}