From 02ddc35714cbd1688b7cb057f770f1410de79dab Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期五, 11 三月 2022 12:19:33 +0800
Subject: [PATCH] PIPL Updated Code 20220311

---
 force-app/main/default/classes/SearchVisitorController.cls |   60 ++++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 52 insertions(+), 8 deletions(-)

diff --git a/force-app/main/default/classes/SearchVisitorController.cls b/force-app/main/default/classes/SearchVisitorController.cls
index f40ef4c..2a48b1b 100644
--- a/force-app/main/default/classes/SearchVisitorController.cls
+++ b/force-app/main/default/classes/SearchVisitorController.cls
@@ -5,6 +5,7 @@
     public List<Contact> cl {get;set;}
     public List<AddContactWrapper> acwl {get;set;}
     public String index {get; set;}
+    public String awsContactIds{set;get;}//Add By Li Jun 20220214 for PIPL
     public String id1 {get;set;}
     public String hId1 {get;set;}
     public String idVa1 {get;set;}
@@ -24,6 +25,14 @@
     
     public User u {get;set;}
     public Account a {get;set;}
+
+
+    //Add By Li Jun 20220217 Start
+    public String staticResource {get; set;}
+    public String contactAWSIds {set;get;}
+    public String contactsInfo {set;get;}
+    public String awsDataIdArray {set;get;}
+    //Add By Li Jun 20220217 End
     
     public SearchVisitorController(){
         this.id1 = Apexpages.currentPage().getParameters().get('id1');
@@ -161,10 +170,40 @@
         }*/
         
         serContact();
+
+        //Add By Li Jun for PIPL 20220217 Start
+        //1. Query Contact by accountId
+        List<Contact> conList = new List<Contact>();
+        system.debug('Account Id from Front-end:'+a.Id);
+        String accountId = a.Id;
+        if(String.isNotBlank(accountId) && String.isNotEmpty(accountId)){
+            conList = new List<Contact>([select Id,AWS_Data_Id__c from Contact where AccountId=:accountId and AWS_Data_Id__c!='']);
+        }        
+        //2. Prepare the Contact Info
+        List<String> conAWSIds = new List<String>();
+        for(Contact con:conList){
+            conAWSIds.add(con.AWS_Data_Id__c);
+        }
+        contactAWSIds = JSON.serialize(conAWSIds);
+        staticResource = JSON.serialize(PIHelper.getPIIntegrationInfo('Contact')); 
+        //Add By Li Jun for PIPL 20220217 End 
+     }
+    //Add by Li Jun for PIPL 202202117 Start
+    public PageReference clearLineInfoList()  {
+        scwl = new List<SltContactWrapper>();
+        return null;
     }
-    
+    //Add by Li Jun for PIPL 202202117 End
     public PageReference serContact(){
-        System.debug('===== serContact start =====');
+        System.debug('===== serContact start ====='+awsContactIds);
+        //Add By Li Jun for PIPL 20220218 Start
+        Set<String> awsContactSet = new Set<String>();
+        if(String.isNotBlank(awsContactIds)&&String.isNotEmpty(awsContactIds)){
+            List<String> awsDataIds = (List<String>) JSON.deserialize(awsContactIds, List<String>.class);
+            awsContactSet = new Set<String>(awsDataIds);
+        }        
+        System.debug('===== serContact start ====='+awsContactSet);
+         //Add By Li Jun for PIPL 20220218 End
         String searchHospital = 'Select Hospital__c, Department_Class__c,Is_Active__c From Account Where Id = \'' + vp + '\' ';
         Account a = Database.query(searchHospital);
         if(a.Is_Active__c == '鐒″姽'){
@@ -172,16 +211,20 @@
             return null;
         }
         
-        String searchSql = 'Select id, name,Ignore_Same_Name__c, Account.Name, Type__c, Doctor_Division1__c, MyDr_Flg__c, phone, Supplement__c, MyDr__c, Select_Flg__c,Delete_Reason__c, Please_Delete__c, Please_Delete_applier__c, FirstName, LastName, Search_LastName__c, Account_Visitor_Search__c  From Contact ';
+        String searchSql = 'Select id, name,Ignore_Same_Name__c,AWS_Data_Id__c, Account.Name, Type__c, Doctor_Division1__c, MyDr_Flg__c, phone, Supplement__c, MyDr__c, Select_Flg__c,Delete_Reason__c, Please_Delete__c, Please_Delete_applier__c, FirstName, LastName, Search_LastName__c, Account_Visitor_Search__c  From Contact ';
         String whereStr = 'Where Account.ParentId =\'' + a.Department_Class__c + '\' and Account.Is_Active__c != \'鐒″姽\' ' + ' and Isactive__c != \'鏃犳晥(閫�浼�)\' and Isactive__c != \'鏃犳晥(閲嶅)\'';
         String whereSql = '';
-        if(sc.Search_LastName__c != null && sc.Search_LastName__c != ''){
-            whereSql += 'and LastName like ' + '\'%' + sc.Search_LastName__c + '%\' ';
+        //Commented by Li Jun 20220214 for PIPL
+        if(awsContactSet.size()>0){
+            whereSql += 'and AWS_Data_Id__c in: awsContactSet ';
         }
+        // if(sc.Search_LastName__c != null && sc.Search_LastName__c != ''){
+        //     whereSql += 'and LastName like ' + '\'%' + sc.Search_LastName__c + '%\' ';
+        // }
         
-        if(sc.Search_FirstName__c != null && sc.Search_FirstName__c != ''){
-            whereSql += 'and FirstName like ' + '\'%' + sc.Search_FirstName__c + '%\' ';
-        }
+        // if(sc.Search_FirstName__c != null && sc.Search_FirstName__c != ''){
+        //     whereSql += 'and FirstName like ' + '\'%' + sc.Search_FirstName__c + '%\' ';
+        // }
         
         if(sc.Type__c != null && sc.Type__c != ''){
             whereSql += 'and Type__c = \'' + sc.Type__c + '\' ';
@@ -202,6 +245,7 @@
         
         System.debug('searchSql:'+searchSql);
         cl = Database.query(searchSql);
+        System.debug('Query Result from SF:'+JSON.serialize(cl));
         Integer i = 0;
         
         scwl = new List<SltContactWrapper>();

--
Gitblit v1.9.1