From ae4088132b8d18959452d0ca172f6c004e8c2c82 Mon Sep 17 00:00:00 2001 From: 涂煌豪 <tuhuanghao@prec-tech.com> Date: 星期三, 30 三月 2022 18:07:52 +0800 Subject: [PATCH] ContactTriggerHandler修改 --- force-app/main/default/classes/ContactTriggerHandler.cls | 91 ++++++++++++++++++++++----------------------- 1 files changed, 45 insertions(+), 46 deletions(-) diff --git a/force-app/main/default/classes/ContactTriggerHandler.cls b/force-app/main/default/classes/ContactTriggerHandler.cls index e8fc656..43a4497 100644 --- a/force-app/main/default/classes/ContactTriggerHandler.cls +++ b/force-app/main/default/classes/ContactTriggerHandler.cls @@ -14,17 +14,18 @@ } protected override void beforeInsert() { mobileNumberVerification(); - sendToComPlat(); } protected override void afterInsert() { syncToAgencyContact(); updateDealerNum(); + sendToComPlat(); } protected override void afterUpdate() { syncToAgencyContact(); updateDealerNum(); + sendToComPlat(); } protected override void beforeUpdate() { @@ -32,7 +33,6 @@ UpdateProcessingWork(); // 鏈嶅姟鎶�甯� 2018/12/24 end mobileNumberVerification(); - sendToComPlat(); } @@ -257,12 +257,13 @@ } } //鎵嬫満鍙峰敮涓�鏍¢獙-鍖婚櫌涓嬫柊寤哄鎴蜂汉鍛樻牎楠屼娇鐢ㄥ姞瀵嗘墜鏈哄彿,缁忛攢鍟嗕娇鐢ㄦ櫘閫氭墜鏈哄彿 thh 20220328 start - ID recordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId(); + ID DoctorRecordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Doctor').getRecordTypeId(); + ID AgencyRecordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId(); for (Contact contactnew : newList) { // 鎵嬫満鍙锋湁鍊煎苟涓旇仈绯讳汉鏈夋晥锛岃仈绯讳汉鐨勫鎴锋湁鏁堬紝杩涜鎵嬫満鍙风爜楠岃瘉 if (('鏈夋晥'.equals(contactnew.Isactive__c) || '鏈夊姽'.equals(contactnew.Isactive__c)) && ('鏈夊姽'.equals(accMap.get(contactnew.AccountId)) || '鏈夋晥'.equals(accMap.get(contactnew.AccountId)))) { - if(contactnew.RecordTypeId.equals(recordTypeId)){ + if(AgencyRecordTypeId.equals(contactnew.RecordTypeId)){ if(String.isNotBlank(contactnew.MobilePhone)){ Matcher isMobilePhone = pattern.matcher(contactnew.MobilePhone); if (isMobilePhone.matches()) { @@ -274,7 +275,7 @@ } else { contactnew.UniqueNumber__c = null; } - } else{ + } else if(DoctorRecordTypeId.equals(contactnew.RecordTypeId)){ if(String.isNotBlank(contactnew.MobilePhone_Encrypted__c)){ contactnew.UniqueNumber__c = contactnew.MobilePhone_Encrypted__c; } else { @@ -339,12 +340,10 @@ } } - - } - public static Map<Id,Id> NFM606_IdMap = new Map<Id,Id>(); + // 606鎺ュ彛璋冪敤闂淇 thh 20220330 start private void sendToComPlat() { List<Id> contactIdList = new List<Id>(); List<String> interfaceUserUpsertContact = new List<String>(); @@ -375,62 +374,62 @@ || old.ContactType__c != local.ContactType__c//浜哄憳绫诲瀷 ) { - //624璋冪敤606闂淇 thh 20220328 start - if (!local.IsFromSPO__c && !'01210000000QtkyAAC'.equals(local.RecordTypeId)) { + //鑾峰彇瀹㈡埛浜哄憳鐨勮褰曠被鍨婭D thh 20220330 start + ID InternalStaffRecordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Internal_staff').getRecordTypeId(); + ID DoctorRecordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Doctor').getRecordTypeId(); + ID AgencyRecordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId(); + //鑾峰彇瀹㈡埛浜哄憳鐨勮褰曠被鍨婭D thh 20220330 end + if (!local.IsFromSPO__c && !InternalStaffRecordTypeId.equals(local.RecordTypeId)) { + // 鍖婚櫌 瀹㈡埛浜哄憳 缁熶竴骞冲彴缂栫爜鏈夊�� 鍙戦�� PO - if ('01210000000QfWdAAK'.equals(local.RecordTypeId) && String.isNotBlank(local.UnifiedI_Contact_ID__c)) { + if (DoctorRecordTypeId.equals(local.RecordTypeId) && String.isNotBlank(local.UnifiedI_Contact_ID__c)) { if (!NFM606_IdMap.containsKey(local.Id)) { - // if(UserInfo.getProfileId().equals(System.Label.ProfileId_SystemAdmin)){ - // interfaceUserUpsertContact.add(local.Id); - // } else { - // contactIdList.add(local.Id); - // } - local.trigger606Flag__c = true; + if(UserInfo.getUserId().equals(System.Label.interfaceUserID)){ + interfaceUserUpsertContact.add(local.Id); + } else { + contactIdList.add(local.Id); + } NFM606_IdMap.put(local.Id, local.Id); } } // 缁忛攢鍟� 瀹㈡埛浜哄憳 鎵嬫満鍙风爜鏈夊�� 鍙戦�� PO - if ('01210000000QfWiAAK'.equals(local.RecordTypeId) && String.isNotBlank(local.MobilePhone)) { + if (AgencyRecordTypeId.equals(local.RecordTypeId) && String.isNotBlank(local.MobilePhone)) { if (!NFM606_IdMap.containsKey(local.Id)) { - // if(UserInfo.getProfileId().equals(System.Label.ProfileId_SystemAdmin)){ - // interfaceUserUpsertContact.add(local.Id); - // } else { - // contactIdList.add(local.Id); - // } - local.trigger606Flag__c = true; + if(UserInfo.getUserId().equals(System.Label.interfaceUserID)){ + interfaceUserUpsertContact.add(local.Id); + } else { + contactIdList.add(local.Id); + } NFM606_IdMap.put(local.Id, local.Id); } } } - //624璋冪敤606闂淇 thh 20220328 end + } } //606鏍囪 - // if(!System.Test.isRunningTest()){ - // // NFM606Controller.executeNotFuture('', contactIdList); - // //624璋冪敤606闂淇 thh 20220325 start - // if (contactIdList.size() > 0) { - // // 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(!System.Test.isRunningTest()){ + // NFM606Controller.executeNotFuture('', contactIdList); + if (contactIdList.size() > 0) { + // 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); //娣诲姞future 鍒ゆ柇 add for pipl sushanhu 20220316 start // if (!(System.isFuture()||System.isBatch())) { - // NFM606Controller.executeNotFuture('', interfaceUserUpsertContact); + // NFM606Controller.executeNotFuture('', interfaceUserUpsertContact); // } //娣诲姞future 鍒ゆ柇 add for pipl sushanhu 20220316 end - - // } - //624璋冪敤606闂淇 thh 20220325 end - // } - + } + } } + // 606鎺ュ彛璋冪敤闂淇 thh 20220330 end } \ No newline at end of file -- Gitblit v1.9.1