@isTest
|
private class PrintInspectupReportPDFControllerTest {
|
static testMethod void testMethod1() {
|
|
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;
|
Account hospital = new Account();
|
hospital.recordtypeId =
|
Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
|
|
hospital.Name = 'test hospita/l';
|
insert hospital;
|
|
// 戦略科室を得る
|
List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
|
|
// 診療科を作る
|
Account dep = new Account();
|
dep.recordtypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_GI').getRecordTypeId();
|
dep.Name = 'test de/p';
|
dep.ParentId = strategicDep[0].Id;
|
dep.Department_Class__c = strategicDep[0].Id;
|
dep.Hospital__c = hospital.Id;
|
insert dep;
|
|
Asset ass1 = new Asset(
|
AccountId = dep.Id,
|
Hospital__c = hospital.Id,
|
SerialNumber = 'lw0001',
|
Name = '测试设备0001:aaaaa',
|
Installation_Site__c = '手术室'
|
);
|
Asset ass2 = new Asset(
|
AccountId = dep.Id,
|
Hospital__c = hospital.Id,
|
SerialNumber = 'lw0002',
|
Name = '测试设备并且设备长名称准备好了吗0002:aaaaa',
|
Installation_Site__c = '门诊'
|
);
|
insert new Asset[] {ass1, ass2};
|
|
|
// 维修合同を作成する
|
Maintenance_Contract__c contract = new Maintenance_Contract__c();
|
contract.Name = 'tect contract';
|
contract.Hospital__c = hospital.Id;
|
contract.Department_Class__c = strategicDep[0].Id;
|
contract.Department__c = dep.Id;
|
contract.Service_Contract_Staff__c = MacOwner.Id;
|
contract.Payment_Plan_Sum_First__c = 1;
|
contract.Status__c = '契約';
|
contract.Maintenance_Contract_No__c = '11123';
|
contract.recordtypeId = Schema.SObjectType.Maintenance_Contract__c.getRecordTypeInfosByDeveloperName().get('NewMaintenance_Contract').getRecordTypeId();
|
contract.Not_Upper_limit_reason__c = ' 1';
|
contract.Contract_Start_Date__c = Date.today().addDays( -10);
|
contract.Contract_End_Date__c = Date.today().addDays( 5);
|
contract.SalesOfficeCode_selection__c = '北京RC';
|
|
Maintenance_Contract__c contract2 = contract.clone();
|
contract2.Name = 'tect contract2';
|
contract2.Contract_Start_Date__c = Date.today().addDays( -100);
|
contract2.Contract_End_Date__c = Date.today().addDays( -10);
|
contract2.Maintenance_Contract_No__c = '11a 123';
|
contract2.First_Estimate_Date__c = Date.today().addDays( -80);
|
insert new list<Maintenance_Contract__c> {contract,contract2};
|
|
//点检计划1
|
Inspectup_Plan__c inplan = new Inspectup_Plan__c();
|
inplan.Planned_Start_Date__c = Date.today().addDays(1);
|
inplan.Planned_End_Date__c = Date.today().addMonths(2).addDays(1);
|
inplan.Actual_Execution_Quantity__c = 0;
|
inplan.Maintenance_Contract__c = contract.Id;
|
inplan.Chack_Plan_NO__c = '1';
|
insert inplan;
|
|
//点检计划2
|
Inspectup_Plan__c inplan2 = new Inspectup_Plan__c();
|
inplan2.Planned_Start_Date__c = Date.today().addDays(1);
|
inplan2.Planned_End_Date__c = Date.today().addMonths(2).addDays(1);
|
inplan2.Actual_Execution_Quantity__c = 0;
|
inplan2.Maintenance_Contract__c = contract.Id;
|
inplan2.Chack_Plan_NO__c = '2';
|
insert inplan2;
|
|
//点检计划3
|
Inspectup_Plan__c inplan3 = new Inspectup_Plan__c();
|
inplan3.Planned_Start_Date__c = Date.today().addDays(1);
|
inplan3.Planned_End_Date__c = Date.today().addMonths(2).addDays(1);
|
inplan3.Actual_Execution_Quantity__c = 0;
|
inplan3.Maintenance_Contract__c = contract.Id;
|
inplan3.Chack_Plan_NO__c = '2';
|
insert inplan3;
|
|
//点检计划4
|
Inspectup_Plan__c inplan4 = new Inspectup_Plan__c();
|
inplan4.Planned_Start_Date__c = Date.today().addDays(1);
|
inplan4.Planned_End_Date__c = Date.today().addMonths(2).addDays(1);
|
inplan4.Actual_Execution_Quantity__c = 0;
|
inplan4.Maintenance_Contract__c = contract.Id;
|
inplan4.Chack_Plan_NO__c = '2';
|
insert inplan4;
|
|
//点检报告书
|
Inspection_Report__c ir0 = new Inspection_Report__c();
|
ir0.Name = '*';
|
ir0.Hospital__c = hospital.Id;
|
ir0.Reporter__c = MacOwner.id;
|
ir0.Approved_date__c = Date.today().addDays(-1);
|
ir0.Inspection_Date__c = Date.today().addDays(-1);
|
ir0.Inspectup_Plan__c=inplan.id;
|
ir0.Status__c = '批准';
|
insert ir0;
|
|
Inspection_Item__c ii0 = new Inspection_Item__c();
|
ii0.Inspection_ReportId__c = ir0.Id;
|
ii0.AssetId__c = ass1.Id;
|
ii0.ItemStatus__c = 'OK';
|
insert ii0;
|
|
//点检报告书
|
Inspection_Report__c ir1 = new Inspection_Report__c();
|
ir1.Name = 'dd';
|
ir1.Hospital__c = hospital.Id;
|
ir1.Reporter__c = MacOwner.id;
|
ir1.Approved_date__c = Date.today().addDays(-1);
|
ir1.Inspection_Date__c = Date.today().addDays(-1);
|
ir1.Inspectup_Plan__c=inplan2.id;
|
ir0.Status__c = '批准';
|
insert ir1;
|
|
Inspection_Item__c ii1 = new Inspection_Item__c();
|
ii1.Inspection_ReportId__c = ir1.Id;
|
ii1.AssetId__c = ass1.Id;
|
ii1.ItemStatus__c = 'NG';
|
insert ii1;
|
|
Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c();
|
contactEsti1.Name = 'contract estimate 1';
|
contactEsti1.RecordtypeId = Schema.SObjectType.Maintenance_Contract_Estimate__c.getRecordTypeInfosByDeveloperName().get('NewMaintenance_Quote').getRecordTypeId();
|
contactEsti1.Contract_Esti_Start_Date__c = Date.today();
|
contactEsti1.Contract_Range__c = 2;
|
contactEsti1.Maintenance_Contract__c = contract.Id;
|
contactEsti1.Asset_Sum_Price__c = 1000;
|
contactEsti1.mainTalksTime__c = 1;
|
contactEsti1.talksStartDate__c = date.today();
|
contactEsti1.Discount_reason__c ='1';
|
contactEsti1.Improve_ConsumptionRate_Idea__c = '1';
|
contactEsti1.NewEstimation_Amount__c = 100;
|
insert contactEsti1;
|
|
Maintenance_Contract_Asset_Estimate__c mcae1 = new Maintenance_Contract_Asset_Estimate__c();
|
mcae1.Asset__c = ass1.Id;
|
mcae1.Maintenance_Contract_Estimate__c = contactEsti1.Id;
|
mcae1.ifHaveleftInPrevious__c = true;
|
mcae1.Estimate_List_Price__c = 1000;
|
mcae1.Check_Result__c = 'OK';
|
insert mcae1;
|
|
Maintenance_Contract_Asset__c contractasset = new Maintenance_Contract_Asset__c();
|
contractasset.Asset__c = ass1.Id;
|
contractasset.Maintenance_Contract__c = contract.Id;
|
contractasset.Estimate_List_Price_All_Manual__c = 1000;
|
contractasset.Maintenance_Contract_Asset_Estimate__c = mcae1.id;
|
|
Maintenance_Contract_Asset__c contractasset2 = contractasset.clone();
|
contractasset2.Maintenance_Contract__c = contract.Id;
|
contractasset2.Asset__c = ass2.Id;
|
insert new list<Maintenance_Contract_Asset__c> {contractasset,contractasset2 };
|
|
Repair__c repair01 = new Repair__c();
|
repair01.Account__c = dep.Id;
|
repair01.Department_Class__c = strategicDep[0].Id;
|
repair01.Hospital__c = hospital.Id;
|
repair01.Dealer__c = dep.Id;
|
repair01.Delivered_Product__c = ass1.Id;
|
repair01.SERVICE_CONTRACT_JUDEGE_DAY__C = Date.today().addDays( -1);
|
repair01.Failure_Occurrence_Date__c = Date.today().addDays( -2);
|
insert repair01;
|
|
String parameter = '2,,3,,手术室,门诊,,true,,true,,'+inplan.id+','+inplan2.id+','+inplan3.id+','+inplan4.id+',,'+contract.id;
|
PageReference peg = new PageReference('/apex/PrintInspectupReportPDFController?parameter='+parameter);
|
System.Test.setCurrentPage(peg);
|
|
PrintInspectupReportPDFController pirpc = new PrintInspectupReportPDFController();
|
pirpc.init();
|
}
|
}
|