public with sharing class CreateDataCommon {
|
//调用共通类的方法,可以创建医院、战略科室、科室、经销商、契约
|
//医院
|
public Account CreateHp(){
|
Account hospital = new Account();
|
Id hpRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
|
//hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
|
hospital.recordtypeId = hpRecordTypeId;
|
hospital.Name = '20220110testHospital';
|
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.Assume_Change__c = true;
|
insert hospital;
|
return hospital;
|
}
|
|
//战略科室
|
public Account CreateStrategicDep(Account hospital){
|
//Department_Class_OTH 戦略科室分類 その他
|
// Account sdep = new Account();
|
// Id sdepRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_Class_OTH').getRecordTypeId();
|
// sdep.recordtypeId = sdepRecordTypeId;
|
// sdep.Name = '20220113Test 其他';
|
// sdep.Department_Class_Label__c = '其他';
|
// sdep.parentId = hospital.Id;
|
// insert sdep;
|
// return sdep;
|
Account sdep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
|
return sdep;
|
|
}
|
|
//科室(医院 -- 战略科室 -- 科室)
|
public Account CreateDepartment(Account hospital,Account sdep){
|
//Department_OTH 診療科 その他
|
Account dep = new Account();
|
dep.parentId = sdep.Id;
|
Id depRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_OTH').getRecordTypeId();
|
dep.recordtypeId = depRecordTypeId;
|
dep.Name = '其他';
|
dep.Department_Class__c = sdep.Id;
|
dep.Department_Name__c = '20220113Test 其他 其他';
|
dep.Hospital__c = hospital.Id;
|
insert dep;
|
return dep;
|
}
|
|
//经销商
|
public Account CreateDealer(){
|
Account acc = new Account();
|
Id accRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
|
acc.recordtypeId = accRecordTypeId;
|
//acc.Dealer_discount__c =20;
|
acc.name='20220113TestAcc';
|
insert acc;
|
return acc;
|
|
}
|
|
//契约(经销商合同)
|
public Account CreateContract(Account acc){
|
Account con = new Account();
|
Id conRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('AgencyContract').getRecordTypeId();
|
con.name='20220113TestCon';
|
con.RecordTypeId = conRecordTypeId;
|
con.Contract_Decide_Start_Date__c = Date.today().addDays(-1);
|
con.Contract_Decide_End_Date__c =Date.today().addDays(1);
|
con.Agent_Ref__c = acc.Id;
|
con.ParentId = acc.Id;
|
//con.ET_SP_Dealer__c = true;
|
insert con;
|
return con;
|
}
|
|
}
|