/* * Author: Bubba Li * Created Date: 02/08/2022 * Purpose: SearchContactController * Test Class: SearchContactController * History: * 02/08/2022 - Bubba Li - Initial Code. * * */ public with sharing class SearchContactController { public String searchKeyWord{set;get;} public String staticResource {get; set;} public String contactAWSIds {set;get;} public String contactsInfo {set;get;} public String PIPL_Search_Contact_Label{set;get;} public String aId{set;get;} public static Boolean checkNullString(String inputString){ if(String.isEmpty(inputString)||String.isBlank(inputString)){ return true; } return false; } //2023 08 30 张赫阳 PIPL页面改造 start public String OFSType{set;get;} //2023 08 30 张赫阳 PIPL页面改造 end public SearchContactController() { String accountId = ApexPages.currentPage().getParameters().get('accountId'); searchKeyWord = ApexPages.currentPage().getParameters().get('searchContactKeyWord'); //2023 08 30 张赫阳 PIPL页面改造 start OFSType = ApexPages.currentPage().getParameters().get('Type'); //2023 08 30 张赫阳 PIPL页面改造 end aId = accountId; PIPL_Search_Contact_Label = Label.PIPL_Search_Contact_Label; //1. Query Contact by accountId List conList = new List(); system.debug('Account Id from Front-end:'+accountId); if(checkNullString(accountId)&&checkNullString(searchKeyWord)){ conList = new List(); }else{ if(checkNullString(accountId)){ conList = new List(); }else { //2022-5-12 yjk 将科室匹配改为医院匹配查询联系人 statt Account act = [select id,Hospital__c from Account where id = :accountId]; //deloitte-zhj 20231011 with sharing //conList = new List([select Id,AWS_Data_Id__c,Account.Name from Contact where Account.Hospital__c=:act.Hospital__c and AWS_Data_Id__c!='']); conList = LexAWSServicePIPLDao.searchContactInit(act.Hospital__c); //2022-5-12 yjk 将科室匹配改为医院匹配查询联系人 end } } //2. Prepare the Contact Info Map awsIdToContactMap = new Map(); List conAWSIds = new List(); for(Contact con:conList){ conAWSIds.add(con.AWS_Data_Id__c); awsIdToContactMap.put(con.AWS_Data_Id__c,con); } contactsInfo = JSON.serialize(awsIdToContactMap); contactAWSIds = JSON.serialize(conAWSIds); staticResource = JSON.serialize(PIHelper.getPIIntegrationInfo('Contact')); } @RemoteAction public static Response searchContacts(String awsContactIds,String searchContactName,String accountId) { system.debug('awsContactIds = ' + awsContactIds); Response resp = new Response(); resp.status = 'fail'; Map awsIdToContactMapTemp = new Map(); if(!checkNullString(awsContactIds)){ List awsDataIds = (List) JSON.deserialize(awsContactIds, List.class); List conListTemp = new List(); if(!checkNullString(accountId)){ //2022-5-12 yjk 将科室匹配改为医院匹配查询联系人 statt Account act = [select id,Hospital__c from Account where id = :accountId]; //deloitte-zhj 20231011 with sharing //conListTemp = new List([select Id,AWS_Data_Id__c,Account.Name from Contact where Account.Hospital__c=:act.Hospital__c and AWS_Data_Id__c in:awsDataIds]); conListTemp = LexAWSServicePIPLDao.searchContactWithAccountId(act.Hospital__c,awsDataIds); //2022-5-12 yjk 将科室匹配改为医院匹配查询联系人 end }else { //deloitte-zhj 20231011 with sharing //conListTemp = new List([select Id,AWS_Data_Id__c,Account.Name from Contact where AWS_Data_Id__c in:awsDataIds]); conListTemp = LexAWSServicePIPLDao.searchContactNoWithAccountId(awsDataIds); } for(Contact con:conListTemp){ awsIdToContactMapTemp.put(con.AWS_Data_Id__c,con); } } System.debug('awsIdToContactMapTemp = ' + awsIdToContactMapTemp); Map noPIContactMapTemp = new Map(); List partnerContactList = AWSServiceTool.getNoPIContact(searchContactName,accountId); System.debug('partnerContactList = ' + partnerContactList); if(partnerContactList.size()>0){ for(Contact con:partnerContactList){ noPIContactMapTemp.put(con.Id,con); } } if(awsIdToContactMapTemp.keySet().size()>0 ||noPIContactMapTemp.keySet().size()>0){ resp.status = 'success'; resp.message = JSON.serialize(awsIdToContactMapTemp);// PI contact info resp.noPIContactList = JSON.serialize(noPIContactMapTemp);//NoPI contact info } return resp; } @RemoteAction public static Response searchContactsNoPI(String contactName) { Response resp = new Response(); resp.status = 'fail'; //deloitte-zhj 20231011 with sharing //List conListTemp = new List([select Id,Name,Account.Name,Phone,Email,MobilePhone from Contact where Name like :contactName]); List conListTemp = LexAWSServicePIPLDao.searchContactNoPI(contactName); if(conListTemp.size() > 0){ resp.status = 'success'; resp.message = JSON.serialize(conListTemp); } return resp; } public class Response{ public String message{set;get;} public String status{set;get;} public String noPIContactList{set;get;} } }