高章伟
2023-03-03 d8dc84a3d56df839895f1c417a4d9cbee763d262
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 恢复代码
        // 共享设定
@@ -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++;
    }
}