@isTest private class OPDNoReportApplicationControllerTest { private static integer FIELDMAX = 200; //测试初始化、保存、提交待审批 static testMethod void setupTestData01() { SS_Batch_Column_Mapping__c oppMapping = new SS_Batch_Column_Mapping__c(Name = 'targetKeyProduct', SS_TableName__c='targetKeyProduct__c'); oppMapping.From_Column_001__c = 'OPD_CV290__c'; oppMapping.SS_Column_001__c = 'CV-290'; oppMapping.From_Column_002__c = 'OPD_290Miro__c'; oppMapping.SS_Column_002__c = 'GI-290镜子,GI-290镜子放大,GI-290镜子CF,BF-290镜子'; oppMapping.From_Column_003__c = 'OPD_TB__c'; oppMapping.SS_Column_003__c = 'TB'; oppMapping.From_Column_101__c = 'Rental_Cnt_CV290__c'; oppMapping.SS_Column_101__c = 'CV-290'; oppMapping.From_Column_102__c = 'Rental_Cnt_290MiroGI__c'; oppMapping.SS_Column_102__c = 'GI-290镜子'; oppMapping.From_Column_103__c = 'Rental_Cnt_TB__c'; oppMapping.SS_Column_103__c = 'TB'; oppMapping.From_Column_118__c = 'Sales_target_CV290__c'; oppMapping.SS_Column_118__c = 'CV-290'; oppMapping.From_Column_119__c = 'Sales_target_290Miro__c'; oppMapping.SS_Column_119__c = 'GI-290镜子,GI-290镜子放大,GI-290镜子CF,BF-290镜子'; oppMapping.From_Column_120__c = 'Sales_target_TB__c'; oppMapping.SS_Column_120__c = 'TB'; oppMapping.From_Column_129__c = 'Opp_cnt_290MiroBF__c'; oppMapping.SS_Column_129__c = 'BF-290镜子'; oppMapping.From_Column_130__c = 'Opp_cnt_290MiroGI__c'; oppMapping.SS_Column_130__c = 'GI-290镜子'; oppMapping.From_Column_131__c = 'Opp_cnt_290MiroGI_CF__c'; oppMapping.SS_Column_131__c = 'GI-290镜子CF'; oppMapping.From_Column_146__c = 'Asset_Cnt_290MiroBF__c'; oppMapping.SS_Column_146__c = 'BF-290镜子'; oppMapping.From_Column_147__c = 'Asset_Cnt_290MiroGI__c'; oppMapping.SS_Column_147__c = 'GI-290镜子'; oppMapping.From_Column_148__c = 'Asset_Cnt_290MiroGI_CF__c'; oppMapping.SS_Column_148__c = 'GI-290镜子CF'; oppMapping.From_Column_163__c = 'OPD_amount_290MiroBF__c'; oppMapping.SS_Column_163__c = 'BF-290镜子'; oppMapping.From_Column_164__c = 'OPD_amount_290MiroGI__c'; oppMapping.SS_Column_164__c = 'GI-290镜子'; oppMapping.From_Column_165__c = 'OPD_amount_290MiroGI_CF__c'; oppMapping.SS_Column_165__c = 'GI-290镜子CF'; insert new SS_Batch_Column_Mapping__c[] {oppMapping}; //医院 记录类型 List rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP']; if (rectHp.size() == 0) { return; } //科室 记录类型 List rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI']; if (rectDpt.size() == 0) { return; } //简档 Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; //用户 User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); insert hpOwner; User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); insert hpOwner2; //医院 Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id); hp.FSE_GI_Main_Leader__c = hpOwner.Id; hp.FSE_SP_Main_Leader__c = hpOwner2.Id; insert hp; //战略科室 Account dc = [select Id, Name, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_GI']; //科室 Account dpt = new Account(RecordTypeId = rectDpt[0].Id); dpt.Name = '*'; dpt.Department_Name__c = 'TestDepart'; dpt.ParentId = dc.Id; dpt.Department_Class__c = dc.Id; dpt.Hospital__c = hp.Id; insert dpt; //科室1 Account dpt1 = new Account(RecordTypeId = rectDpt[0].Id); dpt1.Name = '123'; dpt1.Department_Name__c = 'TestDepart1'; dpt1.ParentId = dc.Id; dpt1.Department_Class__c = dc.Id; dpt1.Hospital__c = hp.Id; insert dpt1; //根据opd计划实施日期 算出本财年 Date dateToday = Date.today(); Integer year = dateToday.year(); Integer month = dateToday.month(); if (month < 4) { year -= 1; } String selectedTab = String.valueOf(year - 1867 - 1 + 'P'); String selectedTab1 = String.valueOf(year - 1867 + 'P'); //今财年 //客户-目标客户 默认让opd计划和客户-目标客户的财年相同 Account_Number_of_target__c anot = new Account_Number_of_target__c(); anot.Account__c = dc.Id; anot.Account_HP__c = hp.Id; anot.OCM_Period__c = selectedTab; anot.Target_amount_170_190__c =36597; anot.OPD_amount_290MiroBF__c =1; anot.OPD_amount_290MiroGI_CF__c =1; insert anot; Account_Number_of_target__c anot1 = new Account_Number_of_target__c(); anot1.Account__c = dc.Id; anot1.Account_HP__c = hp.Id; anot1.OCM_Period__c = selectedTab1; anot1.Target_amount_170_190__c =36597; anot1.OPD_CV290__c =1; anot1.OPD_290Miro__c =1; anot1.OPD_TB__c =1; anot1.Rental_Cnt_CV290__c =1; anot1.Rental_Cnt_TB__c =1; anot1.Target_amount_CV290__c =1; anot1.Target_amount_TB__c =1;//Sales_target_TB__c anot1.Opp_cnt_290MiroGI__c =1; anot1.Opp_cnt_290MiroGI_CF__c =1; anot1.Asset_Cnt_290MiroBF__c =1; anot1.OPD_amount_290MiroBF__c =1; anot1.OPD_amount_290MiroGI_CF__c =1; insert anot1; // 产品 Product2 pro5 = new Product2(Name='name05',IsActive=true,Family='SP', Fixture_Model_No__c='n05',Serial_Lot_No__c='S/N tracing', Fixture_Model_No_T__c = 'n05', ProductCode_Ext__c='pc05',Manual_Entry__c=false); insert pro5; System.Test.StartTest(); OPDPlan__c oPDPlan0 = new OPDPlan__c(); oPDPlan0.Status__c = '草案中'; oPDPlan0.OPDType__c = '科室'; oPDPlan0.if_OPDTarget__c=1; oPDPlan0.if_HaveSalestarget__c =1; oPDPlan0.Cnt_OPD_ThisYear__c=1; oPDPlan0.Cnt_OPD_LastYear__c=1; oPDPlan0.if_HaveOpportunity__c=1; oPDPlan0.if_HaveEquipment__c =1; oPDPlan0.Cnt_Rentals__c =1; oPDPlan0.PlanProdDetail__c ='CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; oPDPlan0.Account_Laboratory__c =dpt.Id; oPDPlan0.OPDPlan_ImplementDate__c = Date.today(); oPDPlan0.OPDPlan_ImplementDate_temp__c = Date.today(); oPDPlan0.NoOpp_Reason__c = 'HCP对应'; oPDPlan0.RentalReson__c = '无法进入手术室'; oPDPlan0.AttachmentCertificate__c = '0001.png'; oPDPlan0.ModelLendingProduct__c=pro5.id; //oPDPlan0.CorrespondingRepairNo__c =anot1.id; insert oPDPlan0; Attachment attach1=new Attachment(); attach1.Name='Unit Test Attachment'; Blob bodyBlob1=Blob.valueOf('Unit Test Attachment Body'); attach1.body=bodyBlob1; attach1.ContentType = 'application/pdf'; PageReference page = new PageReference('/apex/OPDNoReportApplication?id='+oPDPlan0.id+'&name=' + oPDPlan0.name); System.Test.setCurrentPage(page); OPDNoReportApplicationController opd = new OPDNoReportApplicationController(); //初始化测试 opd.init(); //获取选项列表测试 opd.getRentalReson(); //保存测试 opd.IsUpload =true; oPDPlan0.RentalResonTemp__c = '无法进入手术室'; //oPDPlan0.ModelLendingProductCode__c = 'test0001'; opd.opdPlan = oPDPlan0; opd.ModelLendingProductId = pro5.id; //保存 opd.Save(); //提交待审批 opd.CommitNeedApproval(); System.Test.StopTest(); } //测试上传附件 @isTest static void setupTestData02() { SS_Batch_Column_Mapping__c oppMapping = new SS_Batch_Column_Mapping__c(Name = 'targetKeyProduct', SS_TableName__c='targetKeyProduct__c'); oppMapping.From_Column_001__c = 'OPD_CV290__c'; oppMapping.SS_Column_001__c = 'CV-290'; oppMapping.From_Column_002__c = 'OPD_290Miro__c'; oppMapping.SS_Column_002__c = 'GI-290镜子,GI-290镜子放大,GI-290镜子CF,BF-290镜子'; oppMapping.From_Column_003__c = 'OPD_TB__c'; oppMapping.SS_Column_003__c = 'TB'; oppMapping.From_Column_101__c = 'Rental_Cnt_CV290__c'; oppMapping.SS_Column_101__c = 'CV-290'; oppMapping.From_Column_102__c = 'Rental_Cnt_290MiroGI__c'; oppMapping.SS_Column_102__c = 'GI-290镜子'; oppMapping.From_Column_103__c = 'Rental_Cnt_TB__c'; oppMapping.SS_Column_103__c = 'TB'; oppMapping.From_Column_118__c = 'Sales_target_CV290__c'; oppMapping.SS_Column_118__c = 'CV-290'; oppMapping.From_Column_119__c = 'Sales_target_290Miro__c'; oppMapping.SS_Column_119__c = 'GI-290镜子,GI-290镜子放大,GI-290镜子CF,BF-290镜子'; oppMapping.From_Column_120__c = 'Sales_target_TB__c'; oppMapping.SS_Column_120__c = 'TB'; oppMapping.From_Column_129__c = 'Opp_cnt_290MiroBF__c'; oppMapping.SS_Column_129__c = 'BF-290镜子'; oppMapping.From_Column_130__c = 'Opp_cnt_290MiroGI__c'; oppMapping.SS_Column_130__c = 'GI-290镜子'; oppMapping.From_Column_131__c = 'Opp_cnt_290MiroGI_CF__c'; oppMapping.SS_Column_131__c = 'GI-290镜子CF'; oppMapping.From_Column_146__c = 'Asset_Cnt_290MiroBF__c'; oppMapping.SS_Column_146__c = 'BF-290镜子'; oppMapping.From_Column_147__c = 'Asset_Cnt_290MiroGI__c'; oppMapping.SS_Column_147__c = 'GI-290镜子'; oppMapping.From_Column_148__c = 'Asset_Cnt_290MiroGI_CF__c'; oppMapping.SS_Column_148__c = 'GI-290镜子CF'; oppMapping.From_Column_163__c = 'OPD_amount_290MiroBF__c'; oppMapping.SS_Column_163__c = 'BF-290镜子'; oppMapping.From_Column_164__c = 'OPD_amount_290MiroGI__c'; oppMapping.SS_Column_164__c = 'GI-290镜子'; oppMapping.From_Column_165__c = 'OPD_amount_290MiroGI_CF__c'; oppMapping.SS_Column_165__c = 'GI-290镜子CF'; insert new SS_Batch_Column_Mapping__c[] {oppMapping}; //医院 记录类型 List rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP']; if (rectHp.size() == 0) { return; } //科室 记录类型 List rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI']; if (rectDpt.size() == 0) { return; } //简档 Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; //用户 User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); insert hpOwner; User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); insert hpOwner2; //医院 Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id); hp.FSE_GI_Main_Leader__c = hpOwner.Id; hp.FSE_SP_Main_Leader__c = hpOwner2.Id; insert hp; //战略科室 Account dc = [select Id, Name, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_GI']; //科室 Account dpt = new Account(RecordTypeId = rectDpt[0].Id); dpt.Name = '*'; dpt.Department_Name__c = 'TestDepart'; dpt.ParentId = dc.Id; dpt.Department_Class__c = dc.Id; dpt.Hospital__c = hp.Id; insert dpt; //科室1 Account dpt1 = new Account(RecordTypeId = rectDpt[0].Id); dpt1.Name = '123'; dpt1.Department_Name__c = 'TestDepart1'; dpt1.ParentId = dc.Id; dpt1.Department_Class__c = dc.Id; dpt1.Hospital__c = hp.Id; insert dpt1; //根据opd计划实施日期 算出本财年 Date dateToday = Date.today(); Integer year = dateToday.year(); Integer month = dateToday.month(); if (month < 4) { year -= 1; } String selectedTab = String.valueOf(year - 1867 - 1 + 'P'); String selectedTab1 = String.valueOf(year - 1867 + 'P'); //今财年 //客户-目标客户 默认让opd计划和客户-目标客户的财年相同 Account_Number_of_target__c anot = new Account_Number_of_target__c(); anot.Account__c = dc.Id; anot.Account_HP__c = hp.Id; anot.OCM_Period__c = selectedTab; anot.Target_amount_170_190__c =36597; anot.OPD_amount_290MiroBF__c =1; anot.OPD_amount_290MiroGI_CF__c =1; insert anot; Account_Number_of_target__c anot1 = new Account_Number_of_target__c(); anot1.Account__c = dc.Id; anot1.Account_HP__c = hp.Id; anot1.OCM_Period__c = selectedTab1; anot1.Target_amount_170_190__c =36597; anot1.OPD_CV290__c =1; anot1.OPD_290Miro__c =1; anot1.OPD_TB__c =1; anot1.Rental_Cnt_CV290__c =1; anot1.Rental_Cnt_TB__c =1; anot1.Target_amount_CV290__c =1; anot1.Target_amount_TB__c =1;//Sales_target_TB__c anot1.Opp_cnt_290MiroGI__c =1; anot1.Opp_cnt_290MiroGI_CF__c =1; anot1.Asset_Cnt_290MiroBF__c =1; anot1.OPD_amount_290MiroBF__c =1; anot1.OPD_amount_290MiroGI_CF__c =1; insert anot1; System.Test.StartTest(); OPDPlan__c oPDPlan0 = new OPDPlan__c(); oPDPlan0.Status__c = '草案中'; oPDPlan0.OPDType__c = '科室'; oPDPlan0.if_OPDTarget__c=1; oPDPlan0.if_HaveSalestarget__c =1; oPDPlan0.Cnt_OPD_ThisYear__c=1; oPDPlan0.Cnt_OPD_LastYear__c=1; oPDPlan0.if_HaveOpportunity__c=1; oPDPlan0.if_HaveEquipment__c =1; oPDPlan0.Cnt_Rentals__c =1; oPDPlan0.PlanProdDetail__c ='CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; oPDPlan0.Account_Laboratory__c =dpt.Id; oPDPlan0.OPDPlan_ImplementDate__c = Date.today(); oPDPlan0.OPDPlan_ImplementDate_temp__c = Date.today(); oPDPlan0.NoOpp_Reason__c = 'HCP对应'; oPDPlan0.RentalReson__c = 'OPD'; // oPDPlan0.OPD_Customers_Target_Last__c=anot.id; // oPDPlan0.OPD_Customers_Target__c =anot1.id; insert oPDPlan0; Attachment attach=new Attachment(); attach.Name='Unit Test Attachment'; Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body'); attach.body=bodyBlob; attach.parentId=oPDPlan0.id; attach.ContentType = 'application/pdf'; String body = 'Unit Test Attachment Body'; String id = String.valueOf(oPDPlan0.id); //Test.startTest(); PageReference page = new PageReference('/apex/OPDNoReportApplication?id='+oPDPlan0.id+'&name=' + oPDPlan0.name); System.Test.setCurrentPage(page); String expectedResult = '您已上传文件成功!';// or false, whatever you expect String result = OPDNoReportApplicationController.testAddAttachment(attach.Name,attach.ContentType, body, id); //Test.stopTest(); System.assertEquals(expectedResult, result); } @isTest static void setupTestData03() { SS_Batch_Column_Mapping__c oppMapping = new SS_Batch_Column_Mapping__c(Name = 'targetKeyProduct', SS_TableName__c='targetKeyProduct__c'); oppMapping.From_Column_001__c = 'OPD_CV290__c'; oppMapping.SS_Column_001__c = 'CV-290'; oppMapping.From_Column_002__c = 'OPD_290Miro__c'; oppMapping.SS_Column_002__c = 'GI-290镜子,GI-290镜子放大,GI-290镜子CF,BF-290镜子'; oppMapping.From_Column_003__c = 'OPD_TB__c'; oppMapping.SS_Column_003__c = 'TB'; oppMapping.From_Column_101__c = 'Rental_Cnt_CV290__c'; oppMapping.SS_Column_101__c = 'CV-290'; oppMapping.From_Column_102__c = 'Rental_Cnt_290MiroGI__c'; oppMapping.SS_Column_102__c = 'GI-290镜子'; oppMapping.From_Column_103__c = 'Rental_Cnt_TB__c'; oppMapping.SS_Column_103__c = 'TB'; oppMapping.From_Column_118__c = 'Sales_target_CV290__c'; oppMapping.SS_Column_118__c = 'CV-290'; oppMapping.From_Column_119__c = 'Sales_target_290Miro__c'; oppMapping.SS_Column_119__c = 'GI-290镜子,GI-290镜子放大,GI-290镜子CF,BF-290镜子'; oppMapping.From_Column_120__c = 'Sales_target_TB__c'; oppMapping.SS_Column_120__c = 'TB'; oppMapping.From_Column_129__c = 'Opp_cnt_290MiroBF__c'; oppMapping.SS_Column_129__c = 'BF-290镜子'; oppMapping.From_Column_130__c = 'Opp_cnt_290MiroGI__c'; oppMapping.SS_Column_130__c = 'GI-290镜子'; oppMapping.From_Column_131__c = 'Opp_cnt_290MiroGI_CF__c'; oppMapping.SS_Column_131__c = 'GI-290镜子CF'; oppMapping.From_Column_146__c = 'Asset_Cnt_290MiroBF__c'; oppMapping.SS_Column_146__c = 'BF-290镜子'; oppMapping.From_Column_147__c = 'Asset_Cnt_290MiroGI__c'; oppMapping.SS_Column_147__c = 'GI-290镜子'; oppMapping.From_Column_148__c = 'Asset_Cnt_290MiroGI_CF__c'; oppMapping.SS_Column_148__c = 'GI-290镜子CF'; oppMapping.From_Column_163__c = 'OPD_amount_290MiroBF__c'; oppMapping.SS_Column_163__c = 'BF-290镜子'; oppMapping.From_Column_164__c = 'OPD_amount_290MiroGI__c'; oppMapping.SS_Column_164__c = 'GI-290镜子'; oppMapping.From_Column_165__c = 'OPD_amount_290MiroGI_CF__c'; oppMapping.SS_Column_165__c = 'GI-290镜子CF'; insert new SS_Batch_Column_Mapping__c[] {oppMapping}; //医院 记录类型 List rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP']; if (rectHp.size() == 0) { return; } //科室 记录类型 List rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI']; if (rectDpt.size() == 0) { return; } //简档 Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; //用户 User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); insert hpOwner; User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); insert hpOwner2; //医院 Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id); hp.FSE_GI_Main_Leader__c = hpOwner.Id; hp.FSE_SP_Main_Leader__c = hpOwner2.Id; insert hp; //战略科室 Account dc = [select Id, Name, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_GI']; //科室 Account dpt = new Account(RecordTypeId = rectDpt[0].Id); dpt.Name = '*'; dpt.Department_Name__c = 'TestDepart'; dpt.ParentId = dc.Id; dpt.Department_Class__c = dc.Id; dpt.Hospital__c = hp.Id; insert dpt; //科室1 Account dpt1 = new Account(RecordTypeId = rectDpt[0].Id); dpt1.Name = '123'; dpt1.Department_Name__c = 'TestDepart1'; dpt1.ParentId = dc.Id; dpt1.Department_Class__c = dc.Id; dpt1.Hospital__c = hp.Id; insert dpt1; //根据opd计划实施日期 算出本财年 Date dateToday = Date.today(); Integer year = dateToday.year(); Integer month = dateToday.month(); if (month < 4) { year -= 1; } String selectedTab = String.valueOf(year - 1867 - 1 + 'P'); String selectedTab1 = String.valueOf(year - 1867 + 'P'); //今财年 //客户-目标客户 默认让opd计划和客户-目标客户的财年相同 Account_Number_of_target__c anot = new Account_Number_of_target__c(); anot.Account__c = dc.Id; anot.Account_HP__c = hp.Id; anot.OCM_Period__c = selectedTab; anot.Target_amount_170_190__c =36597; anot.OPD_amount_290MiroBF__c =1; anot.OPD_amount_290MiroGI_CF__c =1; insert anot; Account_Number_of_target__c anot1 = new Account_Number_of_target__c(); anot1.Account__c = dc.Id; anot1.Account_HP__c = hp.Id; anot1.OCM_Period__c = selectedTab1; anot1.Target_amount_170_190__c =36597; anot1.OPD_CV290__c =1; anot1.OPD_290Miro__c =1; anot1.OPD_TB__c =1; anot1.Rental_Cnt_CV290__c =1; anot1.Rental_Cnt_TB__c =1; anot1.Target_amount_CV290__c =1; anot1.Target_amount_TB__c =1;//Sales_target_TB__c anot1.Opp_cnt_290MiroGI__c =1; anot1.Opp_cnt_290MiroGI_CF__c =1; anot1.Asset_Cnt_290MiroBF__c =1; anot1.OPD_amount_290MiroBF__c =1; anot1.OPD_amount_290MiroGI_CF__c =1; insert anot1; OPDPlan__c oPDPlan = new OPDPlan__c(); oPDPlan.Status__c = '草案中'; oPDPlan.OPDType__c = '学会'; oPDPlan.if_OPDTarget__c=1; oPDPlan.if_HaveSalestarget__c =1; oPDPlan.Cnt_OPD_ThisYear__c=1; oPDPlan.Cnt_OPD_LastYear__c=1; oPDPlan.if_HaveOpportunity__c=1; oPDPlan.if_HaveEquipment__c =1; oPDPlan.Cnt_Rentals__c =1; oPDPlan.PlanProdDetail__c ='CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; oPDPlan.Account_Laboratory__c =dpt.Id; oPDPlan.OPDPlan_ImplementDate__c = Date.today(); oPDPlan.OPDPlan_ImplementDate_temp__c = Date.today(); oPDPlan.NoOpp_Reason__c = 'HCP对应'; oPDPlan.RentalReson__c = 'OPD'; //oPDPlan.AdditionalSupport__c=oPDPlan.id; oPDPlan.OPD_Customers_Target__c =anot1.id; insert oPDPlan; System.Test.StartTest(); OPDPlan__c oPDPlan0 = new OPDPlan__c(); oPDPlan0.Status__c = '草案中'; oPDPlan0.OPDType__c = '学会'; oPDPlan0.if_OPDTarget__c=1; oPDPlan0.if_HaveSalestarget__c =1; oPDPlan0.Cnt_OPD_ThisYear__c=1; oPDPlan0.Cnt_OPD_LastYear__c=1; oPDPlan0.if_HaveOpportunity__c=1; oPDPlan0.if_HaveEquipment__c =1; oPDPlan0.Cnt_Rentals__c =1; oPDPlan0.PlanProdDetail__c ='CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; oPDPlan0.Account_Laboratory__c =dpt.Id; oPDPlan0.OPDPlan_ImplementDate__c = Date.today(); oPDPlan0.OPDPlan_ImplementDate_temp__c = Date.today(); oPDPlan0.NoOpp_Reason__c = 'HCP对应'; oPDPlan0.RentalReson__c = 'OPD'; //oPDPlan0.AdditionalSupport__c=oPDPlan.id; oPDPlan0.OPD_Customers_Target__c =anot1.id; insert oPDPlan0; Attachment attach=new Attachment(); attach.Name='Unit Test Attachment'; Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body'); attach.body=bodyBlob; attach.parentId=oPDPlan0.id; attach.ContentType = 'application/pdf'; String body = 'Unit Test Attachment Body'; String id = String.valueOf(oPDPlan0.id); //Test.startTest(); PageReference page = new PageReference('/apex/OPDNoReportApplication?id='+oPDPlan0.id+'&name=' + oPDPlan0.name); System.Test.setCurrentPage(page); String expectedResult = '您已上传文件成功!';// or false, whatever you expect String result = OPDNoReportApplicationController.testAddAttachment(attach.Name,attach.ContentType, body, id); //Test.stopTest(); System.assertEquals(expectedResult, result); } @isTest static void setupTestData04() { SS_Batch_Column_Mapping__c oppMapping = new SS_Batch_Column_Mapping__c(Name = 'targetKeyProduct', SS_TableName__c='targetKeyProduct__c'); oppMapping.From_Column_001__c = 'OPD_CV290__c'; oppMapping.SS_Column_001__c = 'CV-290'; oppMapping.From_Column_002__c = 'OPD_290Miro__c'; oppMapping.SS_Column_002__c = 'GI-290镜子,GI-290镜子放大,GI-290镜子CF,BF-290镜子'; oppMapping.From_Column_003__c = 'OPD_TB__c'; oppMapping.SS_Column_003__c = 'TB'; oppMapping.From_Column_101__c = 'Rental_Cnt_CV290__c'; oppMapping.SS_Column_101__c = 'CV-290'; oppMapping.From_Column_102__c = 'Rental_Cnt_290MiroGI__c'; oppMapping.SS_Column_102__c = 'GI-290镜子'; oppMapping.From_Column_103__c = 'Rental_Cnt_TB__c'; oppMapping.SS_Column_103__c = 'TB'; oppMapping.From_Column_118__c = 'Sales_target_CV290__c'; oppMapping.SS_Column_118__c = 'CV-290'; oppMapping.From_Column_119__c = 'Sales_target_290Miro__c'; oppMapping.SS_Column_119__c = 'GI-290镜子,GI-290镜子放大,GI-290镜子CF,BF-290镜子'; oppMapping.From_Column_120__c = 'Sales_target_TB__c'; oppMapping.SS_Column_120__c = 'TB'; oppMapping.From_Column_129__c = 'Opp_cnt_290MiroBF__c'; oppMapping.SS_Column_129__c = 'BF-290镜子'; oppMapping.From_Column_130__c = 'Opp_cnt_290MiroGI__c'; oppMapping.SS_Column_130__c = 'GI-290镜子'; oppMapping.From_Column_131__c = 'Opp_cnt_290MiroGI_CF__c'; oppMapping.SS_Column_131__c = 'GI-290镜子CF'; oppMapping.From_Column_146__c = 'Asset_Cnt_290MiroBF__c'; oppMapping.SS_Column_146__c = 'BF-290镜子'; oppMapping.From_Column_147__c = 'Asset_Cnt_290MiroGI__c'; oppMapping.SS_Column_147__c = 'GI-290镜子'; oppMapping.From_Column_148__c = 'Asset_Cnt_290MiroGI_CF__c'; oppMapping.SS_Column_148__c = 'GI-290镜子CF'; oppMapping.From_Column_163__c = 'OPD_amount_290MiroBF__c'; oppMapping.SS_Column_163__c = 'BF-290镜子'; oppMapping.From_Column_164__c = 'OPD_amount_290MiroGI__c'; oppMapping.SS_Column_164__c = 'GI-290镜子'; oppMapping.From_Column_165__c = 'OPD_amount_290MiroGI_CF__c'; oppMapping.SS_Column_165__c = 'GI-290镜子CF'; insert new SS_Batch_Column_Mapping__c[] {oppMapping}; //医院 记录类型 List rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP']; if (rectHp.size() == 0) { return; } //科室 记录类型 List rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI']; if (rectDpt.size() == 0) { return; } //简档 Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; //用户 User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); insert hpOwner; User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); insert hpOwner2; //医院 Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id); hp.FSE_GI_Main_Leader__c = hpOwner.Id; hp.FSE_SP_Main_Leader__c = hpOwner2.Id; insert hp; //战略科室 Account dc = [select Id, Name, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_GI']; //科室 Account dpt = new Account(RecordTypeId = rectDpt[0].Id); dpt.Name = '*'; dpt.Department_Name__c = 'TestDepart'; dpt.ParentId = dc.Id; dpt.Department_Class__c = dc.Id; dpt.Hospital__c = hp.Id; insert dpt; //科室1 Account dpt1 = new Account(RecordTypeId = rectDpt[0].Id); dpt1.Name = '123'; dpt1.Department_Name__c = 'TestDepart1'; dpt1.ParentId = dc.Id; dpt1.Department_Class__c = dc.Id; dpt1.Hospital__c = hp.Id; insert dpt1; //根据opd计划实施日期 算出本财年 Date dateToday = Date.today(); Integer year = dateToday.year(); Integer month = dateToday.month(); if (month < 4) { year -= 1; } String selectedTab = String.valueOf(year - 1867 - 1 + 'P'); String selectedTab1 = String.valueOf(year - 1867 + 'P'); //今财年 //客户-目标客户 默认让opd计划和客户-目标客户的财年相同 Account_Number_of_target__c anot = new Account_Number_of_target__c(); anot.Account__c = dc.Id; anot.Account_HP__c = hp.Id; anot.OCM_Period__c = selectedTab; anot.Target_amount_170_190__c =36597; anot.OPD_amount_290MiroBF__c =1; anot.OPD_amount_290MiroGI_CF__c =1; insert anot; Account_Number_of_target__c anot1 = new Account_Number_of_target__c(); anot1.Account__c = dc.Id; anot1.Account_HP__c = hp.Id; anot1.OCM_Period__c = selectedTab1; anot1.Target_amount_170_190__c =36597; anot1.OPD_CV290__c =1; anot1.OPD_290Miro__c =1; anot1.OPD_TB__c =1; anot1.Rental_Cnt_CV290__c =1; anot1.Rental_Cnt_TB__c =1; anot1.Target_amount_CV290__c =1; anot1.Target_amount_TB__c =1;//Sales_target_TB__c anot1.Opp_cnt_290MiroGI__c =1; anot1.Opp_cnt_290MiroGI_CF__c =1; anot1.Asset_Cnt_290MiroBF__c =1; anot1.OPD_amount_290MiroBF__c =1; anot1.OPD_amount_290MiroGI_CF__c =1; insert anot1; OPDPlan__c oPDPlan = new OPDPlan__c(); oPDPlan.Status__c = '草案中'; oPDPlan.OPDType__c = '学会'; oPDPlan.if_OPDTarget__c=1; oPDPlan.if_HaveSalestarget__c =1; oPDPlan.Cnt_OPD_ThisYear__c=1; oPDPlan.Cnt_OPD_LastYear__c=1; oPDPlan.if_HaveOpportunity__c=1; oPDPlan.if_HaveEquipment__c =1; oPDPlan.Cnt_Rentals__c =1; oPDPlan.PlanProdDetail__c ='CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; oPDPlan.Account_Laboratory__c =dpt.Id; oPDPlan.OPDPlan_ImplementDate__c = Date.today(); oPDPlan.OPDPlan_ImplementDate_temp__c = Date.today(); oPDPlan.NoOpp_Reason__c = 'HCP对应'; oPDPlan.RentalReson__c = 'OPD'; // oPDPlan.AdditionalSupport__c=anot.id; // oPDPlan0.OPD_Customers_Target__c =anot1.id; insert oPDPlan; System.Test.StartTest(); OPDPlan__c oPDPlan0 = new OPDPlan__c(); oPDPlan0.Status__c = '草案中'; oPDPlan0.OPDType__c = '学会'; oPDPlan0.if_OPDTarget__c=1; oPDPlan0.if_HaveSalestarget__c =1; oPDPlan0.Cnt_OPD_ThisYear__c=1; oPDPlan0.Cnt_OPD_LastYear__c=1; oPDPlan0.if_HaveOpportunity__c=1; oPDPlan0.if_HaveEquipment__c =1; oPDPlan0.Cnt_Rentals__c =1; oPDPlan0.PlanProdDetail__c ='CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; oPDPlan0.Account_Laboratory__c =dpt.Id; oPDPlan0.OPDPlan_ImplementDate__c = Date.today(); oPDPlan0.OPDPlan_ImplementDate_temp__c = Date.today(); oPDPlan0.NoOpp_Reason__c = 'HCP对应'; oPDPlan0.RentalReson__c = 'OPD'; // oPDPlan0.AdditionalSupport__c=oPDPlan.id; oPDPlan0.RentalResonTemp__c = '对应修理'; oPDPlan0.CorrespondingRepairNo__c = null; // oPDPlan0.OPD_Customers_Target__c =anot1.id; insert oPDPlan0; Attachment attach=new Attachment(); attach.Name='Unit Test Attachment'; Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body'); attach.body=bodyBlob; attach.parentId=oPDPlan0.id; attach.ContentType = 'application/pdf'; String body = 'Unit Test Attachment Body'; String id = String.valueOf(oPDPlan0.id); //Test.startTest(); PageReference page = new PageReference('/apex/OPDNoReportApplication?id='+oPDPlan0.id+'&name=' + oPDPlan0.name); System.Test.setCurrentPage(page); String expectedResult = '您已上传文件成功!';// or false, whatever you expect String result = OPDNoReportApplicationController.testAddAttachment(attach.Name,attach.ContentType, body, id); //Test.stopTest(); System.assertEquals(expectedResult, result); } static testMethod void setupTestData05() { SS_Batch_Column_Mapping__c oppMapping = new SS_Batch_Column_Mapping__c(Name = 'targetKeyProduct', SS_TableName__c='targetKeyProduct__c'); oppMapping.From_Column_001__c = 'OPD_CV290__c'; oppMapping.SS_Column_001__c = 'CV-290'; oppMapping.From_Column_002__c = 'OPD_290Miro__c'; oppMapping.SS_Column_002__c = 'GI-290镜子,GI-290镜子放大,GI-290镜子CF,BF-290镜子'; oppMapping.From_Column_003__c = 'OPD_TB__c'; oppMapping.SS_Column_003__c = 'TB'; oppMapping.From_Column_101__c = 'Rental_Cnt_CV290__c'; oppMapping.SS_Column_101__c = 'CV-290'; oppMapping.From_Column_102__c = 'Rental_Cnt_290MiroGI__c'; oppMapping.SS_Column_102__c = 'GI-290镜子'; oppMapping.From_Column_103__c = 'Rental_Cnt_TB__c'; oppMapping.SS_Column_103__c = 'TB'; oppMapping.From_Column_118__c = 'Sales_target_CV290__c'; oppMapping.SS_Column_118__c = 'CV-290'; oppMapping.From_Column_119__c = 'Sales_target_290Miro__c'; oppMapping.SS_Column_119__c = 'GI-290镜子,GI-290镜子放大,GI-290镜子CF,BF-290镜子'; oppMapping.From_Column_120__c = 'Sales_target_TB__c'; oppMapping.SS_Column_120__c = 'TB'; oppMapping.From_Column_129__c = 'Opp_cnt_290MiroBF__c'; oppMapping.SS_Column_129__c = 'BF-290镜子'; oppMapping.From_Column_130__c = 'Opp_cnt_290MiroGI__c'; oppMapping.SS_Column_130__c = 'GI-290镜子'; oppMapping.From_Column_131__c = 'Opp_cnt_290MiroGI_CF__c'; oppMapping.SS_Column_131__c = 'GI-290镜子CF'; oppMapping.From_Column_146__c = 'Asset_Cnt_290MiroBF__c'; oppMapping.SS_Column_146__c = 'BF-290镜子'; oppMapping.From_Column_147__c = 'Asset_Cnt_290MiroGI__c'; oppMapping.SS_Column_147__c = 'GI-290镜子'; oppMapping.From_Column_148__c = 'Asset_Cnt_290MiroGI_CF__c'; oppMapping.SS_Column_148__c = 'GI-290镜子CF'; oppMapping.From_Column_163__c = 'OPD_amount_290MiroBF__c'; oppMapping.SS_Column_163__c = 'BF-290镜子'; oppMapping.From_Column_164__c = 'OPD_amount_290MiroGI__c'; oppMapping.SS_Column_164__c = 'GI-290镜子'; oppMapping.From_Column_165__c = 'OPD_amount_290MiroGI_CF__c'; oppMapping.SS_Column_165__c = 'GI-290镜子CF'; insert new SS_Batch_Column_Mapping__c[] {oppMapping}; //医院 记录类型 List rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP']; if (rectHp.size() == 0) { return; } //科室 记录类型 List rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI']; if (rectDpt.size() == 0) { return; } //简档 Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; //用户 User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); insert hpOwner; User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); insert hpOwner2; //医院 Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id); hp.FSE_GI_Main_Leader__c = hpOwner.Id; hp.FSE_SP_Main_Leader__c = hpOwner2.Id; insert hp; //战略科室 Account dc = [select Id, Name, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_GI']; //科室 Account dpt = new Account(RecordTypeId = rectDpt[0].Id); dpt.Name = '*'; dpt.Department_Name__c = 'TestDepart'; dpt.ParentId = dc.Id; dpt.Department_Class__c = dc.Id; dpt.Hospital__c = hp.Id; insert dpt; //科室1 Account dpt1 = new Account(RecordTypeId = rectDpt[0].Id); dpt1.Name = '123'; dpt1.Department_Name__c = 'TestDepart1'; dpt1.ParentId = dc.Id; dpt1.Department_Class__c = dc.Id; dpt1.Hospital__c = hp.Id; insert dpt1; //根据opd计划实施日期 算出本财年 Date dateToday = Date.today(); Integer year = dateToday.year(); Integer month = dateToday.month(); if (month < 4) { year -= 1; } String selectedTab = String.valueOf(year - 1867 - 1 + 'P'); String selectedTab1 = String.valueOf(year - 1867 + 'P'); //今财年 //客户-目标客户 默认让opd计划和客户-目标客户的财年相同 Account_Number_of_target__c anot = new Account_Number_of_target__c(); anot.Account__c = dc.Id; anot.Account_HP__c = hp.Id; anot.OCM_Period__c = selectedTab; anot.Target_amount_170_190__c =36597; anot.OPD_amount_290MiroBF__c =1; anot.OPD_amount_290MiroGI_CF__c =1; insert anot; Account_Number_of_target__c anot1 = new Account_Number_of_target__c(); anot1.Account__c = dc.Id; anot1.Account_HP__c = hp.Id; anot1.OCM_Period__c = selectedTab1; anot1.Target_amount_170_190__c =36597; anot1.OPD_CV290__c =1; anot1.OPD_290Miro__c =1; anot1.OPD_TB__c =1; anot1.Rental_Cnt_CV290__c =1; anot1.Rental_Cnt_TB__c =1; anot1.Target_amount_CV290__c =1; anot1.Target_amount_TB__c =1;//Sales_target_TB__c anot1.Opp_cnt_290MiroGI__c =1; anot1.Opp_cnt_290MiroGI_CF__c =1; anot1.Asset_Cnt_290MiroBF__c =1; anot1.OPD_amount_290MiroBF__c =1; anot1.OPD_amount_290MiroGI_CF__c =1; insert anot1; // 产品 Product2 pro5 = new Product2(Name='name05',IsActive=true,Family='SP', Fixture_Model_No__c='n05',Serial_Lot_No__c='S/N tracing', Fixture_Model_No_T__c = 'n05', ProductCode_Ext__c='pc05',Manual_Entry__c=false); insert pro5; System.Test.StartTest(); OPDPlan__c oPDPlan0 = new OPDPlan__c(); oPDPlan0.Status__c = '草案中'; oPDPlan0.OPDType__c = '科室'; oPDPlan0.if_OPDTarget__c=1; oPDPlan0.if_HaveSalestarget__c =1; oPDPlan0.Cnt_OPD_ThisYear__c=1; oPDPlan0.Cnt_OPD_LastYear__c=1; oPDPlan0.if_HaveOpportunity__c=1; oPDPlan0.if_HaveEquipment__c =1; oPDPlan0.Cnt_Rentals__c =1; oPDPlan0.PlanProdDetail__c ='CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; oPDPlan0.Account_Laboratory__c =dpt.Id; oPDPlan0.OPDPlan_ImplementDate__c = Date.today(); oPDPlan0.OPDPlan_ImplementDate_temp__c = Date.today(); oPDPlan0.NoOpp_Reason__c = 'HCP对应'; oPDPlan0.RentalReson__c = '无法进入手术室'; oPDPlan0.AttachmentCertificate__c = '0001.png'; oPDPlan0.ModelLendingProduct__c=pro5.id; //oPDPlan0.CorrespondingRepairNo__c =anot1.id; insert oPDPlan0; Attachment attach1=new Attachment(); attach1.Name='Unit Test Attachment'; Blob bodyBlob1=Blob.valueOf('Unit Test Attachment Body'); attach1.body=bodyBlob1; attach1.ContentType = 'application/pdf'; PageReference page = new PageReference('/apex/OPDNoReportApplication?id='+oPDPlan0.id+'&name=' + oPDPlan0.name); System.Test.setCurrentPage(page); OPDNoReportApplicationController opd = new OPDNoReportApplicationController(); //初始化测试 opd.init(); //获取选项列表测试 opd.getRentalReson(); //保存测试 opd.IsUpload =false; opd.IsHavFile =false; oPDPlan0.RentalResonTemp__c = '无法进入手术室'; //oPDPlan0.ModelLendingProductCode__c = 'test0001'; opd.opdPlan = oPDPlan0; opd.ModelLendingProductId = pro5.id; //保存 opd.Save(); //提交待审批 opd.CommitNeedApproval(); System.Test.StopTest(); } }