binxie
2023-06-26 1b3fb93f787b8b546a307bf063183f5295d183f8
force-app/main/default/classes/NFMUtil.cls
@@ -126,7 +126,7 @@
            NFM702_ENDPOINT = 'https://wdp.olympus.com.cn:44301/RESTAdapter/NFM702';
            NFM703_ENDPOINT = 'https://wdp.olympus.com.cn:44301/RESTAdapter/NFM703';
            
            NFM112_ENDPOINT = 'http://wdp.olympus.com.cn:8089/RESTAdapter/NFM112';
            NFM112_ENDPOINT = 'https://wdp.olympus.com.cn:44301/RESTAdapter/NFM112';
            NFM115_ENDPOINT = 'https://wdp.olympus.com.cn:44301/RESTAdapter/NFM115';
@@ -189,7 +189,7 @@
            NFM703_ENDPOINT = 'https://wdp.olympus.com.cn:44302/RESTAdapter/NFM703';
            //先款后修
            NFM112_ENDPOINT = 'http://wdp.olympus.com.cn:8089/RESTAdapter/NFM112';
            NFM112_ENDPOINT = 'https://wdp.olympus.com.cn:44302/RESTAdapter/NFM112';
            //样本管理
            NFM115_ENDPOINT = 'https://wdp.olympus.com.cn:44302/RESTAdapter/NFM115';
@@ -1259,6 +1259,31 @@
        }
        return rowDataSFDC;
    }
    // 2022-12-06   zyh   add   start   DB202211540694-重发只发自己
    public static BatchIF_Log__c LogAutoSend(BatchIF_Log__c rowDataSFDC, Exception ex, String status, Boolean check){
        Integer batch_retry_max_cnt = Integer.valueOf(System.Label.batch_retry_max_cnt);
        if (rowDataSFDC.retry_cnt__c == null) rowDataSFDC.retry_cnt__c = 0;
        if (rowDataSFDC.retry_cnt__c < batch_retry_max_cnt){
            rowDataSFDC.retry_cnt__c++;
            // 20230131 ljh start
            // LogAutoSendSchedule.logId = rowDataSFDC.Id;  // 赋值本日志Id
            // LogAutoSendSchedule.messageGroupNumber = rowDataSFDC.MessageGroupNumber__c;  // messagenum号赋值 2023-01-19 zyh add
            // LogAutoSendSchedule.type = rowDataSFDC.Type__c;  // 赋值本日志type 2023-01-19 zyh add
            System.debug('NFM接口测试==========>Id:' + rowDataSFDC.Id + ';===MessageGroupNumber:' + rowDataSFDC.MessageGroupNumber__c + ';===Type' + rowDataSFDC.Type__c);
            // LogAutoSendSchedule.assignOneMinute();
            LogAutoSendSchedule.assignOneMinute(rowDataSFDC.MessageGroupNumber__c,rowDataSFDC.Type__c);
            // 20230131 ljh end
        }
        if (rowDataSFDC.retry_cnt__c >= batch_retry_max_cnt){
            if (ex == null) {
                rowDataSFDC.ErrorLog__c = status + '\n错误次数已经超过自动送信设定的最大次数,请手动送信';
            } else {
                rowDataSFDC.ErrorLog__c = ex.getMessage() + '\n' + ex.getStackTraceString() + '\n' + rowDataSFDC.ErrorLog__c+'错误次数已经超过自动送信设定的最大次数,请手动送信';
            }
        }
        return rowDataSFDC;
    }// 建议以后重发调用此方法
    // 2022-12-06   zyh   add   end   DB202211540694-重发只发自己
    // https://oly.ngrok.kunchuangtech.net/api/sso/sfdc_activitydata
    //发送给共通平台 精琢技术 thh 2021-09-22 start
    public static String sendToComPlat(String rowDataStr, String endpoint) {
@@ -1280,6 +1305,74 @@
    }
    //发送给共通平台 精琢技术 thh 2021-09-22 end
    //zhj batch 调用624接口的时候 需要调用AWS 2023-01-08 start
    public static void batchSendToAWS624(String rowDataId) {
        System.debug('enter batchSendToAWS624');
        BatchIF_Log__c rowData = [Select Id, Name, Log__c,Is_Error__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c, Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, retry_cnt__c,NFM624_Secondary_processing__c  from BatchIF_Log__c where RowDataFlg__c = true and Id =: rowDataId];
        String rowDataStr = getRowDataStr(rowData);
        List < NFM624Rest2.GeData > GeDataList = (List < NFM624Rest2.GeData > ) JSON.deserialize(rowDataStr, List < NFM624Rest2.GeData > .class);
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        PIHelper.PIIntegration documentPI=PIHelper.getPIIntegrationInfo('Document');
        String hostUrl = documentPI.hostUrl;
        System.debug('GeDataList[0].nfm624RequestId = ' + GeDataList[0].nfm624RequestId);
        System.debug('documentPI.hostUrl = ' + documentPI.hostUrl);
        System.debug('documentPI.token = ' + documentPI.token);
        request.setEndpoint(hostUrl + '/api/nfm/reCallNFM624Batch?nfm624RequestId=' + GeDataList[0].nfm624RequestId + '&rowDataId=' + rowDataId);
        request.setMethod('GET');
        request.setHeader('pi-token',documentPI.token);
        HttpResponse response = http.send(request);
        System.debug('send batchSendToAWS624');
    }
    //zhj batch 调用624接口的时候 需要调用AWS 2023-01-08 end
    //zhj 重新 调用624接口的时候 调用AWS 2023-01-11 start
    public static void againSendToAWS624(String rowDataId) {
        if(!Test.isRunningTest()){
            System.debug('enter againSendToAWS624');
            BatchIF_Log__c rowData = [Select Id, Name, Log__c,Is_Error__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c, Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, retry_cnt__c,NFM624_Secondary_processing__c  from BatchIF_Log__c where RowDataFlg__c = true and Id =: rowDataId];
            String rowDataStr = getRowDataStr(rowData);
            List < NFM624Rest2.GeData > GeDataList = (List < NFM624Rest2.GeData > ) JSON.deserialize(rowDataStr, List < NFM624Rest2.GeData > .class);
            Http http = new Http();
            HttpRequest request = new HttpRequest();
            PIHelper.PIIntegration documentPI=PIHelper.getPIIntegrationInfo('Document');
            String hostUrl = documentPI.hostUrl;
            System.debug('GeDataList[0].nfm624RequestId = ' + GeDataList[0].reCallNfm624RequestId);
            System.debug('documentPI.hostUrl = ' + documentPI.hostUrl);
            System.debug('documentPI.token = ' + documentPI.token);
            request.setEndpoint(hostUrl + '/api/nfm/reCallNFM624?reCallNfm624RequestId=' + GeDataList[0].reCallNfm624RequestId + '&rowDataId=' + rowDataId);
            request.setMethod('GET');
            request.setHeader('pi-token',documentPI.token);
            HttpResponse response = http.send(request);
            System.debug('send againSendToAWS624');
        }
    }
    //zhj 重新 调用624接口的时候 调用AWS 2023-01-11 end
    //zhj 新方案改造 624Batch更新日志 将日志内容更新到rowdata里面 2023-01-09 start
    public static BatchIF_Log__c updateRowData(String rowDataId, Object NFMData) {
        BatchIF_Log__c rowData = [Select Id, Name, Log__c,Is_Error__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c, Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c, retry_cnt__c,NFM624_Secondary_processing__c  from BatchIF_Log__c where Id =: rowDataId];
        String rowDataStr = JSON.serialize(NFMData);
        if (rowDataStr.length() > 0) {
            Integer splitIdx = 1;
            while (rowDataStr.length() > 0) {
                if (splitIdx == 1) {
                    rowData.put('Log__c', rowDataStr.substring(0, (rowDataStr.length() > MaxLogColumnLength ? MaxLogColumnLength : rowDataStr.length())));
                } else if (splitIdx == 13) {
                    rowData.ErrorLog__c = rowDataStr;
                    break;
                } else {
                    rowData.put('Log' + splitIdx + '__c', rowDataStr.substring(0, (rowDataStr.length() > MaxLogColumnLength ? MaxLogColumnLength : rowDataStr.length())));
                }
                splitIdx++;
                rowDataStr = rowDataStr.substring((rowDataStr.length() > MaxLogColumnLength ? MaxLogColumnLength : rowDataStr.length()));
            }
        }
        update rowData;
        return rowData;
    }
    //zhj 新方案改造 624Batch更新日志 将日志内容更新到rowdata里面 2023-01-09 end
    public static Integer ControllerUtil() {
        Integer i = 0;
        i++;