高章伟
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
@isTest
public class OpportunityServiceTest {
        static String a = '';
 
    @isTest public static void testMethod1(){
        // 省
        Address_Level__c al = new Address_Level__c();
        al.Name = '東京';
        al.Level1_Code__c = 'CN-99';
        al.Level1_Sys_No__c = '999999';
        insert al;
        // 市
        Address_Level2__c al2 = new Address_Level2__c();
        al2.Level1_Code__c = 'CN-99';
        al2.Level1_Sys_No__c = '999999';
        al2.Level1_Name__c = '東京';
        al2.Name = '渋谷区';
        al2.Level2_Code__c = 'CN-9999';
        al2.Level2_Sys_No__c = '9999999';
        al2.Address_Level__c = al.id;
        insert al2;
 
        // 病院を作る
        Account hospital = new Account();
        hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
        hospital.Name = 'test hospital';
        hospital.Is_Active__c = '有効';
        hospital.Attribute_Type__c = '卫生部';
        hospital.Speciality_Type__c = '综合医院';
        hospital.Grade__c = '一级';
        hospital.OCM_Category__c = 'SLTV';
        hospital.Is_Medical__c = '医疗机构';
        hospital.State_Master__c = al.id;
        hospital.City_Master__c = al2.id;
        hospital.Town__c = '东京';
        insert hospital;
 
        // 病院を作る
        Account hospital2 = new Account();
        hospital2.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
        hospital2.Name = 'test hospital2';
        hospital2.Is_Active__c = '有効';
        hospital2.Attribute_Type__c = '卫生部';
        hospital2.Speciality_Type__c = '综合医院';
        hospital2.Grade__c = '一级';
        hospital2.OCM_Category__c = 'SLTV';
        hospital2.Is_Medical__c = '医疗机构';
        hospital2.State_Master__c = al.id;
        hospital2.City_Master__c = al2.id;
        hospital2.Town__c = '东京';
        insert hospital2;
 
        // 病院を作る
        Account hospital3 = new Account();
        hospital3.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
        hospital3.Name = 'test hospital3';
        hospital3.Is_Active__c = '有効';
        hospital3.Attribute_Type__c = '卫生部';
        hospital3.Speciality_Type__c = '综合医院';
        hospital3.Grade__c = '一级';
        hospital3.OCM_Category__c = 'SLTV';
        hospital3.Is_Medical__c = '医疗机构';
        hospital3.State_Master__c = al.id;
        hospital3.City_Master__c = al2.id;
        hospital3.Town__c = '东京';
        insert hospital3;
 
        System.Test.startTest();
 
        // 病院を作る
        Account hospital4 = new Account();
        hospital4.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
        hospital4.Name = 'test hospital4';
        hospital4.Is_Active__c = '有効';
        hospital4.Attribute_Type__c = '卫生部';
        hospital4.Speciality_Type__c = '综合医院';
        hospital4.Grade__c = '一级';
        hospital4.OCM_Category__c = 'SLTV';
        hospital4.Is_Medical__c = '医疗机构';
        hospital4.State_Master__c = al.id;
        hospital4.City_Master__c = al2.id;
        hospital4.Town__c = '东京';
        insert hospital4;
 
        // 病院を作る
        // Account hospital5 = new Account();
        // hospital5.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
        // hospital5.Name = 'test hospital5';
        // hospital5.Is_Active__c = '有効';
        // hospital5.Attribute_Type__c = '卫生部';
        // hospital5.Speciality_Type__c = '综合医院';
        // hospital5.Grade__c = '一级';
        // hospital5.OCM_Category__c = 'SLTV';
        // hospital5.Is_Medical__c = '医疗机构';
        // hospital5.State_Master__c = al.id;
        // hospital5.City_Master__c = al2.id;
        // hospital5.Town__c = '东京';
        // insert hospital5;
 
        //创建招投标项目
        Tender_information__c Ten = new Tender_information__c();
        Ten.Name = '123456';
        Ten.ProjectId__c = '38_99df2844cf784982acdc61d00d7a7dbb';
 
        insert Ten;
 
        // 创建询价
        Oly_TriggerHandler.bypass('PowerBIBaseHandler');
        Opportunity opp = new Opportunity();
        opp.Name = 'aiueo';
        opp.StageName = 'contact';
        opp.CloseDate = Date.today();
        opp.AccountId = hospital.Id;
        opp.Opportunity_No__c = 'test001Opp';
        opp.Hospital__c = hospital.Id;
        //opp.Department_Class__r.RecordTypeId = '01210000000QezZAAS';
        insert opp;
        List<Opportunity> olist = new List<Opportunity>();
        olist.add(opp);
 
        // 创建询价
        Oly_TriggerHandler.bypass('PowerBIBaseHandler');
        Opportunity opp2 = new Opportunity();
        opp2.Name = 'aiueo2';
        opp2.StageName = 'contact';
        opp2.CloseDate = Date.today();
        opp2.AccountId = hospital2.Id;
        opp2.Opportunity_No__c = 'test002Opp';
        opp2.Hospital__c = hospital2.Id;
        //opp2.Department_Class__r.RecordTypeId = '01210000000QezZAAS';
        insert opp2;
        olist.add(opp2);
        
        // 创建询价
        Oly_TriggerHandler.bypass('PowerBIBaseHandler');
        Opportunity opp3 = new Opportunity();
        opp3.Name = 'aiueo3';
        opp3.StageName = 'contact';
        opp3.CloseDate = Date.today();
        opp3.AccountId = hospital3.Id;
        opp3.Opportunity_No__c = 'test003Opp';
        opp3.Hospital__c = hospital3.Id;
        //opp3.Department_Class__r.RecordTypeId = '01210000000QemLAAS';
        insert opp3;
        olist.add(opp3);
        
        // 创建询价
        Oly_TriggerHandler.bypass('PowerBIBaseHandler');
        Opportunity opp4 = new Opportunity();
        opp4.Name = 'aiueo4';
        opp4.StageName = 'contact';
        opp4.CloseDate = Date.today();
        opp4.AccountId = hospital4.Id;
        opp4.Opportunity_No__c = 'test004Opp';
        opp4.Hospital__c = hospital4.Id;
        //opp4.Department_Class__r.RecordTypeId = '01210000000QemLAAS';
        insert opp4;
        olist.add(opp4);
        
        // 创建询价
        // Oly_TriggerHandler.bypass('PowerBIBaseHandler');
        // Opportunity opp5 = new Opportunity();
        // opp5.Name = 'aiueo5';
        // opp5.StageName = 'contact';
        // opp5.CloseDate = Date.today();
        // opp5.AccountId = hospital5.Id;
        // opp5.Opportunity_No__c = 'test005Opp';
        // opp5.Hospital__c = hospital5.Id;
        // insert opp5;
        // olist.add(opp5);
        System.Test.stopTest();
 
        String[] ids = new String[10];
        ids.Add('0011000000V97G7AAJ');
 
        OpportunityService.GetNormalProductDataSearch('test001Opp',hospital.Id,hospital.Id,'',ids, '01210000000QezZAAS');
        OpportunityService.GetNormalProductDataNotSave('',ids, '01210000000QemLAAS;01210000000QezZAAS');
        // 保存 
        String jsonStr =  JSON.serialize(olist);
        OpportunityService.SaveData('',jsonStr,Ten.Id,true);
        // 查询已保存  只有一个 当前招投标
        OpportunityService.GetNormalProductDataIsSave(Ten.Id);
    }
}