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
@isTest
public with sharing class SubmitForApprovalControllerTest {
 
    static Maintenance_Contract__c setupTestData02(Account hospital, Account strategicDep, Account dep) {
        Maintenance_Contract__c mc = new Maintenance_Contract__c();
        mc.Name = '12313132';                                       //合同名
        mc.Status__c = '询价中';                                    //状态
        mc.Department__c = dep.Id;                                  //科室
        mc.Service_Contract_Staff__c =  UserInfo.getUserId();       //主担当者
        // mc.Negotiation_Start_Date__c = Date.today();                //谈判开始日
        // mc.Opportunity_Stage__c = '意向确认';                        //询价进展状态
        // mc.Forecast_Selling_Price__c = 100000;                      //预测成交价
        // mc.Sales_Method__c = '公开招标';                             //招标方式
        insert mc;
        return mc;
    }
 
 
    @isTest
    static void setupTestData03() {
        Account company1 = new Account();
        company1.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
        company1.Name = '病院テスト1';
        List<Account> hps = new Account[] {company1};
        insert hps;
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id and RecordType_DeveloperName__c = 'Department_Class_BF'];
        StaticParameter.EscapeAccountTrigger = true;
        Account depart1 = new Account();
        depart1.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_BF').getRecordTypeId();
        depart1.Name         = '*';
        depart1.Department_Name__c  = '診療科1';
        depart1.ParentId            = dc1s[0].Id;
        depart1.Department_Class__c = dc1s[0].Id;
        depart1.Hospital__c         = company1.Id;
        insert depart1;
 
        Account depart2 = new Account();
        depart2.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_BF').getRecordTypeId();
        depart2.Name         = '*';
        depart2.Department_Name__c  = '消化科1';
        depart2.ParentId            = dc1s[0].Id;
        depart2.Department_Class__c = dc1s[0].Id;
        depart2.Hospital__c         = company1.Id;
        insert depart2;
 
        StaticParameter.EscapeSyncProduct2Trigger = true;
        Maintenance_Contract__c mContract = setupTestData02(company1, dc1s[0], depart1);
        PageReference page = new PageReference('/apex/SubmitForApprovalPage?id=' + mContract.Id);
        System.Test.setCurrentPage(page);
        SubmitForApprovalController sfac = new SubmitForApprovalController();
        //初始化测试
        sfac.init();
        // sfac.lostData.Specific_Reasons__c = '其他(手写)';
        //提交审批
        sfac.submit();
        //保存测试
        sfac.save();
 
 
    }
 
 
    @isTest
    static void setupTestData04() {
        Account company1 = new Account();
        company1.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
        company1.Name = '病院テスト1';
        List<Account> hps = new Account[] {company1};
        insert hps;
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id and RecordType_DeveloperName__c = 'Department_Class_BF'];
        StaticParameter.EscapeAccountTrigger = true;
        Account depart1 = new Account();
        depart1.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_BF').getRecordTypeId();
        depart1.Name         = '*';
        depart1.Department_Name__c  = '診療科1';
        depart1.ParentId            = dc1s[0].Id;
        depart1.Department_Class__c = dc1s[0].Id;
        depart1.Hospital__c         = company1.Id;
        insert depart1;
 
        Account depart2 = new Account();
        depart2.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_BF').getRecordTypeId();
        depart2.Name         = '*';
        depart2.Department_Name__c  = '消化科1';
        depart2.ParentId            = dc1s[0].Id;
        depart2.Department_Class__c = dc1s[0].Id;
        depart2.Hospital__c         = company1.Id;
        insert depart2;
 
        StaticParameter.EscapeSyncProduct2Trigger = true;
        Maintenance_Contract__c mContract = setupTestData02(company1, dc1s[0], depart1);
        PageReference page = new PageReference('/apex/SubmitForApprovalPage?id=' + mContract.Id);
        System.Test.setCurrentPage(page);
        SubmitForApprovalController sfac = new SubmitForApprovalController();
        //初始化测试
        sfac.init();
        sfac.lostData.Specific_Reasons__c = '其他(手写)';
        sfac.lostData.To_Where__c = '医院选择第三方';
        //提交审批
        sfac.submit();
        //保存测试
        sfac.save();
 
 
    }
 
 
    @isTest
    static void setupTestData05() {
        Account company1 = new Account();
        company1.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
        company1.Name = '病院テスト1';
        List<Account> hps = new Account[] {company1};
        insert hps;
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id and RecordType_DeveloperName__c = 'Department_Class_BF'];
        StaticParameter.EscapeAccountTrigger = true;
        Account depart1 = new Account();
        depart1.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_BF').getRecordTypeId();
        depart1.Name         = '*';
        depart1.Department_Name__c  = '診療科1';
        depart1.ParentId            = dc1s[0].Id;
        depart1.Department_Class__c = dc1s[0].Id;
        depart1.Hospital__c         = company1.Id;
        insert depart1;
 
        Account depart2 = new Account();
        depart2.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_BF').getRecordTypeId();
        depart2.Name         = '*';
        depart2.Department_Name__c  = '消化科1';
        depart2.ParentId            = dc1s[0].Id;
        depart2.Department_Class__c = dc1s[0].Id;
        depart2.Hospital__c         = company1.Id;
        insert depart2;
 
        StaticParameter.EscapeSyncProduct2Trigger = true;
        Maintenance_Contract__c mContract = setupTestData02(company1, dc1s[0], depart1);
        PageReference page = new PageReference('/apex/SubmitForApprovalPage?id=' + mContract.Id);
        System.Test.setCurrentPage(page);
        SubmitForApprovalController sfac = new SubmitForApprovalController();
        //初始化测试
        sfac.init();
        sfac.lostData.Specific_Reasons__c = '其他(手写)';
        sfac.lostData.To_Where__c = '其他(手写)';
        //提交审批
        sfac.submit();
        //保存测试
        sfac.save();
    }
    @isTest
    static void setupTestData06() {
        Account company1 = new Account();
        company1.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
        company1.Name = '病院テスト1';
        List<Account> hps = new Account[] {company1};
        insert hps;
        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id and RecordType_DeveloperName__c = 'Department_Class_BF'];
        StaticParameter.EscapeAccountTrigger = true;
        Account depart1 = new Account();
        depart1.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_BF').getRecordTypeId();
        depart1.Name         = '*';
        depart1.Department_Name__c  = '診療科1';
        depart1.ParentId            = dc1s[0].Id;
        depart1.Department_Class__c = dc1s[0].Id;
        depart1.Hospital__c         = company1.Id;
        insert depart1;
 
        Account depart2 = new Account();
        depart2.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_BF').getRecordTypeId();
        depart2.Name         = '*';
        depart2.Department_Name__c  = '消化科1';
        depart2.ParentId            = dc1s[0].Id;
        depart2.Department_Class__c = dc1s[0].Id;
        depart2.Hospital__c         = company1.Id;
        insert depart2;
 
         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 = depart2.Id;
        contract.Department_Class__c = depart2.Id;
        contract.Department__c = depart2.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';
        contract.RecordTypeId = Schema.SObjectType.Maintenance_Contract__c.getRecordTypeInfosByDeveloperName().get('VM_Contract').getRecordTypeId();
        insert contract;
 
        Lost_Report__c lr = new Lost_Report__c();
        lr.Maintenance_Contract__c = contract.ID;
        lr.Specific_Reasons__c  = '跟进不够';
        lr.To_Where__c = '';
        lr.Status__c = '审批中';
        insert lr;
 
 
        StaticParameter.EscapeSyncProduct2Trigger = true;
        Maintenance_Contract__c mContract = setupTestData02(company1, dc1s[0], depart1);
        PageReference page = new PageReference('/apex/SubmitForApprovalPage?id=' + lr.Id);
        System.Test.setCurrentPage(page);
        SubmitForApprovalController sfac = new SubmitForApprovalController();
        //初始化测试
        sfac.init();
        sfac.lostData.Specific_Reasons__c = '其他(手写)';
        sfac.lostData.To_Where__c = '其他(手写)';
        //提交审批
        sfac.submit();
        //保存测试
        sfac.save();
    }
 
 
}