@isTest private class lexCreateEventButtonTest { // private static Id pricebookId = ControllerUtil.getStandardPricebook().Id; static testMethod void init() { Oly_TriggerHandler.bypass('ContactTriggerHandler'); Oly_TriggerHandler.bypass('PowerBIBaseHandler'); Oly_TriggerHandler.bypass('AgencyOppUpdHandler'); Oly_TriggerHandler.bypass('UpdateContractAimAmountHandler'); Oly_TriggerHandler.bypass('NFM701ControllerHandler'); StaticParameter.EscapeNFM001AgencyContractTrigger = true; StaticParameter.EscapeContactToUser = true; ControllerUtil.EscapeNFM001Trigger = true; lexCreateEventButton.getNowDateTime(); lexCreateEventButton.getEndDateTime(); lexCreateEventButton.getUserJobCategory(); Map eventLineMap = new Map(); eventLineMap.put('StartTime',Datetime.now()); eventLineMap.put('EndTime',Datetime.now()); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('OpportunityId',null); eventLineMap.put('ActivityPurposeFSE','信息收集'); eventLineMap.put('IsOPDPlan','true'); String jsonEvents = JSON.serialize(eventLineMap); List pros = new List(); String jsonRecordNull = System.JSON.serialize(pros); ProLine pro = new ProLine(); // pro.Id = planRE.Id; pro.Quantity = 10; pro.Name = 'CF-H170I1'; pro.ProductCode= 'N4480080'; pro.ProductModel= 'CF-H170I1'; pros.add(pro); RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI']; // List rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_GI', 'Department_BF') order by DeveloperName desc]; 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; Address_Level__c al = new Address_Level__c(); al.Name = '東京'; al.Level1_Code__c = 'CN-99'; al.Level1_Sys_No__c = '999999'; insert al; // 市 Address_Level2__c al2 = new Address_Level2__c(); al2.Level1_Code__c = 'CN-99'; al2.Level1_Sys_No__c = '999999'; al2.Level1_Name__c = '東京'; al2.Name = '渋谷区'; al2.Level2_Code__c = 'CN-9999'; al2.Level2_Sys_No__c = '9999999'; al2.Address_Level__c = al.id; insert al2; Account hospital = new Account(); hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id; hospital.Name = 'test hospital'; hospital.Is_Active__c = '有効'; hospital.Attribute_Type__c = '卫生部'; hospital.Speciality_Type__c = '综合医院'; hospital.Grade__c = '一级'; hospital.OCM_Category__c = 'SLTV'; hospital.Is_Medical__c = '医疗机构'; hospital.State_Master__c = al.id; hospital.City_Master__c = al2.id; hospital.Town__c = '东京'; insert hospital; // 戦略科室を得る Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH']; // 診療科を作る Account acc = new Account(); acc.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id; acc.Name = 'test dep'; acc.AgentCode_Ext__c = '9999998'; acc.ParentId = strategicDep[0].Id; acc.Department_Class__c = strategicDep[0].Id; acc.Hospital__c = hospital.Id; insert acc; Test.startTest(); Opportunity opp = new Opportunity( Name='Opp', StageName='出荷', // Status_Formula_Option__c = '06 已发货', CloseDate=Date.today().addDays(10), Close_Forecasted_Date__c=Date.today(), // Department_Class__c = strategicDep[0].Id, CurrencyIsoCode = 'CNY' ); insert opp; // Quote q = new Quote( // Name = 'quote', // OpportunityId = opp.Id, // Pricebook2Id = pricebookId // ); // insert q; // opp.Estimation_Id__c = q.Id; Opportunity opp1 = new Opportunity( Name='Opp', StageName='引合', AccountId = acc.Id, Status_Formula_Option__c = '12 已签约', CloseDate=Date.today().addDays(10), Close_Forecasted_Date__c=Date.today(), // RecordTypeId = oppRecord.Id, // Department_Class__c = strategicDep[0].Id, CurrencyIsoCode = 'CNY' ); insert opp1; // Product2 prd1 = new Product2(); // prd1.Name = 'Prd1'; // prd1.ProductCode_Ext__c = 'Prd1'; // prd1.ProductCode = 'Prd1'; // prd1.Asset_Model_No__c = '1001'; // prd1.Important_product__c = true; // prd1.Important_Rroduct_1GI__c = true; // prd1.RentalSubject__c = true; // insert prd1; // PricebookEntry entry = new PricebookEntry( Pricebook2Id = pricebookId, Product2Id = prd1.Id); // entry.UnitPrice = 0; // entry.IsActive = true; // entry.UseStandardPrice = false; // entry.CurrencyIsoCode = 'CNY'; // insert entry; // QuoteLineItem quoteItem = new QuoteLineItem(); // quoteItem.Name__c = 'テスト商品'; // quoteItem.QuoteId = q.id; // quoteItem.Quantity = 1; // quoteItem.Cost_Subtotal__c = 0; // quoteItem.Cost__c = 200; // quoteItem.Item_Order__c = 3; // quoteItem.UnitPrice = 10; // quoteItem.Product2Id = prd1.id; // quoteItem.PricebookEntryId = entry.Id; // insert quoteItem; Maintenance_Contract__c contract = new Maintenance_Contract__c(); contract.Name = 'tect contract'; contract.Hospital__c = hospital.Id; contract.Department_Class__c = strategicDep[0].Id; contract.Department__c = acc.Id; contract.Service_Contract_Staff__c = UserInfo.getUserId(); contract.Payment_Plan_Sum_First__c = 1; contract.Status__c = '契約満了'; contract.Maintenance_Contract_No__c = '11123'; contract.recordtypeId = Schema.SObjectType.Maintenance_Contract__c.getRecordTypeInfosByDeveloperName().get('NewMaintenance_Contract').getRecordTypeId(); contract.Not_Upper_limit_reason__c = ' 1'; contract.Contract_Start_Date__c = Date.today().addDays(-5); contract.Contract_End_Date__c = Date.today().addDays(5); contract.SalesOfficeCode_selection__c = '北京RC'; contract.New_Contract_TypeF_Text__c = '续签合同'; contract.IF_Target_Renew__c='1'; contract.Contract_Conclusion_Date__c=Date.today().addDays(-5); // system.assertEquals(contract.Contract_End_Date__c >= Date.newInstance(2021,10,1) && contract.Contract_End_Date__c <= Date.newInstance(2022,9,30),true); insert contract; NewMaintenanceReport_Task__c tempNMCT = new NewMaintenanceReport_Task__c(); tempNMCT.Name = 'FWreport-01'; tempNMCT.Distribution_Start_Date__c = Date.today().addDays(-30); tempNMCT.Distribution_End_Date__c = Date.today().addMonths(2).addDays(-1); tempNMCT.NewMaintenance_Contract__c = contract.Id; tempNMCT.ActualDistributionTimes_Quarter__c = 0; insert tempNMCT; String jsonRecords = System.JSON.serialize(pros); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(70)); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(3)); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2',''); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId',null); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId','123456'); eventLineMap.put('IsOPDPlan',true); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecordNull); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId','123456'); eventLineMap.put('IsOPDPlan',true); eventLineMap.put('OpportunityId',null); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId','123456'); eventLineMap.put('IsOPDPlan',true); eventLineMap.put('OpportunityId',opp.Id); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); Map saveEventMap = new Map(); saveEventMap.put('StartTime',Datetime.now().addDays(1)); saveEventMap.put('EndTime',Datetime.now().addDays(1)); saveEventMap.put('ActivityType2','病院'); saveEventMap.put('PurposeTypeFSE','招标对应'); saveEventMap.put('ActivityPurposeFSE','询价推进'); saveEventMap.put('NoOppReason','HCP对应'); saveEventMap.put('IsOPDPlan',true); saveEventMap.put('AccountId',acc.Id); saveEventMap.put('ContactId',null); saveEventMap.put('OpportunityId',opp1.Id); saveEventMap.put('ProjectId',null); saveEventMap.put('ServiceId',contract.Id); User LoginUser = [SELECT Id, Name, Job_Category__c FROM User WHERE Id = :UserInfo.getUserId()]; String saveEventRecords = JSON.serialize(saveEventMap); lexCreateEventButton.saveEvent(saveEventRecords,jsonRecords); LoginUser.Job_Category__c = '销售推广'; update LoginUser; saveEventMap.put('AccountId',cam.Id); saveEventRecords = JSON.serialize(saveEventMap); lexCreateEventButton.saveEvent(saveEventRecords,jsonRecords); saveEventMap.put('ActivityType2','病院'); saveEventMap.put('AccountId',acc.Id); saveEventMap.put('OpportunityId',null); saveEventRecords = JSON.serialize(saveEventMap); lexCreateEventButton.saveEvent(saveEventRecords,jsonRecords); saveEventMap.put('ActivityType2','販売店'); saveEventMap.put('AccountId',acc.Id); saveEventRecords = JSON.serialize(saveEventMap); lexCreateEventButton.saveEvent(saveEventRecords,jsonRecords); saveEventMap.put('ActivityType2','社外イベント'); saveEventMap.put('AccountId',cam.Id); saveEventRecords = JSON.serialize(saveEventMap); lexCreateEventButton.saveEvent(saveEventRecords,jsonRecords); saveEventMap.put('PurposeTypeFSE','合同季报'); saveEventRecords = JSON.serialize(saveEventMap); // lexCreateEventButton.saveEvent(saveEventRecords,jsonRecords); // saveEventMap.put('PurposeTypeFSE','合同点检'); // saveEventRecords = JSON.serialize(saveEventMap); // lexCreateEventButton.saveEvent(saveEventRecords,jsonRecords); List proLines = new List(); ProLine proLine1 = new ProLine(); // proLine1.Id = planRE.Id; proLine1.Quantity = 10; proLine1.Name = 'CF-H170I1'; proLine1.ProductCode= 'N4480080'; proLine1.ProductModel= '1001'; proLines.add(proLine1); String reRecords = System.JSON.serialize(proLines); // LoginUser.Job_Category__c = '销售服务'; // update LoginUser; // lexCreateEventButton.saveEvent(saveEventRecords,jsonRecords); Test.stopTest(); } static testMethod void init2() { try { Oly_TriggerHandler.bypass('ContactTriggerHandler'); Oly_TriggerHandler.bypass('PowerBIBaseHandler'); Oly_TriggerHandler.bypass('AgencyOppUpdHandler'); Oly_TriggerHandler.bypass('UpdateContractAimAmountHandler'); Oly_TriggerHandler.bypass('NFM701ControllerHandler'); StaticParameter.EscapeNFM001AgencyContractTrigger = true; StaticParameter.EscapeContactToUser = true; ControllerUtil.EscapeNFM001Trigger = true; lexCreateEventButton.getNowDateTime(); lexCreateEventButton.getEndDateTime(); lexCreateEventButton.getUserJobCategory(); Map eventLineMap = new Map(); eventLineMap.put('StartTime',Datetime.now()); eventLineMap.put('EndTime',Datetime.now()); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('OpportunityId',null); eventLineMap.put('ActivityPurposeFSE','信息收集'); eventLineMap.put('IsOPDPlan','true'); String jsonEvents = JSON.serialize(eventLineMap); List pros = new List(); String jsonRecordNull = System.JSON.serialize(pros); ProLine pro = new ProLine(); // pro.Id = planRE.Id; pro.Quantity = 10; pro.Name = 'CF-H170I1'; pro.ProductCode= 'N4480080'; pro.ProductModel= 'CF-H170I1'; pros.add(pro); RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI']; // List rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_GI', 'Department_BF') order by DeveloperName desc]; 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; Address_Level__c al = new Address_Level__c(); al.Name = '東京'; al.Level1_Code__c = 'CN-99'; al.Level1_Sys_No__c = '999999'; insert al; // 市 Address_Level2__c al2 = new Address_Level2__c(); al2.Level1_Code__c = 'CN-99'; al2.Level1_Sys_No__c = '999999'; al2.Level1_Name__c = '東京'; al2.Name = '渋谷区'; al2.Level2_Code__c = 'CN-9999'; al2.Level2_Sys_No__c = '9999999'; al2.Address_Level__c = al.id; insert al2; Account hospital = new Account(); hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id; hospital.Name = 'test hospital'; hospital.Is_Active__c = '有効'; hospital.Attribute_Type__c = '卫生部'; hospital.Speciality_Type__c = '综合医院'; hospital.Grade__c = '一级'; hospital.OCM_Category__c = 'SLTV'; hospital.Is_Medical__c = '医疗机构'; hospital.State_Master__c = al.id; hospital.City_Master__c = al2.id; hospital.Town__c = '东京'; insert hospital; // 戦略科室を得る Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH']; // 診療科を作る Account acc = new Account(); acc.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id; acc.Name = 'test dep'; acc.AgentCode_Ext__c = '9999998'; acc.ParentId = strategicDep[0].Id; acc.Department_Class__c = strategicDep[0].Id; acc.Hospital__c = hospital.Id; insert acc; Test.startTest(); Opportunity opp = new Opportunity( Name='Opp', StageName='出荷', // Status_Formula_Option__c = '06 已发货', CloseDate=Date.today().addDays(10), Close_Forecasted_Date__c=Date.today(), // Department_Class__c = strategicDep[0].Id, CurrencyIsoCode = 'CNY' ); insert opp; // Quote q = new Quote( // Name = 'quote', // OpportunityId = opp.Id, // Pricebook2Id = pricebookId // ); // insert q; // opp.Estimation_Id__c = q.Id; Opportunity opp1 = new Opportunity( Name='Opp', StageName='引合', AccountId = acc.Id, Status_Formula_Option__c = '12 已签约', CloseDate=Date.today().addDays(10), Close_Forecasted_Date__c=Date.today(), // RecordTypeId = oppRecord.Id, // Department_Class__c = strategicDep[0].Id, CurrencyIsoCode = 'CNY' ); insert opp1; Maintenance_Contract__c contract = new Maintenance_Contract__c(); contract.Name = 'tect contract'; contract.Hospital__c = hospital.Id; contract.Department_Class__c = strategicDep[0].Id; contract.Department__c = acc.Id; contract.Service_Contract_Staff__c = UserInfo.getUserId(); contract.Payment_Plan_Sum_First__c = 1; contract.Status__c = '契約満了'; contract.Maintenance_Contract_No__c = '11123'; contract.recordtypeId = Schema.SObjectType.Maintenance_Contract__c.getRecordTypeInfosByDeveloperName().get('NewMaintenance_Contract').getRecordTypeId(); contract.Not_Upper_limit_reason__c = ' 1'; contract.Contract_Start_Date__c = Date.today().addDays(-5); contract.Contract_End_Date__c = Date.today().addDays(5); contract.SalesOfficeCode_selection__c = '北京RC'; contract.New_Contract_TypeF_Text__c = '续签合同'; contract.IF_Target_Renew__c='1'; contract.Contract_Conclusion_Date__c=Date.today().addDays(-5); // system.assertEquals(contract.Contract_End_Date__c >= Date.newInstance(2021,10,1) && contract.Contract_End_Date__c <= Date.newInstance(2022,9,30),true); insert contract; NewMaintenanceReport_Task__c tempNMCT = new NewMaintenanceReport_Task__c(); tempNMCT.Name = 'FWreport-01'; tempNMCT.Distribution_Start_Date__c = Date.today().addDays(-30); tempNMCT.Distribution_End_Date__c = Date.today().addMonths(2).addDays(-1); tempNMCT.NewMaintenance_Contract__c = contract.Id; tempNMCT.ActualDistributionTimes_Quarter__c = 0; insert tempNMCT; String jsonRecords = System.JSON.serialize(pros); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(70)); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(3)); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2',''); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId',null); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId','123456'); eventLineMap.put('IsOPDPlan',true); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecordNull); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId','123456'); eventLineMap.put('IsOPDPlan',true); eventLineMap.put('OpportunityId',null); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId','123456'); eventLineMap.put('IsOPDPlan',true); eventLineMap.put('OpportunityId',opp.Id); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); Map saveEventMap = new Map(); saveEventMap.put('StartTime',Datetime.now().addDays(1)); saveEventMap.put('EndTime',Datetime.now().addDays(1)); saveEventMap.put('ActivityType2','病院'); saveEventMap.put('PurposeTypeFSE','招标对应'); saveEventMap.put('ActivityPurposeFSE','询价推进'); saveEventMap.put('NoOppReason','HCP对应'); saveEventMap.put('IsOPDPlan',true); saveEventMap.put('AccountId',acc.Id); saveEventMap.put('ContactId',null); saveEventMap.put('OpportunityId',opp1.Id); saveEventMap.put('ProjectId',null); saveEventMap.put('ServiceId',contract.Id); User LoginUser = [SELECT Id, Name, Job_Category__c FROM User WHERE Id = :UserInfo.getUserId()]; String saveEventRecords = JSON.serialize(saveEventMap); LoginUser.Job_Category__c = '销售推广'; update LoginUser; saveEventMap.put('AccountId',cam.Id); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('ActivityType2','病院'); saveEventMap.put('AccountId',acc.Id); saveEventMap.put('OpportunityId',null); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('ActivityType2','販売店'); saveEventMap.put('AccountId',acc.Id); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('ActivityType2','社外イベント'); saveEventMap.put('AccountId',cam.Id); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('PurposeTypeFSE','合同季报'); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('PurposeTypeFSE','合同点检'); saveEventRecords = JSON.serialize(saveEventMap); List proLines = new List(); ProLine proLine1 = new ProLine(); // proLine1.Id = planRE.Id; proLine1.Quantity = 10; proLine1.Name = 'CF-H170I1'; proLine1.ProductCode= 'N4480080'; proLine1.ProductModel= '1001'; proLines.add(proLine1); String reRecords = System.JSON.serialize(proLines); // LoginUser.Job_Category__c = '销售服务'; // update LoginUser; // lexCreateEventButton.saveEvent(saveEventRecords,jsonRecords); Integer year = date.today().year(); Integer month = date.today().month(); Integer days = date.today().day(); List ecL=new List(); Event insertTarget = new Event(); insertTarget.Subject = 'test00'; insertTarget.StartDateTime = Datetime.now().adddays(5); insertTarget.EndDateTime = Datetime.now().adddays(5).addMinutes(60); insertTarget.Location = 'testLocation'; insertTarget.Activity_Type2__c = '病院'; insertTarget.OPDPlan_Flag__c = true ; insertTarget.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; insertTarget.EventStatus__c = ' 02 接受'; insertTarget.whatid__c = acc.Id; Event insertTarget2 = new Event(); insertTarget2.Subject = 'test00'; insertTarget2.StartDateTime = Datetime.now().adddays(5); insertTarget2.EndDateTime = Datetime.now().adddays(5).addMinutes(60); insertTarget2.Location = 'testLocation'; insertTarget2.Activity_Type2__c = '病院'; insertTarget2.OPDPlan_Flag__c = true ; insertTarget2.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; insertTarget2.EventStatus__c = ' 04 取消'; insertTarget2.whatid__c = acc.Id; Event insertTarget3 = new Event(); insertTarget3.Subject = 'test00'; insertTarget3.StartDateTime = Datetime.now().adddays(5); insertTarget3.EndDateTime = Datetime.now().adddays(5).addMinutes(60); insertTarget3.Location = 'testLocation'; insertTarget3.Activity_Type2__c = '病院'; insertTarget3.OPDPlan_Flag__c = true ; insertTarget3.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; insertTarget3.EventStatus__c = ' 05 延期'; insertTarget3.whatid__c = acc.Id; ecL.add(insertTarget); ecL.add(insertTarget2); ecL.add(insertTarget3); insert ecL; List tasks = new List(); task__c t1 = new task__c(); t1.Name = 'test1'; t1.taskDifferent__c = '主动任务'; t1.taskStatus__c = '02 接受'; t1.assignee__c = Userinfo.getUserId(); t1.Activity_Date__c = Date.newInstance(year, month,days); tasks.add(t1); task__c t2 = new task__c(); t2.Name = 'test2'; t2.taskDifferent__c = '主动任务'; t2.taskStatus__c = '02 接受'; t2.assignee__c = Userinfo.getUserId(); t2.Activity_Date__c = Date.newInstance(2021, 8, 17); tasks.add(t2); insert tasks; String eventid = insertTarget.Id; String taskId = t1.Id; String accid = acc.Id; String cid = cam.Id; String oid = opp.Id; String mid = contract.Id; String source = 'AccountPCL'; lexCreateEventButton.createCancelPostponePlan_Delay(t1, insertTarget); Test.stopTest(); } catch (Exception e) { System.debug('123'); } } static testMethod void init3() { try { Oly_TriggerHandler.bypass('ContactTriggerHandler'); Oly_TriggerHandler.bypass('PowerBIBaseHandler'); Oly_TriggerHandler.bypass('AgencyOppUpdHandler'); Oly_TriggerHandler.bypass('UpdateContractAimAmountHandler'); Oly_TriggerHandler.bypass('NFM701ControllerHandler'); StaticParameter.EscapeNFM001AgencyContractTrigger = true; StaticParameter.EscapeContactToUser = true; ControllerUtil.EscapeNFM001Trigger = true; lexCreateEventButton.getNowDateTime(); lexCreateEventButton.getEndDateTime(); lexCreateEventButton.getUserJobCategory(); Map eventLineMap = new Map(); eventLineMap.put('StartTime',Datetime.now()); eventLineMap.put('EndTime',Datetime.now()); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('OpportunityId',null); eventLineMap.put('ActivityPurposeFSE','信息收集'); eventLineMap.put('IsOPDPlan','true'); String jsonEvents = JSON.serialize(eventLineMap); List pros = new List(); String jsonRecordNull = System.JSON.serialize(pros); ProLine pro = new ProLine(); // pro.Id = planRE.Id; pro.Quantity = 10; pro.Name = 'CF-H170I1'; pro.ProductCode= 'N4480080'; pro.ProductModel= 'CF-H170I1'; pros.add(pro); RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI']; // List rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_GI', 'Department_BF') order by DeveloperName desc]; 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; Address_Level__c al = new Address_Level__c(); al.Name = '東京'; al.Level1_Code__c = 'CN-99'; al.Level1_Sys_No__c = '999999'; insert al; // 市 Address_Level2__c al2 = new Address_Level2__c(); al2.Level1_Code__c = 'CN-99'; al2.Level1_Sys_No__c = '999999'; al2.Level1_Name__c = '東京'; al2.Name = '渋谷区'; al2.Level2_Code__c = 'CN-9999'; al2.Level2_Sys_No__c = '9999999'; al2.Address_Level__c = al.id; insert al2; Account hospital = new Account(); hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id; hospital.Name = 'test hospital'; hospital.Is_Active__c = '有効'; hospital.Attribute_Type__c = '卫生部'; hospital.Speciality_Type__c = '综合医院'; hospital.Grade__c = '一级'; hospital.OCM_Category__c = 'SLTV'; hospital.Is_Medical__c = '医疗机构'; hospital.State_Master__c = al.id; hospital.City_Master__c = al2.id; hospital.Town__c = '东京'; insert hospital; // 戦略科室を得る Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH']; // 診療科を作る Account acc = new Account(); acc.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id; acc.Name = 'test dep'; acc.AgentCode_Ext__c = '9999998'; acc.ParentId = strategicDep[0].Id; acc.Department_Class__c = strategicDep[0].Id; acc.Hospital__c = hospital.Id; insert acc; Test.startTest(); Opportunity opp = new Opportunity( Name='Opp', StageName='出荷', // Status_Formula_Option__c = '06 已发货', CloseDate=Date.today().addDays(10), Close_Forecasted_Date__c=Date.today(), // Department_Class__c = strategicDep[0].Id, CurrencyIsoCode = 'CNY' ); insert opp; // Quote q = new Quote( // Name = 'quote', // OpportunityId = opp.Id, // Pricebook2Id = pricebookId // ); // insert q; // opp.Estimation_Id__c = q.Id; Opportunity opp1 = new Opportunity( Name='Opp', StageName='引合', AccountId = acc.Id, Status_Formula_Option__c = '12 已签约', CloseDate=Date.today().addDays(10), Close_Forecasted_Date__c=Date.today(), // RecordTypeId = oppRecord.Id, // Department_Class__c = strategicDep[0].Id, CurrencyIsoCode = 'CNY' ); insert opp1; Maintenance_Contract__c contract = new Maintenance_Contract__c(); contract.Name = 'tect contract'; contract.Hospital__c = hospital.Id; contract.Department_Class__c = strategicDep[0].Id; contract.Department__c = acc.Id; contract.Service_Contract_Staff__c = UserInfo.getUserId(); contract.Payment_Plan_Sum_First__c = 1; contract.Status__c = '契約満了'; contract.Maintenance_Contract_No__c = '11123'; contract.recordtypeId = Schema.SObjectType.Maintenance_Contract__c.getRecordTypeInfosByDeveloperName().get('NewMaintenance_Contract').getRecordTypeId(); contract.Not_Upper_limit_reason__c = ' 1'; contract.Contract_Start_Date__c = Date.today().addDays(-5); contract.Contract_End_Date__c = Date.today().addDays(5); contract.SalesOfficeCode_selection__c = '北京RC'; contract.New_Contract_TypeF_Text__c = '续签合同'; contract.IF_Target_Renew__c='1'; contract.Contract_Conclusion_Date__c=Date.today().addDays(-5); // system.assertEquals(contract.Contract_End_Date__c >= Date.newInstance(2021,10,1) && contract.Contract_End_Date__c <= Date.newInstance(2022,9,30),true); insert contract; NewMaintenanceReport_Task__c tempNMCT = new NewMaintenanceReport_Task__c(); tempNMCT.Name = 'FWreport-01'; tempNMCT.Distribution_Start_Date__c = Date.today().addDays(-30); tempNMCT.Distribution_End_Date__c = Date.today().addMonths(2).addDays(-1); tempNMCT.NewMaintenance_Contract__c = contract.Id; tempNMCT.ActualDistributionTimes_Quarter__c = 0; insert tempNMCT; String jsonRecords = System.JSON.serialize(pros); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(70)); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(3)); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2',''); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId',null); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId','123456'); eventLineMap.put('IsOPDPlan',true); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecordNull); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId','123456'); eventLineMap.put('IsOPDPlan',true); eventLineMap.put('OpportunityId',null); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId','123456'); eventLineMap.put('IsOPDPlan',true); eventLineMap.put('OpportunityId',opp.Id); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); Map saveEventMap = new Map(); saveEventMap.put('StartTime',Datetime.now().addDays(1)); saveEventMap.put('EndTime',Datetime.now().addDays(1)); saveEventMap.put('ActivityType2','病院'); saveEventMap.put('PurposeTypeFSE','招标对应'); saveEventMap.put('ActivityPurposeFSE','询价推进'); saveEventMap.put('NoOppReason','HCP对应'); saveEventMap.put('IsOPDPlan',true); saveEventMap.put('AccountId',acc.Id); saveEventMap.put('ContactId',null); saveEventMap.put('OpportunityId',opp1.Id); saveEventMap.put('ProjectId',null); saveEventMap.put('ServiceId',contract.Id); User LoginUser = [SELECT Id, Name, Job_Category__c FROM User WHERE Id = :UserInfo.getUserId()]; String saveEventRecords = JSON.serialize(saveEventMap); LoginUser.Job_Category__c = '销售推广'; update LoginUser; saveEventMap.put('AccountId',cam.Id); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('ActivityType2','病院'); saveEventMap.put('AccountId',acc.Id); saveEventMap.put('OpportunityId',null); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('ActivityType2','販売店'); saveEventMap.put('AccountId',acc.Id); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('ActivityType2','社外イベント'); saveEventMap.put('AccountId',cam.Id); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('PurposeTypeFSE','合同季报'); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('PurposeTypeFSE','合同点检'); saveEventRecords = JSON.serialize(saveEventMap); List proLines = new List(); ProLine proLine1 = new ProLine(); // proLine1.Id = planRE.Id; proLine1.Quantity = 10; proLine1.Name = 'CF-H170I1'; proLine1.ProductCode= 'N4480080'; proLine1.ProductModel= '1001'; proLines.add(proLine1); String reRecords = System.JSON.serialize(proLines); // LoginUser.Job_Category__c = '销售服务'; // update LoginUser; // lexCreateEventButton.saveEvent(saveEventRecords,jsonRecords); Integer year = date.today().year(); Integer month = date.today().month(); Integer days = date.today().day(); List ecL=new List(); Event insertTarget = new Event(); insertTarget.Subject = 'test00'; insertTarget.StartDateTime = Datetime.now().adddays(5); insertTarget.EndDateTime = Datetime.now().adddays(5).addMinutes(60); insertTarget.Location = 'testLocation'; insertTarget.Activity_Type2__c = '病院'; insertTarget.OPDPlan_Flag__c = true ; insertTarget.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; insertTarget.EventStatus__c = ' 02 接受'; insertTarget.whatid__c = acc.Id; Event insertTarget2 = new Event(); insertTarget2.Subject = 'test00'; insertTarget2.StartDateTime = Datetime.now().adddays(5); insertTarget2.EndDateTime = Datetime.now().adddays(5).addMinutes(60); insertTarget2.Location = 'testLocation'; insertTarget2.Activity_Type2__c = '病院'; insertTarget2.OPDPlan_Flag__c = true ; insertTarget2.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; insertTarget2.EventStatus__c = ' 04 取消'; insertTarget2.whatid__c = acc.Id; Event insertTarget3 = new Event(); insertTarget3.Subject = 'test00'; insertTarget3.StartDateTime = Datetime.now().adddays(5); insertTarget3.EndDateTime = Datetime.now().adddays(5).addMinutes(60); insertTarget3.Location = 'testLocation'; insertTarget3.Activity_Type2__c = '病院'; insertTarget3.OPDPlan_Flag__c = true ; insertTarget3.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; insertTarget3.EventStatus__c = ' 05 延期'; insertTarget3.whatid__c = acc.Id; ecL.add(insertTarget); ecL.add(insertTarget2); ecL.add(insertTarget3); insert ecL; List tasks = new List(); task__c t1 = new task__c(); t1.Name = 'test1'; t1.taskDifferent__c = '主动任务'; t1.taskStatus__c = '02 接受'; t1.assignee__c = Userinfo.getUserId(); t1.Activity_Date__c = Date.newInstance(year, month,days); tasks.add(t1); task__c t2 = new task__c(); t2.Name = 'test2'; t2.taskDifferent__c = '主动任务'; t2.taskStatus__c = '02 接受'; t2.assignee__c = Userinfo.getUserId(); t2.Activity_Date__c = Date.newInstance(2021, 8, 17); tasks.add(t2); insert tasks; String eventid = insertTarget.Id; String taskId = t1.Id; String accid = acc.Id; String cid = cam.Id; String oid = opp.Id; String mid = contract.Id; String source = 'AccountPCL'; lexCreateEventButton.confirmCheck(t1, insertTarget); lexCreateEventButton.getOppQuoteItems(reRecords,opp.Id); Test.stopTest(); } catch (Exception e) { System.debug('123'); } } static testMethod void init4() { try { Oly_TriggerHandler.bypass('ContactTriggerHandler'); Oly_TriggerHandler.bypass('PowerBIBaseHandler'); Oly_TriggerHandler.bypass('AgencyOppUpdHandler'); Oly_TriggerHandler.bypass('UpdateContractAimAmountHandler'); Oly_TriggerHandler.bypass('NFM701ControllerHandler'); StaticParameter.EscapeNFM001AgencyContractTrigger = true; StaticParameter.EscapeContactToUser = true; ControllerUtil.EscapeNFM001Trigger = true; lexCreateEventButton.getNowDateTime(); lexCreateEventButton.getEndDateTime(); lexCreateEventButton.getUserJobCategory(); Map eventLineMap = new Map(); eventLineMap.put('StartTime',Datetime.now()); eventLineMap.put('EndTime',Datetime.now()); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('OpportunityId',null); eventLineMap.put('ActivityPurposeFSE','信息收集'); eventLineMap.put('IsOPDPlan','true'); String jsonEvents = JSON.serialize(eventLineMap); List pros = new List(); String jsonRecordNull = System.JSON.serialize(pros); ProLine pro = new ProLine(); // pro.Id = planRE.Id; pro.Quantity = 10; pro.Name = 'CF-H170I1'; pro.ProductCode= 'N4480080'; pro.ProductModel= 'CF-H170I1'; pros.add(pro); RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI']; // List rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_GI', 'Department_BF') order by DeveloperName desc]; 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; Address_Level__c al = new Address_Level__c(); al.Name = '東京'; al.Level1_Code__c = 'CN-99'; al.Level1_Sys_No__c = '999999'; insert al; // 市 Address_Level2__c al2 = new Address_Level2__c(); al2.Level1_Code__c = 'CN-99'; al2.Level1_Sys_No__c = '999999'; al2.Level1_Name__c = '東京'; al2.Name = '渋谷区'; al2.Level2_Code__c = 'CN-9999'; al2.Level2_Sys_No__c = '9999999'; al2.Address_Level__c = al.id; insert al2; Account hospital = new Account(); hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id; hospital.Name = 'test hospital'; hospital.Is_Active__c = '有効'; hospital.Attribute_Type__c = '卫生部'; hospital.Speciality_Type__c = '综合医院'; hospital.Grade__c = '一级'; hospital.OCM_Category__c = 'SLTV'; hospital.Is_Medical__c = '医疗机构'; hospital.State_Master__c = al.id; hospital.City_Master__c = al2.id; hospital.Town__c = '东京'; insert hospital; // 戦略科室を得る Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH']; // 診療科を作る Account acc = new Account(); acc.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id; acc.Name = 'test dep'; acc.AgentCode_Ext__c = '9999998'; acc.ParentId = strategicDep[0].Id; acc.Department_Class__c = strategicDep[0].Id; acc.Hospital__c = hospital.Id; insert acc; Test.startTest(); Opportunity opp = new Opportunity( Name='Opp', StageName='出荷', // Status_Formula_Option__c = '06 已发货', CloseDate=Date.today().addDays(10), Close_Forecasted_Date__c=Date.today(), // Department_Class__c = strategicDep[0].Id, CurrencyIsoCode = 'CNY' ); insert opp; // Quote q = new Quote( // Name = 'quote', // OpportunityId = opp.Id, // Pricebook2Id = pricebookId // ); // insert q; // opp.Estimation_Id__c = q.Id; Opportunity opp1 = new Opportunity( Name='Opp', StageName='引合', AccountId = acc.Id, Status_Formula_Option__c = '12 已签约', CloseDate=Date.today().addDays(10), Close_Forecasted_Date__c=Date.today(), // RecordTypeId = oppRecord.Id, // Department_Class__c = strategicDep[0].Id, CurrencyIsoCode = 'CNY' ); insert opp1; Maintenance_Contract__c contract = new Maintenance_Contract__c(); contract.Name = 'tect contract'; contract.Hospital__c = hospital.Id; contract.Department_Class__c = strategicDep[0].Id; contract.Department__c = acc.Id; contract.Service_Contract_Staff__c = UserInfo.getUserId(); contract.Payment_Plan_Sum_First__c = 1; contract.Status__c = '契約満了'; contract.Maintenance_Contract_No__c = '11123'; contract.recordtypeId = Schema.SObjectType.Maintenance_Contract__c.getRecordTypeInfosByDeveloperName().get('NewMaintenance_Contract').getRecordTypeId(); contract.Not_Upper_limit_reason__c = ' 1'; contract.Contract_Start_Date__c = Date.today().addDays(-5); contract.Contract_End_Date__c = Date.today().addDays(5); contract.SalesOfficeCode_selection__c = '北京RC'; contract.New_Contract_TypeF_Text__c = '续签合同'; contract.IF_Target_Renew__c='1'; contract.Contract_Conclusion_Date__c=Date.today().addDays(-5); // system.assertEquals(contract.Contract_End_Date__c >= Date.newInstance(2021,10,1) && contract.Contract_End_Date__c <= Date.newInstance(2022,9,30),true); insert contract; NewMaintenanceReport_Task__c tempNMCT = new NewMaintenanceReport_Task__c(); tempNMCT.Name = 'FWreport-01'; tempNMCT.Distribution_Start_Date__c = Date.today().addDays(-30); tempNMCT.Distribution_End_Date__c = Date.today().addMonths(2).addDays(-1); tempNMCT.NewMaintenance_Contract__c = contract.Id; tempNMCT.ActualDistributionTimes_Quarter__c = 0; insert tempNMCT; String jsonRecords = System.JSON.serialize(pros); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(70)); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(3)); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2',''); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId',null); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId','123456'); eventLineMap.put('IsOPDPlan',true); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecordNull); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId','123456'); eventLineMap.put('IsOPDPlan',true); eventLineMap.put('OpportunityId',null); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId','123456'); eventLineMap.put('IsOPDPlan',true); eventLineMap.put('OpportunityId',opp.Id); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); Map saveEventMap = new Map(); saveEventMap.put('StartTime',Datetime.now().addDays(1)); saveEventMap.put('EndTime',Datetime.now().addDays(1)); saveEventMap.put('ActivityType2','病院'); saveEventMap.put('PurposeTypeFSE','招标对应'); saveEventMap.put('ActivityPurposeFSE','询价推进'); saveEventMap.put('NoOppReason','HCP对应'); saveEventMap.put('IsOPDPlan',true); saveEventMap.put('AccountId',acc.Id); saveEventMap.put('ContactId',null); saveEventMap.put('OpportunityId',opp1.Id); saveEventMap.put('ProjectId',null); saveEventMap.put('ServiceId',contract.Id); User LoginUser = [SELECT Id, Name, Job_Category__c FROM User WHERE Id = :UserInfo.getUserId()]; String saveEventRecords = JSON.serialize(saveEventMap); LoginUser.Job_Category__c = '销售推广'; update LoginUser; saveEventMap.put('AccountId',cam.Id); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('ActivityType2','病院'); saveEventMap.put('AccountId',acc.Id); saveEventMap.put('OpportunityId',null); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('ActivityType2','販売店'); saveEventMap.put('AccountId',acc.Id); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('ActivityType2','社外イベント'); saveEventMap.put('AccountId',cam.Id); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('PurposeTypeFSE','合同季报'); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('PurposeTypeFSE','合同点检'); saveEventRecords = JSON.serialize(saveEventMap); List proLines = new List(); ProLine proLine1 = new ProLine(); // proLine1.Id = planRE.Id; proLine1.Quantity = 10; proLine1.Name = 'CF-H170I1'; proLine1.ProductCode= 'N4480080'; proLine1.ProductModel= '1001'; proLines.add(proLine1); String reRecords = System.JSON.serialize(proLines); // LoginUser.Job_Category__c = '销售服务'; // update LoginUser; // lexCreateEventButton.saveEvent(saveEventRecords,jsonRecords); Integer year = date.today().year(); Integer month = date.today().month(); Integer days = date.today().day(); List ecL=new List(); Event insertTarget = new Event(); insertTarget.Subject = 'test00'; insertTarget.StartDateTime = Datetime.now().adddays(5); insertTarget.EndDateTime = Datetime.now().adddays(5).addMinutes(60); insertTarget.Location = 'testLocation'; insertTarget.Activity_Type2__c = '病院'; insertTarget.OPDPlan_Flag__c = true ; insertTarget.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; insertTarget.EventStatus__c = ' 02 接受'; insertTarget.whatid__c = acc.Id; Event insertTarget2 = new Event(); insertTarget2.Subject = 'test00'; insertTarget2.StartDateTime = Datetime.now().adddays(5); insertTarget2.EndDateTime = Datetime.now().adddays(5).addMinutes(60); insertTarget2.Location = 'testLocation'; insertTarget2.Activity_Type2__c = '病院'; insertTarget2.OPDPlan_Flag__c = true ; insertTarget2.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; insertTarget2.EventStatus__c = ' 04 取消'; insertTarget2.whatid__c = acc.Id; Event insertTarget3 = new Event(); insertTarget3.Subject = 'test00'; insertTarget3.StartDateTime = Datetime.now().adddays(5); insertTarget3.EndDateTime = Datetime.now().adddays(5).addMinutes(60); insertTarget3.Location = 'testLocation'; insertTarget3.Activity_Type2__c = '病院'; insertTarget3.OPDPlan_Flag__c = true ; insertTarget3.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; insertTarget3.EventStatus__c = ' 05 延期'; insertTarget3.whatid__c = acc.Id; ecL.add(insertTarget); ecL.add(insertTarget2); ecL.add(insertTarget3); insert ecL; List tasks = new List(); task__c t1 = new task__c(); t1.Name = 'test1'; t1.taskDifferent__c = '主动任务'; t1.taskStatus__c = '02 接受'; t1.assignee__c = Userinfo.getUserId(); t1.Activity_Date__c = Date.newInstance(year, month,days); tasks.add(t1); task__c t2 = new task__c(); t2.Name = 'test2'; t2.taskDifferent__c = '主动任务'; t2.taskStatus__c = '02 接受'; t2.assignee__c = Userinfo.getUserId(); t2.Activity_Date__c = Date.newInstance(2021, 8, 17); tasks.add(t2); insert tasks; String eventid = insertTarget.Id; String taskId = t1.Id; String accid = acc.Id; String cid = cam.Id; String oid = opp.Id; String mid = contract.Id; String source = 'AccountPCL'; lexCreateEventButton.initEvent(eventid,taskId, accid, cid, oid, mid, source); Test.stopTest(); } catch (Exception e) { System.debug('123'); } } static testMethod void init5() { try { Oly_TriggerHandler.bypass('ContactTriggerHandler'); Oly_TriggerHandler.bypass('PowerBIBaseHandler'); Oly_TriggerHandler.bypass('AgencyOppUpdHandler'); Oly_TriggerHandler.bypass('UpdateContractAimAmountHandler'); Oly_TriggerHandler.bypass('NFM701ControllerHandler'); StaticParameter.EscapeNFM001AgencyContractTrigger = true; StaticParameter.EscapeContactToUser = true; ControllerUtil.EscapeNFM001Trigger = true; lexCreateEventButton.getNowDateTime(); lexCreateEventButton.getEndDateTime(); lexCreateEventButton.getUserJobCategory(); Map eventLineMap = new Map(); eventLineMap.put('StartTime',Datetime.now()); eventLineMap.put('EndTime',Datetime.now()); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('OpportunityId',null); eventLineMap.put('ActivityPurposeFSE','信息收集'); eventLineMap.put('IsOPDPlan','true'); String jsonEvents = JSON.serialize(eventLineMap); List pros = new List(); String jsonRecordNull = System.JSON.serialize(pros); ProLine pro = new ProLine(); // pro.Id = planRE.Id; pro.Quantity = 10; pro.Name = 'CF-H170I1'; pro.ProductCode= 'N4480080'; pro.ProductModel= 'CF-H170I1'; pros.add(pro); RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI']; // List rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_GI', 'Department_BF') order by DeveloperName desc]; 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; Address_Level__c al = new Address_Level__c(); al.Name = '東京'; al.Level1_Code__c = 'CN-99'; al.Level1_Sys_No__c = '999999'; insert al; // 市 Address_Level2__c al2 = new Address_Level2__c(); al2.Level1_Code__c = 'CN-99'; al2.Level1_Sys_No__c = '999999'; al2.Level1_Name__c = '東京'; al2.Name = '渋谷区'; al2.Level2_Code__c = 'CN-9999'; al2.Level2_Sys_No__c = '9999999'; al2.Address_Level__c = al.id; insert al2; Account hospital = new Account(); hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id; hospital.Name = 'test hospital'; hospital.Is_Active__c = '有効'; hospital.Attribute_Type__c = '卫生部'; hospital.Speciality_Type__c = '综合医院'; hospital.Grade__c = '一级'; hospital.OCM_Category__c = 'SLTV'; hospital.Is_Medical__c = '医疗机构'; hospital.State_Master__c = al.id; hospital.City_Master__c = al2.id; hospital.Town__c = '东京'; insert hospital; // 戦略科室を得る Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH']; // 診療科を作る Account acc = new Account(); acc.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id; acc.Name = 'test dep'; acc.AgentCode_Ext__c = '9999998'; acc.ParentId = strategicDep[0].Id; acc.Department_Class__c = strategicDep[0].Id; acc.Hospital__c = hospital.Id; insert acc; Test.startTest(); Opportunity opp = new Opportunity( Name='Opp', StageName='出荷', // Status_Formula_Option__c = '06 已发货', CloseDate=Date.today().addDays(10), Close_Forecasted_Date__c=Date.today(), // Department_Class__c = strategicDep[0].Id, CurrencyIsoCode = 'CNY' ); insert opp; // Quote q = new Quote( // Name = 'quote', // OpportunityId = opp.Id, // Pricebook2Id = pricebookId // ); // insert q; // opp.Estimation_Id__c = q.Id; Opportunity opp1 = new Opportunity( Name='Opp', StageName='引合', AccountId = acc.Id, Status_Formula_Option__c = '12 已签约', CloseDate=Date.today().addDays(10), Close_Forecasted_Date__c=Date.today(), // RecordTypeId = oppRecord.Id, // Department_Class__c = strategicDep[0].Id, CurrencyIsoCode = 'CNY' ); insert opp1; Maintenance_Contract__c contract = new Maintenance_Contract__c(); contract.Name = 'tect contract'; contract.Hospital__c = hospital.Id; contract.Department_Class__c = strategicDep[0].Id; contract.Department__c = acc.Id; contract.Service_Contract_Staff__c = UserInfo.getUserId(); contract.Payment_Plan_Sum_First__c = 1; contract.Status__c = '契約満了'; contract.Maintenance_Contract_No__c = '11123'; contract.recordtypeId = Schema.SObjectType.Maintenance_Contract__c.getRecordTypeInfosByDeveloperName().get('NewMaintenance_Contract').getRecordTypeId(); contract.Not_Upper_limit_reason__c = ' 1'; contract.Contract_Start_Date__c = Date.today().addDays(-5); contract.Contract_End_Date__c = Date.today().addDays(5); contract.SalesOfficeCode_selection__c = '北京RC'; contract.New_Contract_TypeF_Text__c = '续签合同'; contract.IF_Target_Renew__c='1'; contract.Contract_Conclusion_Date__c=Date.today().addDays(-5); // system.assertEquals(contract.Contract_End_Date__c >= Date.newInstance(2021,10,1) && contract.Contract_End_Date__c <= Date.newInstance(2022,9,30),true); insert contract; NewMaintenanceReport_Task__c tempNMCT = new NewMaintenanceReport_Task__c(); tempNMCT.Name = 'FWreport-01'; tempNMCT.Distribution_Start_Date__c = Date.today().addDays(-30); tempNMCT.Distribution_End_Date__c = Date.today().addMonths(2).addDays(-1); tempNMCT.NewMaintenance_Contract__c = contract.Id; tempNMCT.ActualDistributionTimes_Quarter__c = 0; insert tempNMCT; String jsonRecords = System.JSON.serialize(pros); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(70)); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(3)); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2',''); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId',null); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId','123456'); eventLineMap.put('IsOPDPlan',true); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecordNull); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId','123456'); eventLineMap.put('IsOPDPlan',true); eventLineMap.put('OpportunityId',null); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId','123456'); eventLineMap.put('IsOPDPlan',true); eventLineMap.put('OpportunityId',opp.Id); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); Map saveEventMap = new Map(); saveEventMap.put('StartTime',Datetime.now().addDays(1)); saveEventMap.put('EndTime',Datetime.now().addDays(1)); saveEventMap.put('ActivityType2','病院'); saveEventMap.put('PurposeTypeFSE','招标对应'); saveEventMap.put('ActivityPurposeFSE','询价推进'); saveEventMap.put('NoOppReason','HCP对应'); saveEventMap.put('IsOPDPlan',true); saveEventMap.put('AccountId',acc.Id); saveEventMap.put('ContactId',null); saveEventMap.put('OpportunityId',opp1.Id); saveEventMap.put('ProjectId',null); saveEventMap.put('ServiceId',contract.Id); User LoginUser = [SELECT Id, Name, Job_Category__c FROM User WHERE Id = :UserInfo.getUserId()]; String saveEventRecords = JSON.serialize(saveEventMap); LoginUser.Job_Category__c = '销售推广'; update LoginUser; saveEventMap.put('AccountId',cam.Id); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('ActivityType2','病院'); saveEventMap.put('AccountId',acc.Id); saveEventMap.put('OpportunityId',null); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('ActivityType2','販売店'); saveEventMap.put('AccountId',acc.Id); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('ActivityType2','社外イベント'); saveEventMap.put('AccountId',cam.Id); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('PurposeTypeFSE','合同季报'); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('PurposeTypeFSE','合同点检'); saveEventRecords = JSON.serialize(saveEventMap); List proLines = new List(); ProLine proLine1 = new ProLine(); // proLine1.Id = planRE.Id; proLine1.Quantity = 10; proLine1.Name = 'CF-H170I1'; proLine1.ProductCode= 'N4480080'; proLine1.ProductModel= '1001'; proLines.add(proLine1); String reRecords = System.JSON.serialize(proLines); // LoginUser.Job_Category__c = '销售服务'; // update LoginUser; // lexCreateEventButton.saveEvent(saveEventRecords,jsonRecords); Integer year = date.today().year(); Integer month = date.today().month(); Integer days = date.today().day(); List ecL=new List(); Event insertTarget = new Event(); insertTarget.Subject = 'test00'; insertTarget.StartDateTime = Datetime.now().adddays(5); insertTarget.EndDateTime = Datetime.now().adddays(5).addMinutes(60); insertTarget.Location = 'testLocation'; insertTarget.Activity_Type2__c = '病院'; insertTarget.OPDPlan_Flag__c = true ; insertTarget.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; insertTarget.EventStatus__c = ' 02 接受'; insertTarget.whatid__c = acc.Id; Event insertTarget2 = new Event(); insertTarget2.Subject = 'test00'; insertTarget2.StartDateTime = Datetime.now().adddays(5); insertTarget2.EndDateTime = Datetime.now().adddays(5).addMinutes(60); insertTarget2.Location = 'testLocation'; insertTarget2.Activity_Type2__c = '病院'; insertTarget2.OPDPlan_Flag__c = true ; insertTarget2.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; insertTarget2.EventStatus__c = ' 04 取消'; insertTarget2.whatid__c = acc.Id; Event insertTarget3 = new Event(); insertTarget3.Subject = 'test00'; insertTarget3.StartDateTime = Datetime.now().adddays(5); insertTarget3.EndDateTime = Datetime.now().adddays(5).addMinutes(60); insertTarget3.Location = 'testLocation'; insertTarget3.Activity_Type2__c = '病院'; insertTarget3.OPDPlan_Flag__c = true ; insertTarget3.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; insertTarget3.EventStatus__c = ' 05 延期'; insertTarget3.whatid__c = acc.Id; ecL.add(insertTarget); ecL.add(insertTarget2); ecL.add(insertTarget3); insert ecL; List tasks = new List(); task__c t1 = new task__c(); t1.Name = 'test1'; t1.taskDifferent__c = '主动任务'; t1.taskStatus__c = '02 接受'; t1.assignee__c = Userinfo.getUserId(); t1.Activity_Date__c = Date.newInstance(year, month,days); tasks.add(t1); task__c t2 = new task__c(); t2.Name = 'test2'; t2.taskDifferent__c = '主动任务'; t2.taskStatus__c = '02 接受'; t2.assignee__c = Userinfo.getUserId(); t2.Activity_Date__c = Date.newInstance(2021, 8, 17); tasks.add(t2); insert tasks; String eventid = insertTarget.Id; String taskId = t1.Id; String accid = acc.Id; String cid = cam.Id; String oid = opp.Id; String mid = contract.Id; String source = 'AccountPCL'; eventid = ''; lexCreateEventButton.initEvent(eventid, taskId, accid, cid, oid, mid, source); Test.stopTest(); } catch (Exception e) { System.debug('123'); } } static testMethod void init6() { try { Oly_TriggerHandler.bypass('ContactTriggerHandler'); Oly_TriggerHandler.bypass('PowerBIBaseHandler'); Oly_TriggerHandler.bypass('AgencyOppUpdHandler'); Oly_TriggerHandler.bypass('UpdateContractAimAmountHandler'); Oly_TriggerHandler.bypass('NFM701ControllerHandler'); StaticParameter.EscapeNFM001AgencyContractTrigger = true; StaticParameter.EscapeContactToUser = true; ControllerUtil.EscapeNFM001Trigger = true; lexCreateEventButton.getNowDateTime(); lexCreateEventButton.getEndDateTime(); lexCreateEventButton.getUserJobCategory(); Map eventLineMap = new Map(); eventLineMap.put('StartTime',Datetime.now()); eventLineMap.put('EndTime',Datetime.now()); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('OpportunityId',null); eventLineMap.put('ActivityPurposeFSE','信息收集'); eventLineMap.put('IsOPDPlan','true'); String jsonEvents = JSON.serialize(eventLineMap); List pros = new List(); String jsonRecordNull = System.JSON.serialize(pros); ProLine pro = new ProLine(); // pro.Id = planRE.Id; pro.Quantity = 10; pro.Name = 'CF-H170I1'; pro.ProductCode= 'N4480080'; pro.ProductModel= 'CF-H170I1'; pros.add(pro); RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI']; // List rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_GI', 'Department_BF') order by DeveloperName desc]; 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; Address_Level__c al = new Address_Level__c(); al.Name = '東京'; al.Level1_Code__c = 'CN-99'; al.Level1_Sys_No__c = '999999'; insert al; // 市 Address_Level2__c al2 = new Address_Level2__c(); al2.Level1_Code__c = 'CN-99'; al2.Level1_Sys_No__c = '999999'; al2.Level1_Name__c = '東京'; al2.Name = '渋谷区'; al2.Level2_Code__c = 'CN-9999'; al2.Level2_Sys_No__c = '9999999'; al2.Address_Level__c = al.id; insert al2; Account hospital = new Account(); hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id; hospital.Name = 'test hospital'; hospital.Is_Active__c = '有効'; hospital.Attribute_Type__c = '卫生部'; hospital.Speciality_Type__c = '综合医院'; hospital.Grade__c = '一级'; hospital.OCM_Category__c = 'SLTV'; hospital.Is_Medical__c = '医疗机构'; hospital.State_Master__c = al.id; hospital.City_Master__c = al2.id; hospital.Town__c = '东京'; insert hospital; // 戦略科室を得る Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH']; // 診療科を作る Account acc = new Account(); acc.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id; acc.Name = 'test dep'; acc.AgentCode_Ext__c = '9999998'; acc.ParentId = strategicDep[0].Id; acc.Department_Class__c = strategicDep[0].Id; acc.Hospital__c = hospital.Id; insert acc; Test.startTest(); Opportunity opp = new Opportunity( Name='Opp', StageName='出荷', // Status_Formula_Option__c = '06 已发货', CloseDate=Date.today().addDays(10), Close_Forecasted_Date__c=Date.today(), // Department_Class__c = strategicDep[0].Id, CurrencyIsoCode = 'CNY' ); insert opp; // Quote q = new Quote( // Name = 'quote', // OpportunityId = opp.Id, // Pricebook2Id = pricebookId // ); // insert q; // opp.Estimation_Id__c = q.Id; Opportunity opp1 = new Opportunity( Name='Opp', StageName='引合', AccountId = acc.Id, Status_Formula_Option__c = '12 已签约', CloseDate=Date.today().addDays(10), Close_Forecasted_Date__c=Date.today(), // RecordTypeId = oppRecord.Id, // Department_Class__c = strategicDep[0].Id, CurrencyIsoCode = 'CNY' ); insert opp1; Maintenance_Contract__c contract = new Maintenance_Contract__c(); contract.Name = 'tect contract'; contract.Hospital__c = hospital.Id; contract.Department_Class__c = strategicDep[0].Id; contract.Department__c = acc.Id; contract.Service_Contract_Staff__c = UserInfo.getUserId(); contract.Payment_Plan_Sum_First__c = 1; contract.Status__c = '契約満了'; contract.Maintenance_Contract_No__c = '11123'; contract.recordtypeId = Schema.SObjectType.Maintenance_Contract__c.getRecordTypeInfosByDeveloperName().get('NewMaintenance_Contract').getRecordTypeId(); contract.Not_Upper_limit_reason__c = ' 1'; contract.Contract_Start_Date__c = Date.today().addDays(-5); contract.Contract_End_Date__c = Date.today().addDays(5); contract.SalesOfficeCode_selection__c = '北京RC'; contract.New_Contract_TypeF_Text__c = '续签合同'; contract.IF_Target_Renew__c='1'; contract.Contract_Conclusion_Date__c=Date.today().addDays(-5); // system.assertEquals(contract.Contract_End_Date__c >= Date.newInstance(2021,10,1) && contract.Contract_End_Date__c <= Date.newInstance(2022,9,30),true); insert contract; NewMaintenanceReport_Task__c tempNMCT = new NewMaintenanceReport_Task__c(); tempNMCT.Name = 'FWreport-01'; tempNMCT.Distribution_Start_Date__c = Date.today().addDays(-30); tempNMCT.Distribution_End_Date__c = Date.today().addMonths(2).addDays(-1); tempNMCT.NewMaintenance_Contract__c = contract.Id; tempNMCT.ActualDistributionTimes_Quarter__c = 0; insert tempNMCT; String jsonRecords = System.JSON.serialize(pros); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(70)); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(3)); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2',''); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId',null); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId','123456'); eventLineMap.put('IsOPDPlan',true); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecordNull); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId','123456'); eventLineMap.put('IsOPDPlan',true); eventLineMap.put('OpportunityId',null); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId','123456'); eventLineMap.put('IsOPDPlan',true); eventLineMap.put('OpportunityId',opp.Id); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); Map saveEventMap = new Map(); saveEventMap.put('StartTime',Datetime.now().addDays(1)); saveEventMap.put('EndTime',Datetime.now().addDays(1)); saveEventMap.put('ActivityType2','病院'); saveEventMap.put('PurposeTypeFSE','招标对应'); saveEventMap.put('ActivityPurposeFSE','询价推进'); saveEventMap.put('NoOppReason','HCP对应'); saveEventMap.put('IsOPDPlan',true); saveEventMap.put('AccountId',acc.Id); saveEventMap.put('ContactId',null); saveEventMap.put('OpportunityId',opp1.Id); saveEventMap.put('ProjectId',null); saveEventMap.put('ServiceId',contract.Id); User LoginUser = [SELECT Id, Name, Job_Category__c FROM User WHERE Id = :UserInfo.getUserId()]; String saveEventRecords = JSON.serialize(saveEventMap); LoginUser.Job_Category__c = '销售推广'; update LoginUser; saveEventMap.put('AccountId',cam.Id); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('ActivityType2','病院'); saveEventMap.put('AccountId',acc.Id); saveEventMap.put('OpportunityId',null); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('ActivityType2','販売店'); saveEventMap.put('AccountId',acc.Id); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('ActivityType2','社外イベント'); saveEventMap.put('AccountId',cam.Id); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('PurposeTypeFSE','合同季报'); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('PurposeTypeFSE','合同点检'); saveEventRecords = JSON.serialize(saveEventMap); List proLines = new List(); ProLine proLine1 = new ProLine(); // proLine1.Id = planRE.Id; proLine1.Quantity = 10; proLine1.Name = 'CF-H170I1'; proLine1.ProductCode= 'N4480080'; proLine1.ProductModel= '1001'; proLines.add(proLine1); String reRecords = System.JSON.serialize(proLines); // LoginUser.Job_Category__c = '销售服务'; // update LoginUser; // lexCreateEventButton.saveEvent(saveEventRecords,jsonRecords); Integer year = date.today().year(); Integer month = date.today().month(); Integer days = date.today().day(); List ecL=new List(); Event insertTarget = new Event(); insertTarget.Subject = 'test00'; insertTarget.StartDateTime = Datetime.now().adddays(5); insertTarget.EndDateTime = Datetime.now().adddays(5).addMinutes(60); insertTarget.Location = 'testLocation'; insertTarget.Activity_Type2__c = '病院'; insertTarget.OPDPlan_Flag__c = true ; insertTarget.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; insertTarget.EventStatus__c = ' 02 接受'; insertTarget.whatid__c = acc.Id; Event insertTarget2 = new Event(); insertTarget2.Subject = 'test00'; insertTarget2.StartDateTime = Datetime.now().adddays(5); insertTarget2.EndDateTime = Datetime.now().adddays(5).addMinutes(60); insertTarget2.Location = 'testLocation'; insertTarget2.Activity_Type2__c = '病院'; insertTarget2.OPDPlan_Flag__c = true ; insertTarget2.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; insertTarget2.EventStatus__c = ' 04 取消'; insertTarget2.whatid__c = acc.Id; Event insertTarget3 = new Event(); insertTarget3.Subject = 'test00'; insertTarget3.StartDateTime = Datetime.now().adddays(5); insertTarget3.EndDateTime = Datetime.now().adddays(5).addMinutes(60); insertTarget3.Location = 'testLocation'; insertTarget3.Activity_Type2__c = '病院'; insertTarget3.OPDPlan_Flag__c = true ; insertTarget3.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; insertTarget3.EventStatus__c = ' 05 延期'; insertTarget3.whatid__c = acc.Id; ecL.add(insertTarget); ecL.add(insertTarget2); ecL.add(insertTarget3); insert ecL; List tasks = new List(); task__c t1 = new task__c(); t1.Name = 'test1'; t1.taskDifferent__c = '主动任务'; t1.taskStatus__c = '02 接受'; t1.assignee__c = Userinfo.getUserId(); t1.Activity_Date__c = Date.newInstance(year, month,days); tasks.add(t1); task__c t2 = new task__c(); t2.Name = 'test2'; t2.taskDifferent__c = '主动任务'; t2.taskStatus__c = '02 接受'; t2.assignee__c = Userinfo.getUserId(); t2.Activity_Date__c = Date.newInstance(2021, 8, 17); tasks.add(t2); insert tasks; String eventid = insertTarget.Id; String taskId = t1.Id; String accid = acc.Id; String cid = cam.Id; String oid = opp.Id; String mid = contract.Id; String source = 'AccountPCL'; eventid = ''; taskId = ''; lexCreateEventButton.initEvent(eventid, taskId, accid, cid, oid, mid, source); Test.stopTest(); } catch (Exception e) { System.debug('123'); } } static testMethod void init8() { try { Oly_TriggerHandler.bypass('ContactTriggerHandler'); Oly_TriggerHandler.bypass('PowerBIBaseHandler'); Oly_TriggerHandler.bypass('AgencyOppUpdHandler'); Oly_TriggerHandler.bypass('UpdateContractAimAmountHandler'); Oly_TriggerHandler.bypass('NFM701ControllerHandler'); StaticParameter.EscapeNFM001AgencyContractTrigger = true; StaticParameter.EscapeContactToUser = true; ControllerUtil.EscapeNFM001Trigger = true; lexCreateEventButton.getNowDateTime(); lexCreateEventButton.getEndDateTime(); lexCreateEventButton.getUserJobCategory(); Map eventLineMap = new Map(); eventLineMap.put('StartTime',Datetime.now()); eventLineMap.put('EndTime',Datetime.now()); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('OpportunityId',null); eventLineMap.put('ActivityPurposeFSE','信息收集'); eventLineMap.put('IsOPDPlan','true'); String jsonEvents = JSON.serialize(eventLineMap); List pros = new List(); String jsonRecordNull = System.JSON.serialize(pros); ProLine pro = new ProLine(); // pro.Id = planRE.Id; pro.Quantity = 10; pro.Name = 'CF-H170I1'; pro.ProductCode= 'N4480080'; pro.ProductModel= 'CF-H170I1'; pros.add(pro); RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI']; // List rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_GI', 'Department_BF') order by DeveloperName desc]; 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; Address_Level__c al = new Address_Level__c(); al.Name = '東京'; al.Level1_Code__c = 'CN-99'; al.Level1_Sys_No__c = '999999'; insert al; // 市 Address_Level2__c al2 = new Address_Level2__c(); al2.Level1_Code__c = 'CN-99'; al2.Level1_Sys_No__c = '999999'; al2.Level1_Name__c = '東京'; al2.Name = '渋谷区'; al2.Level2_Code__c = 'CN-9999'; al2.Level2_Sys_No__c = '9999999'; al2.Address_Level__c = al.id; insert al2; Account hospital = new Account(); hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id; hospital.Name = 'test hospital'; hospital.Is_Active__c = '有効'; hospital.Attribute_Type__c = '卫生部'; hospital.Speciality_Type__c = '综合医院'; hospital.Grade__c = '一级'; hospital.OCM_Category__c = 'SLTV'; hospital.Is_Medical__c = '医疗机构'; hospital.State_Master__c = al.id; hospital.City_Master__c = al2.id; hospital.Town__c = '东京'; insert hospital; // 戦略科室を得る Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH']; // 診療科を作る Account acc = new Account(); acc.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id; acc.Name = 'test dep'; acc.AgentCode_Ext__c = '9999998'; acc.ParentId = strategicDep[0].Id; acc.Department_Class__c = strategicDep[0].Id; acc.Hospital__c = hospital.Id; insert acc; Test.startTest(); Opportunity opp = new Opportunity( Name='Opp', StageName='出荷', // Status_Formula_Option__c = '06 已发货', CloseDate=Date.today().addDays(10), Close_Forecasted_Date__c=Date.today(), // Department_Class__c = strategicDep[0].Id, CurrencyIsoCode = 'CNY' ); insert opp; // Quote q = new Quote( // Name = 'quote', // OpportunityId = opp.Id, // Pricebook2Id = pricebookId // ); // insert q; // opp.Estimation_Id__c = q.Id; Opportunity opp1 = new Opportunity( Name='Opp', StageName='引合', AccountId = acc.Id, Status_Formula_Option__c = '12 已签约', CloseDate=Date.today().addDays(10), Close_Forecasted_Date__c=Date.today(), // RecordTypeId = oppRecord.Id, // Department_Class__c = strategicDep[0].Id, CurrencyIsoCode = 'CNY' ); insert opp1; Maintenance_Contract__c contract = new Maintenance_Contract__c(); contract.Name = 'tect contract'; contract.Hospital__c = hospital.Id; contract.Department_Class__c = strategicDep[0].Id; contract.Department__c = acc.Id; contract.Service_Contract_Staff__c = UserInfo.getUserId(); contract.Payment_Plan_Sum_First__c = 1; contract.Status__c = '契約満了'; contract.Maintenance_Contract_No__c = '11123'; contract.recordtypeId = Schema.SObjectType.Maintenance_Contract__c.getRecordTypeInfosByDeveloperName().get('NewMaintenance_Contract').getRecordTypeId(); contract.Not_Upper_limit_reason__c = ' 1'; contract.Contract_Start_Date__c = Date.today().addDays(-5); contract.Contract_End_Date__c = Date.today().addDays(5); contract.SalesOfficeCode_selection__c = '北京RC'; contract.New_Contract_TypeF_Text__c = '续签合同'; contract.IF_Target_Renew__c='1'; contract.Contract_Conclusion_Date__c=Date.today().addDays(-5); // system.assertEquals(contract.Contract_End_Date__c >= Date.newInstance(2021,10,1) && contract.Contract_End_Date__c <= Date.newInstance(2022,9,30),true); insert contract; NewMaintenanceReport_Task__c tempNMCT = new NewMaintenanceReport_Task__c(); tempNMCT.Name = 'FWreport-01'; tempNMCT.Distribution_Start_Date__c = Date.today().addDays(-30); tempNMCT.Distribution_End_Date__c = Date.today().addMonths(2).addDays(-1); tempNMCT.NewMaintenance_Contract__c = contract.Id; tempNMCT.ActualDistributionTimes_Quarter__c = 0; insert tempNMCT; String jsonRecords = System.JSON.serialize(pros); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(70)); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(3)); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2',''); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId',null); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId','123456'); eventLineMap.put('IsOPDPlan',true); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecordNull); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId','123456'); eventLineMap.put('IsOPDPlan',true); eventLineMap.put('OpportunityId',null); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); eventLineMap.put('StartTime',Datetime.now().addDays(1)); eventLineMap.put('EndTime',Datetime.now().addDays(1)); eventLineMap.put('ActivityType2','病院'); eventLineMap.put('AccountId','123456'); eventLineMap.put('IsOPDPlan',true); eventLineMap.put('OpportunityId',opp.Id); jsonEvents = JSON.serialize(eventLineMap); lexCreateEventButton.saveLogic(jsonEvents,jsonRecords); Map saveEventMap = new Map(); saveEventMap.put('StartTime',Datetime.now().addDays(1)); saveEventMap.put('EndTime',Datetime.now().addDays(1)); saveEventMap.put('ActivityType2','病院'); saveEventMap.put('PurposeTypeFSE','招标对应'); saveEventMap.put('ActivityPurposeFSE','询价推进'); saveEventMap.put('NoOppReason','HCP对应'); saveEventMap.put('IsOPDPlan',true); saveEventMap.put('AccountId',acc.Id); saveEventMap.put('ContactId',null); saveEventMap.put('OpportunityId',opp1.Id); saveEventMap.put('ProjectId',null); saveEventMap.put('ServiceId',contract.Id); User LoginUser = [SELECT Id, Name, Job_Category__c FROM User WHERE Id = :UserInfo.getUserId()]; String saveEventRecords = JSON.serialize(saveEventMap); LoginUser.Job_Category__c = '销售推广'; update LoginUser; saveEventMap.put('AccountId',cam.Id); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('ActivityType2','病院'); saveEventMap.put('AccountId',acc.Id); saveEventMap.put('OpportunityId',null); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('ActivityType2','販売店'); saveEventMap.put('AccountId',acc.Id); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('ActivityType2','社外イベント'); saveEventMap.put('AccountId',cam.Id); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('PurposeTypeFSE','合同季报'); saveEventRecords = JSON.serialize(saveEventMap); saveEventMap.put('PurposeTypeFSE','合同点检'); saveEventRecords = JSON.serialize(saveEventMap); List proLines = new List(); ProLine proLine1 = new ProLine(); // proLine1.Id = planRE.Id; proLine1.Quantity = 10; proLine1.Name = 'CF-H170I1'; proLine1.ProductCode= 'N4480080'; proLine1.ProductModel= '1001'; proLines.add(proLine1); String reRecords = System.JSON.serialize(proLines); // LoginUser.Job_Category__c = '销售服务'; // update LoginUser; // lexCreateEventButton.saveEvent(saveEventRecords,jsonRecords); Integer year = date.today().year(); Integer month = date.today().month(); Integer days = date.today().day(); List ecL=new List(); Event insertTarget = new Event(); insertTarget.Subject = 'test00'; insertTarget.StartDateTime = Datetime.now().adddays(5); insertTarget.EndDateTime = Datetime.now().adddays(5).addMinutes(60); insertTarget.Location = 'testLocation'; insertTarget.Activity_Type2__c = '病院'; insertTarget.OPDPlan_Flag__c = true ; insertTarget.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; insertTarget.EventStatus__c = ' 02 接受'; insertTarget.whatid__c = acc.Id; Event insertTarget2 = new Event(); insertTarget2.Subject = 'test00'; insertTarget2.StartDateTime = Datetime.now().adddays(5); insertTarget2.EndDateTime = Datetime.now().adddays(5).addMinutes(60); insertTarget2.Location = 'testLocation'; insertTarget2.Activity_Type2__c = '病院'; insertTarget2.OPDPlan_Flag__c = true ; insertTarget2.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; insertTarget2.EventStatus__c = ' 04 取消'; insertTarget2.whatid__c = acc.Id; Event insertTarget3 = new Event(); insertTarget3.Subject = 'test00'; insertTarget3.StartDateTime = Datetime.now().adddays(5); insertTarget3.EndDateTime = Datetime.now().adddays(5).addMinutes(60); insertTarget3.Location = 'testLocation'; insertTarget3.Activity_Type2__c = '病院'; insertTarget3.OPDPlan_Flag__c = true ; insertTarget3.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;'; insertTarget3.EventStatus__c = ' 05 延期'; insertTarget3.whatid__c = acc.Id; ecL.add(insertTarget); ecL.add(insertTarget2); ecL.add(insertTarget3); insert ecL; List tasks = new List(); task__c t1 = new task__c(); t1.Name = 'test1'; t1.taskDifferent__c = '主动任务'; t1.taskStatus__c = '02 接受'; t1.assignee__c = Userinfo.getUserId(); t1.Activity_Date__c = Date.newInstance(year, month,days); tasks.add(t1); task__c t2 = new task__c(); t2.Name = 'test2'; t2.taskDifferent__c = '主动任务'; t2.taskStatus__c = '02 接受'; t2.assignee__c = Userinfo.getUserId(); t2.Activity_Date__c = Date.newInstance(2021, 8, 17); tasks.add(t2); insert tasks; String eventid = insertTarget.Id; String taskId = t1.Id; String accid = acc.Id; String cid = cam.Id; String oid = opp.Id; String mid = contract.Id; String source = 'AccountPCL'; lexCreateEventButton.createCancelPostponePlan_Advance(insertTarget); Test.stopTest(); } catch (Exception e) { System.debug('123'); } } static testMethod void init0() { lexCreateEventButton.runiplus(); } public class ProLine { @AuraEnabled public Id Id { get; set; } @AuraEnabled public Id QuoteId { get; set; } @AuraEnabled public Integer Quantity { get; set; } @AuraEnabled public String Name { get; set; } @AuraEnabled public String ProductCode { get; set; } @AuraEnabled public String ProductModel { get; set; } @AuraEnabled public String QuoteNo { get; set; } @AuraEnabled public String FixtureModel { get; set; } } }