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
@isTest
private class MaintenanceProductDataControllerTest {
    static void initHpData() {
        List<RecordType> rectCo = [select Id,DeveloperName from RecordType where IsActive = true and SobjectType = 'Maintenance_Product_Data__c'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectCo1 = [Select Id ,DeveloperName FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Product_Data_Details__c' and DeveloperName = 'GuranteeMain'];
        system.assertEquals('GuranteeMain',rectCo1[0].DeveloperName);
        //Profile prof = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证'];
        Product2 prod01 = new Product2(Name='Test01',
                            ProductCode='Test01',
                            Asset_Model_No__c = 'Test01',
                            SFDA_Status__c = '有効',
                            Product_Status__c = '正常销售',
                            SFDA_Approbated_Status__c = '有效',
                            Category3__c = 'CDS',
                            Category4__c = 'OER',
                            Category5__c = '其它',
                            IsActive = true,
                            Dealer_special_Object__c = true,
                            SFDA_Approbation_No__c = 'Test001',
                            Packing_list_manual__c = 1,
                            SFDA_Expiration_Date__c= Date.today(),
                            Intra_Trade_List_RMB_1__c = 1000,
                            Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
                            Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
                            Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
                            Important_Rroduct_1GI__c = true,
                            //-----
                            Intra_Trade_Service_RMB_1__c = 6000.00,
                            Intra_Trade_Service_RMB_Date1__c = Date.toDay().addMonths(-1),
                            Intra_Trade_Service_RMB_EndDate1__c = Date.toDay().addMonths(24),
                            
                            Intra_Trade_Gurantee_RMB_1__c = 6500.00 ,
                            Intra_Trade_Gurantee_RMB_Date1__c = Date.toDay().addMonths(-1),
                            Intra_Trade_Gurantee_RMB_End_Date1__c = Date.toDay().addMonths(24),
                            //-----
                            Extend_new_product_gurantee_MD__c = true,
                            Entend_gurantee_period_MD__c = '两年',
                            Extend_Gurantee_Start_MD__c = Date.toDay(),
                            Extend_Gurantee_End_MD__c = Date.toDay().addMonths(24)
                            );
        Product2 prod02 = new Product2(Name='Test02',
                            ProductCode='Test02',
                            Asset_Model_No__c = 'Test02',
                            SFDA_Status__c = '有効',
                            Product_Status__c = '正常销售',
                            SFDA_Approbated_Status__c = '有效',
                            Category3__c = 'ENT',
                            Category4__c = 'Celon',
                            Category5__c = 'Celon',
                            IsActive = true,
                            Dealer_special_Object__c = true,
                            SFDA_Approbation_No__c = 'Test002',
                            Packing_list_manual__c = 1,
                            SFDA_Expiration_Date__c= Date.today(),
                            Intra_Trade_List_RMB_1__c = 1000,
                            Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
                            Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
                            Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
                            Important_Rroduct_1GI__c = true,
                            //-----
                            Intra_Trade_Service_RMB_2__c = 6001.00,
                            Intra_Trade_Service_RMB_Date2__c = Date.toDay().addMonths(-1),
                            Intra_Trade_Service_RMB_EndDate2__c = Date.toDay().addMonths(24),
 
                            Intra_Trade_Gurantee_RMB_2__c = 6500.00 ,
                            Intra_Trade_Gurantee_RMB_Date2__c = Date.toDay().addMonths(-1),
                            Intra_Trade_Gurantee_RMB_End_Date2__c = Date.toDay().addMonths(24),
                            //-----
                            Extend_new_product_gurantee_MD__c = false,
                            Extend_new_product_gurantee__c = false
                            /*Entend_gurantee_period_MD__c = '两年',
                            Extend_Gurantee_Start_MD__c = Date.toDay(),
                            Extend_Gurantee_End_MD__c = Date.toDay().addMonths(24)*/
                            );
        Product2 prod03 = new Product2(Name='Test03',
                            ProductCode='Test03',
                            Asset_Model_No__c = 'Test03',
                            SFDA_Status__c = '有効',
                            Dealer_special_Object__c = true,
                            Product_Status__c = '正常销售',
                            SFDA_Approbated_Status__c = '有效',
                            Category3__c = 'US',
                            Category4__c = 'ALOKA',
                            Category5__c = '体外超声',
                            IsActive = true,
                            Intra_Trade_List_RMB_1__c = 1000,
                            Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
                            Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
                            Important_Rroduct_1GI__c = true,
                            //-----
                            Intra_Trade_Service_RMB_1__c = 6000.00,
                            Intra_Trade_Service_RMB_Date1__c = Date.toDay().addMonths(-2),
                            Intra_Trade_Service_RMB_EndDate1__c = Date.toDay().addMonths(24),
                            Intra_Trade_Service_RMB_2__c = 6002.00,
                            Intra_Trade_Service_RMB_Date2__c = Date.toDay().addMonths(-1),
                            Intra_Trade_Service_RMB_EndDate2__c = Date.toDay().addMonths(24),
 
                            Intra_Trade_Gurantee_RMB_1__c = 6500.00 ,
                            Intra_Trade_Gurantee_RMB_Date1__c = Date.toDay().addMonths(-2),
                            Intra_Trade_Gurantee_RMB_End_Date1__c = Date.toDay().addMonths(24),
                            Intra_Trade_Gurantee_RMB_2__c = 6500.00 ,
                            Intra_Trade_Gurantee_RMB_Date2__c = Date.toDay().addMonths(-1),
                            Intra_Trade_Gurantee_RMB_End_Date2__c = Date.toDay().addMonths(24),
                            //-----
                            Extend_new_product_gurantee__c = true,
                            Entend_gurantee_period__c = '两年',
                            Extend_Gurantee_Start__c = Date.toDay(),
                            Extend_Gurantee_End__c = Date.toDay().addMonths(24)
                            );
 
        Product2 prod04 = new Product2(Name='Test04',
            ProductCode='Test04',Asset_Model_No__c = 'Test04',
                            SFDA_Status__c = '有効',
                            Dealer_special_Object__c = true,
                            Product_Status__c = '正常销售',
                            SFDA_Approbated_Status__c = '有效',
                            Category3__c = 'OCS',
                            Category4__c = '附属品',
                            Category5__c = 'OCS',
                            IsActive = true,
                            Intra_Trade_List_RMB_1__c = 1000,
                            Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
                            Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
                            Important_Rroduct_1GI__c = true,
                            //-----
                            Intra_Trade_Service_RMB_1__c = 6003.00,
                            Intra_Trade_Service_RMB_Date1__c = Date.toDay().addMonths(-1),
                            Intra_Trade_Service_RMB_EndDate1__c = Date.toDay().addMonths(24),
                            Intra_Trade_Service_RMB_2__c = 6000.00,
                            Intra_Trade_Service_RMB_Date2__c = Date.toDay().addMonths(-2),
                            Intra_Trade_Service_RMB_EndDate2__c = Date.toDay().addMonths(24),
 
                            Intra_Trade_Gurantee_RMB_1__c = 6500.00 ,
                            Intra_Trade_Gurantee_RMB_Date1__c = Date.toDay().addMonths(-1),
                            Intra_Trade_Gurantee_RMB_End_Date1__c = Date.toDay().addMonths(24),
                            Intra_Trade_Gurantee_RMB_2__c = 6500.00 ,
                            Intra_Trade_Gurantee_RMB_Date2__c = Date.toDay().addMonths(-2),
                            Intra_Trade_Gurantee_RMB_End_Date2__c = Date.toDay().addMonths(24),
                            //-----
                            Extend_new_product_gurantee_MD__c = true,
                            Entend_gurantee_period_MD__c = '两年',
                            Extend_Gurantee_Start_MD__c = Date.toDay(),
                            Extend_Gurantee_End_MD__c = Date.toDay().addMonths(24)
                            );
        Product2 prod05 = new Product2(Name='Test05',
                            ProductCode='Test05',
                            Asset_Model_No__c = 'Test05',
                            SFDA_Status__c = '有効',
                            Dealer_special_Object__c = true,
                            Product_Status__c = '正常销售',
                            SFDA_Approbated_Status__c = '有效',
                            Category3__c = '光源',
                            Category4__c = 'CLV',
                            Category5__c = 'S45',
                            IsActive = true,
                            Intra_Trade_List_RMB_1__c = 1000,
                            Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
                            Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
                            Important_Rroduct_1GI__c = true,
                            Intra_Trade_Service_RMB_1__c = 6000.00,
                            Intra_Trade_Service_RMB_EndDate1__c = Date.toDay().addMonths(24),
                            Intra_Trade_Service_RMB_Date1__c = Date.toDay(),
                            Intra_Trade_Gurantee_RMB_End_Date1__c = Date.toDay().addMonths(24),
                            Intra_Trade_Gurantee_RMB_1__c = 6500.00 ,
                            Intra_Trade_Gurantee_RMB_Date1__c = Date.toDay().addMonths(-1)
                            );
        insert new Product2[] {prod01,prod02,prod03, prod04, prod05};
        SS_Batch_Column_Mapping__c oppMapping = new SS_Batch_Column_Mapping__c(Name = 'MaintenanceProductDataDetails', SS_TableName__c='Key_product_147P__c');
        oppMapping.From_Column_001__c = '1';
        oppMapping.SS_Column_001__c = '01.CV-290';
        oppMapping.From_Column_002__c = '2';                           // 重複してもエラーにはならない
        oppMapping.SS_Column_002__c = '02.GI-290镜子';
        insert new SS_Batch_Column_Mapping__c[] {oppMapping};
        //LJPH-C6A3DF 【委托】 【重要】产品主数据中增加服务用产品分类 LY 20210917 Star
        Service_Category6__c sc6 = new Service_Category6__c();
        sc6.Name = '260光源';
        insert sc6;
        Service_Category7__c sc7 = new Service_Category7__c();
        sc7.Name = 'CP监视器';
        insert sc7;
        //LJPH-C6A3DF 【委托】 【重要】产品主数据中增加服务用产品分类 LY 20210917 End  
    }
 
    // FY23修改 WLIG-CFV4AV 重点产品维护(新)start
    private static User getUser() {
        String timenow = Datetime.now().format('yyyyMMddHHmmss');
        // 20231219 ljh 删除掉 FirstName = 'TestMaoF',  
        User hpOwner = new User(Test_staff__c = true, LastName = 'TestMao', 
                Alias = 'hp', CommunityNickname = 'TestMao', Email = 'Test@sunbridge.com',
                Username = 'Test' + timenow + '@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', 
                TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = System.Label.ProfileId_SystemAdmin,
                Dept__c = '医疗华北营业本部', Province__c = '北京');
        insert hpOwner;
        return hpOwner;
    }
    // FY23修改 WLIG-CFV4AV 重点产品维护(新)end
 
    //分记录类型 重点产品区分维护ImportantProduct
    static testMethod void testMethod1() {
        
        User testuser = getUser();
        System.runAs(testuser) {
            initHpData();
            Maintenance_Product_Data__c m = new Maintenance_Product_Data__c();
            PageReference page = new PageReference('/apex/MaintenanceProductData?RecordTypeName=ImportantProduct&retURL=/a3V/o');
            page.setRedirect(true);
            System.Test.setCurrentPage(page);
            MaintenanceProductDataController mpdTest = new MaintenanceProductDataController(new ApexPages.StandardController(m));
            System.Test.startTest();
            mpdTest.size = 2;
            mpdTest.init();
            mpdTest.getKeyProduct147POps();
            mpdTest.getGuranteeTypeOps();
            mpdTest.getEntendGuranteePeriodOps();
            mpdTest.getDefaultFixtureArrivalProcessOps();
            mpdTest.getAssetLoanerCategoryOps();
            mpdTest.searchMaintenanceProductDataDetails();
            List<Product2> Product2Num = [select Id ,ProductCode_Ext__c,Name FROM Product2  WHERE IsActive = true ];
            system.assertEquals(5,Product2Num.size());
            system.assertEquals(5,mpdTest.mpdDetailsRecordsView.size());
            
            mpdTest.mpdDetailsRecordsView[0].check = true;
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.RecordTypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Product_Data_Details__c' and DeveloperName = 'ImportantProduct'].id;
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.Important_Endopartner_product__c = true;
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.Key_product_147P__c = '01.CV-290';
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.ProductsID__c = mpdTest.mpdDetailsRecordsView[0].Prod.id;
            mpdTest.mpdDetailsRecordsView[1].check = true;
            mpdTest.mpdDetailsRecordsView[1].mpdrdd.RecordTypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Product_Data_Details__c' and DeveloperName = 'ImportantProduct'].id;
            mpdTest.mpdDetailsRecordsView[1].mpdrdd.Important_Endopartner_product__c = true;
            mpdTest.mpdDetailsRecordsView[1].mpdrdd.Key_product_147P__c = '01.CV-290';
            mpdTest.mpdDetailsRecordsView[1].mpdrdd.Key_product_147P_Old__c = null;
            mpdTest.mpdDetailsRecordsView[1].mpdrdd.ProductsID__c = mpdTest.mpdDetailsRecordsView[1].Prod.id;
            mpdTest.save();
            //修改
            List<Maintenance_Product_Data__c> mList = [SELECT Id,Status__c,Name,RecordTypeId, RecordType.Name,RecordType.DeveloperName
                            FROM Maintenance_Product_Data__c ];
            system.assertEquals(1,mList.size());
            mpdTest.setEditAble();
            PageReference page1 = new PageReference('/apex/MaintenanceProductData?id='+mList[0].id+'&retURL=/a3V/o');
            page1.setRedirect(true);
            System.Test.setCurrentPage(page1);
            MaintenanceProductDataController mpdTest1 = new MaintenanceProductDataController(new ApexPages.StandardController(m));
            mpdTest1.init();
            List<Maintenance_Product_Data_Details__c> mdList = [SELECT Id,Status__c,Name
                            FROM Maintenance_Product_Data_Details__c where Maintenance_Product_Data__c=:mList[0].id];
            mpdTest1.size = 5;
            //mpdTest1.id = mList[0].id;
            //mpdTest1.category1 = 'Test';
            mpdTest1.searchMaintenanceProductDataDetails();
 
            //mpdTest1.mpdDetailsRecords[0].check = true;
            mpdTest1.mpdDetailsRecords[0].mpded.RecordTypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Product_Data_Details__c' and DeveloperName = 'ImportantProduct'].id;
            mpdTest1.mpdDetailsRecords[0].mpded.Important_Endopartner_product__c = false;
            mpdTest1.mpdDetailsRecords[0].mpded.Key_product_147P__c = '02.GI-290镜子';
            mpdTest1.mpdDetailsRecords[0].mpded.id = mdList[0].id;
            mpdTest1.mpdDetailsRecords[1].mpded.RecordTypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Product_Data_Details__c' and DeveloperName = 'ImportantProduct'].id;
            mpdTest1.mpdDetailsRecords[1].mpded.Important_Endopartner_product__c = false;
            mpdTest1.mpdDetailsRecords[1].mpded.Key_product_147P__c = '02.GI-290镜子';
            mpdTest1.mpdDetailsRecords[1].mpded.Key_product_147P_Old__c = null;
            mpdTest1.mpdDetailsRecords[1].mpded.id = mdList[1].id;
            //mpdTest1.save();
            mpdTest1.UpdateSave();
            mpdTest1.Submitmpd();
            List<Maintenance_Product_Data__c> mList1 = [SELECT Id,Status__c,Name,RecordTypeId, RecordType.Name,RecordType.DeveloperName
                            FROM Maintenance_Product_Data__c where id=:mpdTest1.id];
            List<Maintenance_Product_Data_Details__c> mdList1 = [SELECT Id,Status__c,Name,Key_product_147P__c,Key_product_147P_Old__c
                            FROM Maintenance_Product_Data_Details__c where Maintenance_Product_Data__c=:mList1[0].id];
            mdList1[1].Key_product_147P_Old__c   = null;
            update  mdList1;            
            system.assertEquals('02.GI-290镜子',mdList1[0].Key_product_147P__c);
            system.assertEquals('02.GI-290镜子',mdList1[1].Key_product_147P__c);
            system.assertEquals(null,mdList1[1].Key_product_147P_Old__c);
            system.assertEquals(1,mList1.size());
            if(mList1.size()>0){
                mList1[0].ApplyPersion__c = testuser.Id;
                mList1[0].BuchangApprovalRecommend__c = testuser.Id;
                mList1[0].Status__c = '完成';
                update mList1[0];
            }
            System.Test.stopTest();
        }
    }
    //多年保主数据维护 GuranteeMain
    static testMethod void testMethod2() {
        User testuser = getUser();
        System.runAs(testuser) {
            initHpData();
            Maintenance_Product_Data__c m = new Maintenance_Product_Data__c();
            PageReference page = new PageReference('/apex/MaintenanceProductData?RecordTypeName=GuranteeMain&retURL=/a3V/o');
            page.setRedirect(true);
            System.Test.setCurrentPage(page);
            MaintenanceProductDataController mpdTest = new MaintenanceProductDataController(new ApexPages.StandardController(m));
            System.Test.startTest();
            mpdTest.init();
            mpdTest.size = 5;
            //mpdTest.category1 = 'Test';
            mpdTest.searchMaintenanceProductDataDetails();
            mpdTest.mpdDetailsRecordsView[0].check = true;
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.RecordTypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Product_Data_Details__c' and DeveloperName = 'GuranteeMain'].id;
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.Entend_gurantee_period__c = '两年';
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.Gurantee_Start_Date__c = Date.toDay();
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.GuranteeType__c = '服务';
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.Gurantee_End_Date__c = Date.toDay().addMonths(24);
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.ProductsID__c = mpdTest.mpdDetailsRecordsView[0].Prod.id;
 
            mpdTest.mpdDetailsRecordsView[1].check = true;
            mpdTest.mpdDetailsRecordsView[1].mpdrdd.RecordTypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Product_Data_Details__c' and DeveloperName = 'GuranteeMain'].id;
            mpdTest.mpdDetailsRecordsView[1].mpdrdd.Entend_gurantee_period__c = '三年';
            mpdTest.mpdDetailsRecordsView[1].mpdrdd.Gurantee_Start_Date__c = Date.toDay();
            mpdTest.mpdDetailsRecordsView[1].mpdrdd.GuranteeType__c = '服务';
            mpdTest.mpdDetailsRecordsView[1].mpdrdd.Gurantee_End_Date__c = Date.toDay().addMonths(36);
            mpdTest.mpdDetailsRecordsView[1].mpdrdd.ProductsID__c = mpdTest.mpdDetailsRecordsView[1].Prod.id;
 
            mpdTest.mpdDetailsRecordsView[2].check = true;
            mpdTest.mpdDetailsRecordsView[2].mpdrdd.RecordTypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Product_Data_Details__c' and DeveloperName = 'GuranteeMain'].id;
            mpdTest.mpdDetailsRecordsView[2].mpdrdd.Entend_gurantee_period__c = '三年';
            mpdTest.mpdDetailsRecordsView[2].mpdrdd.Gurantee_Start_Date__c = Date.toDay();
            mpdTest.mpdDetailsRecordsView[2].mpdrdd.GuranteeType__c = '服务';
            mpdTest.mpdDetailsRecordsView[2].mpdrdd.Gurantee_End_Date__c = Date.toDay().addMonths(36);
            mpdTest.mpdDetailsRecordsView[2].mpdrdd.ProductsID__c = mpdTest.mpdDetailsRecordsView[2].Prod.id;
 
            mpdTest.mpdDetailsRecordsView[3].check = true;
            mpdTest.mpdDetailsRecordsView[3].mpdrdd.RecordTypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Product_Data_Details__c' and DeveloperName = 'GuranteeMain'].id;
            mpdTest.mpdDetailsRecordsView[3].mpdrdd.Entend_gurantee_period__c = '两年';
            mpdTest.mpdDetailsRecordsView[3].mpdrdd.Gurantee_Start_Date__c = Date.toDay();
            mpdTest.mpdDetailsRecordsView[3].mpdrdd.GuranteeType__c = '服务';
            mpdTest.mpdDetailsRecordsView[3].mpdrdd.Gurantee_End_Date__c = Date.toDay().addMonths(24);
            mpdTest.mpdDetailsRecordsView[3].mpdrdd.ProductsID__c = mpdTest.mpdDetailsRecordsView[3].Prod.id;
 
 
            mpdTest.save();
            mpdTest.Submitmpd();
            List<Maintenance_Product_Data__c> mList = [SELECT Id,Status__c,Name,RecordTypeId, RecordType.Name,RecordType.DeveloperName
                            FROM Maintenance_Product_Data__c where id=:mpdTest.id];
            system.assertEquals(1,mList.size());
            if(mList.size()>0){
                mList[0].Status__c = '审批中';
                update mList[0];
            } 
            PageReference page11 = new PageReference('/apex/MaintenanceProductData?id='+mList[0].id+'&retURL=/a3V/o');
            page11.setRedirect(true);
            MaintenanceProductDataController mpdTest11 = new MaintenanceProductDataController(new ApexPages.StandardController(m));
            mpdTest11.init();
 
            System.Test.setCurrentPage(page11);
            if(mList.size()>0){
                mList[0].Status__c = '服务填写';
                update mList[0];
            } 
            
            //修改
            mpdTest.setEditAble();
            PageReference page1 = new PageReference('/apex/MaintenanceProductData?id='+mList[0].id+'&retURL=/a3V/o');
            page1.setRedirect(true);
            System.Test.setCurrentPage(page1);
            MaintenanceProductDataController mpdTest1 = new MaintenanceProductDataController(new ApexPages.StandardController(m));
            mpdTest1.init();
 
            mpdTest1.mpdDetailsRecords[0].mpded.Intra_Trade_Service_RMB__c = null;
            mpdTest1.mpdDetailsRecords[0].mpded.Intra_Trade_Gurantee_RMB__c = 7500.00 ;
            mpdTest1.mpdDetailsRecords[0].mpded.Maintenance_Price_Year__c = 7000.00;
            mpdTest1.mpdDetailsRecords[1].mpded.Intra_Trade_Service_RMB__c = null;
            mpdTest1.mpdDetailsRecords[1].mpded.Intra_Trade_Gurantee_RMB__c = 7500.00 ;
            mpdTest1.mpdDetailsRecords[1].mpded.Maintenance_Price_Year__c = 7000.00;        
            mpdTest1.mpdDetailsRecords[2].mpded.Intra_Trade_Service_RMB__c = null;
            mpdTest1.mpdDetailsRecords[2].mpded.Intra_Trade_Gurantee_RMB__c = 7500.00 ;
            mpdTest1.mpdDetailsRecords[2].mpded.Maintenance_Price_Year__c = 7000.00;
            mpdTest1.mpdDetailsRecords[3].mpded.Intra_Trade_Service_RMB__c = null;
            mpdTest1.mpdDetailsRecords[3].mpded.Intra_Trade_Gurantee_RMB__c = 7500.00 ;
            mpdTest1.mpdDetailsRecords[3].mpded.Maintenance_Price_Year__c = 7000.00;
            mpdTest1.UpdateSave();
            ContentVersion version = new ContentVersion();
            version.Title = '123';
            version.VersionData = EncodingUtil.base64Decode('test');
            version.ContentLocation = 's';
            version.PathOnClient = '123.txt';
            insert version;
            version = [select ContentDocumentId from ContentVersion where Id =: version.Id];
            ContentDocumentLink link = new ContentDocumentLink();
            link.ContentDocumentId = version.ContentDocumentId;
            link.LinkedEntityId = mpdTest1.Id;
            link.ShareType = 'I';
            link.Visibility = 'AllUsers';
            insert link;
            // Attachment att = new Attachment(
            //     Name = 'test',
            //     ParentId = mpdTest1.Id,
            //     Body = EncodingUtil.base64Decode('test')
            // );
            // insert att;
            //system.assertEquals(1,mList.size());  
            if(mList.size()>0){
                mList[0].Status__c = '审批中-服务';
                update mList[0];
            }     
            if(mList.size()>0){
                mList[0].ApplyPersion__c = testuser.Id;
                mList[0].BuchangApprovalRecommend__c = testuser.Id;
                mList[0].Status__c = '完成';
                update mList[0];
            }
            System.Test.stopTest();
        }
    }
    //多年保价格维护 GuranteePrice
    static testMethod void testMethod3() {
        User testuser = getUser();
        System.runAs(testuser) {
            initHpData();
            Maintenance_Product_Data__c m = new Maintenance_Product_Data__c();
            PageReference page = new PageReference('/apex/MaintenanceProductData?RecordTypeName=GuranteePrice&retURL=/a3V/o');
            page.setRedirect(true);
            System.Test.setCurrentPage(page);
            MaintenanceProductDataController mpdTest = new MaintenanceProductDataController(new ApexPages.StandardController(m));
            System.Test.startTest();
            mpdTest.init();
            mpdTest.size = 5;
            //mpdTest.category1 = 'Test';
            mpdTest.searchMaintenanceProductDataDetails();
            mpdTest.mpdDetailsRecordsView[0].check = true;
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.RecordTypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Product_Data_Details__c' and DeveloperName = 'GuranteePrice'].id;
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.Intra_Trade_Gurantee_RMB__c = 7500.00 ;
            //mpdTest.mpdDetailsRecordsView[0].mpdrdd.Intra_Trade_Gurantee_RMB_DateFrom__c = Date.toDay();
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.Intra_Trade_Service_RMB__c = 8000.00;
            //mpdTest.mpdDetailsRecordsView[0].mpdrdd.Intra_Trade_Service_RMB_DateFrom__c =  Date.toDay();
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.Maintenance_Price_Year__c = 9000.00;
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.ProductsID__c = mpdTest.mpdDetailsRecordsView[0].Prod.id;
            mpdTest.save();
            //修改
            List<Maintenance_Product_Data__c> mList = [SELECT Id,Status__c,Name,RecordTypeId, RecordType.Name,RecordType.DeveloperName
                        FROM Maintenance_Product_Data__c ];
            system.assertEquals(1,mList.size());
            mpdTest.setEditAble();
            
            PageReference page1 = new PageReference('/apex/MaintenanceProductData?id='+mList[0].id+'&retURL=/a3V/o');
            page1.setRedirect(true);
            System.Test.setCurrentPage(page1);
            MaintenanceProductDataController mpdTest1 = new MaintenanceProductDataController(new ApexPages.StandardController(m));
            mpdTest1.init();
            //mpdTest1.UpdateSave();
            List<Maintenance_Product_Data__c> mListEdit = [SELECT Id,Status__c,Name,RecordTypeId, RecordType.Name,RecordType.DeveloperName
                            FROM Maintenance_Product_Data__c where id = :mpdTest1.id];
            ContentVersion version = new ContentVersion();
            version.Title = '123';
            version.VersionData = EncodingUtil.base64Decode('test11');
            version.ContentLocation = 's';
            version.PathOnClient = '123.txt';
            insert version;
            version = [select ContentDocumentId from ContentVersion where Id =: version.Id];
            ContentDocumentLink link = new ContentDocumentLink();
            link.ContentDocumentId = version.ContentDocumentId;
            link.LinkedEntityId = mListEdit[0].Id;
            link.ShareType = 'I';
            link.Visibility = 'AllUsers';
            insert link;
            // Attachment att = new Attachment(
            //     Name = 'test11',
            //     ParentId = mListEdit[0].Id,
            //     Body = EncodingUtil.base64Decode('test11')
            // );
            // insert att;
            mpdTest1.init();
            mpdTest1.UpdateSave();
            mpdTest1.Submitmpd();
            List<Maintenance_Product_Data__c> mListEdit1 = [SELECT Id,Status__c,Name,RecordTypeId, RecordType.Name,RecordType.DeveloperName
                            FROM Maintenance_Product_Data__c where id = :mpdTest1.id];
            system.assertEquals(1,mListEdit.size());               
            if(mListEdit1.size()>0){
                mListEdit1[0].ApplyPersion__c = testuser.Id;
                mListEdit1[0].BuchangApprovalRecommend__c = testuser.Id;
                mListEdit1[0].Status__c = '完成';
                update mListEdit1[0];
            }
            System.Test.stopTest();
        }
    }
    //修理信息维护 RepairInfo
    static testMethod void testMethod4() {
        User testuser = getUser();
            System.runAs(testuser) {
            initHpData();
            Maintenance_Product_Data__c m = new Maintenance_Product_Data__c();
            PageReference page = new PageReference('/apex/MaintenanceProductData?RecordTypeName=RepairInfo&retURL=/a3V/o');
            page.setRedirect(true);
            System.Test.setCurrentPage(page);
            MaintenanceProductDataController mpdTest = new MaintenanceProductDataController(new ApexPages.StandardController(m));
            System.Test.startTest();
            mpdTest.init();
            mpdTest.size = 2;
            //mpdTest.category1 = 'Test';
            mpdTest.searchMaintenanceProductDataDetails();
            //LJPH-C6A3DF 【委托】 【重要】产品主数据中增加服务用产品分类 LY 20210917 Star
            mpdTest.getCanRepairOps();
            mpdTest.getServiceCategory1();
            mpdTest.getServiceCategory2();
            mpdTest.getServiceCategory3();
            mpdTest.getServiceCategory4();
            mpdTest.getServiceCategory5();
            //LJPH-C6A3DF 【委托】 【重要】产品主数据中增加服务用产品分类 LY 20210917 END
            mpdTest.mpdDetailsRecordsView[0].check = true;
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.RecordTypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Product_Data_Details__c' and DeveloperName = 'RepairInfo'].id;
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.RepairListPriceLevelA__c = 1000 ;
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.RepairListPriceLevelB__c = 2000;
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.RepairListPriceLevelC__c = 3000;
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.CanRepairAccsessary__c = true;
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.Repair_Product_Code__c = 'test';
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.PartSupplyFinishDate__c = Date.toDay();
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.Maintenance_Price_Year__c = 8000.00;
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.ProductsID__c = mpdTest.mpdDetailsRecordsView[0].Prod.id;
            //LJPH-C6A3DF 【委托】 【重要】产品主数据中增加服务用产品分类 LY 20210917 Star
            // mpdTest.mpdDetailsRecordsView[0].mpdrdd.Can_Repair__c = '可';
            // mpdTest.mpdDetailsRecordsView[0].mpdrdd.Service_Category1__c = '本体';
            // mpdTest.mpdDetailsRecordsView[0].mpdrdd.Service_Category2__c = 'ENG';
            // mpdTest.mpdDetailsRecordsView[0].mpdrdd.Service_Category3__c = '硬性镜';
            // mpdTest.mpdDetailsRecordsView[0].mpdrdd.Service_Category4__c = '膀胱镜';
            // mpdTest.mpdDetailsRecordsView[0].mpdrdd.Service_Category5__c = '3D周边产品';
            //mpdTest.mpdDetailsRecordsView[0].mpdrdd.Service_Category6__c = cs6.Id;
            //mpdTest.mpdDetailsRecordsView[0].mpdrdd.Service_Category7__c = cs7.Id;
            //LJPH-C6A3DF 【委托】 【重要】产品主数据中增加服务用产品分类 LY 20210917 END
            mpdTest.save();
            //修改
            List<Maintenance_Product_Data__c> mList = [SELECT Id,Status__c,Name,RecordTypeId, RecordType.Name,RecordType.DeveloperName
                            FROM Maintenance_Product_Data__c ];
            system.assertEquals(1,mList.size());
            mpdTest.setEditAble();
            PageReference page1 = new PageReference('/apex/MaintenanceProductData?id='+mList[0].id+'&retURL=/a3V/o');
            page1.setRedirect(true);
            System.Test.setCurrentPage(page1);
            MaintenanceProductDataController mpdTest1 = new MaintenanceProductDataController(new ApexPages.StandardController(m));
            List<Maintenance_Product_Data__c> mListEdit = [SELECT Id,Status__c,Name,RecordTypeId, RecordType.Name,RecordType.DeveloperName
                            FROM Maintenance_Product_Data__c where id = :mpdTest1.id];
            ContentVersion version = new ContentVersion();
            version.Title = '123';
            version.VersionData = EncodingUtil.base64Decode('test11');
            version.ContentLocation = 's';
            version.PathOnClient = '123.txt';
            insert version;
            version = [select ContentDocumentId from ContentVersion where Id =: version.Id];
            ContentDocumentLink link = new ContentDocumentLink();
            link.ContentDocumentId = version.ContentDocumentId;
            link.LinkedEntityId = mListEdit[0].Id;
            link.ShareType = 'I';
            link.Visibility = 'AllUsers';
            insert link;
            // Attachment att = new Attachment(
            //     Name = 'test11',
            //     ParentId = mListEdit[0].Id,
            //     Body = EncodingUtil.base64Decode('test11')
            // );
            // insert att;
            mpdTest1.init();
            mpdTest1.UpdateSave();
            mpdTest1.Submitmpd();
            List<Maintenance_Product_Data__c> mListEdit1 = [SELECT Id,Status__c,Name,RecordTypeId, RecordType.Name,RecordType.DeveloperName
                            FROM Maintenance_Product_Data__c where id=:mpdTest1.id];
            if(mListEdit1.size()>0){
                mListEdit1[0].ApplyPersion__c = testuser.Id;
                mListEdit1[0].BuchangApprovalRecommend__c = testuser.Id;
                mListEdit1[0].Status__c = '完成';
                update mListEdit1[0];
            }
            System.Test.stopTest();  
        }
    }
    //备品信息维护 EquipmentInfo
    static testMethod void testMethod5() {
        User testuser = getUser();
        System.runAs(testuser) {
            initHpData();
            Maintenance_Product_Data__c m = new Maintenance_Product_Data__c();
            PageReference page = new PageReference('/apex/MaintenanceProductData?RecordTypeName=EquipmentInfo&retURL=/a3V/o');
            page.setRedirect(true);
            System.Test.setCurrentPage(page);
            MaintenanceProductDataController mpdTest = new MaintenanceProductDataController(new ApexPages.StandardController(m));
            System.Test.startTest();
            mpdTest.init();
            mpdTest.size = 2;
            //mpdTest.category1 = 'Test';
            mpdTest.searchMaintenanceProductDataDetails();
            mpdTest.mpdDetailsRecordsView[0].check = true;
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.RecordTypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Product_Data_Details__c' and DeveloperName = 'EquipmentInfo'].id;
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.Asset_loaner_category__c = '为资产管理' ;
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.Special_Model__c = true;
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.Fixture_Model_No__c = 'test001';
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.Packing_list_Fixture__c = 2 ;
            mpdTest.mpdDetailsRecordsView[0].mpdrdd.ProductsID__c = mpdTest.mpdDetailsRecordsView[0].Prod.id;
            mpdTest.save();
            //修改
            List<Maintenance_Product_Data__c> mList = [SELECT Id,Status__c,Name,RecordTypeId, RecordType.Name,RecordType.DeveloperName
                            FROM Maintenance_Product_Data__c ];
            system.assertEquals(1,mList.size());
            mpdTest.setEditAble();
            PageReference page1 = new PageReference('/apex/MaintenanceProductData?id='+mList[0].id+'&retURL=/a3V/o');
            page1.setRedirect(true);
            System.Test.setCurrentPage(page1);
            MaintenanceProductDataController mpdTest1 = new MaintenanceProductDataController(new ApexPages.StandardController(m));
            mpdTest1.init();
            mpdTest1.UpdateSave();
            mpdTest1.Submitmpd();
            List<Maintenance_Product_Data__c> mListEdit = [SELECT Id,Status__c,Name,RecordTypeId, RecordType.Name,RecordType.DeveloperName
                            FROM Maintenance_Product_Data__c where id=:mpdTest1.id];
            if(mListEdit.size()>0){
                mListEdit[0].ApplyPersion__c = testuser.Id;
                mListEdit[0].BuchangApprovalRecommend__c = testuser.Id;
                mListEdit[0].Status__c = '完成';
                update mListEdit[0];
            }
            System.Test.stopTest();   
        }
    }
}