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
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
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
public with sharing class otherButtonRepairController {
    public otherButtonRepairController() {
 
    }
 
    @AuraEnabled
    public static InitData init(String recordId){
        InitData res = new initData();
        try{
            //deloitte-zhj 20231123 PIPL还原 去掉AWS_Data_Id__c
            Repair__c report =  [SELECT HP_active__c,SAP_condition__c,DOJ_Status__c,DW_Sign__c,
            Incharge_Staff__r.Id,URF_Reapir__c,Recall_Correspondence__c,Day_later_30__c,Dealer__r.Id,Status__c,
            URFLimitSerial__c,Maintenance_Contract__r.Id,FSE_ApplyForRepair_time__c,Delivered_Product__r.Id,Asset_Owner__c,
            State_Hospital__c,is_aohui_product__c,Sales_Dept_HP__c,RCCD__c,Quick_Repair_Sign__c,RepairSource__c,FSE_State__c,
            VM_Maintenance_Contract__c,Maintenance_Contract__c,NewProductGuarante_Txt__c,Number_of_EffectiveContract__c,Detailed_Address__c,
            Status1__c,Rental_Apply_Equipment_Set_Detail__c,Rental_Apply_Equipment_Set_Detail_Id__c,Latest_Collect_Date_Priority__c,
            if_Rental_Apply__c,Offer_Rental_New__c,ProduceCompany_hand__c,CFDA_No_Hand__c,MBC_AwareDate__c,InsReport__c,QIS_ID__c,
            On_Call_ID__c,RepairSubOrder__c,ProductFailureRelated__c,Delay15Min__c,ProblemOccurredSelect__c,Repair_Source__c ,Failure_Occurrence_Date__c ,
            MaintenanceContractType__c ,OperationOrExaminationName__c ,WhatProject__c ,FailureQInHospital__c ,ReportAdverseEvents__c ,InformationFrom__c ,
            AfterFailureInformation__c ,ProblemOccurred__c ,SupportingProducts__c ,ifDeadHurt__c ,UseFailProductFinish__c ,DelayReportReason__c ,
            BreakORFallOff__c ,DateReceiptQuestions__c ,DeliveryLogisticsAnnotation__c ,DeliveryLogisticsNo__c ,engineerSendDate__c ,DeliveryLogisticsMode__c ,
            RepairApplicantDepartment__c ,RepairApplicantHospital__c ,RepairApplicant__c ,Repair_Detail__c ,Returns_Product_way__c ,work_location_select__c ,
            On_site_repair__c ,SalesOfficeCode_selection__c ,Incharge_Staff_Contact__c ,Incharge_Staff__c ,Dealer__c ,RepairCostType__c ,Account__c,
            Department_Class__c ,Hospital__c ,PaperRepairRequestNo__c ,part_arrangement_complete__c,Repair_Shipped_Date__c,OCSMAdministrativeReportStatus__c,
            Incharge_Staff_Email__c,Name,HP_Name__c,Delivered_Product__c,Delivered_Product__r.Name,//deloitte-zhj 20230914 增加Delivered_Product__r.Name
            Delivered_Product__r.OT_CODE__c,// WYL 贸易合规2期 add
            Delivered_Product__r.Product2.ProTradeComplianceStatus__c, // WYL 贸易合规2期 add
            Repair_Product_Serial_No__c,Service_Repair_No__c,Repair_Firstestimated_Date__c,
            Repair_Estimated_Date__c,RC_information__c,Id,OCSMAdministrativeReportNumber__c,
            OCSMAdministrativeReportDate__c,Aware_date__c,PAE_Determine__c,ETQ_UPLOAD_STATUS__c,
            AE_DetermineResult__c,PAE_DetermineAC__c,Repair_Inspection_Date__c,Contain_UseRSA__c,Affiliation_RC__c,Limit_Price__c FROM Repair__c WHERE Id =: recordId LIMIT 1];
            List<Account> sql = [select id,IFTradeComplianceIntercept__c,RecordType.DeveloperName,
                                name,TradeComplianceStatus__c // WYL 贸易合规2期 add
                                from Account where id = :report.Hospital__c or id = :report.Dealer__c];
            System.debug(LoggingLevel.INFO, '*** opp: ' + report);
            // 2023/09/05 zhangchunxu start
            res.sql = sql;
            // 2023/09/05 zhangchunxu end
            res.HPActiveC = report.HP_active__c;
            res.detailedAddress = report.Detailed_Address__c;
            res.numberofEffectiveContract = report.Number_of_EffectiveContract__c;
            res.newProductGuaranteTxt = report.NewProductGuarante_Txt__c;
            res.maintenanceContract = report.Maintenance_Contract__c;
            res.VMMaintenanceContract = report.VM_Maintenance_Contract__c;
            res.FSEState = report.FSE_State__c;
            res.repairSource = report.RepairSource__c;
            res.quickRepairSign = report.Quick_Repair_Sign__c;
            res.RCCD = report.RCCD__c;
            res.salesDeptHP = report.Sales_Dept_HP__c;
            res.isAohuiProduct = report.is_aohui_product__c;
            res.stateHospital = report.State_Hospital__c;
            res.assetOwner = report.Asset_Owner__c;
 
            res.deliveredProductId = report.Delivered_Product__c;
            res.maintenanceContractId = report.Maintenance_Contract__c;
 
            res.FSEApplyForRepairTime = report.FSE_ApplyForRepair_time__c;
            
            res.URFLimitSerial = report.URFLimitSerial__c;
            res.status = report.Status__c;
            res.dealerId = report.Dealer__r.Id;
            res.dayLater30 = report.Day_later_30__c;
            res.recallCorrespondence = report.Recall_Correspondence__c;
            res.URFReapir = report.URF_Reapir__c;
            res.inchargeStaffId = report.Incharge_Staff__r.Id;
            res.DWSign = report.DW_Sign__c;
            res.DOJStatus = report.DOJ_Status__c;
            res.SAPcondition = report.SAP_condition__c;
            //res.AWSDataId = report.AWS_Data_Id__c;   //deloitte-zhj 20231123 PIPL还原
 
            res.Status1C = report.Status1__c;
            res.ProblemOccurredSelectC = report.ProblemOccurredSelect__c;
            res.Delay15MinC = report.Delay15Min__c;
            res.ProductFailureRelatedC = report.ProductFailureRelated__c;
            res.RepairSubOrderC = report.RepairSubOrder__c;
            res.OnCallIDC = report.On_Call_ID__c;
            res.QISIDC = report.QIS_ID__c;
            res.InsReportC = report.InsReport__c;
            res.MBCAwareDateC = report.MBC_AwareDate__c;
            res.CFDANoHandC = report.CFDA_No_Hand__c;
            res.ProduceCompanyHandC = report.ProduceCompany_hand__c;
            res.OfferRentalNewC = report.Offer_Rental_New__c;
            res.ifRentalApplyC = report.if_Rental_Apply__c;
            res.LatestCollectDatePriorityC = report.Latest_Collect_Date_Priority__c;
            res.RentalApplyEquipmentSetDetailIdC = report.Rental_Apply_Equipment_Set_Detail_Id__c;
            res.RentalApplyEquipmentSetDetailC = report.Rental_Apply_Equipment_Set_Detail__c;
            res.PaperRepairRequestNoC = report.PaperRepairRequestNo__c;
            res.HospitalC = report.Hospital__c;
            res.DepartmentClassC = report.Department_Class__c;
            res.AccountC = report.Account__c;
            res.RepairCostTypeC = report.RepairCostType__c;
            res.DealerC  = report.Dealer__c ;
            res.InchargeStaffC  = report.Incharge_Staff__c ;
            res.InchargeStaffContactC  = report.Incharge_Staff_Contact__c ;
            res.SalesOfficeCodeSelectionC  = report.SalesOfficeCode_selection__c ;
            res.OnSiteRepairC  = report.On_site_repair__c ;
            res.workLocationSelectC  = report.work_location_select__c ;
            res.ReturnsProductWayC  = report.Returns_Product_way__c ;
            res.RepairDetailC  = report.Repair_Detail__c ;
            res.RepairApplicantC  = report.RepairApplicant__c ;
            res.RepairApplicantHospitalC  = report.RepairApplicantHospital__c ;
            res.RepairApplicantDepartmentC  = report.RepairApplicantDepartment__c ;
            res.DeliveryLogisticsModeC  = report.DeliveryLogisticsMode__c ;
            res.engineerSendDateC  = report.engineerSendDate__c ;
            res.DeliveryLogisticsNoC  = report.DeliveryLogisticsNo__c ;
            res.DeliveryLogisticsAnnotationC  = report.DeliveryLogisticsAnnotation__c ;
            res.DateReceiptQuestionsC  = report.DateReceiptQuestions__c ;
            res.BreakORFallOffC  = report.BreakORFallOff__c ;
            res.DelayReportReasonC  = report.DelayReportReason__c ;
            res.UseFailProductFinishC  = report.UseFailProductFinish__c ;
            res.ifDeadHurtC = report.ifDeadHurt__c ;
            res.SupportingProductsC = report.SupportingProducts__c ;
            res.ProblemOccurredC = report.ProblemOccurred__c ;
            res.AfterFailureInformationC = report.AfterFailureInformation__c ;
            res.InformationFromC = report.InformationFrom__c ;
            res.ReportAdverseEventsC = report.ReportAdverseEvents__c ;
            res.FailureQInHospitalC = report.FailureQInHospital__c ;
            res.WhatProjectC = report.WhatProject__c ;
            res.OperationOrExaminationNameC = report.OperationOrExaminationName__c ;
            res.MaintenanceContractTypeC = report.MaintenanceContractType__c ;
            res.FailureOccurrenceDateC = report.Failure_Occurrence_Date__c ;
            res.RepairSourceC = report.Repair_Source__c ;
            res.Id = report.Id;
            res.partArrangementCompleteC = report.part_arrangement_complete__c;
            res.RepairShippedDateC = report.Repair_Shipped_Date__c;
            res.OCSMAdministrativeReportNumberC = report.OCSMAdministrativeReportNumber__c;
            res.OCSMAdministrativeReportDateC = report.OCSMAdministrativeReportDate__c;
            res.AwareDateC = report.Aware_date__c;
            res.PAEDetermineC = report.PAE_Determine__c;
            res.ETQUPLOADSTATUSC = report.ETQ_UPLOAD_STATUS__c;
            res.AEDetermineResultC = report.AE_DetermineResult__c;
            res.PAEDetermineACC = report.PAE_DetermineAC__c;
            res.RepairInspectionDateC = report.Repair_Inspection_Date__c;
            res.ContainUseRSAC = report.Contain_UseRSA__c;
            res.InchargeStaffEmailC = report.Incharge_Staff_Email__c;
            res.Name = report.Name;
            res.HPNameC = report.HP_Name__c;
            res.DeliveredProductC = report.Delivered_Product__c;
            res.AssetName = report.Delivered_Product__r.Name; //Deloitte-zhj  2023-09-14
            res.RepairProductSerialNoC = report.Repair_Product_Serial_No__c;
            res.ServiceRepairNoC = report.Service_Repair_No__c;
            res.RepairFirstestimatedDateC = report.Repair_Firstestimated_Date__c;
            res.RepairEstimatedDateC = report.Repair_Estimated_Date__c;
            res.RCInformationC = report.RC_information__c;
            res.OCSMAdministrativeReportStatusC = report.OCSMAdministrativeReportStatus__c;
            res.Asset_Model_No = report.Delivered_Product__r.OT_CODE__c; // WYL 贸易合规2期 add
            res.ProTradeComplianceStatus = report.Delivered_Product__r.Product2.ProTradeComplianceStatus__c;// WYL 贸易合规2期 add
            res.userID = UserInfo.getUserId();
            res.profileId = UserInfo.getProfileId();
            res.userEmail = UserInfo.getUserEmail();
            res.linkUrl = System.Label.mailMessegeLink;
 
            res.tradeComplianceStatusFlagFW = System.Label.TradeComplianceStatusFlagFW;
            res.ifTradeComplianceAlert = System.Label.IFTradeComplianceAlert;
            res.ifTradeComplianceIntercept = sql[0].IFTradeComplianceIntercept__c;
            res.typeDeveloperName = sql[0].RecordType.DeveloperName;
            res.AccountName =  sql[0].name; // WYL 贸易合规2期 add
            res.state = sql[0].TradeComplianceStatus__c; // WYL 贸易合规2期 add
            res.affiliationRC = report.Affiliation_RC__c;
            res.limitPrice = report.Limit_Price__c;
 
            //res.staticResourceRepair = Json.serialize(PIHelper.getPIIntegrationInfo('Repair__c')); //Deloitte-zhj PIPL解密 2023-08-23   //deloitte-zhj 20231123 PIPL还原
            System.debug(LoggingLevel.INFO, '*** res: ' + res);
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }   
 
    // 根据ID查找修理表
    @AuraEnabled
    public static List<Repair__c> selectRecords(String recordId){
        List<Repair__c> res = new List<Repair__c>();
        try{
            res = [SELECT Id,AsyncData__c,Complaint_Number__c,ETQ_UPLOAD_STATUS__c FROM Repair__c WHERE id =: recordId ];
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }
 
    // 根据ID修改修理
    @AuraEnabled
    public static String updateRepair(String recordId,String ocsm){
        String res;
        try {
            Repair__c repair = new Repair__c();
            repair.Id = recordId;
            repair.OCSMAdministrativeReportStatus__c = ocsm;
            update repair;
        } catch (Exception e) {
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            res=e.getMessage();
        }
        return res;
    } 
 
    // 修改验收单
    @AuraEnabled
    public static String updateYanshoudan(String recordId){
        String res;
        try {
            Repair__c repair = new Repair__c();
            repair.Id = recordid;
            repair.Request_yanshoudan_PDF__c = true;
            repair.Facility_Return_Receipt_Collection_reque__c = Datetime.now().date();
            
            update repair;
            return 'ok';
        } catch (Exception e) {
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            return e.getMessage();
        }
    }
 
    // 查找PAE判定记录
    @AuraEnabled
    public static List<PAE_DecisionRecord__c> selectPAEDecisionRecord(String recordId,String recordTypeId){
        List<PAE_DecisionRecord__c > res = new List<PAE_DecisionRecord__c >();
        try{
            res = [SELECT LastModifiedDate, Id, Name, LastModifiedById,RecordType.DeveloperName FROM PAE_DecisionRecord__c  where PAE_Repair__c =: recordId And RecordType.DeveloperName =: recordTypeId Order by LastModifiedDate desc];
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }
 
    // 发送邮件
    @AuraEnabled
    public static String sendToETQ(String iflog_Id,BatchIF_Log__c rowDataSFDC, List<String> repairIds,String statu){
        List<QIS_Report__c> temp = [select id from QIS_Report__c where id in :repairIds ];
        if(temp != null && temp.size() > 0){
            try {
                Database.executeBatch(new QISToPDFBatch(iflog_Id, rowDataSFDC,repairIds,statu),50); //生成PDF
            }
            catch (Exception e) {
                return '更新QIS报错:'+ e.getMessage();
            }
        }else{
            BatchIF_Log__c iflog = new BatchIF_Log__c();
            iflog.Type__c = 'sendToETQ';
            iflog.ErrorLog__c = '';
            iflog.Log__c = 'NFM401WebService start--';
 
            Repair__c updateRe = new Repair__c();
            updateRe.Id = repairIds[0];
            updateRe.INTERFACE_RECORD_ID__c = null; 
            updateRe.ETQ_UPLOAD_STATUS__c = null; 
            updateRe.ETQ_UPLOAD_MESSAGE__c = null; 
            updateRe.OSH_ConfirmationDate__c = Date.today(); 
            updateRe.OSH_Affirmant__c = UserInfo.getUserId(); 
            updateRe.AWS_Interface_Time__c = Datetime.now();
            updateRe.AsyncData__c = true; 
            try{
                update updateRe;
                Database.executeBatch(new RepairToPDFBatch(iflog_Id, rowDataSFDC,repairIds,statu)); //生成PDF
                iflog.Log__c += '\n修理:'+updateRe+' 更新成功';
                iflog.Log__c = '\nNFM401WebService end--';
                insert iflog;
            }catch(Exception ex){
                iflog.ErrorLog__c += '修理:'+updateRe+' 更新失败,因为::'+ex.getMessage();
                iflog.Log__c = '\nNFM401WebService end--';
                insert iflog;
                return '更新修理报错:'+ ex.getMessage();
            }
        }
        return '发送成功!';
    }
 
    // 查找AssetID
    @AuraEnabled
    public static String selectAssetID(String recordId){
        List<Repair__c> res = new List<Repair__c>();
        try{
            res = [SELECT Delivered_Product__c from Repair__c WHERE Id =: recordId];
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e.getMessage());
        }
        return res[0].Delivered_Product__c;
    }
 
    // 查找删除ID
    @AuraEnabled
    public static List<Repair__c> selectCustomDeleteById(String recordId){
        List<Repair__c > res = new List<Repair__c >();
        try{
            res = [SELECT Id, Status__c,SAP_Transfer_time__c,FSE_ApplyForRepair_time__c, Repair_Ordered_Date__c, CreatedById, Acc_OwnerId__c,FSE_ownerid__c FROM Repair__c WHERE Id =: recordId];
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e.getMessage());
        }
        return res;
    }
 
     // 查找删除ID
     @AuraEnabled
     public static String deleteRepair(String rid) {
        try {
            Repair__c r = new Repair__c(Id = rid);
            delete r;
            return 'OK';
        } catch (Exception e) {
            return e.getMessage();
        }
    }
 
    //通过deliveredProductId作为Id查询Asset的记录并返回
    @AuraEnabled
    public static List<Asset> queryForEquipments(String deliveredProductId){
        try {
             List<Asset> assets = [SELECT Id, Status FROM Asset WHERE Id = :deliveredProductId];
            return assets;
        } catch (Exception e) {
         throw new AuraHandledException(e.getMessage());
        }
    }
 
    //通过Maintenance_Contract__c和Asset__c字段查询Maintenance_Contract_Asset__c的记录并返回
    @AuraEnabled
    public static List<Maintenance_Contract_Asset__c> queryForUrfAsset(String maintenanceContractId,String deliveredProductId){
         try {
            List<Maintenance_Contract_Asset__c> assets = [SELECT Id,URF_Series_F__c,Series_MaxRepairCount_F__c,Series_RepairCount_F__c FROM Maintenance_Contract_Asset__c WHERE Maintenance_Contract__c =:maintenanceContractId and Asset__c=:deliveredProductId];
            return assets;
        } catch (Exception e) {
             throw new AuraHandledException(e.getMessage());
        }
    }
 
    //通过URFLimitSerial作为Id查询ProductURF__c的记录并返回
    @AuraEnabled
    public static List<ProductURF__c> queryForUrfSeriesInfo(String URFLimitSerial){
        try {
             List<ProductURF__c> urfs = [SELECT Id,URFLimitSerial__c FROM ProductURF__c WHERE Id=:URFLimitSerial]; 
             return urfs;
         } catch (Exception e) {
         throw new AuraHandledException(e.getMessage());
         }
    }
 
    //通过Maintenance_Contract__c,Status1__c和Delivered_Product__r.Product2.ProductURF__r.URFLimitSerial__c字段查询Repair__c中的记录并返回
    @AuraEnabled
    public static List<Repair__c> queryForRepairCount(String maintenanceContractId,List<String> status1,String URFLimitSerial){
        try {
            List<Repair__c> repairs = [SELECT Id,name FROM Repair__c WHERE Maintenance_Contract__c=:maintenanceContractId 
                                                                    AND Status2__c IN: status1 
                                                                    AND Delivered_Product__r.Product2.ProductURF__r.URFLimitSerial__c = :URFLimitSerial];
            return repairs;
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
        }    
    }
 
    //计算上限合同进行中的修理
    @AuraEnabled
    public static CeilingContractData  CeilingContractRepair(String MaintenanceContractId){
        CeilingContractData res = new CeilingContractData();
        try {
            List<Maintenance_Contract__c> maintenanceContract = [SELECT Id,name,Remaining_Amount__c,Remaining_Amount_DB__c,PackageFlag__c FROM Maintenance_Contract__c WHERE ID=:MaintenanceContractId];
            List<Repair__c> repairs = [SELECT Id,name FROM Repair__c WHERE Maintenance_Contract__c = :MaintenanceContractId AND Status2__c in ('00.申请完毕','01.分公司受理完毕','02.RC受理完毕','03.报价检查结束','04.报价跟进中')];
            res.maintenanceContract = maintenanceContract;
            res.repairs = repairs;
            return res;
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
        }
    }
 
    //通过Is_Validity__c和Id字段查询Account的记录并返回
    @AuraEnabled
    public static List<Account> queryForFindInvalidLicense(String dealerId){
        try {
            List<Account> accounts = [select Id,Is_Validity__c from Account where Is_Validity__c = false And Id = :dealerId];
            return accounts;
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
        }
    }
 
    //通过inchargeStaffId作为Id查询User中的记录并返回
    @AuraEnabled
    public static List<User> queryForReocrds(String inchargeStaffId){
        try {
            List<User> users = [SELECT Id, JingliApprovalManager__c, BuchangApprovalManager__c, ZongjianApprovalManager__c FROM User WHERE Id = :inchargeStaffId]; 
            return users;
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
        }
    }
 
    //通过Id查询Repair__c中的记录并返回
    @AuraEnabled
    public static List<Repair__c> queryForRds(String recordId){
        try {
            List<Repair__c> res = [SELECT Id,NewProductGuarante_Formula__c,ProductGuarante_Create__c FROM Repair__c WHERE Id = :recordId]; 
            return res;
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
        }
    }
 
    //通过Id查询Repair__c中的Dealer__c,再根据Dealer__c查询Account中的记录并返回
    @AuraEnabled
    public static List<Account> queryForrecords3(String dealer){
        try {
           List<Account> accounts = [SELECT id, FirstParagraph__c from Account where Id =:dealer]; 
           return accounts;
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
        }
    }
 
    // //更新Repair__c中的记录,将Maintenance_Contract__c和MaintenanceContractType__c字段更新为空,若捕获到异常则返回错误信息
    // @AuraEnabled
    // public static String updateForRepair1(String recordId){
    //     String res='1';
    //     try {
    //         Repair__c repair = [SELECT Id,Maintenance_Contract__c,MaintenanceContractType__c FROM Repair__c WHERE Id =:recordId ];
    //         // Repair__c repair = new Repair__c();
    //         repair.Id = recordId;
    //         repair.Maintenance_Contract__c = null;
    //         repair.MaintenanceContractType__c = null;
    //         update repair;
    //         System.debug('updateRepair---Maintenance_Contract__c--->>>'+repair.Maintenance_Contract__c+'MaintenanceContractType__c---->>>>'+repair.MaintenanceContractType__c);
    //         // return null;
            
    //     } catch (Exception e) {
    //         res = e.getDmlMessage(0);
    //         return res;
    //     }
        
    //     return res;
    // }
 
    //更新Repair__c中的记录,若捕获到异常则返回错误信息
    @AuraEnabled
    public static String updateRepair2(String recordId,User staff,Boolean DWSign,String statusc,String DOJStatus,String SAPcondition,Boolean maintenanceFlag){
        String res='1';
        Repair__c repair =  [SELECT Id,JingliApprovalManager__c,BuchangApprovalManager__c,ZongjianApprovalManager__c,FSE_ApplyForRepair_time__c,
                                DW_Sign_Txt__c,Status__c,Service_contract_judege_day__c,SAP_Transfer_time__c,Maintenance_Contract__c, MaintenanceContractType__c FROM Repair__c WHERE Id =:recordId ];
        repair.Id = recordId;
        repair.JingliApprovalManager__c =staff.JingliApprovalManager__c == null ? staff.Id : staff.JingliApprovalManager__c;
        repair.BuchangApprovalManager__c = staff.BuchangApprovalManager__c == null ? staff.Id : staff.BuchangApprovalManager__c;
        repair.ZongjianApprovalManager__c =staff.ZongjianApprovalManager__c == null ? staff.Id : staff.ZongjianApprovalManager__c;
        repair.FSE_ApplyForRepair_time__c = Datetime.now();
        repair.DW_Sign_Txt__c = DWSign; //20210608 ljh SFDC-C3CCN4 end
        repair.Status__c = statusc;
        repair.Service_contract_judege_day__c = Date.today();
        if (DOJStatus == LightingButtonConstant.REPAIR_FIELD_DOJ_STATUS_NOT_OBJECT &&SAPcondition == LightingButtonConstant.REPAIR_FIELD_SAP_CONDITION_IS_TRUE) {
            repair.SAP_Transfer_time__c = Datetime.now();
        }
        if(maintenanceFlag){
            repair.Maintenance_Contract__c = null;
            repair.MaintenanceContractType__c = null;
        }
        // 20230918 ljh update start
        // update repair;
        list<Repair__c> updateList = new list<Repair__c>();
        updateList.add(repair);
        Database.SaveResult[] updateRepairResult = Database.update(updateList, false);
        for (Integer tIdx = 0; tIdx < updateRepairResult.size(); tIdx++) {
            Database.SaveResult sr = updateRepairResult[tIdx];
            if (!sr.isSuccess()) {
                // System.debug('sr.getErrors()未拆分------>>>>:'+sr.getErrors());\
                res = '';
                for(Integer i = 0; i < sr.getErrors().size(); i++){
                    // System.debug('sr.getErrors()[i].getMessage()拆分------>>>>:'+sr.getErrors()[i].getMessage());
                    res += sr.getErrors()[i].getMessage()+sr.getErrors()[i].getFields()+';'+'\n';
                }
            }
        }
        // res = 'repair.Maintenance_Contract__c:'+repair.Maintenance_Contract__c+'repair.MaintenanceContractType__c'+repair.MaintenanceContractType__c;
        // System.debug('zheli99999:'+res);
        // 20230918 ljh update end
        return res;
    }
 
     // 查找简档
     @AuraEnabled
     public static String initSelectProfile(String profileId){
         List<Profile> res = new List<Profile>();
         String profileName = '';
         try{
            res = [SELECT Id,Name FROM Profile WHERE Id=: profileId ];
            if (res.size() > 0) {
                profileName = res[0].Name;
            }
         }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
         }
        //  return res;
        return profileName;
     }
 
      // 查找UserName
      @AuraEnabled
      public static List<User> initUserName(String userId){
          List<User> res = new List<User>();
          try{
              res = [SELECT Id,name FROM User WHERE Id=: userId ];
          }catch(Exception e){
              System.debug(LoggingLevel.INFO, '*** e: ' + e);
          }
          return res;
      }
      @AuraEnabled
      public static estimateData initList(){
        estimateData res = new estimateData();
        res.oshact = [SELECT name FROM Profile WHERE Id = :System.Label.ProfileId_2F7_OSHACT].Name;//2F7_OSH担当
        res.oshqualityregulations = [SELECT name FROM Profile WHERE Id = :System.Label.oshqualityregulations].Name;//2F7_OSH质量法规
        res.administrator = [SELECT name FROM Profile WHERE Id = :System.Label.ProfileId_SystemAdmin ].Name;//系统管理员
        res.leixinjian = [SELECT Name FROM User WHERE Id = :System.Label.leixinjian ].Name;//雷新建
        res.huyucheng = [SELECT Name FROM User WHERE Id = :System.Label.huyucheng ].Name;//胡玉成
        res.liqiqing = [SELECT Name FROM User WHERE Id = :System.Label.liqiqing ].Name;//李琪清
        res.guoyang = [SELECT Name FROM User WHERE Id = :System.Label.guoyang ].Name;//李琪清
        return res;
      }
    public class estimateData{
        @AuraEnabled
        public String oshact;
        @AuraEnabled
        public String oshqualityregulations;
        @AuraEnabled
        public String administrator;
        @AuraEnabled
        public String leixinjian;
        @AuraEnabled
        public String huyucheng;
        @AuraEnabled
        public String liqiqing;
        @AuraEnabled
        public String guoyang;
    }
 
    public class InitData{
        @AuraEnabled
        public String detailedAddress;
        @AuraEnabled
        public String numberofEffectiveContract;
        @AuraEnabled
        public String newProductGuaranteTxt;
        @AuraEnabled
        public String maintenanceContract;
        @AuraEnabled
        public String VMMaintenanceContract;
        @AuraEnabled
        public String FSEState;
        @AuraEnabled
        public String repairSource;
        @AuraEnabled
        public Boolean quickRepairSign;
        @AuraEnabled
        public String RCCD;
        @AuraEnabled
        public String salesDeptHP;
        @AuraEnabled
        public Boolean isAohuiProduct;
        @AuraEnabled
        public String stateHospital;
        @AuraEnabled
        public String assetOwner;
        @AuraEnabled
        public String deliveredProductId;
        @AuraEnabled
        public Datetime FSEApplyForRepairTime;
        @AuraEnabled
        public String maintenanceContractId;
        @AuraEnabled
        public String URFLimitSerial;
        @AuraEnabled
        public String status;
        @AuraEnabled
        public String dealerId;
        @AuraEnabled
        public String dayLater30;
        @AuraEnabled
        public Boolean recallCorrespondence;
        @AuraEnabled
        public Boolean URFReapir;
        @AuraEnabled
        public String inchargeStaffId;
        @AuraEnabled
        public Boolean DWSign;
        @AuraEnabled
        public String DOJStatus;
        @AuraEnabled
        public String SAPcondition;
        // @AuraEnabled
        // public String AWSDataId;  //deloitte-zhj 20231228 PIPL还原
        
        // 2023/09/05 zhangchunxu start
        @AuraEnabled
        public List<Account> sql;
        // 2023/09/05 zhangchunxu end
        @AuraEnabled
        public String Status1C;
        @AuraEnabled
        public String RepairSubOrderC;
        @AuraEnabled
        public String OnCallIDC;
        @AuraEnabled
        public String QISIDC;
        @AuraEnabled
        public String InsReportC;
        @AuraEnabled
        public Datetime MBCAwareDateC;
        @AuraEnabled
        public String CFDANoHandC;
        @AuraEnabled
        public String ProduceCompanyHandC;
        @AuraEnabled
        public Boolean OfferRentalNewC;
        @AuraEnabled
        public Boolean ifRentalApplyC;
        @AuraEnabled
        public Datetime LatestCollectDatePriorityC;
        @AuraEnabled
        public String RentalApplyEquipmentSetDetailIdC;
        @AuraEnabled
        public String RentalApplyEquipmentSetDetailC;
        @AuraEnabled
        public String ProblemOccurredSelectC;
         @AuraEnabled
        public String Delay15MinC;
         @AuraEnabled
        public String ProductFailureRelatedC;
        @AuraEnabled
        public String Id;
        @AuraEnabled
        public String OCSMAdministrativeReportNumberC;
        @AuraEnabled
        public Datetime OCSMAdministrativeReportDateC;
        @AuraEnabled
        public Datetime AwareDateC;
        @AuraEnabled
        public String PAEDetermineC;
        @AuraEnabled
        public String ETQUPLOADSTATUSC;
        @AuraEnabled
        public String AEDetermineResultC;
        @AuraEnabled
        public String PAEDetermineACC;
        @AuraEnabled
        public Datetime RepairInspectionDateC;
        @AuraEnabled
        public boolean ContainUseRSAC;
         @AuraEnabled
        public String InchargeStaffEmailC;
         @AuraEnabled
        public String Name;
         @AuraEnabled
        public String HPNameC;
         @AuraEnabled
        public String DeliveredProductC;
         @AuraEnabled
        public String RepairProductSerialNoC;
         @AuraEnabled
        public String ServiceRepairNoC;
         @AuraEnabled
        public Datetime RepairFirstestimatedDateC;
         @AuraEnabled
        public Datetime RepairEstimatedDateC;
         @AuraEnabled
        public String RCInformationC;
        @AuraEnabled
        public String OCSMAdministrativeReportStatusC;
        @AuraEnabled
        public Datetime RepairShippedDateC;
        @AuraEnabled
        public Datetime partArrangementCompleteC;
        @AuraEnabled
        public String userID;
        @AuraEnabled
        public String profileId;
        @AuraEnabled
        public String userEmail;
        @AuraEnabled
        public String PaperRepairRequestNoC;
        @AuraEnabled
        public String HospitalC;
        @AuraEnabled
        public String AccountC;
        @AuraEnabled
        public String DepartmentClassC;
        @AuraEnabled
        public String RepairCostTypeC;
        @AuraEnabled
        public String DealerC;
        @AuraEnabled
        public String InchargeStaffC;
        @AuraEnabled
        public String InchargeStaffContactC;
        @AuraEnabled
        public String SalesOfficeCodeSelectionC;
        @AuraEnabled
        public String OnSiteRepairC;
        @AuraEnabled
        public String workLocationSelectC;
        @AuraEnabled
        public String ReturnsProductWayC;
        @AuraEnabled
        public String RepairDetailC;
        @AuraEnabled
        public String RepairApplicantC;
        @AuraEnabled
        public String RepairApplicantHospitalC;
        @AuraEnabled
        public String RepairApplicantDepartmentC;
        @AuraEnabled
        public String DeliveryLogisticsModeC;
        @AuraEnabled
        public Datetime engineerSendDateC;
        @AuraEnabled
        public String DeliveryLogisticsNoC;
        @AuraEnabled
        public String DeliveryLogisticsAnnotationC;
        @AuraEnabled
        public Datetime DateReceiptQuestionsC;
        @AuraEnabled
        public String BreakORFallOffC;
        @AuraEnabled
        public String DelayReportReasonC;
        @AuraEnabled
        public String UseFailProductFinishC;
        @AuraEnabled
        public String ifDeadHurtC;
        @AuraEnabled
        public String SupportingProductsC;
        @AuraEnabled
        public String ProblemOccurredC;
        @AuraEnabled
        public String AfterFailureInformationC;
        @AuraEnabled
        public String InformationFromC;
        @AuraEnabled
        public String ReportAdverseEventsC;
        @AuraEnabled
        public String FailureQInHospitalC;
        @AuraEnabled
        public String WhatProjectC;
        @AuraEnabled
        public String OperationOrExaminationNameC;
        @AuraEnabled
        public String MaintenanceContractTypeC;
        @AuraEnabled
        public Datetime FailureOccurrenceDateC;
        @AuraEnabled
        public String RepairSourceC;
        @AuraEnabled
        public String linkUrl;
 
        @AuraEnabled
        public String typeDeveloperName;
        @AuraEnabled
        public String ifTradeComplianceIntercept;
        @AuraEnabled
        public String ifTradeComplianceAlert;
        @AuraEnabled
        public String tradeComplianceStatusFlagFW;
        @AuraEnabled
        public String affiliationRC;
        @AuraEnabled
        public Boolean limitPrice;
        @AuraEnabled
        public String staticResourceRepair; //Deloitte-zhj PIPL解密 2023-08-23
        @AuraEnabled
        public String AssetName; //Deloitte-zhj  2023-09-14
        @AuraEnabled
        public String HPActiveC;
        @AuraEnabled
        public String AccountName; // WYL 贸易合规2期 add
        @AuraEnabled
        public String state; // WYL 贸易合规2期 add
        @AuraEnabled
        public String Asset_Model_No;// WYL 贸易合规2期 add
        @AuraEnabled
        public String ProTradeComplianceStatus;// WYL 贸易合规2期 add
     }
     public class CeilingContractData{
        @AuraEnabled
        public List<Repair__c> repairs;
        @AuraEnabled
        public List<Maintenance_Contract__c> maintenanceContract;
     }
}