高章伟
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
@isTest
private class BeforeUpsertReportHandlerTest {
    static testMethod void testMethod1() {
         RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        
         // 病院を作る
        Account hospital = new Account();
        hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
        hospital.Name = 'test hospital';
        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;
   
        Opportunity opp1 = new Opportunity(
            Name='testOpp1',
            StageName='引合',
            CloseDate=Date.today(),
            AccountId=dep.Id,
            Competitor__c ='A',
            Click_Close_Date__c = null,
            RecordType = rectOpp,
            Hospital__c = dep.Id
            );
        insert opp1;
 
        OPDPlan__c oPDPlan0 = new OPDPlan__c();
        oPDPlan0.Status__c = '草案中';
        oPDPlan0.OPDPlan_ImplementDate__c = Date.today().addDays(1);
        oPDPlan0.NoOpp_Reason__c = 'HCP对应';
        oPDPlan0.Related_Opportunity1_ID__c =opp1.id;
        oPDPlan0.Account_Laboratory__c =dep.Id;
        insert oPDPlan0;
        
 
        Report__c rep1 = new Report__c();
        rep1.Report_OPDPlan__c       = oPDPlan0.id;
        rep1.CurrencyIsoCode         = 'CNY';
        rep1.Status__c               = '';
        rep1.Purpose1__c             = 'OPD';
        rep1.Purpose2__c             = '引合追及活動';
 
        rep1.Reason__c               = '実施背景';
        rep1.Appeal_Point__c         = '実施目的・訴求点';
        rep1.Strategic_Department_Class__c = '1.消化科';
        rep1.Technical_Category1__c  = '消化道检查';
        rep1.Technical_Category2__c  = '普通胃镜检查';
        rep1.Patient_Status__c       = '患者状況';
        rep1.Operation_Process__c    = '手術プロセス';
        rep1.Operation_Task__c       = '手術上の課題';
        rep1.Product_Evaluation_Advantage__c = '製品評価利点';
        rep1.Product_Evaluation_Faults__c = '製品評価欠点';
        rep1.OPD_Summarize__c        = 'OPD実施総括';
        rep1.Activity_Plan__c        = '今後の活動計画';
        rep1.Opportunity_Situation__c = '引合無';
        rep1.OPD_ProductCategory1__c ='3D System';
        rep1.OPD_ProductCategory2__c ='OR Imaging Products';
        rep1.Hospital_Reference__c   = hospital.Id;
        rep1.Department_Class_Ref__c = strategicDep[0].Id;
        rep1.Hospital_Department__c  = dep.Id;
        
        rep1.Status__c = '草案中';
        rep1.Date__c= Date.today().addDays(-1);
        
        insert rep1;
    }   
    static testMethod void testMethod2() {
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        // 病院を作る
            Account hospital = new Account();
            hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
            hospital.Name = 'test hospital';
            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;
        Opportunity opp1 = new Opportunity(
            Name='testOpp1',
            StageName='引合',
            CloseDate=Date.today(),
            AccountId=dep.Id,
            Competitor__c ='A',
            Click_Close_Date__c = null,
            RecordType = rectOpp
            );
        insert opp1;
        
        OPDPlan__c oPDPlan0 = new OPDPlan__c();
        oPDPlan0.Status__c = '草案中';
        oPDPlan0.OPDPlan_ImplementDate__c = Date.today().addDays(1);
        oPDPlan0.NoOpp_Reason__c = 'HCP对应';
        insert oPDPlan0;
 
        // 产品
        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,ProductCode='N2032430');
        insert pro5; 
         // 保有设备
        Asset asset = new Asset(Asset_Owner__c = 'Olympus');
        asset.RecordTypeId = System.Label.Asset_RecordType;
        asset.SerialNumber = 'asset';
        asset.Name = 'asset';
        asset.AccountId = dep.Id;
        asset.Department_Class__c = strategicDep[0].Id;
        asset.Hospital__c = hospital.Id;
        asset.Product2Id = pro5.Id;
        asset.Quantity = 1;
        asset.Status = '有库存';
        asset.Manage_type__c = '个体管理';
        asset.Internal_asset_location__c = '北京 备品中心';
        asset.Loaner_accsessary__c = true;
        asset.Delete_Flag__c = false;
        asset.Freeze_sign__c = false;
        asset.Out_of_wh__c = 0;
        insert asset;
 
        Rental_Apply__c raObj1 = new Rental_Apply__c();
        raObj1.Rental_Start_Date__c = Date.today().addDays(1);
        raObj1.Request_return_day__c=Date.today().addDays(5);
        raObj1.DataMigration_Flag__c = true;
        raObj1.demo_purpose2__c = 'ceshi';
        raObj1.Follow_UP_Opp__c = opp1.Id;
        insert raObj1;
        
 
        Rental_Apply__c raObj = new Rental_Apply__c();
        raObj.Rental_Start_Date__c = Date.today().addDays(1);
        raObj.Request_return_day__c=Date.today().addDays(5);
        raObj.DataMigration_Flag__c = true;
        raObj.demo_purpose2__c = '试用(有询价)';
        raObj.Old_Rental_Apply__c = raObj1.id;
        raObj.Follow_UP_Opp__c = opp1.Id;
        raObj.Status__c = '草案中';
        raObj.OPDPlan__c = oPDPlan0.id;
        insert raObj;
        // 借出备品配套一览
        Rental_Apply_Equipment_Set__c raesObj = new Rental_Apply_Equipment_Set__c();
        raesObj.Rental_Apply__c = raObj.Id;
        raesObj.Cancel_Select__c = false;
        raesObj.Shipment_request_time__c = Date.toDay();
        raesObj.Rental_Start_Date__c = Date.toDay();
        raesObj.Rental_End_Date__c = Date.toDay();
        raesObj.IndexFromUniqueKey__c = 1;
        raesObj.UniqueKey__c = '1::1';
        raesObj.DataMigration_Flag__c =true;
        insert raesObj;
         // 借出备品配套一览明细
        Rental_Apply_Equipment_Set_Detail__c raesdObj1 = new Rental_Apply_Equipment_Set_Detail__c();
        raesdObj1.Rental_Apply__c = raObj.Id;
       // raesdObj1.Rental_Num__c = 1;
        raesdObj1.Queue_Number__c = null;
        raesdObj1.Is_Body__c = true;
        raesdObj1.IndexFromUniqueKey__c = 1;
        raesdObj1.UniqueKey__c = '1:'+ raesObj.Id +  ':1';
        raesdObj1.Salesdepartment_before__c = '1.华北营业本部';
        raesdObj1.Internal_asset_location_before__c = '北京 备品中心';
        raesdObj1.Product_category_text__c = 'GI';
        raesdObj1.Equipment_Type_text__c = '产品试用';
        raesdObj1.Rental_Apply_Equipment_Set__c = raesObj.Id;
        raesdObj1.Fixture_Model_No_text__c ='n05';
        raesdObj1.Asset__c = asset.Id;
        insert raesdObj1;
 
        raesObj.First_RAESD__c = raesdObj1.Id;
        update raesObj;
 
        
 
        Report__c rep1 = new Report__c();
        rep1.CurrencyIsoCode         = 'CNY';
       // rep1.RecordTypeId            = rectOPD[0].Id;
        rep1.Status__c               = '';
        rep1.Loaner_request_no1__c         = raObj.Id;
        rep1.Purpose1__c             = 'OPD';
        rep1.Purpose2__c             = '引合追及活動';        
        rep1.Reason__c               = '実施背景';
        rep1.Appeal_Point__c         = '実施目的・訴求点';
        rep1.Strategic_Department_Class__c = '1.消化科';
        rep1.Technical_Category1__c  = '消化道检查';
        rep1.Technical_Category2__c  = '普通胃镜检查';
        rep1.Patient_Status__c       = '患者状況';
        rep1.Operation_Process__c    = '手術プロセス';
        rep1.Operation_Task__c       = '手術上の課題';
        rep1.Product_Evaluation_Advantage__c = '製品評価利点';
        rep1.Product_Evaluation_Faults__c = '製品評価欠点';
        rep1.OPD_Summarize__c        = 'OPD実施総括';
        rep1.Activity_Plan__c        = '今後の活動計画';
        rep1.Opportunity_Situation__c = '引合無';
        rep1.OPD_ProductCategory1__c ='3D System';
        rep1.OPD_ProductCategory2__c ='OR Imaging Products';
        rep1.Hospital_Reference__c   = hospital.Id;
        rep1.Department_Class_Ref__c = strategicDep[0].Id;
        rep1.Hospital_Department__c  = dep.Id;
        
        rep1.Status__c = '草案中';
        rep1.Date__c= Date.today().addDays(-1);
        
        insert rep1;
        
        
        
    }
    
     static testMethod void testMethod3() {
      // 病院を作る
        Account hospital = new Account();
        hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
        hospital.Name = 'test hospital';
        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;
     
     
        Consum_Apply__c ca = new Consum_Apply__c();
        ca.DataMigration_Flag__c = true;
        insert ca;
        Consum_Apply_Equipment_Set__c caes = new Consum_Apply_Equipment_Set__c();
        caes.Consum_Apply__c = ca.Id;
        caes.Consum_Start_Date__c = Date.today().addDays(20);
        caes.DataMigration_Flag__c = true;
        insert caes;
        Consum_Apply_Equipment_Set_Detail__c caesd = new Consum_Apply_Equipment_Set_Detail__c();
        caesd.DataMigration_Flag__c = true;
        caesd.Consum_Apply__c = ca.Id;
        caesd.Consum_Apply_Equipment_Set__c = caes.Id;
        caesd.Consum_Start_Date__c = caes.Consum_Start_Date__c;
        caesd.Trial_User__c = '我';
        caesd.Follower_User__c = UserInfo.getUserId();
        insert caesd; // 草案中
     
      // 耗材备品配套一览
        Consum_Apply_Equipment_Set__c caesObj = new Consum_Apply_Equipment_Set__c();
        caesObj.Consum_Apply__c = ca.Id;
        caesObj.Cancel_Select__c = false;
        caesObj.Consum_Start_Date__c = Date.toDay().addDays(20);
        caesObj.IndexFromUniqueKey__c = 1;
        caesObj.UniqueKey__c = '1::1';
        caesObj.DataMigration_Flag__c =true;
        caesObj.Model_No__c ='n05';
        insert caesObj;
       
 
        // 产品
        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);
        insert pro5; 
 
       Report__c rep1 = new Report__c();
        rep1.CurrencyIsoCode         = 'CNY';
        rep1.Status__c               = '';
        rep1.Consum_Apply__c         = ca.Id;
        rep1.Technical_Category1__c  ='消化道检查';
        rep1.Technical_Category2__c  ='普通胃镜检查';
        rep1.Practitioner1_Part__c   ='主刀';
        rep1.Purpose1__c             ='SIS-ET';
        rep1.Purpose2__c             = '引合追及活動';        
        rep1.Reason__c               = '実施背景';
        rep1.Appeal_Point__c         = '実施目的・訴求点';
        rep1.Strategic_Department_Class__c = '1.消化科';
        rep1.Technical_Category1__c  = '消化道检查';
        rep1.Technical_Category2__c  = '普通胃镜检查';
        rep1.Patient_Status__c       = '患者状況';
        rep1.Operation_Process__c    = '手術プロセス';
        rep1.Operation_Task__c       = '手術上の課題';
        rep1.Product_Evaluation_Advantage__c = '製品評価利点';
        rep1.Product_Evaluation_Faults__c = '製品評価欠点';
        rep1.OPD_Summarize__c        = 'OPD実施総括';
        rep1.Activity_Plan__c        = '今後の活動計画';
        rep1.Opportunity_Situation__c = '引合無';
        rep1.Operation_From__c       =Date.today();
        rep1.Operation_To__c         =Date.today().addDays(2);
        rep1.sex__c                  ='男';
        rep1.Product_Evaluation_Advantage1__c  ='不起雾';
        rep1.Product_Evaluation_Faults1__c     ='起雾';
        rep1.This_OPD_Summarize__c      ='效果良好';
        rep1.Medical_History__c     ='家族';
        rep1.age__c                 ='66';
        rep1.OPD_ProductCategory1__c ='3D System';
        rep1.OPD_ProductCategory2__c ='OR Imaging Products';
        rep1.Hospital_Department__c  = dep.Id;
        rep1.Status__c = '草案中';
        rep1.Date__c= Date.today().addDays(-1);
        
        insert rep1;
        }
}