@isTest private class SimpleEventRegisterControllerTester { @TestSetup static void makeData(){ TestDataUtility.CreatePIPolicyConfiguration('Contact'); } static testMethod void myUnitTest01() { Event insertTarget = new Event(); insertTarget.IsAllDayEvent = false; insertTarget.IsRecurrence = false; insertTarget.OwnerId = Userinfo.getUserId(); // 行動簡易登録画面空登録するときだけに立つフラグ insertTarget.isScheduled__c = true; insertTarget.Subject = 'test'; insertTarget.StartDateTime = Datetime.now().adddays(1); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update start //insertTarget.DurationInMinutes = 10; insertTarget.EndDateTime = Datetime.now().adddays(1).addMinutes(20); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update end insertTarget.Main_Visit_Location__c = 'test_location'; insertTarget.Activity_Type2__c = '病院'; insertTarget.Purpose_Type__c = ''; ApexPages.StandardController sc = new ApexPages.standardController( insertTarget); SimpleEventRegisterController target = new SimpleEventRegisterController( sc); target.init(); target.visitToHospital(); target.visitToAgent(); target.visitToCampaign(); target.visitToNone(); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update start //insertTarget.DurationInMinutes = 10; target.targetEvent = insertTarget; //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update end target.save(); //target.saveAndNew(); } static testMethod void myUnitTest02() { //20200923 zh start List res = createRe(); insert res; //20200923 zh end Event insertTarget = new Event(); insertTarget.IsAllDayEvent = false; insertTarget.IsRecurrence = false; insertTarget.OwnerId = Userinfo.getUserId(); // 行動簡易登録画面空登録するときだけに立つフラグ insertTarget.isScheduled__c = true; insertTarget.Subject = 'test'; insertTarget.StartDateTime = Datetime.now().adddays(1); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update start //insertTarget.DurationInMinutes = 10; insertTarget.EndDateTime = Datetime.now().adddays(1).addMinutes(20); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update end insertTarget.Main_Visit_Location__c = 'test_location'; insertTarget.Activity_Type2__c = '病院'; insertTarget.Purpose_Type__c = ''; insertTarget.OPDPlan_Flag__c = true; ApexPages.StandardController sc = new ApexPages.standardController( insertTarget); SimpleEventRegisterController target = new SimpleEventRegisterController( sc); target.init(); //20200923 zh 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对应'; //20200923 zh end target.targetEvent.StartDateTime = Datetime.now().adddays(1); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update start //insertTarget.DurationInMinutes = 10; target.targetEvent.EndDateTime = Datetime.now().adddays(1).addMinutes(20); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update end target.targetEvent.Location = 'testLocation'; target.targetEvent.whatid__c = 'testWhatid'; target.targetEvent.Related_Service1__c = 'testRelated_Service1'; target.targetEvent.Related_Opportunity1__c = 'testRelated_Opportunity1'; target.saveAndNew(); // target.save(); } static testMethod void initTest01() { // レコードタイプ取得 RecordType hospitalRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院']; RecordType sectionRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科']; RecordType departmentRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科']; // 病院作成 Account hospital = new Account(); hospital.RecordTypeId = hospitalRec.Id; hospital.Name = 'TestHospital'; insert hospital; // 病院を作ると戦略科室は、トリガーによって作られている Account section = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Parent.Id = :hospital.Id and RecordTypeId = :sectionRec.Id limit 1]; // 診療科1を作成 Account depart1 = new Account(); depart1.RecordTypeId = departmentRec.Id; depart1.Name = '*'; depart1.Department_Name__c = 'TestDepart'; depart1.ParentId = section.Id; depart1.Department_Class__c = section.Id; depart1.Hospital__c = hospital.Id; depart1.AgentCode_Ext__c = '9999997'; insert depart1; // 2021-06-18 mzy update RecordType oppVND = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity']; /*Opportunity opp1 = new Opportunity(); opp1.Name = 'test'; opp1.RecordTypeId = oppVND; opp1.StageName = '引合'; opp1.CloseDate = Date.today().adddays(1); opp1.AccountId = depart1.Id; insert opp1; */ Opportunity opp1 = new Opportunity( Name = 'test opp2', StageName = '引合', CurrencyIsoCode = 'USD', CloseDate = Date.today().adddays(1), AccountId = depart1.Id, RecordTypeId = oppVND.Id, Closing_Bid_Date__c = Date.today().addDays(-5), Hospital__c = hospital.Id, Competitor__c = 'B' ); insert opp1; // 2021-06-18 mzy update // 维修合同を作成する Maintenance_Contract__c contract = new Maintenance_Contract__c(); contract.Name = 'tect contract'; contract.Hospital__c = hospital.Id; contract.Department_Class__c = section.Id; contract.Department__c = depart1.Id; insert contract; // Visualforceページの引数設定 ApexPages.currentPage().getParameters().put( 'accid', depart1.Id); ApexPages.currentPage().getParameters().put( 'oid', opp1.Id); ApexPages.currentPage().getParameters().put( 'mid', contract.Id); // テスト対象クラス実体化 ApexPages.StandardController sc = new ApexPages.StandardController( depart1); SimpleEventRegisterController target = new SimpleEventRegisterController( sc); target.init(); } static testMethod void initTest02() { //販売店 RecordType recHanbaiten = [select id from RecordType where IsActive = true and SobjectType= 'Account' and Name='販売店' limit 1]; Account sellerA = new Account(Name = '販売店'); sellerA.RecordTypeId = recHanbaiten.id; sellerA.Delete_Flag__c = false; insert sellerA; // Visualforceページの引数設定 ApexPages.currentPage().getParameters().put( 'accid', sellerA.Id); // テスト対象クラス実体化 ApexPages.StandardController sc = new ApexPages.StandardController( sellerA); SimpleEventRegisterController target = new SimpleEventRegisterController( sc); target.init(); } static testMethod void initTest03() { /*Campaign cam = new Campaign(); cam.Name = 'test camapign'; insert cam;*/ RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp']; RecordType rectCam = [select Id from RecordType where IsActive = true and SobjectType = 'Campaign' and DeveloperName = 'ServiceEngineerTraining']; Campaign cam = new Campaign(); cam.Name = 'cam'; cam.Name2__c = '1234'; cam.RecordTypeId = rectCam.Id; cam.StartDate = Date.today().addDays(-15); cam.EndDate = Date.today().addDays(18); cam.Mailflg_after45__c = true; cam.Mailflg_cancel__c = true; cam.Mailflg_before15__c = true; cam.Mailflg_before7__c = true; cam.Mailflg_after3__c = true; insert cam; // Visualforceページの引数設定 ApexPages.currentPage().getParameters().put( 'cid', cam.Id); // テスト対象クラス実体化 ApexPages.StandardController sc = new ApexPages.StandardController( cam); SimpleEventRegisterController target = new SimpleEventRegisterController( sc); target.init(); target.visitToTraining(); } static testMethod void saveTest() { 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); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update start //insertTarget.DurationInMinutes = 10; target.targetEvent.EndDateTime = Datetime.now().adddays(1).addMinutes(20); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update end target.targetEvent.Location = 'testLocation1'; target.init(); target.save(); } static testMethod void saveAndNewTest() { Event insertTarget = new Event(); ApexPages.StandardController sc = new ApexPages.standardController( insertTarget); SimpleEventRegisterController target = new SimpleEventRegisterController( sc); target.init(); target.targetEvent.Subject = 'test'; target.targetEvent.StartDateTime = Datetime.now().addDays(1); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update start //insertTarget.DurationInMinutes = 10; target.targetEvent.EndDateTime = Datetime.now().adddays(1).addMinutes(20); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update end target.saveAndNew(); } static testMethod void saveTest1() { 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); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update start //insertTarget.DurationInMinutes = 1500; target.targetEvent.EndDateTime = Datetime.now().adddays(1).addMinutes(20); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update end target.init(); target.save(); } static testMethod void saveTest2() { //20200923 zh start List res = createRe(); insert res; //20200923 zh 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); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update start //insertTarget.DurationInMinutes = 10; target.targetEvent.EndDateTime = Datetime.now().adddays(1).addMinutes(20); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update end target.targetEvent.Activity_Type2__c = '販売店'; target.targetEvent.Activity_PurposeFSE__c = '其他'; target.targetEvent.OPDPlan_Flag__c = true ; target.init(); target.save(); } //任务和日报管理开发 update by vivek 2020-05-29 start static testMethod void saveTest3() { //20200923 zh start List res = createRe(); insert res; //20200923 zh end // レコードタイプ取得 RecordType hospitalRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院']; RecordType sectionRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科']; RecordType departmentRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科']; // 病院作成 Account hospital = new Account(); hospital.RecordTypeId = hospitalRec.Id; hospital.Name = 'TestHospital'; insert hospital; // 病院を作ると戦略科室は、トリガーによって作られている Account section = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Parent.Id = :hospital.Id and RecordTypeId = :sectionRec.Id limit 1]; // 診療科1を作成 Account depart1 = new Account(); depart1.RecordTypeId = departmentRec.Id; depart1.Name = '*'; depart1.Department_Name__c = 'TestDepart'; depart1.ParentId = section.Id; depart1.Department_Class__c = section.Id; depart1.Hospital__c = hospital.Id; depart1.AgentCode_Ext__c = '9999997'; insert depart1; task__c task = new task__c(); task.isDelay__c = true; task.delayToDate__c = Date.today().addMonths(2); task.taskDifferent__c = '主动任务'; task.taskStatus__c = '01 分配'; insert task; 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); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update start //insertTarget.DurationInMinutes = 10; target.targetEvent.EndDateTime = Datetime.now().adddays(1).addMinutes(20); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update end target.targetEvent.Activity_Type2__c = '病院'; target.targetEvent.Activity_PurposeFSE__c = '其他'; target.targetEvent.Location = 'testLocation'; target.targetEvent.whatid__c = depart1.Id; target.targetEvent.OPDPlan_Flag__c = true ; target.init(); //20200923 zh 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对应'; //20200923 zh end target.LoginUser.Job_Category__c = '销售推广'; target.save(); target.saveAndNew(); // ApexPages.currentPage().getParameters().put( 'taskId', task.Id); // ApexPages.currentPage().getParameters().put( 'isDelay', 'true'); // target.targetEvent.StartDateTime = Datetime.now().addMonths(2); // target.init(); // target.save(); // target.saveAndNew(); } /*static testMethod void saveTest4() { //20200923 zh start List res = createRe(); insert res; //20200923 zh end task__c task = new task__c(); // task.isDelay__c = true; // task.delayToDate__c = Date.today().addMonths(2); task.taskDifferent__c = '主动任务'; task.taskStatus__c = '01 分配'; insert task; Event insertTarget = new Event(); ApexPages.StandardController sc = new ApexPages.standardController( insertTarget); SimpleEventRegisterController target = new SimpleEventRegisterController(sc); ApexPages.currentPage().getParameters().put('taskId', task.Id); ApexPages.currentPage().getParameters().put( 'isDelay', ''); target.targetEvent.Subject = 'test'; target.targetEvent.StartDateTime = Datetime.now().addMonths(1); // target.targetEvent.StartDateTime = Datetime.now().adddays(1); target.targetEvent.DurationInMinutes = 10; target.targetEvent.Location = 'testLocation'; target.targetEvent.Activity_Type2__c = '病院'; target.targetEvent.Activity_PurposeFSE__c = '销售支持'; target.targetEvent.OPDPlan_Flag__c = true ; target.init(); target.LoginUser.Job_Category__c = '销售推广'; //20200923 zh 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对应'; //20200923 zh end target.save(); //target.saveAndNew(); // ApexPages.currentPage().getParameters().put( 'isDelay', 'true'); //target.targetEvent.StartDateTime = Datetime.now().adddays(1); // target.init(); //target.save(); //target.saveAndNew(); }*/ static testMethod void saveTest5() { //20200923 zh start List res = createRe(); insert res; //20200923 zh end task__c task = new task__c(); // task.isDelay__c = true; // task.delayToDate__c = Date.today().addMonths(2); task.taskDifferent__c = '主动任务'; task.taskStatus__c = '01 分配'; insert task; Event insertTarget = new Event(); ApexPages.StandardController sc = new ApexPages.standardController( insertTarget); SimpleEventRegisterController target = new SimpleEventRegisterController( sc); ApexPages.currentPage().getParameters().put( 'taskId', task.Id); ApexPages.currentPage().getParameters().put( 'isDelay', 'true'); target.targetEvent.Subject = 'test'; target.targetEvent.StartDateTime = Datetime.now().addMonths(2).addDays(-1); // target.targetEvent.StartDateTime = Datetime.now().adddays(1); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update start //insertTarget.DurationInMinutes = 10; target.targetEvent.EndDateTime = Datetime.now().adddays(1).addMinutes(20); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update end target.targetEvent.Location = 'testLocation'; target.targetEvent.Activity_Type2__c = '病院'; target.targetEvent.Activity_PurposeFSE__c = '销售支持'; target.targetEvent.OPDPlan_Flag__c = true ; target.init(); target.LoginUser.Job_Category__c = '销售推广'; //20200923 zh 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对应'; //20200923 zh end target.save(); //target.saveAndNew(); //target.targetEvent.StartDateTime = Datetime.now().adddays(1); // target.init(); //target.save(); //target.saveAndNew(); // target.init(); // target.save(); // target.saveAndNew(); } //任务和日报管理开发 update by vivek 2020-05-29 end /* static testMethod void saveTest7() { //20200923 zh start List res = createRe(); insert res; //20200923 zh end task__c task = new task__c(); // task.isDelay__c = true; // task.delayToDate__c = Date.today().addMonths(2); RecordType mainTaskrecId = [select Id from RecordType where IsActive = true and SobjectType = 'task__c' and Name = '维修合同任务']; task.RecordTypeId = mainTaskrecId.Id; task.taskDifferent__c = '主动任务'; task.taskStatus__c = '01 分配'; insert task; Event insertTarget = new Event(); ApexPages.StandardController sc = new ApexPages.standardController( insertTarget); SimpleEventRegisterController target = new SimpleEventRegisterController( sc); ApexPages.currentPage().getParameters().put( 'taskId', task.Id); ApexPages.currentPage().getParameters().put( 'isDelay', 'true'); target.targetEvent.Subject = 'test'; target.targetEvent.StartDateTime = Datetime.now().addMonths(2).addDays(-1); // target.targetEvent.StartDateTime = Datetime.now().adddays(1); target.targetEvent.DurationInMinutes = 10; target.targetEvent.Location = 'testLocation'; target.targetEvent.Activity_Type2__c = '病院'; target.targetEvent.Activity_PurposeFSE__c = '销售支持'; target.targetEvent.OPDPlan_Flag__c = true ; target.init(); target.LoginUser.Job_Category__c = '销售推广'; //20200923 zh 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对应'; //20200923 zh end target.save(); target.saveAndNew(); target.targetEvent.StartDateTime = Datetime.now().adddays(1); // target.init(); target.save(); //target.saveAndNew(); // target.init(); // target.save(); // target.saveAndNew(); }*/ static testMethod void saveAndNewTest2() { //20200923 zh start List res = createRe(); insert res; //20200923 zh end RecordType hospitalRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院']; RecordType sectionRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科']; RecordType departmentRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科']; SS_Batch_Column_Mapping__c ssmap = new SS_Batch_Column_Mapping__c(); ssmap.Name = 'targetKeyProduct'; ssmap.SS_TableName__c = 'targetKeyProduct'; ssmap.SS_Column_001__c = 'SS_Column_001__c'; insert ssmap; // 病院作成 Account hospital = new Account(); hospital.RecordTypeId = hospitalRec.Id; hospital.Name = 'TestHospital'; insert hospital; // 病院を作ると戦略科室は、トリガーによって作られている Account section = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Parent.Id = :hospital.Id and RecordTypeId = :sectionRec.Id limit 1]; // 診療科1を作成 Account depart1 = new Account(); depart1.RecordTypeId = departmentRec.Id; depart1.Name = '*'; depart1.Department_Name__c = 'TestDepart'; depart1.ParentId = section.Id; depart1.Department_Class__c = section.Id; depart1.Hospital__c = hospital.Id; depart1.AgentCode_Ext__c = '9999997'; insert depart1; task__c task = new task__c(); task.isDelay__c = false; // task.delayToDate__c = Date.today().addMonths(2); task.taskDifferent__c = '主动任务'; task.taskStatus__c = '01 分配'; insert task; ApexPages.currentPage().getParameters().put( 'taskId', task.Id); ApexPages.currentPage().getParameters().put( 'isDelay', 'false'); 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); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update start //insertTarget.DurationInMinutes = 10; target.targetEvent.EndDateTime = Datetime.now().adddays(1).addMinutes(20); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update end target.targetEvent.Activity_Type2__c = '販売店';//'販売店'; target.targetEvent.Activity_PurposeFSE__c = '业务对应'; target.targetEvent.OPDPlan_Flag__c = true ; target.targetEvent.whatid__c = depart1.Id; target.init(); //20200923 zh 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对应'; try{ insert target.targetEvent; target.saveOPDPlan(target.targetEvent); }catch(Exception e){ System.debug('Exception---' + e); } } //20200923 zh start private static List createRe(){ List res = new List(); Rental_Equipment__c re1 = new Rental_Equipment__c(Name = 'GI-290镜子'); res.add(re1); Rental_Equipment__c re2 = new Rental_Equipment__c(Name = 'EU-ME2'); res.add(re2); Rental_Equipment__c re3 = new Rental_Equipment__c(Name = 'OTV-S190'); res.add(re3); Rental_Equipment__c re4 = new Rental_Equipment__c(Name = 'CV-170'); res.add(re4); Rental_Equipment__c re5 = new Rental_Equipment__c(Name = 'OTV-S300'); res.add(re5); return res; } //20200923 zh end //20201127 you start static testMethod void saveTest6() { // レコードタイプ取得 RecordType hospitalRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院']; RecordType sectionRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科']; RecordType departmentRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科']; // 病院作成 Account hospital = new Account(); hospital.RecordTypeId = hospitalRec.Id; hospital.Name = 'TestHospital'; insert hospital; // 病院を作ると戦略科室は、トリガーによって作られている Account section = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Parent.Id = :hospital.Id and RecordTypeId = :sectionRec.Id limit 1]; // 診療科1を作成 Account depart1 = new Account(); depart1.RecordTypeId = departmentRec.Id; depart1.Name = '*'; depart1.Department_Name__c = 'TestDepart'; depart1.ParentId = section.Id; depart1.Department_Class__c = section.Id; depart1.Hospital__c = hospital.Id; depart1.AgentCode_Ext__c = '9999997'; insert depart1; // 2021-06-18 mzy update RecordType oppVND = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity']; Opportunity opp1 = new Opportunity( Name = 'test opp2', StageName = '引合', CurrencyIsoCode = 'USD', CloseDate = Date.today().adddays(1), AccountId = depart1.Id, RecordTypeId = oppVND.Id, Closing_Bid_Date__c = Date.today().addDays(-5), Hospital__c = hospital.Id, Competitor__c = 'B' ); insert opp1; // 2021-06-18 mzy update // 维修合同を作成する Maintenance_Contract__c contract = new Maintenance_Contract__c(); contract.Name = 'tect contract'; contract.Hospital__c = hospital.Id; contract.Department_Class__c = section.Id; contract.Department__c = depart1.Id; insert contract; RecordType hospitalRec1 = [select Id from RecordType where IsActive = true and SobjectType = 'task__c' and Name = 'OPD']; task__c task = new task__c(); task.taskDifferent__c = '主动任务'; task.taskStatus__c = '01 分配'; task.RecordTypeId = hospitalRec1.Id; task.account__c =section.id; insert task; ApexPages.currentPage().getParameters().put('taskId', task.Id); // Visualforceページの引数設定 ApexPages.currentPage().getParameters().put( 'accid', depart1.Id); ApexPages.currentPage().getParameters().put( 'oid', opp1.Id); ApexPages.currentPage().getParameters().put( 'mid', contract.Id); // テスト対象クラス実体化 ApexPages.StandardController sc = new ApexPages.StandardController( depart1); ApexPages.currentPage().getParameters().put( 'source', 'AccountPCL'); SimpleEventRegisterController target = new SimpleEventRegisterController( sc); RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ]; Opportunity opp = new Opportunity( Name='testOpp1', StageName='引合', CloseDate=Date.today(), AccountId=depart1.Id, Sales_Root__c = '販売店', Competitor__c ='A', Click_Close_Date__c = null, RecordType = rectOpp ); insert opp; target.targetEvent.Subject = 'test'; target.targetEvent.StartDateTime = Datetime.now().adddays(1); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update start //insertTarget.DurationInMinutes = 10; target.targetEvent.EndDateTime = Datetime.now().adddays(1).addMinutes(20); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update end target.targetEvent.Activity_Type2__c = '病院'; target.targetEvent.Activity_PurposeFSE__c = '销售支持'; target.targetEvent.Location = 'testLocation'; target.targetEvent.whatid__c = depart1.Id; target.targetEvent.OPDPlan_Flag__c = true ; target.targetEvent.Purpose_TypeFSE__c ='移动'; target.targetEvent.Related_Opportunity1_ID__c =opp.id; target.targetEvent.Related_Opportunity2_ID__c =opp.id; target.init(); Map tempMap = new Map(); tempMap.put('CV-290', '4'); tempMap.put('GI-290镜子', '1'); tempMap.put('GI-290镜子CF', '1'); target.planProducts = tempMap; target.LoginUser.Job_Category__c = '销售服务'; target.saveAndNew(); target.save(); } //20201127 you end //20210618 mzy start 维修合同 + 报告书任务 static testMethod void saveTest8() { // レコードタイプ取得 RecordType hospitalRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院']; RecordType sectionRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科']; RecordType departmentRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科']; // 病院作成 Account hospital = new Account(); hospital.RecordTypeId = hospitalRec.Id; hospital.Name = 'TestHospital'; insert hospital; // 病院を作ると戦略科室は、トリガーによって作られている Account section = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Parent.Id = :hospital.Id and RecordTypeId = :sectionRec.Id limit 1]; // 診療科1を作成 Account depart1 = new Account(); depart1.RecordTypeId = departmentRec.Id; depart1.Name = '*'; depart1.Department_Name__c = 'TestDepart'; depart1.ParentId = section.Id; depart1.Department_Class__c = section.Id; depart1.Hospital__c = hospital.Id; depart1.AgentCode_Ext__c = '9999997'; insert depart1; //服务合同 Maintenance_Contract__c contract = new Maintenance_Contract__c(); contract.Name = 'test contract'; contract.Hospital__c = hospital.Id; contract.Department_Class__c = section.Id; contract.Department__c = depart1.Id; contract.RecordTypeId = '01210000000gTYqAAM'; insert contract; //这个季度的生成服务合同报告书 NewMaintenanceReport_Task__c tempNMCT = new NewMaintenanceReport_Task__c(); tempNMCT.Name = 'test MT'; tempNMCT.Distribution_Start_Date__c = Date.today().addMonths(-2).addDays(-1); tempNMCT.Distribution_End_Date__c = Date.today().addMonths(2).adddays(-1); tempNMCT.NewMaintenance_Contract__c = contract.Id; tempNMCT.Is_Generate_Task__c = false; insert tempNMCT; RecordType oppVND = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity']; Opportunity opp1 = new Opportunity( Name = 'test opp2', StageName = '引合', CurrencyIsoCode = 'USD', CloseDate = Date.today().adddays(1), AccountId = depart1.Id, RecordTypeId = oppVND.Id, Closing_Bid_Date__c = Date.today().addDays(-5), Hospital__c = hospital.Id, Competitor__c = 'B' ); insert opp1; ApexPages.StandardController sc = new ApexPages.StandardController( depart1); SimpleEventRegisterController target = new SimpleEventRegisterController( sc); ApexPages.currentPage().getParameters().put( 'mid', contract.Id); target.init(); target.targetEvent.Subject = 'test'; target.targetEvent.StartDateTime = Datetime.now().adddays(1); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update start //insertTarget.DurationInMinutes = 10; target.targetEvent.EndDateTime = Datetime.now().adddays(1).addMinutes(20); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update end target.targetEvent.Activity_Type2__c = '病院'; target.targetEvent.Activity_PurposeFSE__c = '服务合同'; target.targetEvent.Location = 'testLocation'; target.targetEvent.whatid__c = depart1.Id; Map tempMap = new Map(); tempMap.put('CV-290', '4'); tempMap.put('GI-290镜子', '1'); tempMap.put('GI-290镜子CF', '1'); target.planProducts = tempMap; target.targetEvent.OPDPlan_Flag__c = false ; target.targetEvent.Purpose_TypeFSE__c ='合同季报'; target.LoginUser.Job_Category__c = '销售服务'; target.targetEvent.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; target.targetEvent.noOpp_Reason__c = 'HCP对应'; target.targetEvent.Related_Opportunity1_ID__c =opp1.id; target.targetEvent.Related_Opportunity2_ID__c =opp1.id; target.targetEvent.Related_Service1_ID__c =contract.id; target.save(); } //20210618 mzy end 维修合同 + 报告书任务 //2021-06-21 mzy start 普通任务延期 static testMethod void saveTest9() { // レコードタイプ取得 RecordType hospitalRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院']; RecordType sectionRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科']; RecordType departmentRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科']; // 病院作成 Account hospital = new Account(); hospital.RecordTypeId = hospitalRec.Id; hospital.Name = 'TestHospital'; insert hospital; // 病院を作ると戦略科室は、トリガーによって作られている Account section = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Parent.Id = :hospital.Id and RecordTypeId = :sectionRec.Id limit 1]; // 診療科1を作成 Account depart1 = new Account(); depart1.RecordTypeId = departmentRec.Id; depart1.Name = '*'; depart1.Department_Name__c = 'TestDepart'; depart1.ParentId = section.Id; depart1.Department_Class__c = section.Id; depart1.Hospital__c = hospital.Id; depart1.AgentCode_Ext__c = '9999997'; insert depart1; //服务合同 Maintenance_Contract__c contract = new Maintenance_Contract__c(); contract.Name = 'test contract'; contract.Hospital__c = hospital.Id; contract.Department_Class__c = section.Id; contract.Department__c = depart1.Id; contract.RecordTypeId = '01210000000gTYqAAM'; insert contract; List res = createRe(); insert res; RecordType oppVND = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity']; Opportunity opp1 = new Opportunity( Name = 'test opp2', StageName = '引合', CurrencyIsoCode = 'USD', CloseDate = Date.today().adddays(1), AccountId = depart1.Id, RecordTypeId = oppVND.Id, Closing_Bid_Date__c = Date.today().addDays(-5), Hospital__c = hospital.Id, Competitor__c = 'B' ); insert opp1; task__c task = new task__c(); // task.isDelay__c = true; // task.delayToDate__c = Date.today().addMonths(2); RecordType mainTaskrecId = [select Id from RecordType where IsActive = true and SobjectType = 'task__c' and Name = '日常拜访']; task.RecordTypeId = mainTaskrecId.id; task.taskDifferent__c = '被动任务'; task.taskStatus__c = '01 分配'; task.Activity_Date__c = Date.today().addDays(2); task.account__c = depart1.Id; task.OpportunityId__c = opp1.Id; task.Maintenance_Contract__c = contract.Id; task.delayReason__c = '与其他突发事件冲突'; 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 =depart1.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'; insert oPDPlan0; Event insertTarget = new Event(); insertTarget.Subject = 'test00'; insertTarget.StartDateTime = Datetime.now().adddays(2); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update start //insertTarget.DurationInMinutes = 10; insertTarget.EndDateTime = Datetime.now().adddays(2).addMinutes(20); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update end insertTarget.Location = 'testLocation'; insertTarget.whatid__c = depart1.Id; insertTarget.Activity_Type2__c = '病院'; insertTarget.Activity_PurposeFSE__c = '销售支持'; insertTarget.OPDPlan_Flag__c = false ; //insertTarget.Opd_Plan__c = oPDPlan0.Id; insertTarget.Task_ID__c = task.Id; insertTarget.Related_Opportunity1__c = opp1.Id; insertTarget.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; insertTarget.Purpose_TypeFSE__c = '备品装机/OPD'; insertTarget.Related_Service1__c = contract.Name; insertTarget.Related_Service1_ID__c = contract.Id; insertTarget.delayReason__c = '客户事件变更或冲突'; insert insertTarget; ApexPages.StandardController sc = new ApexPages.standardController( insertTarget); SimpleEventRegisterController target = new SimpleEventRegisterController( sc); ApexPages.currentPage().getParameters().put( 'taskId', task.Id); ApexPages.currentPage().getParameters().put( 'isDelay', 'true'); ApexPages.currentPage().getParameters().put( 'id', insertTarget.Id ); target.init(); target.targetEvent.Subject = 'test01'; target.targetEvent.StartDateTime = Datetime.now().addMonths(2).addDays(-3); // target.targetEvent.StartDateTime = Datetime.now().adddays(1); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update start //target.targetEvent.DurationInMinutes = 60; target.targetEvent.EndDateTime = Datetime.now().addMonths(2).addDays(-3).addMinutes(60); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update end target.targetEvent.Location = 'testLocation'; target.targetEvent.Activity_Type2__c = '病院'; target.targetEvent.Activity_PurposeFSE__c = '销售支持'; target.targetEvent.OPDPlan_Flag__c = false ; Map tempMap = new Map(); tempMap.put('GI-290镜子', '4'); tempMap.put('GI-290镜子', '1'); tempMap.put('GI-290镜子CF', '1'); target.planProducts = tempMap; target.LoginUser.Job_Category__c = '销售服务'; //20200923 zh start target.targetEvent.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; target.targetEvent.noOpp_Reason__c = 'HCP对应'; //20200923 zh end target.save(); target.saveAndNew(); } //2021-06-21 mzy start 普通任务延期 //2021-06-21 mzy start OPD任务延期 static testMethod void saveTest10() { // レコードタイプ取得 RecordType hospitalRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院']; RecordType sectionRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科']; RecordType departmentRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科']; // 病院作成 Account hospital = new Account(); hospital.RecordTypeId = hospitalRec.Id; hospital.Name = 'TestHospital'; insert hospital; // 病院を作ると戦略科室は、トリガーによって作られている Account section = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Parent.Id = :hospital.Id and RecordTypeId = :sectionRec.Id limit 1]; // 診療科1を作成 Account depart1 = new Account(); depart1.RecordTypeId = departmentRec.Id; depart1.Name = '*'; depart1.Department_Name__c = 'TestDepart'; depart1.ParentId = section.Id; depart1.Department_Class__c = section.Id; depart1.Hospital__c = hospital.Id; depart1.AgentCode_Ext__c = '9999997'; insert depart1; List res = createRe(); insert res; task__c task = new task__c(); // task.isDelay__c = true; // task.delayToDate__c = Date.today().addMonths(2); RecordType mainTaskrecId = [select Id from RecordType where IsActive = true and SobjectType = 'task__c' and Name = 'OPD']; task.RecordTypeId = mainTaskrecId.id; task.taskDifferent__c = '被动任务'; task.taskStatus__c = '01 分配'; task.Activity_Date__c = Date.newInstance(2021, 7, 17); task.account__c = depart1.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 =depart1.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'; insert oPDPlan0; task.Opd_Plan__c = oPDPlan0.Id; update task; Event insertTarget = new Event(); insertTarget.Subject = 'test00'; insertTarget.StartDateTime = Datetime.now().adddays(2); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update start //insertTarget.DurationInMinutes = 60; insertTarget.EndDateTime = Datetime.now().adddays(2).addMinutes(60); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update end insertTarget.Location = 'testLocation'; insertTarget.whatid__c = depart1.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.delayReason__c = '客户事件变更或冲突'; insert insertTarget; ApexPages.StandardController sc = new ApexPages.standardController( insertTarget); SimpleEventRegisterController target = new SimpleEventRegisterController( sc); ApexPages.currentPage().getParameters().put( 'taskId', task.Id); ApexPages.currentPage().getParameters().put( 'isDelay', 'true'); ApexPages.currentPage().getParameters().put( 'id', insertTarget.Id ); target.init(); target.targetEvent.Subject = 'test01'; target.targetEvent.StartDateTime = Datetime.now().addMonths(2).addDays(-3); // target.targetEvent.StartDateTime = Datetime.now().adddays(1); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update start //insertTarget.DurationInMinutes = 60; target.targetEvent.EndDateTime = Datetime.now().addMonths(2).addDays(-3).addMinutes(60); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update end target.targetEvent.Location = 'testLocation'; target.targetEvent.Activity_Type2__c = '病院'; target.targetEvent.OPDPlan_Flag__c = true ; target.LoginUser.Job_Category__c = '销售推广'; target.targetEvent.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; target.targetEvent.noOpp_Reason__c = 'HCP对应'; target.save(); target.saveAndNew(); } //2021-06-21 mzy start OPD任务延期 //2021-06-21 mzy start SLA任务延期 static testMethod void saveTest11() { // レコードタイプ取得 RecordType hospitalRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院']; RecordType sectionRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科']; RecordType departmentRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科']; // 病院作成 Account hospital = new Account(); hospital.RecordTypeId = hospitalRec.Id; hospital.Name = 'TestHospital'; insert hospital; // 病院を作ると戦略科室は、トリガーによって作られている Account section = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Parent.Id = :hospital.Id and RecordTypeId = :sectionRec.Id limit 1]; // 診療科1を作成 Account depart1 = new Account(); depart1.RecordTypeId = departmentRec.Id; depart1.Name = '*'; depart1.Department_Name__c = 'TestDepart'; depart1.ParentId = section.Id; depart1.Department_Class__c = section.Id; depart1.Hospital__c = hospital.Id; depart1.AgentCode_Ext__c = '9999997'; insert depart1; //服务合同 Maintenance_Contract__c contract = new Maintenance_Contract__c(); contract.Name = 'test contract'; contract.Hospital__c = hospital.Id; contract.Department_Class__c = section.Id; contract.Department__c = depart1.Id; contract.RecordTypeId = '01210000000gTYqAAM'; insert contract; List res = createRe(); insert res; task__c task = new task__c(); // task.isDelay__c = true; // task.delayToDate__c = Date.today().addMonths(2); //RecordType mainTaskrecId = [select Id from RecordType where IsActive = true and SobjectType = 'task__c' and Name = 'SLAReport_Task']; task.RecordTypeId = Schema.SObjectType.task__c.getRecordTypeInfosByDeveloperName().get('SLAReport_Task').getRecordTypeId(); task.taskDifferent__c = '被动任务'; task.taskStatus__c = '01 分配'; task.Activity_Date__c = Date.newInstance(2021, 7, 17); task.account__c = depart1.Id; task.Maintenance_Contract__c = contract.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 =depart1.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'; insert oPDPlan0; task.Opd_Plan__c = oPDPlan0.Id; update task; Event insertTarget = new Event(); insertTarget.Subject = 'test00'; insertTarget.StartDateTime = Datetime.now().adddays(2); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update start //insertTarget.DurationInMinutes = 60; insertTarget.EndDateTime = Datetime.now().adddays(2).addMinutes(60); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update end insertTarget.Location = 'testLocation'; insertTarget.whatid__c = depart1.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.Related_Service1__c = contract.Name; insertTarget.Related_Service1_ID__c = contract.Id; insertTarget.delayReason__c = '客户事件变更或冲突'; insert insertTarget; ApexPages.StandardController sc = new ApexPages.standardController( insertTarget); SimpleEventRegisterController target = new SimpleEventRegisterController( sc); ApexPages.currentPage().getParameters().put( 'taskId', task.Id); ApexPages.currentPage().getParameters().put( 'isDelay', 'true'); ApexPages.currentPage().getParameters().put( 'id', insertTarget.Id ); target.init(); target.targetEvent.Subject = 'test01'; target.targetEvent.StartDateTime = Datetime.now().addMonths(2).addDays(-3); // target.targetEvent.StartDateTime = Datetime.now().adddays(1); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update start //insertTarget.DurationInMinutes = 60; target.targetEvent.EndDateTime = Datetime.now().addMonths(2).addDays(-3).addMinutes(60); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update end target.targetEvent.Location = 'testLocation'; target.targetEvent.Activity_Type2__c = '病院'; target.targetEvent.OPDPlan_Flag__c = true ; target.LoginUser.Job_Category__c = '销售服务'; Map tempMap = new Map(); tempMap.put('CV-290', '4'); tempMap.put('GI-290镜子', '1'); tempMap.put('GI-290镜子CF', '1'); target.planProducts = tempMap; //20200923 zh start target.targetEvent.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; target.targetEvent.noOpp_Reason__c = 'HCP对应'; //20200923 zh end //target.saveAndNew(); target.save(); } //2021-06-26 mzy start SLA任务延期 //2021-06-30 mzy start 提前 static testMethod void saveTest12() { // レコードタイプ取得 RecordType hospitalRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院']; RecordType sectionRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科']; RecordType departmentRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科']; // 病院作成 Account hospital = new Account(); hospital.RecordTypeId = hospitalRec.Id; hospital.Name = 'TestHospital'; insert hospital; // 病院を作ると戦略科室は、トリガーによって作られている Account section = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Parent.Id = :hospital.Id and RecordTypeId = :sectionRec.Id limit 1]; // 診療科1を作成 Account depart1 = new Account(); depart1.RecordTypeId = departmentRec.Id; depart1.Name = '*'; depart1.Department_Name__c = 'TestDepart'; depart1.ParentId = section.Id; depart1.Department_Class__c = section.Id; depart1.Hospital__c = hospital.Id; depart1.AgentCode_Ext__c = '9999997'; insert depart1; List res = createRe(); insert res; task__c task = new task__c(); // task.isDelay__c = true; // task.delayToDate__c = Date.today().addMonths(2); RecordType mainTaskrecId = [select Id from RecordType where IsActive = true and SobjectType = 'task__c' and Name = 'OPD']; task.RecordTypeId = mainTaskrecId.id; task.taskDifferent__c = '主动任务'; task.taskStatus__c = '01 分配'; task.Activity_Date__c = Date.today().addDays(30); task.account__c = depart1.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 =depart1.Id; oPDPlan0.OPDPlan_ImplementDate__c = Date.today().adddays(5); oPDPlan0.OPDPlan_ImplementDate_temp__c = Date.today().adddays(5); oPDPlan0.NoOpp_Reason__c = 'HCP对应'; oPDPlan0.RentalReson__c = '无法进入手术室'; oPDPlan0.AttachmentCertificate__c = '0001.png'; insert oPDPlan0; task.Opd_Plan__c = oPDPlan0.Id; update task; Event insertTarget = new Event(); insertTarget.Subject = 'test00'; insertTarget.StartDateTime = Datetime.now().adddays(5); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update start //insertTarget.DurationInMinutes = 60; insertTarget.EndDateTime = Datetime.now().adddays(5).addMinutes(60); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update end insertTarget.Location = 'testLocation'; insertTarget.whatid__c = depart1.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;'; insert insertTarget; ApexPages.StandardController sc = new ApexPages.standardController( insertTarget); SimpleEventRegisterController target = new SimpleEventRegisterController( sc); ApexPages.currentPage().getParameters().put( 'taskId', task.Id); ApexPages.currentPage().getParameters().put( 'id', insertTarget.Id); ApexPages.currentPage().getParameters().put( 'isDelay', 'false'); target.init(); target.targetEvent.Subject = 'test01'; target.targetEvent.StartDateTime = Datetime.now().addDays(2); // target.targetEvent.StartDateTime = Datetime.now().adddays(1); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update start //insertTarget.DurationInMinutes = 60; target.targetEvent.EndDateTime = Datetime.now().adddays(2).addMinutes(60); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update end target.targetEvent.Location = 'testLocation'; target.targetEvent.Activity_Type2__c = '病院'; target.targetEvent.OPDPlan_Flag__c = true ; Map tempMap = new Map(); tempMap.put('CV-290', '4'); tempMap.put('GI-290镜子', '1'); tempMap.put('GI-290镜子CF', '1'); target.planProducts = tempMap; target.LoginUser.Job_Category__c = '销售推广'; insertTarget.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; target.targetEvent.noOpp_Reason__c = 'HCP对应'; target.save(); target.saveAndNew(); } //2021-06-30 mzy end //2021-09-30 mzy start static testMethod void saveTest13() { // レコードタイプ取得 RecordType hospitalRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院']; RecordType sectionRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科']; RecordType departmentRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科']; // 病院作成 Account hospital = new Account(); hospital.RecordTypeId = hospitalRec.Id; hospital.Name = 'TestHospital'; insert hospital; // 病院を作ると戦略科室は、トリガーによって作られている Account section = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Parent.Id = :hospital.Id and RecordTypeId = :sectionRec.Id limit 1]; // 診療科1を作成 Account depart1 = new Account(); depart1.RecordTypeId = departmentRec.Id; depart1.Name = '*'; depart1.Department_Name__c = 'TestDepart'; depart1.ParentId = section.Id; depart1.Department_Class__c = section.Id; depart1.Hospital__c = hospital.Id; depart1.AgentCode_Ext__c = '9999997'; insert depart1; //服务合同 Maintenance_Contract__c contract = new Maintenance_Contract__c(); contract.Name = 'test contract'; contract.Hospital__c = hospital.Id; contract.Department_Class__c = section.Id; contract.Department__c = depart1.Id; contract.RecordTypeId = '01210000000gTYqAAM'; insert contract; ApexPages.StandardController sc = new ApexPages.StandardController( depart1); SimpleEventRegisterController target = new SimpleEventRegisterController( sc); target.init(); target.targetEvent.Subject = 'test'; target.targetEvent.StartDateTime = Datetime.now().adddays(1); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update start //insertTarget.DurationInMinutes = 10; target.targetEvent.EndDateTime = Datetime.now().adddays(1).addMinutes(20); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update end target.targetEvent.Activity_Type2__c = '病院'; target.targetEvent.Activity_PurposeFSE__c = '服务合同'; target.targetEvent.Location = 'testLocation'; target.targetEvent.whatid__c = depart1.Id; Map tempMap = new Map(); tempMap.put('CV-290', '4'); tempMap.put('GI-290镜子', '1'); tempMap.put('GI-290镜子CF', '1'); target.planProducts = tempMap; target.targetEvent.OPDPlan_Flag__c = false ; target.targetEvent.Purpose_TypeFSE__c ='合同点检'; target.LoginUser.Job_Category__c = '销售服务'; target.targetEvent.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; target.targetEvent.noOpp_Reason__c = 'HCP对应'; target.targetEvent.Related_Service1_ID__c =contract.id; target.save(); } //模拟点检任务接受 static testMethod void saveTest14() { // レコードタイプ取得 RecordType hospitalRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院']; RecordType sectionRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科']; RecordType departmentRec = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科']; // 病院作成 Account hospital = new Account(); hospital.RecordTypeId = hospitalRec.Id; hospital.Name = 'TestHospital'; insert hospital; // 病院を作ると戦略科室は、トリガーによって作られている Account section = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Parent.Id = :hospital.Id and RecordTypeId = :sectionRec.Id limit 1]; // 診療科1を作成 Account depart1 = new Account(); depart1.RecordTypeId = departmentRec.Id; depart1.Name = '*'; depart1.Department_Name__c = 'TestDepart'; depart1.ParentId = section.Id; depart1.Department_Class__c = section.Id; depart1.Hospital__c = hospital.Id; depart1.AgentCode_Ext__c = '9999997'; insert depart1; //服务合同 Maintenance_Contract__c contract = new Maintenance_Contract__c(); contract.Name = 'test contract'; contract.Hospital__c = hospital.Id; contract.Department_Class__c = section.Id; contract.Department__c = depart1.Id; contract.RecordTypeId = '01210000000gTYqAAM'; insert contract; ApexPages.StandardController sc = new ApexPages.StandardController( depart1); SimpleEventRegisterController target = new SimpleEventRegisterController( sc); task__c task = new task__c(); task.Name = 'testTask'; task.RecordTypeId = Schema.SObjectType.task__c.getRecordTypeInfosByDeveloperName().get('InspectUp_Task').getRecordTypeId(); task.taskDifferent__c = '被动任务'; task.taskStatus__c = '01 分配'; task.account__c = depart1.Id; task.Maintenance_Contract__c = contract.Id; insert task; ApexPages.currentPage().getParameters().put( 'taskId', task.Id); target.init(); target.targetEvent.Subject = 'test'; target.targetEvent.StartDateTime = Datetime.now().adddays(1); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update start //insertTarget.DurationInMinutes = 10; target.targetEvent.EndDateTime = Datetime.now().adddays(1).addMinutes(20); //2021-08-09 mzy SWAG-C4YB9J 事件页面优化 update end target.targetEvent.Activity_Type2__c = '病院'; target.targetEvent.Location = 'testLocation'; target.targetEvent.whatid__c = depart1.Id; Map tempMap = new Map(); tempMap.put('CV-290', '4'); tempMap.put('GI-290镜子', '1'); tempMap.put('GI-290镜子CF', '1'); target.planProducts = tempMap; target.targetEvent.OPDPlan_Flag__c = false ; target.LoginUser.Job_Category__c = '销售服务'; target.targetEvent.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; target.targetEvent.noOpp_Reason__c = 'HCP对应'; target.targetEvent.Related_Service1_ID__c =contract.id; target.save(); } //2021-09-30 mzy end }