|  |  | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             // if (Trigger.isInsert) { | 
 |  |  |             accountIdSet.add(contactnew.AccountId);   | 
 |  |  |             if(DoctorRecordTypeId.equals(contactnew.RecordTypeId)){ | 
 |  |  |                 accountIdSet.add(contactnew.AccountId);   | 
 |  |  |             } | 
 |  |  |             // }    | 
 |  |  |         } | 
 |  |  |         //手机号唯一校验-医院下新建客户人员校验使用加密手机号,经销商使用普通手机号 thh 20220328 end | 
 |  |  |         // 新增联系人时 | 
 |  |  |         // 新增医院联系人时 | 
 |  |  |         if (accountIdSet.size() > 0) { | 
 |  |  |             List<Contact> contactList = new List<Contact>(); | 
 |  |  |             if(Test.isRunningTest()){ | 
 |  |  |             if(Trigger.isInsert){ | 
 |  |  |                 contactList = [SELECT Id,AccountId,FullName__c,LastName,FirstName,Account.Name,CManageCode__c,IsFromSPO__c, | 
 |  |  |                                                 LastName_Encrypted__c// 20220314 PI改造 by Bright | 
 |  |  |                                                 , MobilePhone_Encrypted__c // 通过姓名+手机号判断人员是否重复 thh 20220518 | 
 |  |  |                                                 FROM Contact  | 
 |  |  |                                                 WHERE IsFromSPO__c = false AND AccountId IN:accountIdSet]; | 
 |  |  |             }else{ | 
 |  |  |             } | 
 |  |  |             if(Trigger.isUpdate){ | 
 |  |  |                 contactList = [SELECT Id,AccountId,FullName__c,LastName,FirstName,Account.Name,CManageCode__c,IsFromSPO__c, | 
 |  |  |                                              LastName_Encrypted__c// 20220314 PI改造 by Bright | 
 |  |  |                                              , MobilePhone_Encrypted__c // 通过姓名+手机号判断人员是否重复 thh 20220518 | 
 |  |  | 
 |  |  |                                             WHERE IsFromSPO__c = false AND AccountId IN:accountIdSet AND Id Not IN: oldMap.keyset()]; | 
 |  |  |             } | 
 |  |  |             System.debug('contactList:' + contactList); | 
 |  |  |             if ( contactList.size() > 0) { | 
 |  |  |             if (contactList.size() > 0) { | 
 |  |  |                 for(Contact contact :contactList){ | 
 |  |  |                     // 通过姓名+手机号判断人员是否重复 thh 20220518 start | 
 |  |  |                     // String lastNameStr = String.isNotBlank(contact.LastName) ? contact.LastName:''; | 
 |  |  | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         for (Contact contactnew: newList) {  | 
 |  |  |         for (Contact contactnew: newList) { | 
 |  |  |             if(AgencyRecordTypeId.equals(contactnew.RecordTypeId) || (Trigger.isUpdate && !oldMap.isEmpty() && oldMap.get(contactnew.Id) != null  | 
 |  |  |                 && String.isBlank(oldMap.get(contactnew.Id).MobilePhone_Encrypted__c)  | 
 |  |  |                 && String.isBlank(contactnew.MobilePhone_Encrypted__c))){ | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |             String accountId = String.valueOf(contactnew.AccountId).substring(0, 15); | 
 |  |  |             if (accountContactMap.containsKey(accountId)) { | 
 |  |  |                 Map<String,Contact> contactFullNameMap =  accountContactMap.get(accountId); |