From d8dc84a3d56df839895f1c417a4d9cbee763d262 Mon Sep 17 00:00:00 2001
From: 高章伟 <gaozhangwei@prec-tech.com>
Date: 星期五, 03 三月 2023 14:50:59 +0800
Subject: [PATCH] gzw 测试环境代码更新

---
 force-app/main/default/classes/RentalApplyTriggerHandler.cls |  880 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 876 insertions(+), 4 deletions(-)

diff --git a/force-app/main/default/classes/RentalApplyTriggerHandler.cls b/force-app/main/default/classes/RentalApplyTriggerHandler.cls
index c7d60e2..4803b23 100644
--- a/force-app/main/default/classes/RentalApplyTriggerHandler.cls
+++ b/force-app/main/default/classes/RentalApplyTriggerHandler.cls
@@ -33,6 +33,7 @@
     private static Map<String, String> rental_Apply_App_CCEmailMap = FixtureUtil.initRental_Apply_App_CCEmailMap();
 
     public RentalApplyTriggerHandler() {
+        System.debug('杩涘叆RentalApplyTriggerHandler');
         Integer i = 0;
         i ++;
         this.newMap = (Map<Id, Rental_Apply__c>) Trigger.newMap;
@@ -44,11 +45,13 @@
     }
 
     protected override void beforeInsert() {
+        System.debug('杩涘叆rentalapply beforeInsert');
         setManager();
         beforeSetValue();
         setOffice_Assistant();
     }
     protected override void afterInsert() {
+        System.debug('杩涘叆rentalapply afterInsert');
         // Check鏈儴鏄惁鍙互閫夋嫨
         checkbenbu();// 20220909 ljh 鎭㈠浠g爜
         // 鍏变韩璁惧畾
@@ -238,6 +241,7 @@
         List<Rental_Apply__Share> rasList = new List<Rental_Apply__Share>();
         List<Id> deleteOfficeAssistantShare_nObjId_List = new List<Id>();       // 鍏变韩鍒犻櫎鐢�
         List<Id> deleteApplyUserShare_nObjId_List = new List<Id>();// 20210727 ljh SFDC-C54C33 鍏变韩鍒犻櫎鐢�
+        Set<Id> shareSet = new Set<Id>(); // 20230301 ljh DB202302444522 add
         for (Rental_Apply__c nObj : newList) {
             Rental_Apply__c oObj = (null == this.oldMap) ? null : this.oldMap.get(nObj.Id);
             // 鏈嶅姟閮ㄥ鎵逛汉
@@ -293,6 +297,7 @@
                 ) {
                 deleteApplyUserShare_nObjId_List.add(nObj.Id);
                 if(nObj.SalesManager__c != null){
+                    shareSet.add(nObj.SalesManager__c);// 20230301 ljh DB202302444522 add
                     Rental_Apply__Share rasSalesManager = new Rental_Apply__Share(
                             RowCause = 'ApplyUserShare__c',
                             ParentId = nObj.Id,
@@ -302,6 +307,7 @@
                     rasList.add(rasSalesManager);
                 }
                 if(nObj.BuchangApprovalManagerSales__c != null){
+                    shareSet.add(nObj.BuchangApprovalManagerSales__c);// 20230301 ljh DB202302444522 add
                     Rental_Apply__Share rasBz = new Rental_Apply__Share(
                             RowCause = 'ApplyUserShare__c',
                             ParentId = nObj.Id,
@@ -311,6 +317,7 @@
                     rasList.add(rasBz);
                 }
                 if(nObj.ZongjianApprovalManager__c != null){
+                    shareSet.add(nObj.ZongjianApprovalManager__c);// 20230301 ljh DB202302444522 add
                     Rental_Apply__Share rasZj = new Rental_Apply__Share(
                             RowCause = 'ApplyUserShare__c',
                             ParentId = nObj.Id,
@@ -333,10 +340,18 @@
         if(deleteOfficeAssistantShare_nObjId_List.size() > 0){
             soql += ' AND (RowCause = \'Office_Assistant__c\' AND ParentId =: deleteOfficeAssistantShare_nObjId_List) ';
             if(deleteApplyUserShare_nObjId_List.size() > 0){
-                soql += ' OR (RowCause = \'ApplyUserShare__c\'AND ParentId =: deleteApplyUserShare_nObjId_List)';
+                // 20230301 ljh DB202302444522 update start
+                // soql += ' OR (RowCause = \'ApplyUserShare__c\'AND ParentId =: deleteApplyUserShare_nObjId_List)';
+                soql += ' OR (RowCause = \'ApplyUserShare__c\'AND ParentId =: deleteApplyUserShare_nObjId_List';
+                soql += ' and UserOrGroupId IN :shareSet)';
+                // 20230301 ljh DB202302444522 update end
             }
         }else if(deleteApplyUserShare_nObjId_List.size() > 0){
-            soql += ' AND (RowCause = \'ApplyUserShare__c\'AND ParentId =: deleteApplyUserShare_nObjId_List)';
+            // 20230301 ljh DB202302444522 update start
+            // soql += ' AND (RowCause = \'ApplyUserShare__c\'AND ParentId =: deleteApplyUserShare_nObjId_List)';
+            soql += ' AND (RowCause = \'ApplyUserShare__c\'AND ParentId =: deleteApplyUserShare_nObjId_List';
+            soql += ' and UserOrGroupId IN :shareSet)';
+            // 20230301 ljh DB202302444522 update end
         }
         List<Rental_Apply__Share> deleteShareList = new List<Rental_Apply__Share>();
         if(deleteOfficeAssistantShare_nObjId_List.size() > 0 || deleteApplyUserShare_nObjId_List.size() > 0){
@@ -1042,6 +1057,7 @@
     }
     
     public static void decryptInsert(List<Rental_Apply__c> newList){
+        System.debug('enter RentalApply decryptInsert');
         if(!system.isFuture()){
             List<Rental_Apply__c> fendanList = new List<Rental_Apply__c>();
             for(Rental_Apply__c ra : newList){
@@ -1054,8 +1070,60 @@
                 system.debug('no need split');
                 return;
             }
-            
-           decryptInsertFuture(JSON.serialize(fendanList)); 
+            //zhj MEBG鏂版柟妗堟敼閫� 2022-12-01 start
+           //decryptInsertFuture(JSON.serialize(fendanList));
+           Map<String,PIHelper.PIIntegration> staticResource = new Map<String,PIHelper.PIIntegration>();
+           staticResource.put('Rental_Apply__c',PIHelper.getPIIntegrationInfo('Rental_Apply__c'));
+           Map<String, Map<String, PI_Field_Policy_Detail__c>> mmsp = new Map<String, Map<String,PI_Field_Policy_Detail__c>>();
+           for (String key : staticResource.keySet()) {
+               mmsp.put(key, new Map<String,PI_Field_Policy_Detail__c>());
+               for (PI_Field_Policy_Detail__c detail : staticResource.get(key).PIDetails) {
+                   mmsp.get(key).put(detail.SF_Field_API_Name__c, detail);
+               }
+           }
+           System.debug('mmsp = ' + mmsp);
+
+
+           List<AWSServiceTool2V2.EncryptPushRequestBody> EncryptPushList = new List<AWSServiceTool2V2.EncryptPushRequestBody>();
+            for(Rental_Apply__c ac : fendanList){
+                Rental_Apply__c oldAc = [select id,AWS_Data_Id__c from Rental_Apply__c where id=:ac.Old_Rental_Apply__c];
+                System.debug('oldAc = ' + oldAc);
+                AWSServiceTool2V2.EncryptPushRequestBody EncryptPush = new AWSServiceTool2V2.EncryptPushRequestBody();
+                EncryptPush.dataId = ac.AWS_Data_Id__c != null ?ac.AWS_Data_Id__c:'';
+                EncryptPush.sfRecordId = ac.Id;
+                EncryptPush.fieldsMapping = new Map<String, List<AWSServiceTool2V2.EncryptPushRes>>();
+                List<AWSServiceTool2V2.EncryptPushRes> resList = new List<AWSServiceTool2V2.EncryptPushRes>();
+                AWSServiceTool2V2.EncryptPushRes res= new AWSServiceTool2V2.EncryptPushRes();
+                res.isQueryDb = true;
+                res.value = '';
+                res.table = staticResource.get('Rental_Apply__c').awsTableName;
+                //res.dataId = ac.Old_Rental_Apply__r.AWS_Data_Id__c;
+                res.dataId = oldAc.AWS_Data_Id__c;
+                res.field = mmsp.get('Rental_Apply__c').get('direct_shippment_address__c').AWS_Field_API__c;
+                resList.add(res);
+
+                List<AWSServiceTool2V2.EncryptPushRes> resList2 = new List<AWSServiceTool2V2.EncryptPushRes>();
+                AWSServiceTool2V2.EncryptPushRes res2= new AWSServiceTool2V2.EncryptPushRes();
+                res2.isQueryDb = true;
+                res2.value = '';
+                res2.table = staticResource.get('Rental_Apply__c').awsTableName;
+                //res2.dataId = ac.Old_Rental_Apply__r.AWS_Data_Id__c;
+                res2.dataId = oldAc.AWS_Data_Id__c;
+                res2.field = mmsp.get('Rental_Apply__c').get('Phone_number__c').AWS_Field_API__c;
+                resList2.add(res2);
+
+                EncryptPush.fieldsMapping.put(mmsp.get('Rental_Apply__c').get('direct_shippment_address__c').AWS_Field_API__c, resList);
+                EncryptPush.fieldsMapping.put(mmsp.get('Rental_Apply__c').get('Phone_number__c').AWS_Field_API__c, resList2);
+                EncryptPushList.add(EncryptPush);
+            }
+            System.debug('EncryptPushListdataId = ' + JSON.serialize(EncryptPushList[0].dataId));
+            System.debug('EncryptPushListsfRecordId = ' + JSON.serialize(EncryptPushList[0].sfRecordId));
+            System.debug('EncryptPushListfieldsMapping = ' + JSON.serialize(EncryptPushList[0].fieldsMapping));
+            System.debug('EncryptPushList = ' + JSON.serialize(EncryptPushList));
+            AwsServiceTool2V2.EncryptPushFutureV2(Json.serialize(EncryptPushList),Json.serialize(fendanList), 'Rental_Apply__c');
+           //zhj MEBG鏂版柟妗堟敼閫� 2022-12-01 end
+
+           //decryptInsertFuture(JSON.serialize(fendanList)); 
         }
     }
     
@@ -2648,5 +2716,809 @@
         i++;
         i++;
         i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+                i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
+        i++;
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1