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
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
@isTest
private class lexSelectAssetEstimateVMControllerTest {
    private static Id pricebookId = ControllerUtil.getStandardPricebook().Id;
    private static User staticUser;
    private static Maintenance_Contract_Estimate__c staticContactEsti;
    static Asset createAsset(String input, String accountid, String dcId, String hpId, String serialNo, String prId, String mark ) {
        Asset asset = new Asset();
        asset.Name = input;
        asset.AccountId = accountid;
        asset.Department_Class__c = dcId;
        asset.Hospital__c = hpId;
        asset.SerialNumber = serialNo;
        asset.Product2Id = prId;
        asset.InstallDate = Date.today();
        //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start
        //在接收参数的时候新增了String类型的Mark字段,以及在调用该方法时传递了String类型的Mark字段
        asset.AssetMark__c = mark;
        //JZHG-BSDUT4 ---20200825---update By rentongxiao---End 
        insert asset;
        return asset;
    }
 
    public class AssetInfo {
        public Integer lineNo {get; private set;}
        public Boolean rec_checkBox_c {get; set;}
        public Asset rec { get; set; }
        public Maintenance_Contract_Asset_Estimate__c mcae { get; set; }
        public Boolean isManual { get; set; }
        public Decimal orgPrice {get; private set;}
        public Id getRecId() {
            Id rtn = null;
            if (rec != null) {
                rtn = rec.Id;
            }
            return rtn;
        }
        public void setRecId(Id value) {
            // なにもしない
        }
        
        // Manual専用
        public AssetInfo(Integer lineNo) {
            this.lineNo = lineNo;
            this.rec = null;
            this.mcae = new Maintenance_Contract_Asset_Estimate__c(
                isNew__c = true
            );
            this.isManual = true;
            this.rec_checkBox_c = false;
            this.orgPrice = 0;
        }
    }
    //构造数据
    @TestSetup
    public static void setup(){
        ControllerUtil.EscapeNFM001Trigger = true;
 
        User u3 = new User();
        u3.LastName = '_サンブリッジ';
        u3.Alias = 'う';
        u3.Email = 'olympusTest03@sunbridge.com';
        u3.Username = 'olympusTest03@sunbridge.com';
        u3.CommunityNickname = 'う';
        u3.IsActive = true;
        u3.EmailEncodingKey = 'ISO-2022-JP';
        u3.TimeZoneSidKey = 'Asia/Tokyo';
        u3.LocaleSidKey = 'ja_JP';
        u3.LanguageLocaleKey = 'ja';
        u3.ProfileId = System.Label.ProfileId_SystemAdmin;
        u3.Job_Category__c = '销售服务';
        u3.Province__c = '北京市';
        u3.Use_Start_Date__c = Date.today().addMonths(-6);
        u3.HR_Post__c='总裁';
        insert u3;
        lexSelectAssetEstimateVMControllerTest.staticUser = u3;
        system.runAs(u3) {
            Address_Level__c address = new Address_Level__c(Level1_Code__c = 'CN-01',Name='北京市');
            insert address;
            // 病院を作る
            Account hospital = new Account();
            hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
            hospital.Name = 'test hospital';
            hospital.Is_Active__c = '有效';
            hospital.TradeComplianceStatus__c = '警示名单';
            hospital.State_Master__c = address.Id;
            insert hospital;
            
            // 戦略科室を得る
            List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
            
            // 診療科を作る
            Account dep = new Account();
            dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
            dep.Name = 'test dep';
            dep.ParentId = strategicDep[0].Id;
            dep.Department_Class__c = strategicDep[0].Id;
            dep.Hospital__c = hospital.Id;
            insert dep;
            
            // 製品を作る
            Product2 productA = new Product2( Name='テスト商品', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false);
            insert productA;
            
            // 価格表エントリを作成する        
            PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=productA.Id);
            entry.UnitPrice = 0;
            entry.IsActive = true;
            entry.UseStandardPrice = false;
            entry.CurrencyIsoCode = 'CNY';
            entry.Product2Id = productA.Id;
            insert entry;
            
            // 納入機器を作成する
            Asset asset01 = createAsset('asset01', dep.Id, strategicDep[0].Id, hospital.Id, '00001', productA.Id,'耗材');
            Asset asset02 = createAsset('asset02', dep.Id, strategicDep[0].Id, hospital.Id, '00002', productA.Id,'主机');
            Asset asset03 = createAsset('asset03', dep.Id, strategicDep[0].Id, hospital.Id, '00003', productA.Id,'耗材');
            Asset asset04 = createAsset('asset04', dep.Id, strategicDep[0].Id, hospital.Id, '00004', productA.Id,'主机');
            Asset asset05 = createAsset('asset05', dep.Id, strategicDep[0].Id, hospital.Id, '00005', productA.Id,'耗材');
            
            // 维修合同を作成する
            Maintenance_Contract__c contract = new Maintenance_Contract__c();
            contract.Name = 'tect contract';
            contract.Not_Upper_limit_reason__c = 'tect contract';
            contract.RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
            contract.Hospital__c = hospital.Id;
            contract.Department_Class__c = strategicDep[0].Id;
            contract.Department__c = dep.Id;
            contract.Service_Contract_Staff__c = u3.Id;
 
            insert contract;
 
            Maintenance_Contract__c contractLastyear = new Maintenance_Contract__c();
            contractLastyear.Name = 'tect contract contractLastyear';
            contractLastyear.Not_Upper_limit_reason__c = 'tect contract contractLastyear';
            contractLastyear.RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id;
            contractLastyear.Hospital__c = hospital.Id;
            contractLastyear.Department_Class__c = strategicDep[0].Id;
            contractLastyear.Department__c = dep.Id;
            contractLastyear.Service_Contract_Staff__c = u3.Id;
            contractLastyear.Contract_End_Date__c = Date.newInstance(2023, 1, 1);
            contractLastyear.Last_year_service_contract__c = contract.Id;
 
            insert contractLastyear;
            
            // 维修合同/保有设备を作成する
            Maintenance_Contract_Asset__c mca1 = new Maintenance_Contract_Asset__c();
            mca1.Asset__c = asset01.Id;
            mca1.Estimate_List_Price__c = 100;
            mca1.Maintenance_Contract__c = contract.Id;
            
            Maintenance_Contract_Asset__c mca2 = new Maintenance_Contract_Asset__c();
            mca2.Asset__c = asset01.Id;
            mca2.Estimate_List_Price__c = 100;
            mca2.Maintenance_Contract__c = contract.Id;
            
            Maintenance_Contract_Asset__c mca3 = new Maintenance_Contract_Asset__c();
            mca3.Asset__c = asset01.Id;
            mca3.Estimate_List_Price__c = 100;
            mca3.Maintenance_Contract__c = contractLastyear.Id;
            
 
            insert new Maintenance_Contract_Asset__c[] {mca1, mca2,mca3};
 
            asset01.CurrentContract_F_asset__c = mca2.id;
            update asset01;
            asset02.CurrentContract_F_asset__c = mca3.id;
            update asset02;
            Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
                RecordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract_Estimate__c' and DeveloperName = 'NewMaintenance_Quote'].id,
                Name = 'contract estimate 1',
                Maintenance_Contract__c = contract.Id,
                Contract_Esti_Start_Date__c = Date.today().addDays(1),
                Request_quotation_Amount__c = 1,
                EndUserType__c = '既有用户',
                mainTalksTime__c = 1,
                talksStartDate__c = Date.today(),
                Discount_reason__c = 'test',
                Improve_ConsumptionRate_Idea__c = 'test'
            );
            insert contactEsti1;
            
            Maintenance_Contract_Asset_Estimate__c mcae1 = new Maintenance_Contract_Asset_Estimate__c();
            mcae1.Asset__c = asset01.Id;
            mcae1.Adjustment_Upper_price__c = 1;
            mcae1.Adjustment_Lower_price__c = 1;
            mcae1.Maintenance_Contract_Estimate__c = contactEsti1.Id;
            mcae1.Estimate_List_Price__c = 1000;
            mcae1.Check_Result__c = 'OK';
 
            //lwc add
            mcae1.Asset_Consumption_rate__c = 10;
            
            Maintenance_Contract_Asset_Estimate__c mcae2 = new Maintenance_Contract_Asset_Estimate__c();
            mcae2.Asset__c = asset01.Id;
            mcae2.Adjustment_Upper_price__c = 1;
            mcae2.Adjustment_Lower_price__c = 1;
            mcae2.Maintenance_Contract_Estimate__c = contactEsti1.Id;
            mcae2.Estimate_List_Price__c = 1000;
            mcae2.Check_Result__c = 'OK';
 
            Maintenance_Contract_Asset_Estimate__c mcae3 = new Maintenance_Contract_Asset_Estimate__c();
            mcae3.Asset__c = asset01.Id;
            mcae3.Adjustment_Upper_price__c = 1;
            mcae3.Adjustment_Lower_price__c = 1;
            mcae3.Maintenance_Contract_Estimate__c = contactEsti1.Id;
            mcae3.Estimate_List_Price__c = 1000;
            mcae3.Check_Result__c = 'OK';
            mcae3.Product_Manual__c = productA.Id;
            
            insert new Maintenance_Contract_Asset_Estimate__c[] {mcae1, mcae2,mcae3};
 
            Achievement_linkage__c objAchievementlinkage = new Achievement_linkage__c(Consumption_rate_Lower__c =100, Consumption_rate_Upper__c=10,
                                                PriceCount_Lower__c =100, PriceCount_Upper__c = 20,Name = 'test');
            insert objAchievementlinkage;
 
            
        }
 
    }
 
    static testMethod void testInitById() {
        System.Test.startTest();
        User u3 = [SELECT Id FROM User WHERE Username = 'olympusTest03@sunbridge.com'];
        system.runAs(u3) {
 
            Maintenance_Contract_Estimate__c contactEsti1 = [SELECT Id FROM Maintenance_Contract_Estimate__c WHERE EndUserType__c = '既有用户' LIMIT 1];
 
            String initResById = lexSelectAssetEstimateVMController.init(contactEsti1.Id,'Id');
            System.assertEquals(true, initResById.length() > 0, '初始化信息异常');
            
        }
        System.Test.stopTest();
 
    }
    static testMethod void testInitByCopyId() {
        System.Test.startTest();
        User u3 = [SELECT Id FROM User WHERE Username = 'olympusTest03@sunbridge.com'];
        system.runAs(u3) {
 
            Maintenance_Contract_Estimate__c contactEsti1 = [SELECT Id FROM Maintenance_Contract_Estimate__c WHERE EndUserType__c = '既有用户' LIMIT 1];
            Maintenance_Contract__c contract = [SELECT Id,Past_Contract_end_day__c,Estimate_Num__c FROM Maintenance_Contract__c WHERE Not_Upper_limit_reason__c = 'tect contract' LIMIT 1];
 
            lexSelectAssetEstimateVMControllerTest.staticContactEsti = contactEsti1;
            String initResByCopyId = lexSelectAssetEstimateVMController.init(contactEsti1.Id,'copyid');
            System.assertEquals(true, initResByCopyId.length() > 0, '初始化信息异常');
            lexSelectAssetEstimateVMController.InitData transInitDataByCopyId = (lexSelectAssetEstimateVMController.InitData)JSON.deserialize(initResByCopyId, lexSelectAssetEstimateVMController.InitData.class);
        }
        System.Test.stopTest();
 
    }
    static testMethod void testInitByMcid() {
        System.Test.startTest();
        User u3 = [SELECT Id FROM User WHERE Username = 'olympusTest03@sunbridge.com'];
        system.runAs(u3) {
 
            Maintenance_Contract_Estimate__c contactEsti1 = [SELECT Id FROM Maintenance_Contract_Estimate__c WHERE EndUserType__c = '既有用户' LIMIT 1];
            Maintenance_Contract__c contract = [SELECT Id,Past_Contract_end_day__c,Estimate_Num__c FROM Maintenance_Contract__c WHERE Not_Upper_limit_reason__c = 'tect contract' LIMIT 1];
            Maintenance_Contract__c contractNoEstimate = [SELECT Id,Past_Contract_end_day__c,Estimate_Num__c FROM Maintenance_Contract__c WHERE Not_Upper_limit_reason__c = 'tect contract contractLastyear' LIMIT 1];
 
            lexSelectAssetEstimateVMControllerTest.staticContactEsti = contactEsti1;
            String initResByMcid = lexSelectAssetEstimateVMController.init(contract.Id,'mcid');
            String initResByMcidLastYear = lexSelectAssetEstimateVMController.init(contractNoEstimate.Id,'mcid');
            System.assertEquals(true, initResByMcid.length() > 0, '初始化信息异常');
            lexSelectAssetEstimateVMController.InitData transInitDataMcid = (lexSelectAssetEstimateVMController.InitData)JSON.deserialize(initResByMcid, lexSelectAssetEstimateVMController.InitData.class);
 
        }
        System.Test.stopTest();
 
    }
    static testMethod void testSave() {
        User u3 = [SELECT Id FROM User WHERE Username = 'olympusTest03@sunbridge.com'];
        
        system.runAs(u3) {
            System.Test.startTest();
            Maintenance_Contract_Estimate__c contactEsti1 = [SELECT Id,EndUserType__c,Request_quotation_Amount__c,mainTalksTime__c,talksStartDate__c,Improve_ConsumptionRate_Idea__c,GuidePrice_Up__c
                                                             ,Contract_Esti_Start_Date__c FROM Maintenance_Contract_Estimate__c WHERE EndUserType__c = '既有用户' LIMIT 1];
 
 
            lexSelectAssetEstimateVMController.InitData transInitDataById =  new lexSelectAssetEstimateVMController.InitData();
            transInitDataById.estimate = contactEsti1;
            transInitDataById.estimate.Discount_reason__c =  'test save';
 
            transInitDataById.estimate.Contract_Range__c = 10;
 
            transInitDataById.estimate.GuidePrice_Up__c = 0;
 
            transInitDataById.checkedAssets = new List<lexSelectAssetEstimateVMController.AssetInfo>();
            transInitDataById.currPage = 1;
            transInitDataById.selRecordOption = '20';
            transInitDataById.totalRecords = 0;
            transInitDataById.checkDealerId = '';
            //2021-11-30 fy add LJPH-C8W8FV 置顶 start
            transInitDataById.TopProductModel.add('CF-LV1I');
            transInitDataById.TopProductModel.add('CF-LV1L');
            transInitDataById.TopProductModel.add('CV-V1');
            transInitDataById.TopProductModel.add('GIF-LV1');
            transInitDataById.TopProductModel.add('OER-AW');
            transInitDataById.TopProductModel.add('OER-A');
            //2021-11-30 fy add LJPH-C8W8FV 置顶 end
            transInitDataById.typeresult = null;
            transInitDataById.changedAfterPrint = false;
            transInitDataById.changedSubmitPrice = false;
            transInitDataById.isSaveOrApproval = false;
            transInitDataById.OldContractStartDate = null;
            transInitDataById.OldMaintenancePrice = null;
            transInitDataById.inDicideFlag = false;
            transInitDataById.isSoft = false;
            transInitDataById.activeOn = true;
            
            //LJPH-BSS6E2  ---20200911 ---update by rentongxiao start
            transInitDataById.contr = '1';
            transInitDataById.val1 = '主机';
            
            String saveResById = lexSelectAssetEstimateVMController.save(JSON.serialize(transInitDataById));
            System.assertEquals(true, saveResById != null);
 
            transInitDataById.estimate.Contract_Esti_Start_Date__c = Date.today();
            saveResById = lexSelectAssetEstimateVMController.save(JSON.serialize(transInitDataById));
            // for exc
            saveResById = lexSelectAssetEstimateVMController.save('');
            System.Test.stopTest();
 
        }
    }
    
    static testMethod void testSave1() {
        User u3 = [SELECT Id FROM User WHERE Username = 'olympusTest03@sunbridge.com'];
        
        system.runAs(u3) {
            System.Test.startTest();
            Maintenance_Contract_Estimate__c contactEsti1 = [SELECT Id,EndUserType__c,Request_quotation_Amount__c,mainTalksTime__c,talksStartDate__c,Improve_ConsumptionRate_Idea__c,GuidePrice_Up__c
                                                             ,Contract_Esti_Start_Date__c FROM Maintenance_Contract_Estimate__c WHERE EndUserType__c = '既有用户' LIMIT 1];
 
 
            lexSelectAssetEstimateVMController.InitData transInitDataById =  new lexSelectAssetEstimateVMController.InitData();
            transInitDataById.estimate = contactEsti1;
            transInitDataById.estimate.Discount_reason__c =  'test save';
 
            transInitDataById.estimate.Contract_Range__c = 10;
 
            transInitDataById.estimate.GuidePrice_Up__c = 0;
 
            transInitDataById.checkedAssets = new List<lexSelectAssetEstimateVMController.AssetInfo>();
            transInitDataById.currPage = 1;
            transInitDataById.selRecordOption = '20';
            transInitDataById.totalRecords = 0;
            transInitDataById.checkDealerId = '';
            //2021-11-30 fy add LJPH-C8W8FV 置顶 start
            transInitDataById.TopProductModel.add('CF-LV1I');
            transInitDataById.TopProductModel.add('CF-LV1L');
            transInitDataById.TopProductModel.add('CV-V1');
            transInitDataById.TopProductModel.add('GIF-LV1');
            transInitDataById.TopProductModel.add('OER-AW');
            transInitDataById.TopProductModel.add('OER-A');
            //2021-11-30 fy add LJPH-C8W8FV 置顶 end
            transInitDataById.typeresult = null;
            transInitDataById.changedAfterPrint = false;
            transInitDataById.changedSubmitPrice = false;
            transInitDataById.isSaveOrApproval = false;
            transInitDataById.OldContractStartDate = null;
            transInitDataById.OldMaintenancePrice = null;
            transInitDataById.inDicideFlag = true;
            transInitDataById.isSoft = false;
            transInitDataById.activeOn = true;
            transInitDataById.contract= new Maintenance_Contract__c();
            transInitDataById.contract.Contract_End_Date__c = null;
            //LJPH-BSS6E2  ---20200911 ---update by rentongxiao start
            transInitDataById.contr = '1';
            transInitDataById.val1 = '主机';
            
            String saveResById = lexSelectAssetEstimateVMController.save(JSON.serialize(transInitDataById));
            System.assertEquals(true, saveResById != null);
 
            transInitDataById.estimate.Contract_Esti_Start_Date__c = Date.today();
            saveResById = lexSelectAssetEstimateVMController.save(JSON.serialize(transInitDataById));
            System.Test.stopTest();
 
        }
    }
 
    static testMethod void testOnChDealerUpdate() {
        System.Test.startTest();
        User u3 = [SELECT Id FROM User WHERE Username = 'olympusTest03@sunbridge.com'];
        system.runAs(u3) {
 
            Maintenance_Contract_Estimate__c contactEsti1 = [SELECT Id FROM Maintenance_Contract_Estimate__c WHERE EndUserType__c = '既有用户' LIMIT 1];
 
            lexSelectAssetEstimateVMControllerTest.staticContactEsti = contactEsti1;
            Account hospital =  [SELECT Id FROM Account WHERE Is_Active__c = '有效' LIMIT 1];
            String initResById = lexSelectAssetEstimateVMController.init(contactEsti1.Id,'Id');
            System.assertEquals(true, initResById.length() > 0, '初始化信息异常');
            lexSelectAssetEstimateVMController.InitData transInitDataById = (lexSelectAssetEstimateVMController.InitData)JSON.deserialize(initResById, lexSelectAssetEstimateVMController.InitData.class);
 
            transInitDataById.estimate.Discount_reason__c =  'test save';
            transInitDataById.estimate.Contract_Range__c = 10;
 
            String onChDealerUpdateResById = lexSelectAssetEstimateVMController.onChDealerUpdate(JSON.serialize(contactEsti1),hospital.Id);
            // for exc
            onChDealerUpdateResById = lexSelectAssetEstimateVMController.onChDealerUpdate('',hospital.Id);
            String refreshProductDataResById = lexSelectAssetEstimateVMController.refreshProductData(JSON.serialize(transInitDataById.checkedAssets),JSON.serialize(transInitDataById.TopProductModel),10,10);
            transInitDataById.checkedAssets[0].mcae.Product_Manual__c = [SELECT Id,Name FROM Product2 WHERE  Name='テスト商品' LIMIT 1].Id;
            refreshProductDataResById = lexSelectAssetEstimateVMController.refreshProductData(JSON.serialize(transInitDataById.checkedAssets),JSON.serialize(transInitDataById.TopProductModel),0,10);
            Boolean getMCAEIsCreateableResById = lexSelectAssetEstimateVMController.getMCAEIsCreateable();
 
            List<Asset> assetList = [SELECT Id, Maintenance_Price_Month__c, Posting_Date__c, InstallDate FROM Asset WHERE Name='asset01' OR  Name='asset02' OR  Name='asset03'];
 
            List<Id> IdList = new List<Id>();
            String idsStr = '';
            for (Asset assetObj : assetList) {
                idsStr +='\''+ assetObj.Id+'\',';
            }
            List<Asset> saveBeforeCheckPriceChangeAssetResById = lexSelectAssetEstimateVMController.saveBeforeCheckPriceChangeAsset(idsStr.substring(0,idsStr.length()-1));
            System.assertEquals(true, saveBeforeCheckPriceChangeAssetResById != null, 'saveBeforeCheckPriceChangeAsset 异常');
 
            idsStr = '';
            List<Product2> product2List = [SELECT Id,Name FROM Product2 WHERE  Name='テスト商品'];
            for (Product2 product2Obj : product2List) {
                idsStr +='\''+ product2Obj.Id+'\',';
            }
            List<Product2> saveBeforeCheckPriceChangeProduct2ResById = lexSelectAssetEstimateVMController.saveBeforeCheckPriceChangeProduct2(idsStr.substring(0,idsStr.length()-1));
 
            System.assertEquals(true, saveBeforeCheckPriceChangeProduct2ResById != null, 'saveBeforeCheckPriceChangeProduct2 异常');
        }
        System.Test.stopTest();
 
    }
    static testMethod void testSearchBtnEquals() {
        System.Test.startTest();
        User u3 = [SELECT Id FROM User WHERE Username = 'olympusTest03@sunbridge.com'];
        
        system.runAs(u3) {
 
            Maintenance_Contract_Estimate__c contactEsti1 = [SELECT Id FROM Maintenance_Contract_Estimate__c WHERE EndUserType__c = '既有用户' LIMIT 1];
            
            String initResById = lexSelectAssetEstimateVMController.init(contactEsti1.Id,'Id');
            System.assertEquals(true, initResById.length() > 0, '初始化信息异常');
            lexSelectAssetEstimateVMController.InitData transInitDataById = (lexSelectAssetEstimateVMController.InitData)JSON.deserialize(initResById, lexSelectAssetEstimateVMController.InitData.class);
 
            transInitDataById.estimate.Discount_reason__c =  'test save';
            transInitDataById.estimate.Contract_Range__c = 10;
           
            String saveResById = lexSelectAssetEstimateVMController.save(JSON.serialize(transInitDataById));
            String approvalProcessResById = lexSelectAssetEstimateVMController.approvalProcess(JSON.serialize(transInitDataById));
            String decideResById = lexSelectAssetEstimateVMController.decide(JSON.serialize(transInitDataById));
            String saveAndCancelResById = lexSelectAssetEstimateVMController.saveAndCancel(JSON.serialize(transInitDataById));
            Maintenance_Contract_Estimate__c contactEstiObj = [SELECT Id,Discount_reason__c FROM Maintenance_Contract_Estimate__c WHERE Name = 'contract estimate 1'];
            System.assertEquals(true,contactEstiObj.Discount_reason__c == 'test save');
 
            transInitDataById.text1 = 'S:AssetMark__c';
            transInitDataById.cond1 = 'equals';
            transInitDataById.val1 = '';
            String searchBtnResById = lexSelectAssetEstimateVMController.searchBtn(JSON.serialize(transInitDataById));
            System.assertEquals(true, searchBtnResById != null);
        }
        System.Test.stopTest();
    }
    static testMethod void testSearchBtnEqualsWithVal() {
        
        User u3 = [SELECT Id FROM User WHERE Username = 'olympusTest03@sunbridge.com'];
        
        system.runAs(u3) {
            System.Test.startTest();
            Maintenance_Contract_Estimate__c contactEsti1 = [SELECT Id FROM Maintenance_Contract_Estimate__c WHERE EndUserType__c = '既有用户' LIMIT 1];
            
            String initResById = lexSelectAssetEstimateVMController.init(contactEsti1.Id,'Id');
            System.assertEquals(true, initResById.length() > 0, '初始化信息异常');
            lexSelectAssetEstimateVMController.InitData transInitDataById = (lexSelectAssetEstimateVMController.InitData)JSON.deserialize(initResById, lexSelectAssetEstimateVMController.InitData.class);
 
            String addNewRowsResById = lexSelectAssetEstimateVMController.addNewRows(JSON.serialize(transInitDataById.checkedAssets));
            // for exc
            addNewRowsResById = lexSelectAssetEstimateVMController.addNewRows('');
 
            transInitDataById.text1 = 'S:AssetMark__c';
            transInitDataById.cond1 = 'equals';
            
            transInitDataById.val1 = '耗材,主机';
            String searchBtnResById = lexSelectAssetEstimateVMController.searchBtn(JSON.serialize(transInitDataById));
            System.assertEquals(true, searchBtnResById != null);
            System.Test.stopTest();
 
        }
    }
    static testMethod void testSearchBtnNotEquals() {
        
        User u3 = [SELECT Id FROM User WHERE Username = 'olympusTest03@sunbridge.com'];
        
        system.runAs(u3) {
            System.Test.startTest();
            Maintenance_Contract_Estimate__c contactEsti1 = [SELECT Id FROM Maintenance_Contract_Estimate__c WHERE EndUserType__c = '既有用户' LIMIT 1];
            
            String initResById = lexSelectAssetEstimateVMController.init(contactEsti1.Id,'Id');
            System.assertEquals(true, initResById.length() > 0, '初始化信息异常');
            lexSelectAssetEstimateVMController.InitData transInitDataById = (lexSelectAssetEstimateVMController.InitData)JSON.deserialize(initResById, lexSelectAssetEstimateVMController.InitData.class);
 
            transInitDataById.estimate.Discount_reason__c =  'test save';
            transInitDataById.estimate.Contract_Range__c = 10;
 
            transInitDataById.text1 = 'S:AssetMark__c';
            transInitDataById.cond1 = 'notequals';
            transInitDataById.val1 = '';
            String searchBtnResById = lexSelectAssetEstimateVMController.searchBtn(JSON.serialize(transInitDataById));
            System.assertEquals(true, searchBtnResById != null);
            
            transInitDataById.val1 = '耗材,主机';
            searchBtnResById = lexSelectAssetEstimateVMController.searchBtn(JSON.serialize(transInitDataById));
            System.Test.stopTest();
        }
    }
    static testMethod void testSearchBtnContains() {
        
        User u3 = [SELECT Id FROM User WHERE Username = 'olympusTest03@sunbridge.com'];
        
        system.runAs(u3) {
            System.Test.startTest();
            Maintenance_Contract_Estimate__c contactEsti1 = [SELECT Id FROM Maintenance_Contract_Estimate__c WHERE EndUserType__c = '既有用户' LIMIT 1];
            
            String initResById = lexSelectAssetEstimateVMController.init(contactEsti1.Id,'Id');
            System.assertEquals(true, initResById.length() > 0, '初始化信息异常');
            lexSelectAssetEstimateVMController.InitData transInitDataById = (lexSelectAssetEstimateVMController.InitData)JSON.deserialize(initResById, lexSelectAssetEstimateVMController.InitData.class);
 
            transInitDataById.estimate.Discount_reason__c =  'test save';
            transInitDataById.estimate.Contract_Range__c = 10;
 
            transInitDataById.text1 = 'S:AssetMark__c';
            transInitDataById.cond1 = 'contains';
            transInitDataById.val1 = '';
            String searchBtnResById = lexSelectAssetEstimateVMController.searchBtn(JSON.serialize(transInitDataById));
            System.assertEquals(true, searchBtnResById != null);
            
            transInitDataById.val1 = '耗材,主机';
            searchBtnResById = lexSelectAssetEstimateVMController.searchBtn(JSON.serialize(transInitDataById));
 
            transInitDataById.val1 = '耗材 主机';
            searchBtnResById = lexSelectAssetEstimateVMController.searchBtn(JSON.serialize(transInitDataById));
 
            transInitDataById.cond1 = 'starts with';
            searchBtnResById = lexSelectAssetEstimateVMController.searchBtn(JSON.serialize(transInitDataById));
            System.Test.stopTest();
 
        }
    }
    static testMethod void testExchangeAsset(){
        
        User u3 = [SELECT Id FROM User WHERE Username = 'olympusTest03@sunbridge.com'];
        
        system.runAs(u3) {
            System.Test.startTest();
            Maintenance_Contract_Estimate__c contactEsti1 = [SELECT Id FROM Maintenance_Contract_Estimate__c WHERE EndUserType__c = '既有用户' LIMIT 1];
            
            String initResById = lexSelectAssetEstimateVMController.init(contactEsti1.Id,'Id');
            System.assertEquals(true, initResById.length() > 0, '初始化信息异常');
            lexSelectAssetEstimateVMController.InitData transInitDataById = (lexSelectAssetEstimateVMController.InitData)JSON.deserialize(initResById, lexSelectAssetEstimateVMController.InitData.class);
 
            transInitDataById.unCheckedAssets[0].rec_checkBox_c = true;
            //Maintenance_Contract__c 上一期维修合同 
            Maintenance_Contract__c objMaintenanceContract = [SELECT Id,Contract_Consumption_rate__c FROM Maintenance_Contract__c WHERE Not_Upper_limit_reason__c = 'tect contract' LIMIT 1];
            System.debug(LoggingLevel.INFO, '***testExchangeAsset objMaintenanceContract: ' + objMaintenanceContract);
            transInitDataById.unCheckedAssets[0].rec.CurrentContract_F__c = objMaintenanceContract.Id;
            // transInitDataById.unCheckedAssets[0].mcae.Asset_Consumption_rate__c = 100;
 
            transInitDataById.estimate.Discount_reason__c =  'test save';
            transInitDataById.estimate.Contract_Range__c = 10;
 
            transInitDataById.text1 = 'S:AssetMark__c';
            transInitDataById.cond1 = 'contains';
            transInitDataById.val1 = '';
 
            String exchangeAssetResById = lexSelectAssetEstimateVMController.exchangeAsset(JSON.serialize(transInitDataById));
            System.assertEquals(true, exchangeAssetResById != null);
            // for exc
            exchangeAssetResById = lexSelectAssetEstimateVMController.exchangeAsset('');
 
            Maintenance_Contract__c contractNoEstimate = [SELECT Id,Past_Contract_end_day__c,Estimate_Num__c FROM Maintenance_Contract__c WHERE Not_Upper_limit_reason__c = 'tect contract contractLastyear' LIMIT 1];
            // contract.Hospital_Salesdepartment__c = '6.华南';
 
            String initResByMcidLastYear = lexSelectAssetEstimateVMController.init(contractNoEstimate.Id,'mcid');
            exchangeAssetResById = lexSelectAssetEstimateVMController.exchangeAsset(initResByMcidLastYear);
            System.Test.stopTest();
 
        }
    }
    static testMethod void testApprovalProcess() {
        User u3 = [SELECT Id FROM User WHERE Username = 'olympusTest03@sunbridge.com'];
 
        
        system.runAs(u3) {
            
            System.Test.startTest();
            Maintenance_Contract_Estimate__c contactEsti1 = [SELECT Id FROM Maintenance_Contract_Estimate__c WHERE EndUserType__c = '既有用户' LIMIT 1];
            
            String initResById = lexSelectAssetEstimateVMController.init(contactEsti1.Id,'Id');
            System.assertEquals(true, initResById.length() > 0, '初始化信息异常');
            lexSelectAssetEstimateVMController.InitData transInitDataById = (lexSelectAssetEstimateVMController.InitData)JSON.deserialize(initResById, lexSelectAssetEstimateVMController.InitData.class);
 
            String approvalProcessResById = lexSelectAssetEstimateVMController.approvalProcess(JSON.serialize(transInitDataById));
            System.assertEquals(true, approvalProcessResById != null);
            System.Test.stopTest();
 
        }
    }
    static testMethod void testShowLTYRepair() {
        User u3 = [SELECT Id FROM User WHERE Username = 'olympusTest03@sunbridge.com'];
 
        
        system.runAs(u3) {
            
            System.Test.startTest();
            Maintenance_Contract_Estimate__c contactEsti1 = [SELECT Id FROM Maintenance_Contract_Estimate__c WHERE EndUserType__c = '既有用户' LIMIT 1];
            
            String initResById = lexSelectAssetEstimateVMController.init(contactEsti1.Id,'Id');
            System.assertEquals(true, initResById.length() > 0, '初始化信息异常');
            lexSelectAssetEstimateVMController.InitData transInitDataById = (lexSelectAssetEstimateVMController.InitData)JSON.deserialize(initResById, lexSelectAssetEstimateVMController.InitData.class);
 
            transInitDataById.estimate.Discount_reason__c =  'test save';
            transInitDataById.estimate.Contract_Range__c = 10;
 
            String showLTYRepairResById = lexSelectAssetEstimateVMController.ShowLTYRepair(transInitDataById.targetEstimateId);
            //for exc
            showLTYRepairResById = lexSelectAssetEstimateVMController.ShowLTYRepair('');
            
            String toApprovalProcessResById = lexSelectAssetEstimateVMController.toApprovalProcess(JSON.serialize(transInitDataById));
            toApprovalProcessResById = lexSelectAssetEstimateVMController.toApprovalProcess('');
            String decideResById = lexSelectAssetEstimateVMController.decide(JSON.serialize(transInitDataById));
            String decideCancleResById = lexSelectAssetEstimateVMController.decideCancle(JSON.serialize(transInitDataById));
            decideCancleResById = lexSelectAssetEstimateVMController.decideCancle('');
            String undecideResById = lexSelectAssetEstimateVMController.undecide(transInitDataById.targetEstimateId,JSON.serialize(contactEsti1));
            System.assertEquals(true, undecideResById != null);
            System.Test.stopTest();
 
        }
    }
    static testMethod void testDecideSyncEstimateById() {
        User u3 = [SELECT Id FROM User WHERE Username = 'olympusTest03@sunbridge.com'];
        
        system.runAs(u3) {
            System.Test.startTest();
 
            //init id
            Maintenance_Contract_Estimate__c contactEsti2 = [SELECT Id,Contract_Esti_Start_Date__c,Contract_Range__c,Process_Status__c,EndUserType__c,Request_quotation_Amount__c,mainTalksTime__c,talksStartDate__c,Improve_ConsumptionRate_Idea__c,GuidePrice_Up__c
                                                             ,Contract_Start_Date__c FROM Maintenance_Contract_Estimate__c WHERE EndUserType__c = '既有用户' LIMIT 1];
            Maintenance_Contract_Asset_Estimate__c mcae = [SELECT Id,IsNew__c,Check_Object__c,Product_Manual__c,Estimate_List_Price__c,Check_Result__c,Repair_Price__c,Repair_Price_pass__c
                                                        ,Comment__c,EquipmentGuaranteeFlgTxt__c,Estimate_Cost__c,Adjustment_ratio_Upper__c,Adjustment_ratio_Lower__c,Adjustment_Upper_price__c
                                                        ,LastMContract_Price__c,Adjustment_Lower_price__c,Asset_Consumption_rate__c,Maintenance_Contract_Estimate__r.Contract_Esti_Start_Date__c
                                                        ,Estimate_List_Price_Page__c,Third_Party_Return__c,Product_Manual__r.Maintenance_Price_Month__c,Product_Manual__r.EquipmentGuaranteeFlg__c
                                                        ,Product_Manual__r.Asset_Model_No__c,Product_Manual__r.IS_StandardPricing__c,Asset__r.OwnershipMachine_No__c
                                                        ,Product_Manual__r.Category4__c 
                                                        FROM Maintenance_Contract_Asset_Estimate__c 
                                                        WHERE Maintenance_Contract_Estimate__c =:contactEsti2.Id AND Product_Manual__c != null LIMIT 1];
            // transInitDataById.checkedAssets.add(new lexSelectAssetEstimateVMController.AssetInfo(1,mcae));
            lexSelectAssetEstimateVMController.AssetInfo objAssetInfo = new lexSelectAssetEstimateVMController.AssetInfo(1,mcae);
            // contactEsti2.Process_Status__c = '批准';
            // update contactEsti2;
            String initResById = lexSelectAssetEstimateVMController.init(contactEsti2.Id,'Id');
            System.assertEquals(true, initResById.length() > 0, '初始化信息异常');
            lexSelectAssetEstimateVMController.InitData transInitDataById = (lexSelectAssetEstimateVMController.InitData)JSON.deserialize(initResById, lexSelectAssetEstimateVMController.InitData.class);
 
            transInitDataById.estimate.Discount_reason__c =  'test save';
            transInitDataById.estimate.Contract_Range__c = 10;
 
            String decideSyncEstimateResById = lexSelectAssetEstimateVMController.syncEstimate(true,true,transInitDataById);
 
            // transInitDataById.contract.
            transInitDataById.estimate.Process_Status__c = '批准';
            decideSyncEstimateResById = lexSelectAssetEstimateVMController.syncEstimate(false,true,transInitDataById);
 
            transInitDataById.changedAfterPrint = true;
            transInitDataById.estimate.Maintenance_Price__c = 0;
            decideSyncEstimateResById = lexSelectAssetEstimateVMController.syncEstimate(true,true,transInitDataById);
            System.assertEquals(true, decideSyncEstimateResById != null);
            System.Test.stopTest();
        }
    }
    static testMethod void testDecideSyncEstimateByMcid() {
        User u3 = [SELECT Id FROM User WHERE Username = 'olympusTest03@sunbridge.com'];
        
        system.runAs(u3) {
 
            System.Test.startTest();
            //mcid id
            Maintenance_Contract_Estimate__c contactEsti1 = [SELECT Id, Name, Maintenance_Contract__c, Estimation_Decision__c, CreatedDate, Service_Contract_Staff__c,
                                                             JingliApprovalManager__c, BuchangApprovalManager__c, ZongjianApprovalManager__c, Finally_Approved_Staff__c,
                                                             Contract_Esti_Start_Date__c, Contract_Esti_End_Date__c, Contract_Range__c, Contract_Start_Date__c, Contract_End_Date__c,
                                                             Maintenance_Contract_Status__c, Discount_reason__c, Improve_ConsumptionRate_Idea__c, Process_Status__c,
                                                             Estimate_Trial_Money__c, Maintenance_Price__c, Department__c, PrintDate__c, Quote_Date__c, Submit_quotation_day__c,
                                                             Examination_Price__c, Service_contract_target_number__c,IS_Reduced_price_approval__c,
                                                             Maintenance_Contract__r.Payment_Plan_Sum_First__c, Maintenance_Contract__r.Payment_Plan_Date_First__c,
                                                             Maintenance_Contract__r.Payment_Plan_Sum_Second__c,
                                                             Maintenance_Contract__r.Payment_Plan_Sum_Third__c,
                                                             Maintenance_Contract__r.Payment_Plan_Sum_Forth__c,
                                                             Maintenance_Contract__r.Payment_Plan_Sum_Fifth__c,
                                                             Maintenance_Contract__r.Payment_Plan_Sum_Sixth__c,
                                                             Discount_Price__c, Discount_Percentage__c, IsSyncing__c,
                                                             NotUse_Oxygenated_Water__c, Estimate_Target__c, Dealer__c,Dealer__r.FirstParagraphEnd__c,Is_RecognitionModel__c,
                                                             Append_Condition_Price__c, Asset_Sum_Price__c, Asset_Repair_Sum_Price__c,
                                                             Print_Contract__c, Print_RepairPrice__c, Print_DiscountPercentage__c, Print_Agent__c, Change_Dealer_Approval__c,
                                                             Print_DiscountPrice__c, Print_ListPrice__c, Print_MaintePrice__c, Print_SumPrice__c, Print_Tripartite__c, TKZongjianApprovalManager__c
                                                             //打印报价(简化版) 2019/12/18 start
                                                             , IS_Clone_After_Decide__c, New_contract_offer__c, NewEstimation_Amount__c, EndUserType__c, Print_Simplify__c
                                                             //打印报价(简化版) 2019/12/18 end
                                                             //最低价格 最高价格 申请背景相关字段 20200108 start
                                                             , GuidePrice_Up__c, GuidePrice_Down__c, finalPriceDecideWay__c, mainTalksTime__c, talksStartDate__c
                                                             , Combined_rate__c, New_Contract_Type_TxT__c, Estimate_Price_range__c
                                                             //最低价格 最高价格计算 20200108 end
                                                             , Sales_incidental__c, Consumption_rate_Forecast__c, AgencyHos_Price__c
                                                             // 申请报价金额 和 相对标准价格范围的折扣率
                                                             , Request_quotation_Amount__c, Service_discount_Rate__c, ContractPriceType__c
                                                             //上限合同 20230103 hql start
                                                             ,Limit_Price_Amount__c
                                                             //上限合同 20230103 hql end
                                                             , LastMContract1__c, LastMContract2__c, LastMContract3__c, LastMContract4__c, LastMContract5__c
                                                             , LastMContract1_ConCount__c, LastMContract2_ConCount__c, LastMContract3_ConCount__c, LastMContract4_ConCount__c, LastMContract5_ConCount__c,
                                                             LastMContract1_NO__c, LastMContract2_NO__c, LastMContract3_NO__c, LastMContract4_NO__c, LastMContract5_NO__c
                                                             //跳过点检标记 2021/07/28 gzw start
                                                             , Skip_DJ__c
                                                             //跳过点检标记 2021/07/28 gzw start
                                                             // 服务合同点检拦截逻辑修改 start
                                                              ,Approved_quotation_day__c
                                                             // 服务合同点检拦截逻辑修改 end
                                                             //WLIG-CDFBV3 开通续签报价为true的可以开放续签报价 thh 20220419 start
                                                             , Maintenance_Contract__r.Open_RenewalQuotation__c,Maintenance_Contract__r.VM_Contract_Check__c
                                                             //WLIG-CDFBV3 开通续签报价为true的可以开放续签报价 thh 20220419 end'
                                                            //LJPH-C9SCX7 【委托】合同无空白期的提醒  lt  20211221  start
                                                             // 报价规则改善20230314 start
                                                            , Maintenance_Contract__r.Past_Contract_end_day__c //过去合同结束日
                                                            ,renewTen_OFF__c
                                                            ,AgreeRenewTen_OFF__c
                                                            ,Monthly_Repair_Cost_SUM__c
                                                             // 报价规则改善20230314 end
                                                            //LJPH-C9SCX7 【委托】合同无空白期的提醒  lt  20211221  end
                                                            // URF限次合同2期 LY 20220811 start
                                                            ,URF_P_MaxRepairCount__c,URF_V_MaxRepairCount__c
                                                            ,URFMContract1__c,URFMContract1_startDate__c,URFMContract1_endDate__c
                                                            //,URFMContract2__c,URFMContract3__c,URFMContract4__c,URFMContract5__c
                                                            ,URF_LastMContract1_NO__c,URF_LastMContract2_NO__c,URF_LastMContract3_NO__c,URF_LastMContract4_NO__c,URF_LastMContract5_NO__c
                                                            ,URF_LastMContract1_ConCount__c,URF_LastMContract2_ConCount__c,URF_LastMContract3_ConCount__c,URF_LastMContract4_ConCount__c,URF_LastMContract5_ConCount__c
                                                            // URF限次合同2期 LY 20220811 end
                                                            //故障品加费  2022/12/16 start
                                                            ,Hospital_Salesdepartment__c
                                                            ,Send_Email_To_RC__c
                                                            //故障品加费  2022/12/16 end
                                                            //贸易合规 you start
                                                            ,Maintenance_Contract__r.AccDealerBlacklist__c 
                                                            ,Maintenance_Contract__r.Hospital__r.Name
                                                            ,Maintenance_Contract__r.Dealer__r.Name
                                                            ,CreatedById
                                                            //贸易合规 you end
                                                            // 报价合并 20230602 start
                                                            ,Maintenance_Contract__r.MaintanceContractPack__r.id
                                                            // 报价合并 20230602 end
                                                            //  报价页面【合同定价总额】字段添加 20230628 start
                                                            ,Total_Contract_Price__c FROM Maintenance_Contract_Estimate__c WHERE EndUserType__c = '既有用户' LIMIT 1];
 
            //targetEstimateId blank
            Maintenance_Contract__c contract = [SELECT Id,Past_Contract_end_day__c,Estimate_Num__c FROM Maintenance_Contract__c WHERE Not_Upper_limit_reason__c = 'tect contract' LIMIT 1];
            String initResByMcid = lexSelectAssetEstimateVMController.init(contract.Id,'mcid');
            lexSelectAssetEstimateVMController.InitData transInitDataByMcid = (lexSelectAssetEstimateVMController.InitData)JSON.deserialize(initResByMcid, lexSelectAssetEstimateVMController.InitData.class);
            contactEsti1.Contract_Esti_Start_Date__c = Date.newInstance(2022, 2,2);
            contactEsti1.Contract_Range__c = 12;
            transInitDataByMcid.estimate = contactEsti1;
            String decideSyncEstimateResByMcid = lexSelectAssetEstimateVMController.syncEstimate(false,false,transInitDataByMcid);
            System.assertEquals(true, decideSyncEstimateResByMcid != null);
            System.Test.stopTest();
            
        }
    }
    static testMethod void testPrint() {
        User u3 = [SELECT Id FROM User WHERE Username = 'olympusTest03@sunbridge.com'];
 
        
        system.runAs(u3) {
            System.Test.startTest();
            Maintenance_Contract_Estimate__c contactEsti1 = [SELECT Id FROM Maintenance_Contract_Estimate__c WHERE EndUserType__c = '既有用户' LIMIT 1];
            
            String initResById = lexSelectAssetEstimateVMController.init(contactEsti1.Id,'Id');
            System.assertEquals(true, initResById.length() > 0, '初始化信息异常');
            lexSelectAssetEstimateVMController.InitData transInitDataById = (lexSelectAssetEstimateVMController.InitData)JSON.deserialize(initResById, lexSelectAssetEstimateVMController.InitData.class);
 
            transInitDataById.estimate.Discount_reason__c =  'test save';
            transInitDataById.estimate.Contract_Range__c = 10;
            String printResById = lexSelectAssetEstimateVMController.print(JSON.serialize(transInitDataById));
            System.assertEquals(true, printResById != null);
            transInitDataById.estimate.Process_Status__c = '批准';
            printResById = lexSelectAssetEstimateVMController.print(JSON.serialize(transInitDataById));
            // for exc
            printResById = lexSelectAssetEstimateVMController.print('');
            System.Test.stopTest();
 
        }
    }
    static testMethod void testSendEmail() {
        
        User u3 = [SELECT Id FROM User WHERE Username = 'olympusTest03@sunbridge.com'];
        
        system.runAs(u3) {
            System.Test.startTest();
            Maintenance_Contract_Estimate__c contactEsti1 = [SELECT Id,EndUserType__c,Request_quotation_Amount__c,mainTalksTime__c,talksStartDate__c,Improve_ConsumptionRate_Idea__c,GuidePrice_Up__c
                                                             FROM Maintenance_Contract_Estimate__c WHERE EndUserType__c = '既有用户' LIMIT 1];
 
 
            lexSelectAssetEstimateVMController.InitData transInitDataById =  new lexSelectAssetEstimateVMController.InitData();
            transInitDataById.estimate = contactEsti1;
            transInitDataById.estimate.Discount_reason__c =  'test save';
 
            transInitDataById.estimate.Contract_Range__c = 10;
 
            transInitDataById.estimate.GuidePrice_Up__c = 0;
 
            transInitDataById.checkedAssets = new List<lexSelectAssetEstimateVMController.AssetInfo>();
 
            transInitDataById.currPage = 1;
            transInitDataById.selRecordOption = '20';
            transInitDataById.totalRecords = 0;
            transInitDataById.checkDealerId = '';
            //2021-11-30 fy add LJPH-C8W8FV 置顶 start
            transInitDataById.TopProductModel.add('CF-LV1I');
            transInitDataById.TopProductModel.add('CF-LV1L');
            transInitDataById.TopProductModel.add('CV-V1');
            transInitDataById.TopProductModel.add('GIF-LV1');
            transInitDataById.TopProductModel.add('OER-AW');
            transInitDataById.TopProductModel.add('OER-A');
            //2021-11-30 fy add LJPH-C8W8FV 置顶 end
            transInitDataById.typeresult = null;
            transInitDataById.changedAfterPrint = false;
            transInitDataById.changedSubmitPrice = false;
            transInitDataById.isSaveOrApproval = false;
            transInitDataById.OldContractStartDate = null;
            transInitDataById.OldMaintenancePrice = null;
            transInitDataById.inDicideFlag = false;
            transInitDataById.isSoft = false;
            transInitDataById.activeOn = true;
            
            //LJPH-BSS6E2  ---20200911 ---update by rentongxiao start
            transInitDataById.contr = '1';
            transInitDataById.val1 = '主机';
            transInitDataById.estimate.Contract_Esti_Start_Date__c = Date.today();
            // transInitDataById.estimate.Decided_Estimation__c ='';
 
            //走发邮件
            String sendEmailResById = lexSelectAssetEstimateVMController.sendEmail(JSON.serialize(transInitDataById));
            System.assertEquals(true, sendEmailResById != null);
            //验证返回结果
            transInitDataById.estimate.Contract_Range__c = null;
            sendEmailResById = lexSelectAssetEstimateVMController.sendEmail(JSON.serialize(transInitDataById));
            transInitDataById.estimate.Contract_Range__c = 10;
            transInitDataById.estimate.EndUserType__c = '';
            sendEmailResById = lexSelectAssetEstimateVMController.sendEmail(JSON.serialize(transInitDataById));
 
            String initResById = lexSelectAssetEstimateVMController.init(contactEsti1.Id,'Id');
            System.assertEquals(true, initResById.length() > 0, '初始化信息异常');
            transInitDataById = (lexSelectAssetEstimateVMController.InitData)JSON.deserialize(initResById, lexSelectAssetEstimateVMController.InitData.class);
 
            transInitDataById.estimate.Discount_reason__c =  'test save';
            transInitDataById.estimate.Contract_Range__c = 10;
            sendEmailResById = lexSelectAssetEstimateVMController.sendEmail(JSON.serialize(transInitDataById));
            System.Test.stopTest();
 
        }
    }
    static testMethod void testFirstPage() {
        
        User u3 = [SELECT Id FROM User WHERE Username = 'olympusTest03@sunbridge.com'];
        
        system.runAs(u3) {
            System.Test.startTest();
            Maintenance_Contract_Estimate__c contactEsti1 = [SELECT Id FROM Maintenance_Contract_Estimate__c WHERE EndUserType__c = '既有用户' LIMIT 1];
            Asset objAsset = [SELECT Id, Name,OwnershipMachine_No__c,Product2.ProductURF__c, Asset_situation__c, SerialNumber, Department_Name__c, Installation_Site__c, Posting_Date__c, Management_Code__c, IF_Warranty_Service__c, Reson_Can_not_Warranty__c,
                            InstallDate, isNewDate_use__c, Asset_Owner__c, Accumulation_Repair_Amount__c, Maintenance_Price_Month__c, Final_Examination_Date__c, CurrentContract_End_Date__c, EquipmentGuaranteeFlg__c,
                            CurrentContract_F__c, CurrentContract_F__r.Maintenance_Contract_No_F__c,CurrentContract_F__r.Management_Code__c, CurrentContract_F__r.RecordType_DeveloperName__c, CurrentContract_F__r.Estimate_Num__c, CurrentContract_F__r.Contract_End_Date__c, CurrentContract_F__r.Estimate_Contract_endDate__c,
                            CurrentContract_F_asset__c, CurrentContract_F_asset__r.Estimate_Cost_Month_formula__c, CurrentContract_F_asset__r.endDateGurantee_Text__c, CurrentContract_F__r.Gurantee_Estimate_startDate__c,
                            CurrentContract_F__r.First_Estimate_Date__c,
                            //变更多年保续签开始日 thh 20220315 start
                            CurrentContract_F__r.Gurantee_Renew_startDate__c,
                            //变更多年保续签开始日 thh 20220315 end
                            //   (2022年12月上线)故障品加费 start
                            Return_Without_Repair__r.Repair_List_Price_formula__c,
                            Return_Without_Repair__r.Agreed_Date__c,
                            //   (2022年12月上线)故障品加费 end
                            CurrentContract_F__r.Contract_Consumption_rate__c, CurrentContract_F__r.First_contract_usage_Rate__c,
                            CurrentContract_F__r.Contract_Range__c, AssetMark__c,
                            //WLIG-CDFBV3 开通续签报价为true的可以开放续签报价 thh 20220414 start
                            CurrentContract_F__r.Open_RenewalQuotation__c,CurrentContract_F__r.VM_Contract_Check__c,
                            //WLIG-CDFBV3 开通续签报价为true的可以开放续签报价 thh 20220414 end
                            // 2021-01-29 LJPH-BX9CVX mzy   add  合同报价时判断零件风险
                            NoPartRiskDate_F__c, NoPartRiskDate__c, SignableFlag__c,
                            Product2.PartSupplyFinishDate__c, Product2.PartSupplyFinishDateExp__c
                            // 2021-01-29 LJPH-BX9CVX mzy   add  合同报价时判断零件风险
                            //URF限次合同2期 LY 20220811 start
                            , URF_Maintenance_Contract__c
                            , URF_Maintenance_Contract__r.Management_Code__c
                            , URF_Maintenance_Contract__r.Contract_End_Date__c
                            //URF限次合同2期 LY 20220811 end
                            // 报价规则改善 20230315 start
                            ,IS_StandardPricing__c
                            // 报价规则改善 20230315 end
                            //多年保设备续签计算逻辑调整 2023/1/17 start
                            ,CurrentContract_F_asset__r.Asset_Consumption_Rate__c
                            ,CurrentContract_F_asset__r.Maintenance_Price_Year__c
                            ,CurrentContract_F_asset__r.IS_VMContract_Asset__c
                            ,Product2.Asset_Model_No__c
                            //  报价页面【合同定价总额】字段添加 20230608 start
                            ,Product2.Maintenance_Price_Year__c
                            //  报价页面【合同定价总额】字段添加 20230608 end
                            ,Product2.Category4__c
                            ,CurrentContract_F__r.endDateGurantee__c
                            //添加是否服务多年保修,多年保维修期至
                            ,IS_Extend_Gurantee__c,Extend_Gurantee_DateTo__c
                             //多年保设备续签计算逻辑调整 2023/1/17 end
                            FROM Asset WHERE Name = 'asset01' LIMIT 1];
            
            String initResById = lexSelectAssetEstimateVMController.init(contactEsti1.Id,'Id');
            System.assertEquals(true, initResById.length() > 0, '初始化信息异常');
            lexSelectAssetEstimateVMController.InitData transInitDataById = (lexSelectAssetEstimateVMController.InitData)JSON.deserialize(initResById, lexSelectAssetEstimateVMController.InitData.class);
 
            transInitDataById.estimate.Discount_reason__c =  'test save';
            // String firstPageResById = lexSelectAssetEstimateVMController.firstPage(JSON.serialize(transInitDataById));
            // System.assertEquals(true, firstPageResById != null);
            // String nextPageResById = lexSelectAssetEstimateVMController.nextPage(JSON.serialize(transInitDataById));
            // transInitDataById.currPage++;
            // String previousPageResById = lexSelectAssetEstimateVMController.previousPage(JSON.serialize(transInitDataById));
            // String endPageResById = lexSelectAssetEstimateVMController.endPage(JSON.serialize(transInitDataById));
            // String recordNumChangeResById = lexSelectAssetEstimateVMController.recordNumChange(JSON.serialize(transInitDataById));
            Boolean getApprovalBtnNewDisabledResById = lexSelectAssetEstimateVMController.getApprovalBtnNewDisabled();
            String interceptsendResById = lexSelectAssetEstimateVMController.interceptsend(JSON.serialize(transInitDataById.estimate),transInitDataById.targetEstimateId);
 
            // transInitDataById.currPage = 101;
            // nextPageResById = lexSelectAssetEstimateVMController.nextPage(firstPageResById);
            System.assertEquals(true, interceptsendResById != null);
            // for exc
            interceptsendResById = lexSelectAssetEstimateVMController.interceptsend('',transInitDataById.targetEstimateId);
 
            System.Test.stopTest();
        }
    }
    static testMethod void testPriceChangeReset() {
        User u3 = [SELECT Id FROM User WHERE Username = 'olympusTest03@sunbridge.com'];
        
        system.runAs(u3) {
 
            System.Test.startTest();
            Maintenance_Contract_Estimate__c contactEsti1 = [SELECT Id FROM Maintenance_Contract_Estimate__c WHERE EndUserType__c = '既有用户' LIMIT 1];
            lexSelectAssetEstimateVMController.Data dataObj = new lexSelectAssetEstimateVMController.Data(22,22,22,22);
 
            String initResById = lexSelectAssetEstimateVMController.init(contactEsti1.Id,'Id');
            System.assertEquals(true, initResById.length() > 0, '初始化信息异常');
            lexSelectAssetEstimateVMController.InitData transInitDataById = (lexSelectAssetEstimateVMController.InitData)JSON.deserialize(initResById, lexSelectAssetEstimateVMController.InitData.class);
 
            transInitDataById.estimate.Discount_reason__c =  'test save';
            transInitDataById.estimate.Contract_Range__c = 10;
 
            transInitDataById.changedSubmitPrice = true;
            String priceChangeResetResById = lexSelectAssetEstimateVMController.approvalProcess(JSON.serialize(transInitDataById));
            System.Test.stopTest();
 
        }
    }
    static testMethod void testComputeLTYRepair() {
        User u3 = [SELECT Id FROM User WHERE Username = 'olympusTest03@sunbridge.com'];
        system.runAs(u3) {
            System.Test.startTest();
            Maintenance_Contract_Estimate__c contactEsti1 = [SELECT Id FROM Maintenance_Contract_Estimate__c WHERE EndUserType__c = '既有用户' LIMIT 1];
            Account hospital =  [SELECT Id FROM Account WHERE Is_Active__c = '有效' LIMIT 1];
            Account dep = [SELECT Id FROM Account WHERE Hospital__c = :hospital.Id LIMIT 1];
            // 戦略科室を得る
            List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
            Asset asset01 = [SELECT Id FROM Asset WHERE Name = 'asset01' LIMIT 1];
            // 修理を作成する01
            Repair__c repair01 = new Repair__c();
            repair01.Account__c = dep.Id;
            repair01.Department_Class__c = strategicDep[0].Id;
            repair01.Hospital__c = hospital.Id;
            repair01.Delivered_Product__c = asset01.Id;
            repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays(0);  // 维修合同判断日がサービス契約の中間辺りの日付
            repair01.FSE_Work_Location__c = '上海';
            repair01.AWS_Data_Id__c = '123456789';
            repair01.Agreed_Date__c = Date.today().addDays(-1);
            insert repair01;
 
            String computeLTYRepairResById = lexSelectAssetEstimateVMController.ComputeLTYRepair(contactEsti1.Id);
            //sumPrice  savePrintFlg  setApprovalManager
            System.assertEquals(true, computeLTYRepairResById == null);
            System.Test.stopTest();
            
        }
    }
 
    static testMethod void testAccSendEmailFW(){
        Maintenance_Contract__c mc = [select id,name,Hospital__r.name,
                                        Hospital__r.TradeComplianceStatus__c,
                                        Dealer__r.TradeComplianceStatus__c,
                                        Dealer__r.name,
                                        Service_Contract_Staff__r.name,
                                        Service_Contract_Staff__r.Email
                                        from Maintenance_Contract__c  limit 1];
        lexSelectAssetEstimateVMController.accSendEmailFW(mc.id,'2222222','1',null);
        lexSelectAssetEstimateVMController.accSendEmailFW(mc.id,'2222222','2','2223d2d2d');
    }
 
    
    
}