From ec47f5ab5923a315bf22e0df5af7371e9668589e Mon Sep 17 00:00:00 2001
From: 张宇恒 <bxyun0@163.com>
Date: 星期五, 23 十二月 2022 11:16:18 +0800
Subject: [PATCH] 修理接口推送触发条件新加故障描述修理内容等
---
force-app/main/default/classes/ContactTriggerHandler.cls | 145 ++++++++++++++++++++++++++++++++++--------------
1 files changed, 102 insertions(+), 43 deletions(-)
diff --git a/force-app/main/default/classes/ContactTriggerHandler.cls b/force-app/main/default/classes/ContactTriggerHandler.cls
index 3885c2c..3e9f002 100644
--- a/force-app/main/default/classes/ContactTriggerHandler.cls
+++ b/force-app/main/default/classes/ContactTriggerHandler.cls
@@ -140,13 +140,41 @@
// )
)
) {
- Agency_Contact__c acObj = new Agency_Contact__c(Agency_ID__c = '000000000000000', Contact__c = nObj.Id, ContactId18__c = nObj.Id, Agency_Hospital__c = null, Name = nObj.LastName + ((String.isBlank(nObj.FirstName) == false) ? ' ' + nObj.FirstName : ''), Department_Class__c = nObj.Strategic_dept_Class__c, Type__c = nObj.Type__c, Doctor_Division1__c = nObj.Doctor_Division1__c);
+ //Agency_Contact__c acObj = new Agency_Contact__c(Agency_ID__c = '000000000000000', Contact__c = nObj.Id, ContactId18__c = nObj.Id, Agency_Hospital__c = null, Name = nObj.LastName + ((String.isBlank(nObj.FirstName) == false) ? ' ' + nObj.FirstName : ''), Department_Class__c = nObj.Strategic_dept_Class__c, Type__c = nObj.Type__c, Doctor_Division1__c = nObj.Doctor_Division1__c);
+ Agency_Contact__c acObj = new Agency_Contact__c(
+ Agency_ID__c = '000000000000000',
+ Contact__c = nObj.Id,
+ ContactId18__c = nObj.Id,
+ Agency_Hospital__c = null,
+ Name = nObj.LastName,
+ Name_Encrypted__c = nObj.LastName_Encrypted__c,
+ Department_Class__c = nObj.Strategic_dept_Class__c,
+ Type__c = nObj.Type__c,
+ Type_Encrypted__c = nObj.Type_Encrypted__c,
+ Doctor_Division1__c = nObj.Doctor_Division1__c,
+ Doctor_Division1_Encrypted__c = nObj.Doctor_Division1_Encrypted__c
+ );
targetContactMap.put(nObj.Id, acObj);
}
}
}
if (targetContactMap.size() > 0) {
- upsert targetContactMap.values() ContactId18__c;
+ List<Agency_Contact__c> temp = targetContactMap.values();
+ upsert temp ContactId18__c;
+ system.debug('temp='+temp);
+ EncryptInsert(temp);
+ }
+ }
+
+ static void EncryptInsert(List<Agency_Contact__c> aclist){
+ if(!(system.isFuture() || system.isBatch())){
+ AwsServiceTool2.EncryptPushFuture(Json.serialize(aclist), 'Agency_Contact__c');
+ }else{
+ //Add By Li Jun for sync agency contact to aws 20220424 start
+ if(!Test.isRunningTest()){
+ SyncAccountContactToAWS.assignOnceOneMinuteLater(aclist);
+ }
+ //Add By Li Jun for sync agency contact to aws 20220424 end
}
}
@@ -227,7 +255,7 @@
// 鎵嬫満鍙峰幓閲嶅強瑙勫垯楠岃瘉 鍙婃柊澧炲鎴蜂汉鍛橀噸鍚嶉獙璇�
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}$');
+ // 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>();
//鐢ㄦ埛瀵硅薄涓婃壘瀵瑰簲鐨勮仈绯讳汉
@@ -265,18 +293,20 @@
// 鎵嬫満鍙锋湁鍊煎苟涓旇仈绯讳汉鏈夋晥锛岃仈绯讳汉鐨勫鎴锋湁鏁堬紝杩涜鎵嬫満鍙风爜楠岃瘉
if (('鏈夋晥'.equals(contactnew.Isactive__c) || '鏈夊姽'.equals(contactnew.Isactive__c))
&& ('鏈夊姽'.equals(accMap.get(contactnew.AccountId)) || '鏈夋晥'.equals(accMap.get(contactnew.AccountId)))) {
+ // 缁忛攢鍟嗗鎴蜂汉鍛樹笉杩涜鎵嬫満鍙锋牎楠� thh 20220517 start
if(AgencyRecordTypeId.equals(contactnew.RecordTypeId)){
if(String.isNotBlank(contactnew.MobilePhone)){
- Matcher isMobilePhone = pattern.matcher(contactnew.MobilePhone);
- if (isMobilePhone.matches()) {
- contactnew.UniqueNumber__c = contactnew.MobilePhone;
- } else {
+ // Matcher isMobilePhone = pattern.matcher(contactnew.MobilePhone);
+ // if (isMobilePhone.matches()) {
+ contactnew.UniqueNumber__c = contactnew.MobilePhone;
+ // } else {
// 鎵嬫満鍙峰敮涓�瀛楁娓呯┖
- contactnew.UniqueNumber__c = null;
- }
+ // contactnew.UniqueNumber__c = null;
+ // }
} else {
contactnew.UniqueNumber__c = null;
}
+ // 缁忛攢鍟嗗鎴蜂汉鍛樹笉杩涜鎵嬫満鍙锋牎楠� thh 20220517 end
} else if(DoctorRecordTypeId.equals(contactnew.RecordTypeId)){
if(String.isNotBlank(contactnew.MobilePhone_Encrypted__c)){
contactnew.UniqueNumber__c = contactnew.MobilePhone_Encrypted__c;
@@ -285,24 +315,39 @@
}
}
}
- if (Trigger.isInsert) {
+ // if (Trigger.isInsert) {
+ if(DoctorRecordTypeId.equals(contactnew.RecordTypeId)){
accountIdSet.add(contactnew.AccountId);
- }
+ }
+ // }
}
//鎵嬫満鍙峰敮涓�鏍¢獙-鍖婚櫌涓嬫柊寤哄鎴蜂汉鍛樻牎楠屼娇鐢ㄥ姞瀵嗘墜鏈哄彿,缁忛攢鍟嗕娇鐢ㄦ櫘閫氭墜鏈哄彿 thh 20220328 end
- // 鏂板鑱旂郴浜烘椂锛�
+ // 鏂板鍖婚櫌鑱旂郴浜烘椂
if (accountIdSet.size() > 0) {
- 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) {
+ List<Contact> contactList = new List<Contact>();
+ 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];
+ }
+ 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
+ FROM Contact
+ WHERE IsFromSPO__c = false AND AccountId IN:accountIdSet AND Id Not IN: oldMap.keyset()];
+ }
+ System.debug('contactList:' + contactList);
+ if (contactList.size() > 0) {
for(Contact contact :contactList){
-
- 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
+ // 閫氳繃濮撳悕+鎵嬫満鍙峰垽鏂汉鍛樻槸鍚﹂噸澶� thh 20220518 start
+ // String lastNameStr = String.isNotBlank(contact.LastName) ? contact.LastName:'';
+ // String firstNameStr = String.isNotBlank(contact.FirstName) ? contact.FirstName:'';
+ // String contactFullName = lastNameStr + firstNameStr + MobilePhoneStr;
+ String contactFullName = contact.LastName_Encrypted__c + contact.MobilePhone_Encrypted__c;// 20220314 PI鏀归�� by Bright
+ // 閫氳繃濮撳悕+鎵嬫満鍙峰垽鏂汉鍛樻槸鍚﹂噸澶� thh 20220518 end
if(string.isBlank(contactFullName)){
continue;
}
@@ -318,29 +363,41 @@
}
for (Contact contactnew: newList) {
-
- if (Trigger.isInsert) {
-
- String accountId = String.valueOf(contactnew.AccountId).substring(0, 15);
-
- if (accountContactMap.containsKey(accountId)) {
- Map<String,Contact> contactFullNameMap = accountContactMap.get(accountId);
- 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;
- // 璺宠繃娴嬭瘯绋嬪簭 鍜� SPO閫氳繃203鎺ュ彛鍒涘缓鐨勮仈绯讳汉
- if (!(Test.isRunningTest() || contactnew.IsFromSPO__c)) {
+ 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);
+ // 閫氳繃濮撳悕+鎵嬫満鍙峰垽鏂汉鍛樻槸鍚﹂噸澶� thh 20220518 start
+ // String lastNameStr = String.isNotBlank(contactnew.LastName) ? contactnew.LastName:'';
+ // String firstNameStr = String.isNotBlank(contactnew.FirstName) ? contactnew.FirstName:'';
+ // String contactFullName = lastNameStr + firstNameStr + MobilePhoneStr;
+ String contactFullName = contactnew.LastName_Encrypted__c + contactnew.MobilePhone_Encrypted__c;// 20220314 PI鏀归�� by Bright
+ // 閫氳繃濮撳悕+鎵嬫満鍙峰垽鏂汉鍛樻槸鍚﹂噸澶� thh 20220518 end
+ if (contactFullNameMap.containsKey(contactFullName)) {
+ String accountName = contactFullNameMap.get(contactFullName).Account.Name;
+ String cManageCode = contactFullNameMap.get(contactFullName).CManageCode__c;
+ // 璺宠繃娴嬭瘯绋嬪簭 鍜� SPO閫氳繃203鎺ュ彛鍒涘缓鐨勮仈绯讳汉
+ if (!(Test.isRunningTest() || contactnew.IsFromSPO__c)) {
+ // if(Trigger.isInsert) {
contactnew.LastName.addError('瀹㈡埛 [ '+accountName+ ' ],宸插瓨鍦ㄧ浉鍚屽悕瀛楃殑鑱旂郴浜� 浜哄憳绠$悊缂栫爜 ['+cManageCode+' ] 锛屼笉鑳介噸澶嶅垱寤猴紝璇蜂簡瑙�');
- }
-
- }
+ // }
+ // 瀹㈡埛浜哄憳鍒犻櫎鎵嬫満鍙锋椂,杩涜鍒ゆ柇鏄惁瀛樺湪鍚屽悕涓旀墜鏈哄彿涓虹┖鐨勫鎴蜂汉鍛� thh 20220523 start
+ // if(Trigger.isUpdate && !UserInfo.getUserId().equals(System.Label.interfaceUserID)) {
+ // if (String.isNotBlank(oldMap.get(contactnew.Id).MobilePhone_Encrypted__c) && String.isBlank(contactnew.MobilePhone_Encrypted__c)){
+ // contactnew.LastName.addError('鐩稿悓鍚嶅瓧鐨勮仈绯讳汉 浜哄憳绠$悊缂栫爜 ['+cManageCode+' ] 鎵嬫満鍙蜂负绌哄凡缁忓瓨鍦紝涓嶈兘閲嶅鍒涘缓锛岃浜嗚В');
+ // }
+ // if (oldMap.get(contactnew.Id).CManageCode__c != contactnew.CManageCode__c){
+ // contactnew.LastName.addError('瀹㈡埛 [ '+accountName+ ' ],宸插瓨鍦ㄧ浉鍚屽悕瀛楃殑鑱旂郴浜� 浜哄憳绠$悊缂栫爜 ['+cManageCode+' ] 锛屼笉鑳介噸澶嶅垱寤猴紝璇蜂簡瑙�');
+ // }
+ // }
+ // 瀹㈡埛浜哄憳鍒犻櫎鎵嬫満鍙锋椂,杩涜鍒ゆ柇鏄惁瀛樺湪鍚屽悕涓旀墜鏈哄彿涓虹┖鐨勫鎴蜂汉鍛� thh 20220523 end
+ }
}
-
- }
+ }
}
}
public static Map<Id,Id> NFM606_IdMap = new Map<Id,Id>();
@@ -380,6 +437,8 @@
ID DoctorRecordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Doctor').getRecordTypeId();
ID AgencyRecordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
//鑾峰彇瀹㈡埛浜哄憳鐨勮褰曠被鍨婭D thh 20220330 end
+ System.debug('local.UnifiedI_Contact_ID__c1:' + local.UnifiedI_Contact_ID__c);
+ System.debug('local.MobilePhone1:' + local.MobilePhone);
if (!local.IsFromSPO__c && !InternalStaffRecordTypeId.equals(local.RecordTypeId)) {
// 鍖婚櫌 瀹㈡埛浜哄憳 缁熶竴骞冲彴缂栫爜鏈夊�� 鍙戦�� PO
if (DoctorRecordTypeId.equals(local.RecordTypeId) && String.isNotBlank(local.UnifiedI_Contact_ID__c)) {
--
Gitblit v1.9.1