From 9b197b7fac92278fb591ea8f4942c7d5687cb5ce Mon Sep 17 00:00:00 2001
From: 李金换 <lijinhuan@prec-tech.com>
Date: 星期一, 28 三月 2022 18:01:22 +0800
Subject: [PATCH] LJPH-C8FB4P【委托】配合PBI设备覆盖率的数据准备0328

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

diff --git a/force-app/main/default/classes/InquiryFormHandler.cls b/force-app/main/default/classes/InquiryFormHandler.cls
index ffe6238..0d39970 100644
--- a/force-app/main/default/classes/InquiryFormHandler.cls
+++ b/force-app/main/default/classes/InquiryFormHandler.cls
@@ -15,9 +15,15 @@
 
     protected override void beforeInsert() {
         beforeExecute();
+        //瀹㈡埛浜哄憳褰曞叆鍚�,銆愮數璇濄�戙�愰偖绠便�戣嚜鍔ㄥ綍鍏� thh 20220321 start
+        getContactInformation();
+        //瀹㈡埛浜哄憳褰曞叆鍚�,銆愮數璇濄�戙�愰偖绠便�戣嚜鍔ㄥ綍鍏� thh 20220321 end
     }
     protected override void beforeUpdate() {
         beforeExecute();
+        //瀹㈡埛浜哄憳褰曞叆鍚�,銆愮數璇濄�戙�愰偖绠便�戣嚜鍔ㄥ綍鍏� thh 20220321 start
+        getContactInformation();
+        //瀹㈡埛浜哄憳褰曞叆鍚�,銆愮數璇濄�戙�愰偖绠便�戣嚜鍔ㄥ綍鍏� thh 20220321 end
     }
 
     protected override void afterInsert() {
@@ -95,7 +101,36 @@
             nObj.Product1_Manual__c = '';
         }
     }
-    
+
+    //瀹㈡埛浜哄憳褰曞叆鍚�,銆愮數璇濄�戙�愰偖绠便�戣嚜鍔ㄥ綍鍏� thh 20220321 start
+    private void getContactInformation(){
+        List<String> ContactIdList = new List<String>();
+        List<Contact> ContactList = new List<Contact>();
+        Map<String, Contact> ContactMap = new Map<String, Contact>();
+        for(Inquiry_form__c nnObj : newList) {
+            if(String.isNotBlank(nnObj.Contact_Name__c)){
+                ContactIdList.add(nnObj.Contact_Name__c);
+            }
+        }
+        if(ContactIdList.size() > 0){
+            ContactList = [select id, Phone, Email from Contact where Id IN :ContactIdList];
+            for(Contact contact : ContactList){
+                ContactMap.put(contact.Id, contact);
+            }
+        }
+        for(Inquiry_form__c nnObj : newList) {
+            if(String.isNotBlank(nnObj.Contact_Name__c)){
+                if(String.isNotBlank(ContactMap.get(nnObj.Contact_Name__c).Phone)){
+                    nnObj.Phone__c = ContactMap.get(nnObj.Contact_Name__c).Phone;
+                }
+                if(String.isNotBlank(ContactMap.get(nnObj.Contact_Name__c).Email)){
+                    nnObj.Email__c = ContactMap.get(nnObj.Contact_Name__c).Email;
+                }
+            }
+        }
+    }
+    //瀹㈡埛浜哄憳褰曞叆鍚�,銆愮數璇濄�戙�愰偖绠便�戣嚜鍔ㄥ綍鍏� thh 20220321 end
+
      // 鎴樼暐绉戝鐨勪富鎷呭綋 銈掑彇寰椼�両nquiry_form__Share銇ō瀹�(Read)
     // private void shareToOSCM() {
     //     //瀛樻斁鐢ㄤ簬鏂板鐨勫叡浜暟鎹�

--
Gitblit v1.9.1