buli
2023-07-05 af7b716a60d889acea95560abba0e46eee008b8f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
@IsTest
private class LexCancelRemoveBoxControllerTest {
  static testMethod void testMethod1() {
    Oly_TriggerHandler.bypass('ConsumableAssetHander');
    Oly_TriggerHandler.bypass('Oly_TriggerHandler');
    user myUser_test;
    Account myAccount2;
    User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
    System.runAs(thisUser) {
      List<RecordType> rectCo = [
        SELECT Id
        FROM RecordType
        WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '販売店'
      ];
      if (rectCo.size() == 0) {
        return;
      }
      Profile prof = [
        SELECT Id
        FROM Profile
        WHERE Name = '901_经销商社区普通权限_2重验证(ET Email)'
      ];
 
      myAccount2 = new Account(
        name = 'Testaccount002',
        Dealer_discount__c = 20,
        RecordTypeId = rectCo[0].Id,
        AgentCode_Ext__c = '9999900'
      );
      insert myAccount2;
 
      Contact core = new Contact(
        email = 'jplumber@salesforce.com',
        firstname = 'Joe',
        lastname = 'Plumber',
        accountid = myAccount2.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 = prof.Id,
        TimeZoneSidKey = 'Asia/Shanghai',
        UserName = 'testUser@testorg.com'
      );
      insert MyUser_Test;
    }
    System.runAs(MyUser_Test) {
      Product2 prod01 = new Product2(
        Name = 'Test01',
        ProductCode = 'Test01',
        Asset_Model_No__c = 'Test01',
        SFDA_Status__c = '有効',
        JANCODE__c = '04953170200311',
        Dealer_special_Object__c = true,
        Packing_list_manual__c = 5,
        Manual_Entry__c = false
      );
      Product2 prod02 = new Product2(
        Name = 'Test02',
        ProductCode = 'Test02',
        Asset_Model_No__c = 'Test02',
        SFDA_Status__c = '有効',
        JANCODE__c = '04953170200312',
        Dealer_special_Object__c = true,
        Packing_list_manual__c = 5,
        Manual_Entry__c = false
      );
      Product2 prod03 = new Product2(
        Name = 'Test03',
        ProductCode = 'Test03',
        Asset_Model_No__c = 'Test03',
        SFDA_Status__c = '有効',
        JANCODE__c = '04953170200313',
        Dealer_special_Object__c = true,
        Packing_list_manual__c = 1,
        Manual_Entry__c = false
      );
      insert new List<Product2>{ prod01, prod02, prod03 };
      Product2__c pro1 = new Product2__c(
        Name = 'Pro001',
        OT_CODE_Text__c = 'Test001',
        Product2__c = prod01.Id
      );
      Product2__c pro2 = new Product2__c(
        Name = 'Pro002',
        OT_CODE_Text__c = 'Test002',
        Product2__c = prod02.Id
      );
      Product2__c pro3 = new Product2__c(
        Name = 'Pro003',
        OT_CODE_Text__c = 'Test003',
        Product2__c = prod03.Id
      );
      insert new List<Product2__c>{ pro1, pro2, pro3 };
      //订单
      Consumable_order__c Order1 = new Consumable_order__c();
      Order1.Name = 'OCM_01_001';
      Order1.Order_status__c = '批准';
      Order1.Order_type__c = '订单';
      Order1.Dealer_Info__c = myAccount2.Id;
      Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
      Order1.Order_ProType__c = 'ET';
      insert Order1;
      List<Consumable_order_details2__c> conList = new List<Consumable_order_details2__c>();
 
      //daoku
      Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
      Orderdet2.Name = 'OCM_01_001001';
      Orderdet2.Consumable_order_minor__c = Order1.Id;
      Orderdet2.Consumable_Product__c = pro1.Id;
      Orderdet2.Asset_Model_No__c = 'Test01';
      Orderdet2.Arrive_date__c = Date.today();
      Orderdet2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
      Orderdet2.Used_date__c = null;
      Orderdet2.Lose_Flag__c = false;
      Orderdet2.Return_date__c = null;
      Orderdet2.Send_Date__c = null;
      Orderdet2.Box_Piece__c = '盒';
      conList.add(Orderdet2);
      // insert Orderdet2;
 
      //chuku
      Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
      Orderdet3.Name = 'OCM_01_001002';
      Orderdet3.Consumable_order_minor__c = Order1.Id;
      Orderdet3.Consumable_Product__c = pro2.Id;
      Orderdet3.Asset_Model_No__c = 'Test02';
      Orderdet3.Arrive_date__c = Date.today();
      Orderdet3.Send_Date__c = Date.today();
      Orderdet3.Box_Piece__c = '个';
      Orderdet3.RemoveBox_date__c = Date.today();
      Orderdet3.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRA';
      Orderdet3.Used_date__c = null;
      Orderdet3.Lose_Flag__c = false;
      Orderdet3.Return_date__c = null;
      conList.add(Orderdet3);
      // insert Orderdet3;
 
      //sale
      Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
      Orderdet4.Name = 'OCM_01_001004';
      Orderdet4.Consumable_order_minor__c = Order1.Id;
      Orderdet4.Consumable_Product__c = pro2.Id;
      Orderdet4.Asset_Model_No__c = 'Test02';
      Orderdet4.Arrive_date__c = Date.today();
      Orderdet4.Box_Piece__c = '个';
      Orderdet4.RemoveBox_date__c = Date.today();
      Orderdet4.Bar_Code__c = '011495317020843711170400172003311074K250CXSDS';
      Orderdet4.Lose_Flag__c = false;
      Orderdet4.Return_date__c = null;
      Orderdet4.Used_date__c = Date.today();
      // insert Orderdet4;
      conList.add(Orderdet4);
 
      //ProductPacking_list_manual__c=1
      Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
      Orderdet5.Name = 'OCM_01_001004';
      Orderdet5.Consumable_order_minor__c = Order1.Id;
      Orderdet5.Consumable_Product__c = pro3.Id;
      Orderdet5.Asset_Model_No__c = 'Test03';
      Orderdet5.Arrive_date__c = Date.today();
      //Orderdet5.Used_date__c = Date.today();
      Orderdet5.Box_Piece__c = '盒';
      Orderdet5.RemoveBox_date__c = Date.today();
      Orderdet5.Used_date__c = null;
      Orderdet5.Lose_Flag__c = false;
      Orderdet5.Return_date__c = null;
      Orderdet5.Send_Date__c = null;
      Orderdet5.Bar_Code__c = '010495317014059411170400172203311074K250DCWQW';
      // insert Orderdet5;
      conList.add(Orderdet5);
 
      //pandian
      Consumable_order_details2__c Orderdet7 = new Consumable_order_details2__c();
      Orderdet7.Name = 'OCM_01_001004';
      Orderdet7.Consumable_order_minor__c = Order1.Id;
      Orderdet7.Consumable_Product__c = pro2.Id;
      Orderdet7.Asset_Model_No__c = 'Test02';
      Orderdet7.Box_Piece__c = '盒';
      Orderdet7.Lose_Flag__c = false;
      Orderdet7.Bar_Code__c = '010495317014059411170400172203311074K250DBVUD';
      Orderdet7.RemoveBox_date__c = Date.today();
      Orderdet7.Inventory_date__c = Date.today();
      // insert Orderdet7;
      conList.add(Orderdet7);
 
      Consumable_order_details2__c Orderdet8 = new Consumable_order_details2__c();
      Orderdet8.Name = 'OCM_01_001004';
      Orderdet8.Consumable_order_minor__c = Order1.Id;
      Orderdet8.Consumable_Product__c = pro2.Id;
      Orderdet8.Asset_Model_No__c = 'Test02';
      Orderdet8.Arrive_date__c = Date.today();
      Orderdet8.Box_Piece__c = '个';
      Orderdet8.Lose_Flag__c = false;
      Orderdet8.Bar_Code__c = '1683272847250250WZIOF';
      Orderdet8.Used_date__c = null;
      Orderdet8.Lose_Flag__c = false;
      Orderdet8.Return_date__c = null;
      Orderdet8.RemoveBox_date__c = Date.today();
      Orderdet8.Send_Date__c = null;
      Orderdet8.RemoveBox_No__c = 3;
      conList.add(Orderdet8);
      insert conList;
      // insert Orderdet8;
 
      System.Test.startTest();
      LexCancelRemoveBoxController.init();
      // LexCancelRemoveBoxController.getinventorysize();
      LexCancelRemoveBoxController.searchConsumableorderdetails(
        '1683272847250250WZIOF',
        '捷尔医疗(海南)有限公司',
        '深圳',
        'ENG'
      );
      LexCancelRemoveBoxController.searchConsumableorderdetails(
        '',
        '捷尔医疗(海南)有限公司',
        '深圳',
        'ENG'
      );
      LexCancelRemoveBoxController.cancelRemoveBoxConfirm(
        JSON.serialize(conList),
        '捷尔医疗(海南)有限公司',
        '深圳',
        'ENG'
      );
 
      System.Test.stopTest();
    }
 
  }
  static testMethod void testMethod2() {
    Oly_TriggerHandler.bypass('ConsumableAssetHander');
    Oly_TriggerHandler.bypass('Oly_TriggerHandler');
    user myUser_test;
    Account myAccount2;
    User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
    System.runAs(thisUser) {
      List<RecordType> rectCo = [
        SELECT Id
        FROM RecordType
        WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '販売店'
      ];
      if (rectCo.size() == 0) {
        return;
      }
      Profile prof = [
        SELECT Id
        FROM Profile
        WHERE Name = '901_经销商社区普通权限_2重验证(ET Email)'
      ];
 
      myAccount2 = new Account(
        name = 'Testaccount002',
        Dealer_discount__c = 20,
        RecordTypeId = rectCo[0].Id,
        AgentCode_Ext__c = '9999900'
      );
      insert myAccount2;
 
      Contact core = new Contact(
        email = 'jplumber@salesforce.com',
        firstname = 'Joe',
        lastname = 'Plumber',
        accountid = myAccount2.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 = prof.Id,
        TimeZoneSidKey = 'Asia/Shanghai',
        UserName = 'testUser@testorg.com',
        Work_Location__c = '重庆'
      );
      insert MyUser_Test;
    }
    System.runAs(MyUser_Test) {
      //订单
      Consumable_order__c Order1 = new Consumable_order__c();
      Order1.Name = 'OCM_01_001';
      Order1.Order_status__c = '批准';
      Order1.Order_type__c = '到货';
      Order1.Dealer_Info__c = myAccount2.Id;
      Order1.RecordTypeid = '01210000000c9dqAAA';
      Order1.Order_ProType__c = 'ET';
      insert Order1;
 
      List<Consumable_order_details2__c> conList = new List<Consumable_order_details2__c>();
      List<Consumable_order_details2__c> conList1 = new List<Consumable_order_details2__c>();
      Consumable_order_details2__c con = new Consumable_order_details2__c();
      con.Consumable_Arrived_order__c = Order1.Id;
      con.Send_Date__c = null;
      con.Used_date__c = null;
      con.Return_date__c = null;
      con.Lose_Flag__c = false;
      con.Box_Piece__c = '个';
      con.RemoveBox_date__c = Date.today();
      con.Arrive_date__c = Date.today();
      con.RemoveBox_No__c = 2;
      con.Bar_Code__c = '1682414917514250XSCYW';
      conList.add(con);
 
      Consumable_order_details2__c con1 = new Consumable_order_details2__c();
      con1.Consumable_Arrived_order__c = Order1.Id;
      con1.Send_Date__c = null;
      con1.Used_date__c = null;
      con1.Return_date__c = null;
      con1.Lose_Flag__c = false;
      con1.Box_Piece__c = '个';
      con1.RemoveBox_date__c = Date.today();
      con1.Arrive_date__c = Date.today();
      con.RemoveBox_No__c = 1;
      con1.Bar_Code__c = '1682414917514250XSCYW';
      conList.add(con1);
      insert (conList);
      System.debug('conList' + conList);
      System.Test.startTest();
      LexCancelRemoveBoxController.cancelRemoveBoxConfirm(
        JSON.serialize(conList),
        'Testaccount002',
        '重庆',
        'ET'
      );
      LexCancelRemoveBoxController.cancelRemoveBoxConfirm(
        JSON.serialize(conList1),
        'Testaccount002',
        '重庆',
        'ET'
      );
      System.Test.stopTest();
    }
  }
  static testMethod void testMethod3() {
    Oly_TriggerHandler.bypass('ConsumableAssetHander');
    Oly_TriggerHandler.bypass('Oly_TriggerHandler');
    User myUser_test;
    Account myAccount2;
    User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
    System.runAs(thisUser) {
      List<RecordType> rectCo = [
        SELECT Id
        FROM RecordType
        WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '販売店'
      ];
      if (rectCo.size() == 0) {
        return;
      }
      Profile prof = [
        SELECT Id
        FROM Profile
        WHERE Name = '901_经销商社区普通权限_2重验证(ET Email)'
      ];
      myAccount2 = new Account(
        name = 'Testaccount003',
        Dealer_discount__c = 20,
        RecordTypeId = rectCo[0].Id,
        AgentCode_Ext__c = '2'
      );
      insert myAccount2;
      Contact core = new Contact(
        email = 'wan@salesforce.com',
        firstname = 'wan',
        lastname = 'Plumbers',
        accountid = myAccount2.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 = prof.Id,
        TimeZoneSidKey = 'Asia/Shanghai',
        UserName = 'testUser@testorg.com',
        UserPro_Type__c = 'ENG',
        Work_Location__c = '北京'
      );
      insert myUser_test;
      System.debug('MyUser_Test' + MyUser_Test);
    }
    System.runAs(MyUser_Test) {
      //产品信息
      Product2 prod01 = new Product2(
        Name = 'Test01',
        ProductCode = 'Test01',
        Asset_Model_No__c = 'Test01',
        SFDA_Status__c = '有効',
        Dealer_special_Object__c = true,
        Packing_list_manual__c = 1,
        SFDA_Expiration_Date__c = Date.today(),
        Category5__c = 'test01',
        Manual_Entry__c = false
      );
      Product2 prod02 = new Product2(
        Name = 'Test02',
        ProductCode = 'Test02',
        Asset_Model_No__c = 'Test02',
        SFDA_Status__c = '有効',
        Dealer_special_Object__c = true,
        Packing_list_manual__c = 1,
        SFDA_Expiration_Date__c = Date.today(),
        Category5__c = 'test02',
        Manual_Entry__c = false
      );
      Product2 prod03 = new Product2(
        Name = 'Test03',
        ProductCode = 'Test03',
        Asset_Model_No__c = 'Test03',
        SFDA_Status__c = '有効',
        Dealer_special_Object__c = true,
        Packing_list_manual__c = 1,
        SFDA_Expiration_Date__c = Date.today(),
        Category5__c = 'test03',
        Manual_Entry__c = false
      );
      Product2 prod04 = new Product2(
        Name = 'Test04',
        ProductCode = 'Test04',
        Asset_Model_No__c = 'Test04',
        SFDA_Status__c = '有効',
        Dealer_special_Object__c = true,
        Packing_list_manual__c = 2,
        SFDA_Expiration_Date__c = Date.today(),
        Category5__c = 'test04',
        Manual_Entry__c = false
      );
      Product2 prod05 = new Product2(
        Name = 'Test05',
        ProductCode = 'Test05',
        Asset_Model_No__c = 'Test05',
        SFDA_Status__c = '有効',
        Dealer_special_Object__c = true,
        Packing_list_manual__c = 1,
        SFDA_Expiration_Date__c = Date.today(),
        Category5__c = 'test05',
        Manual_Entry__c = false
      );
      Product2 prod06 = new Product2(
        Name = 'Test06',
        ProductCode = 'Test06',
        Asset_Model_No__c = 'Test06',
        SFDA_Status__c = '有効',
        Dealer_special_Object__c = true,
        Packing_list_manual__c = 1,
        SFDA_Expiration_Date__c = Date.today(),
        Category5__c = 'test06',
        Manual_Entry__c = false
      );
      insert new List<Product2>{
        prod01,
        prod02,
        prod03,
        prod04,
        prod05,
        prod06
      };
      Product2__c pro1 = new Product2__c(
        Name = 'Pro001',
        OT_CODE_Text__c = 'Test001',
        Product2__c = prod01.Id
      );
      Product2__c pro2 = new Product2__c(
        Name = 'Pro002',
        OT_CODE_Text__c = 'Test002',
        Product2__c = prod02.Id
      );
      Product2__c pro3 = new Product2__c(
        Name = 'Pro004',
        OT_CODE_Text__c = 'Test004',
        Product2__c = prod03.Id
      );
      Product2__c pro4 = new Product2__c(
        Name = 'Pro005',
        OT_CODE_Text__c = 'Test005',
        Product2__c = prod04.Id
      );
      Product2__c pro5 = new Product2__c(
        Name = 'Pro003',
        OT_CODE_Text__c = 'Test003',
        Product2__c = prod05.Id
      );
      Product2__c pro6 = new Product2__c(
        Name = 'Pro006',
        OT_CODE_Text__c = 'Test006',
        Product2__c = prod06.Id
      );
      insert new List<Product2__c>{ pro4, pro5, pro6, pro1, pro2, pro3 };
      //订单
      Consumable_order__c Order1 = new Consumable_order__c();
      Order1.Name = 'OCM_01';
      Order1.Order_status__c = '批准';
      Order1.Order_type__c = '订单';
      Order1.Dealer_Info__c = myAccount2.Id;
      Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
      Order1.Order_ProType__c = 'ENG';
      insert 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 = myAccount2.Id;
      Order2.RecordTypeid = '012100000006Jx9AAE';
      Order2.Order_ProType__c = 'ENG';
      insert Order2;
 
      List<Consumable_order_details2__c> conList = new List<Consumable_order_details2__c>();
      List<Consumable_order_details2__c> conList1 = new List<Consumable_order_details2__c>();
      List<Consumable_order_details2__c> conList2 = new List<Consumable_order_details2__c>();
      //产品类型不同
      Consumable_order_details2__c con = new Consumable_order_details2__c();
      con.Name = 'OCM_01_001001';
      con.Consumable_order_minor__c = Order1.Id;
      con.Consumable_Product__c = pro2.Id;
      con.Asset_Model_No__c = 'Test01';
      con.Arrive_date__c = Date.today();
      con.Bar_Code__c = '10061';
      con.Used_date__c = null;
      con.Lose_Flag__c = false;
      con.Return_date__c = null;
      con.Send_Date__c = null;
      con.Box_Piece__c = '盒';
      conList.add(con);
      insert conList;
 
      //产品类型不同
      Consumable_order_details2__c con1 = new Consumable_order_details2__c();
      con1.Consumable_Product__c = pro2.Id;
      con1.Consumable_order_minor__c = Order1.Id;
      con1.Bar_Code__c = '10011';
      con1.Arrive_date__c = Date.today();
      conList1.add(con1);
      //没有拆盒
      Consumable_order_details2__c con2 = new Consumable_order_details2__c();
      con2.Send_Date__c = null;
      con2.Used_date__c = null;
      con2.Lose_Flag__c = false;
      con2.Box_Piece__c = '盒';
      con2.Consumable_Product__c = pro2.Id;
      con2.Consumable_order_minor__c = Order1.Id;
      con2.Bar_Code__c = '10021';
      con2.Arrive_date__c = Date.today();
      con2.RemoveBox_date__c = null;
      conList1.add(con2);
      insert conList1;
 
      //已出货 未到货
      Consumable_order_details2__c con3 = new Consumable_order_details2__c();
      con3.Arrive_date__c = null;
      con3.Send_Date__c = null;
      con3.Used_date__c = null;
      con3.Return_date__c = null;
      con3.Lose_Flag__c = false;
      con3.Box_Piece__c = '盒';
      con3.Consumable_Arrived_order__c = Order2.Id;
      con3.Consumable_Product__c = pro2.Id;
      con3.Bar_Code__c = '10031';
      conList2.add(con3);
      //拆盒已出货
      Consumable_order_details2__c con4 = new Consumable_order_details2__c();
      con4.Arrive_date__c = Date.today();
      con4.Send_Date__c = Date.today();
      con4.Return_date__c = null;
      con4.Used_date__c = null;
      con4.Lose_Flag__c = false;
      con4.Box_Piece__c = '个';
      con4.RemoveBox_date__c = Date.today();
      con4.Consumable_Arrived_order__c = Order2.Id;
      con4.Consumable_Product__c = pro2.Id;
      con4.Bar_Code__c = '10041';
      conList2.add(con4);
      insert conList2;
 
      System.Test.startTest();
      LexCancelRemoveBoxController.barcode = '1004\n1003\n1002\n1001';
      LexCancelRemoveBoxController.searchConsumableorderdetails(
        '10061\n10051\n10041\n10031\n10021\n10011',
        'Testaccount003',
        '重庆',
        'ET'
      );
      String str = '该商品存在盘点履历';
      String errorReason = '';
      LexCancelRemoveBoxController.ConsumableorderdetailsInfo c2 = new LexCancelRemoveBoxController.ConsumableorderdetailsInfo(
        con,
        str
      );
      c2.esd = con;
      c2.Prod = con.Consumable_product__r;
      c2.oldConsumableCount = con.name;
      c2.ErrorReason = str;
      LexCancelRemoveBoxController.ConsumableorderdetailsInfo c1 = new LexCancelRemoveBoxController.ConsumableorderdetailsInfo(
        con2
      );
      c1.esd = con;
      c1.Prod = con.Consumable_product__r;
      c1.oldConsumableCount = con.name;
      c1.compareTo(c2);
      System.Test.stopTest();
    }
  }
  static testMethod void testMethod4() {
    Oly_TriggerHandler.bypass('ConsumableAssetHander');
    Oly_TriggerHandler.bypass('Oly_TriggerHandler');
    User myUser_test;
    Account myAccount2;
    User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
    System.runAs(thisUser) {
      List<RecordType> rectCo = [
        SELECT Id
        FROM RecordType
        WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '販売店'
      ];
      if (rectCo.size() == 0) {
        return;
      }
      Profile prof = [
        SELECT Id
        FROM Profile
        WHERE Name = '901_经销商社区普通权限_2重验证(ET Email)'
      ];
      myAccount2 = new Account(
        name = 'Testaccount003',
        Dealer_discount__c = 20,
        RecordTypeId = rectCo[0].Id,
        AgentCode_Ext__c = '2'
      );
      insert myAccount2;
      Contact core = new Contact(
        email = 'wan@salesforce.com',
        firstname = 'wan',
        lastname = 'Plumbers',
        accountid = myAccount2.id
      );
      insert core;
      MyUser_Test = new User(
        ContactId = core.id,
        Alias = 'newWang',
        Email = 'newWang@testorg.com',
        EmailEncodingKey = 'UTF-8',
        LastName = 'TestUserWang',
        LanguageLocaleKey = 'zh_CN',
        LocaleSidKey = 'zh_CN',
        ProfileId = prof.Id,
        TimeZoneSidKey = 'Asia/Shanghai',
        UserName = 'testUserWang@testorg.com',
        Work_Location__c = '重庆'
      );
      insert MyUser_Test;
      System.debug('MyUser_Test' + MyUser_Test);
    }
    System.runAs(MyUser_Test) {
      //产品信息
      Product2 prod01 = new Product2(
        Name = 'Test01',
        ProductCode = 'Test01',
        Asset_Model_No__c = 'Test01',
        SFDA_Status__c = '有効',
        Dealer_special_Object__c = true,
        Packing_list_manual__c = 1,
        SFDA_Expiration_Date__c = Date.today(),
        Category5__c = 'test01',
        Manual_Entry__c = false
      );
      Product2 prod02 = new Product2(
        Name = 'Test02',
        ProductCode = 'Test02',
        Asset_Model_No__c = 'Test02',
        SFDA_Status__c = '有効',
        Dealer_special_Object__c = true,
        Packing_list_manual__c = 1,
        SFDA_Expiration_Date__c = Date.today(),
        Category5__c = 'test02',
        Manual_Entry__c = false
      );
      Product2 prod03 = new Product2(
        Name = 'Test03',
        ProductCode = 'Test03',
        Asset_Model_No__c = 'Test03',
        SFDA_Status__c = '有効',
        Dealer_special_Object__c = true,
        Packing_list_manual__c = 1,
        SFDA_Expiration_Date__c = Date.today(),
        Category5__c = 'test03',
        Manual_Entry__c = false
      );
      Product2 prod04 = new Product2(
        Name = 'Test04',
        ProductCode = 'Test04',
        Asset_Model_No__c = 'Test04',
        SFDA_Status__c = '有効',
        Dealer_special_Object__c = true,
        Packing_list_manual__c = 2,
        SFDA_Expiration_Date__c = Date.today(),
        Category5__c = 'test04',
        Manual_Entry__c = false
      );
      Product2 prod05 = new Product2(
        Name = 'Test05',
        ProductCode = 'Test05',
        Asset_Model_No__c = 'Test05',
        SFDA_Status__c = '有効',
        Dealer_special_Object__c = true,
        Packing_list_manual__c = 1,
        SFDA_Expiration_Date__c = Date.today(),
        Category5__c = 'test05',
        Manual_Entry__c = false
      );
      Product2 prod06 = new Product2(
        Name = 'Test06',
        ProductCode = 'Test06',
        Asset_Model_No__c = 'Test06',
        SFDA_Status__c = '有効',
        Dealer_special_Object__c = true,
        Packing_list_manual__c = 1,
        SFDA_Expiration_Date__c = Date.today(),
        Category5__c = 'test06',
        Manual_Entry__c = false
      );
      insert new List<Product2>{
        prod01,
        prod02,
        prod03,
        prod04,
        prod05,
        prod06
      };
      Product2__c pro1 = new Product2__c(
        Name = 'Pro001',
        OT_CODE_Text__c = 'Test001',
        Product2__c = prod01.Id
      );
      Product2__c pro2 = new Product2__c(
        Name = 'Pro002',
        OT_CODE_Text__c = 'Test002',
        Product2__c = prod02.Id
      );
      Product2__c pro3 = new Product2__c(
        Name = 'Pro004',
        OT_CODE_Text__c = 'Test004',
        Product2__c = prod03.Id
      );
      Product2__c pro4 = new Product2__c(
        Name = 'Pro005',
        OT_CODE_Text__c = 'Test005',
        Product2__c = prod04.Id
      );
      Product2__c pro5 = new Product2__c(
        Name = 'Pro003',
        OT_CODE_Text__c = 'Test003',
        Product2__c = prod05.Id
      );
      Product2__c pro6 = new Product2__c(
        Name = 'Pro006',
        OT_CODE_Text__c = 'Test006',
        Product2__c = prod06.Id
      );
      insert new List<Product2__c>{ pro4, pro5, pro6, pro1, pro2, pro3 };
      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 = myAccount2.Id;
      Order1.RecordTypeid = '01210000000c9duAAA';
      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 = myAccount2.Id;
      Order2.RecordTypeid = '012100000006Jx4AAE';
      Order2.Order_ProType__c = 'ENG';
      orderList.add(Order2);
      //盘点
      Consumable_order__c Order3 = new Consumable_order__c();
      Order3.Name = 'OCM_01';
      Order3.Order_status__c = '批准';
      Order3.Order_type__c = '盘点';
      Order3.Dealer_Info__c = myAccount2.Id;
      Order3.RecordTypeid = '01210000000c9dsAAA';
      Order3.Order_ProType__c = 'ENG';
      orderList.add(Order3);
      //发货
      Consumable_order__c Order4 = new Consumable_order__c();
      Order4.Name = 'OCM_0122';
      Order4.Order_status__c = '批准';
      Order4.Order_type__c = '订单';
      Order4.Dealer_Info__c = myAccount2.Id;
      Order4.RecordTypeid = '01210000000c9drAAA';
      Order4.Order_ProType__c = 'ET';
      Order4.ContractNo__c = '';
      orderList.add(Order4);
      insert orderList;
 
      List<Consumable_order_details2__c> conList = new List<Consumable_order_details2__c>();
      List<Consumable_order_details2__c> conList1 = new List<Consumable_order_details2__c>();
      List<Consumable_order_details2__c> conList2 = new List<Consumable_order_details2__c>();
      //拆盒已销售
      Consumable_order_details2__c con4 = new Consumable_order_details2__c();
      con4.Arrive_date__c = Date.today();
      con4.Deliver_date__c = Date.today();
      con4.Sterilization_limit__c = Date.today();
      con4.Send_Date__c = null;
      con4.Return_date__c = null;
      con4.Used_date__c = Date.today();
      con4.Lose_Flag__c = false;
      con4.Box_Piece__c = '个';
      con4.RemoveBox_date__c = Date.today();
      con4.RecordTypeId = '01210000000kUDKAA2';
      con4.Consumable_Product__c = pro2.Id;
      con4.Bar_Code__c = '100611';
      conList.add(con4);
      insert conList;
 
      //拆盒返品
      Consumable_order_details2__c con5 = new Consumable_order_details2__c();
      con5.Arrive_date__c = Date.today();
      con5.Return_date__c = Date.today();
      con5.Deliver_date__c = Date.today();
      con5.Send_Date__c = null;
      con5.Sterilization_limit__c = Date.today();
      con5.Used_date__c = Date.today();
      con5.Box_Piece__c = '个';
      con5.RemoveBox_date__c = Date.today();
      con5.RecordTypeId = '01210000000kUDPAA2';
      con5.Consumable_Product__c = pro2.Id;
      con5.Consumable_order_minor__c = Order4.Id;
      con5.Bar_Code__c = '10061';
      conList1.add(con5);
      insert conList1;
 
      //拆盒后盘点过
      Consumable_order_details2__c con6 = new Consumable_order_details2__c();
      con6.Inventory_date__c = Date.today();
      con6.Box_Piece__c = '个';
      con6.RemoveBox_date__c = Date.today();
      con6.Send_Date__c = null;
      con6.Deliver_date__c = Date.today();
      con6.Sterilization_limit__c = Date.today();
      con6.RecordTypeId = '01210000000kUDKAA2';
      con6.Consumable_Arrived_order__c = Order3.Id;
      con6.Consumable_Product__c = pro2.Id;
      con6.Bar_Code__c = '10078';
      conList2.add(con6);
      insert conList2;
 
      List<Consumable_order_details2__c> conList3 = 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 = Date.today();
      con3.Return_date__c = null;
      con3.Used_date__c = null;
      con3.Lose_Flag__c = false;
      con3.Box_Piece__c = '个';
      con3.Deliver_date__c = Date.today();
      con3.RemoveBox_date__c = Date.today();
      con3.RecordTypeId = '01210000000kUDKAA2';
      con3.Consumable_Product__c = pro2.Id;
      con3.Consumable_order_minor__c = Order4.Id;
      con3.Bar_Code__c = '100999';
      con3.Sterilization_limit__c = Date.today();
      conList3.add(con3);
      insert conList3;
 
      //reset
      // Consumable_order_details2__c con1 = new Consumable_order_details2__c();
      // con1.Intra_Trade_List_RMB__c = 1000;
      // con1.Asset_Model_No__c = 'test';
      // con1.Sterilization_limit__c = Date.today();
      // con1.Deliver_date__c =  Date.today();
      // 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.Box_Piece__c = '个';
 
      // con1.Consumable_order_minor__c = Order4.Id;
      // con1.Guarantee_period_for_products__c =  Date.today();
      // con1.Consumable_Product__c = pro2.Id;
      // con1.Bar_Code__c = '1009999';
      // conList2.add(con1);
      // insert conList2;
 
      // List<Consumable_order_details2__c> conList3 = new List<Consumable_order_details2__c> ();
      // Consumable_order_details2__c con9 = new Consumable_order_details2__c();
      // con9.RemoveBox_date__c = Date.today();
      // con9.Bar_Code__c = '100112';
      // con9.Arrive_date__c = Date.today();
      // con9.Send_Date__c = null;
      // con9.Used_date__c = null;
      // con9.Return_date__c = null;
      // con9.Lose_Flag__c = false;
      // con9.Box_Piece__c = '个';
      // con9.RemoveBox_No__c = 9;
      // conList3.add(con9);
      // LexCancelRemoveBoxController.searchConsumableorderdetails('100112','Testaccount003','重庆','ET');
 
      //orderDetails2
      // Consumable_order_details2__c con00 = new Consumable_order_details2__c();
      // con00.Box_Piece__c = '个';
      // con00.RemoveBox_date__c = Date.today();
      // con00.RemoveBox_No__c = 1;
      // con00.ContractNo_text__c = '';
      // con00.Consumable_order_minor__c = Order4.Id;
      // con00.Bar_Code__c = '10099999989';
      // conList3.add(con00);
 
      // insert conList3;
      System.Test.startTest();
      LexCancelRemoveBoxController CancelRemoveBoxController = new LexCancelRemoveBoxController();
      LexCancelRemoveBoxController.searchConsumableorderdetails(
        '100611\n10078\n10099\n1009999\n100999',
        'Testaccount003',
        '重庆',
        'ET'
      );
      LexCancelRemoveBoxController.searchConsumableorderdetails(
        '100611\n10078\n10061\n10051\n10041\n10031\n10021\n10011',
        'Testaccount003',
        '北京',
        'ET'
      );
      LexCancelRemoveBoxController.searchConsumableorderdetails(
        '100611\n10078\n10061\n10051\n10041\n10031\n10021\n10011',
        'Testaccount003',
        '重庆',
        'ET'
      );
      System.Test.stopTest();
    }
  }
}