From c2f105094a6ee6bae21b16130023eabbb55914df Mon Sep 17 00:00:00 2001 From: 涂煌豪 <tuhuanghao@prec-tech.com> Date: 星期五, 25 三月 2022 17:59:45 +0800 Subject: [PATCH] 624调用606问题修复,联系人手机号排重 --- force-app/main/default/classes/ContactTriggerHandler.cls | 127 +++++++++++++++++++++++------------------- 1 files changed, 70 insertions(+), 57 deletions(-) diff --git a/force-app/main/default/classes/ContactTriggerHandler.cls b/force-app/main/default/classes/ContactTriggerHandler.cls index ad4e5ce..55901b1 100644 --- a/force-app/main/default/classes/ContactTriggerHandler.cls +++ b/force-app/main/default/classes/ContactTriggerHandler.cls @@ -20,16 +20,12 @@ syncToAgencyContact(); updateDealerNum(); sendToComPlat(); - //NFM702 - // NFM702_Handler(this.newList , this.newMap , this.oldList , this.oldMap); } protected override void afterUpdate() { syncToAgencyContact(); updateDealerNum(); sendToComPlat(); - //NFM702 - // NFM702_Handler(this.newList , this.newMap , this.oldList , this.oldMap); } protected override void beforeUpdate() { @@ -227,14 +223,43 @@ //鏇存柊缁忛攢鍟嗙敤鎴蜂汉鏁板瓧娈� 绮剧悽鎶�鏈� pk 2021-08-26 end // 鎵嬫満鍙峰幓閲嶅強瑙勫垯楠岃瘉 鍙婃柊澧炲鎴蜂汉鍛橀噸鍚嶉獙璇� - public void mobileNumberVerification(){ + public void mobileNumberVerification(){ Pattern pattern = Pattern.compile('^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$'); Map<String, Map<String,Contact>> accountContactMap = new Map<String, Map<String,Contact>>(); Set<Id> accountIdSet = new Set<Id>(); + //鐢ㄦ埛瀵硅薄涓婃壘瀵瑰簲鐨勮仈绯讳汉 + // List<User> userList=[select ID,ContactID from User where ContactID != null]; + // Map<String,User> userMap= new Map<String,User>(); + // if (userList.size()>0){ + // for(User us1: userList){ + // userMap.put(us1.ContactId, us1); + // } + // } + //鏌ユ壘鑱旂郴浜哄璞′笂瀵瑰簲鐨勬湁鏁堝鎴凤紱鍖婚櫌鐩存帴浣跨敤鏈夋晥/鏃犳晥瀛楁銆佺粡閿�鍟嗕娇鐢ㄦ湁鏁�/鏃犳晥鍏紡瀛楁 + List<String> accIdList = new List<String>(); + Map<String,String> accMap= new Map<String,String>(); + for (Contact contact1: newList) { + accIdList.add(contact1.AccountId); + } + if (accIdList.size()>0){ + List<Account> accList=[select ID,Is_Active__c,Is_Active_Formula__c from Account where ID in:accIdList]; + if(accList.size()>0){ + for(Account acc:accList){ + if (String.isNotBlank(acc.Is_Active__c)){ + accMap.put(acc.Id, acc.Is_Active__c); + continue; + } + if (String.isNotBlank(acc.Is_Active_Formula__c)){ + accMap.put(acc.Id, acc.Is_Active_Formula__c); + } + } + } + } for (Contact contactnew: newList) { - // 鎵嬫満鍙� 鏈夊�� 骞朵笖 鑱旂郴浜烘湁鏁� 杩涜鎵嬫満鍙风爜楠岃瘉 - if (String.isNotBlank(contactnew.MobilePhone) && '鏈夋晥'.equals(contactnew.Isactive__c)) { + // 鎵嬫満鍙� 鏈夊�� 骞朵笖 鑱旂郴浜烘湁鏁� 鑱旂郴浜虹殑瀹㈡埛鏈夋晥 杩涜鎵嬫満鍙风爜楠岃瘉 + if (String.isNotBlank(contactnew.MobilePhone) && ('鏈夋晥'.equals(contactnew.Isactive__c) ||'鏈夊姽'.equals(contactnew.Isactive__c)) + && '鏈夊姽'.equals(accMap.get(contactnew.AccountId))) { Matcher isMobilePhone = pattern.matcher(contactnew.MobilePhone); if (isMobilePhone.matches()) { // 灏嗘墜鏈哄彿 璧嬪�肩粰 鎵嬫満鍙峰敮涓�瀛楁 @@ -257,7 +282,8 @@ } // 鏂板鑱旂郴浜烘椂锛� if (accountIdSet.size() > 0) { - List<Contact> contactList = [SELECT Id,AccountId,FullName__c,LastName,FirstName,Account.Name,CManageCode__c,IsFromSPO__c + List<Contact> contactList = [SELECT Id,AccountId,FullName__c,LastName,FirstName,Account.Name,CManageCode__c,IsFromSPO__c, + LastName_Encrypted__c// 20220314 PI鏀归�� by Bright FROM Contact WHERE IsFromSPO__c = false AND AccountId IN:accountIdSet]; if ( contactList.size() > 0) { @@ -266,6 +292,10 @@ String lastNameStr = String.isNotBlank(contact.LastName) ? contact.LastName:''; String firstNameStr = String.isNotBlank(contact.FirstName) ? contact.FirstName:''; String contactFullName = lastNameStr + firstNameStr; + contactFullName = contact.LastName_Encrypted__c;// 20220314 PI鏀归�� by Bright + if(string.isBlank(contactFullName)){ + continue; + } String accountId = String.valueOf(contact.AccountId).SubString(0,15); Map<String,Contact> contactFullNameMap = new Map<String,Contact>(); if (accountContactMap.containsKey(accountId)) { @@ -288,7 +318,7 @@ String lastNameStr = String.isNotBlank(contactnew.LastName) ? contactnew.LastName:''; String firstNameStr = String.isNotBlank(contactnew.FirstName) ? contactnew.FirstName:''; String contactFullName = lastNameStr + firstNameStr; - + contactFullName = contactnew.LastName_Encrypted__c;// 20220314 PI鏀归�� by Bright if (contactFullNameMap.containsKey(contactFullName)) { String accountName = contactFullNameMap.get(contactFullName).Account.Name; String cManageCode = contactFullNameMap.get(contactFullName).CManageCode__c; @@ -344,22 +374,26 @@ // 鍖婚櫌 瀹㈡埛浜哄憳 缁熶竴骞冲彴缂栫爜鏈夊�� 鍙戦�� PO if ('01210000000QfWdAAK'.equals(local.RecordTypeId) && String.isNotBlank(local.UnifiedI_Contact_ID__c)) { if (!NFM606_IdMap.containsKey(local.Id)) { - if(UserInfo.getUserId().equals(System.Label.interfaceUserID)){ - interfaceUserUpsertContact.add(local.Id); - } else { + //624璋冪敤606闂淇 thh 20220325 start + // if(UserInfo.getProfileId().equals(System.Label.ProfileId_SystemAdmin)){ + // interfaceUserUpsertContact.add(local.Id); + // } else { contactIdList.add(local.Id); - } + // } + //624璋冪敤606闂淇 thh 20220325 end NFM606_IdMap.put(local.Id, local.Id); } } // 缁忛攢鍟� 瀹㈡埛浜哄憳 鎵嬫満鍙风爜鏈夊�� 鍙戦�� PO if ('01210000000QfWiAAK'.equals(local.RecordTypeId) && String.isNotBlank(local.MobilePhone)) { if (!NFM606_IdMap.containsKey(local.Id)) { - if(UserInfo.getUserId().equals(System.Label.interfaceUserID)){ - interfaceUserUpsertContact.add(local.Id); - } else { + //624璋冪敤606闂淇 thh 20220325 start + // if(UserInfo.getProfileId().equals(System.Label.ProfileId_SystemAdmin)){ + // interfaceUserUpsertContact.add(local.Id); + // } else { contactIdList.add(local.Id); - } + // } + //624璋冪敤606闂淇 thh 20220325 end NFM606_IdMap.put(local.Id, local.Id); } } @@ -370,50 +404,29 @@ if(!System.Test.isRunningTest()){ // NFM606Controller.executeNotFuture('', contactIdList); + //624璋冪敤606闂淇 thh 20220325 start if (contactIdList.size() > 0) { - NFM606Controller.callout('', contactIdList); + // NFM606Controller.callout('', contactIdList); + //娣诲姞future 鍒ゆ柇 add for pipl sushanhu 20220317 start + if (!(System.isFuture()||System.isBatch())) { + NFM606Controller.callout('', contactIdList); + } else{ + NFM606Controller.executeNotFuture('', contactIdList); + } + //娣诲姞future 鍒ゆ柇 add for pipl sushanhu 20220317 end } - if (interfaceUserUpsertContact.size() > 0) { - NFM606Controller.executeNotFuture('', interfaceUserUpsertContact); - } + // if (interfaceUserUpsertContact.size() > 0) { + // NFM606Controller.executeNotFuture('', interfaceUserUpsertContact); + //娣诲姞future 鍒ゆ柇 add for pipl sushanhu 20220316 start + // if (!(System.isFuture()||System.isBatch())) { + // NFM606Controller.executeNotFuture('', interfaceUserUpsertContact); + // } + //娣诲姞future 鍒ゆ柇 add for pipl sushanhu 20220316 end + + // } + //624璋冪敤606闂淇 thh 20220325 end } - } - - - public void NFM702_Handler(List<Contact> newList, Map<Id, Contact> newMap, List<Contact> oldList, Map<Id, Contact> oldMap){ - List<Contact> conIdList = new List<Contact>(); - List<String> idList = new List<String>(); - String LOG_TYPE = 'NFM702'; - // iflog.Log__c = '---------'; - String ConTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Doctor').getRecordTypeId(); - if (Trigger.isUpdate && Trigger.isAfter) { - if (newList.size() > 0) { - for (Contact con : newList) { - Contact oldCon = oldMap.get(con.Id); - if ((con.RecordTypeId.equals(ConTypeId)) && (con.FullName__c != oldCon.FullName__c || con.Phone != oldCon.Phone || con.Department__c != oldCon.Department__c || con.Isactive__c != oldCon.Isactive__c)) { - idList.add(con.Id); - } - } - } - } - if(Trigger.isInsert && Trigger.isAfter){ - if (newList.size() > 0) { - for (Contact con : newList) { - if(con.RecordTypeId.equals(ConTypeId)){ - idList.add(con.Id); - } - } - } - } - if (idList.size() > 0) { - BatchIF_Log__c iflog = new BatchIF_Log__c(); - iflog.Log__c = '瑙﹀彂鎴愬姛'; - iflog.Type__c = LOG_TYPE; - insert iflog; - NFM702Controller.callout(iflog.Id, idList); - } - } } \ No newline at end of file -- Gitblit v1.9.1