高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
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
@isTest
private class InventoryReportDetailControllerTest {
    // 创建 Asset & 盘点表头 & 盘点明细 数据
    static void setupTestData() {
        SS_Batch_Column_Mapping__c InventoryHeaderName = new SS_Batch_Column_Mapping__c(Name = 'Inventory_Header_Name', SS_TableName__c='Inventory_Header_Name');
        InventoryHeaderName.From_Column_001__c = '北京 备品中心';
        InventoryHeaderName.SS_Column_001__c = 'BJ';
        InventoryHeaderName.From_Column_002__c = '上海 备品中心';
        InventoryHeaderName.SS_Column_002__c = 'SH';
        InventoryHeaderName.From_Column_003__c = '广州 备品中心';
        InventoryHeaderName.SS_Column_003__c = 'GZ';
        insert new SS_Batch_Column_Mapping__c[] {InventoryHeaderName};
        // 病院を作る
        Account hospital = new Account();
        hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
        hospital.Name = 'test hospital';
        hospital.Is_Active__c = '有効';
        hospital.Attribute_Type__c = '卫生部';
        hospital.Speciality_Type__c = '综合医院';
        hospital.Grade__c = '一级';
        hospital.OCM_Category__c = 'SLTV';
        hospital.Is_Medical__c = '医疗机构';
        //hospital.State_Master__c = al.id;
        //hospital.City_Master__c = al2.id;
        hospital.Town__c = '东京';
        insert hospital;
 
        // 戦略科室を得る
        Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
        // 診療科を作る
        Account dep = new Account();
        dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
        dep.Name = 'test dep';
        dep.AgentCode_Ext__c = '9999998';
        dep.ParentId = strategicDep[0].Id;
        dep.Department_Class__c = strategicDep[0].Id;
        dep.Hospital__c = hospital.Id;
        insert dep;
 
        Contact contact2 = new Contact();
        contact2.AccountId = dep.Id;
        contact2.FirstName = '責任者';
        contact2.LastName = 'test1经销商';
        insert contact2;
 
        // 产品
        Product2 pro1 = new Product2(Name='name01',IsActive=true,Family='GI',
                Fixture_Model_No__c='n01',Serial_Lot_No__c='S/N tracing',
                Fixture_Model_No_T__c = 'n01',
                ProductCode_Ext__c='pc01',Manual_Entry__c=false);
        Product2 pro2 = new Product2(Name='name02',IsActive=true,Family='GI',
                Fixture_Model_No__c='n02',Serial_Lot_No__c='Lot tracing',
                ProductCode_Ext__c='pc02',Manual_Entry__c=false);
        Product2 pro3 = new Product2(Name='name03',IsActive=true,Family='GI',
                Fixture_Model_No__c='n03',Serial_Lot_No__c='Lot tracing',
                ProductCode_Ext__c='pc03',Manual_Entry__c=false);
        insert new Product2[] {pro1, pro2, pro3};
 
        //---------------------------主体 两个附属品(个体管理 数量管理)
        // 保有设备A (主体)
        Asset assetA1 = new Asset(Asset_Owner__c = 'Olympus');
        assetA1.RecordTypeId = System.Label.Asset_RecordType;
        assetA1.SerialNumber = 'ass01';
        assetA1.Name = 'ass01';
        assetA1.AccountId = dep.Id;
        assetA1.Department_Class__c = strategicDep[0].Id;
        assetA1.Hospital__c = hospital.Id;
        assetA1.Product2Id = pro1.Id;
        assetA1.Quantity = 1;
        assetA1.Status = '有库存';
        assetA1.Manage_type__c = '个体管理';
        assetA1.Loaner_accsessary__c = false;
        assetA1.Product_category__c = 'GI';
        assetA1.Delete_Flag__c = false;
        assetA1.Freeze_sign__c = false;
        assetA1.Out_of_wh__c = 0;
        assetA1.Salesdepartment__c = '1.华北营业本部';
        assetA1.Internal_asset_location__c = '北京 备品中心';
        assetA1.Equipment_Type__c = '产品试用';
        assetA1.SalesProvince__c = '北京';
        assetA1.WH_location__c = '货架号1';
        // 保有设备A (附属品 数量管理)
        Asset assetA2 = new Asset(Asset_Owner__c = 'Olympus');
        assetA2.RecordTypeId = System.Label.Asset_RecordType;
        assetA2.SerialNumber = 'ass02';
        assetA2.Name = 'ass02';
        assetA2.AccountId = dep.Id;
        assetA2.Department_Class__c = strategicDep[0].Id;
        assetA2.Hospital__c = hospital.Id;
        assetA2.Product2Id = pro2.Id;
        assetA2.Quantity = 10;
        assetA2.Status = '有库存';
        assetA2.Manage_type__c = '数量管理';
        assetA2.Loaner_accsessary__c = true;
        assetA2.Product_category__c = 'GI';
        assetA2.Delete_Flag__c = false;
        assetA2.Freeze_sign__c = false;
        assetA2.Out_of_wh__c = 3;
        assetA2.Frozen_Quantity__c = 2;
        assetA2.Salesdepartment__c = '1.华北营业本部';
        assetA2.Internal_asset_location__c = '北京 备品中心';
        assetA2.Equipment_Type__c = '产品试用';
        assetA2.SalesProvince__c = '北京';
        assetA2.WH_location__c = '货架号2';
        // 保有设备A (附属品 个体管理)
        Asset assetA3 = new Asset(Asset_Owner__c = 'Olympus');
        assetA3.RecordTypeId = System.Label.Asset_RecordType;
        assetA3.SerialNumber = 'ass03';
        assetA3.Name = 'ass03';
        assetA3.AccountId = dep.Id;
        assetA3.Department_Class__c = strategicDep[0].Id;
        assetA3.Hospital__c = hospital.Id;
        assetA3.Product2Id = pro3.Id;
        assetA3.Quantity = 10;
        assetA3.Status = '有库存';
        assetA3.Manage_type__c = '数量管理';
        assetA3.Loaner_accsessary__c = true;
        assetA3.Product_category__c = 'GI';
        assetA3.Delete_Flag__c = false;
        assetA3.Freeze_sign__c = false;
        assetA3.Out_of_wh__c = 3;
        assetA3.Salesdepartment__c = '1.华北营业本部';
        assetA3.Internal_asset_location__c = '北京 备品中心';
        assetA3.Equipment_Type__c = '产品试用';
        assetA3.SalesProvince__c = '北京';
        assetA3.WH_location__c = '货架号3';
        assetA3.Abandoned_Inventory__c = 1;
        insert new Asset[] {assetA1, assetA2, assetA3};
 
        // 盘点表头
        List<Inventory_Header__c> invHeadTestList = new List<Inventory_Header__c>();
        Inventory_Header__c invHead1 = new Inventory_Header__c();
        invHead1.Internal_asset_location__c = '北京 备品中心';
        // invHead1.InventoryPIC__c = ;
        invHead1.Inventory_Start_Date__c = Date.today();
        invHead1.Inventory_Status__c = '盘点中';
        invHead1.UniqueKey__c = '备品中心:' + String.valueOf(Date.today());
        invHeadTestList.add(invHead1);
        insert invHeadTestList;
        List<Inventory_Header__c> invHeadList = [SELECT Id FROM Inventory_Header__c];
        System.assertEquals(1, invHeadList.size());
 
        // 盘点表明细 -- all 北京 备品中心
        List<Inventory_Detail__c> invDetailTestList = new List<Inventory_Detail__c>();
        // 盘盈 & 主体 & 固定资产 & GI & 产品试用 & 个体管理
        Inventory_Detail__c invDetail1 = new Inventory_Detail__c();
        invDetail1.Asset__c = assetA1.Id;
        invDetail1.Inventory_Header__c = invHead1.Id;
        invDetail1.Sync_Asset_Record_Flag__c  = true;
        invDetail1.toAbandon_amount__c = 1;             // 待废弃数
        // invDetail1.Inventory_Count__c = 15;             // 实盘数
        invDetail1.Amount__c = 14;                      // 应盘数
        invDetail1.Internal_Asset_number_key__c = 'abc';// 固定资产
        invDetail1.Internal_asset_location__c = '北京 备品中心';
        invDetail1.Asset_Status__c = '在库';
        invDetail1.Fixture_Model_No__c = 'n01';
        invDetail1.Internal_Asset_number__c = 'test';
        invDetail1.SerialNumber__c = 'serialNo1';
        invDetail1.WH_location__c = 'whLocation1';
        invDetail1.Main_OneToOne__c = true;
        invDetail1.Product_category__c = 'GI';
        invDetail1.Equipment_Type__c = '产品试用';
        invDetail1.Manage_type__c = '个体管理';
        // invDetail1.Inventory_Time__c = Date.today();
        invDetail1.UniqueKey__c = '备品中心:' + String.valueOf(Date.today()) + '1';
        invDetailTestList.add(invDetail1);
        // 盘亏 & 附属品 & 非固定资产 & SP & 数量管理
        Inventory_Detail__c invDetail2 = new Inventory_Detail__c();
        invDetail2.Asset__c = assetA2.Id;
        invDetail2.Inventory_Header__c = invHead1.Id;
        invDetail2.Sync_Asset_Record_Flag__c  = true;
        invDetail2.toAbandon_amount__c = 1;             // 待废弃数
        // invDetail2.Inventory_Count__c = 14;             // 实盘数
        invDetail2.Amount__c = 15;                      // 应盘数
        invDetail2.Internal_asset_location__c = '北京 备品中心';
        invDetail2.Asset_Status__c = '维修中';
        invDetail2.Fixture_Model_No__c = 'n01';
        invDetail2.Loaner_accsessary__c = true;         // 附属品
        invDetail2.Product_category__c = 'SP';
        invDetail2.Manage_type__c = '数量管理';
        // invDetail2.Inventory_Time__c = Date.today();
        invDetail2.UniqueKey__c = '备品中心:' + String.valueOf(Date.today()) + '2';
        invDetailTestList.add(invDetail2);
        Inventory_Detail__c invDetail3 = new Inventory_Detail__c();
        invDetail3.Asset__c = assetA3.Id;
        invDetail3.Inventory_Header__c = invHead1.Id;
        invDetail3.Sync_Asset_Record_Flag__c  = true;
        invDetail3.toAbandon_amount__c = 1;             // 待废弃数
        // invDetail3.Inventory_Count__c = 15;             // 实盘数
        invDetail3.Amount__c = 15;                      // 应盘数
        invDetail3.Internal_Asset_number_key__c = 'abc';// 固定资产
        invDetail3.Internal_asset_location__c = '北京 备品中心';
        invDetail3.Asset_Status__c = '出借中';
        invDetail3.Fixture_Model_No__c = 'n01';
        invDetail3.Internal_Asset_number__c = 'test';
        // invDetail3.Inventory_Time__c = Date.today();
        invDetail3.UniqueKey__c = '备品中心:' + String.valueOf(Date.today()) + '3';
        invDetailTestList.add(invDetail3);
        Inventory_Detail__c invDetail4 = new Inventory_Detail__c();
        invDetail4.Asset__c = assetA1.Id;
        invDetail4.Inventory_Header__c = invHead1.Id;
        invDetail4.Sync_Asset_Record_Flag__c  = true;
        invDetail4.toAbandon_amount__c = 1;             // 待废弃数
        // invDetail4.Inventory_Count__c = 15;             // 实盘数
        invDetail4.Amount__c = 15;                      // 应盘数
        invDetail4.Internal_Asset_number_key__c = 'abc';// 固定资产
        invDetail4.Internal_asset_location__c = '北京 备品中心';
        invDetail4.Asset_Status__c = '丢失';
        invDetail4.Fixture_Model_No__c = 'n01';
        // invDetail4.Inventory_Time__c = Date.today();
        invDetail4.UniqueKey__c = '备品中心:' + String.valueOf(Date.today()) + '4';
        invDetailTestList.add(invDetail4);
        Inventory_Detail__c invDetail5 = new Inventory_Detail__c();
        invDetail5.Asset__c = assetA2.Id;
        invDetail5.Inventory_Header__c = invHead1.Id;
        invDetail5.Sync_Asset_Record_Flag__c  = true;
        invDetail5.toAbandon_amount__c = 1;             // 待废弃数
        // invDetail5.Inventory_Count__c = 15;             // 实盘数
        invDetail5.Amount__c = 15;                      // 应盘数
        invDetail5.Internal_asset_location__c = '北京 备品中心';
        invDetail5.Asset_Status__c = '在库';
        invDetail5.Fixture_Model_No__c = 'n01';
        // invDetail5.Inventory_Time__c = Date.today();
        invDetail5.UniqueKey__c = '备品中心:' + String.valueOf(Date.today()) + '5';
        invDetailTestList.add(invDetail5);
        Inventory_Detail__c invDetail6 = new Inventory_Detail__c();
        invDetail6.Asset__c = assetA3.Id;
        invDetail6.Inventory_Header__c = invHead1.Id;
        invDetail6.Sync_Asset_Record_Flag__c  = true;
        invDetail6.toAbandon_amount__c = 1;             // 待废弃数
        // invDetail6.Inventory_Count__c = 15;             // 实盘数
        invDetail6.Amount__c = 15;                      // 应盘数
        invDetail6.Internal_asset_location__c = '北京 备品中心';
        invDetail6.Asset_Status__c = '冻结';
        // invDetail6.Inventory_Time__c = Date.today();
        invDetail6.UniqueKey__c = '备品中心:' + String.valueOf(Date.today()) + '6';
        invDetailTestList.add(invDetail6);
        insert invDetailTestList;
 
        List<Inventory_Detail__c> invDetailUpdateList = new List<Inventory_Detail__c>();
        invDetail1.Inventory_Count__c = 15;             // 实盘数
        invDetail2.Inventory_Count__c = 14;             // 实盘数
        invDetail3.Inventory_Count__c = 15;             // 实盘数
        invDetail4.Inventory_Count__c = 15;             // 实盘数
        invDetail5.Inventory_Count__c = 15;             // 实盘数
        invDetail6.Inventory_Count__c = 15;             // 实盘数
        invDetail1.Inventory_Time__c = Date.today();
        invDetail2.Inventory_Time__c = Date.today();
        invDetail3.Inventory_Time__c = Date.today();
        invDetail4.Inventory_Time__c = Date.today();
        invDetail5.Inventory_Time__c = Date.today();
        invDetail6.Inventory_Time__c = Date.today();
        invDetailUpdateList.add(invDetail1);
        invDetailUpdateList.add(invDetail2);
        invDetailUpdateList.add(invDetail3);
        invDetailUpdateList.add(invDetail4);
        invDetailUpdateList.add(invDetail5);
        invDetailUpdateList.add(invDetail6);
        update invDetailUpdateList;
 
        List<Inventory_Detail__c> invDetailList = [SELECT Id FROM Inventory_Detail__c];
        System.assertEquals(6, invDetailList.size());
 
    }
 
    static Inventory_Header__c invHeadObj { get {
        List<Inventory_Header__c> invObjs = [
                SELECT Id, Inventory_Status__c, Name, InventoryPIC__r.Name
                , Inventory_Submit_Date__c, Internal_asset_location__c, Inventory_Start_Date__c
                , Inventory_Date_From__c, Inventory_Date_To__c, Inventory_Persons__c
                , InventorySubmit_PIC__c, InventorySubmit_PIC__r.Post__c, InventoryCheck_PIC__c
                , InventoryCheck_PIC__r.Post__c, Checktime__c
                , Jingli_Equipment__r.Name, Buzhang_Equipment__r.Name, Zongjian_Equipment__r.Name
                , IvtDifference_Detail__c, IvtDifference_Comment__c
                , Buzhang_Equipment_Id__c, Zongjian_Equipment_Id__c, Jingli_Equipment_Id__c
                 FROM Inventory_Header__c
                ];
        System.assertEquals(invObjs.size(), 1);
        Inventory_Header__c invHeadObj = invObjs[0];
 
        return invHeadObj;
    }}
 
    static String invHeadId { get { return invHeadObj.Id; }}
 
    // 初始化画面
    static testMethod void testInitPage() {
        // システム管理者
        User user = new User(Test_staff__c = true);
        user.LastName = '_サンブリッジ';
        user.FirstName = 'う';
        user.Alias = 'う';
        user.Email = 'olympusTest03@sunbridge.com';
        user.Username = 'olympusTest03@sunbridge.com';
        user.CommunityNickname = 'う';
        user.IsActive = true;
        user.EmailEncodingKey = 'ISO-2022-JP';
        user.TimeZoneSidKey = 'Asia/Tokyo';
        user.LocaleSidKey = 'ja_JP';
        user.LanguageLocaleKey = 'ja';
        user.ProfileId = System.Label.ProfileId_SystemAdmin;
        user.Job_Category__c = '销售推广';
        user.Province__c = '北京市';
        user.Use_Start_Date__c = Date.today().addMonths(-6);
        user.SalesManager__c = UserInfo.getUserId();
        user.BuchangApprovalManagerSales__c = UserInfo.getUserId();
        user.JingliApprovalManager__c = UserInfo.getUserId();
        user.BuchangApprovalManager__c = UserInfo.getUserId();
        user.ZongjianApprovalManager__c = UserInfo.getUserId();
 
        System.runAs(new User(Id = Userinfo.getUserId())) {
            setupTestData();
 
            insert user;
            User currUser = [
                        SELECT Id, Name, Default_Referable_Apply_Equipment_Center__c
                        FROM User
                        WHERE Id = :UserInfo.getUserId()
                        ];
            System.assertEquals('北京 备品中心', currUser.Default_Referable_Apply_Equipment_Center__c);
 
            PageReference page = new PageReference('/apex/InventoryReportDetail');    // 不带id的url
            System.Test.setCurrentPage(page);
            InventoryReportDetailController controller = new InventoryReportDetailController(new ApexPages.StandardController(invHeadObj));
            CreateRelationListPagingCmpCtrl cmp = new CreateRelationListPagingCmpCtrl();
            cmp.pageController = controller;
            controller.init();
 
            page = new PageReference('/apex/InventoryReportDetail?ivt_headId=' + invHeadId);  // 带id的url
            System.Test.setCurrentPage(page);
            controller.init();
 
            System.Test.StartTest();
 
            System.Test.StopTest();
        }
 
    }
 
    // 添加检索条件
    static testMethod void testSearchOpp() {
        // システム管理者
        User user = new User(Test_staff__c = true);
        user.LastName = '_サンブリッジ';
        user.FirstName = 'う';
        user.Alias = 'う';
        user.Email = 'olympusTest03@sunbridge.com';
        user.Username = 'olympusTest03@sunbridge.com';
        user.CommunityNickname = 'う';
        user.IsActive = true;
        user.EmailEncodingKey = 'ISO-2022-JP';
        user.TimeZoneSidKey = 'Asia/Tokyo';
        user.LocaleSidKey = 'ja_JP';
        user.LanguageLocaleKey = 'ja';
        user.ProfileId = System.Label.ProfileId_SystemAdmin;
        user.Job_Category__c = '销售推广';
        user.Province__c = '北京市';
        user.Use_Start_Date__c = Date.today().addMonths(-6);
        user.SalesManager__c = UserInfo.getUserId();
        user.BuchangApprovalManagerSales__c = UserInfo.getUserId();
        user.JingliApprovalManager__c = UserInfo.getUserId();
        user.BuchangApprovalManager__c = UserInfo.getUserId();
        user.ZongjianApprovalManager__c = UserInfo.getUserId();
 
        System.runAs(new User(Id = Userinfo.getUserId())) {
            setupTestData();
            insert user;
 
            PageReference page = new PageReference('/apex/InventoryReportDetail?ivt_headId=' + invHeadId);
            System.Test.setCurrentPage(page);
            InventoryReportDetailController controller = new InventoryReportDetailController(new ApexPages.StandardController(invHeadObj));
            CreateRelationListPagingCmpCtrl cmp = new CreateRelationListPagingCmpCtrl();
            cmp.pageController = controller;
            controller.myComponentController.init();
 
            System.Test.StartTest();
            // I 无检索条件
            controller.searchOpp();
            System.assertEquals(6, controller.viewList.size());
 
            List<Inventory_Detail__c> idObjList = [
                                                    SELECT Id, UniqueKey__c
                                                      FROM Inventory_Detail__c
                                                     ORDER BY UniqueKey__c
                                                    ];
            System.assertEquals(6, idObjList.size());
 
            // II 盘亏 & 附属品 & 非固定资产 & SP & 数量管理
            controller.bpPankuiYing = controller.getbpPankuiYingOps()[2].getValue();        // Pankui
            controller.bpBodyFushupin = controller.getbpBodyFushupinOps()[2].getValue();    // Fushupin
            controller.ifInternalAsset = controller.getifInternalAssetOps()[2].getValue();  // false
            controller.bieChanPinFenLei = controller.getbieChanPinFenLeiOps()[2].getValue();// SP
            controller.bieManageType = controller.getbieManageTypeOps()[1].getValue();      // 数量管理
            controller.searchOpp();
            System.assertEquals(1, controller.viewList.size());
            Inventory_Detail__c idObj = (Inventory_Detail__c)controller.viewList[0].sobj;
            System.assertEquals(idObj.Id, idObjList[1].Id);     // invDetail2
            // System.assertEquals(true, idObj.Inventory_Count__c-idObj.Amount__c<0);     // Pankui
            // System.assertEquals(true, idObj.Loaner_accsessary__c);                     // Fushupin
            // System.assertEquals(true, idObj.Internal_Asset_number__c==null);           // 非固定资产
            // System.assertEquals('SP', idObj.Product_category__c);                      // 产品分类
            // System.assertEquals('数量管理', idObj.Manage_type__c);                      // 管理种类
 
            // III 盘盈 & 主体 & 固定资产 & GI & 产品试用 & 个体管理 & 备品型号 & 固定资产号 & 机身号 & 货架号
            controller.modelNo = 'n01';
            controller.assetNumberKey = 'test';
            controller.serialNo = 'serialNo1';
            controller.whLocation = 'whLocation1';
            controller.bpPankuiYing = controller.getbpPankuiYingOps()[1].getValue();        // Panying
            controller.bpBodyFushupin = controller.getbpBodyFushupinOps()[1].getValue();    // Zhuti
            controller.ifInternalAsset = controller.getifInternalAssetOps()[1].getValue();  // true
            controller.bieChanPinFenLei = controller.getbieChanPinFenLeiOps()[1].getValue();// GI
            controller.bieBeiPinFenLei = controller.getbieBeiPinFenLeiOps()[2].getValue();  // 产品试用
            controller.bieManageType = controller.getbieManageTypeOps()[2].getValue();      // 个体管理
            controller.searchOpp();
            System.assertEquals(1, controller.viewList.size());
            idObj = (Inventory_Detail__c)controller.viewList[0].sobj;
            System.assertEquals(idObj.Id, idObjList[0].Id);     // invDetail1
            // System.assertEquals(true, idObj.Inventory_Count__c-idObj.Amount__c>0);     // Panying
            // System.assertEquals(true, idObj.Main_OneToOne__c);                         // Zhuti
            // System.assertEquals(true, idObj.Internal_Asset_number__c!=null);           // 固定资产
            // System.assertEquals('GI', idObj.Product_category__c);                      // 产品分类
            // System.assertEquals('个体管理', idObj.Manage_type__c);                      // 管理种类
 
            System.Test.StopTest();
        }
 
    }
 
    // 保存备注和备注人
    static testMethod void testSave() {
        // システム管理者
        User user = new User(Test_staff__c = true);
        user.LastName = '_サンブリッジ';
        user.FirstName = 'う';
        user.Alias = 'う';
        user.Email = 'olympusTest03@sunbridge.com';
        user.Username = 'olympusTest03@sunbridge.com';
        user.CommunityNickname = 'う';
        user.IsActive = true;
        user.EmailEncodingKey = 'ISO-2022-JP';
        user.TimeZoneSidKey = 'Asia/Tokyo';
        user.LocaleSidKey = 'ja_JP';
        user.LanguageLocaleKey = 'ja';
        user.ProfileId = System.Label.ProfileId_SystemAdmin;
        user.Job_Category__c = '销售推广';
        user.Province__c = '北京市';
        user.Use_Start_Date__c = Date.today().addMonths(-6);
        user.SalesManager__c = UserInfo.getUserId();
        user.BuchangApprovalManagerSales__c = UserInfo.getUserId();
        user.JingliApprovalManager__c = UserInfo.getUserId();
        user.BuchangApprovalManager__c = UserInfo.getUserId();
        user.ZongjianApprovalManager__c = UserInfo.getUserId();
 
        System.runAs(new User(Id = Userinfo.getUserId())) {
            setupTestData();
            insert user;
 
            PageReference page = new PageReference('/apex/InventoryReportDetail?ivt_headId=' + invHeadId);
            System.Test.setCurrentPage(page);
            InventoryReportDetailController controller = new InventoryReportDetailController(new ApexPages.StandardController(invHeadObj));
            CreateRelationListPagingCmpCtrl cmp = new CreateRelationListPagingCmpCtrl();
            cmp.pageController = controller;
            controller.myComponentController.init();
 
            System.Test.StartTest();
            controller.searchOpp();
            System.assertEquals(6, controller.viewList.size());
 
            List<Inventory_Detail__c> idObjList = [
                                                    SELECT Id, UniqueKey__c
                                                      FROM Inventory_Detail__c
                                                     ORDER BY UniqueKey__c
                                                    ];
            System.assertEquals(6, idObjList.size());
            Inventory_Detail__c idObj = (Inventory_Detail__c)controller.viewList[0].sobj;
            controller.viewList[0].changeFlg = '1';
            idObj.Inventory_Remarks__c = 'remark test';
            controller.saveType = '1';
            controller.save();
 
            controller.keyword = 'remark';
            controller.searchOpp();
            System.assertEquals(1, controller.viewList.size());
            idObj = (Inventory_Detail__c)controller.viewList[0].sobj;
            idObjList = [
                        SELECT Id, Inventory_Remarks__c
                          FROM Inventory_Detail__c
                         WHERE Inventory_Remarks__c LIKE '%remark%'
                        ];
            System.assertEquals(1, idObjList.size());
            System.assertEquals(idObj.Id, idObjList[0].Id);
            System.Test.StopTest();
        }
 
    }
}