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
@isTest
public  class InventoryControllerTest {
    // private static RecordType rectCoO ;
    // private static Account olympus;
    // private static Account myAccount1;
    // private static Contact core;
    // private static user MyUser_Test;
    // static void creatdata(){
    //     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;
    //     }
    //     rectCoO = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
    //     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;
    //     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');
    //     // List<user> MyUser_Test = [select id,Alias,Email,LastName,UserName from User where Alias = '精琢技术'];
    //     insert MyUser_Test;
    // }
    static testMethod void InventoryControllerTest_PartBar(){
        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;
        // creatdata();
        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;
        Account 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;
        // user 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');
        // List<user> MyUser_Test = [select id,Alias,Email,LastName,UserName,Contact.accountid,Contact.account.Name from User where Id = '00510000006xOSq'];
        // insert MyUser_Test;
        user MyUser_Test =new user();
        System.runAs(new User(Id = UserInfo.getUserId())){ 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 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);
      //      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);
      //      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);
      //      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 = 1);
      //      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);
      //      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);
            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,Category5__c='竞争对手');
            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,Category5__c='竞争对手');
            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,Category5__c='竞争对手');
            //insert new Product2[] {prod01,prod02,prod03,prod04,prod05,prod06,prod07,prod08,prod09};
            insert new Product2[] {prod07,prod08,prod09};
 
            //Product2__c pro1 = new Product2__c(Name='MH-364:帽',Product2__c = prod01.Id);
            //Product2__c pro2 = new Product2__c(Name='MH-462:透明黏膜吸套',Product2__c = prod02.Id);
            //Product2__c pro5 = new Product2__c(Name='MH-155:白平衡帽',Product2__c = prod03.Id);
            //Product2__c pro3 = new Product2__c(Name='MB-677:BNC电缆',Product2__c = prod04.Id);
            //Product2__c pro4 = new Product2__c(Name='70236110:金刚砂锥状钻头,70度',Product2__c = prod05.Id);
            //Product2__c pro6 = new Product2__c(Name='MAJ-643R:水囊鞘管',Product2__c = prod06.Id);
            //制作产品
            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;
            //Product2__c proD = new Product2__c(Name='70236110:金刚砂锥状钻头,70度',OT_CODE_Text__c='Test003',Product2__c = prod09.Id);
            //insert proD;
            //insert new Product2__c[] {pro1, pro2,pro3,pro4, pro5, pro6};
 
            //预制头明细
            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 = MyUser_Test[0].Contact.accountId;
            CreateId.Dealer_Info__c = myAccount1.id;
            CreateId.Inventory_date__c = Date.today();
            CreateId.Order_type__c = '盘点';
            CreateId.Order_ProType__c = 'ET';
            insert  CreateId;
        
            ConsumableAssetHander.isRunning=true;
            //制作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;
            insert 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;
            insert 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;    
            insert 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;
            insert 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;
            insert dataForProductCount5;
            
            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];
                        // AND  Dealer_Info_text__c = :MyUser_Test[0].Contact.account.Name];
           // system.assertEquals(8,productCount_Res.size());
             PageReference page = new Pagereference('/Inventory');
             page.setRedirect(true);
             
            System.Test.setCurrentPage(page);
            InventoryController OwnTest = new InventoryController();
            System.Test.startTest();
            OwnTest.init();
            
            OwnTest.barcode = '';
            OwnTest.searchConsumableorderdetails();
            //OwnTest.save();
 
            OwnTest.barcode = '';
            OwnTest.ConsumableorderdetailsRecordsview[0][0].check = true;
            OwnTest.searchConsumableorderdetails();
            //system.assertEquals(100,OwnTest.ConsumableorderdetailsRecordsview[0].size());
            //OwnTest.save();
            
            OwnTest.barcode = '1234567895\n1234567890\n12345678511\n1234567856\n1234567855\n1234567886\n12345678551\n1234567890\n1234567883\n1234567882\n1234567881\n1234567884\nn123456788412\n1234567885\n123456788512\n1234567891\n1234567892\n1234567893\n1234567894';
            //OwnTest.ConsumableorderdetailsRecordsview[0][0].check = true;
            //OwnTest.ConsumableorderdetailsRecordsview[0][0].DiffReason = '123';
            //OwnTest.ConsumableorderdetailsRecordsview[0][1].check = true;
            //OwnTest.ConsumableorderdetailsRecordsview[0][1].DiffReason = null;
            //OwnTest.ConsumableorderdetailsRecordsview[0][2].check = false;
            OwnTest.searchConsumableorderdetails();
            OwnTest.save();
            //system.assertEquals(4,OwnTest.consumableorderdetailsRecordserrordummy.size());
            OwnTest.doClick();
            OwnTest.ProS();
  
            
            System.Test.stopTest();
        }
    }
    static testMethod void InventoryControllerTest_PartPan(){
        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 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true);
        //      Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true);
        //      Product2 prod03 = new Product2(Name='Test03',ProductCode='Test03',Asset_Model_No__c = 'Test03',SFDA_Status__c = '有効',Dealer_special_Object__c = true);
        //      Product2 prod04 = new Product2(Name='Test04',ProductCode='Test04',Asset_Model_No__c = 'Test04',SFDA_Status__c = '有効',Dealer_special_Object__c = true);
        //      Product2 prod05 = new Product2(Name='Test05',ProductCode='Test05',Asset_Model_No__c = 'Test05',SFDA_Status__c = '有効',Dealer_special_Object__c = true);
        //      Product2 prod06 = new Product2(Name='Test06',ProductCode='Test06',Asset_Model_No__c = 'Test06',SFDA_Status__c = '有効',Dealer_special_Object__c = true);
        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 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 pro5 = new Product2__c(Name='Pro003',OT_CODE_Text__c='Test003',Product2__c = prod03.Id);
        //Product2__c pro3 = new Product2__c(Name='Pro004',OT_CODE_Text__c='Test004',Product2__c = prod04.Id);
        //Product2__c pro4 = new Product2__c(Name='Pro005',OT_CODE_Text__c='Test005',Product2__c = prod05.Id);
        //Product2__c pro6 = new Product2__c(Name='Pro006',OT_CODE_Text__c='Test006',Product2__c = prod06.Id);
        //insert new Product2__c[] {pro4, pro5,pro6,pro1, pro2, pro3};
        //制作产品
        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;
        //Product2__c proD = new Product2__c(Name='Too003',OT_CODE_Text__c='Test001',Product2__c = prod09.Id);
        //insert proD;
        
        Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id);
        //Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
        insert myAccount1;
        //insert myAccount2;
        Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.id);
        insert core;
        // user 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;
        user MyUser_Test =new user();
        System.runAs(new User(Id = UserInfo.getUserId())){ 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(){
        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;
        Account 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;
        // user 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;
        user MyUser_Test =new user();
        System.runAs(new User(Id = UserInfo.getUserId())){ 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 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);
      //      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);
      //      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);
      //      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 = 1);
      //      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);
      //      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);
            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,Category5__c='竞争对手');
            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,Category5__c='竞争对手');
            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,Category5__c='竞争对手');
            insert new Product2[] {prod07,prod08,prod09};
 
            //Product2__c pro1 = new Product2__c(Name='MH-364:帽',Product2__c = prod01.Id);
            //Product2__c pro2 = new Product2__c(Name='MH-462:透明黏膜吸套',Product2__c = prod02.Id);
            //Product2__c pro5 = new Product2__c(Name='MH-155:白平衡帽',Product2__c = prod03.Id);
            //Product2__c pro3 = new Product2__c(Name='MB-677:BNC电缆',Product2__c = prod04.Id);
            //Product2__c pro4 = new Product2__c(Name='70236110:金刚砂锥状钻头,70度',Product2__c = prod05.Id);
            //Product2__c pro6 = new Product2__c(Name='MAJ-643R:水囊鞘管',Product2__c = prod06.Id);
            //制作产品
            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;
            //Product2__c proD = new Product2__c(Name='70236110:金刚砂锥状钻头,70度',OT_CODE_Text__c='Test003',Product2__c = prod09.Id);
            //insert proD;
            //insert new Product2__c[] {pro1, pro2,pro3,pro4, pro5, pro6};
            //预制头明细
            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;
        
            
            //制作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;
            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;
            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 dataForProduct1 = new Consumable_order_details2__c();
            dataForProduct1.Bar_Code__c               = '1234567893';
            dataForProduct1.Arrive_date__c              = Date.today();
            dataForProduct1.Sterilization_limit__c    = Date.today().addDays(2);
            dataForProduct1.RecordTypeid              = System.Label.RT_ConOrderDetail2_Delivery;
            dataForProduct1.Consumable_Product__c     = proG.id;
            dataForProduct1.Box_Piece__c              = '个';
            dataForProduct1.Consumable_order_minor__c = CreateId.id;
            dataForProduct1.Send_Date__c = null;
            dataForProduct1.Used_date__c = null;
            dataForProduct1.Lose_Flag__c = false;
            dataForProduct1.RemoveBox_No__c = 1;
            insert dataForProduct1;*/
            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;
            insert 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;
            insert dataForProductCount3;
            
    
             PageReference page = new Pagereference('/Inventory');
             page.setRedirect(true);
            System.Test.setCurrentPage(page);
            InventoryController OwnTest = new InventoryController();
            //OwnTest.init();
            System.Test.startTest();
            OwnTest.size = 2;
            OwnTest.init();
 
            
            OwnTest.barcode = '1234567816\n12345678951\n123456785512\n12345678561\n12345678551\n12345678861\n12345678901\n12345678831\n12345678821\n12345678811\n12345678841\n12345678851\n12345678911\n12345678921\n12345678931\n12345678941\n1234567856';
            /*OwnTest.ConsumableorderdetailsRecordsview[0][0].check = true;
            OwnTest.ConsumableorderdetailsRecordsview[0][0].DiffReason = '123';
            OwnTest.ConsumableorderdetailsRecordsview[0][1].check = true;
            OwnTest.ConsumableorderdetailsRecordsview[0][1].DiffReason = null;
            OwnTest.ConsumableorderdetailsRecordsview[0][2].check = false;*/
            OwnTest.searchConsumableorderdetails();
            System.assertEquals(2, OwnTest.ConsumableorderdetailsRecordsview[0].size());
            OwnTest.ConsumableorderdetailsRecordsview[0][0].check = true;
            OwnTest.ConsumableorderdetailsRecordsview[0][0].DiffReason = '123';
            OwnTest.save();
            OwnTest.refreshPageSize();
            OwnTest.makepagerecords();
            OwnTest.setCon.next();
            System.Test.stopTest();
        }
    }
 
    static testMethod void InventoryControllerTest_xunhui(){
        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;
        Account 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;
        // user 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;
        user MyUser_Test =new user();
        System.runAs(new User(Id = UserInfo.getUserId())){ 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 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);
      //      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);
      //      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);
      //      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 = 1);
      //      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);
      //      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);
            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,Category5__c='竞争对手');
            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,Category5__c='竞争对手');
            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,Category5__c='竞争对手');
            insert new Product2[] {prod07,prod08,prod09};
 
            //Product2__c pro1 = new Product2__c(Name='MH-364:帽',Product2__c = prod01.Id);
            //Product2__c pro2 = new Product2__c(Name='MH-462:透明黏膜吸套',Product2__c = prod02.Id);
            //Product2__c pro5 = new Product2__c(Name='MH-155:白平衡帽',Product2__c = prod03.Id);
            //Product2__c pro3 = new Product2__c(Name='MB-677:BNC电缆',Product2__c = prod04.Id);
            //Product2__c pro4 = new Product2__c(Name='70236110:金刚砂锥状钻头,70度',Product2__c = prod05.Id);
            //Product2__c pro6 = new Product2__c(Name='MAJ-643R:水囊鞘管',Product2__c = prod06.Id);
            //制作产品
            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;
            //Product2__c proD = new Product2__c(Name='70236110:金刚砂锥状钻头,70度',OT_CODE_Text__c='Test003',Product2__c = prod09.Id);
            //insert proD;
            //insert new Product2__c[] {pro1, pro2,pro3,pro4, pro5, pro6};
            //预制头明细
            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;
        
            
            //制作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;
    
             PageReference page = new Pagereference('/Inventory');
            page.setRedirect(true);
            System.Test.setCurrentPage(page);
            InventoryController OwnTest = new InventoryController();
            System.Test.startTest();
            OwnTest.init();
            OwnTest.barcode = '';
            OwnTest.ConsumableorderdetailsRecordsview[0][0].check = true;
            OwnTest.ConsumableorderdetailsRecordsview[0][1].check = true;
            OwnTest.searchConsumableorderdetails();
            OwnTest.save();
 
            OwnTest = new InventoryController();
            OwnTest.init();
            OwnTest.barcode = '1234567890\n1234567891\n1234567892\n1234567893\n1234567814';
            //OwnTest.ConsumableorderdetailsRecordsview[0][0].check = true;
            //OwnTest.ConsumableorderdetailsRecordsview[0][1].check = true;
            OwnTest.searchConsumableorderdetails();
            OwnTest.save();
            System.Test.stopTest();
        }
    }
}