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
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
@isTest
private class QISReportControllerTest {
 
     static Maintenance_Contract__c createMaintenanceContract( Account hospital, Account strategicDep, Account dep) {
        Maintenance_Contract__c contract = new Maintenance_Contract__c();
        contract.Name = 'tect contract';
        contract.status__c ='契約';
        contract.Maintenance_Contract_No__c = 'Kami_Contract_No';
        contract.Contract_Conclusion_Date__c = Date.today();
        contract.Hospital__c = hospital.Id;
        contract.Department_Class__c = strategicDep.Id;
        contract.Department__c = dep.Id;
        contract.Contract_Start_Date__c = Date.today().addDays( -10);   // 10日前
        contract.Contract_End_Date__c = Date.today().addDays( 5);       // 5日後
        contract.SalesOfficeCode_selection__c = '北京RC';
        insert contract;
        return contract;
    }
    
    static Maintenance_Contract_Asset__c createMiddleTable( Asset asset, Maintenance_Contract__c contract) {
        // 中間テーブルを設ける
        Maintenance_Contract_Asset__c middleTable = new Maintenance_Contract_Asset__c();
        middleTable.Asset__c = asset.Id;
        middleTable.Maintenance_Contract__c = contract.id;
        insert middleTable;
        return middleTable;
    }
    @isTest
    public static void testMethod1() {
        Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
        //医院所有人
        User comOwner = new User(Dept__c='能量事业本部',Test_staff__c = true, LastName = 'com',  Alias = 'com', CommunityNickname = 'comOwner', Email = 'olympus_comowner@sunbridge.com', Username = 'olympus_comowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert comOwner;
        String RecordTypeId = Schema.SObjectType.QIS_Report__c.getRecordTypeInfosByDeveloperName().get('QISRecordType1').getRecordTypeId();
        System.debug(RecordTypeId);
        QIS_Report__c qis = new QIS_Report__c();
        qis.RecordTypeId = RecordTypeId;
        qis.Name = 'Test';
        qis.QIS_Status__c='OSH检测中';
        qis.OwnerId=comOwner.id;
        qis.CDS_date__c=Date.today();
        qis.OCSMAdministrativeReportDate__c=Date.today();
        qis.Aware_date__c=Date.today();
        qis.OCSMAdministrativeReportNumber__c='00510000001R56KAAS';
        qis.OCSMAdministrativeReportStatus__c='无需报告';
        qis.isAE_Profile__c='YES';
        qis.isPAE_Profile__c='YES';
        qis.next_action__c='无偿维修';
        // qis.QIS_SC_Report__c='a3w10000000U6frAAC';
        qis.IsSendQIS__c=false;
        insert qis;
        // Id qisssId = [SELECT  id FROM QIS_Report__c where Relation_With_The_Problem__c = '有可能'][0].id;
        Test.StartTest();
        QISReportController.initForQisUniversalFailureCodeButton(qis.id);
        QISReportController.sqlForPAE(qis.id);
        QISReportController.initForlexQISIntakeuniversalcodeButton(qis.id);
        QISReportController.sqlForPAE1(qis.id);
        QISReportController.initForOSHRecievedButton(qis.id);
        QISReportController.updateQis(qis.id);
        QISReportController.updateQis1(qis.id);
        QISReportController.initForQisAgreeButton(qis.id);
        QISReportController.updateQisForQisAgree(qis.id);
        QISReportController.initForRCCDScompleteButton(qis.id);
       
 
        Test.stopTest();
    }
 
    @isTest
    public static void testMethod1_1() {
        Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
        //医院所有人
        User comOwner = new User(Dept__c='能量事业本部',Test_staff__c = true, LastName = 'com',  Alias = 'com', CommunityNickname = 'comOwner', Email = 'olympus_comowner@sunbridge.com', Username = 'olympus_comowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert comOwner;
        String RecordTypeId = Schema.SObjectType.QIS_Report__c.getRecordTypeInfosByDeveloperName().get('QISRecordType1').getRecordTypeId();
        System.debug(RecordTypeId);
        QIS_Report__c qis = new QIS_Report__c();
        qis.RecordTypeId = RecordTypeId;
        qis.Name = 'Test';
        qis.QIS_Status__c='OSH检测中';
        qis.OwnerId=comOwner.id;
        qis.CDS_date__c=Date.today();
        qis.OCSMAdministrativeReportDate__c=Date.today();
        qis.Aware_date__c=Date.today();
        qis.OCSMAdministrativeReportNumber__c='00510000001R56KAAS';
        qis.OCSMAdministrativeReportStatus__c='无需报告';
        qis.isAE_Profile__c='YES';
        qis.isPAE_Profile__c='YES';
        qis.next_action__c='无偿维修';
        // qis.QIS_SC_Report__c='a3w10000000U6frAAC';
        qis.IsSendQIS__c=false;
        insert qis;
        // Id qisssId = [SELECT  id FROM QIS_Report__c where Relation_With_The_Problem__c = '有可能'][0].id;
        Test.StartTest();
       
        QISReportController.updateQisForRCCDScomplete(qis.id);
        QISReportController.initForlexOCSMNoToReportLightingButton(qis.id);
        QISReportController.updateQisForlexOCSMNoToReportLighting(qis.id);
        QISReportController.initForlexOCSMToReportLightingButton(qis.id);
        QISReportController.updateQisForlexOCSMToReportLighting(qis.id);
        QISReportController.initForlexSendQISButton(qis.id);
        QISReportController.updateQisForSendQIS(qis.id);
        QISReportController.initForlexRCRecievedButton(qis.id);
        QISReportController.updateQisForRCRecieved(qis.id);
        QISReportController.initForlexQISSCButton(qis.id);
        QISReportController.initForlexCreateRepairButton(qis.id);
        QISReportController.initForlexPDFQISrequestButton(qis.id);
        QISReportController.initForlexOCSMNogoodsButton(qis.id);
        // QISReportController.updatelexOCSMNogoods(qis.id);
 
        Test.stopTest();
    }
 
    @isTest
    public static void testMethod2() {
 
        Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
        //医院所有人
        User comOwner = new User(Dept__c='能量事业本部',Test_staff__c = true, LastName = 'com',  Alias = 'com', CommunityNickname = 'comOwner', Email = 'olympus_comowner@sunbridge.com', Username = 'olympus_comowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert comOwner;
        String RecordTypeId = Schema.SObjectType.QIS_Report__c.getRecordTypeInfosByDeveloperName().get('QISRecordType1').getRecordTypeId();
        System.debug(RecordTypeId);
        QIS_Report__c qis = new QIS_Report__c();
        qis.RecordTypeId = RecordTypeId;
        qis.Name = 'Test';
        qis.QIS_Status__c='OSH检测中';
        qis.OSH_staff__c = '00510000006xTn0AAE';
        qis.OSH_staff_email__c = '754543560@qq.com';
        qis.Cancel_QIS_Reason__c = '取消';
        qis.RC_inspection_date__c = Date.today();
        qis.QIS_Reply_day__c = Date.today();
        qis.OSHInspectionDate__c = Date.today();
        qis.QIS_Submit_day__c = Date.today();
        qis.RC_problem_not_found__c = false;
 
        insert qis;
        // Id qisssId = [SELECT  id FROM QIS_Report__c where Relation_With_The_Problem__c = '有可能'][0].id;
        Test.StartTest();
        QISReportController.initForOSHSubmitButton(qis.id);
        QISReportController.initForRCSubmitButton(qis.id);
        QISReportController.initForOCMSubmitButton(qis.id);
        QISReportController.initForlexRCinspectioncompletedateButton(qis.id);
        QISReportController.updateQisForRCinspectioncompletedate(qis.id);
        QISReportController.updateQisForlexOSHInspect(qis.id);
        QISReportController.initForlexcopyQISButton(qis.id);
        Test.stopTest();
    }
    @isTest
    public static void testMethod3() {
        String RecordTypeId = Schema.SObjectType.QIS_Report__c.getRecordTypeInfosByDeveloperName().get('QISRecordType1').getRecordTypeId();
        System.debug(RecordTypeId);
        QIS_Report__c qis = new QIS_Report__c();
        qis.RecordTypeId = RecordTypeId;
        qis.Name = 'Test';
        qis.QIS_Status__c='OSH检测中';
        qis.OSH_staff__c = '00510000006xTn0AAE';
        qis.OSH_staff_email__c = '754543560@qq.com';
        qis.Cancel_QIS_Reason__c = '取消';
        qis.RC_inspection_date__c = Date.today();
        qis.QIS_Reply_day__c = Date.today();
        qis.RC_problem_not_found__c = true;
        qis.RC_FixedJudgement__c = false;
        qis.OCM_judgement__c = '现象未发现';
        insert qis;
        // Id qisssId = [SELECT  id FROM QIS_Report__c where Relation_With_The_Problem__c = '有可能'][0].id;
        Test.StartTest();
        QISReportController.updateQisWithRC(qis.id,'1','RC检测中');
        QISReportController.updateQisWithRC(qis.id,'2','RC检测中');
        QISReportController.updateQisWithOCM(qis.id);
        Test.stopTest();
    }
    @isTest
    public static void testMethod4() {
 
         Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
        //医院所有人
        User comOwner = new User(Dept__c='能量事业本部',Test_staff__c = true, LastName = 'com',  Alias = 'com', CommunityNickname = 'comOwner', Email = 'olympus_comowner@sunbridge.com', Username = 'olympus_comowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert comOwner;
        String RecordTypeId = Schema.SObjectType.QIS_Report__c.getRecordTypeInfosByDeveloperName().get('QISRecordType1').getRecordTypeId();
        System.debug(RecordTypeId);
        QIS_Report__c qis = new QIS_Report__c();
        qis.RecordTypeId = RecordTypeId;
        qis.Name = 'Test';
        qis.QIS_Status__c='OSH检测中';
        qis.OwnerId=comOwner.id;
        qis.CDS_date__c=Date.today();
        qis.OCSMAdministrativeReportDate__c=Date.today();
        qis.Aware_date__c=Date.today();
        qis.OCSMAdministrativeReportNumber__c='00510000001R56KAAS';
        qis.OCSMAdministrativeReportStatus__c='无需报告';
        qis.isAE_Profile__c='YES';
        qis.isPAE_Profile__c='YES';
        qis.next_action__c='无偿维修';
        // qis.QIS_SC_Report__c='a3w10000000U6frAAC';
        qis.IsSendQIS__c=false;
        insert qis;
        // Id qisssId = [SELECT  id FROM QIS_Report__c where Relation_With_The_Problem__c = '有可能'][0].id;
        Test.StartTest();
        QISReportController.updatelexOCSMNogoods(qis.id);
 
        Test.stopTest();
    }
    @isTest
    public static void testMethod5() {
       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[] 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;
 
        Date toDate = Date.today();
         Asset report = new Asset();
        report.AssetMark__c = '耗材';
        report.Asset_Owner__c = '病院資産';
        report.InstallDate = Date.today();
        report.Posting_Date__c = Date.today();
        report.Asset_day__c = Date.today();
        report.SerialNumber = '09K(IOSJA)';
        report.Order_No__c = 'BJ-ET-203044-7';
        report.Name = 'FD-410LR:一次性高频止血';
        report.AccountId = dep.Id;
        report.Department_Class__c = strategicDep[0].Id;
        report.Hospital__c = hospital.Id;
        insert report;
        Repair__c repair1 = new Repair__c();
        repair1.Service_Repair_No__c = 'repair1';
        repair1.Account__c = dep.Id;
        repair1.Department_Class__c = strategicDep[0].Id;
        repair1.Hospital__c = hospital.Id;
        // repair1.Delivered_Product__c = ast1.Id;
        repair1.Repair_List_Price__c = 100;
        repair1.Delivered_Product__c = report.id;
        repair1.Billing_Amount__c = 10;
        repair1.Paid_Amount__c = 1;
        repair1.FSE_ApplyForRepair_time__c = Date.today().addMonths(6);
        repair1.Failure_Occurrence_Date__c = Date.today().addDays(-1);
        repair1.Repair_Returned_To_HP_Date__c = Date.today().addDays(3);
        repair1.Repair_Shipped_Date__c = Date.today().addDays(1);
        repair1.AWS_Data_Id__c = '123';
        
        insert repair1;
        // Id qisssId = [SELECT  id FROM QIS_Report__c where Relation_With_The_Problem__c = '有可能'][0].id;
        Test.StartTest();
         QISReportController.initForlexCreateQISFromAssetButton(report.id);
 
        Test.stopTest();
    }
    @isTest
    public static void testMethod6() {
        Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
        //医院所有人
        User comOwner = new User(Dept__c='能量事业本部',Test_staff__c = true, LastName = 'com',  Alias = 'com', CommunityNickname = 'comOwner', Email = 'olympus_comowner@sunbridge.com', Username = 'olympus_comowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert comOwner;
        String RecordTypeId = Schema.SObjectType.QIS_Report__c.getRecordTypeInfosByDeveloperName().get('QISRecordType1').getRecordTypeId();
        System.debug(RecordTypeId);
        QIS_Report__c qis = new QIS_Report__c();
        qis.RecordTypeId = RecordTypeId;
        qis.Name = 'Test';
        qis.QIS_Status__c='OSH检测中';
        qis.OwnerId=comOwner.id;
        qis.CDS_date__c=Date.today();
        qis.OCSMAdministrativeReportDate__c=Date.today();
        qis.Aware_date__c=Date.today();
        qis.OCSMAdministrativeReportNumber__c='00510000001R56KAAS';
        qis.OCSMAdministrativeReportStatus__c='无需报告';
        qis.isAE_Profile__c='YES';
        qis.isPAE_Profile__c='YES';
        qis.next_action__c='无偿维修';
        // qis.QIS_SC_Report__c='a3w10000000U6frAAC';
        qis.IsSendQIS__c=false;
        insert qis;
        // Id qisssId = [SELECT  id FROM QIS_Report__c where Relation_With_The_Problem__c = '有可能'][0].id;
        Test.StartTest();
        QISReportController.initForlexOSHInspectButton(qis.id);
 
        Test.stopTest();
    }
}