@isTest
|
private class updateContectBatchTest {
|
|
static testMethod void testupdateContectBatch() {
|
|
//维修合同
|
Maintenance_Contract__c macnt = new Maintenance_Contract__c();
|
//用户信息中的简档
|
Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
|
//主担当者联系的用户信息
|
User MacOwner = new User(Test_staff__c = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner@sunbridge.com',Job_Category__c = '销售服务', Username = 'olympus_hpowner@sunbridge.com1', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
|
insert MacOwner;
|
//科室的三层结构
|
//病院
|
// List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'] ;
|
// if (rectCo.size() == 0) {
|
// return;
|
// }
|
//战略科室分类
|
// RecordType rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 普外科'];
|
// //科室分类
|
// RecordType rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 普外科'];
|
Account company = new Account();
|
//company.RecordTypeId = rectCo[0].Id;
|
//病院的ID
|
company.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
|
company.Name = 'NFM206TestCompany';
|
insert company;
|
Account section = new Account();
|
//section.RecordTypeId = rectSct.id;
|
//战略科室分类 普外科的ID
|
section.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_Class_GS').getRecordTypeId();
|
section.Name = '*';
|
section.Department_Class_Label__c = '普外科';
|
section.ParentId = company.Id;
|
section.Hospital_Department_Class__c = company.Id;
|
insert section;
|
Account depart = new Account();
|
//depart.RecordTypeId = rectDpt.Id;
|
//科室分类 普外科的ID
|
depart.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_GS').getRecordTypeId();
|
depart.Name = '*';
|
depart.Department_Name__c = 'NFM206TestDepart';
|
depart.ParentId = section.Id;
|
depart.Department_Class__c = section.Id;
|
depart.Hospital__c = company.Id;
|
insert depart;
|
macnt.Name = '测试服务合同1';
|
macnt.Status__c = '合同中';
|
//科室
|
macnt.Department__c = depart.id;
|
//主担当者
|
macnt.Service_Contract_Staff__c = MacOwner.Id ;
|
insert macnt;
|
|
//点检计划
|
Inspectup_Plan__c Inplan = new Inspectup_Plan__c();
|
//币种
|
Inplan.CurrencyIsoCode = 'CNY';
|
//点检计划编码
|
Inplan.Name = 'Check_plan_Test1';
|
//实际执行数
|
Inplan.Actual_Execution_Quantity__c = 0;
|
//Maintenance_Contract__c:维修合同
|
Inplan.Maintenance_Contract__c = macnt.id;
|
//Planned_Start_Date__c:计划开始日
|
Inplan.Planned_Start_Date__c = Date.today().addDays(-2);
|
// Planned_End_Date__c:计划结束日
|
Inplan.Planned_End_Date__c = Date.today().addDays(-1);
|
//Timeliness_Rate__c:本次点检及时率
|
Inplan.Timeliness_Rate__c = 80;
|
//Implementation_Rate__c:本次点检实施率
|
Inplan.Implementation_Rate__c = 80;
|
insert Inplan;
|
|
//点检计划2
|
Inspectup_Plan__c Inplan2 = new Inspectup_Plan__c();
|
Inplan2.CurrencyIsoCode = 'CNY';
|
Inplan2.Name = 'Check_plan_Test2';
|
Inplan2.Actual_Execution_Quantity__c = 0;
|
Inplan2.Maintenance_Contract__c = macnt.id;
|
Inplan2.Planned_Start_Date__c = Date.today().addDays(-1);
|
Inplan2.Planned_End_Date__c = Date.today().addDays(+2);
|
Inplan2.Timeliness_Rate__c = 80;
|
Inplan2.Implementation_Rate__c = 80;
|
insert Inplan2;
|
|
Database.executeBatch(new updateContectBatch(), 20);
|
Database.executeBatch(new updateContectBatch(Inplan.id), 20);
|
}
|
}
|