public without sharing class AssetHandlerCheck extends Oly_TriggerHandler { private Map newMap; private Map oldMap; private List newList; private List oldList; private static Set rentalErrorIds = new Set(); private static Set jizhongErrorIds = new Set(); public AssetHandlerCheck() { this.newMap = (Map) Trigger.newMap; this.oldMap = (Map) Trigger.oldMap; this.newList = (List) Trigger.new; this.oldList = (List) Trigger.old; } protected override void afterInsert() { checkAsset(); } protected override void afterUpdate() { checkAsset(); } private void checkAsset() { Set ids = new Set (); for (Asset nObj : newList) { Asset oObj = null; if(oldMap != null && oldMap.containsKey(nObj.Id)) { oObj = oldMap.get(nObj.Id); } if (nObj.AssetManageConfirm__c && nObj.Account_Management_Code__c != System.Label.Account_Asset_FJZ ) { if(!jizhongErrorIds.contains(nObj.Id) && nObj.Ji_Zhong_Guan_Li_Ku_Cun__c < 0 && (oObj == null || oObj.Ji_Zhong_Guan_Li_Ku_Cun__c != nObj.Ji_Zhong_Guan_Li_Ku_Cun__c)) { ids.add(nObj.Id); jizhongErrorIds.add(nObj.Id); } if(!rentalErrorIds.contains(nObj.Id) && (nObj.Out_of_wh__c != nObj.Out_of_wh_Sys__c || nObj.Rental_Count_Sys__c != nObj.Rental_Count__c)) { ids.add(nObj.Id); rentalErrorIds.add(nObj.Id); } } } if(!ids.isEmpty()) { String idsStr = String.join(new List(ids),','); System.enqueueJob(new AssetHandlerCheckQueuable(idsStr)); } } }