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
@isTest
public class RetrospectiveWeeklyReportControllerTest {
    static user myUser_Test;  
    static Contact core; 
    static Account myAccount2;         
    public static Account account1 = new Account();
    public static Account account2 = new Account();
    public static Contact contact1 = new Contact();
    public static Contact contact2 = new Contact();
    public static User user = new User();
    public static Agency_Hospital_Link__c agency_hospital_link = new Agency_Hospital_Link__c();
    public static Agency_Contact__c agency_contact = new Agency_Contact__c();
    public static ProductTypes__c product_types = new ProductTypes__c();
    // 经销商活动周报导入 update by vivek start
    public static ProductTypes__c product_types1 = new ProductTypes__c();
    public static ProductTypes__c product_types2 = new ProductTypes__c();
    public static ProductTypes__c product_types3 = new ProductTypes__c();
    public static FieldClassification__c fcftion = new FieldClassification__c();
    public static FieldClassification__c fcftion1 = new FieldClassification__c();
    public static product2 pro2 = new product2();
 
    // 经销商活动周报导入 update by vivek end
    public static Agency_Opportunity__c agency_opportunity = new Agency_Opportunity__c();
    public static OlympusCalendar__c olympus_calendar = new OlympusCalendar__c();
    public static String report_id;
    public static String report_header_id;
 
    public RetrospectiveWeeklyReportControllerTest() {
    }
 
    @TestSetup
    static void makeData(){
        List<String> strList= new List<String>();
        strList.add('Agency_Contact__c');
        strList.add('Contact');
        TestDataUtility.CreatePIPolicyConfigurations(strList);
    }
 
    private static void testinit(){
        account1.Name = 'test1医院';
        account1.RecordTypeId = '01210000000QemG';
        insert account1;
        
        account2.Name = 'test1经销商';
        account2.RecordTypeId = '01210000000Qem1';
        insert account2;
        
        // 取引先責任者
        contact1.AccountId = account1.Id;
        contact1.FirstName = '責任者';
        contact1.LastName = 'test1医院';
        insert contact1;
        
        contact2.AccountId = account2.Id;
        contact2.FirstName = '責任者';
        contact2.LastName = 'test1经销商';
        insert contact2;
 
        Profile p = [select Id from Profile where Name = '901_经销商活动系统'];
        user.ProfileId = p.Id;
        user.ContactId = contact2.Id;
        user.FirstName = 'ユーザー';
        user.LastName = 'テスト';
        user.Email = 'test_user@example.com';
        user.emailencodingkey='UTF-8';
        user.languagelocalekey='zh_CN';
        user.localesidkey='ja_JP';
        user.timezonesidkey='Asia/Shanghai';
        user.Username = 'test_user@example.com';
        user.Alias = 'テユ';
        user.CommunityNickname = 'テストユーザー';
        insert user;
 
        // 代理店医院
        agency_hospital_link.Name = 'test1代理店医院';
        agency_hospital_link.Hospital__c = account1.Id;
        agency_hospital_link.Agency__c = account2.Id;
        agency_hospital_link.OwnerId = user.Id;
        agency_hospital_link.Agency_Campaign_Obj__c = true;
        insert agency_hospital_link;
        
        // 先生
        agency_contact.Name = 'test1医院先生';
        agency_contact.Doctor_Division1__c = '院长';
        agency_contact.Type__c = '医生';
        agency_contact.Agency_Hospital__c = agency_hospital_link.Id;
        agency_contact.OwnerId = user.Id;
        // 经销商活动周报导入 update by vivek start
        // agency_contact.Hospital_ID18__c = agency_hospital_link.Id;
        // 经销商活动周报导入 update by vivek end
        insert agency_contact;
        
         // 製品区分
         product_types.Name = '製品区分1';
         product_types.OwnerId = user.Id;
         product_types.Department_Cateogy__c = 'GI;BF;ET;GYN;OTH;URO;GS;ENT';
         insert product_types;
 
         // 经销商活动周报导入 update by vivek start
         product_types1.OwnerId = user.Id;
         product_types1.Department_Cateogy__c = 'GI;BF;ET;GYN;OTH;URO;GS;ENT';
         product_types1.Name = '170系统';
         product_types1.OPD_Flg__c = true;
         insert product_types1;
 
         product_types2.OwnerId = user.Id;
         product_types2.Department_Cateogy__c = 'GI;BF;ET;GYN;OTH;URO;GS;ENT';
         product_types2.Name = 'EUS系统';
         product_types2.SIS_Flg__c = true;
         insert product_types2;
 
         product_types3.OwnerId = user.Id;
         product_types3.Department_Cateogy__c = 'GI;BF;ET;GYN;OTH;URO;GS;ENT';
         product_types3.Name = 'CHF胆道镜';
         insert product_types3;
 
         fcftion.ProductCcategory__c='波科';
         fcftion.ET_ENG_classification__c = 'ET';
         fcftion.ProductClassification__c = 'ERCP';
         insert fcftion;
 
         fcftion1.ProductCcategory__c='波科';
         fcftion1.ET_ENG_classification__c = 'ENG';
         fcftion1.ProductClassification__c = 'ERCP';
         insert fcftion1;
 
         // 经销商活动周报导入 update by vivek end
 
         // 引合
         agency_opportunity.RecordTypeId = [select Id,DeveloperName from RecordType where IsActive = true and SobjectType = 'Agency_Opportunity__c' and DeveloperName = 'Opportunity'].Id;
         agency_opportunity.Name = '引合1';
         agency_opportunity.Hospital_Target__c = account1.Id;
         agency_opportunity.Agency__c = account2.Id;
         agency_opportunity.Agency_Hospital__c = agency_hospital_link.Id;
         agency_opportunity.StageName__c = '还没申请预算';
         agency_opportunity.OwnerId = user.Id;
         agency_opportunity.NewOpportunity_Agency_Apply_Status__c = '批准';
         insert agency_opportunity;
         
         // オリンパスカレンダー
         olympus_calendar.Date__c = Date.valueOf('2017-04-10');
         olympus_calendar.OwnerId = user.Id;
         insert olympus_calendar;
         ProductTypes__c producttyoe = WeeklyReportCmp.getProduct(product_types.Id);
    }
    @isTest
    private static void test01() {
        // List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
        // if (rectCo.size() == 0) {
        //     return;
        // }
        // myAccount2 = new Account(Name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id,Product_Limit_Date__c = 'Test01|2|4,Test02|3|5');
        // insert myAccount2;
        // Profile prof = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
        // // Profile prof = [select Id from Profile where Name ='System Administrator'];
        // core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount2.id);
        // insert core;
        // myUser_Test = New User(ContactId = core.id,UserPro_Type__c = 'ET',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;
        //testinit();
        User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
        system.runAs(thisUser){
            // testinit();
            // myAccount2 = new Account(Name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id,Product_Limit_Date__c = 'Test01|2|4,Test02|3|5');
            // insert myAccount2;
            // Profile prof = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
            // // Profile prof = [select Id from Profile where Name ='System Administrator'];
            // core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount2.id);
            // insert core;
            // myUser_Test = New User(ContactId = core.id,UserPro_Type__c = 'ET',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;
            // TestDataUtility.CreatePIPolicyConfiguration('Agency_Contact__c');
            // String sobjectType = 'Agency_Contact__c';
            //Test.startTest();
            List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
            if (rectCo.size() == 0) {
                return;
            }
            myAccount2 = new Account(Name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id,Product_Limit_Date__c = 'Test01|2|4,Test02|3|5');
            insert myAccount2;
            Profile prof = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
            // Profile prof = [select Id from Profile where Name ='System Administrator'];
            core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount2.id);
            insert core;
            myUser_Test = New User(ContactId = core.id,UserPro_Type__c = 'ET',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;
            testinit();
            //TestDataUtility.CreatePIPolicyConfiguration('Agency_Contact__c');
            String sobjectType = 'Agency_Contact__c';
            Test.startTest();
            PIHelper.getPIIntegrationInfo(sobjectType);
            RetrospectiveWeeklyReportController retrospectiveWeeklyReportobj = new RetrospectiveWeeklyReportController();
            retrospectiveWeeklyReportobj.UserDoin();
            retrospectiveWeeklyReportobj.setalldata();
            RetrospectiveWeeklyReportController.selectdoctor3c();
            RetrospectiveWeeklyReportController.getalldata();
            RetrospectiveWeeklyReportController.getProduct(product_types.Id);
            String ids =String.valueof(contact1.Id);
            String key =ids+':20170410';
            String aa =RetrospectiveWeeklyReportController.createReportHeader('','2017-04-10',ids,key);
            RetrospectiveWeeklyReportController.makeReportHeader('','2017-04-10',ids,key);
            //RetrospectiveWeeklyReportController.getHospitalList('');
            RetrospectiveWeeklyReportController.getUseProduct1('a','ERCP');
            RetrospectiveWeeklyReportController.getDoctorList(String.valueof(agency_hospital_link.Id));
            String bb=RetrospectiveWeeklyReportController.saveAgencyReport('消化科',2,false,2,String.valueof(contact1.Id),'','','','','','',aa,String.valueof(agency_hospital_link.Id),'',String.valueof(agency_contact.Id),'2017-04-10','','','','','','','','2017-04-10');
            // Agency_Report__c agency_report=RetrospectiveWeeklyReportController.makeAgencyReport('消化科',2,false,2,String.valueof(contact1.Id),'','','','','','',String.valueof(aa.Id),String.valueof(agency_hospital_link.Id),'',String.valueof(agency_contact.Id),'2017-04-10','','','','','','','','2017-04-10');
            // insert agency_report;
            RetrospectiveWeeklyReportController.editAgencyReport(bb,'消化科',2,false,2,String.valueof(contact1.Id),'','','','','','',aa,String.valueof(agency_hospital_link.Id),'',String.valueof(agency_contact.Id),'2017-04-10','','','','2017-04-10');
            RetrospectiveWeeklyReportController.selectOpportunityByIdAndHospitalLinkId('','');
            RetrospectiveWeeklyReportController.getReports('2017-04-10','2017-04-10');
            RetrospectiveWeeklyReportController.getReportsById('');
            RetrospectiveWeeklyReportController.getReportsByDate('2017-04-10','2017-04-10');
            retrospectiveWeeklyReportobj.selectMAgencyPerson();
            String ccc ='活动日,医院,科室,经销商人员,工作记录,医院人员,产品分类(第三分类),使用产品1(产品型号),使用产品2,使用产品3,效果/进度,科室同类耗材月使用量,术士分类,已采用其他品牌,其他品牌产品类别,产品用量,工作标记\r\n,,,广津 经销商,,临床信息(使用量)收集,,,,,,,,,,,\r\n2022/5/16,大连市妇女儿童医疗中心,泌尿外科,曹 玉鹏,科室会,医生,ERCP,B5-2Q,BML-110A,MAJ-403,不认可,1,导丝,库克,,,需要\r\n,,,广津 经销商,,,,,,,,,,,,,\r\n';
            RetrospectiveWeeklyReportController.processDataAWSId(ccc);
            RetrospectiveWeeklyReportController.getAwsurl('Agency_Contact__c');
            List<String> fields =new List<String>();
            RetrospectiveWeeklyReportController.processData(ccc,'',fields);
            RetrospectiveWeeklyReportController.GetDepartment_Cateogy('呼吸科');
            RetrospectiveWeeklyReportController.GetDepartment_Cateogy('耳鼻喉科');
            RetrospectiveWeeklyReportController.GetDepartment_Cateogy('ET耗材');
            RetrospectiveWeeklyReportController.GetDepartment_Cateogy('消化科');
            RetrospectiveWeeklyReportController.GetDepartment_Cateogy('普外科');
            RetrospectiveWeeklyReportController.GetDepartment_Cateogy('妇科');
            RetrospectiveWeeklyReportController.GetDepartment_Cateogy('其他');
            RetrospectiveWeeklyReportController.GetDepartment_Cateogy('泌尿科');
            List<Map<String,String>> prolist = new List<Map<String,String>>();
            Map<String,String> x = new Map<String,String>();
            x.put('label','aaa');
            prolist.add(x);
            RetrospectiveWeeklyReportController.ifTrueProduct(prolist,'aaa');
            RetrospectiveWeeklyReportController.newlyBuild(String.valueof(agency_hospital_link.Id),'test1医院先生','','');
            RetrospectiveWeeklyReportController.selectPurposeTypes('SIS');
            RetrospectiveWeeklyReportController.selectProductClassificationc('ERCP');
            RetrospectiveWeeklyReportController.selectProductCcategory();
            RetrospectiveWeeklyReportController.selectProductCcategory01('波科');
            Test.stopTest();
        }
    }
    @isTest
    private static void test02() {
        // List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
        // if (rectCo.size() == 0) {
        //     return;
        // }
        // myAccount2 = new Account(Name='Testaccount003',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id,Product_Limit_Date__c = 'Test01|2|4,Test02|3|5');
        // insert myAccount2;
        // Profile prof = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
        // // Profile prof = [select Id from Profile where Name ='System Administrator'];
        // core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount2.id);
        // insert core;
        // myUser_Test = New User(ContactId = core.id,UserPro_Type__c = 'ENG',Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser3', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
        // insert myUser_Test;
        //testinit();
        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;
            }
            myAccount2 = new Account(Name='Testaccount003',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id,Product_Limit_Date__c = 'Test01|2|4,Test02|3|5');
            insert myAccount2;
            Profile prof = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
            // Profile prof = [select Id from Profile where Name ='System Administrator'];
            core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount2.id);
            insert core;
            myUser_Test = New User(ContactId = core.id,UserPro_Type__c = 'ENG',Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser3', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
            insert myUser_Test;
            testinit();
            //TestDataUtility.CreatePIPolicyConfiguration('Agency_Contact__c');
            String sobjectType = 'Agency_Contact__c';
            Test.startTest();
            PIHelper.getPIIntegrationInfo(sobjectType);
            RetrospectiveWeeklyReportController retrospectiveWeeklyReportobj = new RetrospectiveWeeklyReportController();
            retrospectiveWeeklyReportobj.UserDoin();
            retrospectiveWeeklyReportobj.setalldata();
            RetrospectiveWeeklyReportController.selectdoctor3c();
            RetrospectiveWeeklyReportController.getalldata();
            RetrospectiveWeeklyReportController.getProduct(product_types.Id);
            String ids =String.valueof(contact1.Id);
            String key =ids+':20170410';
            String aa =RetrospectiveWeeklyReportController.createReportHeader('','2017-04-10',ids,key);
            String bb=RetrospectiveWeeklyReportController.saveAgencyReport('消化科',2,false,2,String.valueof(contact1.Id),'','','','','','',aa,String.valueof(agency_hospital_link.Id),'',String.valueof(agency_contact.Id),'2017-04-10','','','','','','','','2017-04-10');
            // Agency_Report__c agency_report=RetrospectiveWeeklyReportController.makeAgencyReport('消化科',2,false,2,String.valueof(contact1.Id),'','','','','','',String.valueof(aa.Id),String.valueof(agency_hospital_link.Id),'',String.valueof(agency_contact.Id),'2017-04-10','','','','','','','','2017-04-10');
            // insert agency_report;
            RetrospectiveWeeklyReportController.editAgencyReport(bb,'消化科',2,false,2,String.valueof(contact1.Id),'','','','','','',aa,String.valueof(agency_hospital_link.Id),'',String.valueof(agency_contact.Id),'2017-04-10','','','','2017-04-10');
            RetrospectiveWeeklyReportController.selectOpportunityByIdAndHospitalLinkId('','');
            RetrospectiveWeeklyReportController.getReports('2017-04-10','2017-04-10');
            RetrospectiveWeeklyReportController.getReportsById('');
            RetrospectiveWeeklyReportController.getReportsByDate('2017-04-10','2017-04-10');
            retrospectiveWeeklyReportobj.selectMAgencyPerson();
            String ccc ='活动日,医院,科室,经销商人员,工作记录,医院人员,产品分类(第三分类),使用产品1(产品型号),使用产品2,使用产品3,效果/进度,科室同类耗材月使用量,术士分类,已采用其他品牌,其他品牌产品类别,产品用量,工作标记\r\n2022/5/16,大连市妇女儿童医疗中心,泌尿外科,曹 玉鹏,临床信息(使用量)收集,医生,ERCP,B5-2Q,B5-2Q,B5-2Q,不认可,1,导丝,库克,,,需要\r\n2022/5/16,大连市妇女儿童医疗中心,神经内二科,广津 经销商,院内入院申请,周正强,aaa,B5-2Q,BML-110A,MAJ-403,申请驳回,1,取石气囊,波科,,,需要\r\n';
            RetrospectiveWeeklyReportController.processDataAWSId(ccc);
            RetrospectiveWeeklyReportController.getAwsurl('Agency_Contact__c');
            List<String> fields =new List<String>();
            RetrospectiveWeeklyReportController.processData(ccc,'',fields);
            List<Map<String,String>> prolist = new List<Map<String,String>>();
            Map<String,String> x = new Map<String,String>();
            x.put('label','aaa');
            prolist.add(x);
            RetrospectiveWeeklyReportController.ifTrueProduct(prolist,'aaa');
            RetrospectiveWeeklyReportController.newlyBuild(String.valueof(agency_hospital_link.Id),'test1医院先生','','');
            RetrospectiveWeeklyReportController.selectPurposeTypes('SIS');
            RetrospectiveWeeklyReportController.selectProductClassificationc('ERCP');
            RetrospectiveWeeklyReportController.selectProductCcategory();
            RetrospectiveWeeklyReportController.selectProductCcategory01('波科');
            //RetrospectiveWeeklyReportController.saveAgencyContact('波科','波科','波科','波科','波科','波科',String.valueof(agency_hospital_link.Id),'波科');
            RetrospectiveWeeklyReportController.saveAgencyContact('波科','波科','波科',String.valueof(agency_hospital_link.Id),'波科');     //zhj 新方案改造,参数Encrypt去掉 2023-01-28
            RetrospectiveWeeklyReportController.deleteAgencyReport('121');
            RetrospectiveWeeklyReportController.GetProductClassification('121');
            Test.stopTest();
        }
    }
 
    // @isTest
    // private static void test03() {
    //     RetrospectiveWeeklyReportController.improveTestRate();
    // }
 
    @isTest
    private static void searchAgencyDataId() {
        User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
        system.runAs(thisUser){
            testinit();
            Test.startTest();
            RetrospectiveWeeklyReportController.searchAgencyDataId(agency_hospital_link.Id);
            Test.stopTest();
        }
    }
    
}