高章伟
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
@isTest
private class LookupControllerTest {
    static testMethod void testMethod1() {
         SS_Batch_Column_Mapping__c oppMapping = new SS_Batch_Column_Mapping__c(Name = 'targetKeyProduct', SS_TableName__c='targetKeyProduct__c');
        oppMapping.From_Column_001__c = 'OPD_CV290__c';
        oppMapping.SS_Column_001__c = 'CV-290';
        oppMapping.From_Column_002__c = 'OPD_290Miro__c';
        oppMapping.SS_Column_002__c = 'GI-290镜子,GI-290镜子放大,GI-290镜子CF,BF-290镜子';
        oppMapping.From_Column_003__c = 'OPD_TB__c';
        oppMapping.SS_Column_003__c = 'TB';
        oppMapping.From_Column_101__c = 'Rental_Cnt_CV290__c';
        oppMapping.SS_Column_101__c = 'CV-290';
        oppMapping.From_Column_102__c = 'Rental_Cnt_290MiroGI__c';
        oppMapping.SS_Column_102__c = 'GI-290镜子';
        oppMapping.From_Column_103__c = 'Rental_Cnt_TB__c';
        oppMapping.SS_Column_103__c = 'TB';
        
 
        oppMapping.From_Column_118__c = 'Sales_target_CV290__c';
        oppMapping.SS_Column_118__c = 'CV-290';
        oppMapping.From_Column_119__c = 'Sales_target_290Miro__c';
        oppMapping.SS_Column_119__c = 'GI-290镜子,GI-290镜子放大,GI-290镜子CF,BF-290镜子';
        oppMapping.From_Column_120__c = 'Sales_target_TB__c';
        oppMapping.SS_Column_120__c = 'TB';
        oppMapping.From_Column_129__c = 'Opp_cnt_290MiroBF__c';
        oppMapping.SS_Column_129__c = 'BF-290镜子';
        oppMapping.From_Column_130__c = 'Opp_cnt_290MiroGI__c';
        oppMapping.SS_Column_130__c = 'GI-290镜子';
        oppMapping.From_Column_131__c = 'Opp_cnt_290MiroGI_CF__c';
        oppMapping.SS_Column_131__c = 'GI-290镜子CF';
        oppMapping.From_Column_146__c = 'Asset_Cnt_290MiroBF__c';
        oppMapping.SS_Column_146__c = 'BF-290镜子';
        oppMapping.From_Column_147__c = 'Asset_Cnt_290MiroGI__c';
        oppMapping.SS_Column_147__c = 'GI-290镜子';
        oppMapping.From_Column_148__c = 'Asset_Cnt_290MiroGI_CF__c';
        oppMapping.SS_Column_148__c = 'GI-290镜子CF';
        oppMapping.From_Column_163__c = 'OPD_amount_290MiroBF__c';
        oppMapping.SS_Column_163__c = 'BF-290镜子';
        oppMapping.From_Column_164__c = 'OPD_amount_290MiroGI__c';
        oppMapping.SS_Column_164__c = 'GI-290镜子';
        oppMapping.From_Column_165__c = 'OPD_amount_290MiroGI_CF__c';
        oppMapping.SS_Column_165__c = 'GI-290镜子CF';
        insert new SS_Batch_Column_Mapping__c[] {oppMapping};
        
 
       //医院 记录类型
        List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'];
        if (rectHp.size() == 0) {
            return;
        }
        //科室 记录类型
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'];
        if (rectDpt.size() == 0) {
            return;
        }
 
        //简档
        Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
 
        //用户
        User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert hpOwner;
        User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert hpOwner2;
 
 
        //医院
        Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id);
        hp.FSE_GI_Main_Leader__c = hpOwner.Id;
        hp.FSE_SP_Main_Leader__c = hpOwner2.Id;
        insert hp;
 
        //战略科室
        Account dc = [select Id, Name, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_GI'];
        //科室
        Account dpt = new Account(RecordTypeId = rectDpt[0].Id);
        dpt.Name         = '*';
        dpt.Department_Name__c  = 'TestDepart';
        dpt.ParentId            = dc.Id;
        dpt.Department_Class__c = dc.Id;
        dpt.Hospital__c         = hp.Id;
        insert dpt;
        //科室1
        Account dpt1 = new Account(RecordTypeId = rectDpt[0].Id);
        dpt1.Name         = '123';
        dpt1.Department_Name__c  = 'TestDepart1';
        dpt1.ParentId            = dc.Id;
        dpt1.Department_Class__c = dc.Id;
        dpt1.Hospital__c         = hp.Id;
        insert dpt1;
 
 
        PageReference page = new PageReference('/apex/LookupPage?SObjectName=Account&searchLike=123');
        System.Test.setCurrentPage(page);
        System.Test.StartTest();
        LookupController look = new LookupController();
        look.search();
        look.soql('Account', 'Test');
        look.FirstPage();
        look.previous();
        look.next();
        look.LastPage();
        look.getModelCode();
        look.loadPage();
 
 
 
        System.Test.StopTest(); 
    }
 
    static testMethod void testMethod2() {
        
            // 产品
        Product2 pro5 = new Product2(Name='name05',IsActive=true,Family='SP',
                Fixture_Model_No__c='n05',Serial_Lot_No__c='S/N tracing',
                Fixture_Model_No_T__c = 'n05',
                ProductCode_Ext__c='pc05',Manual_Entry__c=false,
                StorageStatus__c = '',StorageStatusNo__c = 22,
                WhiteSpace__c = true);
        insert pro5;
 
        ModelLendingProduct__c mpdelLendingProduct = new ModelLendingProduct__c();
        mpdelLendingProduct.name='模型123';
        mpdelLendingProduct.Product__c = pro5.Id;
 
        insert mpdelLendingProduct;
 
 
        PageReference page = new PageReference('/apex/LookupPage?SObjectName=ModelLendingProduct__c&searchLike=123');
        System.Test.setCurrentPage(page);
        System.Test.StartTest();
        LookupController look = new LookupController();
        look.search();
        look.soql('Account', 'Test');
        look.FirstPage();
        look.previous();
        look.next();
        look.LastPage();
        look.getModelCode();
        look.loadPage();
 
 
 
        System.Test.StopTest(); 
    }
 
}