| | |
| | | campaign.StartDate__c = campaign.CeremonyDate__c == null ? |
| | | campaign.Lesson1Date__c : campaign.CeremonyDate__c; |
| | | } |
| | | // OBPM市场活动联动 add 手动绑定决裁信息时,从决裁上获取信息并写入 start |
| | | GetInfoFromAdjudication(); |
| | | // OBPM市场活动联动 add 手动绑定决裁信息时,从决裁上获取信息并写入 end |
| | | } |
| | | protected override void beforeUpdate() { |
| | | beforeDateModifyDecide(); |
| | |
| | | List<String> app_ids = new List<String>(); |
| | | List<String> cam_ids = new List<String>(); |
| | | for (Campaign cam : this.newList) { |
| | | Campaign old_cam = this.oldMap.get(cam.Id); |
| | | // 会议决裁发生变化且不为空时 |
| | | Campaign old_cam = this.oldMap != null ? this.oldMap.get(cam.Id) : new Campaign(); |
| | | // 会议决裁不为空时 |
| | | if (String.isNotBlank(cam.Meeting_Approved_No__c) && cam.Meeting_Approved_No__c != old_cam.Meeting_Approved_No__c) { |
| | | app_ids.add(cam.Meeting_Approved_No__c); |
| | | cam_ids.add(cam.Id); |
| | | if (String.isNotBlank(cam.Id)) { |
| | | cam_ids.add(cam.Id); |
| | | } |
| | | } |
| | | } |
| | | if (app_ids.size() > 0) { |
| | | List<OPDPlan__c> plans = cam_ids.size() > 0 ? [select Id, Campaign__c, IF_Approved__c, Approved_Status__c, Approved_No__c from OPDPlan__c where Campaign__c in :cam_ids] : null; |
| | | List<Application_for_Conference_Adjudication__c> apps = [select Id, |
| | | MeetingApprovedNo__c, |
| | | Num__c, |
| | | ProcessState__c, |
| | | StartDate__c, |
| | | EndDate__c, |
| | | BudgetType__c, |
| | | OfficeCategory__c, |
| | | MeetingType__c, |
| | | ActivityTypeName__c, |
| | | WorkshopPlace__c, |
| | | HostName__c, |
| | | CooperatorCompany__c, |
| | | ExpectedOlympusAttendance__c, |
| | | ExpectedHcpAttendance__c, |
| | | StateMaster__c, |
| | | CityMaster__c, |
| | | IsPaidToSponsor__c, |
| | | SponsorshipCategory__c, |
| | | ConveningParticipantsNum__c |
| | | ConveningParticipantsNum__c, |
| | | Type_of_adjudication_meeting__c |
| | | from |
| | | Application_for_Conference_Adjudication__c |
| | | where |
| | | Id in :app_ids]; |
| | | if (apps != null && apps.size() > 0) { |
| | | init_state_city(); |
| | | List<Application_for_Conference_Adjudication__c> set_cam_num_apps = new List<Application_for_Conference_Adjudication__c>(); |
| | | for (Application_for_Conference_Adjudication__c app : apps) { |
| | | for (Campaign cam : this.newList) { |
| | | if (cam.Meeting_Approved_No__c == app.Id && cam_ids.contains(cam.Id)) { |
| | | cam.MeetingApprovedNo__c = app.MeetingApprovedNo__c; |
| | | cam.Meeting_Approved_No__c = app.Id; |
| | | // 非赞助会的情况下更新以下内容 |
| | | if (app.MeetingType__c != '赞助会') { |
| | | cam.StartDate = app.StartDate__c; |
| | | cam.EndDate = app.EndDate__c; |
| | | cam.Implementation_Purpose__c = app.BudgetType__c; |
| | | cam.OfficeCategory__c = app.OfficeCategory__c; |
| | | cam.Meeting_Type__c = app.MeetingType__c; |
| | | |
| | | cam.Activity_Type_Name__c = app.ActivityTypeName__c; |
| | | cam.Expected_Olympus_Attendance__c = app.ExpectedOlympusAttendance__c; |
| | | cam.Expected_Hcp_Attendance__c = app.ExpectedHcpAttendance__c; |
| | | // 这里需要额外加操作 |
| | | cam.State_Master__c = get_state(app.StateMaster__c); |
| | | cam.City_Master__c = get_city(app.CityMaster__c); |
| | | cam.IsPaidToSponsor__c = app.IsPaidToSponsor__c; |
| | | cam.SponsorshipCategory__c = app.SponsorshipCategory__c; |
| | | cam.Convening_Participants_Num__c = app.ConveningParticipantsNum__c; |
| | | cam.WorkshopPlace__c = app.WorkshopPlace__c; |
| | | cam.HostName__c = app.HostName__c; |
| | | cam.cooperatorCompany__c = app.CooperatorCompany__c; |
| | | cam.Convening_Participants_Num__c = app.ConveningParticipantsNum__c; |
| | | |
| | | // OBPM对接 新增字段 |
| | | cam.Expected_Olympus_Attendance__c = app.ExpectedOlympusAttendance__c; |
| | | cam.Expected_Hcp_Attendance__c = app.ExpectedHcpAttendance__c; |
| | | cam.SponsorshipCategory__c = app.SponsorshipCategory__c; |
| | | cam.IsPaidToSponsor__c = app.IsPaidToSponsor__c; |
| | | // cam.Activity_Type_Name__c = app.ActivityTypeName__c; |
| | | cam.Activity_Type_Name__c = app.Type_of_adjudication_meeting__c; |
| | | // 这里需要额外加操作 |
| | | cam.State_Master__c = StateCityUtil.get_state(app.StateMaster__c); |
| | | cam.City_Master__c = StateCityUtil.get_city(app.CityMaster__c); |
| | | |
| | | if (cam.Num__c != app.Num__c) { |
| | | app.Num__c = cam.Num__c; |
| | | set_cam_num_apps.add(app); |
| | | } |
| | | } |
| | | // opd计划上的内容更新 |
| | | if (plans != null && plans.size() > 0) { |
| | | for (OPDPlan__c plan : plans) { |
| | | if (plan.Campaign__c == cam.Id) { |
| | | plan.IF_Approved__c = true; |
| | | plan.Approved_Status__c = cam.Approved_Status__c; |
| | | plan.Approved_No__c = cam.Meeting_Approved_No__c; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if (set_cam_num_apps.size() > 0) { |
| | | update set_cam_num_apps; |
| | | } |
| | | if (plans != null && plans.size() > 0) { |
| | | update plans; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 初始化省市信息 |
| | | public static void init_state_city() { |
| | | if (states == null || states.size() <= 0) { |
| | | states = new Map<String, String>(); |
| | | List<Address_Level__c> lst_state = [select Id, Name from Address_Level__c]; |
| | | for (Address_Level__c level1 : lst_state) { |
| | | states.put(level1.Name, level1.Id); |
| | | } |
| | | } |
| | | if (cities == null || cities.size() <= 0) { |
| | | cities = new Map<String, String>(); |
| | | List<Address_Level2__c> lst_city = [select Id, Name from Address_Level2__c]; |
| | | for (Address_Level2__c level2 : lst_city) { |
| | | cities.put(level2.Name, level2.Id); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 设置会议上的省 |
| | | public static String get_state(String state_name) { |
| | | if (String.isBlank(state_name)) { |
| | | return null; |
| | | } |
| | | if (states == null || states.size() <= 0) { |
| | | return null; |
| | | } |
| | | // 处理空格 或许后续还有别的处理 |
| | | state_name = state_name.trim().replace(' ', ''); |
| | | for(String state : states.keySet()) { |
| | | if (state_name.contains(state) || state.contains(state_name)) { |
| | | return states.get(state); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | // 设置会议上的市 |
| | | public static String get_city(String city_name) { |
| | | if (String.isBlank(city_name)) { |
| | | return null; |
| | | } |
| | | if (cities == null || cities.size() <= 0) { |
| | | return null; |
| | | } |
| | | // 处理空格 或许后续还有别的处理 |
| | | city_name = city_name.trim().replace(' ', ''); |
| | | for(String city : cities.keySet()) { |
| | | if (city_name.contains(city) || city.contains(city_name)) { |
| | | return cities.get(city); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | // OBPM市场活动联动 add 手动绑定决裁信息时,从决裁上获取信息并写入 end |
| | | } |