Li Jun
2022-03-24 4452a59757a30ff31fd05c1c6cc8c46725008827
force-app/main/default/classes/PIHelper.cls
@@ -8,6 +8,7 @@
 * 
 * */
global without sharing class PIHelper {
    public static Set<String> displayByOrderNumberObject = new set<String>{'Report__c'};
    public static String getObjectKeyPrefix(String objName){
        try{
            schema.sObjectType sObjType = Schema.getGlobalDescribe().get(objName);
@@ -112,14 +113,40 @@
        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.SFRecordId__c=sfRecordId.substring(0, (sfRecordId.length() > MaxLogColumnLength ? MaxLogColumnLength : sfRecordId.length()));
        }else {
            String sfIds =JSON.serialize(idList);
           traLog.SFRecordId__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
        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,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,Full_View_Unified_Contact_URL__c,TransactionURL__c FROM PI_Policy_Configuration__c WHERE Sobject_Type__c =:sobjectType];
        System.debug('config = ' + config);
        //获取appid和appsecret
        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;
@@ -157,6 +184,9 @@
        //获取敏感字段
        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];
        if(displayByOrderNumberObject.contains(sobjectType)){
            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 order by Order_Number__c];
        }
        List<String> vLookUpFields = new List<String>();
        List<String> PIFields = new List<String>();
        for (PI_Field_Policy_Detail__c PIDetail : piIntegration.PIDetails) {
@@ -170,6 +200,7 @@
        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;
@@ -189,6 +220,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;}