From fc8a8cea62e5d248834482a1ade9db6ab0758bf2 Mon Sep 17 00:00:00 2001
From: Li Jun <buli@deloitte.com.cn>
Date: 星期日, 24 四月 2022 18:55:04 +0800
Subject: [PATCH] 20220424FixIssue

---
 force-app/main/default/classes/ContactTriggerHandler.cls |   42 ++++++++++++++++++++++++++++++++++++------
 1 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/force-app/main/default/classes/ContactTriggerHandler.cls b/force-app/main/default/classes/ContactTriggerHandler.cls
index 43a4497..3c3c299 100644
--- a/force-app/main/default/classes/ContactTriggerHandler.cls
+++ b/force-app/main/default/classes/ContactTriggerHandler.cls
@@ -13,7 +13,9 @@
         this.oldList = (List < Contact > ) Trigger.old;
     }
     protected override void beforeInsert() {
-        mobileNumberVerification();
+        if(Test.isRunningTest()||UserInfo.getUserId()!=System.Label.ByPassTrigger){ //Add by Li Jun for PIPL 20220331
+            mobileNumberVerification();
+        }
     }
 
     protected override void afterInsert() {
@@ -138,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();
+            }
+            //Add By Li Jun for sync agency contact to aws 20220424 end
         }
     }
 
@@ -341,7 +371,6 @@
             }   
         }
     }
-
     public static Map<Id,Id> NFM606_IdMap = new Map<Id,Id>();
     // 606鎺ュ彛璋冪敤闂淇 thh 20220330 start
     private void sendToComPlat() {
@@ -379,8 +408,9 @@
                 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)) {
                         if (!NFM606_IdMap.containsKey(local.Id)) {
@@ -414,7 +444,7 @@
                 // NFM606Controller.callout('', contactIdList);
                  //娣诲姞future 鍒ゆ柇 add for pipl  sushanhu 20220317 start
                 // if (!(System.isFuture()||System.isBatch())) {
-                    NFM606Controller.callout('', contactIdList);
+                NFM606Controller.callout('', contactIdList);
                 // } else{
                     // NFM606Controller.executeNotFuture('', contactIdList);
                 // }

--
Gitblit v1.9.1