buli
2023-07-14 5b5c1e16deaa3a9d6d0ed1ffca390655ed103df7
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
@isTest
public class LexInventoryControllerTest {
    static testMethod void InventoryControllerTest_PartBar(){
        user myUser_test;
        Account myAccount1;
        User thisUser = [ select Id from User where Id = :UserInfo.getUserId()];
        System.runAs(thisUser){
            Profile prof1 = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET Email)'];
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
        if (rectCo.size() == 0) {
            return;
        }
        StaticParameter.EscapeOrderDetail2Trigger = true;
        StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
        RecordType rectCoO = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
 
        Account olympus = new Account(RecordTypeId = rectCoO.Id, AgentCode_Ext__c = '9999900', Name = 'olympus');
        insert olympus;
 
        myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '8888888');
        insert myAccount1;
 
        Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.id);
        insert core;
        MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof1.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com',Work_Location__c = '上海');
        insert MyUser_Test;
 
        }
        system.runAs(MyUser_Test){
            Product2 prod07 = new Product2(Name='Test07',ProductCode='Test07',Asset_Model_No__c = 'Test07',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false);
            Product2 prod08 = new Product2(Name='Test08',ProductCode='Test08',Asset_Model_No__c = 'Test08',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false);
            Product2 prod09 = new Product2(Name='Test09',ProductCode='Test09',Asset_Model_No__c = 'Test09',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false);
          
            insert new Product2[] {prod07,prod08,prod09};
 
            //制作产品
            Product2__c proG = new Product2__c(Name='MH-155:白平衡帽',OT_CODE_Text__c='Test001',Product2__c = prod07.Id);
            insert proG;
            Product2__c proH = new Product2__c(Name='MB-677:BNC电缆',OT_CODE_Text__c='Test002',Product2__c = prod08.Id);
            insert proH;
            Product2__c proF = new Product2__c(Name='TooMAJ-643R:水囊鞘管003',OT_CODE_Text__c='Test003',Product2__c = prod09.Id);
            insert proF;
            
            //预制头明细
            Consumable_order__c CreateId = new Consumable_order__c();
            CreateId.Name = 'testMing';
            CreateId.Order_status__c = '草案中';
            CreateId.RecordTypeid = System.Label.RT_ConOrder_Order;
            CreateId.Dealer_Info__c = myAccount1.id;
            CreateId.Inventory_date__c = Date.today();
            CreateId.Order_type__c = '盘点';
            CreateId.Order_ProType__c = 'ET';
            insert  CreateId;
            List<Consumable_order_details2__c> conList = new List<Consumable_order_details2__c>(); 
        
            
            //制作Consumable_order_details__c-------ProductCount
            Consumable_order_details2__c  dataForProductCount9 = new Consumable_order_details2__c();
            dataForProductCount9.Bar_Code__c               = '1234567890';
            dataForProductCount9.Sterilization_limit__c    = Date.today().addDays(2);
            dataForProductCount9.Arrive_date__c              = Date.today();
            dataForProductCount9.RecordTypeid              = System.Label.RT_ConOrderDetail2_Delivery;
            dataForProductCount9.Consumable_Product__c     = proG.id;
            dataForProductCount9.Asset_Model_No__c         = proG.Asset_Model_No__c;
            dataForProductCount9.Box_Piece__c              = '盒';
            dataForProductCount9.Consumable_order_minor__c = CreateId.id;
            dataForProductCount9.Send_Date__c = null;
            dataForProductCount9.Used_date__c = null;
            dataForProductCount9.Lose_Flag__c = false;
            conList.add(dataForProductCount9);
 
            Consumable_order_details2__c dataForProductCount7 = new Consumable_order_details2__c();
            dataForProductCount7.Bar_Code__c               = '1234567892';
            dataForProductCount7.Sterilization_limit__c    = Date.today().addDays(2);
            dataForProductCount7.Arrive_date__c              = Date.today();
            dataForProductCount7.RecordTypeid              = System.Label.RT_ConOrderDetail2_Delivery;
            dataForProductCount7.Consumable_Product__c     = proH.id;
            dataForProductCount7.Asset_Model_No__c         = proH.Asset_Model_No__c;
            dataForProductCount7.Box_Piece__c              = '盒';
            dataForProductCount7.Consumable_order_minor__c = CreateId.id;
            dataForProductCount7.Send_Date__c = null;
            dataForProductCount7.Used_date__c = null;
            dataForProductCount7.Lose_Flag__c = false;
            conList.add(dataForProductCount7);
            
            Consumable_order_details2__c dataForProductCount = new Consumable_order_details2__c();
            dataForProductCount.Bar_Code__c               = '1234567882';
            dataForProductCount.Sterilization_limit__c    = Date.today().addDays(2);
            dataForProductCount.Arrive_date__c              = Date.today();
            dataForProductCount.RecordTypeid              = System.Label.RT_ConOrderDetail2_Delivery;
            dataForProductCount.Consumable_Product__c     = proG.id;
            dataForProductCount.Asset_Model_No__c         = proG.Asset_Model_No__c;
            dataForProductCount.Box_Piece__c              = '盒';
            dataForProductCount.Consumable_order_minor__c = CreateId.id;
            dataForProductCount.Send_Date__c = null;
            dataForProductCount.Used_date__c = null;
            dataForProductCount.Lose_Flag__c = true;    
            conList.add(dataForProductCount);
            
            Consumable_order_details2__c dataForProductCount4 = new Consumable_order_details2__c();
            dataForProductCount4.Bar_Code__c               = '1234567884';
            dataForProductCount4.Sterilization_limit__c    = Date.today().addDays(2);
            dataForProductCount4.Arrive_date__c              = Date.today();
            dataForProductCount4.RecordTypeid              = System.Label.RT_ConOrderDetail2_Delivery;
            dataForProductCount4.Consumable_Product__c     = proF.id;
            dataForProductCount4.Asset_Model_No__c         = proF.Asset_Model_No__c;
            dataForProductCount4.Box_Piece__c              = '个';
            dataForProductCount4.Consumable_order_minor__c = CreateId.id;
            //dataForProductCount4.Lose_Flag__c = true;
            dataForProductCount4.RemoveBox_No__c = 1;
 
            conList.add(dataForProductCount4);
 
            Consumable_order_details2__c dataForProductCount5 = new Consumable_order_details2__c();
            dataForProductCount5.Bar_Code__c               = '1234567885';
            dataForProductCount5.Sterilization_limit__c    = Date.today().addDays(2);
            dataForProductCount5.Arrive_date__c              = Date.today();
            dataForProductCount5.RecordTypeid              = System.Label.RT_ConOrderDetail2_Delivery;
            dataForProductCount5.Consumable_Product__c     = proH.id;
            dataForProductCount5.Asset_Model_No__c         = proH.Asset_Model_No__c;
            dataForProductCount5.Box_Piece__c              = '个';
            dataForProductCount5.Consumable_order_minor__c = CreateId.id;
            dataForProductCount5.Lose_Flag__c = true;
            dataForProductCount5.RemoveBox_No__c = 1;
            conList.add(dataForProductCount5);
            insert conList;
            
            List<Consumable_order_details2__c> productCount_Res = [select Id,Name
                        FROM Consumable_order_details2__c
                        WHERE Dealer_Arrive__c = true
                        AND Dealer_Shipment__c = false
                        AND Dealer_Saled__c = false
                        AND Lose_Flag__c = false
                        AND Bar_Code__c !=null
                        AND  Dealer_Info_text__c = :myAccount1.Name];
            //查询库存 追加返品库存
 
            List<Consumable_order_details2__c> conList1 = new List<Consumable_order_details2__c>(); 
            Consumable_order_details2__c con = new Consumable_order_details2__c();
            con.Arrive_date__c = Date.today();
            con.Send_Date__c  = null;
            con.Used_date__c = null;
            con.Return_date__c = null;
            con.Lose_Flag__c = false;
            con.Cancellation_Flag__c = false;
            con.Consumable_Product__c = proG.Id;
            con.Asset_Model_No__c = 'Mj-1001';
            con.Sterilization_limit__c = Date.today().addDays(2);
            con.Box_Piece__c = '盒';
            con.Consumable_order_minor__c = CreateId.id;
            con.Bar_Code__c = '1234567885';
            conList1.add(con);
 
            Consumable_order_details2__c con1 = new Consumable_order_details2__c();
            con1.Arrive_date__c = Date.today();
            con1.Send_Date__c  = null;
            con1.Used_date__c = null;
            con1.Return_date__c = null;
            con1.Lose_Flag__c = false;
            con1.Cancellation_Flag__c = false;
            con1.Consumable_Product__c = proG.Id;
            con1.Asset_Model_No__c = 'Mj-1001';
            con1.Sterilization_limit__c = Date.today().addDays(2);
            con1.Box_Piece__c = '个';
            con1.Consumable_order_minor__c = CreateId.id;
            con1.Bar_Code__c = '12345678856';
            conList1.add(con1);
            insert conList1;
            
            LexInventoryController OwnTest = new LexInventoryController();
            LexInventoryController.init();
            LexInventoryController controller = new LexInventoryController();
            List<LexInventoryController.ConsumableorderdetailsInfo> testList  = LexInventoryController.consumableorderdetailsRecords;
            List<LexInventoryController.ConsumableorderdetailsInfo> testList1  = new List<LexInventoryController.ConsumableorderdetailsInfo>();
            System.debug('testCount:'+testList.size());
            for(LexInventoryController.ConsumableorderdetailsInfo ass : testList){
                System.debug(ass.check);
                ass.check = true;
                testList1.add(ass);
            }
            System.debug('testList1:'+testList1);
            LexInventoryController.searchConsumableorderdetails('ET','上海','Testaccount001','12345678856\n1234567895\n1234567890\n12345678511\n1234567856\n1234567855\n1234567886\n12345678551\n1234567890\n1234567883\n1234567882\n1234567881\n1234567884\nn123456788412\n1234567885\n123456788512\n1234567891\n1234567892\n1234567893\n1234567894',JSON.serialize(testList1),1,0,'Test','ASC');
            LexInventoryController.searchConsumableorderdetails('ET','上海','Testaccount001','1234567882',JSON.serialize(testList1),1,0,'Test','ASC');
            LexInventoryController.barcode = '';
  
        }        
    }
    static testMethod void InventoryControllerTest_PartPan(){
        user MyUser_Test;
        Account myAccount1;
        User thisUser = [ select Id from User where Id = :UserInfo.getUserId()];
        system.runAs(thisUser){
      
        Profile prof1 = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET Email)'];
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
        if (rectCo.size() == 0) {
            return;
        }
        RecordType rectCoO = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        Account olympus = new Account(RecordTypeId = rectCoO.Id, AgentCode_Ext__c = '9999900', Name = 'olympus');
        insert olympus;
    
        Product2 prod07 = new Product2(Name='Test07',ProductCode='Test07',Asset_Model_No__c = 'Test07',SFDA_Status__c = '有効',Dealer_special_Object__c = true);
        Product2 prod08 = new Product2(Name='Test08',ProductCode='Test08',Asset_Model_No__c = 'Test08',SFDA_Status__c = '有効',Dealer_special_Object__c = true);
        Product2 prod09 = new Product2(Name='Test09',ProductCode='Test09',Asset_Model_No__c = 'Test09',SFDA_Status__c = '有効',Dealer_special_Object__c = true);
        insert new Product2[] {prod07,prod08,prod09};
        
        //制作产品
        Product2__c proG = new Product2__c(Name='Too001',OT_CODE_Text__c='Test001',Product2__c = prod07.Id);
        insert proG;
        Product2__c proH = new Product2__c(Name='Too002',OT_CODE_Text__c='Test002',Product2__c = prod08.Id);
        insert proH;
        Product2__c proF = new Product2__c(Name='Too003',OT_CODE_Text__c='Test001',Product2__c = prod09.Id);
        insert proF;
        
        
        myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id);
    
        insert myAccount1;
    
        Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.id);
        insert core;
        MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof1.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
        insert MyUser_Test;
    }
        system.runAs(MyUser_Test){
        
        InventoryController OwnTest = new InventoryController();
        OwnTest.size = 2;
        OwnTest.init();
        OwnTest.setCon.next();
        OwnTest.refreshPageSize();
        OwnTest.ConsumableorderdetailsRecordsview.sort();
        system.assertEquals(0,OwnTest.consumableorderdetailsCount);
        OwnTest.save();
        }
    }
    static testMethod void InventoryControllerTest_ge(){
        user MyUser_Test;
        Account myAccount1;
        User thisUser = [ select Id from User where Id = :UserInfo.getUserId()];
        system.runAs(thisUser){
      
        
        Profile prof1 = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET Email)'];
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
        if (rectCo.size() == 0) {
            return;
        }
        StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
        
        RecordType rectCoO = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        Account olympus = new Account(RecordTypeId = rectCoO.Id, AgentCode_Ext__c = '9999900', Name = 'olympus');
        insert olympus;
        myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '8888888');
        insert myAccount1;
        Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.id);
        insert core;
        MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof1.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
        insert MyUser_Test;
    }
        system.runAs(MyUser_Test){
            
            Product2 prod07 = new Product2(Name='Test07',ProductCode='Test07',Asset_Model_No__c = 'Test07',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false);
            Product2 prod08 = new Product2(Name='Test08',ProductCode='Test08',Asset_Model_No__c = 'Test08',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false);
            Product2 prod09 = new Product2(Name='Test09',ProductCode='Test09',Asset_Model_No__c = 'Test09',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false);
            insert new Product2[] {prod07,prod08,prod09};
 
            //制作产品
            Product2__c proG = new Product2__c(Name='MH-155:白平衡帽',OT_CODE_Text__c='Test001',Product2__c = prod07.Id);
            insert proG;
            Product2__c proH = new Product2__c(Name='MB-677:BNC电缆',OT_CODE_Text__c='Test002',Product2__c = prod08.Id);
            insert proH;
            Product2__c proF = new Product2__c(Name='TooMAJ-643R:水囊鞘管003',OT_CODE_Text__c='Test003',Product2__c = prod09.Id);
            insert proF;
            
            //预制头明细
            Consumable_order__c CreateId = new Consumable_order__c();
            CreateId.Name = 'testMing';
            CreateId.Order_status__c = '草案中';
            CreateId.RecordTypeid = System.Label.RT_ConOrder_Order;
            CreateId.Dealer_Info__c = myAccount1.id;
            CreateId.Inventory_date__c = Date.today();
            CreateId.Order_type__c = '盘点';
            CreateId.Order_ProType__c = 'ET';
            insert  CreateId;
            List<Consumable_order_details2__c> orderList = new List<Consumable_order_details2__c>();
        
            
            //制作Consumable_order_details__c-------ProductCount
            Consumable_order_details2__c  dataForProductCount9 = new Consumable_order_details2__c();
            dataForProductCount9.Bar_Code__c               = '1234567890';
            dataForProductCount9.Sterilization_limit__c    = Date.today().addDays(2);
            dataForProductCount9.Arrive_date__c              = Date.today();
            dataForProductCount9.RecordTypeid              = System.Label.RT_ConOrderDetail2_Delivery;
            dataForProductCount9.Consumable_Product__c     = proG.id;
            dataForProductCount9.Asset_Model_No__c         = proG.Asset_Model_No__c;
            dataForProductCount9.Box_Piece__c              = '个';
            dataForProductCount9.RemoveBox_No__c = 1;
            orderList.add(dataForProductCount9);
 
            Consumable_order_details2__c dataForProductCount8 = new Consumable_order_details2__c();
            dataForProductCount8.Bar_Code__c               = '1234567891';
            dataForProductCount8.Sterilization_limit__c    = Date.today().addDays(2);
            dataForProductCount8.Arrive_date__c              = Date.today();
            dataForProductCount8.RecordTypeid              = System.Label.RT_ConOrderDetail2_Delivery;
            dataForProductCount8.Consumable_Product__c     = proG.id;
            dataForProductCount8.Asset_Model_No__c         = proG.Asset_Model_No__c;
            orderList.add(dataForProductCount8);
 
            Consumable_order_details2__c dataForProductCount7 = new Consumable_order_details2__c();
            dataForProductCount7.Bar_Code__c               = '1234567892';
            dataForProductCount7.Sterilization_limit__c    = Date.today().addDays(2);
            dataForProductCount7.Arrive_date__c              = Date.today();
            dataForProductCount7.RecordTypeid              = System.Label.RT_ConOrderDetail2_Delivery;
            dataForProductCount7.Consumable_Product__c     = proH.id;
            dataForProductCount7.Asset_Model_No__c         = proH.Asset_Model_No__c;
            dataForProductCount7.Box_Piece__c              = '个';
            dataForProductCount7.Consumable_order_minor__c = CreateId.id;
            dataForProductCount7.Send_Date__c = null;
            dataForProductCount7.Used_date__c = null;
            dataForProductCount7.Lose_Flag__c = false;
            dataForProductCount7.RemoveBox_No__c = 1;
            orderList.add(dataForProductCount7);
            
            Consumable_order_details2__c dataForProduct = new Consumable_order_details2__c();
            dataForProduct.Bar_Code__c               = '1234567894';
            dataForProduct.Sterilization_limit__c    = Date.today().addDays(2);
            dataForProduct.Arrive_date__c              = Date.today();
            dataForProduct.RecordTypeid              = System.Label.RT_ConOrderDetail2_Delivery;
            dataForProduct.Consumable_Product__c     = proF.id;
            dataForProduct.Asset_Model_No__c         = proF.Asset_Model_No__c;
            dataForProduct.Box_Piece__c              = '个';
            dataForProduct.Consumable_order_minor__c = CreateId.id;
            dataForProduct.Send_Date__c = null;
            dataForProduct.Used_date__c = null;
            dataForProduct.Lose_Flag__c = false;
            dataForProduct.RemoveBox_No__c = 1;
            orderList.add(dataForProduct);
            
            Consumable_order_details2__c dataForProductCount3 = new Consumable_order_details2__c();
            dataForProductCount3.Bar_Code__c               = '1234567883';
            dataForProductCount3.Sterilization_limit__c    = Date.today().addDays(2);
            dataForProductCount3.Arrive_date__c              = Date.today();
            dataForProductCount3.RecordTypeid              = System.Label.RT_ConOrderDetail2_Delivery;
            dataForProductCount3.Consumable_Product__c     = proG.id;
            dataForProductCount3.Asset_Model_No__c         = proG.Asset_Model_No__c;
            dataForProductCount3.Consumable_order_minor__c = CreateId.id;
            dataForProductCount3.Lose_Flag__c = true;
            //dataForProductCount3.RemoveBox_No__c = 1;
            orderList.add(dataForProductCount3);
            
    
            PageReference page = new Pagereference('/Inventory');
            page.setRedirect(true);
            System.Test.setCurrentPage(page);
            System.Test.startTest();
            LexInventoryController controller = new LexInventoryController();
            LexInventoryController.init();
            System.debug('===>值1'+LexInventoryController.consumableorderdetailsRecords);
            System.debug('===>值2'+ JSON.serialize(LexInventoryController.consumableorderdetailsRecords));
            System.debug('===>2222222'+JSON.serialize(LexInventoryController.consumableorderdetailsRecords));
            List<LexInventoryController.ConsumableorderdetailsInfo> testList  = LexInventoryController.consumableorderdetailsRecords;
            List<LexInventoryController.ConsumableorderdetailsInfo> testList1  = new List<LexInventoryController.ConsumableorderdetailsInfo>();
            System.debug('testCount:'+testList.size());
            for(LexInventoryController.ConsumableorderdetailsInfo ass : testList){
                System.debug(ass.check);
                ass.check = true;
                testList1.add(ass);
            }
            System.debug('testList1:'+testList1);
 
            LexInventoryController.searchConsumableorderdetails('ET','上海','Testaccount001','12345678856\n1234567895\n1234567890\n12345678511\n1234567856\n1234567855\n1234567886\n12345678551\n1234567890\n1234567883\n1234567882\n1234567881\n1234567884\nn123456788412\n1234567885\n123456788512\n1234567891\n1234567892\n1234567893\n1234567894',JSON.serialize(testList1),1,0,'Test','ASC');
            System.Test.stopTest();
        }
    }
    static testMethod void InventoryControllerTest_xunhui(){
        user MyUser_Test;
        Account myAccount1;
        User thisUser = [ select Id from User where Id = :UserInfo.getUserId()];
        system.runAs(thisUser){
        Profile prof1 = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET Email)'];
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
        if (rectCo.size() == 0) {
            return;
        }
        StaticParameter.EscapeOrderDetail2Trigger = true;
        StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
        RecordType rectCoO = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        Account olympus = new Account(RecordTypeId = rectCoO.Id, AgentCode_Ext__c = '9999900', Name = 'olympus');
        insert olympus;
        myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '8888888');
        insert myAccount1;
        Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.id);
        insert core;
        MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof1.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
        insert MyUser_Test;
    }
        system.runAs(MyUser_Test){
            
            Product2 prod07 = new Product2(Name='Test07',ProductCode='Test07',Asset_Model_No__c = 'Test07',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false);
            Product2 prod08 = new Product2(Name='Test08',ProductCode='Test08',Asset_Model_No__c = 'Test08',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false);
            Product2 prod09 = new Product2(Name='Test09',ProductCode='Test09',Asset_Model_No__c = 'Test09',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false);
            insert new Product2[] {prod07,prod08,prod09};
 
            //制作产品
            Product2__c proG = new Product2__c(Name='MH-155:白平衡帽',OT_CODE_Text__c='Test001',Product2__c = prod07.Id);
            insert proG;
            Product2__c proH = new Product2__c(Name='MB-677:BNC电缆',OT_CODE_Text__c='Test002',Product2__c = prod08.Id);
            insert proH;
            Product2__c proF = new Product2__c(Name='TooMAJ-643R:水囊鞘管003',OT_CODE_Text__c='Test003',Product2__c = prod09.Id);
            insert proF;
        
            //预制头明细
            Consumable_order__c CreateId = new Consumable_order__c();
            CreateId.Name = 'testMing';
            CreateId.Order_status__c = '草案中';
            CreateId.RecordTypeid = System.Label.RT_ConOrder_Order;
            CreateId.Dealer_Info__c = myAccount1.id;
            CreateId.Inventory_date__c = Date.today();
            CreateId.Order_type__c = '盘点';
            CreateId.Order_ProType__c = 'ET';
            insert  CreateId;
            List<Consumable_order__c> orderList = new List<Consumable_order__c>();
             //到货
            Consumable_order__c Order1 = new Consumable_order__c();
            Order1.Name = 'OCM_01';
            Order1.Order_status__c = '批准';
            Order1.Order_type__c = '到货';
            Order1.Dealer_Info__c = myAccount1.Id;
            Order1.RecordTypeid = '01210000000c9dqAAA';
            Order1.Order_ProType__c = 'ENG';
            orderList.add(Order1);
            //发货
            Consumable_order__c Order2 = new Consumable_order__c();
            Order2.Name = 'OCM_01';
            Order2.Order_status__c = '批准';
            Order2.Order_type__c = '订单 ';
            Order2.Dealer_Info__c = myAccount1.Id;
            Order2.RecordTypeid = '01210000000c9drAAA';
            Order2.Order_ProType__c = 'ENG';
            orderList.add(Order2);
            insert orderList;
 
        
            
            //制作Consumable_order_details__c-------ProductCount
            Consumable_order_details2__c  dataForProductCount9 = new Consumable_order_details2__c();
            dataForProductCount9.Bar_Code__c               = '1234567890';
            dataForProductCount9.Sterilization_limit__c    = Date.today().addDays(2);
            dataForProductCount9.Arrive_date__c              = Date.today();
            dataForProductCount9.RecordTypeid              = System.Label.RT_ConOrderDetail2_Delivery;
            dataForProductCount9.Consumable_Product__c     = proG.id;
            dataForProductCount9.Asset_Model_No__c         = proG.Asset_Model_No__c;
            dataForProductCount9.Box_Piece__c              = '盒';
            dataForProductCount9.Consumable_order_minor__c = CreateId.id;
            dataForProductCount9.Send_Date__c = null;
            dataForProductCount9.Used_date__c = null;
            dataForProductCount9.Lose_Flag__c = false;
            dataForProductCount9.RemoveBox_No__c = 1;
            insert dataForProductCount9;
 
            Consumable_order_details2__c dataForProductCount8 = new Consumable_order_details2__c();
            dataForProductCount8.Bar_Code__c               = '1234567891';
            dataForProductCount8.Sterilization_limit__c    = Date.today().addDays(2);
            dataForProductCount8.Arrive_date__c              = Date.today();
            dataForProductCount8.RecordTypeid              = System.Label.RT_ConOrderDetail2_Delivery;
            dataForProductCount8.Consumable_Product__c     = proG.id;
            dataForProductCount8.Asset_Model_No__c         = proG.Asset_Model_No__c;
            dataForProductCount8.Box_Piece__c              = '盒';
            dataForProductCount8.Consumable_order_minor__c = CreateId.id;
            dataForProductCount8.Send_Date__c = null;
            dataForProductCount8.Used_date__c = null;
            dataForProductCount8.Lose_Flag__c = false;
            dataForProductCount8.RemoveBox_No__c = 1;
            insert dataForProductCount8;
 
            Consumable_order_details2__c dataForProductCount7 = new Consumable_order_details2__c();
            dataForProductCount7.Bar_Code__c               = '1234567892';
            dataForProductCount7.Sterilization_limit__c    = Date.today().addDays(2);
            dataForProductCount7.Arrive_date__c              = Date.today();
            dataForProductCount7.RecordTypeid              = System.Label.RT_ConOrderDetail2_Delivery;
            dataForProductCount7.Consumable_Product__c     = proH.id;
            dataForProductCount7.Asset_Model_No__c         = proH.Asset_Model_No__c;
            dataForProductCount7.Box_Piece__c              = '个';
            dataForProductCount7.Consumable_order_minor__c = CreateId.id;
            dataForProductCount7.Send_Date__c = null;
            dataForProductCount7.Used_date__c = null;
            dataForProductCount7.Lose_Flag__c = false;
            dataForProductCount7.RemoveBox_No__c = 1;
            insert dataForProductCount7;
 
            Consumable_order_details2__c dataForProductCount6 = new Consumable_order_details2__c();
            dataForProductCount6.Bar_Code__c               = '1234567893';
            dataForProductCount6.Sterilization_limit__c    = Date.today().addDays(2);
            dataForProductCount6.Arrive_date__c              = Date.today();
            dataForProductCount6.RecordTypeid              = System.Label.RT_ConOrderDetail2_Delivery;
            dataForProductCount6.Consumable_Product__c     = proH.id;
            dataForProductCount6.Asset_Model_No__c         = proH.Asset_Model_No__c;
            dataForProductCount6.Box_Piece__c              = '个';
            dataForProductCount6.Consumable_order_minor__c = CreateId.id;
            dataForProductCount6.Send_Date__c = null;
            dataForProductCount6.Used_date__c = null;
            dataForProductCount6.Lose_Flag__c = false;
            dataForProductCount6.RemoveBox_No__c = 1;
            insert dataForProductCount6;
 
            Consumable_order_details2__c dataForProductCount5 = new Consumable_order_details2__c();
            dataForProductCount5.Bar_Code__c               = '1234567894';
            dataForProductCount5.Sterilization_limit__c    = Date.today().addDays(2);
            dataForProductCount5.Arrive_date__c              = Date.today();
            dataForProductCount5.RecordTypeid              = System.Label.RT_ConOrderDetail2_Delivery;
            dataForProductCount5.Consumable_Product__c     = proH.id;
            dataForProductCount5.Asset_Model_No__c         = proH.Asset_Model_No__c;
            dataForProductCount5.Box_Piece__c              = '个';
            dataForProductCount5.Consumable_order_minor__c = CreateId.id;
            dataForProductCount5.Send_Date__c = null;
            dataForProductCount5.Used_date__c = null;
            dataForProductCount5.Lose_Flag__c = false;
            dataForProductCount5.RemoveBox_No__c = 1;
            insert dataForProductCount5;
 
            List<Consumable_order_details2__c> conlist = new List<Consumable_order_details2__c>();
            //Barcode检索 所有在库
            Consumable_order_details2__c con1 = new Consumable_order_details2__c();
            con1.Lose_Flag__c               = false;
            con1.Arrive_date__c             = Date.today();
            con1.Send_Date__c               = null;
            con1.Return_date__c             = null;
            con1.Lose_Flag__c               = false;
            con1.Cancellation_Date__c       = null;
            con1.Sterilization_limit__c     = Date.today().addDays(2);
            con1.Bar_Code__c                = '123';
            con1.Box_Piece__c               = '盒';
            con1.Bar_Code__c                = '1234567894';
            con1.Sterilization_limit__c     = Date.today().addDays(2);
            con1.RecordTypeid               = System.Label.RT_ConOrderDetail2_Delivery;
            con1.Consumable_Product__c      = proH.id;
            con1.Consumable_order_minor__c = CreateId.id;
            conlist.add(con1);
 
            //查询库存 追加返品库存
            Consumable_order_details2__c con3 = new Consumable_order_details2__c();
            con3.Consumable_Product__c = proH.id;
            con3.Bar_Code__c = '1001';
            con3.Consumable_Arrived_order__c = Order1.id;
            con3.Consumable_order_minor__c = Order2.id;
            con3.Arrive_date__c = Date.today();
            con3.Send_Date__c = null;
            con3.Return_date__c = null;
            con3.Lose_Flag__c = false;
            con3.Cancellation_Flag__c = false;
            con3.Consumable_order_minor__c = CreateId.id;
            con3.Sterilization_limit__c    = Date.today().addDays(2);
            con3.Box_Piece__c = '个';
            con3.RecordTypeid = '01210000000kUDKAA2';
            conlist.add(con3);
 
            //productAdjust
            Consumable_order_details2__c con6 = new Consumable_order_details2__c();
            con6.Consumable_Product__c = proH.id;
            con6.Lose_reason__c = '过期库存销存';
            con6.Box_Piece__c = '盒';
            con6.Sterilization_limit__c = Date.today().addDays(-2);
            con6.Bar_Code__c = '10011';
            con6.Consumable_Arrived_order__c = Order1.id;
            con6.Lose_Flag__c = true;
            con6.RecordTypeid = '01210000000kUDKAA2';
            conlist.add(con6);
            System.debug('conlist===>'+conlist);
 
 
            //reset592
            Consumable_order_details2__c con4 = new Consumable_order_details2__c();
            con4.Arrive_date__c = Date.today();
            con4.Send_Date__c = null;
            con4.Return_date__c = null;
            con4.Lose_Flag__c = false;
            con4.Cancellation_Date__c  =null;
            con4.Sterilization_limit__c    = Date.today().addDays(2);
            con4.Bar_Code__c = '123456';
            con4.Box_Piece__c              = '盒';
            // con2.Bar_Code__c               = '1234567894';
            con4.Sterilization_limit__c    = Date.today().addDays(2);
            con4.RecordTypeid              = System.Label.RT_ConOrderDetail2_Delivery;
            con4.Consumable_Product__c     = proH.id;
            // con2.Asset_Model_No__c         = proH.Asset_Model_No__c;
            con4.Consumable_order_minor__c = CreateId.id;
            conlist.add(con4);
 
            
            //查询库存 追加返品库存
            Consumable_order_details2__c con5 = new Consumable_order_details2__c();
            con5.Arrive_date__c = Date.today();
            con5.Send_Date__c = null;
            con5.Return_date__c = null;
            con5.Lose_Flag__c = false;
            con5.Cancellation_Flag__c = false;
            con5.Consumable_Product__c = proH.id;
            con5.Consumable_order_minor__c = Order2.id;
            // con5.Sterilization_limit__c    = Date.today().addDays(2);
            con5.Box_Piece__c = '盒';
            con5.Bar_Code__c = '1001';
            conlist.add(con5);
            insert conlist;
 
            System.Test.startTest();
            LexInventoryController inver = new LexInventoryController();
            LexInventoryController.init();
            List<LexInventoryController.ConsumableorderdetailsInfo> testList  = LexInventoryController.consumableorderdetailsRecords;
            List<LexInventoryController.ConsumableorderdetailsInfo> testList1  = new List<LexInventoryController.ConsumableorderdetailsInfo>();
            System.debug('testCount:'+testList.size());
            for(LexInventoryController.ConsumableorderdetailsInfo ass : testList){
                System.debug(ass.check);
                ass.check = true;
                testList1.add(ass);
            }
            System.debug('testList1:'+testList1);
            LexInventoryController.searchConsumableorderdetails('ET','上海','Testaccount001','',JSON.serialize(testList1),20,9,'Test','ASC');
            LexInventoryController.searchConsumableorderdetails('ET','上海','Testaccount001','01210000000kUDKAA2\n10011',JSON.serialize(testList1),20,9,'Test','ASC');
            LexInventoryController.searchConsumableorderdetails('ET','上海','Testaccount001','12345678856\n1234567895\n1234567890\n12345678511\n1234567856\n1234567855\n1234567886\n12345678551\n1234567890\n1234567883\n1234567882\n1234567881\n1234567884\nn123456788412\n1234567885\n123456788512\n1234567891\n1234567892\n1234567893\n1234567894\n1001',JSON.serialize(testList1),1,0,'Test','ASC');
            LexInventoryController.save(true,JSON.serialize(testList1),myAccount1.Id,'ET',LexInventoryController.pandiandetailsMap,LexInventoryController.reSet);
            LexInventoryController.searchConsumableorderdetails('ET','上海','Testaccount001','','[{"sortBy": null,"refind": 0,"ProdId": "a0l0l000004EisKAAS","Prod": {"attributes": {"type": "Product2__c","url": "/services/data/v58.0/sobjects/Product2__c/a0l0l000004EisKAAS"},"Id": "a0l0l000004EisKAAS","Name": "MH-155:白平衡帽","Name__c": "Test07","SFDA_Status__c": "停止","Packing_list_manual__c": 1,"Asset_Model_No__c": "Test07"},"Pandian": 0,"overlimitCount": 0,"orderdetails2": null,"orderdetails1": null,"limitCount": 2,"DiffReason": null,"Diff": 0,"countid": 2,"check": true,"canSelect": true,"boxPiece": "盒"}]',20,9,'Test','ASC');
 
 
 
            System.Test.stopTest();
        }
    }
 
    static testMethod void all(){
        user MyUser_Test;
        Account myAccount1;
        User thisUser = [ select Id from User where Id = :UserInfo.getUserId()];
        system.runAs(thisUser){
        Profile prof1 = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET Email)'];
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
        if (rectCo.size() == 0) {
            return;
        }
        StaticParameter.EscapeOrderDetail2Trigger = true;
        StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
        RecordType rectCoO = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        Account olympus = new Account(RecordTypeId = rectCoO.Id, AgentCode_Ext__c = '9999900', Name = 'olympus');
        insert olympus;
        myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '8888888');
        insert myAccount1;
        Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.id);
        insert core;
        MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof1.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com',Work_Location__c = '上海');
        insert MyUser_Test;
    }
        system.runAs(MyUser_Test){
            
            Product2 prod07 = new Product2(Name='Test07',ProductCode='Test07',Asset_Model_No__c = 'Test07',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false);
            Product2 prod08 = new Product2(Name='Test08',ProductCode='Test08',Asset_Model_No__c = 'Test08',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false);
            Product2 prod09 = new Product2(Name='Test09',ProductCode='Test09',Asset_Model_No__c = 'Test09',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false);
            insert new Product2[] {prod07,prod08,prod09};
 
            //制作产品
            Product2__c proG = new Product2__c(Name='MH-155:白平衡帽',OT_CODE_Text__c='Test001',Product2__c = prod07.Id);
            insert proG;
            Product2__c proH = new Product2__c(Name='MB-677:BNC电缆',OT_CODE_Text__c='Test002',Product2__c = prod08.Id);
            insert proH;
            Product2__c proF = new Product2__c(Name='TooMAJ-643R:水囊鞘管003',OT_CODE_Text__c='Test003',Product2__c = prod09.Id);
            insert proF;
            List<Consumable_order__c> orderList = new List<Consumable_order__c>();
            //到货
            Consumable_order__c Order1 = new Consumable_order__c();
            Order1.Name = 'OCM_01';
            Order1.Order_status__c = '批准';
            Order1.Order_type__c = '到货';
            Order1.Dealer_Info__c = myAccount1.Id;
            Order1.RecordTypeid = '01210000000c9dqAAA';
            Order1.Order_ProType__c = 'ET';
            orderList.add(Order1);
            //发货
            Consumable_order__c Order2 = new Consumable_order__c();
            Order2.Name = 'OCM_01';
            Order2.Order_status__c = '批准';
            Order2.Order_type__c = '订单 ';
            Order2.Dealer_Info__c = myAccount1.Id;
            Order2.RecordTypeid = '01210000000c9drAAA';
            Order2.Order_ProType__c = 'ET';
            orderList.add(Order2);
            insert orderList;
            //查询库存 追加返品库存
            List<Consumable_order_details2__c> conlist = new List<Consumable_order_details2__c>();
            Consumable_order_details2__c con3 = new Consumable_order_details2__c();
            con3.Arrive_date__c = Date.today();
            con3.Send_Date__c = null;
            con3.Used_date__c = null;
            con3.Return_date__c = null;
            con3.Lose_Flag__c = false;
            con3.Cancellation_Flag__c = false;
            con3.Consumable_order_minor__c = Order1.id;
            con3.Consumable_Arrived_order__c = Order1.id;
            con3.Bar_Code__c = '1001';
            con3.Consumable_Product__c = proH.id;
            conlist.add(con3);
            insert conlist;
 
            //productAdjust
            Consumable_order_details2__c con6 = new Consumable_order_details2__c();
            // con6.Consumable_Product__c = proH.id;
             con6.Lose_reason__c = '过期库存销存';
            // con6.Box_Piece__c = '盒';
             con6.Sterilization_limit__c = Date.today().addDays(-2);
            con6.Bar_Code__c = '10011';
            // con6.Consumable_Arrived_order__c = Order1.id;
            con6.Lose_Flag__c = true;
            // con6.RecordTypeid = '01210000000kUDKAA2';
            conlist.add(con6);
            System.debug('conlist===>'+conlist);
            LexInventoryController.init();
            List<LexInventoryController.ConsumableorderdetailsInfo> testList  = LexInventoryController.consumableorderdetailsRecords;
            List<LexInventoryController.ConsumableorderdetailsInfo> testList1  = new List<LexInventoryController.ConsumableorderdetailsInfo>();
            System.debug('testCount:'+testList.size());
            for(LexInventoryController.ConsumableorderdetailsInfo ass : testList){
                System.debug(ass.check);
                ass.check = true;
                testList1.add(ass);
            }
            System.debug('testList1:'+testList1);
 
            LexInventoryController.searchConsumableorderdetails('ET','上海','Testaccount001','1001\n10011',JSON.serialize(testList1),20,9,'Test','ASC');
            LexInventoryController.searchConsumableorderdetails('ET','上海','Testaccount001','',JSON.serialize(testList1),20,9,'Test','ASC');
        }
    }
}