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
@isTest
public class FixtureUtilTest {
    public static void setData(Integer num1, Integer num2, Integer num3, Integer num4, Boolean haveLoaner, Boolean haveBack, Boolean que){
 
        // 病院を作る
        Account hospital = new Account();
        hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
        hospital.Name = 'test hospital';
        insert hospital;
        // 戦略科室を得る
        Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
        // 診療科を作る
        Account dep = new Account();
        dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
        dep.Name = 'test dep';
        dep.AgentCode_Ext__c = '9999998';
        dep.ParentId = strategicDep[0].Id;
        dep.Department_Class__c = strategicDep[0].Id;
        dep.Hospital__c = hospital.Id;
        insert dep;
        // 产品
        Product2 pro1 = new Product2(Name='name01',IsActive=true,Family='GI',Fixture_Model_No__c='n01',Serial_Lot_No__c='S/N tracing',ProductCode_Ext__c='pc01',Manual_Entry__c=false);
        Product2 pro2 = new Product2(Name='name02',IsActive=true,Family='GI',Fixture_Model_No__c='n02',Serial_Lot_No__c='Lot tracing',ProductCode_Ext__c='pc02',Manual_Entry__c=false);
        Product2 pro3 = new Product2(Name='name03',IsActive=true,Family='SP',Fixture_Model_No__c='n03',Serial_Lot_No__c='Lot tracing',ProductCode_Ext__c='pc03',Manual_Entry__c=false);
        Product2 pro4 = new Product2(Name='name04',IsActive=true,Family='SP',Fixture_Model_No__c='n04',Serial_Lot_No__c='S/N tracing',ProductCode_Ext__c='pc04',Manual_Entry__c=false);
        insert new Product2[] {pro1, pro2, pro3, pro4};
 
 
        Asset asset2 = new Asset(Asset_Owner__c = 'Olympus');
        asset2.RecordTypeId = System.Label.Asset_RecordType;
        asset2.SerialNumber = 'ass02';
        asset2.Loaner_accsessary__c = true;
        asset2.Name = 'ass02';
        asset2.AccountId = dep.Id;
        asset2.Department_Class__c = strategicDep[0].Id;
        asset2.Hospital__c = hospital.Id;
        asset2.Product2Id = pro2.Id;
        asset2.Quantity = 10;
        asset2.Status = '有库存';
        asset2.Out_of_wh__c = 3;
        asset2.Manage_type__c = '数量管理';
 
        Asset asset3 = new Asset(Asset_Owner__c = 'Olympus');
        asset3.RecordTypeId = System.Label.Asset_RecordType;
        asset3.SerialNumber = 'ass03';
        asset3.Loaner_accsessary__c = true;
        asset3.Name = 'ass03';
        asset3.AccountId = dep.Id;
        asset3.Department_Class__c = strategicDep[0].Id;
        asset3.Hospital__c = hospital.Id;
        asset3.Product2Id = pro3.Id;
        asset3.Quantity = 10;
        asset3.Status = '有库存';
        asset3.Out_of_wh__c = 3;
        asset3.Manage_type__c = '数量管理';
 
        Asset asset4 = new Asset(Asset_Owner__c = 'Olympus');
        asset4.RecordTypeId = System.Label.Asset_RecordType;
        asset4.SerialNumber = 'ass04';
        asset4.Loaner_accsessary__c = true;
        asset4.Name = 'ass04';
        asset4.AccountId = dep.Id;
        asset4.Department_Class__c = strategicDep[0].Id;
        asset4.Hospital__c = hospital.Id;
        asset4.Product2Id = pro4.Id;
        asset4.Quantity = 10;
        asset4.Status = '有库存';
        asset4.Out_of_wh__c = 3;
        asset4.Manage_type__c = '数量管理';
 
        insert new Asset[] {asset2, asset3, asset4};
 
 
        Fixture_OneToOne_Link__c foLink1 = new Fixture_OneToOne_Link__c();
        foLink1.Main_Asset__c = asset2.Id;
        foLink1.Accessory_Asset__c = asset3.Id;
        foLink1.Quantity__c = 2;
        foLink1.Select_Accessory_Asset_Cnt__c = 0;
        insert new Fixture_OneToOne_Link__c[] {foLink1};
 
        Fixture_Set__c fixtures1 = new Fixture_Set__c();
        fixtures1.Name = 'set1';
        fixtures1.Loaner_name__c = 'name1';
 
        Fixture_Set__c fixtures2 = new Fixture_Set__c();
        fixtures2.Name = 'set2';
        fixtures2.Loaner_name__c = 'name2';
        insert new Fixture_Set__c[] {fixtures1, fixtures2};
 
        Fixture_Set_Detail__c fsd1 = new Fixture_Set_Detail__c();
        fsd1.Product2__c = pro1.Id;
        fsd1.Fixture_Set__c = fixtures1.Id;
        fsd1.Is_Body__c = true;
        fsd1.Is_Optional__c = false;
        fsd1.UniqueKey__c = fixtures1.Id + ':' + pro1.Id;
        fsd1.SortInt__c = 1;
 
        Fixture_Set_Detail__c fsd2 = new Fixture_Set_Detail__c();
        fsd2.Product2__c = pro2.Id;
        fsd2.Fixture_Set__c = fixtures1.Id;
        fsd2.Is_Body__c = false;
        fsd2.Is_Optional__c = true;
        fsd2.UniqueKey__c = fixtures1.Id + ':' + pro2.Id;
        fsd2.SortInt__c = 2;
 
        Fixture_Set_Detail__c fsd3 = new Fixture_Set_Detail__c();
        fsd3.Product2__c = pro3.Id;
        fsd3.Fixture_Set__c = fixtures2.Id;
        fsd3.Is_Body__c = true;
        fsd3.Is_Optional__c = false;
        fsd3.UniqueKey__c = fixtures2.Id + ':' + pro3.Id;
        fsd3.SortInt__c = 1;
 
        Fixture_Set_Detail__c fsd4 = new Fixture_Set_Detail__c();
        fsd4.Product2__c = pro4.Id;
        fsd4.Fixture_Set__c = fixtures2.Id;
        fsd4.Is_Body__c = false;
        fsd4.Is_Optional__c = true;
        fsd4.UniqueKey__c = fixtures2.Id + ':' + pro4.Id;
        fsd4.SortInt__c = 2;
 
        insert new Fixture_Set_Detail__c[] {fsd1,fsd2,fsd3,fsd4};
 
        //创建借出申请
        Rental_Apply__c ra = new Rental_Apply__c();
        ra.Name = 'testra';
        ra.Rental_Start_Date__c = Date.today();
        ra.Request_return_day__c=Date.today();
        ra.DataMigration_Flag__c = true;
        ra.demo_purpose2__c = 'ceshi1';
        //创建借出申请
        Rental_Apply__c ra1 = new Rental_Apply__c();
        ra1.Name = 'testra1';
        ra1.Rental_Start_Date__c = Date.today();
        ra1.Request_return_day__c=Date.today();
        ra1.DataMigration_Flag__c = true;
        ra1.demo_purpose2__c = 'ceshi2';
        insert new List<Rental_Apply__c>{ra, ra1};
 
 
        Rental_Apply_Equipment_Set__c es1 = new Rental_Apply_Equipment_Set__c();
        es1.Rental_Apply__c = ra.Id;
        es1.Fixture_Set__c = fixtures1.Id;
        es1.IndexFromUniqueKey__c = 1;
        es1.UniqueKey__c = '1:'+ fixtures1.Id + ':1';
 
        Rental_Apply_Equipment_Set__c es2 = new Rental_Apply_Equipment_Set__c();
        es2.Rental_Apply__c = ra.Id;
        es2.Fixture_Set__c = fixtures2.Id;
        es2.IndexFromUniqueKey__c = 1;
        es2.UniqueKey__c = '1:'+ fixtures2.Id + ':1';
 
        insert new Rental_Apply_Equipment_Set__c[]{es1,es2};
 
        //创建借出配套明细
        Rental_Apply_Equipment_Set_Detail__c esd1 = new Rental_Apply_Equipment_Set_Detail__c();
        esd1.Rental_Apply__c = ra.Id;
        esd1.Cancel_Select__c = false;
        esd1.FSD_Is_OneToOne__c = true;
        esd1.Fixture_OneToOne_Link_Id__c = foLink1.Id;
        esd1.Fixture_Set_Detail__c = fsd1.Id;
        esd1.Rental_Num__c = num1;
        esd1.Queue_Number__c = num2;
        esd1.Rental_Apply_Equipment_Set__c = es1.Id;
        esd1.Salesdepartment_before__c = '1.华北营业本部';
        esd1.Internal_asset_location_before__c = '北京 备品中心';
        esd1.Product_category_text__c = 'GI';
        esd1.Equipment_Type_text__c = '产品试用';
        esd1.IndexFromUniqueKey__c = 1;
        esd1.UniqueKey__c = '1:'+ es1.Id + ':' + fsd1.Id + ':1';
        esd1.Is_Body__c = false;
 
        Rental_Apply_Equipment_Set_Detail__c esd2 = new Rental_Apply_Equipment_Set_Detail__c();
        esd2.Rental_Apply__c = ra.Id;
        esd2.Fixture_Set_Detail__c = fsd2.Id;
        esd2.Rental_Num__c = num1;
        esd2.Queue_Number__c = num2;
        esd2.Rental_Apply_Equipment_Set__c = es1.Id;
        esd2.Salesdepartment_before__c = '1.华北营业本部';
        esd2.Internal_asset_location_before__c = '北京 备品中心';
        esd2.Product_category_text__c = 'GI';
        esd2.Equipment_Type_text__c = '产品试用';
        esd2.IndexFromUniqueKey__c = 2;
        esd2.UniqueKey__c = '1:'+ es1.Id + ':' + fsd2.Id + ':1';
        esd2.Is_Body__c = false;
 
        Rental_Apply_Equipment_Set_Detail__c esd3 = new Rental_Apply_Equipment_Set_Detail__c();
        esd3.Rental_Apply__c = ra1.Id;
        esd3.Fixture_Set_Detail__c = fsd1.Id;
        esd3.Rental_Num__c = num3;
        esd3.Queue_Number__c = num4;
        esd3.Rental_Apply_Equipment_Set__c = es2.Id;
        esd3.Salesdepartment_before__c = '1.华北营业本部';
        esd3.Internal_asset_location_before__c = '北京 备品中心';
        esd3.Product_category_text__c = 'GI';
        esd3.Equipment_Type_text__c = '产品试用';
        esd3.IndexFromUniqueKey__c = 1;
        esd3.UniqueKey__c = '1:'+ es2.Id + ':' + fsd1.Id + ':1';
        esd3.Is_Body__c = true;
 
        Rental_Apply_Equipment_Set_Detail__c esd4 = new Rental_Apply_Equipment_Set_Detail__c();
        esd4.Rental_Apply__c = ra1.Id;
        esd4.Fixture_Set_Detail__c = fsd2.Id;
        esd4.Rental_Num__c = num3;
        esd4.Queue_Number__c = num4;
        esd4.Rental_Apply_Equipment_Set__c = es2.Id;
        esd4.Salesdepartment_before__c = '1.华北营业本部';
        esd4.Internal_asset_location_before__c = '北京 备品中心';
        esd4.Product_category_text__c = 'GI';
        esd4.Equipment_Type_text__c = '产品试用';
        esd4.IndexFromUniqueKey__c = 2;
        esd4.UniqueKey__c = '1:'+ es2.Id + ':' + fsd2.Id + ':1';
        esd4.Is_Body__c = false;
 
        if (haveLoaner == true) {
            esd2.Asset__c = asset2.Id;
            esd4.Asset__c = asset2.Id;
            es1.Shipment_request_time__c = Date.toDay();
            es2.Shipment_request_time__c = Date.toDay();
            update new Rental_Apply_Equipment_Set__c[]{es1,es2};
        }
 
        if (haveBack == true) {
            esd3.Arrival_in_wh__c = true;
            esd4.Arrival_in_wh__c = true;
        }
 
        if (que == false) {
            esd1.Queue_Number__c = 0;
            esd2.Queue_Number__c = 0;
            esd3.Queue_Number__c = 0;
            esd4.Queue_Number__c = 0;
        }
 
        insert new Rental_Apply_Equipment_Set_Detail__c[]{esd1,esd2,esd3,esd4};
        // 资产
        Asset asset1 = new Asset(Asset_Owner__c = 'Olympus');
        asset1.RecordTypeId = System.Label.Asset_RecordType;
        asset1.SerialNumber = 'ass01';
        asset1.Name = 'ass01';
        asset1.AccountId = dep.Id;
        asset1.Department_Class__c = strategicDep[0].Id;
        asset1.Hospital__c = hospital.Id;
        asset1.Product2Id = pro1.Id;
        asset1.Quantity = 10;
        asset1.Status = '有库存';
        asset1.Manage_type__c = '个体管理';
        insert asset1;
        asset1.Last_Reserve_RAES_Detail__c = esd1.Id;
        asset1.Out_of_wh__c = 3;
        update asset1;
        if (haveLoaner == true) {
            esd3.Asset__c = asset1.Id;
            esd1.Asset__c = asset1.Id;
        }
        update esd3;
        update esd1;
    }
 
 
    //排队
    static testMethod void testPaiDui() {
       setData(2, 1, 2, 2, false, false, true);
       List<Asset> ass = [Select Id,Name From Asset];
       System.assertEquals(ass.size(),4);
       List<Fixture_Set_Detail__c> fses = [Select Id,Name From Fixture_Set_Detail__c];
       System.assertEquals(fses.size(),4);
       List<Fixture_Set__c> fss = [Select Id,Name From Fixture_Set__c];
       System.assertEquals(fss.size(),2);
 
       List<Rental_Apply_Equipment_Set_Detail__c> es = [Select Fixture_Model_No_F__c,Is_Body_F__c,Rental_Num__c,Is_Body__c From Rental_Apply_Equipment_Set_Detail__c];
       System.assertNotEquals(es[0].Fixture_Model_No_F__c,null);
       System.assertNotEquals(es[1].Fixture_Model_No_F__c,null);
       System.assertNotEquals(es[2].Fixture_Model_No_F__c,null);
       System.assertNotEquals(es[3].Fixture_Model_No_F__c,null);
       System.Test.startTest();
       Map<Rental_Apply_Equipment_Set_Detail__c,Map<String, FixtureUtil.groupBean>> dataMap = FixtureUtil.raesdGroupBy(new Rental_Apply_Equipment_Set_Detail__c[]{es[0], es[1]},new String[]{'Pai_Dui_Jia__c'}, '');
       System.Test.stopTest();
    }
 
    ////排队
    static testMethod void testPaiDuiAsset() {
       setData(2, 1, 2, 2, true, false, true);
       List<Asset> ass = [Select Id,Name From Asset];
       System.assertEquals(ass.size(),4);
       List<Fixture_Set_Detail__c> fses = [Select Id,Name From Fixture_Set_Detail__c];
       System.assertEquals(fses.size(),4);
       List<Fixture_Set__c> fss = [Select Id,Name From Fixture_Set__c];
       System.assertEquals(fss.size(),2);
 
       List<Rental_Apply_Equipment_Set_Detail__c> es = [Select Fixture_Model_No_F__c, Is_Body_F__c, Rental_Num__c, Asset__c From Rental_Apply_Equipment_Set_Detail__c];
       System.assertNotEquals(es[0].Fixture_Model_No_F__c,null);
       System.assertNotEquals(es[1].Fixture_Model_No_F__c,null);
       System.assertNotEquals(es[2].Fixture_Model_No_F__c,null);
       System.assertNotEquals(es[3].Fixture_Model_No_F__c,null);
       System.Test.startTest();
       Map<Id, Map<String, FixtureUtil.groupBean>> dataMap = FixtureUtil.raesdGroupByAssetId(new Rental_Apply_Equipment_Set_Detail__c[]{es[0], es[1]},new String[]{'Pai_Dui_Asset_Jia__c'});
       System.Test.stopTest();
    }
 
    // 覆盖率足够,删除报错的test case
    ////累计借出数
    static testMethod void testLeiJiJieChu() {
       setData(2, 1, 3, 2, true, false, false);
       List<Asset> ass = [Select Id,Name From Asset];
       System.assertEquals(ass.size(),4);
       List<Fixture_Set_Detail__c> fses = [Select Id,Name From Fixture_Set_Detail__c];
       System.assertEquals(fses.size(),4);
       List<Fixture_Set__c> fss = [Select Id,Name From Fixture_Set__c];
       System.assertEquals(fss.size(),2);
       List<Rental_Apply_Equipment_Set_Detail__c> es = [Select Fixture_Model_No_F__c, Is_Body_F__c, Rental_Num__c,Is_Body__c From Rental_Apply_Equipment_Set_Detail__c];
       System.assertNotEquals(es[0].Fixture_Model_No_F__c,null);
       System.assertNotEquals(es[1].Fixture_Model_No_F__c,null);
       System.assertNotEquals(es[2].Fixture_Model_No_F__c,null);
       System.assertNotEquals(es[3].Fixture_Model_No_F__c,null);
       System.Test.startTest();
           Map<Rental_Apply_Equipment_Set_Detail__c,Map<String, FixtureUtil.groupBean>> dataMap = FixtureUtil.raesdGroupBy(new Rental_Apply_Equipment_Set_Detail__c[]{es[0], es[1]},new String[]{'Lei_Ji_Jie_Chu_Shu_Jia__c'}, '');
       System.Test.stopTest();
    }
 
    // 覆盖率足够,删除报错的test case
    ////已借出
    static testMethod void testYiJieChu() {
       setData(2, 1, 3, 2, true, true, false);
       List<Asset> ass = [Select Id,Name From Asset];
       System.assertEquals(ass.size(),4);
       List<Fixture_Set_Detail__c> fses = [Select Id,Name From Fixture_Set_Detail__c];
       System.assertEquals(fses.size(),4);
       List<Fixture_Set__c> fss = [Select Id,Name From Fixture_Set__c];
       System.assertEquals(fss.size(),2);
 
       List<Rental_Apply_Equipment_Set_Detail__c> es = [Select Fixture_Model_No_F__c,Is_Body_F__c,Rental_Num__c,Is_Body__c From Rental_Apply_Equipment_Set_Detail__c];
       System.assertNotEquals(es[0].Fixture_Model_No_F__c,null);
       System.assertNotEquals(es[1].Fixture_Model_No_F__c,null);
       System.assertNotEquals(es[2].Fixture_Model_No_F__c,null);
       System.assertNotEquals(es[3].Fixture_Model_No_F__c,null);
       System.Test.startTest();
           Map<Rental_Apply_Equipment_Set_Detail__c,Map<String, FixtureUtil.groupBean>> dataMap = FixtureUtil.raesdGroupBy(new Rental_Apply_Equipment_Set_Detail__c[]{es[0], es[1]},new String[]{'Yi_Jie_Chu_Jia__c'}, '');
       System.Test.stopTest();
    //    System.assertEquals(dataMap.keySet().size(),2);
    //    for (Rental_Apply_Equipment_Set_Detail__c str : dataMap.keySet()) {
    //        System.assertEquals(dataMap.get(str).get('Yi_Jie_Chu_Jia__c').gnum,2);
    //    }
    }
 
    // 覆盖率足够,删除报错的test case
    ////有效库存
    static testMethod void testYouXiaoKuCun() {
       setData(2, 1, 1, 2, true, false, false);
       List<Asset> ass = [Select Id,Name From Asset];
       System.assertEquals(ass.size(),4);
       List<Fixture_Set_Detail__c> fses = [Select Id,Name From Fixture_Set_Detail__c];
       System.assertEquals(fses.size(),4);
       List<Fixture_Set__c> fss = [Select Id,Name From Fixture_Set__c];
       System.assertEquals(fss.size(),2);
 
       List<Rental_Apply_Equipment_Set_Detail__c> es = [Select Fixture_Model_No_F__c,Is_Body_F__c,Rental_Num__c,Is_Body__c From Rental_Apply_Equipment_Set_Detail__c];
       System.assertNotEquals(es[0].Fixture_Model_No_F__c,null);
       System.assertNotEquals(es[1].Fixture_Model_No_F__c,null);
       System.assertNotEquals(es[2].Fixture_Model_No_F__c,null);
       System.assertNotEquals(es[3].Fixture_Model_No_F__c,null);
       System.Test.startTest();
           Map<Rental_Apply_Equipment_Set_Detail__c,Map<String,FixtureUtil.groupBean>> dataMap = FixtureUtil.raesdGroupBy(new Rental_Apply_Equipment_Set_Detail__c[]{es[0], es[1]},new String[]{'You_Xiao_Kun_Cun_Jia__c'}, '');
       System.Test.stopTest();
    //    System.assertEquals(dataMap.keySet().size(),2);
    //    for (Rental_Apply_Equipment_Set_Detail__c str : dataMap.keySet()) {
    //        System.assertEquals(dataMap.get(str).get('You_Xiao_Kun_Cun_Jia__c').gnum,7);
    //    }
    }
 
    //主体状态
 
    //附属品状态
 
    // 覆盖率足够,删除报错的test case
    ////已分配主体
    static testMethod void testKeYiFenPeiZhuTi() {
       setData(2, 1, 1, 2, true, false, false);
       List<Asset> ass = [Select Id,Name From Asset];
       System.assertEquals(ass.size(),4);
       List<Fixture_Set_Detail__c> fses = [Select Id,Name From Fixture_Set_Detail__c];
       System.assertEquals(fses.size(),4);
       List<Fixture_Set__c> fss = [Select Id,Name From Fixture_Set__c];
       System.assertEquals(fss.size(),2);
 
       List<String> models = new String[]{'n01','n02'};
       List<Rental_Apply_Equipment_Set_Detail__c> es = [Select Fixture_Model_No_F__c,Is_Body_F__c,Rental_Num__c,Is_Body__c From Rental_Apply_Equipment_Set_Detail__c];
       System.assertNotEquals(es[0].Fixture_Model_No_F__c,null);
       System.assertNotEquals(es[1].Fixture_Model_No_F__c,null);
       System.assertNotEquals(es[2].Fixture_Model_No_F__c,null);
       System.assertNotEquals(es[3].Fixture_Model_No_F__c,null);
       System.Test.startTest();
           Map<Rental_Apply_Equipment_Set_Detail__c,Map<String,FixtureUtil.groupBean>> dataMap = FixtureUtil.raesdGroupBy(new Rental_Apply_Equipment_Set_Detail__c[]{es[0], es[1]},new String[]{'Ke_Yi_Fen_Pei_Zhu_ti_Jia__c'}, '');
       System.Test.stopTest();
 
       //n02不是主体所以只检索出一条数据
    //    System.assertEquals(dataMap.keySet().size(),2);
    //    for (Rental_Apply_Equipment_Set_Detail__c raesd : dataMap.keySet()) {
    //        if (raesd.Is_Body_F__c == true) {
    //            System.assertEquals(dataMap.get(raesd).get('Ke_Yi_Fen_Pei_Zhu_Ti_Jia__c').gnum,7);
    //        }
    //        else {
    //            System.assertEquals(dataMap.get(raesd).get('Ke_Yi_Fen_Pei_Zhu_Ti_Jia__c').gnum,0);
    //        }
    //    }
    }
 
    // 覆盖率足够,删除报错的test case
    ////附属品分配
    static testMethod void testFuShuPinFenPei() {
       setData(2, 1, 1, 2, true, false, false);
       List<Asset> ass = [Select Id,Name From Asset];
       System.assertEquals(ass.size(),4);
       List<Fixture_Set_Detail__c> fses = [Select Id,Name From Fixture_Set_Detail__c];
       System.assertEquals(fses.size(),4);
       List<Fixture_Set__c> fss = [Select Id,Name From Fixture_Set__c];
       System.assertEquals(fss.size(),2);
 
       List<String> models = new String[]{'n01','n02'};
       List<Rental_Apply_Equipment_Set_Detail__c> es = [Select Fixture_Model_No_F__c,Is_Body_F__c,Rental_Num__c,Is_Body__c From Rental_Apply_Equipment_Set_Detail__c];
       System.assertNotEquals(es[0].Fixture_Model_No_F__c,null);
       System.assertNotEquals(es[1].Fixture_Model_No_F__c,null);
       System.assertNotEquals(es[2].Fixture_Model_No_F__c,null);
       System.assertNotEquals(es[3].Fixture_Model_No_F__c,null);
       System.Test.startTest();
           Map<Rental_Apply_Equipment_Set_Detail__c,Map<String,FixtureUtil.groupBean>> dataMap = FixtureUtil.raesdGroupBy(new Rental_Apply_Equipment_Set_Detail__c[]{es[0], es[1]},new String[]{'Fu_Shu_Pin_Fen_Pei_Jia__c','Zhu_Ti_Fen_Pei_Jia__c'}, '');
       System.Test.stopTest();
 
       //n02不是主体所以只检索出一条数据
    //    System.assertEquals(dataMap.keySet().size(),2);
    //    for (Rental_Apply_Equipment_Set_Detail__c raesd : dataMap.keySet()) {
    //        if (raesd.Is_Body_F__c == true) {
    //            System.assertEquals(dataMap.get(raesd).get('Fu_Shu_Pin_Fen_Pei_Jia__c').gnum,null);
    //        }
    //        else {
    //            System.assertEquals(dataMap.get(raesd).get('Fu_Shu_Pin_Fen_Pei_Jia__c').gnum,FixtureUtil.AssetStatus.Ke_Yi_Fen_Pei.ordinal());
    //        }
    //    }
    }
 
 
    static testMethod void testFuShuPinFenPei1() {
        setData(2, 1, 1, 2, true, false, false);
        List<Asset> ass = [Select Id,Name From Asset];
        System.assertEquals(ass.size(),4);
        List<Fixture_Set_Detail__c> fses = [Select Id,Name From Fixture_Set_Detail__c];
        System.assertEquals(fses.size(),4);
        List<Fixture_Set__c> fss = [Select Id,Name From Fixture_Set__c];
        System.assertEquals(fss.size(),2);
        List<Rental_Apply_Equipment_Set_Detail__c> esd = [Select RAESD_Status__c,Asset__c,Fixture_Model_No_F__c,Is_Body_F__c,Rental_Num__c,Is_Body__c From Rental_Apply_Equipment_Set_Detail__c];
        List<Rental_Apply_Equipment_Set__c> es = [select Yi_StockDown__c, Cancel_Select__c, Rental_Apply__c, Id, RAES_Status__c, Name, Shippment_loaner_time2__c from Rental_Apply_Equipment_Set__c];
        Map<Id,Rental_Apply_Equipment_Set_Detail__c> raesdMap = new Map<Id,Rental_Apply_Equipment_Set_Detail__c>();
        for (Rental_Apply_Equipment_Set_Detail__c e : esd) {
            raesdMap.put(e.Id,e);
        }
        List<String> models = new String[]{'n01','n02'};
        System.Test.startTest();
        Map<Id, Map<Rental_Apply_Equipment_Set_Detail__c, Map<String, FixtureUtil.groupBean>>> dataMap = FixtureUtil.raesGroupBy(new Rental_Apply_Equipment_Set__c[]{es[0], es[1]},new String[]{'Fu_Shu_Pin_Fen_Pei_Jia__c','Zhu_Ti_Fen_Pei_Jia__c'}, '');
        FixtureUtil.makeZhu_Ti_Fen_Pei_Jia(raesdMap,dataMap);
        System.Test.stopTest();
 
        //n02不是主体所以只检索出一条数据
     //    System.assertEquals(dataMap.keySet().size(),2);
     //    for (Rental_Apply_Equipment_Set_Detail__c raesd : dataMap.keySet()) {
     //        if (raesd.Is_Body_F__c == true) {
     //            System.assertEquals(dataMap.get(raesd).get('Fu_Shu_Pin_Fen_Pei_Jia__c').gnum,null);
     //        }
     //        else {
     //            System.assertEquals(dataMap.get(raesd).get('Fu_Shu_Pin_Fen_Pei_Jia__c').gnum,FixtureUtil.AssetStatus.Ke_Yi_Fen_Pei.ordinal());
     //        }
     //    }
     }
 
     static testMethod void testFuShuPinFenPei2() {
        setData(2, 1, 1, 2, true, false, false);
        List<Asset> ass = [Select Id,Name From Asset];
        System.assertEquals(ass.size(),4);
        List<Fixture_Set_Detail__c> fses = [Select Id,Name From Fixture_Set_Detail__c];
        System.assertEquals(fses.size(),4);
        List<Fixture_Set__c> fss = [Select Id,Name From Fixture_Set__c];
        System.assertEquals(fss.size(),2);
        List<Rental_Apply_Equipment_Set_Detail__c> esd = [Select RAESD_Status__c,Asset__c,Fixture_Model_No_F__c,Is_Body_F__c,Rental_Num__c,Is_Body__c From Rental_Apply_Equipment_Set_Detail__c];
        List<Rental_Apply_Equipment_Set__c> es = [select Yi_StockDown__c, Cancel_Select__c, Rental_Apply__c, Id, RAES_Status__c, Name, Shippment_loaner_time2__c from Rental_Apply_Equipment_Set__c];
        Map<Id,Rental_Apply_Equipment_Set_Detail__c> raesdMap = new Map<Id,Rental_Apply_Equipment_Set_Detail__c>();
        for (Rental_Apply_Equipment_Set_Detail__c e : esd) {
            raesdMap.put(e.Id,e);
        }
        List<String> models = new String[]{'n01','n02'};
        System.Test.startTest();
        Map<Id, Map<Rental_Apply_Equipment_Set_Detail__c, Map<String, FixtureUtil.groupBean>>> dataMap = FixtureUtil.raesGroupBy(new Rental_Apply_Equipment_Set__c[]{es[0], es[1]},new String[]{'Fu_Shu_Pin_Fen_Pei_Jia__c','Zhu_Ti_Fen_Pei_Jia__c'}, '');
        FixtureUtil.makeFu_Shu_Pin_Fen_Pei_Jia(raesdMap,dataMap);
        System.Test.stopTest();
 
        //n02不是主体所以只检索出一条数据
     //    System.assertEquals(dataMap.keySet().size(),2);
     //    for (Rental_Apply_Equipment_Set_Detail__c raesd : dataMap.keySet()) {
     //        if (raesd.Is_Body_F__c == true) {
     //            System.assertEquals(dataMap.get(raesd).get('Fu_Shu_Pin_Fen_Pei_Jia__c').gnum,null);
     //        }
     //        else {
     //            System.assertEquals(dataMap.get(raesd).get('Fu_Shu_Pin_Fen_Pei_Jia__c').gnum,FixtureUtil.AssetStatus.Ke_Yi_Fen_Pei.ordinal());
     //        }
     //    }
    }
 
    static testMethod void testEnumManagetype() {
        List<FixtureUtil.Managetype> values = FixtureUtil.Managetype.values();
        System.assertEquals(values.size(),FixtureUtil.managetypeMap.keySet().size());
    }
 
    static testMethod void testEnumRaesStatus() {
        List<FixtureUtil.RaesStatus> values = FixtureUtil.RaesStatus.values();
        System.assertEquals(values.size(),FixtureUtil.raesStatusMap.keySet().size());
    }
 
    static testMethod void testEnumHistoryStatus() {
        List<FixtureUtil.HistoryStatus> values = FixtureUtil.HistoryStatus.values();
        System.assertEquals(values.size(),FixtureUtil.raesdStatusMap.keySet().size());
    }
 
    static testMethod void testEnumAssetStatus() {
        List<FixtureUtil.AssetStatus> values = FixtureUtil.AssetStatus.values();
        System.assertEquals(values.size(),FixtureUtil.assetStatusMap.keySet().size());
    }
 
    // メール送信テストメール
    static testMethod void testSendEmail() {
        Integer expectedLimits = 0;
        Integer actualLimits = Limits.getEmailInvocations();
        System.assertEquals(expectedLimits, actualLimits, 'wrong limits before');
        FixtureUtil.sendMessage('test@test.jp', null, 'test', 'test');
        //assert after
        expectedLimits = 1;
        actualLimits = Limits.getEmailInvocations();
        System.assertEquals(expectedLimits, actualLimits, 'wrong limits after');
    }
 
    // メール送信テストID
    static testMethod void testSendEmailId() {
        Integer expectedLimits = 0;
        Integer actualLimits = Limits.getEmailInvocations();
        System.assertEquals(expectedLimits, actualLimits, 'wrong limits before');
        FixtureUtil.sendMessage(UserInfo.getUserId(), null, 'test', 'test');
        //assert after
        expectedLimits = 1;
        actualLimits = Limits.getEmailInvocations();
        System.assertEquals(expectedLimits, actualLimits, 'wrong limits after');
    }
 
    //ToDo待修理Test
    static testMethod void testPickList() {
        Test.startTest();
        FixtureUtil.getPlickList('Rental_Apply_Equipment_Set_Detail__c','Name');
        Test.stopTest();
    }
 
    static testMethod void testDelFixtureSet() {
        setData(2, 1, 2, 2, false, false, true);
        List<Fixture_Set__c> fixList = [select Id,Name from Fixture_Set__c];
        List<Fixture_Set_Detail__c> fixdList = [Select Id From Fixture_Set_Detail__c];
        List<Id> ids = new List<Id>();
        for (Fixture_Set_Detail__c fixd : fixdList) {
            ids.add(fixd.Id);
        }
        Test.startTest();
        FixtureUtil.delFixtureSetDetailByIds(fixList[0],ids);
        Test.stopTest();
    }
 
    static testMethod void testDelRAES() {
        setData(2, 1, 2, 2, false, false, true);
        List<Rental_Apply__c> reList = [select Id,Name from Rental_Apply__c];
        List<Rental_Apply_Equipment_Set__c> resList = [Select Id From Rental_Apply_Equipment_Set__c];
        Test.startTest();
        FixtureUtil.delRAES_excludedUpserted(reList[0],resList);
        Test.stopTest();
    }
 
    static testMethod void testDelRAESD() {
        setData(2, 1, 2, 2, false, false, true);
        List<Rental_Apply_Equipment_Set_Detail__c> resdList = [select Id from Rental_Apply_Equipment_Set_Detail__c];
        List<Rental_Apply_Equipment_Set__c> resList = [Select Id From Rental_Apply_Equipment_Set__c];
        Test.startTest();
        FixtureUtil.delRAESD_excludedUpserted(resList,resdList);
        Test.stopTest();
    }
 
 
    static testMethod void testwithout1() {
        Account hospital = new Account();
        hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
        hospital.Name = 'test hospital';
        List<Account> alist = new List<Account>();
        alist.add(hospital);
        Test.startTest();
        FixtureUtil.withoutInsert(alist);
        alist[0].Name = 'test';
        FixtureUtil.withoutUpsertObjects(alist);
        alist[0].Name = 'test1';
        FixtureUtil.withoutUpdate(alist);
        FixtureUtil.withoutDelete(alist);
        Test.stopTest();
    }
 
    static testMethod void testwithout2() {
        Account hospital = new Account();
        hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
        hospital.Name = 'test hospital';
        List<Account> alist = new List<Account>();
        alist.add(hospital);
        Test.startTest();
        FixtureUtil.withoutInsert(alist,true);
        alist[0].Name = 'test';
        FixtureUtil.withoutUpdate(alist,true);
        alist[0].Name = 'test1';
        FixtureUtil.withoutUpsert(alist,true);
        Test.stopTest();
    }
 
 
    static testMethod void testdelRND() {
        setData(2, 1, 2, 2, false, false, true);
        //创建收货清单
        Date td = Date.today();
        ReceivingNote__c rn = new ReceivingNote__c();
        rn.Internal_asset_location__c = '上海 张江';
        rn.Asset_loaner_category__c = '固定资产';
        rn.Name = 'ZZ-153PA-0000813';
        rn.Status__c = '待数据确认';
        rn.DateOfDelivery__c = td+7;
        rn.OrderCode__c = 'SHRC-SP-20044-02';
        rn.Sales_order_number__c = '1000109900';
        rn.ApprovalNumber__c = 'ME153P07-0301';
        rn.ContactPerson__c = 'username';
        insert rn;
        //收货清单一览
        ReceivingNoteSummary__c rns = new ReceivingNoteSummary__c();
        rns.ReceivingNote__c = rn.Id;
        insert rns;
 
        // 收货一览明细
        ReceivingNoteDetail__c rnd1 = new ReceivingNoteDetail__c();
        rnd1.ReceivingNoteSummary__c = rns.Id;
        rnd1.Fixture_Set_Detail__c = [select Id from Fixture_Set_Detail__c limit 1].Id;
        rnd1.Is_Body__c = true;
        rnd1.Delete_Flag__c = false;
        rnd1.SerialNumber__c = '12';
 
        insert new ReceivingNoteDetail__c[] {rnd1};
        List<ReceivingNoteSummary__c> rnsList = new List<ReceivingNoteSummary__c>();
        rnsList.add(rns); 
        Test.startTest();
        FixtureUtil.delRND_excludedUpserted(rnsList,new List<ReceivingNoteDetail__c>(),new List<ReceivingNoteDetail__c>(),true);
        Test.stopTest();
    }
 
    static testMethod void testclearOneToOne() {
        setData(2, 1, 2, 2, false, false, true);
        List<Fixture_OneToOne_Link__c> fixList = [select Id,Main_Asset__c from Fixture_OneToOne_Link__c];
        List<Rental_Apply_Equipment_Set__c> resList = [Select Id From Rental_Apply_Equipment_Set__c];
        Test.startTest();
        FixtureUtil.clearOneToOneAccessory(resList[0].Id,new Map<String, Rental_Apply_Equipment_Set_Detail__c>(),fixList[0].Main_Asset__c,new Map<Id, Fixture_OneToOne_Link__c>());
        Test.stopTest();
    }
 
    static testMethod void testDelRAESDByIds(){
        setData(2, 1, 2, 2, false, false, true);
        List<Rental_Apply_Equipment_Set_Detail__c> resdList = [select Id from Rental_Apply_Equipment_Set_Detail__c];
        List<Rental_Apply_Equipment_Set__c> resList = [Select Id From Rental_Apply_Equipment_Set__c];
        List<Id> ids = new List<Id>();
        for (Rental_Apply_Equipment_Set_Detail__c resd : resdList) {
            ids.add(resd.Id);
        }
        Test.startTest();
        FixtureUtil.delRAESDByIds(resList[0],ids);
        Test.stopTest();
    }
 
 
    static testMethod void testSetAssetRAESSalesdepartment(){
        Test.startTest();
        FixtureUtil.setAssetRAESSalesdepartment('test');
        Test.stopTest();
    }
 
    static testMethod void testSetAssetRAESEquipmentType(){
        Test.startTest();
        FixtureUtil.setAssetRAESEquipment_Type('test');
        Test.stopTest();
    }
 
    static testMethod void testSetUpstError(){
        Test.startTest();
        FixtureUtil.setUpstError(new List<Database.UpsertResult>(),Account.getSObjectType(),new List<Account>(),new List<String>());
        Test.stopTest();
    }
 
    static testMethod void testSetSaveError(){
        Test.startTest();
        FixtureUtil.setSaveError(new List<Database.SaveResult>(),Account.getSObjectType(),new List<Account>(),new List<String>());
        Test.stopTest();
    }
 
    static testMethod void testSetDelError(){
        Test.startTest();
        FixtureUtil.setDelError(new List<Database.DeleteResult>(),Account.getSObjectType(),new List<Account>(),new List<String>());
        Test.stopTest();
    }
 
    static testMethod void testSetDetailWrapper(){
        setData(2, 1, 2, 2, false, false, true);
        List<Rental_Apply_Equipment_Set_Detail__c> resdList = [select Id from Rental_Apply_Equipment_Set_Detail__c];
        Test.startTest();
        FixtureUtil.SetDetailWrapper sd = new FixtureUtil.SetDetailWrapper(resdList[0]);
        //sd.compareTo('compareTo');
        Test.stopTest();
    }
 
    static testMethod void testSetDetailWrapper2(){
        try{
            setData(2, 1, 2, 2, false, false, true);
            FixtureUtil.now=null;
            List<Rental_Apply_Equipment_Set_Detail__c> resdList = [select Id from Rental_Apply_Equipment_Set_Detail__c];
            List<User> userList = [select Id from User];
            FixtureUtil.getCheckFields(resdList);
            FixtureUtil.getCheckFields(userList);
            FixtureUtil.getSoqlString('dd');
            FixtureUtil.getSoqlString('');
            List<Id> ids=new List<Id>();
            List<Fixture_OneToOne_Link__c> FOLCS=[select Main_Asset__c from Fixture_OneToOne_Link__c];
            for(Fixture_OneToOne_Link__c item:FOLCS){
                ids.add(item.Main_Asset__c);
            }
            FixtureUtil.delOtOLinkData(ids);
            List<Rental_Apply_Equipment_Set_Detail__c> raesdList=[select id from Rental_Apply_Equipment_Set_Detail__c limit 1];
            FixtureUtil.queryTempList('select id from Rental_Apply_Equipment_Set_Detail__c limit 1',raesdList);
            List<Rental_Apply_Equipment_Set_Detail__c> es = [Select Fixture_Model_No_F__c,Is_Body_F__c,Rental_Num__c,Is_Body__c 
                                                  From Rental_Apply_Equipment_Set_Detail__c];
            List<String> asFs =new List<String> {
                'Yi_Jie_Chu_Jia__c',             //已借出
                'Jie_Chu_Fen_Pei_Jia__c',        //借出分配  占坑数(不包含排队,从分配到回库的件数,取消的不算)
                'You_Xiao_Kun_Cun_Jia__c',       //有效库存
                'Ke_Yi_Fen_Pei_Zhu_Ti_Jia__c',   //可以分配主体
                'Dai_Xiu_Li_Jia__c',             //待修理
                'Bie_Cun_Fang_Di_Ku_Cun_Jia__c', //存放地
                'Bie_Sheng_Ku_Cun_Jia__c',       //别省
                'Bie_Ben_Bu_Ku_Cun_Jia__c',      //别本部
                'Bie_Yong_Tu_Ku_Cun_Jia__c',     //别用途库存
                'Bie_Chan_Pin_Fen_Lei_Jia__c',   //别产品分类
                'Zhu_Ti_Fen_Pei_Jia__c',         //主体分配
                'Fu_Shu_Pin_Fen_Pei_Jia__c'      //附属品分配状态
            };
            //Map<Rental_Apply_Equipment_Set_Detail__c,Map<String, FixtureUtil.groupBean>> dataMap = 
            //FixtureUtil.raesdGroupBy(new Rental_Apply_Equipment_Set_Detail__c[]{es[0]},asFs, '');
        }catch (Exception e) {
        
        } 
    }
 
    // 20240101 ljh start
    static testMethod void compareTemperatureAndHumidity() {
        Test.startTest();
        FixtureUtil.compareTemperatureAndHumidity('A区(温度:10~40℃,湿度:30~85%)', '5~40℃, 10~95%');
        FixtureUtil.compareTemperatureAndHumidity('A区(温度:10~40℃,湿度:30~85%)', '30%~85%');
        FixtureUtil.compareTemperatureAndHumidity('A区(温度:10~40℃,湿度:30~85%)', ' 5~35°℃');
        Test.stopTest();
    }
    // 20240101 ljh end
}