public without sharing class OrderListHandler extends Oly_TriggerHandler { private Map newMap; private Map oldMap; private List newList; private List oldList; public OrderListHandler() { this.newMap = (Map) Trigger.newMap; this.oldMap = (Map) Trigger.oldMap; this.newList = (List) Trigger.new; this.oldList = (List) Trigger.old; } protected override void afterInsert() { changeStaToSent(); } protected override void afterUpdate() { changeStaToSent(); } //样本订货单 状态 变为 '订单已发送' ==> 触发NFM115接口,给SAP发数据 private void changeStaToSent(){ List sOrderList = new List(); for(Sample_order_list__c orl : newList){ if(Trigger.isInsert){ if(orl.Status__c == '订单已发送'){ sOrderList.add(orl.Id); } } if(Trigger.isUpdate){ if(oldMap.get(orl.Id) != null){ Sample_order_list__c oldOrl = oldMap.get(orl.Id); if(orl.Status__c == '订单已发送' && oldOrl.Status__c != '订单已发送'){ sOrderList.add(orl.Id); } } } } if(sOrderList.size() > 0){ BatchIF_Log__c iflog = new BatchIF_Log__c(); iflog.Type__c = 'NFM115'; iflog.Log__c = 'callout start\n'; insert iflog; iflog = [Select Id, Name from BatchIF_Log__c where Id = :iflog.Id]; NFM115Controller.callout(iflog.Id, sOrderList); } } }