@isTest
|
private class LwcDailyReportControllerTest {
|
//医院ID
|
public static String hpId;
|
//学会ID
|
public static String camId;
|
//Department_Class__c
|
public static String depCId;
|
//Department__c
|
public static String depId;
|
//备品借出申请ID
|
public static String racId;
|
//客户人员ID
|
public static String contactId;
|
public static String contact2Id;
|
public static String contact3Id;
|
public static String contact4Id;
|
public static User user = new User();
|
public static User user2 = new User();
|
//询价ID
|
public static String oppId;
|
public static String opp1Id;
|
public static String opp2Id;
|
public static String opp3Id;
|
public static String drId;
|
public static String taskId;
|
public static String task1Id;
|
public static String task2Id;
|
public static String task3Id;
|
public static String eventc1Id;
|
public static String eventc2Id;
|
public static String eventc3Id;
|
public static String mccId;
|
public Static List<Event__c> etappEventList;
|
public static Account account2 = new Account();
|
public static Agency_Opportunity__c agency_opportunity = new Agency_Opportunity__c();
|
public static Agency_Opportunity__c agency_opportunity2 = new Agency_Opportunity__c();
|
public static Agency_Hospital_Link__c agency_hospital_link = new Agency_Hospital_Link__c();
|
// @TestSetup
|
public static void setupFor4() {
|
Oly_TriggerHandler.bypass('ContactTrigger');
|
Oly_TriggerHandler.bypass('ContactTriggerHandler');
|
ControllerUtil.EscapeNFM001Trigger = true;
|
StaticParameter.EscapeNFM001Trigger = true;
|
StaticParameter.EscapeAccountTrigger = true;
|
StaticParameter.EscapeNFM001AgencyContractTrigger = true;
|
Oly_TriggerHandler.bypass(Product2Handler.Class.getName());
|
Oly_TriggerHandler.bypass(AssetHandler.Class.getName());
|
Oly_TriggerHandler.bypass(FixtureSetHandler.Class.getName());
|
Oly_TriggerHandler.bypass(RentalApplyTriggerHandler.Class.getName());
|
Oly_TriggerHandler.bypass(RentalApplyEquipmentSetHandler.Class.getName());
|
Oly_TriggerHandler.bypass(RentalApplyEquipmentSetDetailHandler.Class.getName());
|
Oly_TriggerHandler.bypass(ContactTriggerHandler.Class.getName());
|
Oly_TriggerHandler.bypass('AssetTrigger');
|
Oly_TriggerHandler.bypass('MaintenanceContractTrigger');
|
Oly_TriggerHandler.bypass('MaintenanceContractAfterUpdate');
|
Oly_TriggerHandler.bypass('MaintenanceContractBeforeDelete');
|
Oly_TriggerHandler.bypass('MaintenanceContractHpDeptUpd');
|
Oly_TriggerHandler.bypass('NFM106Controller');
|
Oly_TriggerHandler.bypass('NFM101Controller');
|
Oly_TriggerHandler.bypass('AgencyOpportunityHandler');
|
Oly_TriggerHandler.bypass('NFM001AgencyContract');
|
Oly_TriggerHandler.bypass('XinEventC2Event');
|
Oly_TriggerHandler.bypass('DailyReportSetHospitalCount');
|
Oly_TriggerHandler.bypass('AgencyHospitalHandler');
|
Oly_TriggerHandler.bypass('ContactTriggerHandler');
|
Oly_TriggerHandler.bypass('Oly_TriggerHandler');
|
Oly_TriggerHandler.bypass('PIHelper');
|
Oly_TriggerHandler.bypass('DailyReportLink2OlympusCalendar');
|
// 省
|
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;
|
hpId = hospital.Id;
|
|
// 戦略科室を得る
|
Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
|
// 診療科を作る
|
Account dep = new Account();
|
dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
|
dep.Name = 'test dep';
|
dep.AgentCode_Ext__c = '9999998';
|
dep.ParentId = strategicDep[0].Id;
|
dep.Department_Class__c = strategicDep[0].Id;
|
dep.Hospital__c = hospital.Id;
|
insert dep;
|
depCId = strategicDep[0].Id;
|
depId = dep.Id;
|
|
Application_for_Conference_Adjudication__c aca = new Application_for_Conference_Adjudication__c();
|
aca.MeetingApprovedNo__c = 'ME154P03-0012';
|
aca.Name = 'ME154P03-0012'; // 用决裁编号替代名称
|
aca.CampaignTheme__c = 'obpm发起赞助决裁';
|
aca.Num__c = 'test1';
|
aca.StartDate__c = NFMUtil.parseDateTimeStr2Date('2022-04-19');
|
aca.EndDate__c = NFMUtil.parseDateTimeStr2Date('2022-04-22');
|
aca.Implementation_Purpose1__c = '其他';
|
aca.OfficeCategory__c = '1.消化科';
|
aca.MeetingType__c = '主办会';
|
aca.StateMaster__c = '北京市';
|
aca.CityMaster__c = '北京市';
|
aca.WorkshopPlace__c = 'CTEC';
|
aca.HostName__c = '医学会';
|
aca.CooperatorCompany__c = '中华医学会';
|
aca.ConveningParticipantsNum__c = 0;
|
aca.IsPaidToSponsor__c = '否';
|
aca.SponsorshipCategory__c = '资金';
|
aca.ExpectedOlympusAttendance__c = 0;
|
aca.ActivityTypeName__c = '自主主办会';
|
aca.ExpectedHcpAttendance__c = 0;
|
aca.ProcessState__c = '草稿';
|
aca.Type_of_adjudication_meeting__c = '线下';
|
aca.Activities_of_a_share__c = '否';
|
aca.IsSupplemental__c = true;
|
|
insert aca;
|
Campaign cam = new Campaign();
|
Id RtId = Schema.SObjectType.Campaign.getRecordTypeInfosByDeveloperName().get('Society').getRecordTypeId();
|
// Id RtId2 = Schema.SObjectType.CampaignMember.getRecordTypeInfosByDeveloperName().get('WorkShop').getRecordTypeId();
|
cam.RecordTypeId = RtId;
|
// cam.CampaignMemberRecordTypeId = RtId2;
|
|
cam.Name = aca.MeetingApprovedNo__c;
|
cam.Name2__c = aca.MeetingApprovedNo__c;
|
cam.MeetingApprovedNo__c = aca.MeetingApprovedNo__c;
|
cam.Meeting_Approved_No__c = aca.Id;
|
cam.StartDate = aca.StartDate__c;
|
cam.EndDate = aca.EndDate__c;
|
cam.Implementation_Purpose__c = aca.Implementation_Purpose1__c;
|
cam.OfficeCategory__c = aca.OfficeCategory__c;
|
cam.Meeting_Type__c = aca.MeetingType__c;
|
cam.Activity_Type_Name__c = aca.ActivityTypeName__c;
|
|
cam.WorkshopPlace__c = aca.WorkshopPlace__c;
|
cam.HostName__c = aca.HostName__c;
|
cam.cooperatorCompany__c = aca.CooperatorCompany__c;
|
cam.Convening_Participants_Num__c = aca.ConveningParticipantsNum__c;
|
cam.IF_Approved__c = true;
|
|
// OBPM对接 新增字段
|
cam.Expected_Olympus_Attendance__c = aca.ExpectedOlympusAttendance__c;
|
cam.Expected_Hcp_Attendance__c = aca.ExpectedHcpAttendance__c;
|
cam.SponsorshipCategory__c = aca.SponsorshipCategory__c;
|
cam.IsPaidToSponsor__c = aca.IsPaidToSponsor__c;
|
cam.Activity_Type_Name__c = aca.ActivityTypeName__c;
|
cam.Is_LendProduct__c = '是';
|
cam.PlanBackData__c = NFMUtil.parseDateTimeStr2Date('2022-04-30');
|
cam.LoadNum__c = 'CV-290*1; GI-290镜子*1;';
|
insert cam;
|
camId=cam.Id;
|
|
List<RecordType> rectCop = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectCop.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
|
RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
|
|
|
|
|
Integer year = date.today().year();
|
Integer month = date.today().month();
|
Integer days = date.today().day();
|
OlympusCalendar__c oc = new OlympusCalendar__c();
|
oc.Date__c = System.Today();
|
oc.Before_1_WorkDay__c = oc.Date__c.addDays(-1);
|
insert oc;
|
List<Daily_Report__c> drList = new List<Daily_Report__c>();
|
Daily_Report__c dr1 = new Daily_Report__c();
|
dr1.Reporter__c = UserInfo.getUserId();
|
dr1.Reported_Date__c = date.today().addDays(0);
|
dr1.Working_Time_From__c = Datetime.newInstance(year, month,days, 0, 0, 0);
|
dr1.Working_Time_To__c = Datetime.newInstance(year, month,days, 9, 0, 0);
|
dr1.Status__c = '作成中';
|
drList.add(dr1);
|
|
insert drList;
|
drId=drList[0].id;
|
|
List<Event__c> ecL=new List<Event__c>();
|
Event__c event = new Event__c();
|
event.ActivityDate__c = date.today();
|
event.Daily_Report__c = dr1.Id;
|
event.StartDateTime__c = Datetime.newInstance(year, month,days, 10, 0, 0);
|
event.EndDateTime__c = Datetime.newInstance(year, month,days, 11, 0, 0);
|
event.whatid__c = hpId;
|
|
|
Event__c event2 = new Event__c();
|
event2.ActivityDate__c = date.today();
|
event2.Daily_Report__c = dr1.Id;
|
event2.StartDateTime__c = Datetime.newInstance(year, month,days, 10, 0, 0);
|
event2.EndDateTime__c = Datetime.newInstance(year, month,days, 11, 0, 0);
|
event2.eventStatus__c = '取消';
|
|
Event__c event3 = new Event__c();
|
event3.ActivityDate__c = date.today();
|
event3.Daily_Report__c = dr1.Id;
|
event3.StartDateTime__c = Datetime.newInstance(year, month,days, 10, 0, 0);
|
event3.EndDateTime__c = Datetime.newInstance(year, month,days, 11, 0, 0);
|
event3.whatid__c = cam.Id;
|
event3.eventStatus__c = '延期';
|
ecL.add(event);
|
ecL.add(event2);
|
ecL.add(event3);
|
insert ecL;
|
eventc1Id=event.Id;
|
eventc2Id=event2.Id;
|
eventc3Id=event3.Id;
|
|
List<task__c> tasks = new List<task__c>();
|
task__c t1 = new task__c();
|
t1.Name = 'test1';
|
t1.taskDifferent__c = '主动任务';
|
t1.taskStatus__c = '02 接受';
|
t1.assignee__c = Userinfo.getUserId();
|
t1.Event__c = event.Id;
|
t1.Daily_Report__c = dr1.Id;
|
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.Event__c = event.Id;
|
t2.Daily_Report__c = dr1.Id;
|
t2.Activity_Date__c = Date.newInstance(2021, 8, 17);
|
tasks.add(t2);
|
|
insert tasks;
|
taskId=t1.Id;
|
task1Id=t1.Id;
|
task2Id=t2.Id;
|
t1.delayTask__c = t2.id;
|
update t1;
|
event.taskId__c = t2.id;
|
update event;
|
|
|
}
|
public static void setup() {
|
Oly_TriggerHandler.bypass('ContactTrigger');
|
Oly_TriggerHandler.bypass('ContactTriggerHandler');
|
ControllerUtil.EscapeNFM001Trigger = true;
|
StaticParameter.EscapeNFM001Trigger = true;
|
StaticParameter.EscapeAccountTrigger = true;
|
StaticParameter.EscapeNFM001AgencyContractTrigger = true;
|
Oly_TriggerHandler.bypass(Product2Handler.Class.getName());
|
Oly_TriggerHandler.bypass(AssetHandler.Class.getName());
|
Oly_TriggerHandler.bypass(FixtureSetHandler.Class.getName());
|
Oly_TriggerHandler.bypass(RentalApplyTriggerHandler.Class.getName());
|
Oly_TriggerHandler.bypass(RentalApplyEquipmentSetHandler.Class.getName());
|
Oly_TriggerHandler.bypass(RentalApplyEquipmentSetDetailHandler.Class.getName());
|
Oly_TriggerHandler.bypass(ContactTriggerHandler.Class.getName());
|
Oly_TriggerHandler.bypass('AssetTrigger');
|
Oly_TriggerHandler.bypass('MaintenanceContractTrigger');
|
Oly_TriggerHandler.bypass('MaintenanceContractAfterUpdate');
|
Oly_TriggerHandler.bypass('MaintenanceContractBeforeDelete');
|
Oly_TriggerHandler.bypass('MaintenanceContractHpDeptUpd');
|
Oly_TriggerHandler.bypass('NFM106Controller');
|
Oly_TriggerHandler.bypass('NFM101Controller');
|
Oly_TriggerHandler.bypass('AgencyOpportunityHandler');
|
Oly_TriggerHandler.bypass('NFM001AgencyContract');
|
Oly_TriggerHandler.bypass('XinEventC2Event');
|
Oly_TriggerHandler.bypass('DailyReportSetHospitalCount');
|
Oly_TriggerHandler.bypass('AgencyHospitalHandler');
|
Oly_TriggerHandler.bypass('ContactTriggerHandler');
|
Oly_TriggerHandler.bypass('Oly_TriggerHandler');
|
Oly_TriggerHandler.bypass('PIHelper');
|
Oly_TriggerHandler.bypass('DailyReportLink2OlympusCalendar');
|
// 省
|
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;
|
hpId = hospital.Id;
|
|
// 戦略科室を得る
|
Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
|
// 診療科を作る
|
Account dep = new Account();
|
dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
|
dep.Name = 'test dep';
|
dep.AgentCode_Ext__c = '9999998';
|
dep.ParentId = strategicDep[0].Id;
|
dep.Department_Class__c = strategicDep[0].Id;
|
dep.Hospital__c = hospital.Id;
|
insert dep;
|
depCId = strategicDep[0].Id;
|
depId = dep.Id;
|
|
|
List<Contact> contactList=new List<Contact>();
|
Contact contact2 = new Contact();
|
contact2.AccountId = depId;
|
// contact2.FirstName = '責任者';
|
contact2.LastName = 'test1经销商';
|
Contact contact3 = new Contact();
|
contact3.AccountId = depId;
|
// contact3.FirstName = '責任者';
|
contact3.LastName = 'test1经销商';
|
Contact contact4 = new Contact();
|
contact4.AccountId = depId;
|
// contact4.FirstName = '責任者';
|
contact4.LastName = 'test1经销商';
|
contactList.add(contact2);
|
contactList.add(contact3);
|
contactList.add(contact4);
|
insert contactList;
|
contactId=contact2.id;
|
contact2Id=contact2.id;
|
contact3Id=contact3.id;
|
contact4Id=contact4.id;
|
|
|
|
|
Application_for_Conference_Adjudication__c aca = new Application_for_Conference_Adjudication__c();
|
aca.MeetingApprovedNo__c = 'ME154P03-0012';
|
aca.Name = 'ME154P03-0012'; // 用决裁编号替代名称
|
aca.CampaignTheme__c = 'obpm发起赞助决裁';
|
aca.Num__c = 'test1';
|
aca.StartDate__c = NFMUtil.parseDateTimeStr2Date('2022-04-19');
|
aca.EndDate__c = NFMUtil.parseDateTimeStr2Date('2022-04-22');
|
aca.Implementation_Purpose1__c = '其他';
|
aca.OfficeCategory__c = '1.消化科';
|
aca.MeetingType__c = '主办会';
|
aca.StateMaster__c = '北京市';
|
aca.CityMaster__c = '北京市';
|
aca.WorkshopPlace__c = 'CTEC';
|
aca.HostName__c = '医学会';
|
aca.CooperatorCompany__c = '中华医学会';
|
aca.ConveningParticipantsNum__c = 0;
|
aca.IsPaidToSponsor__c = '否';
|
aca.SponsorshipCategory__c = '资金';
|
aca.ExpectedOlympusAttendance__c = 0;
|
aca.ActivityTypeName__c = '自主主办会';
|
aca.ExpectedHcpAttendance__c = 0;
|
aca.ProcessState__c = '草稿';
|
aca.Type_of_adjudication_meeting__c = '线下';
|
aca.Activities_of_a_share__c = '否';
|
aca.IsSupplemental__c = true;
|
|
insert aca;
|
Campaign cam = new Campaign();
|
Id RtId = Schema.SObjectType.Campaign.getRecordTypeInfosByDeveloperName().get('Society').getRecordTypeId();
|
// Id RtId2 = Schema.SObjectType.CampaignMember.getRecordTypeInfosByDeveloperName().get('WorkShop').getRecordTypeId();
|
cam.RecordTypeId = RtId;
|
// cam.CampaignMemberRecordTypeId = RtId2;
|
|
cam.Name = aca.MeetingApprovedNo__c;
|
cam.Name2__c = aca.MeetingApprovedNo__c;
|
cam.MeetingApprovedNo__c = aca.MeetingApprovedNo__c;
|
cam.Meeting_Approved_No__c = aca.Id;
|
cam.StartDate = aca.StartDate__c;
|
cam.EndDate = aca.EndDate__c;
|
cam.Implementation_Purpose__c = aca.Implementation_Purpose1__c;
|
cam.OfficeCategory__c = aca.OfficeCategory__c;
|
cam.Meeting_Type__c = aca.MeetingType__c;
|
cam.Activity_Type_Name__c = aca.ActivityTypeName__c;
|
|
cam.WorkshopPlace__c = aca.WorkshopPlace__c;
|
cam.HostName__c = aca.HostName__c;
|
cam.cooperatorCompany__c = aca.CooperatorCompany__c;
|
cam.Convening_Participants_Num__c = aca.ConveningParticipantsNum__c;
|
cam.IF_Approved__c = true;
|
|
// OBPM对接 新增字段
|
cam.Expected_Olympus_Attendance__c = aca.ExpectedOlympusAttendance__c;
|
cam.Expected_Hcp_Attendance__c = aca.ExpectedHcpAttendance__c;
|
cam.SponsorshipCategory__c = aca.SponsorshipCategory__c;
|
cam.IsPaidToSponsor__c = aca.IsPaidToSponsor__c;
|
cam.Activity_Type_Name__c = aca.ActivityTypeName__c;
|
cam.Is_LendProduct__c = '是';
|
cam.PlanBackData__c = NFMUtil.parseDateTimeStr2Date('2022-04-30');
|
cam.LoadNum__c = 'CV-290*1; GI-290镜子*1;';
|
insert cam;
|
camId=cam.Id;
|
|
List<RecordType> rectCop = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectCop.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
|
RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
|
Opportunity opp1 = new Opportunity(
|
Name='testOpp1',
|
StageName='引合',
|
CloseDate=Date.today(),
|
AccountId= depId,
|
Sales_Root__c = '販売店',
|
Competitor__c ='A',
|
Click_Close_Date__c = null,
|
RecordType = rectOpp
|
);
|
Opportunity opp2 = new Opportunity(
|
Name='testOpp1',
|
StageName='引合',
|
CloseDate=Date.today(),
|
AccountId= depId,
|
Sales_Root__c = '販売店',
|
Competitor__c ='A',
|
Click_Close_Date__c = null,
|
RecordType = rectOpp
|
);
|
Opportunity opp3 = new Opportunity(
|
Name='testOpp1',
|
StageName='引合',
|
CloseDate=Date.today(),
|
AccountId= depId,
|
Sales_Root__c = '販売店',
|
Competitor__c ='A',
|
Click_Close_Date__c = null,
|
RecordType = rectOpp
|
);
|
List<Opportunity> oppL=new List<Opportunity>();
|
oppL.add(opp1);
|
oppL.add(opp2);
|
oppL.add(opp3);
|
insert oppL;
|
oppId=opp1.Id;
|
opp1Id=opp1.Id;
|
opp2Id=opp2.Id;
|
opp3Id=opp2.Id;
|
|
|
|
Integer year = date.today().year();
|
Integer month = date.today().month();
|
Integer days = date.today().day();
|
OlympusCalendar__c oc = new OlympusCalendar__c();
|
oc.Date__c = System.Today();
|
oc.Before_1_WorkDay__c = oc.Date__c.addDays(-1);
|
insert oc;
|
List<Daily_Report__c> drList = new List<Daily_Report__c>();
|
Daily_Report__c dr1 = new Daily_Report__c();
|
dr1.Reporter__c = UserInfo.getUserId();
|
dr1.Reported_Date__c = date.today().addDays(0);
|
dr1.Working_Time_From__c = Datetime.newInstance(year, month,days, 0, 0, 0);
|
dr1.Working_Time_To__c = Datetime.newInstance(year, month,days, 9, 0, 0);
|
dr1.Status__c = '作成中';
|
drList.add(dr1);
|
|
insert drList;
|
drId=drList[0].id;
|
|
List<Event__c> ecL=new List<Event__c>();
|
Event__c event = new Event__c();
|
event.ActivityDate__c = date.today();
|
event.Daily_Report__c = dr1.Id;
|
event.StartDateTime__c = Datetime.newInstance(year, month,days, 10, 0, 0);
|
event.EndDateTime__c = Datetime.newInstance(year, month,days, 11, 0, 0);
|
event.whatid__c = hpId;
|
|
|
Event__c event2 = new Event__c();
|
event2.ActivityDate__c = date.today();
|
event2.Daily_Report__c = dr1.Id;
|
event2.StartDateTime__c = Datetime.newInstance(year, month,days, 10, 0, 0);
|
event2.EndDateTime__c = Datetime.newInstance(year, month,days, 11, 0, 0);
|
event2.eventStatus__c = '取消';
|
|
Event__c event3 = new Event__c();
|
event3.ActivityDate__c = date.today();
|
event3.Daily_Report__c = dr1.Id;
|
event3.StartDateTime__c = Datetime.newInstance(year, month,days, 10, 0, 0);
|
event3.EndDateTime__c = Datetime.newInstance(year, month,days, 11, 0, 0);
|
event3.whatid__c = cam.Id;
|
event3.eventStatus__c = '延期';
|
ecL.add(event);
|
ecL.add(event2);
|
ecL.add(event3);
|
insert ecL;
|
eventc1Id=event.Id;
|
eventc2Id=event2.Id;
|
eventc3Id=event3.Id;
|
|
List<task__c> tasks = new List<task__c>();
|
task__c t1 = new task__c();
|
t1.Name = 'test1';
|
t1.taskDifferent__c = '主动任务';
|
t1.taskStatus__c = '02 接受';
|
t1.assignee__c = Userinfo.getUserId();
|
t1.Event__c = event.Id;
|
t1.Daily_Report__c = dr1.Id;
|
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.Event__c = event.Id;
|
t2.Daily_Report__c = dr1.Id;
|
t2.Activity_Date__c = Date.newInstance(2021, 8, 17);
|
tasks.add(t2);
|
|
insert tasks;
|
taskId=t1.Id;
|
task1Id=t1.Id;
|
task2Id=t2.Id;
|
t1.delayTask__c = t2.id;
|
update t1;
|
event.taskId__c = t2.id;
|
update event;
|
|
Event insertTarget = new Event();
|
insertTarget.Subject = 'test00';
|
insertTarget.StartDateTime = Datetime.now();
|
insertTarget.EndDateTime = Datetime.now().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.Task_ID__c = t1.Id;
|
insertTarget.whatid__c = hospital.Id;
|
// insertTarget.EventStatus__c = '05 延期';
|
insertTarget.isScheduled__c = true;
|
|
insert insertTarget;
|
|
|
// Event insertTarget2 = new Event();
|
// insertTarget2.Subject = 'test00';
|
// insertTarget2.StartDateTime = Datetime.now().adddays(1);
|
// insertTarget2.EndDateTime = Datetime.now().adddays(1);
|
// 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.Task_ID__c = t2.Id;
|
// // insertTarget2.whatid__c = '0071000000VATIUAA5';
|
// insertTarget2.NextEventC_ID__c = insertTarget.Id;
|
// insert insertTarget2;
|
|
|
|
|
Maintenance_Contract__c contract1 = new Maintenance_Contract__c();
|
contract1.Name = 'tect contract1111';
|
contract1.Hospital__c = hospital.Id;
|
contract1.Department_Class__c = strategicDep[0].Id;
|
contract1.Department__c = dep.Id;
|
contract1.Service_Contract_Staff__c = Userinfo.getUserId();
|
contract1.Payment_Plan_Sum_First__c = 1;
|
// contract1.Status__c = '契約';
|
contract1.Maintenance_Contract_No__c = '111212123';
|
|
contract1.Not_Upper_limit_reason__c = ' 1';
|
contract1.Contract_Start_Date__c = Date.today().addDays( -10);
|
contract1.Contract_End_Date__c = Date.today().addDays( 5);
|
contract1.SalesOfficeCode_selection__c = '北京RC';
|
insert contract1;
|
mccId=contract1.id;
|
SLAReportInfo__c slaInfo = new SLAReportInfo__c();
|
slaInfo.Event__c = event.Id;
|
slaInfo.Maintenance_Contract__c = contract1.Id;
|
insert slaInfo;
|
|
}
|
public static void setup2() {
|
Oly_TriggerHandler.bypass('ContactTrigger');
|
Oly_TriggerHandler.bypass('ContactTriggerHandler');
|
ControllerUtil.EscapeNFM001Trigger = true;
|
StaticParameter.EscapeNFM001Trigger = true;
|
StaticParameter.EscapeAccountTrigger = true;
|
StaticParameter.EscapeNFM001AgencyContractTrigger = true;
|
Oly_TriggerHandler.bypass(Product2Handler.Class.getName());
|
Oly_TriggerHandler.bypass(AssetHandler.Class.getName());
|
Oly_TriggerHandler.bypass(FixtureSetHandler.Class.getName());
|
Oly_TriggerHandler.bypass(RentalApplyTriggerHandler.Class.getName());
|
Oly_TriggerHandler.bypass(RentalApplyEquipmentSetHandler.Class.getName());
|
Oly_TriggerHandler.bypass(RentalApplyEquipmentSetDetailHandler.Class.getName());
|
Oly_TriggerHandler.bypass(ContactTriggerHandler.Class.getName());
|
Oly_TriggerHandler.bypass('AssetTrigger');
|
Oly_TriggerHandler.bypass('MaintenanceContractTrigger');
|
Oly_TriggerHandler.bypass('MaintenanceContractAfterUpdate');
|
Oly_TriggerHandler.bypass('MaintenanceContractBeforeDelete');
|
Oly_TriggerHandler.bypass('MaintenanceContractHpDeptUpd');
|
Oly_TriggerHandler.bypass('NFM106Controller');
|
Oly_TriggerHandler.bypass('NFM101Controller');
|
Oly_TriggerHandler.bypass('AgencyOpportunityHandler');
|
Oly_TriggerHandler.bypass('NFM001AgencyContract');
|
Oly_TriggerHandler.bypass('XinEventC2Event');
|
Oly_TriggerHandler.bypass('DailyReportSetHospitalCount');
|
Oly_TriggerHandler.bypass('AgencyHospitalHandler');
|
Oly_TriggerHandler.bypass('ContactTriggerHandler');
|
Oly_TriggerHandler.bypass('Oly_TriggerHandler');
|
Oly_TriggerHandler.bypass('PIHelper');
|
Oly_TriggerHandler.bypass('DailyReportLink2OlympusCalendar');
|
// 省
|
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;
|
hpId = hospital.Id;
|
|
// 戦略科室を得る
|
Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
|
// 診療科を作る
|
Account dep = new Account();
|
dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
|
dep.Name = 'test dep';
|
dep.AgentCode_Ext__c = '9999998';
|
dep.ParentId = strategicDep[0].Id;
|
dep.Department_Class__c = strategicDep[0].Id;
|
dep.Hospital__c = hospital.Id;
|
insert dep;
|
depCId = strategicDep[0].Id;
|
depId = dep.Id;
|
|
|
List<Contact> contactList=new List<Contact>();
|
Contact contact2 = new Contact();
|
contact2.AccountId = depId;
|
// contact2.FirstName = '責任者';
|
contact2.LastName = 'test1经销商';
|
Contact contact3 = new Contact();
|
contact3.AccountId = depId;
|
// contact3.FirstName = '責任者';
|
contact3.LastName = 'test1经销商';
|
Contact contact4 = new Contact();
|
contact4.AccountId = depId;
|
// contact4.FirstName = '責任者';
|
contact4.LastName = 'test1经销商';
|
contactList.add(contact2);
|
contactList.add(contact3);
|
contactList.add(contact4);
|
insert contactList;
|
contactId=contact2.id;
|
contact2Id=contact2.id;
|
contact3Id=contact3.id;
|
contact4Id=contact4.id;
|
|
|
|
|
Application_for_Conference_Adjudication__c aca = new Application_for_Conference_Adjudication__c();
|
aca.MeetingApprovedNo__c = 'ME154P03-0012';
|
aca.Name = 'ME154P03-0012'; // 用决裁编号替代名称
|
aca.CampaignTheme__c = 'obpm发起赞助决裁';
|
aca.Num__c = 'test1';
|
aca.StartDate__c = NFMUtil.parseDateTimeStr2Date('2022-04-19');
|
aca.EndDate__c = NFMUtil.parseDateTimeStr2Date('2022-04-22');
|
aca.Implementation_Purpose1__c = '其他';
|
aca.OfficeCategory__c = '1.消化科';
|
aca.MeetingType__c = '主办会';
|
aca.StateMaster__c = '北京市';
|
aca.CityMaster__c = '北京市';
|
aca.WorkshopPlace__c = 'CTEC';
|
aca.HostName__c = '医学会';
|
aca.CooperatorCompany__c = '中华医学会';
|
aca.ConveningParticipantsNum__c = 0;
|
aca.IsPaidToSponsor__c = '否';
|
aca.SponsorshipCategory__c = '资金';
|
aca.ExpectedOlympusAttendance__c = 0;
|
aca.ActivityTypeName__c = '自主主办会';
|
aca.ExpectedHcpAttendance__c = 0;
|
aca.ProcessState__c = '草稿';
|
aca.Type_of_adjudication_meeting__c = '线下';
|
aca.Activities_of_a_share__c = '否';
|
aca.IsSupplemental__c = true;
|
|
insert aca;
|
Campaign cam = new Campaign();
|
Id RtId = Schema.SObjectType.Campaign.getRecordTypeInfosByDeveloperName().get('Society').getRecordTypeId();
|
// Id RtId2 = Schema.SObjectType.CampaignMember.getRecordTypeInfosByDeveloperName().get('WorkShop').getRecordTypeId();
|
cam.RecordTypeId = RtId;
|
// cam.CampaignMemberRecordTypeId = RtId2;
|
|
cam.Name = aca.MeetingApprovedNo__c;
|
cam.Name2__c = aca.MeetingApprovedNo__c;
|
cam.MeetingApprovedNo__c = aca.MeetingApprovedNo__c;
|
cam.Meeting_Approved_No__c = aca.Id;
|
cam.StartDate = aca.StartDate__c;
|
cam.EndDate = aca.EndDate__c;
|
cam.Implementation_Purpose__c = aca.Implementation_Purpose1__c;
|
cam.OfficeCategory__c = aca.OfficeCategory__c;
|
cam.Meeting_Type__c = aca.MeetingType__c;
|
cam.Activity_Type_Name__c = aca.ActivityTypeName__c;
|
|
cam.WorkshopPlace__c = aca.WorkshopPlace__c;
|
cam.HostName__c = aca.HostName__c;
|
cam.cooperatorCompany__c = aca.CooperatorCompany__c;
|
cam.Convening_Participants_Num__c = aca.ConveningParticipantsNum__c;
|
cam.IF_Approved__c = true;
|
|
// OBPM对接 新增字段
|
cam.Expected_Olympus_Attendance__c = aca.ExpectedOlympusAttendance__c;
|
cam.Expected_Hcp_Attendance__c = aca.ExpectedHcpAttendance__c;
|
cam.SponsorshipCategory__c = aca.SponsorshipCategory__c;
|
cam.IsPaidToSponsor__c = aca.IsPaidToSponsor__c;
|
cam.Activity_Type_Name__c = aca.ActivityTypeName__c;
|
cam.Is_LendProduct__c = '是';
|
cam.PlanBackData__c = NFMUtil.parseDateTimeStr2Date('2022-04-30');
|
cam.LoadNum__c = 'CV-290*1; GI-290镜子*1;';
|
insert cam;
|
camId=cam.Id;
|
|
List<RecordType> rectCop = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectCop.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
|
|
//备品借出申请
|
Rental_Apply__c raObj = new Rental_Apply__c();
|
raObj.Name = 'testra';
|
raObj.Product_category__c = 'GI';
|
raObj.Demo_purpose1__c = '产品试用';
|
raObj.demo_purpose2__c = FixtureUtil.raDemo_purpose2MAP.get('shiyongwuxunjia');
|
raObj.direct_send__c = '医疗机构';
|
raObj.Loaner_received_staff__c = '王五';
|
raObj.Loaner_received_staff_phone__c = '110';
|
raObj.direct_shippment_address__c = '北京市';
|
raObj.Hospital__c = hpId;
|
raObj.Strategic_dept__c = depCId;
|
raObj.Account__c = depId;
|
raObj.Request_shipping_day__c = Date.toDay(); // 希望到货日
|
raObj.Hope_Lonaer_date_Num__c = 1; // 希望借用天数
|
// 预定归还日自动生成 预定归还日=(希望到货日+希望借用天数)-1
|
// raObj.Request_return_day__c = Date.toDay(); // 预定归还日
|
// B.OLY_OCM-669 入力规则: 希望借用天数不能为空
|
raObj.Phone_number__c = '1234567890';
|
raObj.Loaner_medical_Staff__c = contact2.Id;
|
// insert raObj;
|
|
// racId=raObj.Id;
|
RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
|
Opportunity opp1 = new Opportunity(
|
Name='testOpp1',
|
StageName='引合',
|
CloseDate=Date.today(),
|
AccountId= depId,
|
Sales_Root__c = '販売店',
|
Competitor__c ='A',
|
Click_Close_Date__c = null,
|
RecordType = rectOpp
|
);
|
Opportunity opp2 = new Opportunity(
|
Name='testOpp1',
|
StageName='引合',
|
CloseDate=Date.today(),
|
AccountId= depId,
|
Sales_Root__c = '販売店',
|
Competitor__c ='A',
|
Click_Close_Date__c = null,
|
RecordType = rectOpp
|
);
|
Opportunity opp3 = new Opportunity(
|
Name='testOpp1',
|
StageName='引合',
|
CloseDate=Date.today(),
|
AccountId= depId,
|
Sales_Root__c = '販売店',
|
Competitor__c ='A',
|
Click_Close_Date__c = null,
|
RecordType = rectOpp
|
);
|
List<Opportunity> oppL=new List<Opportunity>();
|
oppL.add(opp1);
|
oppL.add(opp2);
|
oppL.add(opp3);
|
insert oppL;
|
oppId=opp1.Id;
|
opp1Id=opp1.Id;
|
opp2Id=opp2.Id;
|
opp3Id=opp2.Id;
|
|
|
|
Integer year = date.today().year();
|
Integer month = date.today().month();
|
Integer days = date.today().day();
|
OlympusCalendar__c oc = new OlympusCalendar__c();
|
oc.Date__c = System.Today();
|
oc.Before_1_WorkDay__c = oc.Date__c.addDays(-1);
|
insert oc;
|
List<Daily_Report__c> drList = new List<Daily_Report__c>();
|
Daily_Report__c dr1 = new Daily_Report__c();
|
dr1.Reporter__c = UserInfo.getUserId();
|
dr1.Reported_Date__c = date.today().addDays(0);
|
dr1.Working_Time_From__c = Datetime.newInstance(year, month,days, 0, 0, 0);
|
dr1.Working_Time_To__c = Datetime.newInstance(year, month,days, 9, 0, 0);
|
dr1.Status__c = '作成中';
|
drList.add(dr1);
|
|
insert drList;
|
drId=drList[0].id;
|
|
List<Event__c> ecL=new List<Event__c>();
|
Event__c event = new Event__c();
|
event.ActivityDate__c = date.today();
|
event.Daily_Report__c = dr1.Id;
|
event.StartDateTime__c = Datetime.newInstance(year, month,days, 10, 0, 0);
|
event.EndDateTime__c = Datetime.newInstance(year, month,days, 11, 0, 0);
|
event.whatid__c = hpId;
|
|
|
Event__c event2 = new Event__c();
|
event2.ActivityDate__c = date.today();
|
event2.Daily_Report__c = dr1.Id;
|
event2.StartDateTime__c = Datetime.newInstance(year, month,days, 10, 0, 0);
|
event2.EndDateTime__c = Datetime.newInstance(year, month,days, 11, 0, 0);
|
event2.eventStatus__c = '取消';
|
|
Event__c event3 = new Event__c();
|
event3.ActivityDate__c = date.today();
|
event3.Daily_Report__c = dr1.Id;
|
event3.StartDateTime__c = Datetime.newInstance(year, month,days, 10, 0, 0);
|
event3.EndDateTime__c = Datetime.newInstance(year, month,days, 11, 0, 0);
|
event3.whatid__c = cam.Id;
|
event3.eventStatus__c = '延期';
|
ecL.add(event);
|
ecL.add(event2);
|
ecL.add(event3);
|
|
|
insert ecL;
|
eventc1Id=event.Id;
|
eventc2Id=event2.Id;
|
eventc3Id=event3.Id;
|
|
List<task__c> tasks = new List<task__c>();
|
task__c t1 = new task__c();
|
t1.Name = 'test1';
|
t1.taskDifferent__c = '主动任务';
|
t1.taskStatus__c = '02 接受';
|
t1.assignee__c = Userinfo.getUserId();
|
t1.Event__c = event.Id;
|
t1.Daily_Report__c = dr1.Id;
|
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.Event__c = event.Id;
|
t2.Daily_Report__c = dr1.Id;
|
t2.Activity_Date__c = Date.newInstance(2021, 8, 17);
|
tasks.add(t2);
|
|
insert tasks;
|
taskId=t1.Id;
|
task1Id=t1.Id;
|
task2Id=t2.Id;
|
t1.delayTask__c = t2.id;
|
update t1;
|
event.taskId__c = t2.id;
|
update event;
|
|
Event insertTarget = new Event();
|
insertTarget.Subject = 'test00';
|
insertTarget.StartDateTime = Datetime.now();
|
insertTarget.EndDateTime = date.today().addDays(1);
|
insertTarget.Location = 'testLocation';
|
insertTarget.delayToDate__c= date.today().addDays(0);
|
insertTarget.Activity_Type2__c = '病院';
|
insertTarget.OPDPlan_Flag__c = true ;
|
insertTarget.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;';
|
insertTarget.Task_ID__c = t1.Id;
|
insertTarget.whatid__c = hospital.Id;
|
// insertTarget.EventStatus__c = '05 延期';
|
insertTarget.isScheduled__c = true;
|
|
insert insertTarget;
|
|
Event__c ecc1 = new Event__c(
|
Subject__c = 'test',
|
StartDateTime__c = Datetime.newInstance(2016, 1, 1, 1, 0, 0),
|
DurationInMinutes__c = 60,
|
EndDateTime__c = Datetime.newInstance(2016, 1, 1, 2, 0, 0),
|
ActivityDate__c = date.today().addDays(0),
|
delayToDate__c = date.today().addDays(0),
|
Event_ID__c = insertTarget.Id,
|
Daily_Report__c = dr1.Id,
|
eventstatus__c='延期'
|
);
|
Event__c ecc2 = new Event__c(
|
Subject__c = 'test',
|
StartDateTime__c = Datetime.newInstance(2016, 1, 1, 1, 0, 0),
|
DurationInMinutes__c = 60,
|
EndDateTime__c = Datetime.newInstance(2016, 1, 1, 2, 0, 0),
|
ActivityDate__c = date.today().addDays(0),
|
delayToDate__c = date.today().addDays(0),
|
Event_ID__c = insertTarget.Id,
|
Daily_Report__c = dr1.Id,
|
eventstatus__c='取消'
|
);
|
insert ecc1;
|
// Event insertTarget2 = new Event();
|
// insertTarget2.Subject = 'test00';
|
// insertTarget2.StartDateTime = Datetime.now().adddays(1);
|
// insertTarget2.EndDateTime = Datetime.now().adddays(1);
|
// 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.Task_ID__c = t2.Id;
|
// // insertTarget2.whatid__c = '0071000000VATIUAA5';
|
// insertTarget2.NextEventC_ID__c = insertTarget.Id;
|
// insert insertTarget2;
|
|
|
|
|
Maintenance_Contract__c contract1 = new Maintenance_Contract__c();
|
contract1.Name = 'tect contract1111';
|
contract1.Hospital__c = hospital.Id;
|
contract1.Department_Class__c = strategicDep[0].Id;
|
contract1.Department__c = dep.Id;
|
contract1.Service_Contract_Staff__c = Userinfo.getUserId();
|
contract1.Payment_Plan_Sum_First__c = 1;
|
// contract1.Status__c = '契約';
|
contract1.Maintenance_Contract_No__c = '111212123';
|
|
contract1.Not_Upper_limit_reason__c = ' 1';
|
contract1.Contract_Start_Date__c = Date.today().addDays( -10);
|
contract1.Contract_End_Date__c = Date.today().addDays( 5);
|
contract1.SalesOfficeCode_selection__c = '北京RC';
|
insert contract1;
|
mccId=contract1.id;
|
|
SLAReportInfo__c slaInfo = new SLAReportInfo__c();
|
slaInfo.Event__c = event.Id;
|
slaInfo.Maintenance_Contract__c = contract1.Id;
|
insert slaInfo;
|
List<Event> allEvent=[Select id from Event];
|
for(Event e:allEvent){
|
e.delayToDate__c=date.today().addDays(0);
|
}
|
update allEvent;
|
List<Event__c> allEventc=[Select id,Event_ID__c from Event__c];
|
for(Event__c e:allEventc){
|
e.delayToDate__c=date.today().addDays(0);
|
|
}
|
update allEventc;
|
|
}
|
public static void setup3() {
|
Oly_TriggerHandler.bypass('ContactTrigger');
|
Oly_TriggerHandler.bypass('ContactTriggerHandler');
|
ControllerUtil.EscapeNFM001Trigger = true;
|
StaticParameter.EscapeNFM001Trigger = true;
|
StaticParameter.EscapeAccountTrigger = true;
|
StaticParameter.EscapeNFM001AgencyContractTrigger = true;
|
Oly_TriggerHandler.bypass(Product2Handler.Class.getName());
|
Oly_TriggerHandler.bypass(AssetHandler.Class.getName());
|
Oly_TriggerHandler.bypass(FixtureSetHandler.Class.getName());
|
Oly_TriggerHandler.bypass(RentalApplyTriggerHandler.Class.getName());
|
Oly_TriggerHandler.bypass(RentalApplyEquipmentSetHandler.Class.getName());
|
Oly_TriggerHandler.bypass(RentalApplyEquipmentSetDetailHandler.Class.getName());
|
Oly_TriggerHandler.bypass(ContactTriggerHandler.Class.getName());
|
Oly_TriggerHandler.bypass('AssetTrigger');
|
Oly_TriggerHandler.bypass('MaintenanceContractTrigger');
|
Oly_TriggerHandler.bypass('MaintenanceContractAfterUpdate');
|
Oly_TriggerHandler.bypass('MaintenanceContractBeforeDelete');
|
Oly_TriggerHandler.bypass('MaintenanceContractHpDeptUpd');
|
Oly_TriggerHandler.bypass('NFM106Controller');
|
Oly_TriggerHandler.bypass('NFM101Controller');
|
Oly_TriggerHandler.bypass('AgencyOpportunityHandler');
|
Oly_TriggerHandler.bypass('NFM001AgencyContract');
|
Oly_TriggerHandler.bypass('XinEventC2Event');
|
Oly_TriggerHandler.bypass('DailyReportSetHospitalCount');
|
Oly_TriggerHandler.bypass('AgencyHospitalHandler');
|
Oly_TriggerHandler.bypass('ContactTriggerHandler');
|
Oly_TriggerHandler.bypass('Oly_TriggerHandler');
|
Oly_TriggerHandler.bypass('PIHelper');
|
Oly_TriggerHandler.bypass('DailyReportLink2OlympusCalendar');
|
// 省
|
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;
|
hpId = hospital.Id;
|
|
// 戦略科室を得る
|
Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
|
// 診療科を作る
|
Account dep = new Account();
|
dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
|
dep.Name = 'test dep';
|
dep.AgentCode_Ext__c = '9999998';
|
dep.ParentId = strategicDep[0].Id;
|
dep.Department_Class__c = strategicDep[0].Id;
|
dep.Hospital__c = hospital.Id;
|
insert dep;
|
depCId = strategicDep[0].Id;
|
depId = dep.Id;
|
|
|
List<Contact> contactList=new List<Contact>();
|
Contact contact2 = new Contact();
|
contact2.AccountId = depId;
|
// contact2.FirstName = '責任者';
|
contact2.LastName = 'test1经销商';
|
Contact contact3 = new Contact();
|
contact3.AccountId = depId;
|
// contact3.FirstName = '責任者';
|
contact3.LastName = 'test1经销商';
|
Contact contact4 = new Contact();
|
contact4.AccountId = depId;
|
// contact4.FirstName = '責任者';
|
contact4.LastName = 'test1经销商';
|
contactList.add(contact2);
|
contactList.add(contact3);
|
contactList.add(contact4);
|
insert contactList;
|
contactId=contact2.id;
|
contact2Id=contact2.id;
|
contact3Id=contact3.id;
|
contact4Id=contact4.id;
|
|
|
|
|
Application_for_Conference_Adjudication__c aca = new Application_for_Conference_Adjudication__c();
|
aca.MeetingApprovedNo__c = 'ME154P03-0012';
|
aca.Name = 'ME154P03-0012'; // 用决裁编号替代名称
|
aca.CampaignTheme__c = 'obpm发起赞助决裁';
|
aca.Num__c = 'test1';
|
aca.StartDate__c = NFMUtil.parseDateTimeStr2Date('2022-04-19');
|
aca.EndDate__c = NFMUtil.parseDateTimeStr2Date('2022-04-22');
|
aca.Implementation_Purpose1__c = '其他';
|
aca.OfficeCategory__c = '1.消化科';
|
aca.MeetingType__c = '主办会';
|
aca.StateMaster__c = '北京市';
|
aca.CityMaster__c = '北京市';
|
aca.WorkshopPlace__c = 'CTEC';
|
aca.HostName__c = '医学会';
|
aca.CooperatorCompany__c = '中华医学会';
|
aca.ConveningParticipantsNum__c = 0;
|
aca.IsPaidToSponsor__c = '否';
|
aca.SponsorshipCategory__c = '资金';
|
aca.ExpectedOlympusAttendance__c = 0;
|
aca.ActivityTypeName__c = '自主主办会';
|
aca.ExpectedHcpAttendance__c = 0;
|
aca.ProcessState__c = '草稿';
|
aca.Type_of_adjudication_meeting__c = '线下';
|
aca.Activities_of_a_share__c = '否';
|
aca.IsSupplemental__c = true;
|
|
insert aca;
|
Campaign cam = new Campaign();
|
Id RtId = Schema.SObjectType.Campaign.getRecordTypeInfosByDeveloperName().get('Society').getRecordTypeId();
|
// Id RtId2 = Schema.SObjectType.CampaignMember.getRecordTypeInfosByDeveloperName().get('WorkShop').getRecordTypeId();
|
cam.RecordTypeId = RtId;
|
// cam.CampaignMemberRecordTypeId = RtId2;
|
|
cam.Name = aca.MeetingApprovedNo__c;
|
cam.Name2__c = aca.MeetingApprovedNo__c;
|
cam.MeetingApprovedNo__c = aca.MeetingApprovedNo__c;
|
cam.Meeting_Approved_No__c = aca.Id;
|
cam.StartDate = aca.StartDate__c;
|
cam.EndDate = aca.EndDate__c;
|
cam.Implementation_Purpose__c = aca.Implementation_Purpose1__c;
|
cam.OfficeCategory__c = aca.OfficeCategory__c;
|
cam.Meeting_Type__c = aca.MeetingType__c;
|
cam.Activity_Type_Name__c = aca.ActivityTypeName__c;
|
|
cam.WorkshopPlace__c = aca.WorkshopPlace__c;
|
cam.HostName__c = aca.HostName__c;
|
cam.cooperatorCompany__c = aca.CooperatorCompany__c;
|
cam.Convening_Participants_Num__c = aca.ConveningParticipantsNum__c;
|
cam.IF_Approved__c = true;
|
|
// OBPM对接 新增字段
|
cam.Expected_Olympus_Attendance__c = aca.ExpectedOlympusAttendance__c;
|
cam.Expected_Hcp_Attendance__c = aca.ExpectedHcpAttendance__c;
|
cam.SponsorshipCategory__c = aca.SponsorshipCategory__c;
|
cam.IsPaidToSponsor__c = aca.IsPaidToSponsor__c;
|
cam.Activity_Type_Name__c = aca.ActivityTypeName__c;
|
cam.Is_LendProduct__c = '是';
|
cam.PlanBackData__c = NFMUtil.parseDateTimeStr2Date('2022-04-30');
|
cam.LoadNum__c = 'CV-290*1; GI-290镜子*1;';
|
insert cam;
|
camId=cam.Id;
|
|
List<RecordType> rectCop = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectCop.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
|
|
//备品借出申请
|
Rental_Apply__c raObj = new Rental_Apply__c();
|
raObj.Name = 'testra';
|
raObj.Product_category__c = 'GI';
|
raObj.Demo_purpose1__c = '产品试用';
|
raObj.demo_purpose2__c = FixtureUtil.raDemo_purpose2MAP.get('shiyongwuxunjia');
|
raObj.direct_send__c = '医疗机构';
|
raObj.Loaner_received_staff__c = '王五';
|
raObj.Loaner_received_staff_phone__c = '110';
|
raObj.direct_shippment_address__c = '北京市';
|
raObj.Hospital__c = hpId;
|
raObj.Strategic_dept__c = depCId;
|
raObj.Account__c = depId;
|
raObj.Request_shipping_day__c = Date.toDay(); // 希望到货日
|
raObj.Hope_Lonaer_date_Num__c = 1; // 希望借用天数
|
// 预定归还日自动生成 预定归还日=(希望到货日+希望借用天数)-1
|
// raObj.Request_return_day__c = Date.toDay(); // 预定归还日
|
// B.OLY_OCM-669 入力规则: 希望借用天数不能为空
|
raObj.Phone_number__c = '1234567890';
|
raObj.Loaner_medical_Staff__c = contact2.Id;
|
// insert raObj;
|
|
// racId=raObj.Id;
|
RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
|
Opportunity opp1 = new Opportunity(
|
Name='testOpp1',
|
StageName='引合',
|
CloseDate=Date.today(),
|
AccountId= depId,
|
Sales_Root__c = '販売店',
|
Competitor__c ='A',
|
Click_Close_Date__c = null,
|
RecordType = rectOpp
|
);
|
Opportunity opp2 = new Opportunity(
|
Name='testOpp1',
|
StageName='引合',
|
CloseDate=Date.today(),
|
AccountId= depId,
|
Sales_Root__c = '販売店',
|
Competitor__c ='A',
|
Click_Close_Date__c = null,
|
RecordType = rectOpp
|
);
|
Opportunity opp3 = new Opportunity(
|
Name='testOpp1',
|
StageName='引合',
|
CloseDate=Date.today(),
|
AccountId= depId,
|
Sales_Root__c = '販売店',
|
Competitor__c ='A',
|
Click_Close_Date__c = null,
|
RecordType = rectOpp
|
);
|
List<Opportunity> oppL=new List<Opportunity>();
|
oppL.add(opp1);
|
oppL.add(opp2);
|
oppL.add(opp3);
|
insert oppL;
|
oppId=opp1.Id;
|
opp1Id=opp1.Id;
|
opp2Id=opp2.Id;
|
opp3Id=opp2.Id;
|
|
|
|
Integer year = date.today().year();
|
Integer month = date.today().month();
|
Integer days = date.today().day();
|
OlympusCalendar__c oc = new OlympusCalendar__c();
|
oc.Date__c = System.Today();
|
oc.Before_1_WorkDay__c = oc.Date__c.addDays(-1);
|
insert oc;
|
List<Daily_Report__c> drList = new List<Daily_Report__c>();
|
Daily_Report__c dr1 = new Daily_Report__c();
|
dr1.Reporter__c = UserInfo.getUserId();
|
dr1.Reported_Date__c = date.today().addDays(0);
|
dr1.Working_Time_From__c = Datetime.newInstance(year, month,days, 0, 0, 0);
|
dr1.Working_Time_To__c = Datetime.newInstance(year, month,days, 9, 0, 0);
|
dr1.Status__c = '承認';
|
drList.add(dr1);
|
|
insert drList;
|
drId=drList[0].id;
|
|
List<Event__c> ecL=new List<Event__c>();
|
Event__c event = new Event__c();
|
event.ActivityDate__c = date.today();
|
event.Daily_Report__c = dr1.Id;
|
event.StartDateTime__c = Datetime.newInstance(year, month,days, 10, 0, 0);
|
event.EndDateTime__c = Datetime.newInstance(year, month,days, 11, 0, 0);
|
event.whatid__c = hpId;
|
|
|
Event__c event2 = new Event__c();
|
event2.ActivityDate__c = date.today();
|
event2.Daily_Report__c = dr1.Id;
|
event2.StartDateTime__c = Datetime.newInstance(year, month,days, 10, 0, 0);
|
event2.EndDateTime__c = Datetime.newInstance(year, month,days, 11, 0, 0);
|
event2.eventStatus__c = '取消';
|
|
Event__c event3 = new Event__c();
|
event3.ActivityDate__c = date.today();
|
event3.Daily_Report__c = dr1.Id;
|
event3.StartDateTime__c = Datetime.newInstance(year, month,days, 10, 0, 0);
|
event3.EndDateTime__c = Datetime.newInstance(year, month,days, 11, 0, 0);
|
event3.whatid__c = cam.Id;
|
event3.eventStatus__c = '延期';
|
ecL.add(event);
|
ecL.add(event2);
|
ecL.add(event3);
|
|
|
insert ecL;
|
eventc1Id=event.Id;
|
eventc2Id=event2.Id;
|
eventc3Id=event3.Id;
|
|
List<task__c> tasks = new List<task__c>();
|
task__c t1 = new task__c();
|
t1.Name = 'test1';
|
t1.taskDifferent__c = '主动任务';
|
t1.taskStatus__c = '02 接受';
|
t1.assignee__c = Userinfo.getUserId();
|
t1.Event__c = event.Id;
|
t1.Daily_Report__c = dr1.Id;
|
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.Event__c = event.Id;
|
t2.Daily_Report__c = dr1.Id;
|
t2.Activity_Date__c = Date.newInstance(2021, 8, 17);
|
tasks.add(t2);
|
|
insert tasks;
|
taskId=t1.Id;
|
task1Id=t1.Id;
|
task2Id=t2.Id;
|
t1.delayTask__c = t2.id;
|
update t1;
|
event.taskId__c = t2.id;
|
update event;
|
|
Event insertTarget = new Event();
|
insertTarget.Subject = 'test00';
|
insertTarget.StartDateTime = Datetime.now();
|
insertTarget.EndDateTime = date.today().addDays(1);
|
insertTarget.Location = 'testLocation';
|
insertTarget.delayToDate__c= date.today().addDays(0);
|
insertTarget.Activity_Type2__c = '病院';
|
insertTarget.OPDPlan_Flag__c = true ;
|
insertTarget.PlanProdDetail__c = 'CV-290*4; GI-290镜子*1; GI-290镜子CF*1;';
|
insertTarget.Task_ID__c = t1.Id;
|
insertTarget.whatid__c = hospital.Id;
|
// insertTarget.EventStatus__c = '05 延期';
|
insertTarget.isScheduled__c = true;
|
|
insert insertTarget;
|
|
Event__c ecc1 = new Event__c(
|
Subject__c = 'test',
|
StartDateTime__c = Datetime.newInstance(2016, 1, 1, 1, 0, 0),
|
DurationInMinutes__c = 60,
|
EndDateTime__c = Datetime.newInstance(2016, 1, 1, 2, 0, 0),
|
ActivityDate__c = date.today().addDays(0),
|
delayToDate__c = date.today().addDays(0),
|
Event_ID__c = insertTarget.Id,
|
Daily_Report__c = dr1.Id,
|
eventstatus__c='延期'
|
);
|
Event__c ecc2 = new Event__c(
|
Subject__c = 'test',
|
StartDateTime__c = Datetime.newInstance(2016, 1, 1, 1, 0, 0),
|
DurationInMinutes__c = 60,
|
EndDateTime__c = Datetime.newInstance(2016, 1, 1, 2, 0, 0),
|
ActivityDate__c = date.today().addDays(0),
|
delayToDate__c = date.today().addDays(0),
|
Event_ID__c = insertTarget.Id,
|
Daily_Report__c = dr1.Id,
|
eventstatus__c='取消'
|
);
|
insert ecc1;
|
// Event insertTarget2 = new Event();
|
// insertTarget2.Subject = 'test00';
|
// insertTarget2.StartDateTime = Datetime.now().adddays(1);
|
// insertTarget2.EndDateTime = Datetime.now().adddays(1);
|
// 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.Task_ID__c = t2.Id;
|
// // insertTarget2.whatid__c = '0071000000VATIUAA5';
|
// insertTarget2.NextEventC_ID__c = insertTarget.Id;
|
// insert insertTarget2;
|
|
|
|
|
Maintenance_Contract__c contract1 = new Maintenance_Contract__c();
|
contract1.Name = 'tect contract1111';
|
contract1.Hospital__c = hospital.Id;
|
contract1.Department_Class__c = strategicDep[0].Id;
|
contract1.Department__c = dep.Id;
|
contract1.Service_Contract_Staff__c = Userinfo.getUserId();
|
contract1.Payment_Plan_Sum_First__c = 1;
|
// contract1.Status__c = '契約';
|
contract1.Maintenance_Contract_No__c = '111212123';
|
|
contract1.Not_Upper_limit_reason__c = ' 1';
|
contract1.Contract_Start_Date__c = Date.today().addDays( -10);
|
contract1.Contract_End_Date__c = Date.today().addDays( 5);
|
contract1.SalesOfficeCode_selection__c = '北京RC';
|
insert contract1;
|
mccId=contract1.id;
|
|
SLAReportInfo__c slaInfo = new SLAReportInfo__c();
|
slaInfo.Event__c = event.Id;
|
slaInfo.Maintenance_Contract__c = contract1.Id;
|
insert slaInfo;
|
List<Event> allEvent=[Select id from Event];
|
for(Event e:allEvent){
|
e.delayToDate__c=date.today().addDays(0);
|
}
|
update allEvent;
|
List<Event__c> allEventc=[Select id,Event_ID__c from Event__c];
|
for(Event__c e:allEventc){
|
e.delayToDate__c=date.today().addDays(0);
|
|
}
|
update allEventc;
|
|
}
|
private static User getUser1() {
|
String timenow = Datetime.now().format('yyyyMMddHHmmss');
|
User user1 = new User(Test_staff__c = true, LastName = 'TestMao1',
|
Alias = 'hp1', Email = 'Test1@sunbridge.com',
|
Username = 'Test1' + timenow + '@sunbridge.com', IsActive = true,
|
EmailEncodingKey = 'ISO-2022-JP',TimeZoneSidKey = 'Asia/Tokyo',
|
LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja',
|
ProfileId = System.Label.ProfileId_SystemAdmin,
|
Dept__c = '医疗华北营业本部', Job_Category__c = '销售服务',
|
Province__c = '北京');
|
|
//List<Profile> p = [Select Id From Profile Where Name = '2S6_销售本部窗口&营业助理'];
|
//System.assertEquals(p.size(), 1);
|
System.runAs(new User(Id = Userinfo.getUserId())) {
|
insert user1;
|
}
|
return user1;
|
}
|
private static User getUser2() {
|
String timenow = Datetime.now().format('yyyyMMddHHmmss');
|
User user1 = new User(Test_staff__c = true, LastName = 'TestMao2',
|
Alias = 'hp2', Email = 'Test2@sunbridge.com',
|
Username = 'Test2' + timenow + '@sunbridge.com', IsActive = true,
|
EmailEncodingKey = 'ISO-2022-JP',TimeZoneSidKey = 'Asia/Tokyo',
|
LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja',
|
ProfileId = System.Label.ProfileId_SystemAdmin,
|
Dept__c = '医疗华北营业本部', Job_Category__c = '支援',
|
Province__c = '北京');
|
|
//List<Profile> p = [Select Id From Profile Where Name = '2S6_销售本部窗口&营业助理'];
|
//System.assertEquals(p.size(), 1);
|
System.runAs(new User(Id = Userinfo.getUserId())) {
|
insert user1;
|
}
|
return user1;
|
}
|
public static void initData(){
|
setup();
|
}
|
@isTest
|
public static void test_method_one() {
|
User user2 = getUser2();
|
System.runAs(user2) {
|
Daily_Report__c dr1 = new Daily_Report__c();
|
List<Daily_Report__c> drList = [Select Id from Daily_Report__c limit 1];
|
if(drList.size()>0) {
|
dr1 = drList[0];
|
}
|
|
Test.startTest();
|
LwcDailyReportController.init('');
|
LwcDailyReportController.init(dr1.Id);
|
LwcDailyReportController.getDailyReport(date.toDay(),Userinfo.getUserId());
|
LwcDailyReportController.getDailyReport(date.toDay().addDays(1),Userinfo.getUserId());
|
LwcDailyReportController.cancleApply(dr1.Id);
|
// LwcDailyReportController.updateTask(dr1.Id);
|
|
|
Test.stopTest();
|
}
|
}
|
@isTest
|
public static void test_method_one2() {
|
User user2 = getUser2();
|
System.runAs(user2) {
|
initData();
|
|
Test.startTest();
|
LwcDailyReportController.init('');
|
LwcDailyReportController.init(drId);
|
LwcDailyReportController.getDailyReport(date.toDay(),Userinfo.getUserId());
|
LwcDailyReportController.getDailyReport(date.toDay().addDays(1),Userinfo.getUserId());
|
LwcDailyReportController.cancleApply(drId);
|
|
|
Test.stopTest();
|
}
|
}
|
@isTest
|
public static void test_method_two() {
|
User user2 = getUser2();
|
System.runAs(user2) {
|
initData();
|
Test.startTest();
|
RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_GI', 'Department_BF') order by DeveloperName desc];
|
|
Account acc = new Account();
|
// acc.Id='0011000000VATIUAA5';
|
acc.RecordTypeId = rectCo.Id;
|
acc.Name = 'HP test1';
|
acc.Assume_Change__c = true;
|
insert acc;
|
Contact contact2 = new Contact();
|
contact2.AccountId = acc.Id;
|
// contact2.FirstName = '責任者';
|
contact2.LastName = 'test1经销商';
|
insert contact2;
|
LwcDailyReportController.getDailyReport(date.toDay(),Userinfo.getUserId());
|
LwcDailyReportController.getDailyReport(date.toDay(),'');
|
LwcDailyReportController.queryDepartmentClass(acc.Id);
|
LwcDailyReportController.queryAbountIndo(acc.Id,contact2.id);
|
LwcDailyReportController.queryHospital(acc.Id);
|
LwcDailyReportController.getAccountForJs(acc.Id);
|
LwcDailyReportController.selectAccount(acc.Id);
|
LwcDailyReportController.selectRecordType('Hp');
|
Test.stopTest();
|
}
|
}
|
@isTest
|
public static void test_method_three() {
|
Oly_TriggerHandler.bypass('ContactTriggerHandler');
|
Oly_TriggerHandler.bypass('Oly_TriggerHandler');
|
Oly_TriggerHandler.bypass('PIHelper');
|
Oly_TriggerHandler.bypass('AgencyHospitalHandler');
|
Oly_TriggerHandler.bypass('DailyReportSetHospitalCount');
|
Oly_TriggerHandler.bypass('AgencyOpportunityHandler');
|
Oly_TriggerHandler.bypass('DailyReportLink2OlympusCalendar');
|
Oly_TriggerHandler.bypass('ContactTrigger');
|
Oly_TriggerHandler.bypass('AccountTrigger');
|
Oly_TriggerHandler.bypass('InfrastructureProjectTrigger');
|
User user2 = getUser2();
|
System.runAs(user2) {
|
setup();
|
Integer year = date.today().year();
|
Integer month = date.today().month();
|
Integer days = date.today().day();
|
Map<String, Object> contactMap1 = new Map<String, Object>();
|
contactMap1.put('AccountId',hpId);
|
// contactMap1.put('FirstName', '責任者');
|
contactMap1.put('LastName', 'test1经销商');
|
|
// 将Map转换为JSON格式的字符串
|
String contactJSON = JSON.serialize(contactMap1);
|
LwcDailyReportController.saveContact(contactJSON);
|
|
String visit='123';
|
String visitAim='';
|
String purposeType1='';
|
String purposeType2='';
|
String purposeType3='';
|
String contactId1=contact2Id;
|
String contactId2=contact3Id;
|
String contactId3=contact4Id;
|
String accountId=hpId;
|
String relatedOpportunity1=opp1Id;
|
String relatedOpportunity2=opp2Id;
|
String relatedOpportunity3=opp3Id;
|
String relatedService1='';
|
String infrastructureProject1='';
|
String infrastructureProject2='';
|
String reportJsonStr=null;
|
String eventJsonStr=null;
|
|
Daily_Report__c dr1 = new Daily_Report__c();
|
List<Daily_Report__c> drList = [Select Id from Daily_Report__c limit 1];
|
if(drList.size()>0) {
|
dr1 = drList[0];
|
}
|
|
|
// 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 = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
|
// 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 dep = new Account();
|
// dep.recordtypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_OTH').getRecordTypeId();
|
// dep.Name = 'test dep11111111';
|
// dep.AgentCode_Ext__c = '12345678';
|
// dep.ParentId = strategicDep[0].Id;
|
// dep.Department_Class__c = strategicDep[0].Id;
|
// dep.Hospital__c = hospital.Id;
|
// insert dep;
|
|
// Contact contact2 = new Contact();
|
// contact2.AccountId = dep.Id;
|
// contact2.FirstName = '責任者';
|
// contact2.LastName = 'test1经销商';
|
// insert contact2;
|
// Contact contact3 = new Contact();
|
// contact3.AccountId = dep.Id;
|
// contact3.FirstName = '責任者1';
|
// contact3.LastName = 'test11经销商';
|
// insert contact3;
|
|
Map<String, Object> reportMap1 = new Map<String, Object>();
|
reportMap1.put('Id',dr1.Id);
|
reportMap1.put('Reporter__c', UserInfo.getUserId());
|
reportMap1.put('Reported_Date__c', date.today());
|
reportMap1.put('Status__c', '作成中');
|
reportMap1.put('Working_Time_From__c', Datetime.newInstance(year, month,days, 0, 0, 0));
|
reportMap1.put('Working_Time_To__c', Datetime.newInstance(year, month,days, 9, 0, 0));
|
// account2.Name = 'test1经销商';
|
// account2.RecordTypeId = '01210000000Qem1';
|
// insert new List<Account> {account2};
|
|
|
reportJsonStr = JSON.serialize(reportMap1);
|
|
|
// agency_hospital_link.Name = 'test1代理店医院';
|
// agency_hospital_link.Hospital__c = hospital.Id;
|
// agency_hospital_link.Agency__c = account2.Id;
|
// agency_hospital_link.OwnerId = getUser2().Id;
|
// agency_hospital_link.Agency_Campaign_Obj__c = true;
|
// insert agency_hospital_link;
|
|
// List<Contact> contactlist=[select Id,FirstName from Contact];
|
// Id rtId = Schema.SObjectType.Agency_Opportunity__c.getRecordTypeInfosByDeveloperName().get('Opportunity').getRecordTypeId();
|
// agency_opportunity.Agency_Person__c = contactlist[0].id;
|
// agency_opportunity.RecordTypeId = rtId;
|
// agency_opportunity.Name = '引合1';
|
// agency_opportunity.Hospital_Target__c = hospital.Id;
|
// agency_opportunity.Agency__c = account2.Id;
|
// agency_opportunity.Agency_Hospital__c = agency_hospital_link.Id;
|
// agency_opportunity.StageName__c = '还没申请预算';
|
// agency_opportunity.OwnerId = getUser2().Id;
|
// agency_opportunity.NewOpportunity_Agency_Apply_Status__c = '批准';
|
// agency_opportunity.OCM_Change_To_Opportunity_Flg__c = true;
|
// agency_opportunity.Department_Cateogy__c = 'GI';
|
// agency_opportunity.Product_Category1_P__c ='290系统';
|
|
// agency_opportunity.Sales_Manager__c = getUser2().Id;
|
// insert agency_opportunity;
|
|
// Opportunity opp = new Opportunity();
|
// opp.Agency_Opportunity__c = agency_opportunity.Id;
|
// opp.Name = 'test询价';
|
// opp.StageName = '目標';
|
// opp.SAP_Send_OK__c = false;
|
// opp.CloseDate = Date.newInstance(2023, 11, 15);
|
// insert opp;
|
|
// Opportunity opp1 = new Opportunity();
|
// opp1.Agency_Opportunity__c = agency_opportunity.Id;
|
// opp1.Name = 'test询价11';
|
// opp1.StageName = '目標';
|
// opp1.SAP_Send_OK__c = false;
|
// opp1.CloseDate = Date.newInstance(2023, 11, 16);
|
// 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 = dep.Id;
|
// contract.Service_Contract_Staff__c = getUser2().Id;
|
// contract.Payment_Plan_Sum_First__c = 1;
|
// contract.Status__c = '契約満了';
|
// contract.Maintenance_Contract_No__c = '11123';
|
// contract.recordtypeId =
|
// Schema.SObjectType.Maintenance_Contract__c.getRecordTypeInfosByDeveloperName().get('NewMaintenance_Contract').getRecordTypeId();
|
// contract.Not_Upper_limit_reason__c = ' 1';
|
// contract.Contract_Start_Date__c = Date.newInstance(2021,10,5);
|
// contract.Contract_End_Date__c = Date.newInstance(2021,11,1);
|
// contract.SalesOfficeCode_selection__c = '北京RC';
|
// contract.New_Contract_TypeF_Text__c = '续签合同';
|
// contract.IF_Target_Renew__c='1';
|
// contract.Contract_Conclusion_Date__c=Date.newInstance(2021,10,5);
|
// insert contract;
|
// String hpTypeId=[Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
|
// List<Account> hpL=[Select id from Account where recordtypeId =:hpTypeId];
|
|
Map<String, Object> eventcMap1 = new Map<String, Object>();
|
eventcMap1.put('ActivityDate__c', date.today());
|
eventcMap1.put('StartDateTime__c', Datetime.newInstance(year, month,days, 10, 0, 0));
|
eventcMap1.put('EndDateTime__c', Datetime.newInstance(year, month,days, 11, 0, 0));
|
eventcMap1.put('whatid__c', hpId);
|
eventcMap1.put('Daily_Report__c', dr1.Id);
|
eventcMap1.put('Visitor1_ID__c', depId);
|
// Contact contactItem=[select id from contact limit 1];
|
eventcMap1.put('Visitor2_ID__c', contactId);
|
eventcMap1.put('Visitor3_ID__c', contactId);
|
// Opportunity opp=[select id from Opportunity limit 1];
|
eventcMap1.put('Related_Opportunity1_ID__c', oppId);
|
eventcMap1.put('Related_Opportunity2_ID__c', oppId);
|
eventcMap1.put('Related_Opportunity3_ID__c', oppId);
|
eventcMap1.put('Related_Service1_ID__c', contactId);
|
eventcMap1.put('Related_Service2_ID__c', contactId);
|
reportMap1.put('Report_Contract__c', ' FSE');
|
reportMap1.put('Report_Contract_Type__c', '线上(微信、邮件)');
|
reportMap1.put('relatedService1', mccId);
|
|
List<task__c> tasks = [select Id from task__c limit 1];
|
if(tasks.size()>0) {
|
eventcMap1.put('taskId__c', tasks[0].Id);
|
}
|
List<Infrastructure_Project__c> projects=new List<Infrastructure_Project__c>();
|
Infrastructure_Project__c project = new Infrastructure_Project__c();
|
project.Name = 'Test';
|
project.Province__c = '北京市';
|
project.City__c = '北京市';
|
project.OCSM_Hospital__c = hpId;
|
projects.add(project);
|
Infrastructure_Project__c project2 = new Infrastructure_Project__c();
|
project2.Name = 'Test222';
|
project2.Province__c = '天津市';
|
project2.City__c = '天津市';
|
project2.OCSM_Hospital__c = hpId;
|
projects.add(project2);
|
// insert projects;
|
eventJsonStr = JSON.serialize(eventcMap1);
|
|
Test.startTest();
|
LwcDailyReportController.saveActivity( eventJsonStr,9,0,18,
|
0, visit, visitAim,
|
purposeType1, purposeType2, purposeType3,
|
contactId1, contactId2, contactId3,
|
accountId, reportJsonStr,1,0,2,0
|
, relatedOpportunity1, relatedOpportunity2, relatedOpportunity3, relatedService1
|
, infrastructureProject1, infrastructureProject2
|
);
|
// visit='';
|
// visitAim='';
|
// purposeType1='';
|
// purposeType2='';
|
// purposeType3='';
|
// contactId1=contact2.id;
|
// contactId2=contact3.id;
|
// contactId3=contact3.id;
|
// accountId=hpId;
|
// relatedOpportunity1=opp.id;
|
// relatedOpportunity2=opp1.id;
|
// relatedOpportunity3=opp1.id;
|
// relatedService1=contract.id;
|
// infrastructureProject1=project.id;
|
// infrastructureProject2=project2.id;
|
// LwcDailyReportController.saveActivity( eventJsonStr,9,0,18,
|
// 0, visit, visitAim,
|
// purposeType1, purposeType2, purposeType3,
|
// contactId1, contactId2, contactId3,
|
// accountId, reportJsonStr,1,0,2,0
|
// , relatedOpportunity1, relatedOpportunity2, relatedOpportunity3, relatedService1
|
// , infrastructureProject1, infrastructureProject2
|
// );
|
// User user1 = getUser1();
|
// system.runAs(user1) {
|
// LwcDailyReportController.saveActivity( eventJsonStr,9,0,18,
|
// 0, visit, visitAim,
|
// purposeType1, purposeType2, purposeType3,
|
// contactId1, contactId2, contactId3,
|
// accountId, reportJsonStr,1,0,2,0
|
// , relatedOpportunity1, relatedOpportunity2, relatedOpportunity3, relatedService1
|
// , infrastructureProject1, infrastructureProject2
|
// );
|
|
// String reportedId ='';
|
// List<Map<String, Object>> eventcsList = new List<Map<String, Object>>();
|
// eventcsList.add(eventcMap1);
|
// String eventsJsonStr = JSON.serialize(eventcsList);
|
// LwcDailyReportController.saveAllData( eventsJsonStr, reportJsonStr, 1, 0,2,0, reportedId );
|
// }
|
|
Test.stopTest();
|
}
|
}
|
@isTest
|
public static void test_method_four() {
|
Test.startTest();
|
User user2 = getUser2();
|
System.runAs(user2) {
|
setupFor4();
|
|
String t1Id=task1Id;
|
|
List<Event> el=new List<Event>();
|
Event e1 = new Event();
|
e1.ActivityDateTime = Datetime.newInstance(2016, 1, 1, 1, 0, 0);
|
e1.DurationInMinutes = 60;
|
e1.ActivityDate = Date.newInstance(2016, 1, 1);
|
e1.OwnerId = UserInfo.getUserId();
|
e1.IsScheduled__c = true;
|
e1.whatid__c = hpId;
|
// e1.NextEventC_ID__c = ec.Id;
|
// e1.task_id__c = t1Id;
|
el.add(e1);
|
Event e2 = new Event();
|
e2.ActivityDateTime = Datetime.newInstance(2016, 1, 1, 2, 0, 0);
|
e2.ActivityDate = Date.newInstance(2016, 1, 1);
|
e2.DurationInMinutes = 60;
|
e2.OwnerId = UserInfo.getUserId();
|
e2.IsScheduled__c = true;
|
e2.whatid__c = camId;
|
e2.NextEventC_ID__c = e1.Id;
|
// e2.task_id__c = t1Id;
|
e2.eventStatus__c = '05 延期';
|
el.add(e2);
|
Event e3 = new Event();
|
e3.ActivityDateTime = Datetime.newInstance(2016, 1, 1, 2, 0, 0);
|
e3.ActivityDate = Date.newInstance(2016, 1, 1);
|
e3.DurationInMinutes = 60;
|
e3.OwnerId = UserInfo.getUserId();
|
e3.IsScheduled__c = true;
|
e3.whatid__c = hpId;
|
e3.eventStatus__c = '04 取消';
|
// e2.NextEventC_ID__c = ec.Id;
|
// e3.task_id__c = t3.Id;
|
el.add(e3);
|
// el.add(e1);
|
// el.add(e2);
|
// el.add(e3);
|
// insert el;
|
insert el;
|
List<Event__c> ecl=new List<Event__c>();
|
Event__c ec1 = new Event__c(
|
Subject__c = 'test',
|
StartDateTime__c = Datetime.newInstance(2016, 1, 1, 1, 0, 0),
|
DurationInMinutes__c = 60,
|
EndDateTime__c = Datetime.newInstance(2016, 1, 1, 2, 0, 0),
|
ActivityDate__c = Date.newInstance(2016, 1, 1),
|
delayToDate__c = Date.newInstance(2016, 1, 2),
|
Event_ID__c = e1.Id,
|
Daily_Report__c = drId,
|
whatid__c = camId,
|
eventStatus__c='取消'
|
);
|
// insert ec1;
|
Event__c ec2 = new Event__c(
|
Subject__c = 'test',
|
StartDateTime__c = Datetime.newInstance(2016, 1, 1, 3, 0, 0),
|
DurationInMinutes__c = 60,
|
EndDateTime__c = Datetime.newInstance(2016, 1, 1, 4, 0, 0),
|
ActivityDate__c = Date.newInstance(2016, 1, 1),
|
delayToDate__c = Date.newInstance(2016, 1, 2),
|
eventStatus__c = '延期',
|
Event_ID__c = e2.Id,
|
Daily_Report__c = drId,
|
whatid__c = hpId
|
);
|
// insert ec2;
|
Event__c ec3 = new Event__c(
|
Subject__c = 'test',
|
StartDateTime__c = Datetime.newInstance(2016, 1, 1, 3, 0, 0),
|
DurationInMinutes__c = 60,
|
EndDateTime__c = Datetime.newInstance(2016, 1, 1, 4, 0, 0),
|
ActivityDate__c = Date.newInstance(2016, 1, 1),
|
eventStatus__c = '取消',
|
Event_ID__c = e3.Id,
|
Daily_Report__c = drId
|
);
|
// insert ec3;
|
ecl.add(ec1);
|
ecl.add(ec2);
|
ecl.add(ec3);
|
insert ecl;
|
LwcDailyReportController.init(drId);
|
// LwcDailyReportController.updateTask(dr.Id);
|
}
|
Test.stopTest();
|
|
}
|
|
@isTest
|
public static void test_method_updateEvent() {
|
Test.startTest();
|
User user2 = getUser2();
|
System.runAs(user2) {
|
setupFor4();
|
Daily_Report__c dr = new Daily_Report__c();
|
dr.Id=drId;
|
|
|
List<Event> events = new List<Event>();
|
Event e1 = new Event();
|
e1.ActivityDateTime = Datetime.newInstance(2016, 1, 1, 1, 0, 0);
|
e1.DurationInMinutes = 60;
|
e1.ActivityDate = Date.newInstance(2016, 1, 1);
|
e1.OwnerId = UserInfo.getUserId();
|
e1.IsScheduled__c = true;
|
e1.whatid__c = hpId;
|
// e1.NextEventC_ID__c = ec.Id;
|
e1.task_id__c = task1Id;
|
events.add(e1);
|
|
Event e2 = new Event();
|
e2.ActivityDateTime = Datetime.newInstance(2016, 1, 1, 2, 0, 0);
|
e2.ActivityDate = Date.newInstance(2016, 1, 1);
|
e2.DurationInMinutes = 60;
|
e2.OwnerId = UserInfo.getUserId();
|
e2.IsScheduled__c = true;
|
e2.whatid__c = camId;
|
// e2.NextEventC_ID__c = ec.Id;
|
e2.task_id__c = task2Id;
|
events.add(e2);
|
Event e3 = new Event();
|
e3.ActivityDateTime = Datetime.newInstance(2016, 1, 1, 2, 0, 0);
|
e3.ActivityDate = Date.newInstance(2016, 1, 1);
|
e3.DurationInMinutes = 60;
|
e3.OwnerId = UserInfo.getUserId();
|
e3.IsScheduled__c = true;
|
e3.whatid__c = hpId;
|
// e2.NextEventC_ID__c = ec.Id;
|
// e3.task_id__c = t3.Id;
|
events.add(e3);
|
insert events;
|
|
List<Event__c> eventcs = new List<Event__c>();
|
Event__c ec1 = new Event__c(
|
Subject__c = 'test',
|
StartDateTime__c = Datetime.newInstance(2016, 1, 1, 1, 0, 0),
|
DurationInMinutes__c = 60,
|
EndDateTime__c = Datetime.newInstance(2016, 1, 1, 2, 0, 0),
|
ActivityDate__c = Date.newInstance(2016, 1, 1),
|
delayToDate__c = Date.newInstance(2016, 1, 2),
|
eventStatus__c = '延期',
|
Event_ID__c = e1.Id,
|
Daily_Report__c = dr.Id
|
);
|
eventcs.add(ec1);
|
Event__c ec2 = new Event__c(
|
Subject__c = 'test',
|
StartDateTime__c = Datetime.newInstance(2016, 1, 1, 3, 0, 0),
|
DurationInMinutes__c = 60,
|
EndDateTime__c = Datetime.newInstance(2016, 1, 1, 4, 0, 0),
|
ActivityDate__c = Date.newInstance(2016, 1, 1),
|
delayToDate__c = Date.newInstance(2016, 1, 2),
|
eventStatus__c = '延期',
|
Event_ID__c = e2.Id,
|
Daily_Report__c = dr.Id
|
);
|
eventcs.add(ec2);
|
Event__c ec3 = new Event__c(
|
Subject__c = 'test',
|
StartDateTime__c = Datetime.newInstance(2016, 1, 1, 3, 0, 0),
|
DurationInMinutes__c = 60,
|
EndDateTime__c = Datetime.newInstance(2016, 1, 1, 4, 0, 0),
|
ActivityDate__c = Date.newInstance(2016, 1, 1),
|
eventStatus__c = '取消',
|
Event_ID__c = e3.Id,
|
Daily_Report__c = dr.Id
|
);
|
eventcs.add(ec3);
|
insert eventcs;
|
LwcDailyReportController.updateEvent(racId,ec3.Id,'Rental_Apply');
|
// LwcDailyReportController.updateEvent('02i10000004u0jTAAQ',ec3.Id,'Asset_Manual');
|
// LwcDailyReportController.updateEvent('a0B1000003OAcP2EAL',ec3.Id,'Product_Explanation');
|
// LwcDailyReportController.updateEvent('a0B1000003OAcP2EAL',ec3.Id,'OPD');
|
// LwcDailyReportController.updateEvent('a0B1000003OAcP2EAL',ec3.Id,'NTC');
|
// LwcDailyReportController.updateEvent('a0e10000008fflDAAQ',ec3.Id,'On_Call');
|
// LwcDailyReportController.updateEvent('a0Y10000001U5JEEA0',ec3.Id,'Visit_With');
|
// LwcDailyReportController.updateEvent('a0B1000003OAcP2EAL',ec3.Id,'MarketCondition');
|
// LwcDailyReportController.updateEvent('a0B1000003OAcP2EAL',ec3.Id,'Improvement');
|
// LwcDailyReportController.updateEvent('a0B1000003OAcP2EAL',ec3.Id,'Competitor');
|
// LwcDailyReportController.updateEvent('a0f1000000LcKkTAAV',ec3.Id,'Complaint');
|
}
|
Test.stopTest();
|
}
|
@isTest
|
public static void test_method_addReportNT() {
|
Test.startTest();
|
User user2 = getUser2();
|
Oly_TriggerHandler.bypass('TaskObjectTriggerHandle');
|
Oly_TriggerHandler.bypass('taskObjectTrigger');
|
Oly_TriggerHandler.bypass('ContactTrigger');
|
ControllerUtil.EscapeNFM001Trigger = true;
|
StaticParameter.EscapeNFM001Trigger = true;
|
StaticParameter.EscapeAccountTrigger = true;
|
StaticParameter.EscapeNFM001AgencyContractTrigger = true;
|
Oly_TriggerHandler.bypass(Product2Handler.Class.getName());
|
Oly_TriggerHandler.bypass(AssetHandler.Class.getName());
|
Oly_TriggerHandler.bypass(FixtureSetHandler.Class.getName());
|
Oly_TriggerHandler.bypass(RentalApplyTriggerHandler.Class.getName());
|
Oly_TriggerHandler.bypass(RentalApplyEquipmentSetHandler.Class.getName());
|
Oly_TriggerHandler.bypass(RentalApplyEquipmentSetDetailHandler.Class.getName());
|
Oly_TriggerHandler.bypass(ContactTriggerHandler.Class.getName());
|
Oly_TriggerHandler.bypass('AssetTrigger');
|
Oly_TriggerHandler.bypass('MaintenanceContractTrigger');
|
Oly_TriggerHandler.bypass('MaintenanceContractAfterUpdate');
|
Oly_TriggerHandler.bypass('MaintenanceContractBeforeDelete');
|
Oly_TriggerHandler.bypass('MaintenanceContractHpDeptUpd');
|
Oly_TriggerHandler.bypass('NFM106Controller');
|
Oly_TriggerHandler.bypass('NFM101Controller');
|
Oly_TriggerHandler.bypass('AgencyOpportunityHandler');
|
Oly_TriggerHandler.bypass('NFM001AgencyContract');
|
Oly_TriggerHandler.bypass('XinEventC2Event');
|
Oly_TriggerHandler.bypass('DailyReportSetHospitalCount');
|
Oly_TriggerHandler.bypass('AgencyHospitalHandler');
|
Oly_TriggerHandler.bypass('ContactTriggerHandler');
|
Oly_TriggerHandler.bypass('Oly_TriggerHandler');
|
Oly_TriggerHandler.bypass('PIHelper');
|
Oly_TriggerHandler.bypass('DailyReportLink2OlympusCalendar');
|
System.runAs(user2) {
|
initData();
|
// List<task__c> tl=new List<task__c>();
|
// task__c t1 = new task__c();
|
// t1.Name = 'test';
|
// t1.taskDifferent__c = '主动任务';
|
// insert t1;
|
// task__c t2 = new task__c();
|
// t2.Name = 'test';
|
// t2.taskDifferent__c = '主动任务';
|
// // insert t2;
|
// task__c t3 = new task__c();
|
// t3.Name = 'test';
|
// t3.taskDifferent__c = '主动任务';
|
// tl.add(t1);
|
// tl.add(t2);
|
// tl.add(t3);
|
// insert tl;
|
|
// List<Event> eL=new List<Event>();
|
// Event e1 = new Event();
|
// e1.ActivityDateTime = Datetime.newInstance(2016, 1, 1, 1, 0, 0);
|
// e1.DurationInMinutes = 60;
|
// e1.ActivityDate = Date.newInstance(2016, 1, 1);
|
// e1.OwnerId = UserInfo.getUserId();
|
// e1.IsScheduled__c = true;
|
// e1.whatid__c = hpId;
|
// // e1.NextEventC_ID__c = ec.Id;
|
// // e1.task_id__c = task1Id;
|
// eL.add(e1);
|
|
// Event e2 = new Event();
|
// e2.ActivityDateTime = Datetime.newInstance(2016, 1, 1, 2, 0, 0);
|
// e2.ActivityDate = Date.newInstance(2016, 1, 1);
|
// e2.DurationInMinutes = 60;
|
// e2.OwnerId = UserInfo.getUserId();
|
// e2.IsScheduled__c = true;
|
// e2.whatid__c = camId;
|
// // e2.NextEventC_ID__c = ec.Id;
|
// // e2.task_id__c = task2Id;
|
// eL.add(e2);
|
// Event e3 = new Event();
|
// e3.ActivityDateTime = Datetime.newInstance(2016, 1, 1, 2, 0, 0);
|
// e3.ActivityDate = Date.newInstance(2016, 1, 1);
|
// e3.DurationInMinutes = 60;
|
// e3.OwnerId = UserInfo.getUserId();
|
// e3.IsScheduled__c = true;
|
// e3.whatid__c = hpId;
|
// // e2.NextEventC_ID__c = ec.Id;
|
// // e3.task_id__c = t3.Id;
|
// eL.add(e3);
|
// insert eL;
|
// Event__c ec1 = new Event__c(
|
// Subject__c = 'test',
|
// StartDateTime__c = Datetime.newInstance(2016, 1, 1, 1, 0, 0),
|
// DurationInMinutes__c = 60,
|
// EndDateTime__c = Datetime.newInstance(2016, 1, 1, 2, 0, 0),
|
// ActivityDate__c = Date.newInstance(2016, 1, 1),
|
// delayToDate__c = Date.newInstance(2016, 1, 2),
|
// eventStatus__c = '延期',
|
// Event_ID__c = e1.Id,
|
// Daily_Report__c = drId
|
// );
|
// insert ec1;
|
// Event__c ec2 = new Event__c(
|
// Subject__c = 'test',
|
// StartDateTime__c = Datetime.newInstance(2016, 1, 1, 3, 0, 0),
|
// DurationInMinutes__c = 60,
|
// EndDateTime__c = Datetime.newInstance(2016, 1, 1, 4, 0, 0),
|
// ActivityDate__c = Date.newInstance(2016, 1, 1),
|
// delayToDate__c = Date.newInstance(2016, 1, 2),
|
// eventStatus__c = '延期',
|
// Event_ID__c = e2.Id,
|
// Daily_Report__c = drId
|
// );
|
// insert ec2;
|
// Event__c ec3 = new Event__c(
|
// Subject__c = 'test',
|
// StartDateTime__c = Datetime.newInstance(2016, 1, 1, 3, 0, 0),
|
// DurationInMinutes__c = 60,
|
// EndDateTime__c = Datetime.newInstance(2016, 1, 1, 4, 0, 0),
|
// ActivityDate__c = Date.newInstance(2016, 1, 1),
|
// eventStatus__c = '取消',
|
// Event_ID__c = e3.Id,
|
// Daily_Report__c = drId
|
// );
|
// insert ec3;
|
|
String repOwnerId = hpId;
|
String dailyReportId = drId;
|
String eventId = eventc1Id;
|
String recordType = 'OPD';
|
String aId = '内镜中心';
|
String aId1 = hpId;
|
String visitor1 = contact2Id;
|
String visitor2 = contact3Id;
|
String visitor3 = contact4Id;
|
|
String relatedOpportunity1=opp1Id;
|
String relatedOpportunity2=opp2Id;
|
String relatedOpportunity3=opp3Id;
|
|
// 产品
|
Product2 pro1 = new Product2(Name='name05',IsActive=true,Family='SP',
|
Fixture_Model_No__c='n05',Serial_Lot_No__c='S/N tracing',
|
Fixture_Model_No_T__c = 'n05',
|
ProductCode_Ext__c='pc05',Manual_Entry__c=false);
|
insert pro1;
|
Datetime sTime = Datetime.newInstance(2020,1,1);
|
Datetime eTime = Datetime.newInstance(2022,1,1);
|
// LwcDailyReportController.addReportNT( repOwnerId, dailyReportId, eventId, recordType, aId,
|
// visitor1, visitor2, visitor3, sTime, eTime);
|
try{
|
LwcDailyReportController.addReportNT( repOwnerId, dailyReportId, eventId, recordType, aId,
|
visitor1, visitor2, visitor3, sTime, eTime);
|
}catch(Exception e){
|
|
}
|
|
// LwcDailyReportController.addReportOPWithEvaluationPDF( repOwnerId,dailyReportId,
|
// eventId, recordType, aId, visitor1, visitor2, visitor3,
|
// relatedOpportunity1, relatedOpportunity2, relatedOpportunity3, dr.Reported_Date__c,
|
// '', pro1.Id, sTime, eTime) ;
|
try{
|
LwcDailyReportController.addReportOPWithEvaluationPDF( repOwnerId,dailyReportId,
|
eventId, recordType, hpId, visitor1, visitor2, visitor3,
|
relatedOpportunity1, relatedOpportunity2, relatedOpportunity3, date.today().addDays(0),
|
'', pro1.Id, sTime, eTime) ;
|
}catch(Exception e){
|
|
}
|
|
}
|
Test.stopTest();
|
|
}
|
|
|
|
|
@isTest
|
public static void test_updatTask01() {
|
Test.startTest();
|
User user2 = getUser2();
|
System.runAs(user2) {
|
initData();
|
// Daily_Report__c dr = new Daily_Report__c();
|
// dr.Reported_Date__c = Date.newInstance(2016, 1, 1);
|
// dr.Status__c = '申請中';
|
// dr.OwnerId = UserInfo.getUserId();
|
// dr.Reporter__c = UserInfo.getUserId();
|
// insert dr;
|
|
// task__c t1 = new task__c();
|
// t1.Name = 'test';
|
// t1.taskDifferent__c = '主动任务';
|
// // insert t1;
|
// task__c t2 = new task__c();
|
// t2.Name = 'test';
|
// t2.taskDifferent__c = '主动任务';
|
// // insert t2;
|
// task__c t3 = new task__c();
|
// t3.Name = 'test';
|
// t3.taskDifferent__c = '主动任务';
|
// insert t1;
|
// insert t2;
|
// insert t3;
|
|
// Event e1 = new Event();
|
// e1.ActivityDateTime = Datetime.newInstance(2016, 1, 1, 1, 0, 0);
|
// e1.DurationInMinutes = 60;
|
// e1.ActivityDate = Date.newInstance(2016, 1, 1);
|
// e1.OwnerId = UserInfo.getUserId();
|
// e1.IsScheduled__c = true;
|
// e1.whatid__c = hpId;
|
// // e1.NextEventC_ID__c = ec.Id;
|
// e1.task_id__c = t1.Id;
|
// insert e1;
|
|
// Event e2 = new Event();
|
// e2.ActivityDateTime = Datetime.newInstance(2016, 1, 1, 2, 0, 0);
|
// e2.ActivityDate = Date.newInstance(2016, 1, 1);
|
// e2.DurationInMinutes = 60;
|
// e2.OwnerId = UserInfo.getUserId();
|
// e2.IsScheduled__c = true;
|
// e2.whatid__c = camId;
|
// e2.NextEventC_ID__c = e1.Id;
|
// // e2.task_id__c = t2.Id;
|
// e2.eventStatus__c = '05 延期';
|
// insert e2;
|
// Event e3 = new Event();
|
// e3.ActivityDateTime = Datetime.newInstance(2016, 1, 1, 2, 0, 0);
|
// e3.ActivityDate = Date.newInstance(2016, 1, 1);
|
// e3.DurationInMinutes = 60;
|
// e3.OwnerId = UserInfo.getUserId();
|
// e3.IsScheduled__c = true;
|
// e3.whatid__c = hpId;
|
// e3.eventStatus__c = '04 取消';
|
// // e2.NextEventC_ID__c = ec.Id;
|
// // e3.task_id__c = t3.Id;
|
// insert e3;
|
|
// Event__c ec1 = new Event__c(
|
// Subject__c = 'test',
|
// StartDateTime__c = Datetime.newInstance(2016, 1, 1, 1, 0, 0),
|
// DurationInMinutes__c = 60,
|
// EndDateTime__c = Datetime.newInstance(2016, 1, 1, 2, 0, 0),
|
// ActivityDate__c = Date.newInstance(2016, 1, 1),
|
// delayToDate__c = Date.newInstance(2016, 1, 2),
|
// Event_ID__c = e1.Id,
|
// Daily_Report__c = dr.Id
|
// );
|
// insert ec1;
|
// Event__c ec2 = new Event__c(
|
// Subject__c = 'test',
|
// StartDateTime__c = Datetime.newInstance(2016, 1, 1, 3, 0, 0),
|
// DurationInMinutes__c = 60,
|
// EndDateTime__c = Datetime.newInstance(2016, 1, 1, 4, 0, 0),
|
// ActivityDate__c = Date.newInstance(2016, 1, 1),
|
// delayToDate__c = Date.newInstance(2016, 1, 2),
|
// eventStatus__c = '延期',
|
// Event_ID__c = e2.Id,
|
// Daily_Report__c = dr.Id
|
// );
|
// insert ec2;
|
// Event__c ec3 = new Event__c(
|
// Subject__c = 'test',
|
// StartDateTime__c = Datetime.newInstance(2016, 1, 1, 3, 0, 0),
|
// DurationInMinutes__c = 60,
|
// EndDateTime__c = Datetime.newInstance(2016, 1, 1, 4, 0, 0),
|
// ActivityDate__c = Date.newInstance(2016, 1, 1),
|
// eventStatus__c = '取消',
|
// Event_ID__c = e3.Id,
|
// Daily_Report__c = dr.Id
|
// );
|
// insert ec3;
|
LwcDailyReportController.updateTask(drId);
|
}
|
Test.stopTest();
|
|
}
|
@isTest
|
public static void test_updatTask03() {
|
Test.startTest();
|
User user2 = getUser2();
|
System.runAs(user2) {
|
setup2();
|
LwcDailyReportController.updateTask(drId);
|
}
|
Test.stopTest();
|
|
}
|
|
@isTest
|
public static void test_updatTask02() {
|
Test.startTest();
|
User user2 = getUser2();
|
System.runAs(user2) {
|
// initData();
|
Daily_Report__c dr = new Daily_Report__c();
|
dr.Reported_Date__c = Date.newInstance(2016, 1, 1);
|
dr.Status__c = '申請中';
|
dr.OwnerId = UserInfo.getUserId();
|
dr.Reporter__c = UserInfo.getUserId();
|
insert dr;
|
|
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 = depId;
|
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__c t1 = new task__c();
|
t1.Name = 'test';
|
t1.taskDifferent__c = '主动任务';
|
|
|
// insert t1;
|
task__c t2 = new task__c();
|
t2.Name = 'test';
|
t2.taskDifferent__c = '主动任务';
|
t2.Opd_Plan__c = oPDPlan0.Id;
|
t2.taskStatus__c = '05 延期';
|
// insert t2;
|
task__c t3 = new task__c();
|
t3.Name = 'test';
|
t3.taskDifferent__c = '主动任务';
|
t3.Opd_Plan__c = oPDPlan0.Id;
|
t3.taskStatus__c = '04 取消';
|
insert t1;
|
insert t2;
|
insert t3;
|
|
Event e1 = new Event();
|
e1.ActivityDateTime = Datetime.newInstance(2016, 1, 1, 1, 0, 0);
|
e1.DurationInMinutes = 60;
|
e1.ActivityDate = Date.newInstance(2016, 1, 1);
|
e1.OwnerId = UserInfo.getUserId();
|
e1.IsScheduled__c = true;
|
e1.whatid__c = hpId;
|
// e1.NextEventC_ID__c = ec.Id;
|
e1.task_id__c = t1.Id;
|
insert e1;
|
|
Event e2 = new Event();
|
e2.ActivityDateTime = Datetime.newInstance(2016, 1, 1, 2, 0, 0);
|
e2.ActivityDate = Date.newInstance(2016, 1, 1);
|
e2.DurationInMinutes = 60;
|
e2.OwnerId = UserInfo.getUserId();
|
e2.IsScheduled__c = true;
|
e2.whatid__c = camId;
|
// e2.NextEventC_ID__c = ec.Id;
|
e2.task_id__c = t2.Id;
|
e2.eventStatus__c = '05 延期';
|
insert e2;
|
Event e3 = new Event();
|
e3.ActivityDateTime = Datetime.newInstance(2016, 1, 1, 2, 0, 0);
|
e3.ActivityDate = Date.newInstance(2016, 1, 1);
|
e3.DurationInMinutes = 60;
|
e3.OwnerId = UserInfo.getUserId();
|
e3.IsScheduled__c = true;
|
e3.whatid__c = hpId;
|
e3.eventStatus__c = '04 取消';
|
// e2.NextEventC_ID__c = ec.Id;
|
e3.task_id__c = t3.Id;
|
insert e3;
|
|
Event__c ec1 = new Event__c(
|
Subject__c = 'test',
|
StartDateTime__c = Datetime.newInstance(2016, 1, 1, 1, 0, 0),
|
DurationInMinutes__c = 60,
|
EndDateTime__c = Datetime.newInstance(2016, 1, 1, 2, 0, 0),
|
ActivityDate__c = Date.newInstance(2016, 1, 1),
|
delayToDate__c = Date.newInstance(2016, 1, 2),
|
Event_ID__c = e1.Id,
|
Daily_Report__c = dr.Id
|
);
|
insert ec1;
|
Event__c ec2 = new Event__c(
|
Subject__c = 'test',
|
StartDateTime__c = Datetime.newInstance(2016, 1, 1, 3, 0, 0),
|
DurationInMinutes__c = 60,
|
EndDateTime__c = Datetime.newInstance(2016, 1, 1, 4, 0, 0),
|
ActivityDate__c = Date.newInstance(2016, 1, 1),
|
delayToDate__c = Date.newInstance(2016, 1, 2),
|
eventStatus__c = '延期',
|
Event_ID__c = e2.Id,
|
Daily_Report__c = dr.Id
|
);
|
insert ec2;
|
Event__c ec3 = new Event__c(
|
Subject__c = 'test',
|
StartDateTime__c = Datetime.newInstance(2016, 1, 1, 3, 0, 0),
|
DurationInMinutes__c = 60,
|
EndDateTime__c = Datetime.newInstance(2016, 1, 1, 4, 0, 0),
|
ActivityDate__c = Date.newInstance(2016, 1, 1),
|
eventStatus__c = '取消',
|
Event_ID__c = e3.Id,
|
Daily_Report__c = dr.Id
|
);
|
insert ec3;
|
LwcDailyReportController.updateTask(dr.Id);
|
}
|
Test.stopTest();
|
|
}
|
|
|
@isTest
|
public static void test_slaAbout01() {
|
Test.startTest();
|
User user2 = getUser2();
|
System.runAs(user2) {
|
initData();
|
// Daily_Report__c dr = new Daily_Report__c();
|
// dr.Reported_Date__c = Date.newInstance(2016, 1, 1);
|
// dr.Status__c = '申請中';
|
// dr.OwnerId = UserInfo.getUserId();
|
// dr.Reporter__c = UserInfo.getUserId();
|
// insert dr;
|
|
// 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 =hpId;
|
// 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__c t1 = new task__c();
|
// t1.Name = 'test';
|
// t1.taskDifferent__c = '主动任务';
|
|
|
// // insert t1;
|
// task__c t2 = new task__c();
|
// t2.Name = 'test';
|
// t2.taskDifferent__c = '主动任务';
|
// t2.Opd_Plan__c = oPDPlan0.Id;
|
// t2.taskStatus__c = '05 延期';
|
// // insert t2;
|
// task__c t3 = new task__c();
|
// t3.Name = 'test';
|
// t3.taskDifferent__c = '主动任务';
|
// t3.Opd_Plan__c = oPDPlan0.Id;
|
// t3.taskStatus__c = '04 取消';
|
// insert t1;
|
// insert t2;
|
// insert t3;
|
|
// Event e1 = new Event();
|
// e1.ActivityDateTime = Datetime.newInstance(2016, 1, 1, 1, 0, 0);
|
// e1.DurationInMinutes = 60;
|
// e1.ActivityDate = Date.newInstance(2016, 1, 1);
|
// e1.OwnerId = UserInfo.getUserId();
|
// e1.IsScheduled__c = true;
|
// e1.whatid__c = '0011000000VATIUAA5';
|
// // e1.NextEventC_ID__c = ec.Id;
|
// e1.task_id__c = t1.Id;
|
// insert e1;
|
// Event__c ec1 = new Event__c(
|
// Subject__c = 'test',
|
// StartDateTime__c = Datetime.newInstance(2016, 1, 1, 1, 0, 0),
|
// DurationInMinutes__c = 60,
|
// EndDateTime__c = Datetime.newInstance(2016, 1, 1, 2, 0, 0),
|
// ActivityDate__c = Date.newInstance(2016, 1, 1),
|
// delayToDate__c = Date.newInstance(2016, 1, 2),
|
// Event_ID__c = e1.Id,
|
// Daily_Report__c = dr.Id
|
// );
|
// insert ec1;
|
|
List<Event__c> eventcs = [select id,eventStatus__c,Subject__c,StartDateTime__c,DurationInMinutes__c,EndDateTime__c,ActivityDate__c
|
,delayToDate__c,Event_ID__c,Daily_Report__c,SLAReportInfo__c
|
,Purpose_TypeFSE__c,UseReport__c,SLARecorded__c,Related_Service1_ID__c from Event__c];
|
|
LwcDailyReportController.slaAbout(drId,eventcs);
|
}
|
Test.stopTest();
|
|
}
|
|
|
@isTest
|
public static void test_saveActivity02() {
|
User user1 = getUser1();
|
System.runAs(user1) {
|
initData();
|
Test.startTest();
|
Integer year = date.today().year();
|
Integer month = date.today().month();
|
Integer days = date.today().day();
|
Map<String, Object> contactMap1 = new Map<String, Object>();
|
contactMap1.put('AccountId', hpId);
|
// contactMap1.put('FirstName', '責任者');
|
contactMap1.put('LastName', 'test1经销商');
|
|
// 将Map转换为JSON格式的字符串
|
String contactJSON = JSON.serialize(contactMap1);
|
LwcDailyReportController.saveContact(contactJSON);
|
|
|
RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
|
|
Account acc1 = new Account();
|
acc1.RecordTypeId = rectCo.Id;
|
acc1.Name = 'HP test2';
|
acc1.Is_Active__c = '草案中';
|
acc1.Is_upload_file__c = true;
|
insert acc1;
|
String visit='';
|
String visitAim='';
|
String purposeType1='';
|
String purposeType2='';
|
String purposeType3='';
|
String contactId1='';
|
String contactId2='';
|
String contactId3='';
|
String accountId='';
|
String relatedOpportunity1='';
|
String relatedOpportunity2='';
|
String relatedOpportunity3='';
|
String relatedService1=mccId;
|
String infrastructureProject1='';
|
String infrastructureProject2='';
|
String reportJsonStr=null;
|
String eventJsonStr=null;
|
Daily_Report__c dr1 =[select id from Daily_Report__c limit 1];
|
|
|
Map<String, Object> reportMap1 = new Map<String, Object>();
|
reportMap1.put('Id',dr1.Id);
|
reportMap1.put('Reporter__c', UserInfo.getUserId());
|
reportMap1.put('Reported_Date__c', date.today());
|
reportMap1.put('Status__c', '作成中');
|
reportMap1.put('Working_Time_From__c', Datetime.newInstance(year, month,days, 0, 0, 0));
|
reportMap1.put('Working_Time_To__c', Datetime.newInstance(year, month,days, 9, 0, 0));
|
reportMap1.put('Report_Contract__c', ' FSE');
|
|
|
reportJsonStr = JSON.serialize(reportMap1);
|
Event__c event = new Event__c();
|
event.ActivityDate__c = date.today();
|
event.Daily_Report__c = dr1.Id;
|
event.StartDateTime__c = Datetime.newInstance(year, month,days, 10, 0, 0);
|
event.EndDateTime__c = Datetime.newInstance(year, month,days, 11, 0, 0);
|
event.whatid__c = camId;
|
|
insert event;
|
|
Map<String, Object> eventcMap1 = new Map<String, Object>();
|
eventcMap1.put('ActivityDate__c', date.today());
|
eventcMap1.put('StartDateTime__c', Datetime.newInstance(year, month,days, 10, 0, 0));
|
eventcMap1.put('EndDateTime__c', Datetime.newInstance(year, month,days, 11, 0, 0));
|
// eventcMap1.put('whatid__c', '0011000000VATIUAA5');
|
eventcMap1.put('Daily_Report__c', dr1.Id);
|
// eventcMap1.put('Visitor1_ID__c', '0011000000VAJYZ');
|
// eventcMap1.put('Visitor2_ID__c', '0031000001beOOa');
|
// eventcMap1.put('Visitor3_ID__c', '0031000001beOOB');
|
// eventcMap1.put('Related_Opportunity1_ID__c', '0061000001NRS3Y');
|
// eventcMap1.put('Related_Opportunity2_ID__c', '0061000001NOjjF');
|
// eventcMap1.put('Related_Opportunity3_ID__c', '0061000001NOjjF');
|
// eventcMap1.put('Related_Service1_ID__c', 'a0H1000001CeHJx');
|
// eventcMap1.put('Related_Service2_ID__c', 'a0H1000001CeHJx');
|
eventcMap1.put('Id', event.Id);
|
eventcMap1.put('Report_Contract_Type__c', '线上(微信、邮件)');
|
eventcMap1.put('relatedService1', mccId);
|
|
|
task__c t1 = new task__c();
|
t1.Name = 'test1';
|
t1.taskDifferent__c = '主动任务';
|
t1.taskStatus__c = '02 接受';
|
t1.assignee__c = Userinfo.getUserId();
|
t1.Event__c = event.Id;
|
t1.Daily_Report__c = dr1.Id;
|
t1.Activity_Date__c = Date.newInstance(year, month,days);
|
insert t1;
|
List<task__c> tasks = [select Id from task__c limit 1];
|
if(tasks.size()>0) {
|
eventcMap1.put('taskId__c', tasks[0].Id);
|
}
|
|
|
eventJsonStr = JSON.serialize(eventcMap1);
|
|
LwcDailyReportController.saveActivity( eventJsonStr,9,0,18,
|
0, visit, visitAim,
|
purposeType1, purposeType2, purposeType3,
|
contactId1, contactId2, contactId3,
|
accountId, reportJsonStr,1,0,2,0
|
, relatedOpportunity1, relatedOpportunity2, relatedOpportunity3, relatedService1
|
, infrastructureProject1, infrastructureProject2
|
);
|
List<Map<String, Object>> eventcsList = new List<Map<String, Object>>();
|
eventcsList.add(eventcMap1);
|
String eventsJsonStr = JSON.serialize(eventcsList);
|
LwcDailyReportController.saveAllData( eventsJsonStr, reportJsonStr, 1, 0,2,0, dr1.Id );
|
|
Test.stopTest();
|
}
|
}
|
@isTest
|
public static void test_getContactAwsIdByCOntactId() {
|
User user1 = getUser1();
|
System.runAs(user1) {
|
initData();
|
Test.startTest();
|
RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_GI', 'Department_BF') order by DeveloperName desc];
|
|
Account acc = new Account();
|
// acc.Id='0011000000VATIUAA5';
|
acc.RecordTypeId = rectCo.Id;
|
acc.Name = 'HP test1';
|
acc.Assume_Change__c = true;
|
insert acc;
|
Contact contact2 = new Contact();
|
contact2.AccountId = acc.Id;
|
// contact2.FirstName = '責任者';
|
contact2.LastName = 'test1经销商';
|
insert contact2;
|
LwcDailyReportController.getContactAwsIdByCOntactId(contact2.id);
|
|
Test.stopTest();
|
}
|
}
|
@isTest
|
public static void test_updatTask06() {
|
Test.startTest();
|
User user2 = getUser2();
|
System.runAs(user2) {
|
initData();
|
// Daily_Report__c dr = new Daily_Report__c();
|
// dr.Reported_Date__c = Date.newInstance(2016, 1, 1);
|
// dr.Status__c = '申請中';
|
// dr.OwnerId = UserInfo.getUserId();
|
// dr.Reporter__c = UserInfo.getUserId();
|
// insert dr;
|
|
// task__c t1 = new task__c();
|
// t1.Name = 'test';
|
// t1.taskDifferent__c = '主动任务';
|
// // insert t1;
|
// task__c t2 = new task__c();
|
// t2.Name = 'test';
|
// t2.taskDifferent__c = '主动任务';
|
// // insert t2;
|
// task__c t3 = new task__c();
|
// t3.Name = 'test';
|
// t3.taskDifferent__c = '主动任务';
|
// insert t1;
|
// insert t2;
|
// insert t3;
|
|
// Event e1 = new Event();
|
// e1.ActivityDateTime = Datetime.newInstance(2016, 1, 1, 1, 0, 0);
|
// e1.DurationInMinutes = 60;
|
// e1.ActivityDate = Date.newInstance(2016, 1, 1);
|
// e1.OwnerId = UserInfo.getUserId();
|
// e1.IsScheduled__c = true;
|
// e1.whatid__c = hpId;
|
// // e1.NextEventC_ID__c = ec.Id;
|
// e1.task_id__c = t1.Id;
|
// insert e1;
|
|
// Event e2 = new Event();
|
// e2.ActivityDateTime = Datetime.newInstance(2016, 1, 1, 2, 0, 0);
|
// e2.ActivityDate = Date.newInstance(2016, 1, 1);
|
// e2.DurationInMinutes = 60;
|
// e2.OwnerId = UserInfo.getUserId();
|
// e2.IsScheduled__c = true;
|
// e2.whatid__c = camId;
|
// e2.NextEventC_ID__c = e1.Id;
|
// e2.task_id__c = t2.Id;
|
// e2.eventStatus__c = '05 延期';
|
// insert e2;
|
// Event e3 = new Event();
|
// e3.ActivityDateTime = Datetime.newInstance(2016, 1, 1, 2, 0, 0);
|
// e3.ActivityDate = Date.newInstance(2016, 1, 1);
|
// e3.DurationInMinutes = 60;
|
// e3.OwnerId = UserInfo.getUserId();
|
// e3.IsScheduled__c = true;
|
// e3.whatid__c = hpId;
|
// e3.eventStatus__c = '04 取消';
|
// // e2.NextEventC_ID__c = ec.Id;
|
// e3.task_id__c = t3.Id;
|
// insert e3;
|
// Event e4 = new Event();
|
// e4.ActivityDateTime = Datetime.newInstance(2016, 1, 1, 2, 0, 0);
|
// e4.ActivityDate = Date.newInstance(2016, 1, 1);
|
// e4.DurationInMinutes = 60;
|
// e4.OwnerId = UserInfo.getUserId();
|
// e4.IsScheduled__c = true;
|
// e4.whatid__c = hpId;
|
// e4.eventStatus__c = '04 取消';
|
// insert e4;
|
// Event e5 = new Event();
|
// e5.ActivityDateTime = Datetime.newInstance(2016, 1, 1, 2, 0, 0);
|
// e5.ActivityDate = Date.newInstance(2016, 1, 1);
|
// e5.DurationInMinutes = 60;
|
// e5.OwnerId = UserInfo.getUserId();
|
// e5.IsScheduled__c = true;
|
// e5.whatid__c = hpId;
|
// e5.eventStatus__c = '05 延期';
|
// insert e5;
|
// Event__c ec1 = new Event__c(
|
// Subject__c = 'test',
|
// StartDateTime__c = Datetime.newInstance(2016, 1, 1, 1, 0, 0),
|
// DurationInMinutes__c = 60,
|
// EndDateTime__c = Datetime.newInstance(2016, 1, 1, 2, 0, 0),
|
// ActivityDate__c = Date.newInstance(2016, 1, 1),
|
// delayToDate__c = Date.newInstance(2016, 1, 2),
|
// Event_ID__c = e1.Id,
|
// Daily_Report__c = dr.Id
|
// );
|
// insert ec1;
|
// Event__c ec2 = new Event__c(
|
// Subject__c = 'test',
|
// StartDateTime__c = Datetime.newInstance(2016, 1, 1, 3, 0, 0),
|
// DurationInMinutes__c = 60,
|
// EndDateTime__c = Datetime.newInstance(2016, 1, 1, 4, 0, 0),
|
// ActivityDate__c = Date.newInstance(2016, 1, 1),
|
// delayToDate__c = Date.newInstance(2016, 1, 2),
|
// eventStatus__c = '延期',
|
// Event_ID__c = e2.Id,
|
// Daily_Report__c = dr.Id
|
// );
|
// insert ec2;
|
// Event__c ec3 = new Event__c(
|
// Subject__c = 'test',
|
// StartDateTime__c = Datetime.newInstance(2016, 1, 1, 3, 0, 0),
|
// DurationInMinutes__c = 60,
|
// EndDateTime__c = Datetime.newInstance(2016, 1, 1, 4, 0, 0),
|
// ActivityDate__c = Date.newInstance(2016, 1, 1),
|
// eventStatus__c = '取消',
|
// Event_ID__c = e3.Id,
|
// Daily_Report__c = dr.Id
|
// );
|
// insert ec3;
|
// Event__c ec4 = new Event__c(
|
// Subject__c = 'test',
|
// StartDateTime__c = Datetime.newInstance(2016, 1, 1, 3, 0, 0),
|
// DurationInMinutes__c = 60,
|
// EndDateTime__c = Datetime.newInstance(2016, 1, 1, 4, 0, 0),
|
// ActivityDate__c = Date.newInstance(2016, 1, 1),
|
// eventStatus__c = '取消',
|
// Event_ID__c = e4.Id,
|
// Daily_Report__c = dr.Id
|
// );
|
// insert ec4;
|
// Event__c ec5 = new Event__c(
|
// Subject__c = 'test',
|
// StartDateTime__c = Datetime.newInstance(2016, 1, 1, 3, 0, 0),
|
// DurationInMinutes__c = 60,
|
// EndDateTime__c = Datetime.newInstance(2016, 1, 1, 4, 0, 0),
|
// ActivityDate__c = Date.newInstance(2016, 1, 1),
|
// eventStatus__c = '延期',
|
// Event_ID__c = e5.Id,
|
// Daily_Report__c = dr.Id
|
// );
|
// insert ec5;
|
|
LwcDailyReportController.updateTask(drId);
|
}
|
Test.stopTest();
|
|
}
|
@isTest
|
public static void test_saveActivity03() {
|
User user1 = getUser1();
|
System.runAs(user1) {
|
setup();
|
Test.startTest();
|
Integer year = date.today().year();
|
Integer month = date.today().month();
|
Integer days = date.today().day();
|
Map<String, Object> contactMap1 = new Map<String, Object>();
|
contactMap1.put('AccountId', hpId);
|
// contactMap1.put('FirstName', '責任者');
|
contactMap1.put('LastName', 'test1经销商');
|
|
// 将Map转换为JSON格式的字符串
|
String contactJSON = JSON.serialize(contactMap1);
|
LwcDailyReportController.saveContact(contactJSON);
|
|
|
RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
|
|
Account acc1 = new Account();
|
acc1.RecordTypeId = rectCo.Id;
|
acc1.Name = 'HP test2';
|
acc1.Is_Active__c = '草案中';
|
acc1.Is_upload_file__c = true;
|
insert acc1;
|
String visit='';
|
String visitAim='';
|
String purposeType1='';
|
String purposeType2='';
|
String purposeType3='';
|
String contactId1='';
|
String contactId2='';
|
String contactId3='';
|
String accountId='';
|
String relatedOpportunity1='';
|
String relatedOpportunity2='';
|
String relatedOpportunity3='';
|
String relatedService1=mccId;
|
String infrastructureProject1='';
|
String infrastructureProject2='';
|
String reportJsonStr=null;
|
String eventJsonStr=null;
|
Daily_Report__c dr1 =[select id from Daily_Report__c limit 1];
|
|
|
Map<String, Object> reportMap1 = new Map<String, Object>();
|
reportMap1.put('Id',dr1.Id);
|
reportMap1.put('Reporter__c', UserInfo.getUserId());
|
reportMap1.put('Reported_Date__c', date.today());
|
reportMap1.put('Status__c', '作成中');
|
reportMap1.put('Working_Time_From__c', Datetime.newInstance(year, month,days, 0, 0, 0));
|
reportMap1.put('Working_Time_To__c', Datetime.newInstance(year, month,days, 9, 0, 0));
|
reportMap1.put('Report_Contract__c', ' FSE');
|
|
|
reportJsonStr = JSON.serialize(reportMap1);
|
Event__c event = new Event__c();
|
event.ActivityDate__c = date.today();
|
event.Daily_Report__c = dr1.Id;
|
event.StartDateTime__c = Datetime.newInstance(year, month,days, 10, 0, 0);
|
event.EndDateTime__c = Datetime.newInstance(year, month,days, 11, 0, 0);
|
event.whatid__c = camId;
|
|
insert event;
|
|
Map<String, Object> eventcMap1 = new Map<String, Object>();
|
eventcMap1.put('ActivityDate__c', date.today());
|
eventcMap1.put('StartDateTime__c', Datetime.newInstance(year, month,days, 10, 0, 0));
|
eventcMap1.put('EndDateTime__c', Datetime.newInstance(year, month,days, 11, 0, 0));
|
eventcMap1.put('whatid__c', camId);
|
eventcMap1.put('Daily_Report__c', dr1.Id);
|
|
eventcMap1.put('Activity_Type2__c', '社外イベン');
|
eventcMap1.put('Visitor1_ID__c', depId);
|
// eventcMap1.put('Visitor2_ID__c', contact3Id);
|
// eventcMap1.put('Visitor3_ID__c', contact4Id);
|
eventcMap1.put('Related_Opportunity1_ID__c', opp1Id);
|
eventcMap1.put('Related_Opportunity2_ID__c', opp2Id);
|
eventcMap1.put('Related_Opportunity3_ID__c', opp3Id);
|
eventcMap1.put('Related_Service1_ID__c', mccId);
|
// eventcMap1.put('Related_Service2_ID__c', contact3Id);
|
eventcMap1.put('Id', '');
|
eventcMap1.put('Report_Contract_Type__c', '线上(微信、邮件)');
|
eventcMap1.put('relatedService1', mccId);
|
|
|
task__c t1 = new task__c();
|
t1.Name = 'test1';
|
t1.taskDifferent__c = '主动任务';
|
t1.taskStatus__c = '02 接受';
|
t1.assignee__c = Userinfo.getUserId();
|
t1.Event__c = event.Id;
|
t1.Daily_Report__c = dr1.Id;
|
t1.Activity_Date__c = Date.newInstance(year, month,days);
|
insert t1;
|
List<task__c> tasks = [select Id from task__c limit 1];
|
if(tasks.size()>0) {
|
eventcMap1.put('taskId__c', tasks[0].Id);
|
}
|
|
|
eventJsonStr = JSON.serialize(eventcMap1);
|
|
LwcDailyReportController.saveActivity( eventJsonStr,9,0,18,
|
0, visit, visitAim,
|
purposeType1, purposeType2, purposeType3,
|
contactId1, contactId2, contactId3,
|
accountId, reportJsonStr,1,0,2,0
|
, relatedOpportunity1, relatedOpportunity2, relatedOpportunity3, relatedService1
|
, infrastructureProject1, infrastructureProject2
|
);
|
List<Map<String, Object>> eventcsList = new List<Map<String, Object>>();
|
eventcsList.add(eventcMap1);
|
String eventsJsonStr = JSON.serialize(eventcsList);
|
LwcDailyReportController.saveAllData( eventsJsonStr, reportJsonStr, 1, 0,2,0, dr1.Id );
|
|
Test.stopTest();
|
}
|
}
|
@isTest
|
public static void test_saveActivity04() {
|
User user1 = getUser1();
|
System.runAs(user1) {
|
setup();
|
Test.startTest();
|
Integer year = date.today().year();
|
Integer month = date.today().month();
|
Integer days = date.today().day();
|
Map<String, Object> contactMap1 = new Map<String, Object>();
|
contactMap1.put('AccountId', hpId);
|
// contactMap1.put('FirstName', '責任者');
|
contactMap1.put('LastName', 'test1经销商');
|
|
// 将Map转换为JSON格式的字符串
|
String contactJSON = JSON.serialize(contactMap1);
|
LwcDailyReportController.saveContact(contactJSON);
|
|
|
RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
|
|
Account acc1 = new Account();
|
acc1.RecordTypeId = rectCo.Id;
|
acc1.Name = 'HP test2';
|
acc1.Is_Active__c = '草案中';
|
acc1.Is_upload_file__c = true;
|
insert acc1;
|
String visit='';
|
String visitAim='';
|
String purposeType1='';
|
String purposeType2='';
|
String purposeType3='';
|
String contactId1='';
|
String contactId2='';
|
String contactId3='';
|
String accountId='';
|
String relatedOpportunity1='';
|
String relatedOpportunity2='';
|
String relatedOpportunity3='';
|
String relatedService1=mccId;
|
String infrastructureProject1='';
|
String infrastructureProject2='';
|
String reportJsonStr=null;
|
String eventJsonStr=null;
|
Daily_Report__c dr1 =[select id from Daily_Report__c limit 1];
|
|
|
Map<String, Object> reportMap1 = new Map<String, Object>();
|
reportMap1.put('Id',dr1.Id);
|
reportMap1.put('Reporter__c', UserInfo.getUserId());
|
reportMap1.put('Reported_Date__c', date.today());
|
reportMap1.put('Status__c', '作成中');
|
reportMap1.put('Working_Time_From__c', Datetime.newInstance(year, month,days, 0, 0, 0));
|
reportMap1.put('Working_Time_To__c', Datetime.newInstance(year, month,days, 9, 0, 0));
|
reportMap1.put('Report_Contract__c', ' FSE');
|
|
|
reportJsonStr = JSON.serialize(reportMap1);
|
Event__c event = new Event__c();
|
event.ActivityDate__c = date.today();
|
event.Daily_Report__c = dr1.Id;
|
event.StartDateTime__c = Datetime.newInstance(year, month,days, 10, 0, 0);
|
event.EndDateTime__c = Datetime.newInstance(year, month,days, 11, 0, 0);
|
event.whatid__c = camId;
|
|
insert event;
|
|
Map<String, Object> eventcMap1 = new Map<String, Object>();
|
eventcMap1.put('ActivityDate__c', '');
|
eventcMap1.put('StartDateTime__c', Datetime.newInstance(year, month,days, 10, 0, 0));
|
eventcMap1.put('EndDateTime__c', Datetime.newInstance(year, month,days, 11, 0, 0));
|
eventcMap1.put('whatid__c', camId);
|
eventcMap1.put('Daily_Report__c', dr1.Id);
|
eventcMap1.put('Activity_Type2__c', '社外イベント');
|
|
eventcMap1.put('Visitor1_ID__c', contact2Id);
|
// eventcMap1.put('Visitor2_ID__c', contact3Id);
|
// eventcMap1.put('Visitor3_ID__c', contact4Id);
|
eventcMap1.put('Related_Opportunity1_ID__c', opp1Id);
|
eventcMap1.put('Related_Opportunity2_ID__c', opp2Id);
|
eventcMap1.put('Related_Opportunity3_ID__c', opp3Id);
|
eventcMap1.put('Related_Service1_ID__c', mccId);
|
// eventcMap1.put('Related_Service2_ID__c', contact3Id);
|
|
|
|
eventcMap1.put('Id', event.Id);
|
eventcMap1.put('Report_Contract_Type__c', '线上(微信、邮件)');
|
eventcMap1.put('relatedService1', mccId);
|
|
|
task__c t1 = new task__c();
|
t1.Name = 'test1';
|
t1.taskDifferent__c = '主动任务';
|
t1.taskStatus__c = '02 接受';
|
t1.assignee__c = Userinfo.getUserId();
|
t1.Event__c = event.Id;
|
t1.Daily_Report__c = dr1.Id;
|
t1.Activity_Date__c = Date.newInstance(year, month,days);
|
insert t1;
|
List<task__c> tasks = [select Id from task__c limit 1];
|
if(tasks.size()>0) {
|
eventcMap1.put('taskId__c', tasks[0].Id);
|
}
|
|
|
eventJsonStr = JSON.serialize(eventcMap1);
|
|
LwcDailyReportController.saveActivity( eventJsonStr,9,0,18,
|
0, visit, visitAim,
|
purposeType1, purposeType2, purposeType3,
|
contactId1, contactId2, contactId3,
|
accountId, reportJsonStr,1,0,2,0
|
, relatedOpportunity1, relatedOpportunity2, relatedOpportunity3, relatedService1
|
, infrastructureProject1, infrastructureProject2
|
);
|
List<Map<String, Object>> eventcsList = new List<Map<String, Object>>();
|
eventcsList.add(eventcMap1);
|
String eventsJsonStr = JSON.serialize(eventcsList);
|
LwcDailyReportController.saveAllData( eventsJsonStr, reportJsonStr, 1, 0,2,0, dr1.Id );
|
|
Test.stopTest();
|
}
|
}
|
|
@isTest
|
public static void test_saveActivity05() {
|
User user1 = getUser1();
|
System.runAs(user1) {
|
initData();
|
Test.startTest();
|
Integer year = date.today().year();
|
Integer month = date.today().month();
|
Integer days = date.today().day();
|
Map<String, Object> contactMap1 = new Map<String, Object>();
|
contactMap1.put('AccountId', hpId);
|
// contactMap1.put('FirstName', '責任者');
|
contactMap1.put('LastName', 'test1经销商');
|
|
// 将Map转换为JSON格式的字符串
|
String contactJSON = JSON.serialize(contactMap1);
|
LwcDailyReportController.saveContact(contactJSON);
|
|
|
RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
|
|
Account acc1 = new Account();
|
acc1.RecordTypeId = rectCo.Id;
|
acc1.Name = 'HP test2';
|
acc1.Is_Active__c = '草案中';
|
acc1.Is_upload_file__c = true;
|
insert acc1;
|
String visit='';
|
String visitAim='';
|
String purposeType1='';
|
String purposeType2='';
|
String purposeType3='';
|
String contactId1='';
|
String contactId2='';
|
String contactId3='';
|
String accountId='';
|
String relatedOpportunity1='';
|
String relatedOpportunity2='';
|
String relatedOpportunity3='';
|
String relatedService1=mccId;
|
String infrastructureProject1='';
|
String infrastructureProject2='';
|
String reportJsonStr=null;
|
String eventJsonStr=null;
|
Daily_Report__c dr1 =[select id from Daily_Report__c limit 1];
|
|
|
Map<String, Object> reportMap1 = new Map<String, Object>();
|
reportMap1.put('Id',dr1.Id);
|
reportMap1.put('Reporter__c', UserInfo.getUserId());
|
reportMap1.put('Reported_Date__c', date.today());
|
reportMap1.put('Status__c', '作成中');
|
reportMap1.put('Working_Time_From__c', Datetime.newInstance(year, month,days, 0, 0, 0));
|
reportMap1.put('Working_Time_To__c', Datetime.newInstance(year, month,days, 9, 0, 0));
|
reportMap1.put('Report_Contract__c', ' FSE');
|
|
|
reportJsonStr = JSON.serialize(reportMap1);
|
Event__c event = new Event__c();
|
event.ActivityDate__c = date.today();
|
event.Daily_Report__c = dr1.Id;
|
event.StartDateTime__c = Datetime.newInstance(year, month,days, 10, 0, 0);
|
event.EndDateTime__c = Datetime.newInstance(year, month,days, 11, 0, 0);
|
event.whatid__c = camId;
|
|
insert event;
|
|
Map<String, Object> eventcMap1 = new Map<String, Object>();
|
eventcMap1.put('ActivityDate__c', date.today());
|
eventcMap1.put('StartDateTime__c', Datetime.newInstance(year, month,days, 10, 0, 0));
|
eventcMap1.put('EndDateTime__c', Datetime.newInstance(year, month,days, 11, 0, 0));
|
// eventcMap1.put('whatid__c', '0011000000VATIUAA5');
|
eventcMap1.put('Daily_Report__c', dr1.Id);
|
eventcMap1.put('Visitor1_ID__c', contact2Id);
|
eventcMap1.put('Visitor2_ID__c', contact3Id);
|
eventcMap1.put('Visitor3_ID__c', contact4Id);
|
eventcMap1.put('Related_Opportunity1_ID__c', opp1Id);
|
eventcMap1.put('Related_Opportunity2_ID__c', opp2Id);
|
eventcMap1.put('Related_Opportunity3_ID__c', opp3Id);
|
eventcMap1.put('Related_Service1_ID__c', mccId);
|
// eventcMap1.put('Related_Service2_ID__c', 'a0H1000001CeHJx');
|
eventcMap1.put('Id', event.Id);
|
eventcMap1.put('Report_Contract_Type__c', '线上(微信、邮件)');
|
eventcMap1.put('relatedService1', mccId);
|
eventcMap1.put('Report_Contract__c', ' FSE');
|
// eventcMap1.put('Report_Contract_Type__c', ' FSE');
|
|
task__c t1 = new task__c();
|
t1.Name = 'test1';
|
t1.taskDifferent__c = '主动任务';
|
t1.taskStatus__c = '02 接受';
|
t1.assignee__c = Userinfo.getUserId();
|
t1.Event__c = event.Id;
|
t1.Daily_Report__c = dr1.Id;
|
t1.Activity_Date__c = Date.newInstance(year, month,days);
|
insert t1;
|
List<task__c> tasks = [select Id from task__c limit 1];
|
if(tasks.size()>0) {
|
eventcMap1.put('taskId__c', tasks[0].Id);
|
}
|
|
|
eventJsonStr = JSON.serialize(eventcMap1);
|
|
LwcDailyReportController.saveActivity( eventJsonStr,9,0,18,
|
0, visit, visitAim,
|
purposeType1, purposeType2, purposeType3,
|
contactId1, contactId2, contactId3,
|
accountId, reportJsonStr,1,0,2,0
|
, relatedOpportunity1, relatedOpportunity2, relatedOpportunity3, relatedService1
|
, infrastructureProject1, infrastructureProject2
|
);
|
List<Map<String, Object>> eventcsList = new List<Map<String, Object>>();
|
eventcsList.add(eventcMap1);
|
String eventsJsonStr = JSON.serialize(eventcsList);
|
LwcDailyReportController.saveAllData( eventsJsonStr, reportJsonStr, 1, 0,2,0, dr1.Id );
|
|
Test.stopTest();
|
}
|
}
|
@isTest
|
public static void test_saveActivity06() {
|
User user1 = getUser1();
|
System.runAs(user1) {
|
initData();
|
Test.startTest();
|
Integer year = date.today().year();
|
Integer month = date.today().month();
|
Integer days = date.today().day();
|
Map<String, Object> contactMap1 = new Map<String, Object>();
|
contactMap1.put('AccountId', hpId);
|
// contactMap1.put('FirstName', '責任者');
|
contactMap1.put('LastName', 'test1经销商');
|
|
// 将Map转换为JSON格式的字符串
|
String contactJSON = JSON.serialize(contactMap1);
|
LwcDailyReportController.saveContact(contactJSON);
|
|
|
RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
|
|
Account acc1 = new Account();
|
acc1.RecordTypeId = rectCo.Id;
|
acc1.Name = 'HP test2';
|
acc1.Is_Active__c = '草案中';
|
acc1.Is_upload_file__c = true;
|
insert acc1;
|
String visit='';
|
String visitAim='';
|
String purposeType1='';
|
String purposeType2='';
|
String purposeType3='';
|
String contactId1='';
|
String contactId2='';
|
String contactId3='';
|
String accountId='';
|
String relatedOpportunity1='';
|
String relatedOpportunity2='';
|
String relatedOpportunity3='';
|
String relatedService1=mccId;
|
String infrastructureProject1='';
|
String infrastructureProject2='';
|
String reportJsonStr=null;
|
String eventJsonStr=null;
|
Daily_Report__c dr1 =[select id from Daily_Report__c limit 1];
|
|
|
Map<String, Object> reportMap1 = new Map<String, Object>();
|
reportMap1.put('Id',dr1.Id);
|
reportMap1.put('Reporter__c', UserInfo.getUserId());
|
reportMap1.put('Reported_Date__c', date.today());
|
reportMap1.put('Status__c', '作成中');
|
reportMap1.put('Working_Time_From__c', Datetime.newInstance(year, month,days, 0, 0, 0));
|
reportMap1.put('Working_Time_To__c', Datetime.newInstance(year, month,days, 9, 0, 0));
|
reportMap1.put('Report_Contract__c', ' FSE');
|
|
|
reportJsonStr = JSON.serialize(reportMap1);
|
Event__c event = new Event__c();
|
event.ActivityDate__c = date.today();
|
event.Daily_Report__c = dr1.Id;
|
event.StartDateTime__c = Datetime.newInstance(year, month,days, 10, 0, 0);
|
event.EndDateTime__c = Datetime.newInstance(year, month,days, 11, 0, 0);
|
event.whatid__c = camId;
|
|
insert event;
|
|
Map<String, Object> eventcMap1 = new Map<String, Object>();
|
eventcMap1.put('ActivityDate__c', date.today());
|
eventcMap1.put('StartDateTime__c', Datetime.newInstance(year, month,days, 10, 0, 0));
|
eventcMap1.put('EndDateTime__c', Datetime.newInstance(year, month,days, 11, 0, 0));
|
// eventcMap1.put('whatid__c', '0011000000VATIUAA5');
|
eventcMap1.put('Daily_Report__c', dr1.Id);
|
eventcMap1.put('Visitor1_ID__c', contact2Id);
|
eventcMap1.put('Visitor2_ID__c', contact3Id);
|
eventcMap1.put('Visitor3_ID__c', contact4Id);
|
eventcMap1.put('Related_Opportunity1_ID__c', opp1Id);
|
eventcMap1.put('Related_Opportunity2_ID__c', opp2Id);
|
eventcMap1.put('Related_Opportunity3_ID__c', opp3Id);
|
eventcMap1.put('Related_Service1_ID__c', mccId);
|
// eventcMap1.put('Related_Service2_ID__c', 'a0H1000001CeHJx');
|
eventcMap1.put('Id', '');
|
eventcMap1.put('Report_Contract_Type__c', '线上(微信、邮件)');
|
eventcMap1.put('relatedService1', mccId);
|
eventcMap1.put('Report_Contract__c', ' FSE');
|
// eventcMap1.put('Report_Contract_Type__c', ' FSE');
|
|
task__c t1 = new task__c();
|
t1.Name = 'test1';
|
t1.taskDifferent__c = '主动任务';
|
t1.taskStatus__c = '02 接受';
|
t1.assignee__c = Userinfo.getUserId();
|
t1.Event__c = event.Id;
|
t1.Daily_Report__c = dr1.Id;
|
t1.Activity_Date__c = Date.newInstance(year, month,days);
|
insert t1;
|
List<task__c> tasks = [select Id from task__c limit 1];
|
if(tasks.size()>0) {
|
eventcMap1.put('taskId__c', tasks[0].Id);
|
}
|
|
|
eventJsonStr = JSON.serialize(eventcMap1);
|
|
LwcDailyReportController.saveActivity( eventJsonStr,9,0,18,
|
0, visit, visitAim,
|
purposeType1, purposeType2, purposeType3,
|
contactId1, contactId2, contactId3,
|
accountId, reportJsonStr,1,0,2,0
|
, relatedOpportunity1, relatedOpportunity2, relatedOpportunity3, relatedService1
|
, infrastructureProject1, infrastructureProject2
|
);
|
List<Map<String, Object>> eventcsList = new List<Map<String, Object>>();
|
eventcsList.add(eventcMap1);
|
String eventsJsonStr = JSON.serialize(eventcsList);
|
LwcDailyReportController.saveAllData( eventsJsonStr, reportJsonStr, 1, 0,2,0, dr1.Id );
|
|
Test.stopTest();
|
}
|
}
|
|
|
|
|
|
public static void setup11() {
|
Oly_TriggerHandler.bypass('ContactTrigger');
|
Oly_TriggerHandler.bypass('ContactTriggerHandler');
|
ControllerUtil.EscapeNFM001Trigger = true;
|
StaticParameter.EscapeNFM001Trigger = true;
|
StaticParameter.EscapeAccountTrigger = true;
|
StaticParameter.EscapeNFM001AgencyContractTrigger = true;
|
Oly_TriggerHandler.bypass(Product2Handler.Class.getName());
|
Oly_TriggerHandler.bypass(AssetHandler.Class.getName());
|
Oly_TriggerHandler.bypass(FixtureSetHandler.Class.getName());
|
Oly_TriggerHandler.bypass(RentalApplyTriggerHandler.Class.getName());
|
Oly_TriggerHandler.bypass(RentalApplyEquipmentSetHandler.Class.getName());
|
Oly_TriggerHandler.bypass(RentalApplyEquipmentSetDetailHandler.Class.getName());
|
Oly_TriggerHandler.bypass(ContactTriggerHandler.Class.getName());
|
Oly_TriggerHandler.bypass('AssetTrigger');
|
Oly_TriggerHandler.bypass('MaintenanceContractTrigger');
|
Oly_TriggerHandler.bypass('MaintenanceContractAfterUpdate');
|
Oly_TriggerHandler.bypass('MaintenanceContractBeforeDelete');
|
Oly_TriggerHandler.bypass('MaintenanceContractHpDeptUpd');
|
Oly_TriggerHandler.bypass('NFM106Controller');
|
Oly_TriggerHandler.bypass('NFM101Controller');
|
Oly_TriggerHandler.bypass('AgencyOpportunityHandler');
|
Oly_TriggerHandler.bypass('NFM001AgencyContract');
|
Oly_TriggerHandler.bypass('XinEventC2Event');
|
Oly_TriggerHandler.bypass('DailyReportSetHospitalCount');
|
Oly_TriggerHandler.bypass('AgencyHospitalHandler');
|
Oly_TriggerHandler.bypass('ContactTriggerHandler');
|
Oly_TriggerHandler.bypass('Oly_TriggerHandler');
|
Oly_TriggerHandler.bypass('PIHelper');
|
Oly_TriggerHandler.bypass('DailyReportLink2OlympusCalendar');
|
User user2 = getUser2();
|
System.runAs(user2) {
|
// 省
|
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;
|
|
|
|
// OLY_OCM-644
|
StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
|
|
//Account 经销商 recordtypeID
|
Id AgencyRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
|
|
//Account 医院 recordtypeID
|
Id HPRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
|
|
|
Account AccountHP = new Account(Name = 't_e_s_tHP001', AgentCode_Ext__c = '9999900', RecordTypeId = HPRecordTypeId,
|
Is_Active__c = '有効', Attribute_Type__c = '卫生部', Speciality_Type__c = '综合医院',
|
Grade__c = '一级', OCM_Category__c = 'SLTV', Is_Medical__c = '医疗机构',
|
State_Master__c = al.Id, City_Master__c = al2.Id, Town__c = '东京');
|
insert AccountHP;
|
|
Account AccountAgent1 = new Account(Name = 't_e_s_tAgent001', RecordTypeId = AgencyRecordTypeId);
|
insert AccountAgent1;
|
|
Account AccountAgent2 = new Account(Name = 't_e_s_tAgent002', RecordTypeId = AgencyRecordTypeId, ParentId = AccountHP.Id);
|
insert AccountAgent2;
|
|
|
|
|
// 病院を作る
|
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;
|
hpId = AccountHP.Id;
|
|
// 戦略科室を得る
|
Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :AccountHP.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
|
// 診療科を作る
|
Account dep = new Account();
|
dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
|
dep.Name = 'test dep';
|
dep.AgentCode_Ext__c = '9999998';
|
dep.ParentId = strategicDep[0].Id;
|
dep.Department_Class__c = strategicDep[0].Id;
|
dep.Hospital__c = AccountHP.Id;
|
insert dep;
|
depCId = strategicDep[0].Id;
|
depId = dep.Id;
|
|
List<RecordType> rectCop = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectCop.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
Integer year = date.today().year();
|
Integer month = date.today().month();
|
Integer days = date.today().day();
|
OlympusCalendar__c oc = new OlympusCalendar__c();
|
oc.Date__c = System.Today();
|
oc.Before_1_WorkDay__c = oc.Date__c.addDays(-1);
|
insert oc;
|
List<Daily_Report__c> drList = new List<Daily_Report__c>();
|
Daily_Report__c dr1 = new Daily_Report__c();
|
dr1.Reporter__c = UserInfo.getUserId();
|
dr1.Reported_Date__c = date.today().addDays(0);
|
dr1.Working_Time_From__c = Datetime.newInstance(year, month,days, 0, 0, 0);
|
dr1.Working_Time_To__c = Datetime.newInstance(year, month,days, 9, 0, 0);
|
dr1.Status__c = '作成中';
|
drList.add(dr1);
|
|
insert drList;
|
drId=drList[0].id;
|
|
List<Event__c> ecL=new List<Event__c>();
|
Event__c event = new Event__c();
|
event.ActivityDate__c = date.today();
|
event.Daily_Report__c = dr1.Id;
|
event.StartDateTime__c = Datetime.newInstance(year, month,days, 10, 0, 0);
|
event.EndDateTime__c = Datetime.newInstance(year, month,days, 11, 0, 0);
|
event.whatid__c = depId;
|
event.Account_ID__c = depId;
|
event.Activity_PurposeEscFSE__c ='耗材推进';
|
event.Activity_Type2__c = '病院';
|
event.Purpose_TypeEscFSE__c = 'PR活动';
|
event.etapp_third_category__c = 'ESD';
|
event.etapp_forth_category__c = 'IT系粘膜切开刀';
|
|
// event.Purpose_TypeEscFSE2__c = 'PR活动';
|
// event.etapp_third_category2__c = 'ESD';
|
// event.etapp_forth_category2__c = 'IT系粘膜切开刀';
|
|
// event.Purpose_TypeEscFSE3__c = 'PR活动';
|
// event.etapp_third_category3__c = 'ESD';
|
// event.etapp_forth_category3__c = 'IT系粘膜切开刀';
|
|
|
// Event__c event2 = new Event__c();
|
// event2.ActivityDate__c = date.today();
|
// event2.Daily_Report__c = dr1.Id;
|
// event2.StartDateTime__c = Datetime.newInstance(year, month,days, 10, 0, 0);
|
// event2.EndDateTime__c = Datetime.newInstance(year, month,days, 11, 0, 0);
|
// event2.whatid__c = depId;
|
// event2.Account_ID__c = depId;
|
// event2.Purpose_TypeEscFSE__c = '有购买意向';
|
// event2.etapp_third_category__c = 'ESD';
|
// event2.etapp_forth_category__c = 'IT系粘膜切开刀';
|
// event2.Purpose_TypeEscFSE2__c = '有购买意向';
|
// event2.etapp_third_category2__c = 'ESD';
|
// event2.etapp_forth_category2__c = 'IT系粘膜切开刀';
|
// event2.Purpose_TypeEscFSE3__c = '有购买意向';
|
// event2.etapp_third_category3__c = 'ESD';
|
// event2.etapp_forth_category3__c = 'IT系粘膜切开刀';
|
|
|
// Event__c event3 = new Event__c();
|
// event3.ActivityDate__c = date.today();
|
// event3.Daily_Report__c = dr1.Id;
|
// event3.StartDateTime__c = Datetime.newInstance(year, month,days, 10, 0, 0);
|
// event3.EndDateTime__c = Datetime.newInstance(year, month,days, 11, 0, 0);
|
// event3.whatid__c = depId;
|
// event3.Account_ID__c = depId;
|
// event3.Purpose_TypeEscFSE__c = '科室申请';
|
// event3.etapp_third_category__c = 'ESD';
|
// event3.etapp_forth_category__c = 'IT系粘膜切开刀';
|
|
// event3.Purpose_TypeEscFSE2__c = '入院申请';
|
// event3.etapp_third_category2__c = 'ESD';
|
// event3.etapp_forth_category2__c = 'IT系粘膜切开刀';
|
|
// event3.Purpose_TypeEscFSE3__c = '入院申请';
|
// event3.etapp_third_category3__c = 'ESD';
|
// event3.etapp_forth_category3__c = 'IT系粘膜切开刀';
|
|
|
ecL.add(event);
|
// ecL.add(event2);
|
// ecL.add(event3);
|
insert ecL;
|
eventc1Id=event.Id;
|
etappEventList = ecL;
|
// etappEventList.add(event2);
|
// etappEventList.add(event3);
|
|
|
|
Product2 prod01 = new Product2(
|
Name = 'Test01',
|
ProductCode = 'Test01',
|
Asset_Model_No__c = 'Test01',
|
SFDA_Status__c = '有効',
|
Dealer_special_Object__c = true,
|
Family = 'ET',
|
Category2__c = '耗材',
|
Category3__c = 'ERCP',
|
Category4__c = '导丝',
|
Category5__c = 'Visiglide35'
|
);
|
Product2 prod02 = new Product2(
|
Name = 'T_est002',
|
ProductCode = 'T_estCode002',
|
Category2__c = '耗材',
|
Category3__c = 'ERCP',
|
Category4__c = '导丝',
|
Category5__c = 'Visiglide35',
|
Family = 'ET',
|
Packing_list_manual__c = 1,
|
Asset_Model_No__c = 'T_est02',
|
SFDA_Status__c = '有効',
|
Dealer_special_Object__c = true
|
);
|
|
|
|
Product2 [] pd2s = new List<Product2>{
|
prod01, prod02
|
};
|
insert pd2s;
|
|
List<Product2__c> prod2cs = new List<Product2__c>();
|
for(Product2 p: pd2s) {
|
Product2__c pdc = new Product2__c(
|
Name=p.Name,
|
OT_CODE_Text__c=p.ProductCode,
|
Product2__c = p.Id
|
);
|
prod2cs.add(pdc);
|
}
|
insert prod2cs;
|
|
Date td = Date.today();
|
String OCSM_Period = '';
|
if(td.month() >= 1 && td.month() <= 3){
|
OCSM_Period = 'FY'+(td.year());
|
}else{
|
OCSM_Period = 'FY'+(td.year()+1);
|
}
|
|
|
//产品得分表
|
// ET_Product_ScoreTable_Batch bat = new ET_Product_ScoreTable_Batch();
|
// Database.executeBatch(bat);
|
Product_Score_Table__c [] pstList = new List<Product_Score_Table__c>();
|
Product_Score_Table__c pst01 = new Product_Score_Table__c(
|
OCM_Term__c = OCSM_Period,
|
Plan_Category3__c = 'ESD',
|
Category3__c = 'ESD',
|
Category4__c = 'IT系粘膜切开刀');
|
pstList.add(pst01);
|
|
// Product_Score_Table__c pst02 = new Product_Score_Table__c(
|
// OCM_Term__c = 'FY2024',
|
// Plan_Category3__c = 'Capsule',
|
// Category3__c = 'Capsule',
|
// Category4__c = 'CP打印机'
|
// );
|
// pstList.add(pst02);
|
|
// Product_Score_Table__c pst03 = new Product_Score_Table__c(
|
// OCM_Term__c = 'FY2024',
|
// Plan_Category3__c = 'Capsule',
|
// Category3__c = '基幹',
|
// Category4__c = '清洗刷'
|
// );
|
// pstList.add(pst03);
|
|
for(Product_Score_Table__c pst: pstList) {
|
pst.UniqueKey__c = pst.OCM_Term__c+':'+pst.Category3__c+':'+pst.Category4__c;
|
}
|
insert pstList;
|
|
|
Id PDCA_RecordTypeId = Schema.SObjectType.Product_Score_Table_History__c.getRecordTypeInfosByDeveloperName().get('TargetPDCA').getRecordTypeId();
|
|
//历史资料
|
|
// String term = prod01.Plan_Term__c.left(4);
|
String pdcauniqueKey = 'T:' + '2024' + ':' + month + ':' + AccountHP.Management_Code__c + ':' + AccountAgent2.Id + ':' + prod01.Category3__c + ':' + prod01.Category4__c;
|
// String pstKey = term + ':' + prod01.Category3__c + ':' + prod01.Category4__c;
|
Product_Score_Table__c pst = [SELECT Id FROM Product_Score_Table__c limit 1]; //WHERE UniqueKey__c = :pstKey
|
|
|
Product_Score_Table_History__c psth02 = new Product_Score_Table_History__c();
|
//UniqueKey__c : (151PA/151PB)计画财年:第三分类 :新4.5分类 :经销商 :医院
|
psth02.UniqueKey__c = pdcauniqueKey;
|
psth02.Hospital__c = AccountHP.Id;
|
psth02.Product_Score_Table__c = pst01.Id;
|
psth02.Sales_Amount__c = 67;
|
psth02.Shipping_date__c = Date.newInstance(Date.today().year(), Date.today().month(), 1);
|
psth02.Agency__c = AccountAgent2.Id;
|
psth02.Qty__c = 2;
|
psth02.RecordTypeId = PDCA_RecordTypeId;
|
insert psth02;
|
|
}
|
}
|
|
@isTest
|
public static void test_setEtapp() {
|
User user2 = getUser2();
|
System.runAs(user2) {
|
Oly_TriggerHandler.bypass('ContactTrigger');
|
Oly_TriggerHandler.bypass('ContactTriggerHandler');
|
ControllerUtil.EscapeNFM001Trigger = true;
|
StaticParameter.EscapeNFM001Trigger = true;
|
StaticParameter.EscapeAccountTrigger = true;
|
StaticParameter.EscapeNFM001AgencyContractTrigger = true;
|
Oly_TriggerHandler.bypass(Product2Handler.Class.getName());
|
Oly_TriggerHandler.bypass(AssetHandler.Class.getName());
|
Oly_TriggerHandler.bypass(FixtureSetHandler.Class.getName());
|
Oly_TriggerHandler.bypass(RentalApplyTriggerHandler.Class.getName());
|
Oly_TriggerHandler.bypass(RentalApplyEquipmentSetHandler.Class.getName());
|
Oly_TriggerHandler.bypass(RentalApplyEquipmentSetDetailHandler.Class.getName());
|
Oly_TriggerHandler.bypass(ContactTriggerHandler.Class.getName());
|
Oly_TriggerHandler.bypass('AssetTrigger');
|
Oly_TriggerHandler.bypass('MaintenanceContractTrigger');
|
Oly_TriggerHandler.bypass('MaintenanceContractAfterUpdate');
|
Oly_TriggerHandler.bypass('MaintenanceContractBeforeDelete');
|
Oly_TriggerHandler.bypass('MaintenanceContractHpDeptUpd');
|
Oly_TriggerHandler.bypass('NFM106Controller');
|
Oly_TriggerHandler.bypass('NFM101Controller');
|
Oly_TriggerHandler.bypass('AgencyOpportunityHandler');
|
Oly_TriggerHandler.bypass('NFM001AgencyContract');
|
Oly_TriggerHandler.bypass('XinEventC2Event');
|
Oly_TriggerHandler.bypass('DailyReportSetHospitalCount');
|
Oly_TriggerHandler.bypass('AgencyHospitalHandler');
|
Oly_TriggerHandler.bypass('ContactTriggerHandler');
|
Oly_TriggerHandler.bypass('Oly_TriggerHandler');
|
Oly_TriggerHandler.bypass('PIHelper');
|
Oly_TriggerHandler.bypass('DailyReportLink2OlympusCalendar');
|
|
/* // 省
|
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;
|
|
|
|
// OLY_OCM-644
|
StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
|
|
//Account 经销商 recordtypeID
|
Id AgencyRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
|
|
//Account 医院 recordtypeID
|
Id HPRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
|
|
|
Account AccountHP = new Account(Name = 't_e_s_tHP001', AgentCode_Ext__c = '9999900', RecordTypeId = HPRecordTypeId,
|
Is_Active__c = '有効', Attribute_Type__c = '卫生部', Speciality_Type__c = '综合医院',
|
Grade__c = '一级', OCM_Category__c = 'SLTV', Is_Medical__c = '医疗机构',
|
State_Master__c = al.Id, City_Master__c = al2.Id, Town__c = '东京');
|
insert AccountHP;
|
|
Account AccountAgent1 = new Account(Name = 't_e_s_tAgent001', RecordTypeId = AgencyRecordTypeId);
|
insert AccountAgent1;
|
|
Account AccountAgent2 = new Account(Name = 't_e_s_tAgent002', RecordTypeId = AgencyRecordTypeId, ParentId = AccountHP.Id);
|
insert AccountAgent2;
|
|
|
|
|
// 病院を作る
|
// 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;
|
hpId = AccountHP.Id;
|
|
// 戦略科室を得る
|
Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :AccountHP.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
|
// 診療科を作る
|
Account dep = new Account();
|
dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
|
dep.Name = 'test dep';
|
dep.AgentCode_Ext__c = '9999998';
|
dep.ParentId = strategicDep[0].Id;
|
dep.Department_Class__c = strategicDep[0].Id;
|
dep.Hospital__c = AccountHP.Id;
|
insert dep;
|
depCId = strategicDep[0].Id;
|
depId = dep.Id;
|
|
*/
|
|
|
|
|
|
// 省
|
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;
|
hpId = hospital.Id;
|
|
// 戦略科室を得る
|
Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
|
// 診療科を作る
|
Account dep = new Account();
|
dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
|
dep.Name = 'test dep';
|
dep.AgentCode_Ext__c = '9999998';
|
dep.ParentId = strategicDep[0].Id;
|
dep.Department_Class__c = strategicDep[0].Id;
|
dep.Hospital__c = hospital.Id;
|
insert dep;
|
depCId = strategicDep[0].Id;
|
depId = dep.Id;
|
|
|
// OLY_OCM-644
|
StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
|
|
//Account 经销商 recordtypeID
|
Id AgencyRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
|
|
//Account 医院 recordtypeID
|
Id HPRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
|
|
|
|
Account AccountAgent1 = new Account(Name = 't_e_s_tAgent001', RecordTypeId = AgencyRecordTypeId);
|
insert AccountAgent1;
|
|
Account AccountAgent2 = new Account(Name = 't_e_s_tAgent002', RecordTypeId = AgencyRecordTypeId, ParentId = hpId);
|
insert AccountAgent2;
|
|
|
List<RecordType> rectCop = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectCop.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
Integer year = date.today().year();
|
Integer month = date.today().month();
|
Integer days = date.today().day();
|
OlympusCalendar__c oc = new OlympusCalendar__c();
|
oc.Date__c = System.Today();
|
oc.Before_1_WorkDay__c = oc.Date__c.addDays(-1);
|
insert oc;
|
List<Daily_Report__c> drList = new List<Daily_Report__c>();
|
Daily_Report__c dr1 = new Daily_Report__c();
|
dr1.Reporter__c = UserInfo.getUserId();
|
dr1.Reported_Date__c = date.today().addDays(0);
|
dr1.Working_Time_From__c = Datetime.newInstance(year, month,days, 0, 0, 0);
|
dr1.Working_Time_To__c = Datetime.newInstance(year, month,days, 9, 0, 0);
|
dr1.Status__c = '作成中';
|
drList.add(dr1);
|
|
insert drList;
|
drId=drList[0].id;
|
|
List<Event__c> ecL=new List<Event__c>();
|
Event__c event = new Event__c();
|
event.ActivityDate__c = date.today();
|
event.Daily_Report__c = dr1.Id;
|
event.StartDateTime__c = Datetime.newInstance(year, month,days, 10, 0, 0);
|
event.EndDateTime__c = Datetime.newInstance(year, month,days, 11, 0, 0);
|
event.whatid__c = depId;
|
event.Account_ID__c = depId;
|
event.Activity_PurposeEscFSE__c ='耗材推进';
|
event.Activity_Type2__c = '病院';
|
event.Purpose_TypeEscFSE__c = 'PR活动';
|
event.etapp_third_category__c = 'ESD';
|
event.etapp_forth_category__c = 'IT系粘膜切开刀';
|
|
event.Purpose_TypeEscFSE2__c = 'PR活动';
|
event.etapp_third_category2__c = 'ESD';
|
event.etapp_forth_category2__c = 'IT系粘膜切开刀';
|
|
event.Purpose_TypeEscFSE3__c = 'PR活动';
|
event.etapp_third_category3__c = 'ESD';
|
event.etapp_forth_category3__c = 'IT系粘膜切开刀';
|
|
|
|
Event__c event2 = new Event__c();
|
event2.ActivityDate__c = date.today();
|
event2.Daily_Report__c = dr1.Id;
|
event2.StartDateTime__c = Datetime.newInstance(year, month,days, 10, 0, 0);
|
event2.EndDateTime__c = Datetime.newInstance(year, month,days, 11, 0, 0);
|
event2.whatid__c = depId;
|
event2.Account_ID__c = depId;
|
event2.Activity_PurposeEscFSE__c ='耗材推进';
|
event2.Activity_Type2__c = '病院';
|
event2.Purpose_TypeEscFSE__c = '有购买意向';
|
event2.etapp_third_category__c = 'ESD';
|
event2.etapp_forth_category__c = 'IT系粘膜切开刀';
|
|
event2.Purpose_TypeEscFSE2__c = '有购买意向';
|
event2.etapp_third_category2__c = 'ESD';
|
event2.etapp_forth_category2__c = 'IT系粘膜切开刀';
|
|
event2.Purpose_TypeEscFSE3__c = '有购买意向';
|
event2.etapp_third_category3__c = 'ESD';
|
event2.etapp_forth_category3__c = 'IT系粘膜切开刀';
|
|
Event__c event3 = new Event__c();
|
event3.ActivityDate__c = date.today();
|
event3.Daily_Report__c = dr1.Id;
|
event3.StartDateTime__c = Datetime.newInstance(year, month,days, 10, 0, 0);
|
event3.EndDateTime__c = Datetime.newInstance(year, month,days, 11, 0, 0);
|
event3.whatid__c = depId;
|
event3.Account_ID__c = depId;
|
event3.Activity_PurposeEscFSE__c ='耗材推进';
|
event3.Activity_Type2__c = '病院';
|
event3.Purpose_TypeEscFSE__c = '科室申请';
|
event3.etapp_third_category__c = 'ESD';
|
event3.etapp_forth_category__c = 'IT系粘膜切开刀';
|
|
event3.Purpose_TypeEscFSE2__c = '科室申请';
|
event3.etapp_third_category2__c = 'ESD';
|
event3.etapp_forth_category2__c = 'IT系粘膜切开刀';
|
|
event3.Purpose_TypeEscFSE3__c = '科室申请';
|
event3.etapp_third_category3__c = 'ESD';
|
event3.etapp_forth_category3__c = 'IT系粘膜切开刀';
|
|
|
|
|
// Event__c event2 = new Event__c();
|
// event2.ActivityDate__c = date.today();
|
// event2.Daily_Report__c = dr1.Id;
|
// event2.StartDateTime__c = Datetime.newInstance(year, month,days, 10, 0, 0);
|
// event2.EndDateTime__c = Datetime.newInstance(year, month,days, 11, 0, 0);
|
// event2.whatid__c = depId;
|
// event2.Account_ID__c = depId;
|
// event.Activity_PurposeEscFSE__c ='耗材推进';
|
// event2.Purpose_TypeEscFSE__c = '有购买意向';
|
// event2.etapp_third_category__c = 'ESD';
|
// event2.etapp_forth_category__c = 'IT系粘膜切开刀';
|
// event2.Purpose_TypeEscFSE2__c = '有购买意向';
|
// event2.etapp_third_category2__c = 'ESD';
|
// event2.etapp_forth_category2__c = 'IT系粘膜切开刀';
|
// event2.Purpose_TypeEscFSE3__c = '有购买意向';
|
// event2.etapp_third_category3__c = 'ESD';
|
// event2.etapp_forth_category3__c = 'IT系粘膜切开刀';
|
|
|
// Event__c event3 = new Event__c();
|
// event3.ActivityDate__c = date.today();
|
// event3.Daily_Report__c = dr1.Id;
|
// event3.StartDateTime__c = Datetime.newInstance(year, month,days, 10, 0, 0);
|
// event3.EndDateTime__c = Datetime.newInstance(year, month,days, 11, 0, 0);
|
// event3.whatid__c = depId;
|
// event3.Account_ID__c = depId;
|
// event.Activity_PurposeEscFSE__c ='耗材推进';
|
// event3.Purpose_TypeEscFSE__c = '科室申请';
|
// event3.etapp_third_category__c = 'ESD';
|
// event3.etapp_forth_category__c = 'IT系粘膜切开刀';
|
|
// event3.Purpose_TypeEscFSE2__c = '入院申请';
|
// event3.etapp_third_category2__c = 'ESD';
|
// event3.etapp_forth_category2__c = 'IT系粘膜切开刀';
|
|
// event3.Purpose_TypeEscFSE3__c = '入院申请';
|
// event3.etapp_third_category3__c = 'ESD';
|
// event3.etapp_forth_category3__c = 'IT系粘膜切开刀';
|
|
|
ecL.add(event);
|
ecL.add(event2);
|
ecL.add(event3);
|
insert ecL;
|
eventc1Id=event.Id;
|
etappEventList = ecL;
|
|
|
|
|
Product2 prod01 = new Product2(
|
Name = 'Test01',
|
ProductCode = 'Test01',
|
Asset_Model_No__c = 'Test01',
|
SFDA_Status__c = '有効',
|
Dealer_special_Object__c = true,
|
Family = 'ET',
|
Category2__c = '耗材',
|
Category3__c = 'ERCP',
|
Category4__c = '导丝',
|
Category5__c = 'Visiglide35'
|
);
|
Product2 prod02 = new Product2(
|
Name = 'T_est002',
|
ProductCode = 'T_estCode002',
|
Category2__c = '耗材',
|
Category3__c = 'ERCP',
|
Category4__c = '导丝',
|
Category5__c = 'Visiglide35',
|
Family = 'ET',
|
Packing_list_manual__c = 1,
|
Asset_Model_No__c = 'T_est02',
|
SFDA_Status__c = '有効',
|
Dealer_special_Object__c = true
|
);
|
|
|
|
Product2 [] pd2s = new List<Product2>{
|
prod01, prod02
|
};
|
insert pd2s;
|
|
List<Product2__c> prod2cs = new List<Product2__c>();
|
for(Product2 p: pd2s) {
|
Product2__c pdc = new Product2__c(
|
Name=p.Name,
|
OT_CODE_Text__c=p.ProductCode,
|
Product2__c = p.Id
|
);
|
prod2cs.add(pdc);
|
}
|
insert prod2cs;
|
|
Date td = Date.today();
|
String OCSM_Period = '';
|
if(td.month() >= 1 && td.month() <= 3){
|
OCSM_Period = 'FY'+(td.year());
|
}else{
|
OCSM_Period = 'FY'+(td.year()+1);
|
}
|
|
|
//产品得分表
|
// ET_Product_ScoreTable_Batch bat = new ET_Product_ScoreTable_Batch();
|
// Database.executeBatch(bat);
|
Product_Score_Table__c [] pstList = new List<Product_Score_Table__c>();
|
Product_Score_Table__c pst01 = new Product_Score_Table__c(
|
OCM_Term__c = '156P',
|
Plan_Category3__c = 'ESD',
|
Category3__c = 'ESD',
|
Category4__c = 'IT系粘膜切开刀');
|
pstList.add(pst01);
|
|
Product_Score_Table__c pst02 = new Product_Score_Table__c(
|
OCM_Term__c = '156P',
|
Plan_Category3__c = 'Capsule',
|
Category3__c = 'Capsule',
|
Category4__c = 'CP打印机'
|
);
|
pstList.add(pst02);
|
|
// Product_Score_Table__c pst03 = new Product_Score_Table__c(
|
// OCM_Term__c = 'FY2024',
|
// Plan_Category3__c = 'Capsule',
|
// Category3__c = '基幹',
|
// Category4__c = '清洗刷'
|
// );
|
// pstList.add(pst03);
|
|
for(Product_Score_Table__c pst: pstList) {
|
pst.UniqueKey__c = pst.OCM_Term__c+':'+pst.Category3__c+':'+pst.Category4__c;
|
}
|
insert pstList;
|
|
|
Id PDCA_RecordTypeId = Schema.SObjectType.Product_Score_Table_History__c.getRecordTypeInfosByDeveloperName().get('TargetPDCA').getRecordTypeId();
|
|
//历史资料
|
|
// String term = prod01.Plan_Term__c.left(4);
|
String pdcauniqueKey = 'T:' + '2024' + ':' + month + ':' + hospital.Management_Code__c + ':' + AccountAgent2.Id + ':' + prod01.Category3__c + ':' + prod01.Category4__c;
|
// String pstKey = term + ':' + prod01.Category3__c + ':' + prod01.Category4__c;
|
Product_Score_Table__c pst = [SELECT Id FROM Product_Score_Table__c limit 1]; //WHERE UniqueKey__c = :pstKey
|
|
|
Product_Score_Table_History__c psth02 = new Product_Score_Table_History__c();
|
//UniqueKey__c : (151PA/151PB)计画财年:第三分类 :新4.5分类 :经销商 :医院
|
psth02.UniqueKey__c = pdcauniqueKey;
|
psth02.Hospital__c = hpId;
|
psth02.Product_Score_Table__c = pst01.Id;
|
psth02.Sales_Amount__c = 67;
|
psth02.Shipping_date__c = Date.newInstance(Date.today().year(), Date.today().month(), 1);
|
psth02.Agency__c = AccountAgent2.Id;
|
psth02.Qty__c = 2;
|
psth02.RecordTypeId = PDCA_RecordTypeId;
|
insert psth02;
|
|
|
// setup11();
|
Test.startTest();
|
|
LwcDailyReportController.setEtApp(etappEventList,drId,'申請中');
|
LwcDailyReportController.setEtApp(etappEventList,drId,'取消申请');
|
Test.stopTest();
|
}
|
}
|
|
|
}
|