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
@isTest
private class UpdateTenderInformationBatch2Test {
    static testMethod void testMethod1() {
        StaticParameter.EscapeOpportunityBefUpdTrigger = true;
        ControllerUtil.EscapeNFM001Trigger = true;
        ControllerUtil.EscapeMaintenanceContractAfterUpdateTrigger = true;
        StaticParameter.EscapeNFM001Trigger = true;
        StaticParameter.EscapeNFM001AgencyContractTrigger = true;
        StaticParameter.EscapeNFM001AgencyContractTrigger2 = true;
        StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true;
        RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_GI', 'Department_BF') order by DeveloperName desc];
        
        Account acc1 = new Account();
        acc1.RecordTypeId = rectCo.Id;
        acc1.Name = 'HP test1';
        insert acc1;
 
        Account acc2 = new Account();
        acc2.RecordTypeId = rectCo.Id;
        acc2.Name = 'HP test2';
        insert acc2;
 
 
        List<Account> dept = [select Id, Name from Account where ParentId = :acc1.Id and Department_Class_Label__c IN ('消化科', '呼吸科') order by Department_Class_Label__c];
        
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
        depart1.Name         = '*';
        depart1.Department_Name__c  = 'Gastoro Intestin Test';
        depart1.ParentId            = dept[0].Id;
        depart1.Department_Class__c = dept[0].Id;
        depart1.Hospital__c         = acc1.Id;
        
        List<Account> dept2 = [select Id, Name from Account where ParentId = :acc2.Id and Department_Class_Label__c IN ('消化科', '呼吸科') order by Department_Class_Label__c];
        
        Account depart3 = new Account();
        depart3.RecordTypeId = rectDpt[0].Id;
        depart3.Name         = '*';
        depart3.Department_Name__c  = 'Gastoro Intestin Test';
        depart3.ParentId            = dept2[0].Id;
        depart3.Department_Class__c = dept2[0].Id;
        depart3.Hospital__c         = acc2.Id;
        insert depart3;
 
 
        RecordType oppVND = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity'];
 
        System.Test.StartTest();
        //招标项目
        Tender_information__c te1 = new Tender_information__c();
        te1.Name = 'TestZhaoBiao1';
        te1.IsReactionOpp__c = true;
        insert te1;
 
        Tender_information__c te2 = new Tender_information__c();
        te2.Name = 'TestZhaoBiao2';
        te2.IsReactionOpp__c = true;
        insert te2;
 
        Tender_information__c te3 = new Tender_information__c();
        te3.Name = 'TestZhaoBiao3';
        te3.IsReactionOpp__c = true;
        insert te3;
 
        StaticParameter.EscapeOppandStaTrigger = true;
 
        Opportunity opp1 = new Opportunity(
           Name = 'test opp1',
           StageName = '引合',
           CurrencyIsoCode = 'USD',
           CloseDate = Date.today(),
           AccountId = depart1.Id,
           RecordTypeId = oppVND.Id,
           Closing_Bid_Date__c = Date.today().addDays(-5),
           Hospital__c = acc1.Id,
           Competitor__c = 'A',
           Bidding_Project_Name_Bid__c = te1.Id
        );
        Opportunity opp2 = new Opportunity(
           Name = 'test opp2',
           StageName = '引合',
           CurrencyIsoCode = 'USD',
           CloseDate = Date.today(),
           AccountId = depart3.Id,
           RecordTypeId = oppVND.Id,
           Closing_Bid_Date__c = Date.today().addDays(-5),
           Hospital__c = acc2.Id,
           Competitor__c = 'B',
           Bidding_Project_Name_Bid__c = te1.Id
        );
        insert new Opportunity[] {opp1, opp2};
 
        Tender_Opportunity_Link__c tolc1 = new Tender_Opportunity_Link__c();
        tolc1.Tender_information__c=te1.Id;
        tolc1.Opportunity__c=opp1.Id;
        tolc1.IsRelated__c=false;
        insert tolc1;
        Tender_Opportunity_Link__c tolc2 = new Tender_Opportunity_Link__c();
        tolc2.Tender_information__c=te2.Id;
        tolc2.Opportunity__c=opp1.Id;
        tolc2.IsRelated__c=false;
        insert tolc2;
        Tender_Opportunity_Link__c tolc3 = new Tender_Opportunity_Link__c();
        tolc3.Tender_information__c=te3.Id;
        tolc3.Opportunity__c=opp1.Id;
        tolc3.IsRelated__c=false;    
        insert tolc3;    
        Tender_Opportunity_Link__c tolc4 = new Tender_Opportunity_Link__c();
        tolc4.Tender_information__c=te1.Id;
        tolc4.Opportunity__c=opp2.Id;
        tolc4.IsRelated__c=false;    
        insert tolc4;                                                      
 
        Id execBTId = Database.executeBatch(new UpdateTenderInformationBatch2());
        System.Test.StopTest();
 
    }
}