@isTest private class OPDPlanHandlerTest { static testMethod void updaue() { //OPDPlanHandler.test(); // 2020-10-30 mzy add start // 病院を作る Account hospital = new Account(); hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id; hospital.Name = 'test hospital'; insert hospital; // 戦略科室を得る List strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI']; // 診療科を作る Account dep = new Account(); dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id; dep.Name = 'test dep'; dep.ParentId = strategicDep[0].Id; dep.Department_Class__c = strategicDep[0].Id; dep.Hospital__c = hospital.Id; insert dep; // 2020-10-30 mzy add end Event insertTarget = new Event(); ApexPages.StandardController sc = new ApexPages.standardController( insertTarget); //SimpleEventRegisterController target = new SimpleEventRegisterController( sc); /*target.targetEvent.Subject = 'test'; //主题 target.targetEvent.StartDateTime = Datetime.now().addDays(1); //开始日期 target.targetEvent.DurationInMinutes = 60; //持续时间 target.targetEvent.Activity_Type2__c = '病院'; //拜访区分 target.targetEvent.Activity_PurposeFSE__c = '客户培训'; //拜访目的 target.targetEvent.OPDPlan_Flag__c = true ; //OPD计划 target.targetEvent.Location = dep.Name; //科室*/ //target.init(); //2020/10/29 MZY start Map tempMap = new Map(); tempMap.put('GI-290镜子', '1'); tempMap.put('EU-ME2', '2'); tempMap.put('OTV-S300', '4'); //target.planProducts = tempMap; //计划出借备品 //target.targetEvent.noOpp_Reason__c = 'HCP对应'; //无询价申请理由 //2020/10/29 MZY end //target.init(); // target.saveAndNew(); //2020/10/30 mzy start //insert target.targetEvent; // target.saveOPDPlan(target.targetEvent); //2020/10/30 mzy end /** List opdList = [select id,OPDPlan_ImplementDate__c from OPDPlan__c]; System.assertEquals(1, opdList.size()); List eveist = [select id,StartDateTime from Event where Subject = 'test']; System.assertEquals(1, eveist.size()); opdList[0].OPDPlan_ImplementDate__c = opdList[0].OPDPlan_ImplementDate__c.addDays(3); update opdList; eveist = [select id,StartDateTime from Event where Subject = 'test']; System.assertEquals(2, eveist.size()); OPDPlan__c oPDPlan1 = new OPDPlan__c(); oPDPlan1.ThisMonthPlan__c = 1; oPDPlan1.Status__c = '草案中'; oPDPlan1.OPD_Customers_Target_Last__c=null; oPDPlan1.OPDPlan_ImplementDate__c = Date.today(); oPDPlan1.NoOpp_Reason__c = 'HCP对应'; insert oPDPlan1; oPDPlan1.OPDPlan_ImplementDate__c = oPDPlan1.OPDPlan_ImplementDate__c.addDays(3); update oPDPlan1; **/ } //static testMethod void cancle() { // Event insertTarget = new Event(); // ApexPages.StandardController sc = new ApexPages.standardController( insertTarget); // SimpleEventRegisterController target = new SimpleEventRegisterController( sc); // target.targetEvent.Subject = 'test'; // target.targetEvent.StartDateTime = Datetime.now().addDays(1); // target.targetEvent.DurationInMinutes = 10; // target.targetEvent.Activity_Type2__c = '販売店 '; // target.targetEvent.Activity_PurposeFSE__c = '其他'; // target.targetEvent.OPDPlan_Flag__c = true ; // target.init(); // target.saveAndNew(); // List opdList = [select id,Status__c from OPDPlan__c]; // System.assertEquals(1, opdList.size()); // if(opdList.size() == 1){ // opdList[0].Status__c = '取消'; // update opdList; // } // List eveist = [select id,StartDateTime from Event]; // System.assertEquals(0, eveist.size()); //} // 2020/10/29 mzy 推广经理赋值 SFDC-BUF6LN add start static testMethod void updateMngTest() { // OPDPlanHandler.test(); // OPDPlan__c OPDPlan01 = new OPDPlan__c(); // OPDPlan01.Status__c = '提交'; // OPDPlan01.NoOpp_Reason__c= 'HCP对应'; // OPDPlan01.OPDType__c = '事件'; // insert OPDPlan01; //用户 // Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; // User hpOwner = new User(Test_staff__c = true, LastName = 'hp1', 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 = 'hp21', 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; OPDPlan__c OPDPlan02 = new OPDPlan__c(); OPDPlan02.Status__c = '草案中'; OPDPlan02.NoOpp_Reason__c= 'HCP对应'; OPDPlan02.OPDType__c = '询价'; oPDPlan02.noReportStatus__c = '已保存'; // oPDPlan02.SalesManager__c = hpOwner.id; // oPDPlan02.BuchangApprovalManagerSales__c = hpOwner2.id; insert OPDPlan02; OPDPlan02.Status__c = '提交'; oPDPlan02.noReportStatus__c = '提交'; // update OPDPlan02; /** OPDPlan__c OPDPlan03 = new OPDPlan__c(); OPDPlan03.id = OPDPlan02.id; OPDPlan03.Status__c = '提交'; update OPDPlan03; **/ } // 2020/1029 mzy 推广经理赋值 SFDC-BUF6LN add end //start SWAG-BSC5WP 20201106 you private static integer FIELDMAX = 200; static testMethod void setupTestData() { Oly_TriggerHandler.bypass('ContactTrigger'); Oly_TriggerHandler.bypass('ContactTriggerHandler'); Oly_TriggerHandler.bypass('AssetTrigger'); Oly_TriggerHandler.bypass('MaintenanceContractTrigger'); Oly_TriggerHandler.bypass('MaintenanceContractAfterUpdate'); Oly_TriggerHandler.bypass('MaintenanceContractBeforeDelete'); Oly_TriggerHandler.bypass('MaintenanceContractHpDeptUpd'); Oly_TriggerHandler.bypass('NFM106Controller'); Oly_TriggerHandler.bypass('NFM106Trigger'); Oly_TriggerHandler.bypass('AssetRecordTypeUpd'); Oly_TriggerHandler.bypass('NFM101Controller'); Oly_TriggerHandler.bypass('NFM001Controller'); Oly_TriggerHandler.bypass('SyncProduct2'); Oly_TriggerHandler.bypass('RentalApplyBeforeUpdate'); Oly_TriggerHandler.bypass('ContactTriggerHandler'); Oly_TriggerHandler.bypass('CancelPostponePlanHandler'); StaticParameter.ContentDocumentLink = false; StaticParameter.OPDPlanUp = true; Test.startTest(); 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镜子'; 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镜子放大'; 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}; //简档 Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; //用户 User hpOwner = new User(Test_staff__c = true, LastName = 'hp',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', 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 = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId(), 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 = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_GI').getRecordTypeId()); 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 = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_GI').getRecordTypeId()); 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 oPDPlan3 = new OPDPlan__c(); oPDPlan3.ThisMonthPlan__c = 1; oPDPlan3.Status__c = '计划中'; oPDPlan3.Account_Laboratory__c =dpt.Id; oPDPlan3.OPD_Customers_Target_Last__c=null; oPDPlan3.OPDPlan_ImplementDate__c = Date.today().addDays(3); oPDPlan3.NoOpp_Reason__c = 'HCP对应'; OPDPlan3.OPDType__c = '学会'; insert oPDPlan3; //2021-06-26 mzy add OPDPlan__c oPDPlan4 = new OPDPlan__c(); oPDPlan4.Status__c = '草案中'; oPDPlan4.Account_Laboratory__c =dpt.Id; oPDPlan4.OPDPlan_ImplementDate__c = Date.today(); oPDPlan4.NoOpp_Reason__c = 'HCP对应'; oPDPlan4.if_OPDTarget__c=1; oPDPlan4.if_HaveSalestarget__c =1; oPDPlan4.Cnt_OPD_ThisYear__c=1; oPDPlan4.Cnt_OPD_LastYear__c=1; oPDPlan4.if_HaveOpportunity__c=1; oPDPlan4.if_HaveEquipment__c =1; oPDPlan4.Cnt_Rentals__c =1; oPDPlan4.OPD_Customers_Target_Last__c=anot.id; oPDPlan4.OPD_Customers_Target__c =anot1.id; oPDPlan4.PlanProdDetail__c ='CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; oPDPlan4.OPDType__c = '学会'; oPDPlan4.AttachmentCertificate__c = '0001.png'; insert oPDPlan4; //取消 CancelPostponePlan__c tempCancelPostponePlan = new CancelPostponePlan__c(); tempCancelPostponePlan.Status__c = '取消成功'; tempCancelPostponePlan.CancelOPDPlan__c = oPDPlan4.Id; tempCancelPostponePlan.RecordTypeId = '012C80000000NGo'; tempCancelPostponePlan.cancelReasonCombobox__c = '备品不足'; insert tempCancelPostponePlan; oPDPlan4 = [select id,DelayCancel_Reason__c,Status__c from OPDPlan__c where id = :oPDPlan4.Id]; //System.assertEquals('',oPDPlan4.Status__c); //System.assertEquals('',oPDPlan4.DelayCancel_Reason__c); OPDPlan__c oPDPlan5 = new OPDPlan__c(); oPDPlan5.Status__c = '草案中'; oPDPlan5.Account_Laboratory__c =dpt.Id; oPDPlan5.OPDPlan_ImplementDate__c = Date.today(); oPDPlan5.NoOpp_Reason__c = 'HCP对应'; oPDPlan5.if_OPDTarget__c=1; oPDPlan5.if_HaveSalestarget__c =1; oPDPlan5.Cnt_OPD_ThisYear__c=1; oPDPlan5.Cnt_OPD_LastYear__c=1; oPDPlan5.if_HaveOpportunity__c=1; oPDPlan5.if_HaveEquipment__c =1; oPDPlan5.Cnt_Rentals__c =1; oPDPlan5.OPD_Customers_Target_Last__c=anot.id; oPDPlan5.OPD_Customers_Target__c =anot1.id; oPDPlan5.PlanProdDetail__c ='CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; oPDPlan5.OriginalOpdPlan__c = oPDPlan4.Id; // oPDPlan5.OriginalOpdPlan__c = 'a3E10000000S7pdEAC'; oPDPlan5.OPDType__c = '学会'; ContentVersion version = new ContentVersion( Title = 'A-65224941-20200923--1.docx', VersionData = EncodingUtil.base64Decode('test'), ContentLocation = 's', PathOnClient = 'test.txt' ); insert version; // version = [select ContentDocumentId from ContentVersion where Id =: version.Id]; // ContentDocumentLink link = new ContentDocumentLink(); // link.ContentDocumentId = version.ContentDocumentId; // link.LinkedEntityId = oPDPlan4.Id; // link.ShareType = 'V'; // link.Visibility = 'AllUsers'; // insert link; // insert oPDPlan5; //2021-06-29 mzy add Test.stopTest(); } //end SWAG-BSC5WP 20201106 you //2021-06-26 mzy start static testMethod void updaueOpd() { // 病院を作る Account hospital = new Account(); hospital.recordtypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId(); hospital.Name = 'test hospital'; insert hospital; // 戦略科室を得る List 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 dep'; dep.ParentId = strategicDep[0].Id; dep.Department_Class__c = strategicDep[0].Id; dep.Hospital__c = hospital.Id; insert dep; // RecordType mainTaskrecId =Schema.SObjectType.task__c.getRecordTypeInfosByDeveloperName().get('OPD').getRecordTypeId(); task__c task = new task__c(); task.RecordTypeId = Schema.SObjectType.task__c.getRecordTypeInfosByDeveloperName().get('OPD').getRecordTypeId(); task.taskDifferent__c = '被动任务'; task.taskStatus__c = '01 分配'; task.Activity_Date__c = Date.newInstance(2021, 7, 17); task.account__c = dep.Id; insert task; OPDPlan__c oPDPlan0 = new OPDPlan__c(); oPDPlan0.Status__c = '审批中'; oPDPlan0.OPDType__c = '事件'; oPDPlan0.PlanProdDetail__c ='CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; oPDPlan0.Account_Laboratory__c =dep.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.Task_ID__c = task.Id; insert oPDPlan0; Event insertTarget = new Event(); insertTarget.Subject = 'test00'; insertTarget.StartDateTime = Datetime.now().adddays(2); insertTarget.DurationInMinutes = 60; insertTarget.Location = 'testLocation'; insertTarget.whatid__c = dep.Id; insertTarget.Activity_Type2__c = '病院'; insertTarget.OPDPlan_Flag__c = true ; insertTarget.Opd_Plan__c = oPDPlan0.Id; insertTarget.Task_ID__c = task.Id; insertTarget.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; insertTarget.eventStatus__c = '02 接受'; insert insertTarget; OPDPlan__C opd = [SELECT Id,OPDPlan_ImplementDate__c FROM OPDPlan__C WHERE id =: oPDPlan0.Id]; opd.OPDPlan_ImplementDate__c = opd.OPDPlan_ImplementDate__c.addDays(5); update opd; opd.OPDPlan_ImplementDate__c = opd.OPDPlan_ImplementDate__c.addDays(-5); update opd; oPDPlan0.Status__c = '完毕'; update oPDPlan0; } //2021-06-26 mzy end //start SWAG-BSC5WP 20201106 you static testMethod void setupTestDatabak() { Oly_TriggerHandler.bypass('OPDPlanUp'); Oly_TriggerHandler.bypass('ContactTrigger'); Oly_TriggerHandler.bypass('ContactTrigger'); Oly_TriggerHandler.bypass('ContactTriggerHandler'); Oly_TriggerHandler.bypass('AssetTrigger'); Oly_TriggerHandler.bypass('MaintenanceContractTrigger'); Oly_TriggerHandler.bypass('MaintenanceContractAfterUpdate'); Oly_TriggerHandler.bypass('MaintenanceContractBeforeDelete'); Oly_TriggerHandler.bypass('MaintenanceContractHpDeptUpd'); Oly_TriggerHandler.bypass('NFM106Controller'); Oly_TriggerHandler.bypass('NFM106Trigger'); Oly_TriggerHandler.bypass('AssetRecordTypeUpd'); Oly_TriggerHandler.bypass('NFM101Controller'); Oly_TriggerHandler.bypass('NFM001Controller'); Oly_TriggerHandler.bypass('SyncProduct2'); Oly_TriggerHandler.bypass('RentalApplyBeforeUpdate'); Oly_TriggerHandler.bypass('ContactTriggerHandler'); StaticParameter.ContentDocumentLink = false; StaticParameter.OPDPlanUp = true; Test.startTest(); 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}; //简档 Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; //用户 User hpOwner = new User(Test_staff__c = true, LastName = 'hp', 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', 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 = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId(), 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 = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_GI').getRecordTypeId()); 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 = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_GI').getRecordTypeId()); 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; //2021-06-26 mzy add Test.stopTest(); } static testMethod void newOPDPlanOne(){ setupTestDatabak(); List depList = [SELECT Id FROM Account WHERE RecordTypeId = :Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_GI').getRecordTypeId() LIMIT 1 ]; 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 = depList[0].Id; oPDPlan0.OPDPlan_ImplementDate__c = Date.today(); oPDPlan0.OPDPlan_ImplementDate_temp__c = Date.today(); oPDPlan0.NoOpp_Reason__c = 'HCP对应'; // oPDPlan0.OPD_Customers_Target_Last__c=anot.id; // oPDPlan0.OPD_Customers_Target__c =anot1.id; insert oPDPlan0; OPDPlan__c oPDPlan1 = new OPDPlan__c(); oPDPlan1.ThisMonthPlan__c = 1; oPDPlan1.Status__c = '草案中'; oPDPlan1.Account_Laboratory__c = depList[0].Id; oPDPlan1.OPD_Customers_Target_Last__c=null; oPDPlan1.OPDPlan_ImplementDate__c = Date.today().addDays(3); oPDPlan1.NoOpp_Reason__c = 'HCP对应'; OPDPlan1.OPDType__c = '学会'; insert oPDPlan1; oPDPlan0.Account_Laboratory__c = depList[0].Id; oPDPlan0.OPDPlan_ImplementDate__c = oPDPlan1.OPDPlan_ImplementDate__c.addDays(40); update oPDPlan0; } static testMethod void newOPDPlanThree(){ setupTestDatabak(); List depList = [SELECT Id FROM Account WHERE RecordTypeId = :Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_GI').getRecordTypeId() LIMIT 1 ]; //opd计划2 OPDPlan__c oPDPlan3 = new OPDPlan__c(); oPDPlan3.ThisMonthPlan__c = 1; oPDPlan3.Status__c = '计划中'; oPDPlan3.Account_Laboratory__c = depList[0].Id; oPDPlan3.OPD_Customers_Target_Last__c=null; oPDPlan3.OPDPlan_ImplementDate__c = Date.today().addDays(3); oPDPlan3.NoOpp_Reason__c = 'HCP对应'; OPDPlan3.OPDType__c = '学会'; insert oPDPlan3; } static testMethod void newOPDPlanFour(){ setupTestDatabak(); List depList = [SELECT Id FROM Account WHERE RecordTypeId = :Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_GI').getRecordTypeId() LIMIT 1 ]; List anotList = [SELECT Id FROM Account_Number_of_target__c]; //opd计划3 OPDPlan__c oPDPlan2 = new OPDPlan__c(); oPDPlan2.Status__c = '草案中'; oPDPlan2.Account_Laboratory__c = depList[0].Id; //oPDPlan2.OPDPlan_ImplementDate__c = Date.today(); oPDPlan2.NoOpp_Reason__c = 'HCP对应'; oPDPlan2.if_OPDTarget__c=1; oPDPlan2.if_HaveSalestarget__c =1; oPDPlan2.Cnt_OPD_ThisYear__c=1; oPDPlan2.Cnt_OPD_LastYear__c=1; oPDPlan2.if_HaveOpportunity__c=1; oPDPlan2.if_HaveEquipment__c =1; oPDPlan2.Cnt_Rentals__c =1; oPDPlan2.OPD_Customers_Target_Last__c= anotList[0].id; oPDPlan2.OPD_Customers_Target__c = anotList[1].id; oPDPlan2.PlanProdDetail__c ='CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; // oPDPlan2.OriginalOpdPlan__c = oPDPlan3.Id; oPDPlan2.OPDType__c = '学会'; insert oPDPlan2; oPDPlan2.Status__c = '审批中'; update oPDPlan2; } static testMethod void newOPDPlanFive(){ setupTestDatabak(); List depList = [SELECT Id FROM Account WHERE RecordTypeId = :Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_GI').getRecordTypeId() LIMIT 1 ]; //opd计划2 OPDPlan__c oPDPlan3 = new OPDPlan__c(); oPDPlan3.ThisMonthPlan__c = 1; oPDPlan3.Status__c = '计划中'; oPDPlan3.Account_Laboratory__c = depList[0].Id; oPDPlan3.OPD_Customers_Target_Last__c=null; oPDPlan3.OPDPlan_ImplementDate__c = Date.today().addDays(3); oPDPlan3.NoOpp_Reason__c = 'HCP对应'; OPDPlan3.OPDType__c = '学会'; insert oPDPlan3; Rental_Apply__c raObj1 = new Rental_Apply__c(); raObj1.Name = 'testra'; raObj1.Product_category__c = 'GI'; raObj1.Demo_purpose1__c = '其他'; raObj1.demo_purpose2__c = '其他'; raObj1.Account__c = depList[0].Id; raObj1.Person_In_Charge__c = Userinfo.getUserId(); raObj1.applyUser__c = Userinfo.getUserId(); raObj1.Demo_purpose_text__c = '123'; raObj1.Request_shipping_day__c = Date.toDay(); raObj1.Request_return_day__c = Date.toDay(); raObj1.direct_send__c = '医疗机构'; // raObj1.direct_shippment_address__c = '北京市'; raObj1.Loaner_received_staff__c = '王五'; raObj1.Loaner_received_staff_phone__c = '110'; raObj1.pickup_time__c = System.now(); raObj1.OPDPlan__c = oPDPlan3.Id; insert raObj1; oPDPlan3.Status__c = '草案中'; UPDATE oPDPlan3; } static testMethod void newOPDPlanSix(){ setupTestDatabak(); // List depList = [SELECT Id FROM Account WHERE RecordTypeId = :Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_GI').getRecordTypeId() LIMIT 1 ]; // //opd计划2 // OPDPlan__c oPDPlan3 = new OPDPlan__c(); // oPDPlan3.ThisMonthPlan__c = 1; // oPDPlan3.Status__c = '草案中'; // oPDPlan3.Account_Laboratory__c = depList[0].Id; // oPDPlan3.OPD_Customers_Target_Last__c=null; // oPDPlan3.OPDPlan_ImplementDate__c = Date.today().addDays(3); // oPDPlan3.NoOpp_Reason__c = 'HCP对应'; // OPDPlan3.OPDType__c = '学会'; // insert oPDPlan3; // Rental_Apply__c raObj1 = new Rental_Apply__c(); // raObj1.Name = 'testra'; // raObj1.Product_category__c = 'GI'; // raObj1.Demo_purpose1__c = '其他'; // raObj1.demo_purpose2__c = '其他'; // raObj1.Account__c = depList[0].Id; // raObj1.Person_In_Charge__c = Userinfo.getUserId(); // raObj1.applyUser__c = Userinfo.getUserId(); // raObj1.Demo_purpose_text__c = '123'; // raObj1.Request_shipping_day__c = Date.toDay(); // raObj1.Request_return_day__c = Date.toDay(); // raObj1.direct_send__c = '医疗机构'; // raObj1.direct_shippment_address__c = '北京市'; // raObj1.Loaner_received_staff__c = '王五'; // raObj1.Loaner_received_staff_phone__c = '110'; // raObj1.pickup_time__c = System.now(); // raObj1.OPDPlan__c = oPDPlan3.Id; // raObj1.Status__c = '申请中(OPD未通过)'; // insert raObj1; // oPDPlan3.Status__c = '计划中'; // UPDATE oPDPlan3; OPDPlanHandler handler = new OPDPlanHandler(); handler.runningline(); } //补充计划 static testMethod void originalOpd(){ 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镜子'; 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镜子放大'; 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}; //简档 Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; //用户 User hpOwner = new User(Test_staff__c = true, LastName = 'hp', 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', 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 = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId(), 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 = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_GI').getRecordTypeId()); dpt.Name = '*'; dpt.Department_Name__c = 'TestDepart'; dpt.ParentId = dc.Id; dpt.Department_Class__c = dc.Id; dpt.Hospital__c = hp.Id; insert dpt; OPDPlan__c oPDPlan3 = new OPDPlan__c(); oPDPlan3.ThisMonthPlan__c = 1; oPDPlan3.Status__c = '计划中'; oPDPlan3.Account_Laboratory__c =dpt.Id; oPDPlan3.OPD_Customers_Target_Last__c=null; oPDPlan3.OPDPlan_ImplementDate__c = Date.today().addDays(3); oPDPlan3.NoOpp_Reason__c = 'HCP对应'; OPDPlan3.OPDType__c = '学会'; insert oPDPlan3; //根据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 oPDPlan6 = new OPDPlan__c(); oPDPlan6.Status__c = '计划中'; oPDPlan6.Account_Laboratory__c =dpt.Id; //oPDPlan6.OPDPlan_ImplementDate__c = Date.today().addDays(3); oPDPlan6.OPDPlan_ImplementDate__c = oPDPlan3.OPDPlan_ImplementDate__c; oPDPlan6.NoOpp_Reason__c = 'HCP对应'; oPDPlan6.if_OPDTarget__c=1; oPDPlan6.if_HaveSalestarget__c =1; oPDPlan6.Cnt_OPD_ThisYear__c=1; oPDPlan6.Cnt_OPD_LastYear__c=1; oPDPlan6.if_HaveOpportunity__c=1; oPDPlan6.if_HaveEquipment__c =1; oPDPlan6.Cnt_Rentals__c =1; oPDPlan6.OPD_Customers_Target_Last__c=anot.id; oPDPlan6.OPD_Customers_Target__c =anot1.id; oPDPlan6.PlanProdDetail__c ='CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; oPDPlan6.OriginalOpdPlanApplication__c = oPDPlan3.Id; oPDPlan6.RentalReson__c = '追加配套'; oPDPlan6.OPDType__c = '学会'; oPDPlan6.OriginalOpdPlanRental__c = oPDPlan3.Id; insert oPDPlan6; //2022-4-29 yjk update } }