public without sharing class FixtureSetDetailHandler extends Oly_TriggerHandler { private Map newMap; private Map oldMap; private List newList; private List oldList; public FixtureSetDetailHandler() { this.newMap = (Map) Trigger.newMap; this.oldMap = (Map) Trigger.oldMap; this.newList = (List) Trigger.new; this.oldList = (List) Trigger.old; } protected override void beforeInsert() { beforeSetValue(); } protected override void beforeUpdate() { beforeSetValue(); } private void beforeSetValue() { Map fsdMap = new Map(); for (Fixture_Set_Detail__c nObj : newList) { nObj.Name_CHN_Created__c = nObj.Name_CHN__c; // 20230727 ljh 备品类型I和备品类型II放到保有设备上显示 start if(nObj.Loaner_category__c){ fsdMap.put(nObj.Fixture_Model_No_F__c.toUpperCase(),nObj); } } // 20230727 ljh 备品类型I和备品类型II放到保有设备上显示 end if(fsdMap.size() > 0){ List Product2List = [SELECT Id,Fixture_Model_No_T__c,Loaner_categoryI__c,Loaner_categoryII__c ,Product_Type__c,RentalSubject__c FROM Product2 WHERE Fixture_Model_No_T__c IN :fsdMap.keySet()]; if(Product2List.size() > 0){ Map updateMap = new Map(); for(Product2 pro:Product2List){ Product2 p2 = new Product2(); p2.Id = pro.Id; p2.Loaner_categoryI__c = fsdMap.get(pro.Fixture_Model_No_T__c.toUpperCase()).Loaner_categoryI__c; p2.Loaner_categoryII__c =fsdMap.get(pro.Fixture_Model_No_T__c.toUpperCase()).Loaner_categoryII__c; // 借用机会可视化UATbug25 zyh 20240106 start p2.Product_Type__c =fsdMap.get(pro.Fixture_Model_No_T__c.toUpperCase()).Product_Type__c; // 借用机会可视化UATbug25 zyh 20240106 end // 借用机会可视化-上线前遗留问题10 zyh 20240109 start p2.RentalSubject__c = fsdMap.get(pro.Fixture_Model_No_T__c.toUpperCase()).Is_Body__c; // 借用机会可视化-上线前遗留问题10 zyh 20240109 end // 借用机会可视化-上线前遗留问题10 zyh 20240109 start if(p2.RentalSubject__c <> true){ updateMap.put(pro.Id,p2); }else{ // 借用机会可视化-上线前遗留问题10 zyh 20240109 end if( p2.Loaner_categoryI__c == pro.Loaner_categoryI__c && p2.Loaner_categoryII__c == pro.Loaner_categoryII__c // 借用机会可视化-上线前遗留问题10 zyh 20240109 start && p2.RentalSubject__c == true && pro.RentalSubject__c == true // 借用机会可视化-上线前遗留问题10 zyh 20240109 end // 借用机会可视化UATbug25 zyh 20240106 start && (String.isBlank(p2.Product_Type__c) || (String.isNotBlank(p2.Product_Type__c) && p2.Product_Type__c == pro.Product_Type__c)) ){ // 借用机会可视化UATbug25 zyh 20240106 end continue; } updateMap.put(pro.Id,p2); } } if(updateMap.size() > 0){ update updateMap.values(); } } } // 20230727 ljh 备品类型I和备品类型II放到保有设备上显示 start } }