From b823c7f3569cf9368e2245846e918f78f32e903a Mon Sep 17 00:00:00 2001
From: GWY <guweiyiscp096@foxmail.com>
Date: 星期五, 15 四月 2022 11:38:47 +0800
Subject: [PATCH] Merge branch 'master' of http://47.92.229.245:8089/r/OlympusSSBG

---
 force-app/main/default/pages/NewAndEditContact.page                    |   27 
 force-app/main/default/classes/NewAndEditLoanerAppDetailController.cls |    1 
 force-app/main/default/classes/PIHelper.cls                            |  145 +++++
 force-app/main/default/classes/OrderTriggerHandler.cls                 |    4 
 force-app/main/default/pages/NewAndEditOpportunity.page                |    2 
 force-app/main/default/pages/NewOpportunity.page                       |   35 +
 force-app/main/default/classes/NewAndEditContactController.cls         |   58 ++
 force-app/main/default/pages/ViewUserFaultInfoDecryptInfo.page         |   98 +++
 force-app/main/default/classes/SearchContactController.cls-meta.xml    |    2 
 force-app/main/default/pages/SWOPage.page                              |  255 +++++++++
 force-app/main/default/classes/NewAndEditBaseController.cls            |  160 +++--
 force-app/main/default/pages/NewAndEditLoanerApplication.page          |    6 
 force-app/main/default/classes/NewAndEditLoanerExpressController.cls   |    1 
 force-app/main/default/pages/SearchContactPage.page                    |  147 +++-
 force-app/main/default/classes/NewAndEditUserFaultInfoController.cls   |   40 +
 force-app/main/default/classes/SWOController.cls                       |   22 
 force-app/main/default/classes/SearchContactControllerTest.cls         |    5 
 force-app/main/default/pages/ViewOpportunityDecryptInfo.page           |    7 
 force-app/main/default/pages/NewAndEditLoanerUser.page                 |    2 
 force-app/main/default/pages/SWOPageRead.page                          |  123 ++++
 force-app/main/default/classes/SearchContactController.cls             |   82 ++
 force-app/main/default/pages/ViewOrderDecryptInfo.page                 |   57 ++
 force-app/main/default/classes/SBG203Rest.cls                          |   68 ++
 force-app/main/default/classes/NewAndEditOrderController.cls           |   34 +
 force-app/main/default/pages/SearchContactPage.page-meta.xml           |    2 
 force-app/main/default/pages/TSRepair.page                             |   24 
 force-app/main/default/classes/AWSServiceTool.cls                      |   41 +
 force-app/main/default/pages/NewAndEditOrder.page                      |   11 
 force-app/main/default/pages/NewAndEditQuotes.page                     |   21 
 force-app/main/default/pages/NewAndEditUserFaultInfo.page              |    4 
 30 files changed, 1,231 insertions(+), 253 deletions(-)

diff --git a/force-app/main/default/classes/AWSServiceTool.cls b/force-app/main/default/classes/AWSServiceTool.cls
index 049cffd..5f10b3e 100644
--- a/force-app/main/default/classes/AWSServiceTool.cls
+++ b/force-app/main/default/classes/AWSServiceTool.cls
@@ -8,6 +8,21 @@
  * 
  * */
 public without sharing class AWSServiceTool {
+    public static List<Contact>  getNoPIContact(String searchContactName,String accountId){
+        if(searchContactName!='' || accountId!=''){
+            String noPISQL = 'select Id,Name,Email,Phone,Account.Name,MobilePhone from Contact where Account_Record_Type_DeveloperName__c in('+'\'Agency\''+','+'\'Dealer\''+')';
+            if(String.isNotEmpty(accountId)){
+                noPISQL += ' and AccountId=\''+accountId+'\'';
+            }
+            if(String.isNotEmpty(searchContactName)){
+                noPISQL += ' and Name like \'%'+searchContactName+'%\'';
+            }
+            system.debug('noPISQL = ' + noPISQL);
+            List<Contact> partnerContactList = Database.query(noPISQL);
+            return partnerContactList;
+        }
+        return new List<Contact>();
+    }
     public static String getAWSToken(){
         AWS_Integration_Info__mdt awsConfiguration = [SELECT App_Id__c,Token_URL__c,App_Secret__c,Host_URL__c FROM AWS_Integration_Info__mdt  WHERE DeveloperName = 'AWS_Default_Configuration'];
         if (awsConfiguration == null) {
@@ -21,9 +36,35 @@
         String url = awsConfiguration.Token_URL__c;
         request.setEndpoint(url);
         request.setMethod('GET');
+        if(Test.isRunningTest()){
+            return 'UTToken';
+        }
         HttpResponse response = http.send(request);
         Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
         String token = (String)results.get('object');
         return token;
     }
+    @future(callout=true)
+    public static void deleteFileAddress(Set<String> fileAddressIds){
+        //1. Get file address id
+        system.debug('fileAddressId = '+ JSON.serialize(fileAddressIds));
+        PIHelper.PIIntegration documentPI=PIHelper.getPIIntegrationInfo('Document');
+        //2. Delete aws file doucment and post aws service
+        Http http = new Http();
+        HttpRequest request = new HttpRequest();
+        String url = documentPI.deleteUrl;
+        request.setEndpoint(url);
+        request.setMethod('POST');
+        request.setHeader('pi-token',documentPI.token);
+        request.setHeader('Content-Type', 'application/json');
+        request.setBody(JSON.serialize(fileAddressIds));
+        HttpResponse response = http.send(request);
+        system.debug('response = ' + response);
+        if(response.getStatusCode() == 200){
+            Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
+            if(results.get('status')=='0'){
+                System.debug('鎴愬姛鍒犻櫎');
+            }
+        }
+    }
 }
\ No newline at end of file
diff --git a/force-app/main/default/classes/NewAndEditBaseController.cls b/force-app/main/default/classes/NewAndEditBaseController.cls
index 35317ff..49ce172 100644
--- a/force-app/main/default/classes/NewAndEditBaseController.cls
+++ b/force-app/main/default/classes/NewAndEditBaseController.cls
@@ -1,19 +1,16 @@
-/**
- * @description       : 
- * @author            : ChangeMeIn@UserSettingsUnder.SFDoc
- * @group             : 
- * @last modified on  : 03-16-2022
- * @last modified by  : ChangeMeIn@UserSettingsUnder.SFDoc
-**/
 global abstract class NewAndEditBaseController {
 
     public List <LayoutDescriberHelper.LayoutSection > layoutSections{set;get;}
+    public String layoutSectionsStr {get; set;}//for dynamic add readonly attribute 20220316 by Mingjie
     public String awsToken{set;get;}
     public static Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
     public String sobjectTypeValue {private set; get;}
     public Boolean isNewMode{set;get;}
+    public Boolean isCloneMode{protected set;get;}
     public String rtTypeId {get; set;}
     public String AWSDataId{set;get;}
+    public String CurrentUserId{private set;get;}
+    public String CurrentUserName{private set;get;}
 
     // 褰撳墠瀵硅薄鎵�鏈夌殑鍔犲瘑瀛楁闆嗗悎
     public List<String> encryptedAPIList{private set;get;}
@@ -51,12 +48,13 @@
 
     public String sobjectPrefix{get;private set;}
     public String SaveAndNewButtonUrl{get;private set;}
+    @TestVisible
     public List<String> VLookUpFields{get;private set;}
     public String VLookUpFieldsJson{get{return Json.serialize(VLookUpFields);}}
     public List<String> LookUpOverrideFields{get;private set;}
-    public string LookUpOverrideFieldsMapJson{get;private set;}
-    
-
+    public string LookUpOverrideFieldsMapJson{get; set;}
+    public string recordId{get;private set;}
+	
     public NewAndEditBaseController(){
         ApiPrefix = 'PIBackApi';
         AWSToSobjectNonEncryptedMap = new Map<string,string>();
@@ -64,17 +62,24 @@
         VLookUpFields = new List<String>();
         layoutEncryptedAPIList = new List<String>();
         LookUpOverrideFields = new List<String>();
+        CurrentUserName = UserInfo.getName();
+        CurrentUserId = UserInfo.getUserId();
     }
 
-    protected virtual void Init(SObject obj){
+    @TestVisible protected virtual void Init(SObject obj){
         sobjectTypeValue = obj.getSObjectType().getDescribe().getName();
         SobjectLabel = obj.getSObjectType().getDescribe().getLabel();
         system.debug('obj='+sobjectTypeValue);
         
         isNewMode = true;
+        isCloneMode = false;
         List<Sobject> lso = Database.query('select id from RecordType where SobjectType = :sobjectTypeValue');
-        
+        Map<string,string> mso = ApexPages.currentPage().getParameters();
+        if(mso != null && mso.containsKey('newclone')){
+            isCloneMode = true;
+        }
         if(obj.Id != null){
+            recordId = obj.Id;
             isNewMode = false;
             string sql = 'select Id';
             if (lso.size()>0) {
@@ -97,7 +102,7 @@
                     sfIdToAWSIdMap.put(String.valueOf(o).subString(0,15), String.valueOf(leadData.getSobject(GetReferenceField(f)).get('AWS_Data_Id__c')));
                 }
             }
-           
+            
             LookUpOverrideFieldsMapJson = JSON.serialize(sfIdToAWSIdMap);
 
 
@@ -105,7 +110,7 @@
             rtTypeId = ApexPages.currentPage().getParameters().get('RecordType');
         }
         PIHelper.PIIntegration piIntegration = PIHelper.getPIIntegrationInfo(sobjectTypeValue);
-        layoutEncryptedAPIList = piIntegration.PIFields;
+        //layoutEncryptedAPIList = piIntegration.PIFields;
         encryptedAPIList = piIntegration.PIFields;
         staticResource = JSON.serialize(piIntegration);
         sobjectPrefix = piIntegration.sobjectPrefix;
@@ -124,7 +129,7 @@
         system.debug(AWSToSobjectNonEncryptedMapJson);
         try{
             LayoutDescriberHelper.LayoutWrapper LayoutWrapperValue = LayoutDescriberHelper.describeSectionWithFieldsWrapper(rtTypeId, sobjectTypeValue,'classic');
-            layoutSections = LayoutWrapperValue.layoutSections;
+            layoutSections = LayoutWrapperValue.layoutSections;         
             List<String> requiredFieldAPIList = LayoutWrapperValue.requiredFieldAPIList;
             Map<String,String> fieldAPIToLabelMap = LayoutWrapperValue.fieldAPIToLabelMap;
             List<String> fieldApiList = new List<String>(); 
@@ -138,17 +143,19 @@
                         }
 
                         //鍦╲iew瑙e瘑section涓彧闇�鏄剧ず褰撳墠layout涓殑鍔犲瘑瀛楁
-                        // if (encryptedAPIList.contains(lf.fieldAPI)) {
-                        //     layoutEncryptedAPIList.add(lf.fieldAPI);
-                        // }
+                        if (encryptedAPIList.contains(lf.fieldAPI)) {
+                            layoutEncryptedAPIList.add(lf.fieldAPI);
+                        }
                     }
                 }
             }
+            layoutSectionsStr = JSON.serialize(layoutSections); //for dynamic add readonly attribute 20220316 by Mingjie
             fieldApiListStr = JSON.serialize(fieldApiList);
             fieldAPIToLabelMapStr = JSON.serialize(fieldAPIToLabelMap);
             requiredFieldAPIListStr = JSON.serialize(requiredFieldAPIList);
             //awsToken = AWSServiceTool.getAWSToken();
         }catch(Exception e){
+            layoutEncryptedAPIList = piIntegration.PIFields;
             system.debug('Exception from get layout service:'+e.getmessage());
         }
     }
@@ -184,65 +191,77 @@
         string sobjectTypeValue = sobj.getSObjectType().getDescribe().getName();
         System.debug('sobjectTypeValue:'+sobjectTypeValue+' Info:' + JSON.serialize(leadJson));
         System.debug('json length='+leadJson.length());
-        System.debug('json ='+leadJson);
+        System.debug('leadJson---------'+leadJson);
+        System.debug('isNew---------'+isNew);
         //1. Prepare the payload for  Lead
         Schema.SObjectType leadSchema = schemaMap.get(sobjectTypeValue);
         Map<String, Schema.SObjectField> fieldAPIToTypeMap = leadSchema.getDescribe().fields.getMap();
         Map<String,Object> fieldValueMap = (Map<String,Object>)JSON.deserializeUntyped(leadJson);
-        Sobject leadInfo = sobj;
-        for (String fieldAPI: fieldValueMap.keySet()) {
-            system.debug('field API='+fieldAPI);
-            Schema.DisplayType fielddataType = fieldAPIToTypeMap.get(fieldAPI).getDescribe().getType();  
-            String fieldValue = String.valueOf(fieldValueMap.get(fieldAPI)); 
-            system.debug('Field Type:'+fielddataType+' field Value='+fieldValue);
-            if(String.valueOf(fielddataType)=='DATE'){
-                leadInfo.put(fieldAPI,(String.isBlank(fieldValue)||String.isEmpty(fieldValue))? null:Date.valueOf(fieldValue.replace('/', '-')));              
-            }else if(String.valueOf(fielddataType)=='DATETIME'){
-                if(String.isNotBlank(fieldValue)&&fieldValue.contains('T')){
-                    fieldValue = fieldValue.replace('T',' ');
-                    leadInfo.put(fieldAPI, Datetime.valueOfGmt(fieldValue));
-                }else{
-                    leadInfo.put(fieldAPI, null);
-                }                    
-            }else if(String.valueof(fielddataType)=='CURRENCY' || String.valueof(fielddataType)=='PERCENT'||String.valueOf(fielddataType)=='Number'||String.valueOf(fielddataType)=='DOUBLE' ){
-                // leadInfo.put(fieldAPI, (String.isBlank(fieldValue)||String.isEmpty(fieldValue))?0:Decimal.valueOf(fieldValue)); 
-                if(String.isNotBlank(fieldValue)&&String.isNotEmpty(fieldValue)){
-                    if(fieldValue.contains(',')){
-                        fieldValue = fieldValue.replace(',', '');
-                    }
-                    leadInfo.put(fieldAPI, Decimal.valueOf(fieldValue));
-                }else{
-                    leadInfo.put(fieldAPI, 0);
-                } 
-            } else if(String.valueof(fielddataType)=='BOOLEAN'){
-                leadInfo.put(fieldAPI, fieldValueMap.get(fieldAPI));
-            }else {
-                leadInfo.put(fieldAPI,fieldValue);
-            }                  
-        }
-
-        system.debug('for (String fieldAPI: fieldValueMap.keySet()) end');
-
         
+
+        Boolean isClone = false;
         //2. Save Record Process
         String status = 'success';    
         Response resp = new Response();
         String awsDataId = '';
         Savepoint sp = Database.setSavepoint();
+        Sobject leadInfo = sobj;
         try{
-            System.debug('abcde');
-            if(isNew){
+            
+            for (String fieldAPI: fieldValueMap.keySet()) {
+                system.debug('field API='+fieldAPI);
+                if(!fieldAPIToTypeMap.containskey(fieldAPI)){
+                    continue;
+                }
+                Schema.DisplayType fielddataType = fieldAPIToTypeMap.get(fieldAPI).getDescribe().getType();  
+                String fieldValue = String.valueOf(fieldValueMap.get(fieldAPI)); 
+                system.debug('Field Type:'+fielddataType+' field Value='+fieldValue);
+                if(String.valueOf(fielddataType)=='DATE'){
+                    leadInfo.put(fieldAPI,(String.isBlank(fieldValue)||String.isEmpty(fieldValue))? null:Date.valueOf(fieldValue.replace('/', '-')));              
+                }else if(String.valueOf(fielddataType)=='DATETIME'){
+                    if(String.isNotBlank(fieldValue)&&fieldValue.contains('T')){
+                        fieldValue = fieldValue.replace('T',' ');
+                        leadInfo.put(fieldAPI, Datetime.valueOfGmt(fieldValue));
+                    //20220405 By ChenYanan Start
+                    }else if(String.isNotBlank(fieldValue))  {
+                        fieldValue = fieldValue.replace('/', '-') + ':00';
+                        leadInfo.put(fieldAPI, Datetime.valueOf(fieldValue));
+                    //20220405 By ChenYanan End
+                    }else{
+                        leadInfo.put(fieldAPI, null);
+                    }                    
+                }else if(String.valueof(fielddataType)=='CURRENCY'|| String.valueof(fielddataType)=='PERCENT'||String.valueOf(fielddataType)=='Number'||String.valueOf(fielddataType)=='DOUBLE' ){
+                    leadInfo.put(fieldAPI, (String.isBlank(fieldValue)||String.isEmpty(fieldValue))?null:Decimal.valueOf(fieldValue.replace(',', ''))); 
+                } else if(String.valueof(fielddataType)=='BOOLEAN'){
+                    leadInfo.put(fieldAPI, fieldValueMap.get(fieldAPI));
+                }else {
+                    leadInfo.put(fieldAPI,fieldValue);
+                }                  
+            }
+
+            system.debug('for (String fieldAPI: fieldValueMap.keySet()) end');
+            awsDataId = (String)leadInfo.get('AWS_Data_Id__c');
+            if (string.isBlank(awsDataId)) {
+                throw new DMLException('鏇存柊鏃禔WS_Data_Id__c涓嶈兘涓虹┖');
+            }
+            System.debug('awsDataId = ' + awsDataId);
+            Sobject[] sobjects = Database.query('select id from '+sobjectTypeValue+' where AWS_Data_Id__c =:awsDataId');
+            
+            
+            if(!isNew){
+                isClone = sobjects.size() == 0;
+            }
+            System.debug('isNew---------'+isNew);
+            
+            if(isNew || isClone){
                 System.debug('leadInfozhj = ' + leadInfo);
                 if(!Test.isRunningTest()){
                     insert leadInfo;
                 }
             }else{
                 System.debug('into update');
-                awsDataId = (String)leadInfo.get('AWS_Data_Id__c');
-                System.debug('awsDataId = ' + awsDataId);
-                Sobject[] leads = Database.query('select id from '+sobjectTypeValue+' where AWS_Data_Id__c =:awsDataId');
-                System.debug('leads[0].id = ' + leads[0].id);
-                leadInfo.put('Id',leads[0].id);//For testing;
+                System.debug('sobjects[0].id = ' + sobjects[0].id);
+                leadInfo.put('Id',sobjects[0].id);//For testing;
                 if(!Test.isRunningTest()){
                     update leadInfo;
                 }
@@ -263,7 +282,26 @@
             System.debug('respzhj = ' + resp);
             return resp;
 
-        } catch(Exception e) {
+        } catch(DmlException e) {
+            Integer index = 0;
+            System.debug(e.getNumDml());
+            System.debug(e.getDmlFields(index));
+            System.debug(e.getDmlId(index));
+            System.debug(e.getDmlIndex(index));
+            System.debug(e.getDmlMessage(index));
+            System.debug(e.getDmlStatusCode(index));
+            System.debug(e.getDmlType(index));
+            system.debug(e.getMessage());
+            system.debug(e.getStackTraceString());
+
+            System.debug('into catch'+e.getMessage());
+            Database.rollback(sp);
+            resp.status = 'Exception';
+            resp.message ='淇濆瓨澶辫触锛屽師鍥�:'+ e.getDmlMessage(index);
+            PIHelper.saveTransLog(sobjectTypeValue,awsDataId,leadInfo.Id,transId, leadJson ,status,e.getMessage()+e.getStackTraceString());
+            return resp;
+            
+        }catch(Exception e) {
             System.debug('into catch'+e.getMessage());
             Database.rollback(sp);
             resp.status = 'Exception';
diff --git a/force-app/main/default/classes/NewAndEditContactController.cls b/force-app/main/default/classes/NewAndEditContactController.cls
index b5a7688..c72f679 100644
--- a/force-app/main/default/classes/NewAndEditContactController.cls
+++ b/force-app/main/default/classes/NewAndEditContactController.cls
@@ -18,7 +18,12 @@
         
         // Add fields to controller. This is to avoid the SOQL error in visualforce page
         //Get Account Id from url param
-        this.accountId = ApexPages.currentPage().getParameters().get('retURL');
+        system.debug('mso='+ApexPages.currentPage().getParameters());
+        this.accountId = ApexPages.currentPage().getParameters().get('accid');
+        if(string.isBlank(this.accountId)){
+            system.debug('retake accid');
+            this.accountId = ApexPages.currentPage().getParameters().get('con4_lkid');
+        }
         System.debug('accountId = ' + accountId);
 
         // System.debug('accountType = ' + );
@@ -29,11 +34,12 @@
         Init(controller.getRecord());
         
         if (this.accountId != '/003/o' && this.accountId != null && this.isNewMode) {
-            ID accId = ID.valueOf(this.accountId.substring(1, this.accountId.length()));   
+            ID accId = ID.valueOf(this.accountId);   
             System.debug('accId = ' + accId);
             
             account = [select id, Name, PhoneD__c, FaxD__c, Address1D__c, PostCodeD__c, ProductSegment__c from Account where id =:accId];
             System.debug('account = ' + account);
+            
         }
 
         SObject obj = controller.getRecord();
@@ -44,11 +50,59 @@
 
         if (this.account != null) {
             obj.put('ProductSegment'+account.ProductSegment__c+'__c', true);
+            obj.put('AccountId', this.accountId);
         }
         
         
     }
+    
+    PageReference RedirectStandardPage(){
+        system.debug('RedirectStandardPage');
+        Map<string,string> mso = ApexPages.currentPage().getParameters();
+        system.debug(mso);
+        PageReference pg = null;
+        mso.remove('sfdc.override');
+        mso.remove('save_new');
+        system.debug('recordId='+recordId);
+        if(string.isBlank(recordId)){
+            pg = new PageReference('/003/e');
+        }else{
+            pg = new PageReference('/'+recordId+'/e');
+        }
+        pg.getParameters().putAll(mso);
+        //pg.getParameters().put('RecordType',mso.get('RecordType'));
+        //pg.getParameters().put('accid',mso.get('accid'));
+        pg.getParameters().put('nooverride','1');
+        pg.setRedirect(true);
+        
+        return pg;
+    }
 
+    public PageReference PageLoad(){
+        system.debug('rtTypeId='+rtTypeId);
+        
+        string s = null;
+        string accid = ApexPages.currentPage().getParameters().get('accid');
+        if(string.isBlank(accid)){
+            system.debug('retake accid');
+            accid = ApexPages.currentPage().getParameters().get('con4_lkid');
+        }
+        if(!string.isBlank(accid)){
+            List<Account> accs = [select RecordType.DeveloperName from account where id = :accid];
+            system.debug(accs);
+            if(accs.size()>0){
+                s = Schema.SObjectType.Account.getRecordTypeInfosById().get(accs[0].RecordTypeId).getDeveloperName();
+                system.debug('s='+s);
+                if(s == 'Dealer' || s == 'Agency'){
+                    return RedirectStandardPage();
+                }
+            }
+            
+            
+        }
+        system.debug('null');
+        return null;
+    }
     
     @RemoteAction
     global static Response saveContact(String contactJson, String transId, Boolean isNew){
diff --git a/force-app/main/default/classes/NewAndEditLoanerAppDetailController.cls b/force-app/main/default/classes/NewAndEditLoanerAppDetailController.cls
index 72d1a83..287da9c 100644
--- a/force-app/main/default/classes/NewAndEditLoanerAppDetailController.cls
+++ b/force-app/main/default/classes/NewAndEditLoanerAppDetailController.cls
@@ -5,6 +5,7 @@
  * Test Class: NewAndEditLoanerApplicationDetailController 
  * History: 
  *      03/15/2022 - Yanan Chen - Initial Code.
+ * 寰呭垹闄�
  * 
  * */
 global class NewAndEditLoanerAppDetailController extends NewAndEditBaseController {
diff --git a/force-app/main/default/classes/NewAndEditLoanerExpressController.cls b/force-app/main/default/classes/NewAndEditLoanerExpressController.cls
index e34dd71..4619491 100644
--- a/force-app/main/default/classes/NewAndEditLoanerExpressController.cls
+++ b/force-app/main/default/classes/NewAndEditLoanerExpressController.cls
@@ -5,6 +5,7 @@
  * Test Class: NewAndEditLoanerApplicationDetailController 
  * History: 
  *      03/15/2022 - Yanan Chen - Initial Code.
+ * 寰呭垹闄�
  * 
  * */
 global class NewAndEditLoanerExpressController extends NewAndEditBaseController {
diff --git a/force-app/main/default/classes/NewAndEditOrderController.cls b/force-app/main/default/classes/NewAndEditOrderController.cls
index 24a55f6..7eb816a 100644
--- a/force-app/main/default/classes/NewAndEditOrderController.cls
+++ b/force-app/main/default/classes/NewAndEditOrderController.cls
@@ -10,6 +10,10 @@
     public String PIPL_Input_Account_Error_Msg{set;get;}
     public String contactId{set;get;}//For Lookup field
     public String staticResourceContact {get; set;}
+    public String contactAWSDataId{set;get;}
+    public String contactName{set;get;}
+    public String endUserDAWSDataId{set;get;}
+    public String endUserDName{set;get;}
     public NewAndEditOrderController(ApexPages.StandardController controller){
         
     
@@ -33,9 +37,39 @@
         if(obj.Id == null){
             //鍒濆鍖栧姞杞藉��
             obj.put('OwnerId',UserInfo.getUserId());
+        } else {
+             //鑱旂郴浜虹殑Id
+            Order order = [select EndUser__c, EndUserD__c from Order where id=:obj.Id];
+            System.debug('order: ' + order);
+            if(order != null){
+                if (order.EndUser__c != null) {
+                    List<Contact> contact = [select AWS_Data_Id__c,Name from Contact where id=:order.EndUser__c];
+                    if(contact.size()>0){
+                        if (contact[0].AWS_Data_Id__c != null && contact[0].AWS_Data_Id__c != '') {
+                            contactAWSDataId = contact[0].AWS_Data_Id__c;
+                        }else {
+                            contactName = contact[0].Name;
+                        }
+                    }
+                }
+                if (order.EndUserD__c != null) {
+                    List<Contact> contact = [select AWS_Data_Id__c,Name from Contact where id=:order.EndUserD__c];
+                    if(contact.size()>0){
+                        if (contact[0].AWS_Data_Id__c != null && contact[0].AWS_Data_Id__c != '') {
+                            endUserDAWSDataId = contact[0].AWS_Data_Id__c;
+                        }else {
+                            endUserDName = contact[0].Name;
+                        }
+                    }
+                }
+            }else {
+                contactAWSDataId = '鏃�';
+                contactName = '鏃�';
+            }
         }
         //contact淇℃伅锛堟悳绱㈡煡璇uery url鐢級
         staticResourceContact = JSON.serialize(PIHelper.getPIIntegrationInfo('Contact'));
+
     }
 
     
diff --git a/force-app/main/default/classes/NewAndEditUserFaultInfoController.cls b/force-app/main/default/classes/NewAndEditUserFaultInfoController.cls
index 44991ad..d45f3f2 100644
--- a/force-app/main/default/classes/NewAndEditUserFaultInfoController.cls
+++ b/force-app/main/default/classes/NewAndEditUserFaultInfoController.cls
@@ -11,23 +11,57 @@
     public String PIPL_Input_Account_Error_Msg{set;get;}
     public String contactId{set;get;}//For Lookup field
     public String staticResourceContact {get; set;}
+    public String contactAWSDataId{set;get;}
+    public String contactName{set;get;}
+    public String endUserDAWSDataId{set;get;}
+    public String endUserDName{set;get;}
     public NewAndEditUserFaultInfoController(ApexPages.StandardController controller){
         List<String> fieldList = new List<String>(Schema.getGlobalDescribe().get('User_FaultInfo__c').getDescribe().fields.getMap().keyset());  
         // Add fields to controller. This is to avoid the SOQL error in visualforce page
         if(!Test.isRunningTest()){
             controller.addFields(fieldList); // contact lookup
+            LookUpOverrideFields.add('UFContact__c');
+            LookUpOverrideFields.add('CONTACT__c');
         }
-        LookUpOverrideFields.add('CONTACT__c');
         Init(controller.getRecord());
         //娣诲姞椤�
         PIPL_Input_Account_Error_Msg = label.PIPL_Input_Account_Error_Msg;
+        //contact淇℃伅锛堟悳绱㈡煡璇uery url鐢級
+        staticResourceContact = JSON.serialize(PIHelper.getPIIntegrationInfo('Contact'));
         SObject obj = controller.getRecord();
         if(obj.Id == null){
             //鍒濆鍖栧姞杞藉��
             obj.put('OwnerId', UserInfo.getUserId());
+        } else {
+            User_FaultInfo__c userFaultInfo = [select CONTACT__c, UFContact__c from User_FaultInfo__c where id=:obj.Id];
+            System.debug('userFaultInfo: ' + userFaultInfo);
+            if (userFaultInfo.CONTACT__c != null) {
+                List<Contact> contact = [select AWS_Data_Id__c,Name from Contact where id=:userFaultInfo.CONTACT__c];
+                if(contact.size()>0){
+                    if (contact[0].AWS_Data_Id__c != null && contact[0].AWS_Data_Id__c != '') {
+                        contactAWSDataId = contact[0].AWS_Data_Id__c;
+                    }else {
+                        contactName = contact[0].Name;
+                    }
+                }
+            }else {
+                contactAWSDataId = '鏃�';
+                contactName = '鏃�';
+            }
+            if (userFaultInfo.UFContact__c != null) {
+                List<Contact> contact = [select AWS_Data_Id__c,Name from Contact where id=:userFaultInfo.UFContact__c];
+                if(contact.size()>0){
+                    if (contact[0].AWS_Data_Id__c != null && contact[0].AWS_Data_Id__c != '') {
+                        endUserDAWSDataId = contact[0].AWS_Data_Id__c;
+                    }else {
+                        endUserDName = contact[0].Name;
+                    }
+                }
+            }else {
+                endUserDAWSDataId = '鏃�';
+                endUserDName = '鏃�';
+            }
         }
-        //contact淇℃伅锛堟悳绱㈡煡璇uery url鐢級
-        staticResourceContact = JSON.serialize(PIHelper.getPIIntegrationInfo('Contact'));
     }
 
     
diff --git a/force-app/main/default/classes/OrderTriggerHandler.cls b/force-app/main/default/classes/OrderTriggerHandler.cls
index ad164af..cc066e7 100644
--- a/force-app/main/default/classes/OrderTriggerHandler.cls
+++ b/force-app/main/default/classes/OrderTriggerHandler.cls
@@ -2833,7 +2833,7 @@
                 System.debug( !roleMap.containsKey(orOne.OpportunityId));
                 System.debug(orOne.EndUserD__c + '++'+ roleMap.get(orOne.OpportunityId));
 
-                if(oppAccountMap.get(orOne.OpportunityId) != orOne.AccountId || !roleMap.containsKey(orOne.OpportunityId) || orOne.EndUserD__c != roleMap.get(orOne.OpportunityId)){
+                /*if(oppAccountMap.get(orOne.OpportunityId) != orOne.AccountId || !roleMap.containsKey(orOne.OpportunityId) || orOne.EndUserD__c != roleMap.get(orOne.OpportunityId)){
                     // 鑾峰彇鐢ㄦ埛Id
                     String userId = UserInfo.getUserId().subString(0,15);
                     if (String.isNotBlank(getUserId)) {
@@ -2855,7 +2855,7 @@
                     }
                     
                     
-                }
+                }*/
             }
         }
     }
diff --git a/force-app/main/default/classes/PIHelper.cls b/force-app/main/default/classes/PIHelper.cls
index 3572a68..117d9aa 100644
--- a/force-app/main/default/classes/PIHelper.cls
+++ b/force-app/main/default/classes/PIHelper.cls
@@ -17,7 +17,88 @@
             return '';
         }    
     }
+    // confirm file transaction
+    // @future(callout =true)
+    public static void confirmFileTrans(String module,Integer isSuccess, String   sfRecordId ,String transId ,String token,String transUrl){
+        Boolean result =false;
+        Transaction_Log__c traLog = new Transaction_Log__c();
+        traLog.Module__c = 'ConfirmFileTransaction '+module;
+        traLog.Interface_URL__c = transUrl;
+        traLog.TransId__c = transId;
+        // traLog.SFRecordId__c=sfRecordId;
+        Integer MaxLogColumnLength = 131072;
+        try {
+            Http http = new Http();
+            HttpRequest request = new HttpRequest();
+            request.setEndpoint(transUrl);
+            request.setMethod('POST');
+            request.setHeader('pi-token',token);
+            request.setHeader('Content-Type', 'application/json');
+            TransRequestBody requestBody =new TransRequestBody();
+            requestBody.isSuccess=isSuccess;
+            requestBody.sfRecordId=sfRecordId;
+            requestBody.txId =transId;
+            request.setBody(JSON.serialize(requestBody));
+            system.debug('request---'+request.tostring());
+            HttpResponse response = http.send(request);
+            system.debug('token--'+token);
+            system.debug('confirm result--'+response.getBody());
+            Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
+            result = (Boolean)results.get('success');
+            System.debug('result = ' + result);
+            traLog.Status__c = 'success';
+            String res=response.getBody();
+            traLog.Response__c=res.substring(0, (res.length() > MaxLogColumnLength ? MaxLogColumnLength : res.length()));
+           
+        } catch (Exception e) {  
+            traLog.Status__c = 'fail';
+            traLog.Response__c = e.getMessage();    
+        }
+        insert traLog;
+    }
+     // confirm tx transaction
 
+    public static void confirmTrans(String module,Integer isSuccess, String   sfRecordId ,String transId ,String token,String transUrl,List<idList> idList){
+        Boolean result =false;
+        Transaction_Log__c traLog = new Transaction_Log__c();
+        traLog.Module__c = 'Confirm Transaction '+module;
+        traLog.Interface_URL__c = transUrl;
+        traLog.TransId__c = transId;
+        Integer MaxLogColumnLength = 131072;
+        if (!String.isEmpty(sfRecordId)) {
+        traLog.SFRecordId__c=sfRecordId;
+        }else {
+        traLog.SFRecordId__c=JSON.serialize(idList);
+        }
+        
+        try {
+            Http http = new Http();
+            HttpRequest request = new HttpRequest();
+            request.setEndpoint(transUrl);
+            request.setMethod('POST');
+            request.setHeader('pi-token',token);
+            request.setHeader('Content-Type', 'application/json');
+            TransactionRequestBody requestBody =new TransactionRequestBody();
+            requestBody.isSuccess=isSuccess;
+            requestBody.sfRecordId=sfRecordId;
+            requestBody.idList=idList;
+            requestBody.txId =transId;
+            request.setBody(JSON.serialize(requestBody));
+            system.debug('request---'+request.tostring());
+            HttpResponse response = http.send(request);
+            system.debug('confirm result--'+response.getBody());
+            Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
+            result = (Boolean)results.get('success');
+            System.debug('result = ' + result);
+            traLog.Status__c = 'success';
+            String res=response.getBody();
+            traLog.Response__c=res.substring(0, (res.length() > MaxLogColumnLength ? MaxLogColumnLength : res.length()));
+        } catch (Exception e) {  
+            traLog.Status__c = 'fail';
+            traLog.Response__c = e.getMessage();    
+        }
+        insert traLog;
+    }
     // Use this log method
     public static void saveTransLog(String module,String awsDataId,String sfId, String transId,String content,String status,String respMsg){
         Transaction_Log__c traLog = new Transaction_Log__c();
@@ -31,14 +112,42 @@
         traLog.Interface_URL__c = traLog.Module__c;
         insert traLog;
     }
+    //save qianlima log method add sushanhu 20220324
+    // model 0 涓烘枃浠� 1涓烘暟鎹�
+    public static void insertConfirmTrans(String module,Integer isSuccess, String   sfRecordId ,String transId ,Integer model,String transUrl,List<idList> idList){
+        Boolean result =false;
+        Transaction_Log__c traLog = new Transaction_Log__c();
+        if (model==0) {
+            traLog.Module__c = 'ConfirmFileTransaction '+module;
+        }else {
+            traLog.Module__c = 'Confirm Transaction '+module;
+        }
+        traLog.Interface_URL__c = transUrl;
+        traLog.TransId__c = transId;
+        Integer MaxLogColumnLength = 131072;
+        if (!String.isEmpty(sfRecordId)) {
+            traLog.Request__c=sfRecordId.substring(0, (sfRecordId.length() > MaxLogColumnLength ? MaxLogColumnLength : sfRecordId.length()));
+        }else {
+            String sfIds =JSON.serialize(idList);
+            traLog.Request__c=sfIds.substring(0, (sfIds.length() > MaxLogColumnLength ? MaxLogColumnLength : sfIds.length()));
+        }
+        if(isSuccess==0){
+            traLog.Status__c = 'fail';
+        } else {
+            traLog.Status__c='success';
+        }  
+        insert traLog;
+    }
     public static PIIntegration getPIIntegrationInfo(String sobjectType){
         PIIntegration piIntegration = new PIIntegration();
         //鏌ヨurl
+        System.debug('thhsobjectType = ' + sobjectType);
+        // PI_Policy_Configuration__c config = [SELECT Full_New_URL__c,Full_New_Encrypt_URL__c,Full_Update_Encrypt_URL__c,Full_Search_URL__c,Full_Update_URL__c,Full_Undelete_URL__c,Full_Read_URL__c,Full_Delete_URL__c,Full_View_Unified_Contact_URL__c,TransactionURL__c FROM PI_Policy_Configuration__c WHERE Sobject_Type__c =:sobjectType];
         PI_Policy_Configuration__c config = [select Full_New_URL__c,Full_Search_URL__c,Full_Update_URL__c,Full_Undelete_URL__c,Full_Read_URL__c,Full_Delete_URL__c,TransactionURL__c from PI_Policy_Configuration__c where Sobject_Type__c =: sobjectType];
-        System.debug('config = ' + config);
+        System.debug('thhconfig = ' + config);
 
         //鑾峰彇appid鍜宎ppsecret
-        AWS_Integration_Info__mdt awsConfiguration = [SELECT App_Id__c,Token_URL__c,App_Secret__c,Host_URL__c FROM AWS_Integration_Info__mdt  WHERE DeveloperName = 'AWS_Default_Configuration'];
+        AWS_Integration_Info__mdt awsConfiguration = [SELECT App_Id__c,Max_Query_Number__c,Token_URL__c,App_Secret__c,Host_URL__c FROM AWS_Integration_Info__mdt  WHERE DeveloperName = 'AWS_Default_Configuration'];
         if (awsConfiguration == null) {
             System.debug('AWS_Integration_Info__mdt娌¢厤缃�');
             return null;
@@ -60,13 +169,14 @@
             request.setEndpoint(url);
             request.setMethod('GET');
             HttpResponse response = http.send(request);
-            System.debug('response = ' + response);
+			system.debug('response.getBody()='+response.getBody());
             Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
             token = (String)results.get('object');
             System.debug('token = ' + token);
         }catch(Exception e){
-            // System.debug(e.getMessage());
-            // System.debug(e.getStackTraceString());
+            system.debug(e.getMessage());
+            system.debug(e.getStackTraceString());
+            
             Transaction_Log__c traLog = new Transaction_Log__c();
             traLog.Module__c = 'Get Token';
             traLog.Status__c = 'fail';
@@ -78,6 +188,7 @@
         //Insert Get Token Log
 
         //鑾峰彇鏁忔劅瀛楁
+        // piIntegration.PIDetails = [select id,PI_Policy_Configuration__r.Full_New_URL__c,PI_Policy_Configuration__r.Full_New_Encrypt_URL__c,PI_Policy_Configuration__r.Full_Update_Encrypt_URL__c, Enable_Encrypt__c, SF_Field_API_Name__c,SF_Field_Encrypted_API__c, AWS_Field_API__c,AWS_Encrypted_Field_API__c,Field_Type__c from PI_Field_Policy_Detail__c  where PI_Policy_Configuration_Name__c =:sobjectType and Enable_Encrypt__c=true];
         piIntegration.PIDetails = [select id,PI_Policy_Configuration__r.Full_New_URL__c, Enable_Encrypt__c, SF_Field_API_Name__c,SF_Field_Encrypted_API__c, AWS_Field_API__c,AWS_Encrypted_Field_API__c,Field_Type__c from PI_Field_Policy_Detail__c  where PI_Policy_Configuration_Name__c =:sobjectType and Enable_Encrypt__c=true];
         List<String> vLookUpFields = new List<String>();
         List<String> PIFields = new List<String>();
@@ -92,11 +203,15 @@
         System.debug('PIFields = ' + PIFields.toString());
 
         //濉厖鏁版嵁
+        piIntegration.maxQueryNumber = Integer.valueof(awsConfiguration.Max_Query_Number__c);
         piIntegration.newUrl = config.Full_New_URL__c;
         piIntegration.updateUrl = config.Full_Update_URL__c;
         piIntegration.queryUrl = config.Full_Read_URL__c;
         piIntegration.deleteUrl = config.Full_Delete_URL__c;
         piIntegration.undeleteUrl = config.Full_Undelete_URL__c;
+        // piIntegration.viewUnifiedContactUrl = config.Full_View_Unified_Contact_URL__c;
+        // piIntegration.newEncryptUrl = config.Full_New_Encrypt_URL__c;
+        // piIntegration.updateEncryptUrl = config.Full_Update_Encrypt_URL__c;
         piIntegration.transactionURL = config.TransactionURL__c;
         piIntegration.hostUrl = awsConfiguration.Host_URL__c;
         piIntegration.searchUrl = config.Full_Search_URL__c;
@@ -110,6 +225,7 @@
         return piIntegration;
     }
     global class PIIntegration{
+        public Integer maxQueryNumber{set;get;}
         public String sobjectPrefix{set;get;}
         public String searchUrl{set;get;}
         public String newUrl{set;get;}
@@ -117,6 +233,9 @@
         public String queryUrl{set;get;}
         public String deleteUrl{set;get;}
         public String undeleteUrl{set;get;}
+        public String viewUnifiedContactUrl{set;get;}
+        public String newEncryptUrl{set;get;}
+        public String updateEncryptUrl{set;get;}
         public String hostUrl{set;get;}
         public String token{set;get;}
         public String awsAppId{set;get;}
@@ -126,4 +245,20 @@
         public List<String> PIFields{set;get;}
         public List<PI_Field_Policy_Detail__c > PIDetails{set;get;}
     }
+    global class TransRequestBody{
+        public Integer isSuccess{set;get;}
+        public String sfRecordId{set;get;}
+        public String txId{set;get;}
+        
+    }
+    global class TransactionRequestBody{
+        public Integer isSuccess{set;get;}
+        public String sfRecordId{set;get;}
+        public String txId{set;get;}
+        public List<idList> idList{set;get;} 
+    }
+    global class idList{
+        public String awsId{set;get;}
+        public String sfRecordId{set;get;}
+    }
 }
\ No newline at end of file
diff --git a/force-app/main/default/classes/SBG203Rest.cls b/force-app/main/default/classes/SBG203Rest.cls
index 2d69b2c..fb055d9 100644
--- a/force-app/main/default/classes/SBG203Rest.cls
+++ b/force-app/main/default/classes/SBG203Rest.cls
@@ -1,5 +1,10 @@
 @RestResource(urlMapping = '/SBG203/*')
 global with sharing class SBG203Rest {
+    //add Response to aws 20220311 add sushanhu for pipl
+   
+    static Boolean SFStatus=true;
+    static String SFMessage='';
+    //add Response to aws 20220311 add sushanhu for pipl
 
     global class GeDatas {
         public NFMUtil.Monitoring Monitoring;
@@ -125,6 +130,19 @@
         public String ContactMobilePhone; //鏀惰揣浜烘墜鏈�
         public String CITY1; //鏀惰揣浜哄煄甯�
         public String ContactEnglishName; //鑻辨枃鍚嶇О
+        // add for pi sushanhu 20220309 start
+        public String ContactNameEncrypted;     //鏀惰揣浜哄悕绉板瘑鏂�
+        public String ContactPhoneEncrypted;    //鏀惰揣浜虹數璇濆瘑鏂�
+        public String PostalCodeEncrypted;      //閭紪瀵嗘枃
+        public String ContactAddressEncrypted;  //鏀惰揣鍦板潃瀵嗘枃
+        public String ContactMobilePhoneEncrypted; //鏀惰揣浜烘墜鏈哄瘑鏂�
+        public String ContactEnglishNameEncrypted; //鑻辨枃鍚嶇О瀵嗘枃
+        //delete by sushanhu 鍜屽鎴锋矡閫� 鍚庢湡 涓嶈祴鍊艰繖涓瓧娈� satrt 20220411
+        // public String EnglishAddress; //鑻辨枃鍦板潃
+        // public String EnglishAddressEncrypted;// 鑻辨枃鍦板潃瀵嗘枃
+        //delete by sushanhu 鍜屽鎴锋矡閫� 鍚庢湡 涓嶈祴鍊艰繖涓瓧娈� end 20220411
+        public String DataId;                       //aws瀛樺偍鍑嵁
+        // add for pi sushanhu 20220309 end
     }
 
     // 閿�鍞汉灞傜骇
@@ -186,7 +204,7 @@
         // 鍙栧緱鎺ュ彛浼犺緭鍐呭
         String strData = RestContext.request.requestBody.toString();
         GeDatas ges = (GeDatas) JSON.deserializeStrict(strData, GeDatas.class);
-
+        NFMUtil.NFMResponse result = NFMUtil.getNFMResponse(); //add for pipl sushanhu 20220311
         if (ges == null) {
             return;
         }
@@ -204,8 +222,17 @@
         RestResponse res = RestContext.response;
         res.addHeader('Content-Type', 'application/json');
         res.statusCode = 200;
-        String jsonResponse = '{"status": "0", "Message":""}';
+        //update response to aws 20220311 sushanhu for pipl start
+        // String jsonResponse = '{"status": "0", "Message":""}';
+        // res.responseBody = blob.valueOf(jsonResponse);
+        //updata response toAWS
+        
+        result.SFStatus=SFStatus;
+        result.SFMessage=SFMessage;
+        String jsonResponse =JSON.serialize(result);
+        system.debug('result---'+jsonResponse);
         res.responseBody = blob.valueOf(jsonResponse);
+         //update response to aws 20220311 sushanhu for pipl end
         return;
     }
 
@@ -1085,18 +1112,45 @@
                     con.PhoneD__c = consigneeInfo.ContactPhone;
                     con.Postcode__c = consigneeInfo.PostalCode;
                     con.PostcodeD__c = consigneeInfo.PostalCode;
-                    con.Address1__c = gda.BPType == '22' ? gda.RegisterAddress : consigneeInfo.ContactAddress;
-                    con.Address1D__c = gda.BPType == '22' ? gda.RegisterAddress : consigneeInfo.ContactAddress;
-                    con.EnglishAddress__c = gda.BPType == '22' ? gda.STR_SUPPL1 : '';
+                    //update to aws pi start 20220309 sushanhu
+                    // con.Address1__c = gda.BPType == '22' ? gda.RegisterAddress : consigneeInfo.ContactAddress;
+                    // con.Address1D__c = gda.BPType == '22' ? gda.RegisterAddress : consigneeInfo.ContactAddress;
+                    // con.EnglishAddress__c = gda.BPType == '22' ? gda.STR_SUPPL1 : '';
+                    //鍒ゆ柇鍦╝ws鎵ц
+                    con.Address1__c= consigneeInfo.ContactAddress;
+                    con.Address1D__c= consigneeInfo.ContactAddress;
+                    con.Address1_Encrypted__c = consigneeInfo.ContactAddressEncrypted;
+                    con.Address1D_Encrypted__c = consigneeInfo.ContactAddressEncrypted;
+                    con.Postcode_Encrypted__c = consigneeInfo.PostalCodeEncrypted;
+                    con.PostcodeD_Encrypted__c = consigneeInfo.PostalCodeEncrypted;
+                    //delete by sushanhu 鍜屽鎴锋矡閫� 鍚庢湡 涓嶈祴鍊艰繖涓瓧娈� satrt 20220411
+                    // con.EnglishAddress__c = gda.BPType == '22' ? consigneeInfo.EnglishAddress : '';
+                    // con.EnglishAddress_Encrypted__c=gda.BPType == '22' ?consigneeInfo.EnglishAddressEncrypted : '';
+                     //delete by sushanhu 鍜屽鎴锋矡閫� 鍚庢湡 涓嶈祴鍊艰繖涓瓧娈� end 20220411
+                    //update to aws pi start 20220309 sushanhu end
                     if (String.isNotBlank(consigneeInfo.ContactEnglishName) && gda.BPType == '22') {
-                        con.LastName = consigneeInfo.ContactName + '(' + consigneeInfo.ContactEnglishName + ')';
+                        //update for pipl  鍜屽鎴锋矡閫� 瀵嗘枃鏄剧ず浣嶆暟涓嶅彉 20220411 start
+                        // con.LastName = consigneeInfo.ContactName + '(' + consigneeInfo.ContactEnglishName + ')';
+                        con.LastName = consigneeInfo.ContactName ;
+                         //update for pipl  鍜屽鎴锋矡閫� 瀵嗘枃鏄剧ず浣嶆暟涓嶅彉 20220411 end
+
                         con.FirstName = null;
+                        con.FirstName_Encrypted__c =null; ////add for pipl susahnhu 20220311
                         con.ContactEnglishName__c = consigneeInfo.ContactEnglishName;
+                        con.ContactEnglishName_Encrypted__c= consigneeInfo.ContactEnglishNameEncrypted;//add for pipl susahnhu 20220311
                     } else {
                         con.LastName = consigneeInfo.ContactName;
                         con.FirstName = null;
+                        con.FirstName_Encrypted__c =null; ////add for pipl susahnhu 20220311
                     }
-
+                    //add for pipl susahnhu 20220311 start
+                    con.LastName_Encrypted__c = consigneeInfo.ContactNameEncrypted;
+                    con.AWS_Data_Id__c = consigneeInfo.DataId;// AWS 瀛樺偍鍑嵁 add for pipl susahnhu 20220311
+                    con.MobilePhone_Encrypted__c = consigneeInfo.ContactPhoneEncrypted;
+                    con.MobilePhoneD_Encrypted__c = consigneeInfo.ContactPhoneEncrypted;
+                    con.Phone_Encrypted__c = consigneeInfo.ContactPhoneEncrypted;
+                    con.PhoneD_Encrypted__c = consigneeInfo.ContactPhoneEncrypted;
+                      //add for pipl susahnhu 20220311 end
                     con.ContactStatus__c = 'Active';
                     con.ContactStatusD__c = 'Active';
                     con.StatusD__c = 'Pass';
diff --git a/force-app/main/default/classes/SWOController.cls b/force-app/main/default/classes/SWOController.cls
index 5c6dbe2..8d92469 100644
--- a/force-app/main/default/classes/SWOController.cls
+++ b/force-app/main/default/classes/SWOController.cls
@@ -32,21 +32,28 @@
 	public RepairPart__c repairPart{get;set;}
 
 	private String SwoStatus;
+    public String staticResource { get; private set; }// 20220313 PI鏀归�� by Chen Yanan
+    public String contactstaticResource { get; private set; }// 20220313 PI鏀归�� by Chen Yanan
+    public String contactAWSDataId { get; private set; }// 20220313 PI鏀归�� by Chen Yanan
+    public Boolean isNew { get; set; }// 20220313 PI鏀归�� by Chen Yanan
 	//ASSIGNEDTO__c
 	public SWOController() {
 		
 	}
 
 	public SWOController(ApexPages.StandardController stdController) {
+		isNew = true;
 		swoid = System.currentPageReference().getParameters().get('id');
 		caseId = System.currentPageReference().getParameters().get('caseId');
 		accId = System.currentPageReference().getParameters().get('accId');
 		conId = System.currentPageReference().getParameters().get('conId');
 		type = System.currentPageReference().getParameters().get('type');
-		System.debug(caseId);
+        staticResource = JSON.serialize(PIHelper.getPIIntegrationInfo('SWO__c'));// 20220313 PI鏀归�� by Chen Yanan
+        contactstaticResource = JSON.serialize(PIHelper.getPIIntegrationInfo('Contact'));// 20220313 PI鏀归�� by Chen Yanan
 	}
 
 	public void init() {
+
 		lineCount = 0;
 		//鑾峰彇鍒濆URL
 		baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
@@ -66,12 +73,15 @@
 		User_FaultInfo__c ca = new User_FaultInfo__c();
 		List<SWO__c> temp = new List<SWO__c>();
 		if (caseId != null) {
-			ca = [select id, NUMBER__c,COMPANY__c,CONTACT__c,SUBJECT__c from User_FaultInfo__c where id = : caseId];
+			// ca = [select id, NUMBER__c,COMPANY__c,CONTACT__c,SUBJECT__c from User_FaultInfo__c where id = : caseId];
+			ca = [select id, NUMBER__c,COMPANY__c,CONTACT__c,SUBJECT__c, CONTACT__r.AWS_Data_Id__c, CONTACT__r.Name, CONTACT__r.Email from User_FaultInfo__c where id = : caseId];// 20220313 PI鏀归�� by Chen Yanan
 			temp = [select id from SWO__c where CASE_NUMBER__c = :caseId];
+			contactAWSDataId = String.isNotBlank(ca.CONTACT__r.AWS_Data_Id__c)?ca.CONTACT__r.AWS_Data_Id__c:'';
 		}
 		System.debug('ca' + ca.NUMBER__c);
 		System.debug('temp' + temp.size());
 		if (swoid != null) {
+			isNew = false;// 20220313 PI鏀归�� by Chen Yanan
 			//鍒濆鍖朣WO
 			Schema.DescribeSobjectResult d_swo = SWO__c.sObjectType.getDescribe();
 			Map<String, Schema.SObjectField> d_swo_map = d_swo.fields.getMap();
@@ -83,11 +93,15 @@
 				}
 				fields_odr += field;
 			}
-			soql_swo += fields_odr;
+			// soql_swo += fields_odr;
+			soql_swo += fields_odr + ', CONTACT__r.AWS_Data_Id__c, CONTACT__r.Name, CONTACT__r.Email ';// 20220313 PI鏀归�� by Chen Yanan
 			soql_swo += ' from SWO__c where Id = \'' + swoid + '\'';
+			System.debug('soql_swo: ' + soql_swo);// 20220313 PI鏀归�� by Chen Yanan
 			List<SWO__c> swoList = Database.query(soql_swo);
+			System.debug('swoList: ' + swoList);// 20220313 PI鏀归�� by Chen Yanan
 			if (swoList.size() > 0) {
 				swo = swoList[0];
+				contactAWSDataId = String.isNotBlank(swo.CONTACT__r.AWS_Data_Id__c)?swo.CONTACT__r.AWS_Data_Id__c:'';
 			}
 			//鍒濆鍖栬褰昐WO 鍘熷ASSIGNED TO锛屼繚瀛樻椂鍒ゆ柇鐢ㄦ埛鏄惁鍙樻洿锛屽鏋滃彉鏇寸粰鐢ㄦ埛鍙戦�侀偖浠�
 			assignedUser = swo.ASSIGNEDTO__c;
@@ -168,6 +182,7 @@
 				swo.CONTACT__c = conId;
 			}
 			swo.SWO_STATUS__c = 'Not Started';
+			System.debug('SWO: ' + swo);
 		}
 		SwoStatus = swo.SWO_STATUS__c;
 	}
@@ -266,6 +281,7 @@
 			// 	SWOSTATUS_Closed_AddAttachment();//SWOSTATUS_Closed_AddAttachment
 			// }
 		}
+		System.debug('swo save:' + swo);		// Update By Yanan
 		if (swoid == null) {
 			swo.CASE_NUMBER__c = caseId;
 			insert swo;
diff --git a/force-app/main/default/classes/SearchContactController.cls b/force-app/main/default/classes/SearchContactController.cls
index f657e3b..c2f9efa 100644
--- a/force-app/main/default/classes/SearchContactController.cls
+++ b/force-app/main/default/classes/SearchContactController.cls
@@ -7,28 +7,42 @@
  *      02/08/2022 - Bubba Li - Initial Code.
  * 
  * */
-public without sharing class SearchContactController {
+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 Boolean showHeader{set;get;}
+    public static Boolean checkNullString(String inputString){
+        if(String.isEmpty(inputString)||String.isBlank(inputString)){
+            return true;
+        }
+        return false;
+    }
     public SearchContactController() {
         String accountId = ApexPages.currentPage().getParameters().get('accountId');
+        searchKeyWord = ApexPages.currentPage().getParameters().get('searchContactKeyWord');
+        aId = accountId;
         PIPL_Search_Contact_Label = Label.PIPL_Search_Contact_Label;
+        showHeader = false;
+        if(ApexPages.currentPage().getParameters().containskey('showheader')){
+            showHeader = Boolean.valueof(ApexPages.currentPage().getParameters().get('showheader'));
+        }
         //1. Query Contact by accountId
         List<Contact> conList = new List<Contact>();
         system.debug('Account Id from Front-end:'+accountId);
-        if(String.isNotBlank(accountId) && String.isNotEmpty(accountId)){
-            String accountIdStr = '';
-            String[] accountIds = accountId.split(',');
-            List<String> accountIdList = new List<String>();
-            for(String s : accountIds){
-                accountIdList.add(s);
+        if(checkNullString(accountId)&&checkNullString(searchKeyWord)){
+            conList = new List<Contact>();
+        }else{
+            if(checkNullString(accountId)){
+                conList = new List<Contact>(); 
+            }else {
+                conList = new List<Contact>([select Id,AWS_Data_Id__c,Account.Name from Contact  where AccountId=:accountId and AWS_Data_Id__c!='']); 
             }
-            conList = new List<Contact>([select Id,AWS_Data_Id__c from Contact where AccountId in:accountIdList and AWS_Data_Id__c!='']);
-            System.debug('conList:'+conList);
-        }        
+            
+        }    
         //2. Prepare the Contact Info
         Map<String,Contact> awsIdToContactMap = new Map<String,Contact>();
         List<String> conAWSIds = new List<String>();
@@ -42,21 +56,48 @@
     }
 
     @RemoteAction
-    public static Response searchContacts(String awsContactIds) {
+    public static Response searchContacts(String awsContactIds,String searchContactName,String accountId) {
+        system.debug('awsContactIds = ' + awsContactIds);
         Response resp = new Response();
         resp.status = 'fail';
-        if(String.isBlank(awsContactIds)||String.isEmpty(awsContactIds)){
-            return resp;
-        }
-        List<String> awsDataIds = (List<String>) JSON.deserialize(awsContactIds, List<String>.class);
         Map<String,Contact> awsIdToContactMapTemp = new Map<String,Contact>();
-        List<Contact> conListTemp = new List<Contact>([select Id,AWS_Data_Id__c from Contact where AWS_Data_Id__c in:awsDataIds]);
-        for(Contact con:conListTemp){
-            awsIdToContactMapTemp.put(con.AWS_Data_Id__c,con);
+        if(!checkNullString(awsContactIds)){
+            List<String> awsDataIds = (List<String>) JSON.deserialize(awsContactIds, List<String>.class);
+            List<Contact> conListTemp = new List<Contact>();
+            if(!checkNullString(accountId)){
+                conListTemp = new List<Contact>([select Id,AWS_Data_Id__c,Account.Name from Contact where AccountId=:accountId and AWS_Data_Id__c in:awsDataIds]);
+            }else {
+                conListTemp = new List<Contact>([select Id,AWS_Data_Id__c,Account.Name from Contact where AWS_Data_Id__c in:awsDataIds]);
+            }
+            for(Contact con:conListTemp){
+                awsIdToContactMapTemp.put(con.AWS_Data_Id__c,con);
+            }
         }
-        if(awsIdToContactMapTemp.keySet().size()>0){
+        System.debug('awsIdToContactMapTemp = ' + awsIdToContactMapTemp);
+        Map<String,Contact> noPIContactMapTemp = new Map<String,Contact>();
+        List<Contact> 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);
+            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';
+        List<Contact> conListTemp = new List<Contact>([select Id,Name,Account.Name,Phone,Email,MobilePhone from Contact where Name like :contactName]);
+        if(conListTemp.size() > 0){
+            resp.status = 'success';
+            resp.message = JSON.serialize(conListTemp);
         }
         return resp;
     }
@@ -64,5 +105,6 @@
     public class Response{
         public String message{set;get;}
         public String status{set;get;}
+        public String noPIContactList{set;get;}
     }
 }
\ No newline at end of file
diff --git a/force-app/main/default/classes/SearchContactController.cls-meta.xml b/force-app/main/default/classes/SearchContactController.cls-meta.xml
index 40d6793..dd61d1f 100644
--- a/force-app/main/default/classes/SearchContactController.cls-meta.xml
+++ b/force-app/main/default/classes/SearchContactController.cls-meta.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
-    <apiVersion>54.0</apiVersion>
+    <apiVersion>52.0</apiVersion>
     <status>Active</status>
 </ApexClass>
diff --git a/force-app/main/default/classes/SearchContactControllerTest.cls b/force-app/main/default/classes/SearchContactControllerTest.cls
index 092f899..f455f2b 100644
--- a/force-app/main/default/classes/SearchContactControllerTest.cls
+++ b/force-app/main/default/classes/SearchContactControllerTest.cls
@@ -8,15 +8,18 @@
         TestDataUtility.CreatePIPolicyConfiguration('Contact');
         Contact con = TestDataUtility.CreateContacts(1)[0];
         con.AWS_Data_Id__c = 'davdsvgrqcx';
+        con.AccountId = '0010K00001aqioMQAQ';
         update con;
         List<String> awsList = new List<String>();
         awsList.add(con.AWS_Data_Id__c);
+        awsList.add(con.AccountId);
         String awsListJson = JSON.serialize(awsList);
 
         String url = ApexPages.currentPage().getParameters().put('accountId',con.AccountId);
         Test.startTest();
         SearchContactController scc = new SearchContactController();
-        SearchContactController.searchContacts(awsListJson);
+        SearchContactController.searchContacts(awsListJson,'','');
+        SearchContactController.searchContactsNoPI('');
         scc.searchKeyWord = 'test';
         Test.stopTest();
     }
diff --git a/force-app/main/default/pages/NewAndEditContact.page b/force-app/main/default/pages/NewAndEditContact.page
index f624ed2..ce31deb 100644
--- a/force-app/main/default/pages/NewAndEditContact.page
+++ b/force-app/main/default/pages/NewAndEditContact.page
@@ -1,11 +1,4 @@
-<!--
-@description       : 
-@author            : ChangeMeIn@UserSettingsUnder.SFDoc
-@group             : 
-@last modified on  : 03-08-2022
-@last modified by  : ChangeMeIn@UserSettingsUnder.SFDoc
--->
-<apex:page standardController="Contact" extensions="NewAndEditContactController" id="page">
+<apex:page standardController="Contact" extensions="NewAndEditContactController" id="page" action="{!PageLoad}">
     <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" />
     <script src="../../soap/ajax/53.0/connection.js" type="text/javascript"></script>
     <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
@@ -246,7 +239,7 @@
                 
                 // let e1 = document.getElementById(api_id_map[field_api_name]);
                 // if(!result[field_api_name] && e1 && e1.value){
-                // 	result[field_api_name] = e1.value;
+                //  result[field_api_name] = e1.value;
                 // }
             }
             return result;
@@ -336,7 +329,7 @@
             // Check Required Field
             let checkRequiredFieldMsgResult = checkRequiredFieldMsg(sobjJson);
             if (checkRequiredFieldMsgResult) {
-                alertErrorMessage('requiredErrorMsg' + checkRequiredFieldMsgResult);
+                alertErrorMessage('{!$Label.Input_Required_Field_Msg}' + checkRequiredFieldMsgResult);
                 return
             }
             // //3. Prepare the payload for New PI API To AWS - To Do
@@ -446,13 +439,13 @@
                 document.querySelectorAll("[data-id='OwnerId']")[1].classList.add("disabledbutton");
 
                 if({!isNewMode}){
-                	document.getElementById("page:form:block:j_id50:0:j_id51:j_id52:0:j_id53_lkid").value = '{!account.Id}';
-                	document.getElementById("page:form:block:j_id50:0:j_id51:j_id52:0:j_id53_lkold").value = '{!account.Name}';
-                	document.getElementById("page:form:block:j_id50:0:j_id51:j_id52:0:j_id53").value = '{!account.Name}';
-                	document.getElementById("page:form:block:j_id50:0:j_id51:j_id52:5:j_id53").value = '{!account.PhoneD__c}';
-                	document.getElementById("page:form:block:j_id50:0:j_id51:j_id52:8:j_id53").value = '{!account.FaxD__c}';
-                	document.getElementById("page:form:block:j_id50:1:j_id51:j_id52:0:j_id53").value = '{!account.PostCodeD__c}';
-                	document.getElementById("page:form:block:j_id50:2:j_id51:j_id52:0:j_id53").value = '{!account.Address1D__c}';
+                    document.getElementById("page:form:block:j_id50:0:j_id51:j_id52:0:j_id53_lkid").value = '{!account.Id}';
+                    document.getElementById("page:form:block:j_id50:0:j_id51:j_id52:0:j_id53_lkold").value = '{!account.Name}';
+                    document.getElementById("page:form:block:j_id50:0:j_id51:j_id52:0:j_id53").value = '{!account.Name}';
+                    document.getElementById("page:form:block:j_id50:0:j_id51:j_id52:5:j_id53").value = '{!account.PhoneD__c}';
+                    document.getElementById("page:form:block:j_id50:0:j_id51:j_id52:8:j_id53").value = '{!account.FaxD__c}';
+                    document.getElementById("page:form:block:j_id50:1:j_id51:j_id52:0:j_id53").value = '{!account.PostCodeD__c}';
+                    document.getElementById("page:form:block:j_id50:2:j_id51:j_id52:0:j_id53").value = '{!account.Address1D__c}';
                 }
             });
             </script>
diff --git a/force-app/main/default/pages/NewAndEditLoanerApplication.page b/force-app/main/default/pages/NewAndEditLoanerApplication.page
index 3d20ffc..5881c4d 100644
--- a/force-app/main/default/pages/NewAndEditLoanerApplication.page
+++ b/force-app/main/default/pages/NewAndEditLoanerApplication.page
@@ -183,13 +183,13 @@
             // }
             let returnPhone = document.querySelector(textReturnPhone);
 
-            if(returnPhone && !/^1[3|5|8|7][0-9]\d{4,8}$/.test(returnPhone.value)){
+            if(false && returnPhone && !/^1[3|5|8|7][0-9]\d{4,8}$/.test(returnPhone.value)){
                 error_msg += ';	杩斿搧浜虹數璇濆彿鐮侀敊璇�';
             }
 
             let phone = document.querySelector(textPhone);
 
-            if(phone && !/^1[3|5|8|7][0-9]\d{4,8}$/.test(phone.value)){
+            if(false && phone && !/^1[3|5|8|7][0-9]\d{4,8}$/.test(phone.value)){
                 error_msg += ';	鏀朵欢浜虹數璇濆彿鐮侀敊璇�';
             }
 
@@ -343,7 +343,7 @@
             // Check Required Field
             let checkRequiredFieldMsgResult = checkRequiredFieldMsg(sobjJson);
             if (checkRequiredFieldMsgResult) {
-                alertErrorMessage('requiredErrorMsg' + checkRequiredFieldMsgResult);
+                alertErrorMessage('{!$Label.Input_Required_Field_Msg}' + checkRequiredFieldMsgResult);
                 return
             }
             // //3. Prepare the payload for New PI API To AWS - To Do
diff --git a/force-app/main/default/pages/NewAndEditLoanerUser.page b/force-app/main/default/pages/NewAndEditLoanerUser.page
index ecf637b..283c29a 100644
--- a/force-app/main/default/pages/NewAndEditLoanerUser.page
+++ b/force-app/main/default/pages/NewAndEditLoanerUser.page
@@ -332,7 +332,7 @@
             // Check Required Field
             let checkRequiredFieldMsgResult = checkRequiredFieldMsg(sobjJson);
             if (checkRequiredFieldMsgResult) {
-                alertErrorMessage('requiredErrorMsg' + checkRequiredFieldMsgResult);
+                alertErrorMessage('{!$Label.Input_Required_Field_Msg}' + checkRequiredFieldMsgResult);
                 return
             }
             // //3. Prepare the payload for New PI API To AWS - To Do
diff --git a/force-app/main/default/pages/NewAndEditOpportunity.page b/force-app/main/default/pages/NewAndEditOpportunity.page
index fbf90ea..29373ff 100644
--- a/force-app/main/default/pages/NewAndEditOpportunity.page
+++ b/force-app/main/default/pages/NewAndEditOpportunity.page
@@ -332,7 +332,7 @@
             // Check Required Field
             let checkRequiredFieldMsgResult = checkRequiredFieldMsg(sobjJson);
             if (checkRequiredFieldMsgResult) {
-                alertErrorMessage('requiredErrorMsg' + checkRequiredFieldMsgResult);
+                alertErrorMessage('{!$Label.Input_Required_Field_Msg}' + checkRequiredFieldMsgResult);
                 return
             }
             // //3. Prepare the payload for New PI API To AWS - To Do
diff --git a/force-app/main/default/pages/NewAndEditOrder.page b/force-app/main/default/pages/NewAndEditOrder.page
index 4153dd7..54bf8cc 100644
--- a/force-app/main/default/pages/NewAndEditOrder.page
+++ b/force-app/main/default/pages/NewAndEditOrder.page
@@ -1,10 +1,3 @@
-<!--
-@description       : 
-@author            : ChangeMeIn@UserSettingsUnder.SFDoc
-@group             : 
-@last modified on  : 03-08-2022
-@last modified by  : ChangeMeIn@UserSettingsUnder.SFDoc
--->
 <apex:page standardController="Order" extensions="NewAndEditOrderController" id="page">
     <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" />
     <script src="../../soap/ajax/53.0/connection.js" type="text/javascript"></script>
@@ -183,7 +176,7 @@
             }
             let phone = document.querySelector(textPhone);
 
-            if(phone && !/^1[3|5|8|7][0-9]\d{4,8}$/.test(phone.value)){
+            if(false && phone && !/^1[3|5|8|7][0-9]\d{4,8}$/.test(phone.value)){
                 error_msg += ';鐢佃瘽鍙风爜閿欒';
             }
 
@@ -337,7 +330,7 @@
             // Check Required Field
             let checkRequiredFieldMsgResult = checkRequiredFieldMsg(sobjJson);
             if (checkRequiredFieldMsgResult) {
-                alertErrorMessage('requiredErrorMsg' + checkRequiredFieldMsgResult);
+                alertErrorMessage('{!$Label.Input_Required_Field_Msg}' + checkRequiredFieldMsgResult);
                 return
             }
             // //3. Prepare the payload for New PI API To AWS - To Do
diff --git a/force-app/main/default/pages/NewAndEditQuotes.page b/force-app/main/default/pages/NewAndEditQuotes.page
index 0115141..9466289 100644
--- a/force-app/main/default/pages/NewAndEditQuotes.page
+++ b/force-app/main/default/pages/NewAndEditQuotes.page
@@ -1,10 +1,3 @@
-<!--
-  @description       : 
-  @author            : ChangeMeIn@UserSettingsUnder.SFDoc
-  @group             : 
-  @last modified on  : 03-04-2022
-  @last modified by  : ChangeMeIn@UserSettingsUnder.SFDoc
--->
 <apex:page standardController="Quotes__c" extensions="NewAndEditQuotesController" id="page">
     <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" />
     <script src="../../soap/ajax/53.0/connection.js" type="text/javascript"></script>
@@ -183,7 +176,7 @@
             }
             let phone = document.querySelector(textPhone);
 
-            if(phone && !/^1[3|5|8|7][0-9]\d{4,8}$/.test(phone.value)){
+            if(false && phone && !/^1[3|5|8|7][0-9]\d{4,8}$/.test(phone.value)){
                 error_msg += ';鐢佃瘽鍙风爜閿欒';
             }
 
@@ -204,7 +197,7 @@
 
         function getSobjectInformation() {
             //api_id_map
-//let nodelist = document.getElementsByClassName(config.ApiPrefix);
+            //let nodelist = document.getElementsByClassName(config.ApiPrefix);
             let result = {}
             for (let index in api_id_map) {
                 let ele = document.getElementById(api_id_map[index]);
@@ -336,7 +329,7 @@
             // Check Required Field
             let checkRequiredFieldMsgResult = checkRequiredFieldMsg(sobjJson);
             if (checkRequiredFieldMsgResult) {
-                alertErrorMessage('requiredErrorMsg' + checkRequiredFieldMsgResult);
+                alertErrorMessage('{!$Label.Input_Required_Field_Msg}' + checkRequiredFieldMsgResult);
                 return
             }
             // //3. Prepare the payload for New PI API To AWS - To Do
@@ -364,7 +357,7 @@
 
         //鏇挎崲vlookup
         var newSearchContactWindow = null;  
-        var closeField = '';
+        // var closeField = '';
 
         function replaceSearchContactLookup() {
             if (!{!isNewMode}) {
@@ -403,7 +396,7 @@
         
         //鑷畾涔塴ookup鏌ヨ
         function searchContact(contactNodeId,field){
-            closeField = field;
+            // closeField = field;
             let accountValue = "";
             if (document.querySelector("[data-id='AccountId']")) {
                 let accountNodeId = document.querySelector("[data-id='AccountId']").id + '_lkid';
@@ -430,9 +423,9 @@
             let contactInfoStr = document.getElementById('page:form:contactId').value;
             console.log('closePopup:'+contactInfoStr);
             let contactInfo = JSON.parse(contactInfoStr);
-            let contactNodeId = document.querySelector("[data-id="+closeField+"]").id + '_lkid';
+            let contactNodeId = document.querySelector("[data-id='CONTACT_NAME__c']").id + '_lkid';
             document.getElementById(contactNodeId).value = contactInfo.ContactId;
-            document.querySelector("[data-id="+closeField+"]").value = contactInfo.Name;     
+            document.querySelector("[data-id='CONTACT_NAME__c']").value = contactInfo.Name;     
         }
 
     </script>
diff --git a/force-app/main/default/pages/NewAndEditUserFaultInfo.page b/force-app/main/default/pages/NewAndEditUserFaultInfo.page
index 6f9aa94..0d9d2bf 100644
--- a/force-app/main/default/pages/NewAndEditUserFaultInfo.page
+++ b/force-app/main/default/pages/NewAndEditUserFaultInfo.page
@@ -176,7 +176,7 @@
             }
             let phone = document.querySelector(textPhone);
 
-            if(phone && !/^1[3|5|8|7][0-9]\d{4,8}$/.test(phone.value)){
+            if(false && phone && !/^1[3|5|8|7][0-9]\d{4,8}$/.test(phone.value)){
                 error_msg += ';鐢佃瘽鍙风爜閿欒';
             }
 
@@ -329,7 +329,7 @@
             // Check Required Field
             let checkRequiredFieldMsgResult = checkRequiredFieldMsg(sobjJson);
             if (checkRequiredFieldMsgResult) {
-                alertErrorMessage('requiredErrorMsg' + checkRequiredFieldMsgResult);
+                alertErrorMessage('{!$Label.Input_Required_Field_Msg}' + checkRequiredFieldMsgResult);
                 return
             }
             // //3. Prepare the payload for New PI API To AWS - To Do
diff --git a/force-app/main/default/pages/NewOpportunity.page b/force-app/main/default/pages/NewOpportunity.page
index 6fab793..da11553 100644
--- a/force-app/main/default/pages/NewOpportunity.page
+++ b/force-app/main/default/pages/NewOpportunity.page
@@ -7,14 +7,21 @@
     <script>
         var staticResource = JSON.parse('{!staticResource}');
         var txId = '';
-        var DealerSalesStaffNameId = 'Page:mainForm:idSearchSetProduct:j_id53:j_id56:opp_DealerSalesStaffName';
-        var DealerServiceId = 'Page:mainForm:idSearchSetProduct:j_id53:j_id62:opp_DealerService';
+        // var DealerSalesStaffNameId = 'Page:mainForm:idSearchSetProduct:j_id53:j_id56:opp_DealerSalesStaffName';
+        // var DealerServiceId = 'Page:mainForm:idSearchSetProduct:j_id53:j_id62:opp_DealerService';
+        var DealerSalesStaffNameId = 'page:form:block:j_id50:6:j_id51:j_id52:1:j_id53';
+        var DealerServiceId = 'page:form:block:j_id50:6:j_id51:j_id52:2:j_id53';
         var opportunityAWSDataId = 'Page:mainForm:idSearchSetProduct:j_id53:opportunityAWSDataId';
         function getPIData(){
             let opportunityPayloadList = [];
             let opportunityPIData = new Object();
-            opportunityPIData.dealerSalesStaffName = document.getElementById(DealerSalesStaffNameId).value
-            opportunityPIData.dealerService = document.getElementById(DealerServiceId).value
+            
+            if(document.getElementById(DealerSalesStaffNameId)){
+                opportunityPIData.dealerSalesStaffName = document.getElementById(DealerSalesStaffNameId).value
+            }
+            if(document.getElementById(DealerServiceId)){
+                opportunityPIData.dealerService = document.getElementById(DealerServiceId).value
+            }
             opportunityPayloadList.push(opportunityPIData);
             return JSON.stringify(opportunityPayloadList);
         }
@@ -23,9 +30,15 @@
         new Promise(function(resolve,reject){
             //鍔犲瘑
             let queryPostBack = function(data){
-                document.getElementById(DealerSalesStaffNameId).value = data.object[0].dealerSalesStaffName;
-                document.getElementById(DealerServiceId).value = data.object[0].dealerService;
-                document.getElementById(opportunityAWSDataId).value = data.object[0].dataId;
+                if(document.getElementById(DealerSalesStaffNameId)){
+                    document.getElementById(DealerSalesStaffNameId).value = data.object[0].dealerSalesStaffName;
+                }
+                if(document.getElementById(DealerServiceId)){
+                    document.getElementById(DealerServiceId).value = data.object[0].dealerService;
+                }
+                if(document.getElementById(opportunityAWSDataId)){
+                    document.getElementById(opportunityAWSDataId).value = data.object[0].dataId;
+                }
                 txId = data.txId;
                 resolve('success');
             };
@@ -40,8 +53,12 @@
         let b = HasError();
         if(b){
             //娓呯┖浠g悊鍟嗛攢鍞媴褰撹�呭悕
-            document.getElementById(DealerSalesStaffNameId).value=''
-            document.getElementById(DealerServiceId).value=''
+            if(document.getElementById(DealerSalesStaffNameId)){
+                document.getElementById(DealerSalesStaffNameId).value=''
+            }
+            if(document.getElementById(DealerServiceId)){
+                document.getElementById(DealerServiceId).value=''
+            }
         }
         AWSService.post(staticResource.transactionUrl, JSON.stringify({
                 "txId":txId,
diff --git a/force-app/main/default/pages/SWOPage.page b/force-app/main/default/pages/SWOPage.page
index b9d64c1..3f46928 100644
--- a/force-app/main/default/pages/SWOPage.page
+++ b/force-app/main/default/pages/SWOPage.page
@@ -5,8 +5,99 @@
 	<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
 	<apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
 	<apex:includeScript value="{!URLFOR($Resource.apex20)}"/>
+	<!-- 20220313 PI鏀归�� by Chen Yanan -->
+	<apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" />	
 
 	<script>
+		// 20220313 PI鏀归�� by Chen Yanan start
+		AWSService.sfSessionId = '{!GETSESSIONID()}';
+		var staticResources = JSON.parse('{!staticResource}');
+		var contactstaticResource = JSON.parse('{!contactstaticResource}');
+		var aws_data = {};
+		console.log('AWS' + {!contactAWSDataId});
+		var isNew = {!isNew};
+		console.log('isNew: ' + isNew);
+
+		function Decrypt(r,dataIds,callback){
+			if (!(dataIds && dataIds.length)) {
+				if(callback)callback();
+				return;
+			}
+
+			let Foo = function(){
+				for (const id of dataIds) {
+					if (aws_data.hasOwnProperty(id)) {
+						let d = aws_data[id];
+						let $e =j$("[aws-id='"+d.dataId+ "']");
+						$e.each((i,e)=>{
+							j$(e).html(d[j$(e).attr("aws-api")]);
+						})
+						
+					}
+				}
+				if(callback)callback();
+			}
+			let ids = [];
+			for (const id of dataIds) {
+				if (!aws_data.hasOwnProperty(id)) {
+					ids.push(id);
+				}
+			}
+			if (ids.length > 0) {
+				
+				// AWSService.search(r.searchUrl,JSON.stringify({
+				// 	"dataIds":ids
+				// }),function(data){
+				AWSService.query(r.queryUrl,ids[0],function(data){	
+					console.log('data: ' + JSON.stringify(data));
+					// if(data.object && data.object.length > 0){
+					if(data.object){
+						
+						// for(let d of data.object){
+						// 	if(d.dataId){
+						// 		aws_data[d.dataId] = d;
+						// 	}
+						// }
+						aws_data[data.object.dataId] = data.object;
+						Foo();
+					}else{
+						if(callback)callback();
+					}
+				},r.token);
+			}else{
+				Foo();
+			}
+		}
+
+		function DecryptAll(callback){
+			let dataIds1 = [];
+			j$('[aws-id][aws-obj="Contact"]').each((i,e)=>{
+				let v = j$(e).attr('aws-id');
+				if (v) {
+					dataIds1.push(v);
+				}
+			});
+			Decrypt(contactstaticResource,dataIds1,callback);
+
+			
+		}
+
+		function DecryptSWOAll(callback) {
+			let dataIds2 = [];
+			j$('[aws-id][aws-obj="SWO__c"]').each((i,e)=>{
+				let v = j$(e).attr('aws-id');
+				if (v) {
+					dataIds2.push(v);
+				}
+			});
+			Decrypt(staticResources,dataIds2,callback);
+		}
+
+		j$(function(){
+			DecryptSWOAll();
+			DecryptAll();
+		})
+		// 20220313 PI鏀归�� by Chen Yanan end
 		var IS_OPEN = true;
 
 		j$(document).ready(function() {
@@ -159,6 +250,111 @@
     			IS_OPEN = false;
     		}
     	}
+		//Add By Li JUn for PIPL 20220414 Start
+		var aws_result = {};
+
+		function saveSWOToAWS(){
+            // document.getElementById("errorMsg").innerHTML = '';
+            // if(!document.getElementById("Page:mainForm:idSearchVisitor:updateContactLastName").value){
+            //     document.getElementById("errorMsg").innerHTML = '<strong>閿欒:</strong> 蹇呴』濉啓銆�';
+            //     return;
+            // }
+            blockme();
+            let es = document.getElementsByTagName('select')
+            for(let ei in es){
+                let e = es[ei];
+                for(let opi in e.options){
+                    let op = e.options[opi];
+                    if(!op)continue;
+                    if(op.value == "*****" && op.selected){
+                        unblockUI();
+                        alert('涓嬫媺妗嗕笉鑳戒富鍔ㄩ�夋嫨瀵嗘枃閫夐」')
+                        return;
+                    }
+                }
+            }
+            ProcessPIForAWS({},GetEditObj());
+        }
+
+		function ProcessPIForAWS(sobjJson, payloadForNewPI) {
+            let url = staticResources.newUrl
+            let moduleName = AWSService.insertModule;
+            if (!isNew) {
+				console.log('Update');
+                moduleName = AWSService.updateModule;
+            	url = staticResources.updateUrl
+            }
+            console.log('Payload for AWS:'+payloadForNewPI + ' Module Name:'+moduleName);
+            // AWSService.postAWS(url,moduleName, payloadForNewPI, function(result){
+            AWSService.post(url, payloadForNewPI, function(result){
+                aws_result = result;
+                SetEditObj();
+                saveNew();
+            }, staticResources.token);
+        }
+
+        function GetEditObj(){
+    		var swoId = j$(escapeVfId("swoid")).value();
+			console.log('swoId: ' + swoId);
+            return JSON.stringify([{
+                // lastName : document.getElementById("Page:mainForm:idSearchVisitor:updateContactLastName").value,
+                // phone : document.getElementById("Page:mainForm:idSearchVisitor:updateContactPhone").value,
+                // type : document.getElementById("Page:mainForm:idSearchVisitor:updateContactType").value,
+                // doctorDivision1 : document.getElementById("Page:mainForm:idSearchVisitor:updateContactDoctorDivision").value,
+                // dataId:selectedAwsDataId
+				contactNameHidden: document.getElementById("Page:mainForm:CONTACT_NAME_HIDDEN__c").value,
+                dataId:swoId
+            }]);
+        }
+
+		function SetEditObj(){
+            let obj = GetAWSResultObj();
+            if(obj){
+                console.log('Result from AWS:'+JSON.stringify(obj));
+                document.getElementById('Page:mainForm:AWS_Data_Id__c').value = obj.dataId;
+                document.getElementById("Page:mainForm:CONTACT_NAME_HIDDEN__c").value = obj.contactNameHidden;
+                
+                // document.getElementById("Page:mainForm:idSearchVisitor:updateContactLastName").value = obj.lastName;
+                // document.getElementById("Page:mainForm:LastName_Encrypted__c").value = obj.lastNameEncrypt;
+
+                // document.getElementById("Page:mainForm:idSearchVisitor:updateContactPhone").value = obj.phone;
+                // document.getElementById("Page:mainForm:Phone_Encrypted__c").value = obj.phoneEncrypt;
+
+                // document.getElementById("Page:mainForm:idSearchVisitor:updateContactType").value = obj.type;
+                // document.getElementById("Page:mainForm:Type_Encrypted__c").value = obj.typeEncrypt;
+
+                // document.getElementById("Page:mainForm:idSearchVisitor:updateContactDoctorDivision").value = obj.doctorDivision1;
+                // document.getElementById("Page:mainForm:Doctor_Division1_Encrypted__c").value = obj.doctorDivision1Encrypt;
+            }
+            
+        }
+
+		function GetAWSResultObj(){
+            if(aws_result && aws_result.object && aws_result.object.length > 0){
+                return aws_result.object[0];
+            }
+            return null;
+        }
+
+		function Trans(){
+			console.log('SWO ID : ' + document.getElementById('swoid').value);
+    		var swoId = j$(escapeVfId("swoid")).value();
+            console.log('SFRcordId:'+swoId);
+            // AWSService.postAWS(staticResources.transactionUrl,AWSService.confirmTrans, JSON.stringify({
+            //         "txId":aws_result.txId,
+            //         "sfRecordId":swoId,
+            //         "isSuccess":1
+            // }), function(result){
+			AWSService.post(staticResources.transactionUrl, JSON.stringify({
+                    "txId":aws_result.txId,
+                    "sfRecordId":swoId,
+                    "isSuccess":1
+            }), function(result){
+                window.location.reload();
+            }, staticResources.token);
+        }
+
+		//Add By Li JUn for PIPL 20220414 End
 	</script>
 
 	<style type="text/css"> 
@@ -226,6 +422,10 @@
 		<apex:actionFunction name="openPageSave" action="{!openPageSave}" reRender="">
 		</apex:actionFunction>
 		<apex:actionFunction name="uploadFile" action="{!uploadFile}"></apex:actionFunction>
+		<!-- Add save method for PIPL 20220414 by Li Jun Start -->
+		<apex:actionFunction name="saveNew" action="{!save}" reRender="swoid" onComplete="Trans()">
+        </apex:actionFunction>
+		<!-- Add save method for PIPL 20220414 by Li Jun End -->
 		<input type="hidden" id="baseUrl" value="{!baseUrl}"/>
 		<input type="hidden" id="swoid" value="{!swoid}"/>
 		<input type="hidden" id="type" value="{!type}"/>
@@ -242,7 +442,12 @@
 		<apex:outputPanel id="messageInfo">
 			<apex:pagemessages />
         </apex:outputPanel>
-		<apex:commandButton onclick="blockme();" value="Save" action="{!save}" style="width: 5%;"/>
+		<!-- Before PIPL Update 20220414 By Chen Yanan Start -->
+		<!-- <apex:commandButton onclick="blockme();" value="Save" action="{!save}" style="width: 5%;"/> -->
+		<!-- Before PIPL Update 20220414 By Chen Yanan end -->
+		<!-- After PIPL Update 20220414 By Chen Yanan Start -->
+		<apex:commandButton id="saveSWO" value="Save" style="width: 5%;" onclick="saveSWOToAWS();"  rerender="dummy" />
+		<!-- After PIPL Update 20220414 By Chen Yanan end -->
 		<table style="width: 100%;">
 			<colgroup>
 	            <col width="16%"/>
@@ -299,12 +504,19 @@
 	        	<td colspan="2">{!$ObjectType.SWO__c.fields.OFFICE__c.label}<span class="textRed">*</span></td>
 	        	<td><apex:inputField value="{!swo.TYPE__c}"/></td>
 	        	<td colspan="2">{!$ObjectType.SWO__c.fields.CONTACT_NAME_HIDDEN__c.label}</td>
+				
 	        </tr>
 
 	         <tr>
 	        	<td colspan="2"><apex:inputField value="{!swo.OFFICE__c}"/></td>
 	        	<td></td>
-	        	<td colspan="2"><apex:inputField value="{!swo.CONTACT_NAME_HIDDEN__c}"/></td>
+				<!-- Update By Yanan -->
+	        	<!-- <td colspan="2"><apex:inputField value="{!swo.CONTACT_NAME_HIDDEN__c}"/></td>				 -->
+				<td colspan="2" >
+					<apex:inputHidden id="AWS_Data_Id__c" value="{!swo.AWS_Data_Id__c}"/>
+					<apex:inputField html-aws-obj="SWO__c" html-aws-api="CONTACT_NAME_HIDDEN__c" html-aws-id="{!swo.AWS_Data_Id__c}" id="CONTACT_NAME_HIDDEN__c" value="{!swo.CONTACT_NAME_HIDDEN__c }" />
+				</td>
+				<!-- Update By Yanan -->
 	        </tr>
 
 	        <tr>
@@ -456,8 +668,12 @@
 	    <table style="width: 100%;border-collapse: collapse;">
 	    	<tr class="title">
 	    		<td id="titleProduct" class="title1"><apex:commandLink oncomplete="clickColorChange('Product')" action="{!setProduct}" reRender="table" value="Product Info" /></td>
-	    		<td id="titleCase" class="title1"><apex:commandLink oncomplete="clickColorChange('Case')" action="{!setCase}" reRender="table" value="Case Info" /></td>
-	    		<td id="titlemail" class="title1"><apex:commandLink oncomplete="clickColorChange('mail')" action="{!setMail}" reRender="table" value="Mail Merge" /></td>
+	    		<!-- PIPL Update 20220414 By Chen Yanan Start -->
+				<!-- <td id="titleCase" class="title1"><apex:commandLink oncomplete="clickColorChange('Case')" action="{!setCase}" reRender="table" value="Case Info" /></td> -->
+	    		<!-- After -->
+				<td id="titleCase" class="title1"><apex:commandLink oncomplete="clickColorChange('Case');DecryptAll();" action="{!setCase}" reRender="table" value="Case Info" /></td>
+	    		<!-- PIPL Update 20220414 By Chen Yanan End -->
+				<td id="titlemail" class="title1"><apex:commandLink oncomplete="clickColorChange('mail')" action="{!setMail}" reRender="table" value="Mail Merge" /></td>
 	    		<td id="titleTracking" class="title1"><apex:commandLink oncomplete="clickColorChange('Tracking')" action="{!setTracking}" reRender="table" value="Tracking" /></td>
 	    		<td id="titleTechnical" class="title1"><apex:commandLink oncomplete="clickColorChange('Technical')" action="{!setTechnical}" reRender="table" value="Technical Info" /></td>
 	    		<td id="titleEstimation" class="title1"><apex:commandLink oncomplete="clickColorChange('Estimation')" action="{!setEstimation}" reRender="table" value="Estimation" /></td>
@@ -701,7 +917,13 @@
 			        </tr>
 			        <tr>
 			        	<td><apex:outputField value="{!swo.CASE_NUMBER__c}" ></apex:outputField></td>
-	        			<td><apex:inputField value="{!swo.EMAIL__c}"/></td>
+						<!-- PIPL Update 20220414 By Chen Yanan Start -->
+	        			<!-- <td><apex:inputField value="{!swo.EMAIL__c}"/></td> -->
+						<td colspan="2" align="left" >
+							<apex:inputField html-aws-obj="Contact" html-aws-api="email" html-aws-id="{!contactAWSDataId}" value="{!swo.EMAIL__c}" />
+						</td>
+
+						<!-- PIPL Update 20220414 By Chen Yanan End -->
 			        </tr>
 			        <tr>
 			        	<td>{!$ObjectType.SWO__c.fields.COMPANY__c.label}</td>
@@ -716,7 +938,12 @@
 			        	<td>{!$ObjectType.SWO__c.fields.TRAN__c.label}</td>
 			        </tr>
 			        <tr>
-			        	<td><apex:outputField value="{!swo.CONTACT__c}" ></apex:outputField></td>
+						<!-- 20220313 PI鏀归�� by Chen Yanan -->
+			        	<!-- <td><apex:outputField value="{!swo.CONTACT__c}" ></apex:outputField></td> -->
+						<td colspan="2" align="left" >
+							<a href="/{!swo.CONTACT__c}" aws-obj="Contact" aws-api="lastName" aws-id="{!contactAWSDataId}">{!swo.CONTACT__r.Name}</a>
+						</td>
+						<!-- 20220313 PI鏀归�� by Chen Yanan -->
 	        			<td><apex:inputField value="{!swo.TRAN__c}"/></td>
 			        </tr>
 	    		</table>
@@ -1381,9 +1608,12 @@
 	    	</apex:outputPanel>
 
 	    	<apex:outputPanel rendered="{!IF(type = 'General' || type = 'All',true,false)}">
-	    		<apex:commandButton value="Attach" onclick="uploadFileJS();return false;"></apex:commandButton>
-					
-			   
+				<!-- Before PIPL Update by Li Jun 20220414 Start -->
+	    		<apex:commandButton value="Attach" action="{!uploadFile}"></apex:commandButton>
+				<!-- Before PIPL Update by Li Jun 20220414 End -->
+				<!-- After PIPL Update by Li Jun 20220414 Start -->
+			    <input class="btn" type="Button" value="PIPL Attach" onclick="window.open('/apex/SWOFileUploadPage')" />
+				<!-- After PIPL Update by Li Jun 20220414 End -->
 		    	<table class="tableCss" style="border:1px solid #000000;width: 80%">	
 		    		<tr style="text-align:center;">
 		    			<th style="text-align:center;width: 33%;">File Name</th>
@@ -1775,8 +2005,11 @@
 		<br/>
 		<br/>
 		<!-- <apex:commandButton action="{!save}" onclick="blockme();" value="Save" oncomplete="isOk();unblockUI();" reRender="Page,mainForm" style="width: 5%;"/> -->
-		<apex:commandButton onclick="blockme();" value="Save" action="{!save}" style="width: 5%;"/>
-
+		<!-- PIPL Update 20220414 By Chen Yanan -->
+		<!-- <apex:commandButton onclick="blockme();" value="Save" action="{!save}" style="width: 5%;"/> -->
+		<apex:commandButton id="saveSWOs" value="Save" style="width: 5%;" onclick="saveSWOToAWS();" rerender="dummy" />
+		<!-- PIPL Update 20220414 By Chen Yanan -->
+		
 	</apex:form>
 	
 	<br/>
diff --git a/force-app/main/default/pages/SWOPageRead.page b/force-app/main/default/pages/SWOPageRead.page
index d076824..7af0053 100644
--- a/force-app/main/default/pages/SWOPageRead.page
+++ b/force-app/main/default/pages/SWOPageRead.page
@@ -5,8 +5,96 @@
 	<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
 	<apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
 	<apex:includeScript value="{!URLFOR($Resource.apex20)}"/>
-
+	<!-- Update 20220315 By Chen Yanan -->
+	<apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" />
 	<script>
+		// 20220315 PI鏀归�� by Chen Yanan start
+        var staticResources = JSON.parse('{!staticResource}');
+		var contactstaticResource = JSON.parse('{!contactstaticResource}');
+		var aws_data = {};
+		console.log('AWS' + {!contactAWSDataId});
+
+		function Decrypt(r,dataIds,callback){
+			if (!(dataIds && dataIds.length)) {
+				if(callback)callback();
+				return;
+			}
+
+			let Foo = function(){
+				for (const id of dataIds) {
+					if (aws_data.hasOwnProperty(id)) {
+						let d = aws_data[id];
+						let $e =j$("[aws-id='"+d.dataId+ "']");
+						$e.each((i,e)=>{
+							j$(e).html(d[j$(e).attr("aws-api")]);
+						})
+						
+					}
+				}
+				if(callback)callback();
+			}
+			let ids = [];
+			for (const id of dataIds) {
+				if (!aws_data.hasOwnProperty(id)) {
+					ids.push(id);
+				}
+			}
+			if (ids.length > 0) {
+				
+				// AWSService.search(r.searchUrl,JSON.stringify({
+				// 	"dataIds":ids
+				// }),function(data){
+				AWSService.query(r.queryUrl,ids[0],function(data){	
+					console.log('data: ' + JSON.stringify(data));
+					// if(data.object && data.object.length > 0){
+					if(data.object){
+						
+						// for(let d of data.object){
+						// 	if(d.dataId){
+						// 		aws_data[d.dataId] = d;
+						// 	}
+						// }
+						aws_data[data.object.dataId] = data.object;
+						Foo();
+					}else{
+						if(callback)callback();
+					}
+				},r.token);
+			}else{
+				Foo();
+			}
+		}
+
+		function DecryptAll(callback){
+			let dataIds1 = [];
+			j$('[aws-id][aws-obj="Contact"]').each((i,e)=>{
+				let v = j$(e).attr('aws-id');
+				if (v) {
+					dataIds1.push(v);
+				}
+			});
+			Decrypt(contactstaticResource,dataIds1,callback);
+
+			
+		}
+
+		function DecryptSWOAll(callback) {
+			let dataIds2 = [];
+			j$('[aws-id][aws-obj="SWO__c"]').each((i,e)=>{
+				let v = j$(e).attr('aws-id');
+				if (v) {
+					dataIds2.push(v);
+				}
+			});
+			Decrypt(staticResources,dataIds2,callback);
+		}
+
+		j$(function(){
+			DecryptSWOAll();
+			DecryptAll();
+		})
+        // 20220315 PI鏀归�� by Chen Yanan end
+
 		j$(document).ready(function() {
 			var type = j$(escapeVfId("type")).value();
 			clickColorChange(type);
@@ -252,7 +340,10 @@
 	         <tr>
 	        	<td colspan="2"><apex:outputField value="{!swo.OFFICE__c}"/></td>
 	        	<td></td>
-	        	<td colspan="2"><apex:outputField value="{!swo.CONTACT_NAME_HIDDEN__c}"/></td>
+				<!-- 20220315 PI鏀归�� by Chen Yanan start -->
+	        	<!-- <td colspan="2"><apex:outputField value="{!swo.CONTACT_NAME_HIDDEN__c}"/></td> -->
+				<td colspan="2" align="left" ><apex:outputField html-aws-obj="SWO__C" html-aws-api="contactName" html-aws-id="{!swo.CONTACT_NAME_HIDDEN__c}" id="CONTACT_NAME_HIDDEN__c" value="{!swo.CONTACT_NAME_HIDDEN__c}"/></td>
+				<!-- 20220315 PI鏀归�� by Chen Yanan End -->
 	        </tr>
 
 	        <tr>
@@ -403,8 +494,12 @@
 	    <table style="width: 100%;border-collapse: collapse;">
 	    	<tr class="title">
 	    		<td id="titleProduct" class="title1"><apex:commandLink oncomplete="clickColorChange('Product')" action="{!setProduct}" reRender="table" value="Product Info" /></td>
-	    		<td id="titleCase" class="title1"><apex:commandLink oncomplete="clickColorChange('Case')" action="{!setCase}" reRender="table" value="Case Info" /></td>
-	    		<td id="titlemail" class="title1"><apex:commandLink oncomplete="clickColorChange('mail')" action="{!setMail}" reRender="table" value="Mail Merge" /></td>
+	    		<!-- PIPL Update 20220414 By Chen Yanan Start -->
+				<!-- <td id="titleCase" class="title1"><apex:commandLink oncomplete="clickColorChange('Case')" action="{!setCase}" reRender="table" value="Case Info" /></td> -->
+	    		<!-- After -->
+				<td id="titleCase" class="title1"><apex:commandLink oncomplete="clickColorChange('Case');DecryptAll();" action="{!setCase}" reRender="table" value="Case Info" /></td>
+	    		<!-- PIPL Update 20220414 By Chen Yanan End -->
+				<td id="titlemail" class="title1"><apex:commandLink oncomplete="clickColorChange('mail')" action="{!setMail}" reRender="table" value="Mail Merge" /></td>
 	    		<td id="titleTracking" class="title1"><apex:commandLink oncomplete="clickColorChange('Tracking')" action="{!setTracking}" reRender="table" value="Tracking" /></td>
 	    		<td id="titleTechnical" class="title1"><apex:commandLink oncomplete="clickColorChange('Technical')" action="{!setTechnical}" reRender="table" value="Technical Info" /></td>
 	    		<td id="titleEstimation" class="title1"><apex:commandLink oncomplete="clickColorChange('Estimation')" action="{!setEstimation}" reRender="table" value="Estimation" /></td>
@@ -648,7 +743,13 @@
 			        </tr>
 			        <tr>
 			        	<td><apex:outputField value="{!swo.CASE_NUMBER__c}" ></apex:outputField></td>
-	        			<td><apex:outputField value="{!swo.EMAIL__c}"/></td>
+						<!-- PIPL Update 20220414 By Chen Yanan Start -->
+	        			<!-- <td><apex:inputField value="{!swo.EMAIL__c}"/></td> -->
+						<td colspan="2" align="left" >
+							<apex:inputField html-aws-obj="Contact" html-aws-api="email" html-aws-id="{!contactAWSDataId}" value="{!swo.EMAIL__c}" />
+						</td>
+
+						<!-- PIPL Update 20220414 By Chen Yanan End -->
 			        </tr>
 			        <tr>
 			        	<td class="hand">{!$ObjectType.SWO__c.fields.COMPANY__c.label}</td>
@@ -663,7 +764,12 @@
 			        	<td class="hand">{!$ObjectType.SWO__c.fields.TRAN__c.label}</td>
 			        </tr>
 			        <tr>
-			        	<td><apex:outputField value="{!swo.CONTACT__c}" ></apex:outputField></td>
+						<!-- 20220315 PI鏀归�� by Chen Yanan start -->
+			        	<!-- <td><apex:outputField value="{!swo.CONTACT__c}" ></apex:outputField></td> -->
+						<td colspan="2" align="left" >
+							<a href="/{!swo.CONTACT__c}" aws-obj="Contact" aws-api="lastName" aws-id="{!contactAWSDataId}">{!swo.CONTACT__r.Name}</a>
+						</td>
+						<!-- 20220315 PI鏀归�� by Chen Yanan End -->
 	        			<td><apex:outputField value="{!swo.TRAN__c}"/></td>
 			        </tr>
 	    		</table>
@@ -1329,9 +1435,10 @@
 	    	</apex:outputPanel>
 
 	    	<apex:outputPanel rendered="{!IF(type = 'General' || type = 'All',true,false)}">
+				<!-- Before PIPL Update by Li Jun 20220414 Start -->
 	    		<apex:commandButton value="Attach" action="{!uploadFile}"></apex:commandButton>
-					
-			   
+				<!-- Before PIPL Update by Li Jun 20220414 End -->
+			    <input class="btn" type="Button" value="PIPL Attach" onclick="window.open('/apex/SWOFileUploadPage')" />
 		    	<table class="tableCss" style="border:1px solid #000000;width: 80%">	
 		    		<tr style="text-align:center;">
 		    			<th style="text-align:center;width: 33%;">File Name</th>
diff --git a/force-app/main/default/pages/SearchContactPage.page b/force-app/main/default/pages/SearchContactPage.page
index e7f7624..eac07e6 100644
--- a/force-app/main/default/pages/SearchContactPage.page
+++ b/force-app/main/default/pages/SearchContactPage.page
@@ -1,5 +1,9 @@
-<apex:page controller="SearchContactController" showHeader="false" id="page">
+<apex:page controller="SearchContactController" showHeader="{!showHeader}" id="page">
+    <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}" />
     <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" />
+    <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}" />
+    <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}" />
+    <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}" />
 
     <head>
     </head>
@@ -19,16 +23,16 @@
             var staticResources = JSON.parse('{!staticResource}');
             var contactAWSIds = JSON.parse('{!contactAWSIds}');
             var contactsInfo = JSON.parse('{!contactsInfo}');
-            var searchContactName = '';
+            var searchKeyWord = '{!searchKeyWord}';
+            var searchContactName = searchKeyWord;
             queryLeadFromAWS();
             function searchAWSContact(){
-                console.log('Search process!');
-                //1. reset table;             
+                //1. reset table;
+                blockme();             
                 resetTable();
                 //2. get contact name value 
                 searchContactName = document.getElementById('page:form:lksrch').value;
                 queryLeadFromAWS();
-
             }
             function resetTable(){
                 let queryResult = document.getElementById('QueryResult');
@@ -46,39 +50,46 @@
             function queryLeadFromAWS() {
                 //1. Prepare the payload for contact search
                 let requestSearchPayload = preparePayloadForSearchContact();
-                console.log('request payload body:'+requestSearchPayload);
                 //2. Invoke AWS Service
-                fetch(staticResources.searchUrl, {
-                    method: 'POST',
-                    body: requestSearchPayload,
-                    headers: {
-                        'Content-Type': 'application/json',
-                        'pi-token': staticResources.token
-                    }
-                }).then((data) => {
-                    return data.json();
-                }).then((result) => {
-                    if(result.object&&result.object.length>0){
-                        initContactTable(result);
-                    }                   
-                })
+                // fetch(staticResources.searchUrl, {
+                //     method: 'POST',
+                //     body: requestSearchPayload,
+                //     headers: {
+                //         'Content-Type': 'application/json',
+                //         'pi-token': staticResources.token
+                //     }
+                // }).then((data) => {
+                //     return data.json();
+                // }).then((result) => {
+                //     if(result.object&&result.object.length>0){
+                //         initContactTable(result);
+                //     }                   
+                // })
+                let queryBackContactName = function queryBackContactName(result){
+                    // if(result.object){
+                    //     initContactTable(result);
+                    // } 
+                    initContactTable(result);
+                };
+                AWSService.search(staticResources.searchUrl,requestSearchPayload,queryBackContactName,staticResources.token)
             }
             
-            function redirectToParentPage(obj,Phone,awsDataId) {
+            function redirectToParentPage(obj) {
                 var winMain = window.opener;
                 if (null == winMain) {
                     winMain = window.parent.opener;
                 }
-                console.log('obj = ' + obj)
                 let value = obj.currentTarget.innerText;
                 let contactInfo = new Object();
                 contactInfo.Name = obj.currentTarget.innerText;
                 contactInfo.ContactId = obj.currentTarget.id;
-                contactInfo.Phone = Phone;
-                contactInfo.awsDataId = awsDataId;
-                var selectedContactNode = winMain.document.getElementById('{!JSENCODE($CurrentPage.parameters.contactId)}');
-                selectedContactNode.value = JSON.stringify(contactInfo);
-                closeWindow();
+                if({!showHeader}){
+                    window.open('\\'+obj.currentTarget.id,'_blank');
+                }else{
+                    var selectedContactNode = winMain.document.getElementById('{!JSENCODE($CurrentPage.parameters.contactId)}');
+                    selectedContactNode.value = JSON.stringify(contactInfo);
+                    closeWindow();
+                }
             }
 
             function closeWindow() {
@@ -97,11 +108,12 @@
                 let tableBody = document.createElement('TBODY');
                 table.appendChild(tableBody);
                 let headerTR = document.createElement('TR');
+                let colsHeader = ['濮撳悕','瀹㈡埛鍚嶇О','閭', '鐢佃瘽','鎵嬫満鍙�'];
                 tableBody.appendChild(headerTR);
-                for (let i = 0; i < cols.length; i++) {
+                for (let i = 0; i < colsHeader.length; i++) {
                     let td = document.createElement('TH');
                     td.width = '75';
-                    td.appendChild(document.createTextNode(cols[i]));
+                    td.appendChild(document.createTextNode(colsHeader[i]));
                     headerTR.appendChild(td);
                 }
                 //3. Init the AWS data
@@ -112,47 +124,84 @@
                     for (let j = 0; j < cols.length; j++) {
                         let td = document.createElement('TD');
                         td.width = '75';
-                        if(j == 0 && contactsInfo[contactInfoTemp.AWSDataId]){
-                            td.id = contactsInfo[contactInfoTemp.AWSDataId].Id;
-                        }                        
+                        if(contactInfoTemp.pi){
+                            if (!contactsInfo.hasOwnProperty(contactInfoTemp.AWSDataId)) {
+                                continue;
+                            }
+                            if(j == 0 && contactsInfo[contactInfoTemp.AWSDataId] ){
+                                td.id = contactsInfo[contactInfoTemp.AWSDataId].Id;
+                            }      
+                        }else{
+                            td.id = contactInfoTemp.sfRecordId;
+                        }              
                         td.appendChild(document.createTextNode(contactInfoTemp[cols[j]]!=null?contactInfoTemp[cols[j]]:''));
                         if (cols[j] == 'Name') {
                             td.addEventListener("click", function (obj) {
-                                console.log('contactInfoList[i] = ' + contactInfoList[i])
-                                redirectToParentPage(obj,contactInfoList[i].Phone,contactInfoList[i].AWSDataId);
+                                redirectToParentPage(obj);
                             });
                         }
                         tr.appendChild(td);
                     }
                 }
                 myTableDiv.appendChild(table);
+                unblockUI();
             }
             function initContactTable(data) {            
-                let cols = ['Name', 'Email', 'Phone'];
+                let cols = ['Name','AccountName', 'Email', 'Phone','MobilePhone'];
                 let contactInfoList = [];
                 let awsDataIds = [];
-                for(var i=0;i<data.object.length;i++){
-                    if(data.object[i].dataId){
-                        let contactInfo = new Object();
-                        contactInfo.Name = data.object[i].lastName;
-                        contactInfo.Email = data.object[i].email;
-                        contactInfo.Phone = data.object[i].phone;
-                        contactInfo.AWSDataId = data.object[i].dataId;
-                        awsDataIds.push(contactInfo.AWSDataId);
-                        contactInfo.sfRecordId = '';
-                        contactInfoList.push(contactInfo);
-                    }                    
+                if(data.object){
+                    for(var i=0;i<data.object.length;i++){
+                        if(data.object[i].dataId){
+                            let contactInfo = new Object();
+                            contactInfo.Name = data.object[i].lastName;
+                            contactInfo.Email = data.object[i].email;
+                            contactInfo.MobilePhone = data.object[i].mobilePhone;
+                            contactInfo.Phone = data.object[i].phone;
+                            contactInfo.AWSDataId = data.object[i].dataId;
+                            contactInfo.pi = true;
+                            awsDataIds.push(contactInfo.AWSDataId);
+                            contactInfo.sfRecordId = '';
+                            contactInfoList.push(contactInfo);
+                        }                    
+                    }
                 }
                 let AWSIdToSFIdMapValue = {};
-                console.log(awsDataIds);
                 //Invoke SF BackEnd
                 Visualforce.remoting.Manager.invokeAction(
                     '{!$RemoteAction.SearchContactController.searchContacts}',
-                    JSON.stringify(awsDataIds),
+                    JSON.stringify(awsDataIds),searchContactName,'{!aId}',
                     function (result, event) {
                         if(event.status){
                             if(result.status = 'success'){
-                                contactsInfo = JSON.parse(result.message.replace(/(&quot\;)/g,"\""));
+                                if(result.message){
+                                    contactsInfo = JSON.parse(result.message.replace(/(&quot\;)/g,"\""));
+                                    if(Object.keys(contactsInfo).length>0){
+                                        for(let i=0;i<contactInfoList.length;i++){
+                                            let contactFromSF = contactsInfo[contactInfoList[i]['AWSDataId']];
+                                            if(contactFromSF){
+                                                contactInfoList[i].sfRecordId = contactFromSF['Id'];
+                                                contactInfoList[i].AccountName = contactFromSF['Account']['Name'];
+                                            }
+                                        }
+                                    }
+                                }
+                                //1. get SF 闈炴晱鎰熺殑鑱旂郴浜轰俊鎭�
+                                if(result.noPIContactList){
+                                    var noPIInfo = JSON.parse(result.noPIContactList.replace(/(&quot\;)/g,"\""));
+                                    for(let f in noPIInfo){
+                                        let contactInfo = new Object();
+                                        contactInfo.Name = noPIInfo[f].Name!=null?noPIInfo[f].Name:'';
+                                        contactInfo.Email = noPIInfo[f].Email!=null?noPIInfo[f].Email:'';
+                                        contactInfo.Phone = noPIInfo[f].Phone!=null?noPIInfo[f].Phone:'';
+                                        contactInfo.MobilePhone = noPIInfo[f].MobilePhone!=null?noPIInfo[f].MobilePhone:'';
+                                        contactInfo.AWSDataId = '';
+                                        contactInfo.sfRecordId = noPIInfo[f].Id!=null?noPIInfo[f].Id:'';
+                                        contactInfo.AccountName = noPIInfo[f]['Account']['Name'];
+                                        contactInfo.pi = false;
+                                        contactInfoList.push(contactInfo);
+                                    }
+                                }
                                 refreshTable(cols,contactInfoList);
                             }else{
                                 console.log('No result');
diff --git a/force-app/main/default/pages/SearchContactPage.page-meta.xml b/force-app/main/default/pages/SearchContactPage.page-meta.xml
index 2aeb2a4..1fdc8c1 100644
--- a/force-app/main/default/pages/SearchContactPage.page-meta.xml
+++ b/force-app/main/default/pages/SearchContactPage.page-meta.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <ApexPage xmlns="http://soap.sforce.com/2006/04/metadata">
-    <apiVersion>54.0</apiVersion>
+    <apiVersion>52.0</apiVersion>
     <availableInTouch>false</availableInTouch>
     <confirmationTokenRequired>false</confirmationTokenRequired>
     <label>SearchContactPage</label>
diff --git a/force-app/main/default/pages/TSRepair.page b/force-app/main/default/pages/TSRepair.page
index 82b343c..9a7d5c8 100644
--- a/force-app/main/default/pages/TSRepair.page
+++ b/force-app/main/default/pages/TSRepair.page
@@ -395,18 +395,24 @@
         }
 
         var contactIdValue = '';
-        function searchContact(contactNodeId,field1,field2,field3){
+        function searchContact(contactNodeId,field1,field2,field3,accountValueId){
             closeField = field1;
             closePhone = field2;
             contactIdValue = field3;
-            let baseUrl = "/apex/SearchContactPage";
-            let suffixUrl = "?contactId="+contactNodeId;
-            let newSearchContactParam = 'height=600,width=800,left=100,top=100,dialogHide=true,resizable=no,scrollbars=yes,toolbar=no,status=no';
-            newSearchContactWindow = window.open(baseUrl+suffixUrl, 'Popup', newSearchContactParam);
-            if (window.focus) {
-                newSearchContactWindow.focus();
+            var accountValueLkid = document.getElementById(accountValueId+'_lkid').value;
+            var searchContactKeyWord = document.getElementById(field1).value;
+            if (accountValueLkid != '000000000000000') {
+                let baseUrl = "/apex/SearchContactPage";
+                let suffixUrl = "?contactId="+contactNodeId+ "&accountId=" + accountValueLkid;
+                let newSearchContactParam = 'height=600,width=800,left=100,top=100,dialogHide=true,resizable=no,scrollbars=yes,toolbar=no,status=no';
+                newSearchContactWindow = window.open(baseUrl+suffixUrl, 'Popup', newSearchContactParam);
+                if (window.focus) {
+                    newSearchContactWindow.focus();
+                }
+                return false;
+            }else {
+                alert('璇峰厛閫夋嫨瀹㈡埛鍗曚綅');
             }
-            return false;
         }
 
         var currentLastName = '';
@@ -433,7 +439,7 @@
                 }
             }
             for(var i = 0;i<3;i++){
-                let contactHtmlString = '<img src="/img/s.gif" onclick="searchContact(\'allPage:allForm:contactId\',\'allPage:allForm:RepairInfoList:'+i+':Contacts__c\',\'allPage:allForm:RepairInfoList:'+i+':j_id91\',\'allPage:allForm:RepairInfoList:'+i+':contactIdValue\')" alt="Reference Document Number Lookup" class="lookupIcon"  title="Reference Document Number Lookup (New Window)"/>';
+                let contactHtmlString = '<img src="/img/s.gif" onclick="searchContact(\'allPage:allForm:contactId\',\'allPage:allForm:RepairInfoList:'+i+':Contacts__c\',\'allPage:allForm:RepairInfoList:'+i+':j_id91\',\'allPage:allForm:RepairInfoList:'+i+':contactIdValue\',\'allPage:allForm:RepairInfoList:'+i+':BusinessACustomerUnit\')" alt="Reference Document Number Lookup" class="lookupIcon"  title="Reference Document Number Lookup (New Window)"/>';
                 let lookUpNode = htmlToElement(contactHtmlString);
                 console.log(lookUpNode);
                 let parentNode = document.getElementById('allPage:allForm:RepairInfoList:'+i+':contactIdValue').parentNode;
diff --git a/force-app/main/default/pages/ViewOpportunityDecryptInfo.page b/force-app/main/default/pages/ViewOpportunityDecryptInfo.page
index 407fac6..64df350 100644
--- a/force-app/main/default/pages/ViewOpportunityDecryptInfo.page
+++ b/force-app/main/default/pages/ViewOpportunityDecryptInfo.page
@@ -1,10 +1,3 @@
-<!--
-  @description       : 
-  @author            : ChangeMeIn@UserSettingsUnder.SFDoc
-  @group             : 
-  @last modified on  : 02-23-2022
-  @last modified by  : ChangeMeIn@UserSettingsUnder.SFDoc
--->
 <apex:page standardController="Opportunity" extensions="NewAndEditOpportunityController" id="page">
   <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }"/>
     <apex:form id="form">
diff --git a/force-app/main/default/pages/ViewOrderDecryptInfo.page b/force-app/main/default/pages/ViewOrderDecryptInfo.page
index 8d8d597..75e27ff 100644
--- a/force-app/main/default/pages/ViewOrderDecryptInfo.page
+++ b/force-app/main/default/pages/ViewOrderDecryptInfo.page
@@ -7,6 +7,8 @@
                 <apex:repeat value="{!layoutEncryptedAPIList}" var="encryptedAPI">
                     <apex:outputField html-data-id="{!encryptedAPI}" title="{!ApiPrefix}{!encryptedAPI}" value="{!Order[encryptedAPI]}" />
                 </apex:repeat>
+                <apex:outputField html-data-id="EndUser__c" title="{!ApiPrefix}EndUser__c" value="{!Order['EndUser__c']}" />
+                <apex:outputField html-data-id="EndUserD__c" title="{!ApiPrefix}EndUserD__c" value="{!Order['EndUserD__c']}" />
             </apex:pageBlockSection>
             <script>
                 var config = {
@@ -17,9 +19,64 @@
                     AWSToSobjectEncryptedMap:{!AWSToSobjectEncryptedMapJson}
                 };
                 var staticResources = JSON.parse('{!staticResource}');
+                var staticResourceContact = JSON.parse('{!staticResourceContact}');
                 function QuerySobjectFromAWS() {
                     AWSService.query(staticResources.queryUrl, '{!AWSDataId}', queryBack, staticResources.token);
+                    debugger
+                    let t = "[title='"+config.ApiPrefix+"EndUser__c']";
+                    let ele = document.querySelector(t);
+                    if('{!contactAWSDataId}' != '鏃�' && '{!contactName}' != '鏃�'){
+                        if('{!contactAWSDataId}' != ''){
+                            AWSService.query(staticResourceContact.queryUrl, '{!contactAWSDataId}', queryContactBack, staticResourceContact.token);
+                        }else{
+                            ele.innerHTML = '{!contactName}';
+                        }
+                    }else{
+                        ele.innerHTML = '';
+                    }
+
+                    let endUserD = "[title='"+config.ApiPrefix+"EndUserD__c']";
+                    let eleUserD = document.querySelector(endUserD);
+                    if('{!contactAWSDataId}' != '鏃�' && '{!contactName}' != '鏃�'){
+                        if('{!endUserDAWSDataId}' != ''){
+                            AWSService.query(staticResourceContact.queryUrl, '{!endUserDAWSDataId}', queryEndUserDBack, staticResourceContact.token);
+                        }else{
+                            eleUserD.innerHTML = '{!endUserDName}';
+                        }
+                    }else{
+                        eleUserD.innerHTML = '';
+                    }
                 }
+                var queryContactBack = function queryContactBack(data){
+                    if(!data.object){
+                        console.log('data.object is ' + data.object);
+                        return;
+                    }
+                    console.log('data.object is ' + data.object);
+                    
+                    let t = "[title='"+config.ApiPrefix+"EndUser__c']";
+                    let ele = document.querySelector(t);
+                    if(ele){
+                        ele.title='';
+                        ele.innerHTML = data.object.lastName;
+                    }
+                };
+
+                var queryEndUserDBack = function queryEndUserDBack(data){
+                    if(!data.object){
+                        console.log('data.object is ' + data.object);
+                        return;
+                    }
+                    console.log('data.object is ' + data.object);
+                    
+                    let endUserD = "[title='"+config.ApiPrefix+"EndUserD__c']";
+                    let eleUserD = document.querySelector(endUserD);
+                    if(eleUserD){
+                        eleUserD.title='';
+                        eleUserD.innerHTML = data.object.lastName;
+                    }
+                };
+
                 var queryBack = function queryBack(data) {
                     if(!data.object){
                         console.log('data.object is ' + data.object);
diff --git a/force-app/main/default/pages/ViewUserFaultInfoDecryptInfo.page b/force-app/main/default/pages/ViewUserFaultInfoDecryptInfo.page
index a5e93a2..22c92c7 100644
--- a/force-app/main/default/pages/ViewUserFaultInfoDecryptInfo.page
+++ b/force-app/main/default/pages/ViewUserFaultInfoDecryptInfo.page
@@ -1,10 +1,3 @@
-<!--
-  @description       : 
-  @author            : ChangeMeIn@UserSettingsUnder.SFDoc
-  @group             : 
-  @last modified on  : 02-28-2022
-  @last modified by  : ChangeMeIn@UserSettingsUnder.SFDoc
--->
 <apex:page standardController="User_FaultInfo__c" extensions="NewAndEditUserFaultInfoController" id="page">
   <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }"/>
     <apex:form id="form">
@@ -14,6 +7,8 @@
                 <apex:repeat value="{!layoutEncryptedAPIList}" var="encryptedAPI">
                     <apex:outputField html-data-id="{!encryptedAPI}" title="{!ApiPrefix}{!encryptedAPI}" value="{!User_FaultInfo__c[encryptedAPI]}" />
                 </apex:repeat>
+                <apex:outputField html-data-id="CONTACT__c" title="{!ApiPrefix}CONTACT__c" value="{!User_FaultInfo__c['CONTACT__c']}" />
+                <apex:outputField html-data-id="UFContact__c" title="{!ApiPrefix}UFContact__c" value="{!User_FaultInfo__c['UFContact__c']}" />
             </apex:pageBlockSection>
             <script>
                 var config = {
@@ -24,9 +19,98 @@
                     AWSToSobjectEncryptedMap:{!AWSToSobjectEncryptedMapJson}
                 };
                 var staticResources = JSON.parse('{!staticResource}');
+                var staticResourceContact = JSON.parse('{!staticResourceContact}');
+                console.log('{!contactAWSDataId}')
+                console.log('{!contactName}')
+                
+                console.log('{!endUserDAWSDataId}')
+                console.log('{!endUserDName}')
                 function QuerySobjectFromAWS() {
                     AWSService.query(staticResources.queryUrl, '{!AWSDataId}', queryBack, staticResources.token);
+                    debugger
+                    let t = "[title='"+config.ApiPrefix+"CONTACT__c']";
+                    let ele = document.querySelector(t);
+                    if('{!contactAWSDataId}' != '鏃�' && '{!contactName}' != '鏃�'){
+                        if('{!contactAWSDataId}' != ''){
+                            AWSService.query(staticResourceContact.queryUrl, '{!contactAWSDataId}', queryContactBack, staticResourceContact.token);
+                        }else{
+                            ele.innerHTML = '{!contactName}';
+                        }
+                    }else{
+                        ele.innerHTML = '';
+                    }
+                    debugger
+                    let contactUserD = "[title='"+config.ApiPrefix+"UFContact__c']";
+                    let eleUserD = document.querySelector(contactUserD);
+                    if('{!endUserDAWSDataId}' != '鏃�' && '{!endUserDName}' != '鏃�'){
+                        if('{!endUserDAWSDataId}' != ''){
+                            AWSService.query(staticResourceContact.queryUrl, '{!endUserDAWSDataId}', queryEndUserDBack, staticResourceContact.token);
+                        }else{
+                            eleUserD.innerHTML = '{!endUserDName}';
+                        }
+                    }else{
+                        eleUserD.innerHTML = '';
+                    }
                 }
+                var queryContactBack = function queryContactBack(data){
+                    if(!data.object){
+                        console.log('data.object is ' + data.object);
+                        return;
+                    }
+                    console.log('data.object is ' + data.object);
+                    
+                    let t = "[title='"+config.ApiPrefix+"CONTACT__c']";
+                    let ele = document.querySelector(t);
+                    if(ele){
+                        ele.title='';
+                        ele.innerHTML = data.object.lastName;
+                    }
+                };
+
+                var queryEndUserDBack = function queryEndUserDBack(data){
+                    if(!data.object){
+                        console.log('data.object is ' + data.object);
+                        return;
+                    }
+                    console.log('data.object is ' + data.object);
+                    
+                    let endUserD = "[title='"+config.ApiPrefix+"UFContact__c']";
+                    let eleUserD = document.querySelector(endUserD);
+                    if(eleUserD){
+                        eleUserD.title='';
+                        eleUserD.innerHTML = data.object.lastName;
+                    }
+                };
+
+                // var queryContactBack = function queryContactBack(data){
+                //     if(!data.object){
+                //         console.log('data.object is ' + data.object);
+                //         return;
+                //     }
+                //     console.log('data.object is ' + data.object);
+                    
+                //     let t = "[title='"+config.ApiPrefix+"EndUser__c']";
+                //     let ele = document.querySelector(t);
+                //     if(ele){
+                //         ele.title='';
+                //         ele.innerHTML = data.object.lastName;
+                //     }
+                // };
+
+                // var queryEndUserDBack = function queryEndUserDBack(data){
+                //     if(!data.object){
+                //         console.log('data.object is ' + data.object);
+                //         return;
+                //     }
+                //     console.log('data.object is ' + data.object);
+                    
+                //     let endUserD = "[title='"+config.ApiPrefix+"EndUserD__c']";
+                //     let eleUserD = document.querySelector(endUserD);
+                //     if(eleUserD){
+                //         eleUserD.title='';
+                //         eleUserD.innerHTML = data.object.lastName;
+                //     }
+                // };
                 var queryBack = function queryBack(data) {
                     if(!data.object){
                         console.log('data.object is ' + data.object);

--
Gitblit v1.9.1