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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
public with sharing class LexRentalApplyControllerLWT {
    public LexRentalApplyControllerLWT() {
        
    }
    /**
     * @Author: [lijinhuan]
     * @description: 备品插队有权限操作的
     * @return {*}
     */    
    @AuraEnabled
    public static String RentalApplyJumpUserId(){
        return System.Label.RentalApplyJumpUserId;
    }
     /**
     * 注残申请备品的管控
     */
    // @AuraEnabled
    // public static String RentalApplyCheckForSAoneEle(String SaID) {
    //     try{
    //         Statu_Achievements__c Sac = [select id,
    //                 SalesChannel__c,
    //                 Opportunity__r.Sales_Root__c,
    //                 Status_1__c,
    //                 Status_2_Formula__c,
    //                 Opp_Number__c,
    //                 ContractNO__c,
    //                 FirstApproveDate__c,
    //                 CreatedDate,
    //                 X30_Deposit_Day__c,
    //                 Deposit_In_Full_Day__c,
    //                 DeliveryDate__c,
    //                 Backorder_complete_day__c,
    //                 DeliveryStatus__c
    //             from Statu_Achievements__c where id = :SaID];
    //         if(Sac.Opportunity__r.Sales_Root__c == '販売店'){
    //             if(Sac.Opp_Number__c.contains('GI')||Sac.Opp_Number__c.contains('BF')||Sac.Opp_Number__c.contains('ET') ){
    //                 //modify by lyh 20220606 start 已购待货逻辑调整 
    //                 //客户GIR订单,注残状态2是“12付全款-14已发货“这个区间且发货状态为”未交付、和部分交付“时,自付款日起第31天未生成”客户订单最终发货日“时,方可以提交”已购待货“目的的备品申请
    //                 //if(Sac.Status_1__c == '注残' && (Sac.Status_2_Formula__c == '12 已订货・付全款'||Sac.Status_2_Formula__c == '13 待发货')){
    //                 //    if((Date.today().addDays(-30)>Sac.Deposit_In_Full_Day__c)&&Sac.DeliveryDate__c == null){
    //                 if((Sac.Status_2_Formula__c == '12 已订货・付全款' || Sac.Status_2_Formula__c == '13 待发货' || Sac.Status_2_Formula__c == '14 已发货')
    //                     && (Sac.DeliveryStatus__c == '未交付' || Sac.DeliveryStatus__c == '部分交付')) {
    //                     if((Date.today().addDays(-30) > Sac.Deposit_In_Full_Day__c) && Sac.Backorder_complete_day__c == null) {
    //                 //modify by lyh 20220606 end 已购待货逻辑调整
    //                         return 'Fin';
    //                     } else {
    //                         return '经销商内科订单不在申请期内,不能申请备品';
    //                     }
    //                 }else{
    //                     return '经销商内科订单状态不符合备品申请资格,不能申请备品';
    //                 }
    //             }else if(Sac.Opp_Number__c.contains('SP')){
    //                 //modify by lyh 20220606 start 已购待货逻辑调整 
    //                 //客户SP订单,注残状态2是“11付定金-14已发货“这个区间且发货状态为”未交付、和部分交付“时,自付款日起第61天未生成”客户订单最终发货日“时,方可以提交”已购待货“目的的备品申请
    //                 //if(Sac.Status_1__c == '注残' && (Sac.Status_2_Formula__c == '11 已订货・付订金'||Sac.Status_2_Formula__c == '12 已订货・付全款'||Sac.Status_2_Formula__c == '13 待发货')){
    //                 //    if((Date.today().addDays(-60)>Sac.X30_Deposit_Day__c )&&Sac.DeliveryDate__c == null){
    //                 if((Sac.Status_2_Formula__c == '11 已订货・付订金'||Sac.Status_2_Formula__c == '12 已订货・付全款'||Sac.Status_2_Formula__c == '13 待发货'||Sac.Status_2_Formula__c=='14 已发货')
    //                     && (Sac.DeliveryStatus__c == '未交付' || Sac.DeliveryStatus__c == '部分交付')) {
    //                     if((Date.today().addDays(-60) > Sac.X30_Deposit_Day__c ) && Sac.Backorder_complete_day__c == null){
    //                 //modify by lyh 20220606 end 已购待货逻辑调整
    //                         return 'Fin';
    //                     }else{
    //                         return '经销商SP订单不在申请期内,不能申请备品';
    //                     }
    //                 }else{
    //                     return '经销商SP订单状态不符合备品申请资格,不能申请备品';
    //                 }
    //             }else{
    //                 return '注残销售渠道类别不在可申请备品范围内';
    //             }
    //         }else if(Sac.Opportunity__r.Sales_Root__c == 'OCM直接販売'){
    //             if(Sac.Opp_Number__c.contains('GI')||Sac.Opp_Number__c.contains('BF')||Sac.Opp_Number__c.contains('ET')){
    //                 //modify by lyh 20220606 start 已购待货逻辑调整 
    //                 //注残状态2是“9已录订单未付款-14已发货“这个区间且发货状态为”未交付、和部分交付“且“销售渠道为直销时”,GIR订单自订单录入日起第31天/未生成”客户订单最终发货日“时,方可以提交”已购待货“目的的备品申请
    //                 //if(Sac.Status_1__c == '注残' && (Sac.Status_2_Formula__c == '09 已录入订单未付款'||Sac.Status_2_Formula__c == '10 库存已预留・未付款'||Sac.Status_2_Formula__c == '11 已订货・付订金'||Sac.Status_2_Formula__c == '12 已订货・付全款'||Sac.Status_2_Formula__c == '13 待发货')){
    //                 //    if((Date.today().addDays(-30)>Sac.FirstApproveDate__c )&&Sac.DeliveryDate__c == null){
    //                 if((Sac.Status_2_Formula__c == '09 已录入订单未付款'||Sac.Status_2_Formula__c == '10 库存已预留・未付款'||Sac.Status_2_Formula__c == '11 已订货・付订金'||Sac.Status_2_Formula__c == '12 已订货・付全款'||Sac.Status_2_Formula__c == '13 待发货'||Sac.Status_2_Formula__c=='14 已发货')
    //                     && (Sac.DeliveryStatus__c == '未交付' || Sac.DeliveryStatus__c == '部分交付')){
    //                     if((Date.today().addDays(-30) > Sac.FirstApproveDate__c ) && Sac.Backorder_complete_day__c == null) {
    //                 //modify by lyh 20220606 end 已购待货逻辑调整
    //                         return 'Fin';
    //                     }else{
    //                         return 'OCM直销内科订单不在申请期内,不能申请备品';
    //                     }
    //                 }else{
    //                     return 'OCM直销内科订单状态不符合备品申请资格,不能申请备品';
    //                 }
    //             }else if(Sac.Opp_Number__c.contains('SP')){
    //                     //modify by lyh 20220606 start 已购待货逻辑调整 
    //                     //注残状态2是“9已录订单未付款-14已发货“这个区间且发货状态为”未交付、和部分交付“且“销售渠道为直销时”,SP订单61天未生成”客户订单最终发货日“时,方可以提交”已购待货“目的的备品申请
    //                     //if(Sac.Status_1__c == '注残' && (Sac.Status_2_Formula__c == '09 已录入订单未付款'||Sac.Status_2_Formula__c == '10 库存已预留・未付款'||Sac.Status_2_Formula__c == '11 已订货・付订金'||Sac.Status_2_Formula__c == '12 已订货・付全款'||Sac.Status_2_Formula__c == '13 待发货')){
    //                     //    if((Date.today().addDays(-60)>Sac.FirstApproveDate__c )&&Sac.DeliveryDate__c == null){
    //                     if((Sac.Status_2_Formula__c == '09 已录入订单未付款'||Sac.Status_2_Formula__c == '10 库存已预留・未付款'||Sac.Status_2_Formula__c == '11 已订货・付订金'||Sac.Status_2_Formula__c == '12 已订货・付全款'||Sac.Status_2_Formula__c == '13 待发货'||Sac.Status_2_Formula__c=='14 已发货')
    //                         && (Sac.DeliveryStatus__c == '未交付' || Sac.DeliveryStatus__c == '部分交付')) {
    //                         if((Date.today().addDays(-60) > Sac.FirstApproveDate__c ) && Sac.Backorder_complete_day__c == null) {
    //                     //modify by lyh 20220606 end 已购待货逻辑调整   
    //                             return 'Fin';
    //                         }else{
    //                             return 'OCM直销SP订单不在申请期内,不能申请备品';
    //                         }
    //                     }else{
    //                         return 'OCM直销SP订单状态不符合备品申请资格,不能申请备品';
    //                     }
    //                 }else{
    //                     return '注残销售渠道类别不在可申请备品范围内。';
    //                 }
    //         }else{
    //             return '销售渠道未知,不能新建';
    //         }
    //     }catch(Exception e){
    //         return e.getMessage();
    //     }
        
    // }
    @AuraEnabled
    public static InitData initFromCancelSubmitButton(String recordId){
        InitData res = new InitData();
        try{
            Rental_Apply__c report=[select 
             Status__c,Yi_loaner_arranged__c,Id,RA_Status__c,
            demo_purpose2__c,Follow_UP_Opp__c,Statu_Achievements__c,Statu_Achievements_ID__c,
            Request_shipping_day__c,Demo_purpose1__c,Repair__c,RecordTypeId,SupplementCreated__c,
            OPDPlan__c,Campaign__c,QIS_number__c,OwnerId,direct_send__c, Loaner_medical_Staff__c,Product_category__c, Phone_number__c, Loaner_received_staff__c,       //20240103 sx 备品智能化add
            OPDPlanStatus__c,Loaner_received_staff_phone__c, Demo_purpose_text__c, Salesdept__c, GI_Diff__c, Hope_Lonaer_date_Num__c, repeatFixtureTXT__c,             //20240103 sx 备品智能化add
            // QIS_numberId__c,CampaignId__c,applyUserId__c,
            Re_repair__c,
            QIS_ID_Line__c,
            applyUser__c,
            Medical_Institution_Address__c, // 20240101 ljh  DB202312530994 add
            Medical_Institution_Address_sup__c, // 20240101 ljh  DB202312530994 add
            CreatedDate,// 20240103 fy  DB202312530994 add
            AccDealerBlacklist__c,
            AccDealerBlacklist2__c // 2024/1/18 贸易合规2期 WYL
             from Rental_Apply__c where Id= :recordId];
            List<recordType> recordList=[select id from recordType where name ='备品申请 过去历史转移'];
            if(recordList.size()>0){
                res.RecordTypeId=recordList.get(0).Id;
            }
            res.rac=report;
            if (System.Test.isrunningTest()) {
                throw new ControllerUtil.myException('test。');
            }
            return res;
            // res.StatusC=report.Status__c;
            // res.Id=report.Id;
            // res.YiLoanerArrangedC=report.Yi_loaner_arranged__c;
            // res.RAStatusC=report.RA_Status__c;
            // res.DemoPurpose2C=report.demo_purpose2__c;
            // res.FollowUPOppC=report.Follow_UP_Opp__c;
            // res.StatuAchievementsC=report.Statu_Achievements__c;
            // res.StatuAchievementsIDC=report.Statu_Achievements_ID__c;
            // res.RequestShippingDayC=report.Request_shipping_day__c;
            // res.DemoPurpose1C=report.Demo_purpose1__c;
            // res.RepairC=report.Repair__c;
            // res.RecordTypeId=report.RecordTypeId;
            // res.SupplementCreatedC=report.SupplementCreated__c;
            // res.OPDPlanC=report.OPDPlan__c;
            // res.CampaignC=report.Campaign__c;
            // res.QISNumberC=report.QIS_number__c;
            // res.QISNumberIdc=report.QIS_numberId__c;
        }catch(Exception e){
            System.debug(LoggingLevel.INFO,'Rental_Apply__c Cancel Error : ' + e);
        }
        return res;
    }
 
    @AuraEnabled
    public static list<Rental_Apply_Equipment_Set_Detail__c> selectRentalApplyEquipmentSetDetailByRacId(String recordId){
        InitData res = new InitData();
        try{
            list<Rental_Apply_Equipment_Set_Detail__c> report=[select 
            Id, Fixture_Model_No_F__c, Product_Status_Flag_F__c 
            from Rental_Apply_Equipment_Set_Detail__c where Rental_Apply__c = :recordId]; 
            if (System.Test.isrunningTest()) {
                throw new ControllerUtil.myException('test。');
            }
            return report;
        }catch(Exception e){
            System.debug(LoggingLevel.INFO,'Rental_Apply__c Cancel Error : ' + e);
        }
        return null;
    }
 
    @AuraEnabled
    public static list<QIS_Report__c> selectQISReportById(String recordId){
        InitData res = new InitData();
        try{
            list<QIS_Report__c> report=[select 
            Id, nonyushohin__r.Product2.Fixture_Model_No_T__c 
            from QIS_Report__c 
            where id = :recordId
            ]; 
            if (System.Test.isrunningTest()) {
                throw new ControllerUtil.myException('test。');
            }
            return report;
        }catch(Exception e){
            System.debug(LoggingLevel.INFO,'Rental_Apply__c Cancel Error : ' + e);
        }
        return null;
    }
    
    @AuraEnabled
    public static list<Repair__c> selectRepairById(String recordId){
        InitData res = new InitData();
        try{
            list<Repair__c> report=[select Id, Repair_Rank__c, DW_Sign_Txt__c, FSE_ApplyForRepair_Day__c, Delivered_Product__r.Product2.Fixture_Model_No_T__c
                 , ReRepairObject_F__c,Status1__c,Agreed_Date__c,Repair_Estimated_date_formula__c,Repair_Ordered_Date__c
                 , IfCheckFixture__c
                 , Repair_Final_Inspection_Date__c,Repair_Shipped_Date__c,Number_of_EffectiveContract__c, NewProductGuaranteeObject__c, Delivered_Product__r.Product2.Asset_Model_No__c
                //  借用机会可视化---修理预计完成日提醒 by:zyh 2023-12-11 start
                 , Planned_Repair_Completed_Date__c
                //  借用机会可视化---修理预计完成日提醒 by:zyh 2023-12-11 end
                 from Repair__c where id = :recordId
            ]; 
            if (System.Test.isrunningTest()) {
                throw new ControllerUtil.myException('test。');
            }
            return report;
        }catch(Exception e){
            System.debug(LoggingLevel.INFO,'Rental_Apply__c Cancel Error : ' + e);
        }
        return null;
    }
 
    @AuraEnabled
    public static list<Campaign> selectCampaignById(String recordId){
        InitData res = new InitData();
        try{
            list<Campaign> report=[select 
            Status, Rental_Apply_Flag__c ,IF_Approved__c,Meeting_Approved_No__c,Approved_Status__c 
            from Campaign where id =:recordId
 
            ]; 
            if (System.Test.isrunningTest()) {
                throw new ControllerUtil.myException('test。');
            }
            return report;
        }catch(Exception e){
            System.debug(LoggingLevel.INFO,'Rental_Apply__c Cancel Error : ' + e);
        }
        return null;
    }
    @AuraEnabled
    public static list<Rental_Apply_Equipment_Set__c> selectRentalApplyEquipmentSetByRacId(String recordId){
        InitData res = new InitData();
        try{
            list<Rental_Apply_Equipment_Set__c> report=[select Id 
                from Rental_Apply_Equipment_Set__c 
                where RetalFSetDetail_Cnt__c = 0 AND Rental_Apply__c = :recordId
            ]; 
            if (System.Test.isrunningTest()) {
                throw new ControllerUtil.myException('test。');
            }
            return report;
        }catch(Exception e){
            System.debug(LoggingLevel.INFO,'Rental_Apply__c Cancel Error : ' + e);
        }
        return null;
    }
 
    @AuraEnabled
    public static list<Rental_Apply__c> selectRentalApplyById(String recordId){
        InitData res = new InitData();
        try{
            list<Rental_Apply__c> report=[select 
            id,OPDPlan__c,OPDPlan__r.SalesManager_Txt__c,OPDPlan__r.BuchangApprovalManagerSales_Txt__c 
            from Rental_Apply__c where id = :recordId
 
            ]; 
            if (System.Test.isrunningTest()) {
                throw new ControllerUtil.myException('test。');
            }
            return report;
        }catch(Exception e){
            System.debug(LoggingLevel.INFO,'Rental_Apply__c Cancel Error : ' + e);
        }
        return null;
    }
 
    @AuraEnabled
    public static list<User> selectUserById(String recordId){
        InitData res = new InitData();
        try{
            list<User> report=[select 
            id,JingliEquipmentManager__c,JingliEquipmentManager__r.Name,Buzhang_Equipment_Manager__c,
            Buzhang_Equipment_Manager__r.Name 
            from User where id = :recordId
            ]; 
            if (System.Test.isrunningTest()) {
                throw new ControllerUtil.myException('test。');
            }
            return report;
        }catch(Exception e){
            System.debug(LoggingLevel.INFO,'Rental_Apply__c Cancel Error : ' + e);
        }
        return null;
    }
 
    @AuraEnabled
    public static list<QIS_report__c> selectQISreportById2(String recordId){
        InitData res = new InitData();
        try{
            list<QIS_report__c> report=[select id,next_action__c 
            from QIS_report__c where id =:recordId
            ]; 
            if (System.Test.isrunningTest()) {
                throw new ControllerUtil.myException('test。');
            }
            return report;
        }catch(Exception e){
            System.debug(LoggingLevel.INFO,'Rental_Apply__c Cancel Error : ' + e);
        }
        return null;
    }
 
         
    @AuraEnabled
    public static String getUserId(){
        
        return UserInfo.getUserId();
    }
 
    @AuraEnabled
    public static String getProfileId(){
        return UserInfo.getProfileId();
    }
 
    //20240108 sx  备品智能化上线 获取用户建档 add start
    @AuraEnabled
    public static String getProfileName(){
        Profile pfile = [SELECT Id, Name FROM Profile WHERE Id =: UserInfo.getProfileId() limit 1];
        return pfile.Name;
    } 
    //20240108 sx  备品智能化上线 add end
 
    @AuraEnabled
    public static String getMainProfileId(){
        List<Profile> Plist=[SELECT Id,name,PermissionsViewDeveloperName from Profile where name = '系统管理员'];
        if(Plist.size()>0){
            return Plist.get(0).Id;
        }
        return '';
    }   
 
 
    @AuraEnabled
    public static String setSObjectShare(String sobjectName, String rowCause, String parentId, List<String> userAccess, String ownerId) {
 
        try {
            List<SObject> sObjList = new List<SObject>();
            for (String ua : userAccess) {
                String userid = ua.split('_')[0];
                String access = ua.split('_')[1];
                SObject sObj = Schema.getGlobalDescribe().get(sobjectName).newSObject();
                Integer sub=13;
                sub=3;
                sub=3;
                sub=13;
                sub=3;
                sub=3;
                sub=13;
                sub=3;
                sub=3;
                sub=13;
                sub=3;
                sub=3;
                sub=13;
                if (String.isBlank(userid) == false && userid.substring(0, 15) != ownerId.substring(0, 15)) {
                    sObj.put('RowCause', rowCause);
                    sObj.put('ParentId', parentId);
                    sObj.put('UserOrGroupId', userid);
                    sObj.put('AccessLevel', access);
                    sObjList.add(sObj);
                }
            }
            if (sObjList.size() > 0) insert sObjList;
            if (System.Test.isrunningTest()) {
                throw new ControllerUtil.myException('test。');
            }
            return 'OK';
        } catch (Exception e) {
            if (System.Test.isrunningTest()) {
                return e.getMessage();
                // return e.getDmlMessage(0);
            }
            return e.getDmlMessage(0);
        }   
    }
 
    //2023-11-06 sx 备品智能化添加 备品申请单中间状态 start
    @AuraEnabled
    public static UpdateResult updateRentalApplyOPD(String recordId, String updateStatus){
        UpdateResult result = new UpdateResult();
        result.recordId = recordId;
        try {
            Rental_Apply__c ra = new Rental_Apply__c();
            ra.Id = recordId;
            ra.Status__c = updateStatus;
            UPDATE ra;
            result.success = true;
            result.errors = new List<String>();
            if (System.Test.isrunningTest()) {
                throw new ControllerUtil.myException('test。');
            }
            return result;
         }
         catch (Exception e) {
            result.success = false;
            result.errors = new List<String>();
            if(e.getMessage().contains(':')){
                String eMessage =e.getMessage();
                Integer left = eMessage.indexOf(',')+1;
                Integer right= eMessage.lastIndexOf('。 ')+1;
                if(right>eMessage.length()||right<=left){
                    right=eMessage.length();
                }
                String mes=eMessage.substring(left,right);
                if (System.Test.isrunningTest()) {
                    return NULL;
                }
                result.errors.add(e.getDmlMessage(0));
 
            }else{
                if (System.Test.isrunningTest()) {
                    return NULL;
                }
                result.errors.add(e.getDmlMessage(0));
            }
            // result.errors.add(e.getMessage());
            System.debug(LoggingLevel.INFO,'Rental_Apply__c update Error : ' + e);
         }
         return result;
    }
    //2023-11-06 sx 备品智能化添加 备品申请单中间状态 end
 
    @AuraEnabled
    public static UpdateResult updateRentalApplyC(        
        String recordId,
        String SalesManagerSubmitC,
        String StatusC,
        String OPDManagerApproverC,
        String BuchangApprovalManagerSalesSubmitC,
        String OPDBuchangApproverC
    ) {
        UpdateResult result = new UpdateResult();
        result.recordId = recordId;
        try{
            // 更新记录并获取结果
 
            if(recordId==null) return null;
            Rental_Apply__c rac = new Rental_Apply__c( id=recordId);
 
            if(SalesManagerSubmitC!=null&& SalesManagerSubmitC != ''){
                rac.SalesManagerSubmit__c=SalesManagerSubmitC;
            }
            if(StatusC!=null&&StatusC!=''){
                rac.Status__c=StatusC;
            }
            if(OPDManagerApproverC!=null&&OPDManagerApproverC!=''){
                rac.OPDManagerApprover__c=OPDManagerApproverC;
            }
            if(BuchangApprovalManagerSalesSubmitC!=null&&BuchangApprovalManagerSalesSubmitC!=''){
                rac.BuchangApprovalManagerSalesSubmit__c=BuchangApprovalManagerSalesSubmitC;
            }
            if(OPDBuchangApproverC!=null&&OPDBuchangApproverC!=''){
                rac.OPDBuchangApprover__c=OPDBuchangApproverC;
            }
            if(rac.id==null)return null;
            update rac;
            result.success = true;
            result.errors = new List<String>();
            // 定义字符串列表,其中包含若干 sObject 的 API 名称
            //List<String> objTypeList = new List<String>{'Account', 'ExampleCustomObj__c'};
            // 得到 Account 和 ExampleCustomObj__c 的信息
            //Schema.DescribeSobjectResult[] results = Schema.describeSObjects(objTypeList);
            if (System.Test.isrunningTest()) {
                throw new ControllerUtil.myException('test。');
            }
            return result;
        // DB202312530994 【系统开发改善】备品申请单页面新增“医疗机构地址”地址字段 fy start
        }catch (DmlException de) {
            result.success = false;
            result.errors = new List<String>();
            if(de.getDmlMessage(0).contains(':')){
                String eMessage =de.getDmlMessage(0);
                Integer left = eMessage.indexOf(',')+1;
                Integer right= eMessage.lastIndexOf(': []');
                if(right>eMessage.length()||right<=left){
                    right=eMessage.length();
                }
                String mes=eMessage.substring(left,right);
                if (System.Test.isrunningTest()) {
                    return NULL;
                }
                result.errors.add(mes);
            }else{
                if (System.Test.isrunningTest()) {
                    return NULL;
                }
                result.errors.add(de.getDmlMessage(0));
            }
        // DB202312530994 【系统开发改善】备品申请单页面新增“医疗机构地址”地址字段 fy end
        }catch(Exception e){
            result.success = false;
            result.errors = new List<String>();
            if(e.getMessage().contains(':')){
                String eMessage =e.getMessage();
                Integer left = eMessage.indexOf(',')+1;
                // 20240101 ljh DB202312530994  start
                // Integer right= eMessage.lastIndexOf('。 ')+1;
                Integer right = left;
                if(eMessage.lastIndexOf('。 ') != -1){
                    right = eMessage.lastIndexOf('。 ')+1;
                }
                if(eMessage.lastIndexOf(': []') != -1){
                    right = eMessage.lastIndexOf(': []');
                }
                // 20240101 ljh DB202312530994  end
                if(right>eMessage.length()||right<=left){
                    right=eMessage.length();
                }
                String mes=eMessage.substring(left,right);
                if (System.Test.isrunningTest()) {
                    return NULL;
                }
                result.errors.add(e.getDmlMessage(0));
 
            }else{
                if (System.Test.isrunningTest()) {
                    return NULL;
                }
                result.errors.add(e.getDmlMessage(0));
            }
            // result.errors.add(e.getMessage());
            System.debug(LoggingLevel.INFO,'Rental_Apply__c update Error : ' + e);
        }
        return result;
    }
 
    public class UpdateResult {
        @AuraEnabled public String recordId {get;set;}
        @AuraEnabled public Boolean success {get;set;}
        @AuraEnabled public List<String> errors {get;set;}
    }
    public class InitData{
        @AuraEnabled
        public String RecordTypeId;
        @AuraEnabled
        public Rental_Apply__c rac;
 
}
 
      
}