From 2d4a8d2dcad5a17127d2c73c48ddc4b67ec79448 Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期三, 06 四月 2022 11:51:58 +0800
Subject: [PATCH] PIPLDeploy0405

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

diff --git a/force-app/main/default/classes/SearchVisitorController.cls b/force-app/main/default/classes/SearchVisitorController.cls
index f40ef4c..2708850 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,15 @@
     
     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;}
+    public String sfContactId{set;get;}
+    //Add By Li Jun 20220217 End
     
     public SearchVisitorController(){
         this.id1 = Apexpages.currentPage().getParameters().get('id1');
@@ -161,10 +171,47 @@
         }*/
         
         serContact();
+
+        //Add By Li Jun for PIPL 20220217 Start
+        //1. Query Contact by accountId
+        List<Contact> conList = new List<Contact>();
+        List<Account> departmentClass = new List<Account>();
+        system.debug('Account Id from Front-end:'+a.Id);
+        String accountId = a.Id;
+        PIHelper.PIIntegration contactPIIntegration = PIHelper.getPIIntegrationInfo('Contact');
+        if(String.isNotBlank(accountId) && String.isNotEmpty(accountId)){
+            departmentClass = [select Department_Class__c from Account where id =:accountId];
+            if(departmentClass.size() > 0){
+                conList = new List<Contact>([select Id,AWS_Data_Id__c from Contact where Strategic_dept_Class__c=:departmentClass[0].Department_Class__c and AWS_Data_Id__c!='' limit :contactPIIntegration.maxQueryNumber]);
+            }
+            //conList = new List<Contact>([select Id,AWS_Data_Id__c from Contact where AccountId=:accountId and AWS_Data_Id__c!='' limit :contactPIIntegration.maxQueryNumber]);
+        }        
+        //2. Prepare the Contact Info
+        List<String> conAWSIds = new List<String>();
+        system.debug('Contact Size:'+conList.size());
+        for(Contact con:conList){
+            conAWSIds.add(con.AWS_Data_Id__c);
+        }
+        contactAWSIds = JSON.serialize(conAWSIds);
+        staticResource = JSON.serialize(contactPIIntegration); 
+        //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 +219,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 +253,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>();
@@ -355,7 +407,9 @@
         
         Savepoint sp = Database.setSavepoint();
         try{
+            system.debug('rc = ' + rc);
             upsert rc;
+            sfContactId = rc.Id;
             }catch(Exception io){
                 Database.rollback(sp);
                 return null;

--
Gitblit v1.9.1