高章伟
2022-02-24 2aa8da8af66aa8ae00f25831aed6bb0364176e7b
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
@isTest
private class OpportunityBefInsUpdTriggerTest {
 
    private static Product2 product = null;
    private static Id pricebookId = ControllerUtil.getStandardPricebook().Id;
 
    static {
        product = new Product2( Name='テスト商品');
        insert product;
    }
 
    private static PricebookEntry buildPB( String input) {
        PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=product.Id);
        entry.UnitPrice = 0;
        entry.IsActive = true;
        entry.UseStandardPrice = false;
        entry.CurrencyIsoCode = input;
        insert entry;
        return entry;
    }
 
    private static Opportunity buildOppInstance( String inputTrade, String CurrencyIsoCode) {
        Opportunity target = new Opportunity( Name='aiueo', StageName='引合', CloseDate=Date.today());
        target.Trade__c = inputTrade;
        target.CurrencyIsoCode = CurrencyIsoCode;
        return target;
    }
 
    private static void insertOppLineItem( Opportunity input, Pricebookentry entry) {
        OpportunityLineItem target = new OpportunityLineItem();
        target.OpportunityId = input.Id;
        target.Quantity = 1;
        target.UnitPrice = 100;
        target.PricebookEntryId = entry.Id;
        insert target;
    }
 
    static testMethod void test10() {
        PricebookEntry entry = buildPB( 'USD');
    
        List<Opportunity> opps = new List<Opportunity>();
        opps.add( buildOppInstance( '外貿', 'USD'));
        insert opps;
    
        insertOppLineItem( opps[0], entry);
    }
 
 
    static testMethod void test01() {
        
        // 商談を複数レコード insertしてみます
        List<Opportunity> opps = new List<Opportunity>();
 
        // テストデータ生成
        opps.add( buildOppInstance( '外貿', 'USD'));
        opps.add( buildOppInstance( '外貿', 'CNY'));
        opps.add( buildOppInstance( '内貿', 'USD'));
        opps.add( buildOppInstance( '内貿', 'CNY'));
        insert opps;
        
        // 結果発表
        List<Opportunity> selected = [SElECT Id, Name, Trade__c, CurrencyIsoCode FROM Opportunity WHERE Id IN :opps];
        System.assertEquals( '外貿', selected[0].Trade__c);
        System.assertEquals( 'USD', selected[0].CurrencyIsoCode);
        System.assertEquals( '外貿', selected[1].Trade__c);
        System.assertEquals( 'USD', selected[1].CurrencyIsoCode);
        System.assertEquals( '内貿', selected[2].Trade__c);
        System.assertEquals( 'CNY', selected[2].CurrencyIsoCode);
        System.assertEquals( '内貿', selected[3].Trade__c);
        System.assertEquals( 'CNY', selected[3].CurrencyIsoCode);
        
        // データを更新してみる
        selected[0].Trade__c = '内貿';
        selected[0].CurrencyIsoCode = 'USD';        
        selected[1].Trade__c = '内貿';
        selected[1].CurrencyIsoCode = 'CNY';
        selected[2].Trade__c = '外貿';
        selected[2].CurrencyIsoCode = 'USD';        
        selected[3].Trade__c = '外貿';
        selected[3].CurrencyIsoCode = 'CNY';
        update selected;
        
        // 結果発表
        selected = [SElECT Id, Name, Trade__c, CurrencyIsoCode FROM Opportunity WHERE Id IN :opps];
        System.assertEquals( '内貿', selected[0].Trade__c);
        System.assertEquals( 'CNY', selected[0].CurrencyIsoCode);
        System.assertEquals( '内貿', selected[1].Trade__c);
        System.assertEquals( 'CNY', selected[1].CurrencyIsoCode);
        System.assertEquals( '外貿', selected[2].Trade__c);
        System.assertEquals( 'USD', selected[2].CurrencyIsoCode);
        System.assertEquals( '外貿', selected[3].Trade__c);
        System.assertEquals( 'USD', selected[3].CurrencyIsoCode);
 
        // 子レコードを作ってみる
        PricebookEntry entryUSD = buildPB( 'USD');
        PricebookEntry entryCNY = buildPB( 'CNY');
        insertOppLineItem( selected[0], entryCNY);
        insertOppLineItem( selected[1], entryCNY);
        insertOppLineItem( selected[2], entryUSD);
        insertOppLineItem( selected[3], entryUSD);
        
        // データを更新してみる
        selected = [SElECT Id, Name, Trade__c, CurrencyIsoCode FROM Opportunity WHERE Id IN :opps];
        selected[0].Trade__c = '外貿';
        selected[0].CurrencyIsoCode = 'CNY';        
        selected[1].Trade__c = '外貿';
//        selected[1].CurrencyIsoCode = 'USD';
        selected[2].Trade__c = '内貿';
//        selected[2].CurrencyIsoCode = 'CNY';        
        selected[3].Trade__c = '内貿';
        selected[3].CurrencyIsoCode = 'USD';
        update selected;
        
    }
 
    static testMethod void testOwner() {
        Opportunity opp = new Opportunity(Name='testOwner', StageName='contact', CurrencyIsoCode='CNY', CloseDate=Date.today());
        insert opp;
        opp = [select id, ownerid, Owner_System__c from opportunity where id = :opp.id];
        system.assertequals(opp.ownerid, opp.Owner_System__c);
        opp.Owner_System__c = null;
        update opp;
        opp = [select id, ownerid, Owner_System__c from opportunity where id = :opp.id];
        system.assertequals(opp.ownerid, opp.Owner_System__c);
    }
    
    static testMethod void testCity() {
        RecordType rt1 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        RecordType rt2 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        RecordType rt3 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 呼吸科'];
        
        Address_Level__c al1 = new Address_Level__c(
            Name = '四川省'
        );
        insert al1;
        Address_Level2__c al2 = new Address_Level2__c(
            Name = '成都市',
            Address_Level__c = al1.Id
        );
        insert al2;
        
        Account company = new Account();
        company.Name = 'aiueo病院';
        company.RecordTypeId = rt1.Id;
        company.State_Master__c = al1.Id;
        company.City_Master__c = al2.Id;
        insert company;
        
        Account sct = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company.Id and RecordTypeId = :rt2.Id];
        
        Account depart = new Account();
        depart.RecordTypeId = rt3.Id;
        depart.Name = '*';
        depart.Department_Name__c = 'aiueo診療科';
        depart.ParentId = sct.Id;
        depart.Department_Class__c = sct.Id;
        depart.Hospital__c = company.Id;
        insert depart;
        
        Opportunity opp = new Opportunity(Name = 'aiueo商談', StageName = 'contact', CloseDate=Date.today(), AccountId = depart.Id);
        insert opp;
        
        opp = [select City__c, City_Text__c from Opportunity where Id = :opp.Id];
        System.assertequals('成都市', opp.City_Text__c);
        System.assertequals('成都市', opp.City__c);
    }
 
    static testMethod void testShippingDate() {
        Opportunity opp = new Opportunity(Name='testOwner', StageName='contact', CurrencyIsoCode='CNY', CloseDate=Date.today(),Shipping_Finished_Day__c =Date.today().addDays(-2));
        insert opp;
        opp = [select id, ownerid, Owner_System__c,ShippingDate_For_Report__c,StageName,Shipping_Finished_Day__c from opportunity where id = :opp.id];
        System.assertEquals('contact',opp.StageName);
        System.assertEquals(Date.today(),opp.ShippingDate_For_Report__c);
        System.assertEquals(Date.today().addDays(-2),opp.Shipping_Finished_Day__c);
        opp.StageName = '出荷';
        opp.CloseDate = Date.today().addDays(+1);
        update opp;
        opp = [select id, ownerid, Owner_System__c,ShippingDate_For_Report__c,StageName,Shipping_Finished_Day__c from opportunity where id = :opp.id];
        System.assertEquals('出荷',opp.StageName);
        System.assertEquals(Date.today().addDays(-2),opp.Shipping_Finished_Day__c);
        System.assertEquals(Date.today().addDays(-2),opp.ShippingDate_For_Report__c);
    }
 
    static testMethod void testQuote() {
        Opportunity opp = new Opportunity(Name='testOwner', StageName='contact', CurrencyIsoCode='CNY', CloseDate=Date.today(),Shipping_Finished_Day__c =Date.today().addDays(-2));
        insert opp;
        Quote q = new Quote(
            Name = 'quote',
            OpportunityId = opp.Id
        );
        insert q;
        opp = [select id, ownerid, Owner_System__c,ShippingDate_For_Report__c,StageName,Shipping_Finished_Day__c from opportunity where id = :opp.id];
        System.assertEquals('contact',opp.StageName);
        System.assertEquals(Date.today(),opp.ShippingDate_For_Report__c);
        System.assertEquals(Date.today().addDays(-2),opp.Shipping_Finished_Day__c);
        opp.StageName = '引合';
        opp.CloseDate = Date.today().addDays(+1);
        opp.Estimation_Id__c = q.id;
        opp.Estimation_Decision__c = true;
        opp.SAP_Send_OK__c = true;
        opp.Authorized_DB_No__c = '11111';
        opp.Contract_DB_SalesDept_complite_day__c = Date.today();
        opp.NotesApprovedNo__c = '11111';
        update opp;
        opp = [select id, ownerid, Owner_System__c,ShippingDate_For_Report__c,StageName,Shipping_Finished_Day__c from opportunity where id = :opp.id];
        System.assertEquals('引合',opp.StageName);
        System.assertEquals(Date.today().addDays(-2),opp.Shipping_Finished_Day__c);
        //System.assertEquals(Date.today().addDays(-2),opp.ShippingDate_For_Report__c);
    }
 
    static testMethod void testConsumable() {
        RecordType rt1 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '契約'];
        RecordType rt2 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
        //RecordType rt3 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 呼吸科'];
        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', 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;
        Address_Level__c al1 = new Address_Level__c(
            Name = '四川省'
        );
        insert al1;
        Address_Level2__c al2 = new Address_Level2__c(
            Name = '成都市',
            Address_Level__c = al1.Id
        );
        insert al2;
 
        Account company = new Account(name='aiueo经销商',RecordTypeId = rt2.Id,State_Master__c = al1.Id,City_Master__c = al2.Id);
        insert company;
        Account contact = new Account(name='aiueo契约',RecordTypeId = rt1.Id,SpecialDealerName__c = 'aiueo经销商',ParentId = company.Id,Agent_Ref__c = company.Id,Delete_Flag__c = false,Contract_Department_Class__c = 'ET',Contract_Decide_Start_Date__c = Date.today().addDays(-1),Contract_Decide_End_Date__c = Date.today().addDays(1));
        insert contact;
        contact.ownerId = hpOwner.Id;
        update contact;
 
        contact = [select ownerId from Account WHERE Id = :contact.Id];
        System.assertequals(contact.ownerId, hpOwner.Id);
 
        Opportunity opp = new Opportunity(Name = 'aiueo商談', StageName = 'contact', CloseDate=Date.today(), AccountId = contact.Id);
        insert opp;
 
        opp = [select ownerid,Account.RecordType.DeveloperName, City__c, City_Text__c,Custmor_pic_ID__c from Opportunity where Id = :opp.Id];
        System.assertequals(hpOwner.Id, opp.Custmor_pic_ID__c);
        System.assertequals(hpOwner.Id, opp.ownerid);
    }
 
    static testMethod void testConsumableupdate() {
        RecordType rt1 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '契約'];
        RecordType rt2 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
        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', 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;
        Address_Level__c al1 = new Address_Level__c(
            Name = '四川省'
        );
        insert al1;
        Address_Level2__c al2 = new Address_Level2__c(
            Name = '成都市',
            Address_Level__c = al1.Id
        );
        insert al2;
 
        Account company = new Account(name='aiueo经销商',RecordTypeId = rt2.Id,State_Master__c = al1.Id,City_Master__c = al2.Id);
        insert company;
        Account contact = new Account(name='aiueo契约',RecordTypeId = rt1.Id,SpecialDealerName__c = 'aiueo经销商',ParentId = company.Id,Agent_Ref__c = company.Id,Delete_Flag__c = false,Contract_Department_Class__c = 'ET',Contract_Decide_Start_Date__c = Date.today().addDays(-1),Contract_Decide_End_Date__c = Date.today().addDays(1));
        insert contact;
 
        System.Test.startTest();
        Opportunity opp = new Opportunity(Name = 'aiueo商談', StageName = 'contact', CloseDate=Date.today(), AccountId = contact.Id);
        insert opp;
        contact.ownerId = hpOwner.Id;
        update contact;
 
        contact = [select ownerId from Account WHERE Id = :contact.Id];
        System.assertequals(hpOwner.Id, contact.ownerId);
        opp.Name = 'aiueo商談1';
        update opp;
 
        opp = [select ownerid,Account.RecordType.DeveloperName, City__c, City_Text__c,Custmor_pic_ID__c from Opportunity where Id = :opp.Id];
        System.assertequals(hpOwner.Id, opp.Custmor_pic_ID__c);
        System.assertequals(hpOwner.Id, opp.ownerid);
        System.Test.StopTest();
    }
 
    static testMethod void testHosptil() {
        RecordType rt1 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        RecordType rt2 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        RecordType rt3 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 呼吸科'];
        
        Address_Level__c al1 = new Address_Level__c(
            Name = '四川省'
        );
        insert al1;
        Address_Level2__c al2 = new Address_Level2__c(
            Name = '成都市',
            Address_Level__c = al1.Id
        );
        insert al2;
        
        Account company = new Account();
        company.Name = 'aiueo病院';
        company.RecordTypeId = rt1.Id;
        company.State_Master__c = al1.Id;
        company.City_Master__c = al2.Id;
        insert company;
        
        Account sct = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company.Id and RecordTypeId = :rt2.Id];
        
        Account depart = new Account();
        depart.RecordTypeId = rt3.Id;
        depart.Name = '*';
        depart.Department_Name__c = 'aiueo診療科';
        depart.ParentId = sct.Id;
        depart.Department_Class__c = sct.Id;
        depart.Hospital__c = company.Id;
        insert depart;
        
        Opportunity opp = new Opportunity(Name = 'aiueo商談', StageName = 'contact', CloseDate=Date.today(), AccountId = depart.Id,Hospital__c = company.Id);
        insert opp;
        
        opp = [select ownerid,owner_not_automatically_update__c, City__c, City_Text__c,Custmor_pic_ID__c from Opportunity where Id = :opp.Id];
        System.assertequals('00510000005sEEM', opp.ownerid);
        System.assertequals(false, opp.owner_not_automatically_update__c);
        System.assertequals('00510000005sEEM', opp.Custmor_pic_ID__c);
        System.assertequals('成都市', opp.City_Text__c);
        System.assertequals('成都市', opp.City__c);
    }
 
    //付晓坤 2021-1-15 测试:询价借用备品提醒修改客户将影响回库  Start
    static testMethod void testOpportunityUpdate(){
         // Opportunity opIds = [Select Id From Opportunity];
        //Rental_Apply__c ra = [Select Id,Follow_UP_Opp__c From Rental_Apply__c Where Status__c != '取消' and Follow_UP_Opp__c IN :opIds];
        
    //询价的创建
        //1、记录类型
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
        if (rectDpt.size() == 0) {
            return;
        }
 
        //2.创建医院
        Account company = new Account();
        company.RecordTypeId = rectCo[0].Id;
        company.Name         = 'NFM007TestCompany';
        upsert company;
        //3.创建科室
        Account section = new Account();
        section.RecordTypeId = rectSct[0].Id;
        section.Name         = '*';
        section.Department_Class_Label__c = '消化科';
        section.ParentId                  = company.Id;
        section.Hospital_Department_Class__c = company.Id;
        upsert section;
        //4.创建部门
        Account depart = new Account();
        depart.RecordTypeId = rectDpt[0].Id;
        depart.Name         = '*';
        depart.Department_Name__c  = 'NFM007TestDepart';
        depart.ParentId            = section.Id;
        depart.Department_Class__c = section.Id;
        depart.Hospital__c         = company.Id;
        upsert depart;
 
        //5.创建询价(业务机会)
        Opportunity opp = new Opportunity();
        opp.AccountId           = depart.Id;//客户名
        opp.Department_Class__c = section.Id;//战略科室分类
        opp.Hospital__c         = company.Id;//医院
        opp.SAP_Send_OK__c      = false;//SAP上传(WIN)
        opp.Name                = 'GZ-SP-NFM007_1';//业务机会名
        opp.Trade__c            = '内貿';//内贸/外贸
        opp.StageName           = '引合';//阶段
        opp.CloseDate           = Date.today();// 结束日期
        opp.Stock_apply_status__c = '申请中';//备货申请状态
        insert opp;
 
        // 创建备品
        //1.取OPD的Id
        OPDPlan__c  opd = new OPDPlan__c();
        opd.Account_Laboratory__c = depart.Id;
        opd.OPDPlan_ImplementDate__c = Date.today()+60;
        opd.NoOpp_Reason__c = 'HCP对应';
        opd.Status__c = '计划中';
        insert opd;
        //2.添加一条状态为取消的备品
        /*Rental_Apply__c ra = new Rental_Apply__c();
        ra.Follow_UP_Opp__c = opp.Id;
        ra.Status__c = '取消';
        ra.Cancel_Reason__c = '主动取消';
        ra.Name = 'aaa';
        ra.Person_In_Charge__c= UserInfo.getUserId();
        ra.applyUser__c = UserInfo.getUserId();
        ra.Demo_purpose1__c = '产品试用';
        ra.demo_purpose2__c = '试用(无询价)';
        ra.Product_category__c = 'GI';
        ra.Demo_purpose_text__c = '111';
        ra.Request_shipping_day__c = date.newinstance(2022, 11, 30);
        ra.Loaner_received_staff__c = 'www';
        ra.direct_send__c = '上门自提';
        ra.pickup_time__c = date.newinstance(2022, 11, 30);
        ra.Loaner_received_staff_phone__c = '12312312312';
        ra.OPDPlan__c = opd.Id;
        ra.Account__c           = depart.Id;
        ra.Strategic_dept__c = section.Id;
        ra.Hospital__c         = company.Id;//医院
        insert ra;*/
 
        //2.1 添加一条状态不为取消的备品
        /*Rental_Apply__c ra1 = new Rental_Apply__c();
        ra1.Follow_UP_Opp__c = opp.Id;
        ra1.Status__c = '草案中';
        ra1.Name = 'aaa';
        ra1.Person_In_Charge__c= UserInfo.getUserId();
        ra1.applyUser__c = UserInfo.getUserId();
        ra1.Demo_purpose1__c = '产品试用';
        ra1.demo_purpose2__c = '试用(无询价)';
        ra1.Product_category__c = 'GI';
        ra1.Demo_purpose_text__c = '111';
        ra1.Request_shipping_day__c = Date.today();
        ra1.Loaner_received_staff__c = 'www';
        ra1.direct_send__c = '上门自提';
        ra1.pickup_time__c = Date.today();
        ra1.Loaner_received_staff_phone__c = '12312312312';
        ra1.OPDPlan__c = opd.Id;
        ra1.Account__c           = depart.Id;
        ra1.Strategic_dept__c = section.Id;
        ra1.Hospital__c         = company.Id;//医院
        insert ra1;*/
        //更新询价客户名
        //1、记录类型
        List<RecordType> rectSct1 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 泌尿科'];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt1 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 泌尿科'];
        if (rectDpt.size() == 0) {
            return;
        }
        //2.创建科室
        Account section1 = new Account();
        section1.RecordTypeId = rectSct1[0].Id;
        section1.Name         = 'aaa';
        section1.Department_Class_Label__c = '泌尿科';
        section1.ParentId                  = company.Id;
        section1.Hospital_Department_Class__c = company.Id;
        upsert section1;
        //3.创建部门
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt1[0].Id;
        depart1.Name         = 'aaa';
        depart1.Department_Name__c  = 'NFM006TestDepart';
        depart1.ParentId            = section1.Id;
        depart1.Department_Class__c = section1.Id;
        depart1.Hospital__c         = company.Id;
        upsert depart1;
        //4.修改客户
        opp.AccountId           = depart1.Id;//客户名
        update opp;
    //测试
        List<Rental_Apply__c> raList = [Select Id,Follow_UP_Opp__c From Rental_Apply__c Where Status__c != '取消' and Follow_UP_Opp__c = :opp.Id];
        
        System.assertEquals(0, raList.size());
 
 
    
}
    
    //付晓坤 2021-1-15 测试:询价借用备品提醒修改客户将影响回库  End
}