Li Jun
2022-03-24 4452a59757a30ff31fd05c1c6cc8c46725008827
CommitNFM502API
5个文件已修改
83 ■■■■ 已修改文件
force-app/main/default/classes/NFM501Controller.cls 23 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/NFM501FutureController.cls 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/NFM502Controller.cls 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/NFM503InfoFileBatch.cls 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/PIHelper.cls 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/NFM501Controller.cls
@@ -213,13 +213,27 @@
            PIHelper.PIIntegration NFM501AWS =PIHelper.getPIIntegrationInfo('QLMNFM501');
            NFMUtil.response response = NFMUtil.getAWSQLMData(NFM501AWS.newUrl+'cursorMark='
                                         + oldMark.Internal_Value__c + '&pageSize=10', token);
            system.debug('aws response---'+response.responseBody);
            //update to aws  sushanhu end 20220223
            //http的报错处理(重发三遍)
            //
            if (String.isBlank(response.responseBody)) {
            //update to aws sushanhu for pi 20220323 start
            // if (String.isBlank(response.responseBody)) {
            //     System.debug('-------7-------');
            //     // aaaaaaaa 报错原因写的不对
            //     iflog.ErrorLog__c = '501Http报错信息:' + response.status;
            //     if (!Manual_execution501) {
            //         NFM501Controller.againSendRequest(iflog, 'retry_cnt__c', rowData);
            //     }
            //     update tokenTran;
            //     update oldTimeTran;
            //     return;
            // }
                system.debug('statuscode---'+response.status);
            if ('200'!=(response.status)) {
                System.debug('-------7-------');
                // aaaaaaaa 报错原因写的不对
                iflog.ErrorLog__c = '501Http报错信息:' + response.status;
                iflog.ErrorLog__c = '501Http报错信息:' + response.status+response.responseBody;
                if (!Manual_execution501) {
                    NFM501Controller.againSendRequest(iflog, 'retry_cnt__c', rowData);
                }
@@ -227,12 +241,13 @@
                update oldTimeTran;
                return;
            }
            //update to aws sushanhu for pi 20220323 start
            // aaaaaaaa 这里这个字段可以改名为NFM501Response 之类的,这样就有区分度了
            // 解析后的code报错处理
            String NFM501responseBody = response.responseBody;
            System.debug('-------------NFM501responseBody------------' + NFM501responseBody);
            //update to aws response sushanhu 20220223 start
            Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(NFM501responseBody);
            //String qlmResult =(String)results.get('object');
            String qlmResult =JSON.serialize(results.get('object'));
force-app/main/default/classes/NFM501FutureController.cls
@@ -554,6 +554,7 @@
            Map < string, Tender_information__c > TenderMap = new map < string, Tender_information__c > ();
            
            for (Tender_information__c TMap: updateTenderMap.values()) {
                system.debug('TMap---'+JSON.serialize(TMap));
                TenderMap.put(TMap.ProjectId__c, TMap);
                PIHelper.IdList il= new PIHelper.IdList();
                // add for pipl  sushanhu 20220310 start
@@ -598,13 +599,15 @@
                throw new ControllerUtil.myException('aaa');
            }
            //确认事务 add for pi sushanhu 20220310 start
            PIHelper.confirmTrans('NFM501',1,null,txId,NFM501AWS.token,NFM501AWS.transactionURL,idList);
            // PIHelper.confirmTrans('NFM501',1,null,txId,NFM501AWS.token,NFM501AWS.transactionURL,idList);
            PIHelper.insertConfirmTrans('NFM501',1,null,txId,1,NFM501AWS.transactionURL,idList);
            //确认事务 add for pi sushanhu 20220310 end
        } catch (Exception ex) {
            // 如果数据获取过程中,有错误(同一游标,如果报错,是他重新获取一遍,如果三次都没能获取到,就发送邮件报错信息,然后手动进行获取)
            Database.rollback(sp);
            //确认事务 add for pi sushanhu 20220310 start
            PIHelper.confirmTrans('NFM501',0,null,txId,NFM501AWS.token,NFM501AWS.transactionURL,idList);
            // PIHelper.confirmTrans('NFM501',0,null,txId,NFM501AWS.token,NFM501AWS.transactionURL,idList);
            PIHelper.insertConfirmTrans('NFM501',0,null,txId,1,NFM501AWS.transactionURL,idList);
            //确认事务 add for pi sushanhu 20220310 end
            System.debug(Logginglevel.ERROR, 'QLMData_' + rowData.MessageGroupNumber__c + ':' + ex.getMessage());
            System.debug(Logginglevel.ERROR, 'QLMData_' + rowData.MessageGroupNumber__c + ':' + ex.getStackTraceString());
force-app/main/default/classes/NFM502Controller.cls
@@ -4,6 +4,7 @@
    public static String transUrl;
    public static String transId;
    public static String token;
    public static List<String> sfRecordIds =new List<String>();
    //add staic sushanhu 20220302 end
    public NFM502Controller(String rowData_id) {
        this.rowData_id = rowData_id;
@@ -266,12 +267,15 @@
                upsert fileList;
            }
            //确认事务
            List<String> sfRecordIds = new List<String>();
            for (FileAddress__c file : fileList) {
                system.debug('file--'+json.serialize(file));
                system.debug('file.id'+file.Id);
                sfRecordIds.add(file.Id);
            }
            //update to aws pi  sushanhu 20220301 end
             PIHelper.confirmFileTrans('NFM502',1,JSON.serialize(sfRecordIds),transId,token,transUrl);
            //  PIHelper.confirmFileTrans('NFM502',1,JSON.serialize(sfRecordIds),transId,token,transUrl);
            PIHelper.insertConfirmTrans('NFM502',1,JSON.serialize(sfRecordIds),transId,0,transUrl,null);
            // if (!confirm) {
            //     //回滚
            // }
@@ -282,7 +286,8 @@
            // System.debug(Logginglevel.ERROR, 'QLMData_' + rowData.MessageGroupNumber__c + ':' + ex.getStackTraceString());
            // logstr += '\n' + ex.getMessage();
            //add 事务确认 sushanhu 20220302 satrt
             PIHelper.confirmFileTrans('NFM502',0,'',transId,token,transUrl);
            //  PIHelper.confirmFileTrans('NFM502',0,'',transId,token,transUrl);
             PIHelper.insertConfirmTrans('NFM502',0,JSON.serialize(sfRecordIds),transId,0,transUrl,null);
            //add 事务确认 sushanhu 20220302 end
            iflog502.ErrorLog__c = '502抛出异常:' + ex.getMessage() + '\n'
                                   + ex.getStackTraceString() + '\n' + iflog502.ErrorLog__c;
force-app/main/default/classes/NFM503InfoFileBatch.cls
@@ -6,7 +6,7 @@
    public static String transId;
    public static String token;
    public static  integer isSuccess=0; 
    public static List<String> sfRecordIds;
    public static List<String> sfRecordIds =new List<String>();
    //add staic sushanhu 20220302 end
    Boolean IsNeedExecute = false;  //2021-06-28 mzy  WLIG-BYHD79  SFDC环境batch合并调查  是否符合执行条件
    //add nfm 503 aws response start sushanhu 20220301
@@ -192,17 +192,17 @@
            update bidInfoFileList;
            // add 确认事务 sushanhu 20220302 start
            isSuccess =1;
            if (fileList.size() > 0 ) {
            for (FileAddress__c fileAddress : fileList) {
                system.debug('fileAddress.Id---'+json.serialize(fileAddress));
                sfRecordIds.add(fileAddress.Id);
                system.debug('fileAddress.Id---'+fileAddress.Id);
            }
            }
            system.debug('成功的token'+token);
            //  PIHelper.confirmFileTrans('NFM503',1,JSON.serialize(sfRecordIds),transId,token,transUrl);
            isSuccess =1;
            // if (!confirm) {
            //     //回滚
            //     if (sp != null) {
@@ -230,8 +230,8 @@
    global void finish(Database.BatchableContext BC) {
        // add confirm transaction for pipl  sushanhu 20220314 start
        if (sfRecordIds==null) {
            PIHelper.confirmFileTrans('NFM503',0,'',transId,token,transUrl);
        if (isSuccess==0) {
            PIHelper.confirmFileTrans('NFM503',isSuccess,'',transId,token,transUrl);
        }else {
            PIHelper.confirmFileTrans('NFM503',isSuccess,JSON.serialize(sfRecordIds),transId,token,transUrl);
        }
force-app/main/default/classes/PIHelper.cls
@@ -113,12 +113,38 @@
        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];
        System.debug('config = ' + config);
        //获取appid和appsecret
        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) {