public without sharing class AssessmentReportHandler extends Oly_TriggerHandler { private Map newMap; private Map oldMap; private List newList; private List oldList; public AssessmentReportHandler() { this.newMap = (Map) Trigger.newMap; this.oldMap = (Map) Trigger.oldMap; this.newList = (List) Trigger.new; this.oldList = (List) Trigger.old; } protected override void afterUpdate() { SetupFinalGrade(); } //设置最终考核成绩到服务技师培训主页面上去 private void SetupFinalGrade() { System.debug( 'SetupFinalGrade start: ' ); list AssessReportlist = new list(); list updateCamlist = new list(); for (AssessmentReport__C temAR : newList) { AssessmentReport__C oldResult = oldMap.get(temAR.id); if (temAR.Status__c !=null && !oldResult.Status__c.equals('批准') && temAR.Status__c.equals('批准') && temAR.Type__c.equals('考核')) { AssessReportlist.add(temAR); if (temAR.TeachingDate__c != null && temAR.TeachingDate__c.day() >= 15) { updateCamlist.add(new Campaign(id = temAR.Campaign__c, Mailflg_6Month_service__c = 7)); } else if (temAR.TeachingDate__c != null && temAR.TeachingDate__c.day() <= 15) { updateCamlist.add(new Campaign(id = temAR.Campaign__c, Mailflg_6Month_service__c = 6)); } } } list updateCMlist = new list(); list AssessmentReportStafflist = [select id , CampaignMember__c, Grade__c from AssessmentReportStaff__c where AssessmentReport__c in: AssessReportlist and CampaignMember__c != null ]; for (AssessmentReportStaff__c temARS : AssessmentReportStafflist) { CampaignMember__c temCAM = new CampaignMember__c(id = temARS.CampaignMember__c, Grade__c = temARS.Grade__c ); updateCMlist.add(temCAM); } if (updateCMlist.size() > 0) { update updateCMlist; } if (updateCamlist.size() > 0) { update updateCamlist; } } }