高章伟
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
@isTest
private class OPDPlanHandlerTest
{
      static testMethod void updaue() {
        //OPDPlanHandler.test();
        // 2020-10-30  mzy   add  start
        // 病院を作る
        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;
        
        // 戦略科室を得る
        List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
        
        // 診療科を作る
        Account dep = new Account();
        dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
        dep.Name = 'test dep';
        dep.ParentId = strategicDep[0].Id;
        dep.Department_Class__c = strategicDep[0].Id;
        dep.Hospital__c = hospital.Id;
        insert dep;
 
        // 2020-10-30  mzy   add  end
 
        Event insertTarget = new Event();
        
        ApexPages.StandardController sc = new ApexPages.standardController( insertTarget);
        SimpleEventRegisterController target = new SimpleEventRegisterController( sc);
        
        target.targetEvent.Subject = 'test';   //主题
        target.targetEvent.StartDateTime = Datetime.now().addDays(1);   //开始日期
        target.targetEvent.DurationInMinutes = 60;          //持续时间
        target.targetEvent.Activity_Type2__c = '病院';   //拜访区分
        target.targetEvent.Activity_PurposeFSE__c = '客户培训';   //拜访目的
        target.targetEvent.OPDPlan_Flag__c = true ;   //OPD计划
        target.targetEvent.Location = dep.Name;  //科室
        target.init();
        //2020/10/29  MZY  start
        Map<String,String> tempMap = new Map<String,String>();
        tempMap.put('GI-290镜子', '1');
        tempMap.put('EU-ME2', '2');
        tempMap.put('OTV-S300', '4');
        target.planProducts = tempMap;   //计划出借备品
        target.targetEvent.noOpp_Reason__c = 'HCP对应';  //无询价申请理由
        //2020/10/29  MZY  end
        target.init();
       // target.saveAndNew();
        //2020/10/30  mzy  start
        insert target.targetEvent;
       // target.saveOPDPlan(target.targetEvent);
        //2020/10/30  mzy   end
        /**
        List<OPDPlan__c> opdList = [select id,OPDPlan_ImplementDate__c from OPDPlan__c];
 
        System.assertEquals(1, opdList.size());
 
        List<Event> eveist = [select id,StartDateTime from Event where Subject = 'test'];
        System.assertEquals(1, eveist.size());
        opdList[0].OPDPlan_ImplementDate__c = opdList[0].OPDPlan_ImplementDate__c.addDays(3);
        update opdList;
        eveist = [select id,StartDateTime from Event where Subject = 'test'];
        System.assertEquals(2, eveist.size());
        
        OPDPlan__c oPDPlan1 = new OPDPlan__c();
        oPDPlan1.ThisMonthPlan__c = 1;
        oPDPlan1.Status__c = '草案中';
        oPDPlan1.OPD_Customers_Target_Last__c=null;
        oPDPlan1.OPDPlan_ImplementDate__c = Date.today();
        oPDPlan1.NoOpp_Reason__c = 'HCP对应';
        insert oPDPlan1;
        oPDPlan1.OPDPlan_ImplementDate__c = oPDPlan1.OPDPlan_ImplementDate__c.addDays(3);
        update oPDPlan1;
        **/
 
    }
 
    //static testMethod void cancle() {
 
    //    Event insertTarget = new Event();
        
    //    ApexPages.StandardController sc = new ApexPages.standardController( insertTarget);
    //    SimpleEventRegisterController target = new SimpleEventRegisterController( sc);
        
    //    target.targetEvent.Subject = 'test';
    //    target.targetEvent.StartDateTime = Datetime.now().addDays(1);
    //    target.targetEvent.DurationInMinutes = 10;
    //    target.targetEvent.Activity_Type2__c = '販売店 ';
    //    target.targetEvent.Activity_PurposeFSE__c = '其他';
    //    target.targetEvent.OPDPlan_Flag__c = true ;
    //    target.init();
    //    target.saveAndNew();
    //    List<OPDPlan__c> opdList = [select id,Status__c from OPDPlan__c];
 
    //    System.assertEquals(1, opdList.size());
 
    //    if(opdList.size() == 1){
    //      opdList[0].Status__c = '取消';
    //      update opdList;
    //    }
    //    List<Event> eveist = [select id,StartDateTime from Event];
    //    System.assertEquals(0, eveist.size());
 
    //}
 
     // 2020/10/29  mzy  推广经理赋值  SFDC-BUF6LN   add  start
 static testMethod void updateMngTest() {
    // OPDPlanHandler.test();
      OPDPlan__c OPDPlan01 = new OPDPlan__c();
      OPDPlan01.Status__c = '提交';
      OPDPlan01.NoOpp_Reason__c= 'HCP对应';
      insert OPDPlan01;
 
      OPDPlan__c OPDPlan02 = new OPDPlan__c();
      OPDPlan02.Status__c = '草案中';
      OPDPlan02.NoOpp_Reason__c= 'HCP对应';
      insert OPDPlan02;
/**
      OPDPlan__c OPDPlan03 = new OPDPlan__c();
      OPDPlan03.id = OPDPlan02.id;
      OPDPlan03.Status__c = '提交';
      update  OPDPlan03;
      **/
 }
    // 2020/1029  mzy  推广经理赋值  SFDC-BUF6LN   add   end
//start SWAG-BSC5WP 20201106 you
  private static integer FIELDMAX = 200;
   static testMethod void setupTestData() {
 
      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;
 
 
        
 
        //根据opd计划实施日期 算出本财年
        Date dateToday = Date.today();
        Integer year = dateToday.year();
        Integer month = dateToday.month();
        if (month < 4) {
            year -= 1;
        }
        String selectedTab = String.valueOf(year - 1867 - 1 + 'P'); 
        String selectedTab1 = String.valueOf(year - 1867 + 'P'); //今财年
 
        //客户-目标客户 默认让opd计划和客户-目标客户的财年相同
        Account_Number_of_target__c anot = new Account_Number_of_target__c();
        anot.Account__c = dc.Id;
        anot.Account_HP__c = hp.Id;
        anot.OCM_Period__c = selectedTab;
        anot.Target_amount_170_190__c =36597;
        anot.OPD_amount_290MiroBF__c =1;
        anot.OPD_amount_290MiroGI_CF__c =1;
        insert anot;
 
        Account_Number_of_target__c anot1 = new Account_Number_of_target__c();
        anot1.Account__c = dc.Id;
        anot1.Account_HP__c = hp.Id;
        anot1.OCM_Period__c = selectedTab1;
        anot1.Target_amount_170_190__c =36597;
        anot1.OPD_CV290__c =1;
        anot1.OPD_290Miro__c =1;
        anot1.OPD_TB__c =1;
        anot1.Rental_Cnt_CV290__c =1;
        anot1.Rental_Cnt_TB__c =1;
        anot1.Target_amount_CV290__c =1;
        anot1.Target_amount_TB__c  =1;//Sales_target_TB__c
        anot1.Opp_cnt_290MiroGI__c =1;
        anot1.Opp_cnt_290MiroGI_CF__c =1;
        anot1.Asset_Cnt_290MiroBF__c =1;
        anot1.OPD_amount_290MiroBF__c =1;
        anot1.OPD_amount_290MiroGI_CF__c =1;
 
        insert anot1;
        
       System.Test.StartTest();
        OPDPlan__c oPDPlan0 = new OPDPlan__c();
        oPDPlan0.Status__c = '草案中';
        oPDPlan0.OPDType__c = '学会';
        oPDPlan0.if_OPDTarget__c=1;
        oPDPlan0.if_HaveSalestarget__c =1;
        oPDPlan0.Cnt_OPD_ThisYear__c=1;
        oPDPlan0.Cnt_OPD_LastYear__c=1;
        oPDPlan0.if_HaveOpportunity__c=1;
        oPDPlan0.if_HaveEquipment__c =1;
        oPDPlan0.Cnt_Rentals__c =1;
        oPDPlan0.PlanProdDetail__c ='CV-290*4; GI-290镜子*1; GI-290镜子CF*1;';
        oPDPlan0.Account_Laboratory__c =dpt.Id;
        oPDPlan0.OPDPlan_ImplementDate__c = Date.today();
        oPDPlan0.OPDPlan_ImplementDate_temp__c = Date.today();
        oPDPlan0.NoOpp_Reason__c = 'HCP对应';
       // oPDPlan0.OPD_Customers_Target_Last__c=anot.id;
       // oPDPlan0.OPD_Customers_Target__c =anot1.id;
        insert oPDPlan0;
        //opd计划1
        OPDPlan__c oPDPlan1 = new OPDPlan__c();
        oPDPlan1.ThisMonthPlan__c = 1;
        oPDPlan1.Status__c = '草案中';
        oPDPlan1.Account_Laboratory__c =dpt.Id;
        oPDPlan1.OPD_Customers_Target_Last__c=null;
        oPDPlan1.OPDPlan_ImplementDate__c = Date.today().addDays(3);
        oPDPlan1.NoOpp_Reason__c = 'HCP对应';
        insert oPDPlan1;
        oPDPlan0.Account_Laboratory__c =dpt.Id;
        oPDPlan0.OPDPlan_ImplementDate__c = oPDPlan1.OPDPlan_ImplementDate__c.addDays(40);
        update oPDPlan0;
 
        OPDPlan__c oPDPlan3 = new OPDPlan__c();
        oPDPlan3.ThisMonthPlan__c = 1;
        oPDPlan3.Status__c = '计划中';
        oPDPlan3.Account_Laboratory__c =dpt.Id;
        oPDPlan3.OPD_Customers_Target_Last__c=null;
        oPDPlan3.OPDPlan_ImplementDate__c = Date.today().addDays(3);
        oPDPlan3.NoOpp_Reason__c = 'HCP对应';
        insert oPDPlan3;
 
        /*OPDPlan__c oPDPlan4 = new OPDPlan__c();
        oPDPlan4.ThisMonthPlan__c = 1;
        oPDPlan4.Status__c = '计划中';
        oPDPlan4.Account_Laboratory__c =dpt.Id;
        oPDPlan4.OPD_Customers_Target_Last__c=null;
        oPDPlan4.OPDPlan_ImplementDate__c = Date.today().addDays(3);
        oPDPlan4.NoOpp_Reason__c = 'HCP对应';
        oPDPlan4.OriginalOpdPlanApplication__c = oPDPlan3.Id;
        insert oPDPlan4;*/
 
 
        
        OPDPlan__c oPDPlan2 = new OPDPlan__c();
        oPDPlan2.Status__c = '草案中';
        oPDPlan2.Account_Laboratory__c =dpt.Id;
        //oPDPlan2.OPDPlan_ImplementDate__c = Date.today();
        oPDPlan2.NoOpp_Reason__c = 'HCP对应';
        oPDPlan2.if_OPDTarget__c=1;
        oPDPlan2.if_HaveSalestarget__c =1;
        oPDPlan2.Cnt_OPD_ThisYear__c=1;
        oPDPlan2.Cnt_OPD_LastYear__c=1;
        oPDPlan2.if_HaveOpportunity__c=1;
        oPDPlan2.if_HaveEquipment__c =1;
        oPDPlan2.Cnt_Rentals__c =1;
        oPDPlan2.OPD_Customers_Target_Last__c=anot.id;
        oPDPlan2.OPD_Customers_Target__c =anot1.id;
        oPDPlan2.PlanProdDetail__c ='CV-290*4; GI-290镜子*1; GI-290镜子CF*1;';
        // oPDPlan2.OriginalOpdPlan__c = oPDPlan3.Id;
        insert oPDPlan2;
        oPDPlan2.Status__c = '审批中'; 
        
        update oPDPlan2;
 
        //2021-06-26   mzy  add 
 
        OPDPlan__c oPDPlan4 = new OPDPlan__c();
        oPDPlan4.Status__c = '草案中';
        oPDPlan4.Account_Laboratory__c =dpt.Id;
        oPDPlan4.OPDPlan_ImplementDate__c = Date.today();
        oPDPlan4.NoOpp_Reason__c = 'HCP对应';
        oPDPlan4.if_OPDTarget__c=1;
        oPDPlan4.if_HaveSalestarget__c =1;
        oPDPlan4.Cnt_OPD_ThisYear__c=1;
        oPDPlan4.Cnt_OPD_LastYear__c=1;
        oPDPlan4.if_HaveOpportunity__c=1;
        oPDPlan4.if_HaveEquipment__c =1;
        oPDPlan4.Cnt_Rentals__c =1;
        oPDPlan4.OPD_Customers_Target_Last__c=anot.id;
        oPDPlan4.OPD_Customers_Target__c =anot1.id;
        oPDPlan4.PlanProdDetail__c ='CV-290*4; GI-290镜子*1; GI-290镜子CF*1;';
        insert oPDPlan4;
 
        //取消
        CancelPostponePlan__c tempCancelPostponePlan = new  CancelPostponePlan__c();
        tempCancelPostponePlan.Status__c = '取消成功';
        tempCancelPostponePlan.CancelOPDPlan__c = oPDPlan4.Id;
        tempCancelPostponePlan.RecordTypeId = '01210000000gQyL';
        tempCancelPostponePlan.cancelReasonCombobox__c  = '无备品';
        insert tempCancelPostponePlan;
 
 
        oPDPlan4 = [select id,DelayCancel_Reason__c,Status__c from OPDPlan__c where id = :oPDPlan4.Id];
        //System.assertEquals('',oPDPlan4.Status__c);
        //System.assertEquals('',oPDPlan4.DelayCancel_Reason__c);
 
 
        OPDPlan__c oPDPlan5 = new OPDPlan__c();
        oPDPlan5.Status__c = '草案中';
        oPDPlan5.Account_Laboratory__c =dpt.Id;
        oPDPlan5.OPDPlan_ImplementDate__c = Date.today();
        oPDPlan5.NoOpp_Reason__c = 'HCP对应';
        oPDPlan5.if_OPDTarget__c=1;
        oPDPlan5.if_HaveSalestarget__c =1;
        oPDPlan5.Cnt_OPD_ThisYear__c=1;
        oPDPlan5.Cnt_OPD_LastYear__c=1;
        oPDPlan5.if_HaveOpportunity__c=1;
        oPDPlan5.if_HaveEquipment__c =1;
        oPDPlan5.Cnt_Rentals__c =1;
        oPDPlan5.OPD_Customers_Target_Last__c=anot.id;
        oPDPlan5.OPD_Customers_Target__c =anot1.id;
        oPDPlan5.PlanProdDetail__c ='CV-290*4; GI-290镜子*1; GI-290镜子CF*1;';
        oPDPlan5.OriginalOpdPlan__c = oPDPlan4.Id;
        insert oPDPlan5;
 
 
 
        OPDPlan__c oPDPlan6 = new OPDPlan__c();
        oPDPlan6.Status__c = '计划中';
        oPDPlan6.Account_Laboratory__c =dpt.Id;
        oPDPlan6.OPDPlan_ImplementDate__c = Date.today().addDays(3);
        oPDPlan6.NoOpp_Reason__c = 'HCP对应';
        oPDPlan6.if_OPDTarget__c=1;
        oPDPlan6.if_HaveSalestarget__c =1;
        oPDPlan6.Cnt_OPD_ThisYear__c=1;
        oPDPlan6.Cnt_OPD_LastYear__c=1;
        oPDPlan6.if_HaveOpportunity__c=1;
        oPDPlan6.if_HaveEquipment__c =1;
        oPDPlan6.Cnt_Rentals__c =1;
        oPDPlan6.OPD_Customers_Target_Last__c=anot.id;
        oPDPlan6.OPD_Customers_Target__c =anot1.id;
        oPDPlan6.PlanProdDetail__c ='CV-290*4; GI-290镜子*1; GI-290镜子CF*1;';
        oPDPlan6.OriginalOpdPlanApplication__c = oPDPlan3.Id;
        oPDPlan6.RentalReson__c = '追加配套';
        insert oPDPlan6;
 
        //oPDPlan6 = [select Id,Status__c from OPDPlan__c where id = :opdPlan6.Id];
        //System.assertEquals('',oPDPlan6.Status__c);
        //System.assertEquals('',oPDPlan6.DelayCancel_Reason__c);
 
 
        //2021-06-29   mzy  add 
 
 
        System.Test.StopTest(); 
      }  
      //end SWAG-BSC5WP 20201106 you
 
      //2021-06-26 mzy start
       static testMethod void updaueOpd() {
        // 病院を作る
        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;
        
        // 戦略科室を得る
        List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
        
        // 診療科を作る
        Account dep = new Account();
        dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
        dep.Name = 'test dep';
        dep.ParentId = strategicDep[0].Id;
        dep.Department_Class__c = strategicDep[0].Id;
        dep.Hospital__c = hospital.Id;
        insert dep;
 
        RecordType mainTaskrecId = [select Id from RecordType where IsActive = true and SobjectType = 'task__c' and Name = 'OPD'];
        task__c task = new task__c();
        task.RecordTypeId = mainTaskrecId.id; 
        task.taskDifferent__c = '被动任务';
        task.taskStatus__c = '01 分配';
        task.Activity_Date__c = Date.newInstance(2021, 7, 17);
        task.account__c =  dep.Id;
        insert task;
        OPDPlan__c oPDPlan0 = new OPDPlan__c();
        oPDPlan0.Status__c = '审批中';
        oPDPlan0.OPDType__c = '事件';
        oPDPlan0.PlanProdDetail__c ='CV-290*4; GI-290镜子*1; GI-290镜子CF*1;';
        oPDPlan0.Account_Laboratory__c =dep.Id;
        oPDPlan0.OPDPlan_ImplementDate__c = Date.today();
        oPDPlan0.OPDPlan_ImplementDate_temp__c = Date.today();
        oPDPlan0.NoOpp_Reason__c = 'HCP对应';
        oPDPlan0.RentalReson__c = '无法进入手术室';
        oPDPlan0.AttachmentCertificate__c = '0001.png';
        oPDPlan0.Task_ID__c = task.Id;
        insert oPDPlan0;
 
        Event insertTarget = new Event();
        insertTarget.Subject = 'test00';
        insertTarget.StartDateTime =  Datetime.now().adddays(2);
        insertTarget.DurationInMinutes = 60;
        insertTarget.Location = 'testLocation';
        insertTarget.whatid__c = dep.Id;
        insertTarget.Activity_Type2__c = '病院';
        insertTarget.OPDPlan_Flag__c = true ;
        insertTarget.Opd_Plan__c = oPDPlan0.Id;
        insertTarget.Task_ID__c = task.Id;
        insertTarget.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;';
        insert insertTarget;
        
        OPDPlan__C opd = [SELECT Id,OPDPlan_ImplementDate__c  FROM OPDPlan__C WHERE id =: oPDPlan0.Id];
 
        opd.OPDPlan_ImplementDate__c = opd.OPDPlan_ImplementDate__c.addDays(5);
 
        update opd;
 
        opd.OPDPlan_ImplementDate__c = opd.OPDPlan_ImplementDate__c.addDays(-5);
 
        update opd;
 
 
       }
      //2021-06-26 mzy  end
 
}