涂煌豪
2022-03-11 927e81f5c3402d3307b2e7b4b079cc99ecef4d18
NFMUtil
1个文件已修改
187 ■■■■■ 已修改文件
force-app/main/default/classes/NFMUtil.cls 187 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/NFMUtil.cls
@@ -78,8 +78,7 @@
            //NFM007_ENDPOINT = 'http://wdp.olympus.com.cn:8089/RESTAdapter/NFM007';
            NFM007_ENDPOINT = 'https://wdp.olympus.com.cn:44301/RESTAdapter/NFM007';
            NFM008_ENDPOINT = 'https://owdc-test.olympus.co.jp/XISOAPAdapter/MessageServlet?senderParty=&senderService=OCM_SFDC_T&receiverParty=&receiverService=&interface=NFM008_Sync_BC2GPI&interfaceNamespace=http%3A%2F%2Folympus.co.jp%2Fgpi%2FNFM008';
            // NFM103_ENDPOINT = 'http://wdp.olympus.com.cn:8089/RESTAdapter/NFM103';
            NFM103_ENDPOINT = 'https://sfpi-mebg-test.olympuschina.com/api/nfm/103';//aws 103接口
            NFM103_ENDPOINT = 'http://wdp.olympus.com.cn:8089/RESTAdapter/NFM103';
            // NFM106_ENDPOINT = 'https://owdc-test.olympus.co.jp/XISOAPAdapter/MessageServlet?senderParty=&senderService=OCM_SFDC_T&receiverParty=&receiverService=&interface=NFM106_Sync_BC2GPI&interfaceNamespace=http%3A%2F%2Folympus.co.jp%2Fgpi%2FNFM106';
            NFM106_ENDPOINT = 'http://wdp.olympus.com.cn:8089/RESTAdapter/NFM106';
            //NFM106_ENDPOINT = 'https://sfdc-ocm-test.olympus.co.jp/XISOAPAdapter/MessageServlet?senderParty=&senderService=OCM_SFDC_T&receiverParty=&receiverService=&interface=NFM106_Sync_BC2GPI&interfaceNamespace=http%3A%2F%2Folympus.co.jp%2Fgpi%2FNFM106';
@@ -101,16 +100,16 @@
            NFM401_ENDPOINT = 'http://ec2-161-189-3-104.cn-northwest-1.compute.amazonaws.com.cn:8088/dojtest/dojInfo/recevie';
            NFM402_ENDPOINT = 'http://ec2-161-189-3-104.cn-northwest-1.compute.amazonaws.com.cn:8088/dojtest/dojInfo/getDojInfoByRefNo';
            // NFM501_ENDPOINT = 'http://cusdata.qianlima.com/test/v1/info/page/';
            NFM501_ENDPOINT = 'https://sfpi-mebg-test.olympuschina.com/api/nfm/501';
            NFM502_ENDPOINT = 'http://cusdata.qianlima.com/test/v1/info/detailHtml?url=';
            NFM504_ENDPOINT = 'http://cusdata.qianlima.com/test/v1/customer/albs/feedback';
            NFM501_ENDPOINT = 'http://cusdata.qianlima.com/v1/info/page/';
            NFM502_ENDPOINT = 'http://cusdata.qianlima.com/v1/info/detailHtml?url=';
            NFM504_ENDPOINT = 'http://cusdata.qianlima.com/v1/customer/albs/feedback';
            CBPR_Auth_Sap = 'Basic U0ZEQ19XU1VTRVI6cG9xMTIzNDU=';
            // LHJ 20180824 CBPR End
            //CBPR_Auth_Spo = 'http://cbpr.chinacloudsites.cn/sfdc/token';
            CBPR_Auth_Spo = 'http://cbpr.olympuschina.com/sfdc/token';
            QLM_Token = 'http://cusdata.qianlima.com/v1/token';
            // 智慧医疗&服务新系统通信 客户接口
            NFM601_ENDPOINT = 'https://wdp.olympus.com.cn:44301/RESTAdapter/NFM601';
@@ -128,11 +127,11 @@
            NFM115_ENDPOINT = 'https://wdp.olympus.com.cn:44301/RESTAdapter/NFM115';
            // 新服务系统 测试环境
            AWS_DOMAIN = 'https://olympus.bqbot.com';
             // 新服务系统 本地环境(临时)
            // 新服务系统 本地环境(临时)
            // AWS_DOMAIN = 'http://114.249.236.98:29990';
            // AWS_DOMAIN = 'http://jzbase.bqbot.com:29990';
            // AWS_DOMAIN = 'http://114.249.238.243:29990';
            requestURILMS = '/v1/uc/user/syncOlympusUnit';
            appSecretLMS = 'CAE1D68BE3EB4F7AB5FE97EBDD11B83E';
@@ -144,7 +143,7 @@
            NFM007_ENDPOINT = 'https://wdp.olympus.com.cn:44302/RESTAdapter/NFM007';
            NFM008_ENDPOINT = 'https://owdc.olympus.co.jp/XISOAPAdapter/MessageServlet?senderParty=&senderService=OCM_SFDC_P&receiverParty=&receiverService=&interface=NFM008_Sync_BC2GPI&interfaceNamespace=http%3A%2F%2Folympus.co.jp%2Fgpi%2FNFM008';
            //NFM103_ENDPOINT = 'https://owdc.olympus.co.jp/XISOAPAdapter/MessageServlet?senderParty=&senderService=OCM_SFDC_P&receiverParty=&receiverService=&interface=NFM103_Sync_BC2GPI&interfaceNamespace=http%3A%2F%2Folympus.co.jp%2Fgpi%2FNFM103';
            NFM103_ENDPOINT = 'https://wdp.olympus.com.cn:44302/RESTAdapter/NFM103';// 原saphost
            NFM103_ENDPOINT = 'https://wdp.olympus.com.cn:44302/RESTAdapter/NFM103';
            //NFM106_ENDPOINT = 'https://owdc.olympus.co.jp/XISOAPAdapter/MessageServlet?senderParty=&senderService=OCM_SFDC_P&receiverParty=&receiverService=&interface=NFM106_Sync_BC2GPI&interfaceNamespace=http%3A%2F%2Folympus.co.jp%2Fgpi%2FNFM106';
            NFM106_ENDPOINT = 'https://wdp.olympus.com.cn:44302/RESTAdapter/NFM106';
            // LHJ 20180824 CBPR Start
@@ -159,8 +158,7 @@
            NFM401_ENDPOINT = 'http://ec2-161-189-3-104.cn-northwest-1.compute.amazonaws.com.cn:8082/doj/dojInfo/recevie';
            NFM402_ENDPOINT = 'http://ec2-161-189-3-104.cn-northwest-1.compute.amazonaws.com.cn:8082/doj/dojInfo/getDojInfoByRefNo';
            // NFM501_ENDPOINT = 'http://cusdata.qianlima.com/v1/info/page/';
            NFM501_ENDPOINT   ='https://sfpi-mebg-test.olympuschina.com/api/nfm/501';
            NFM501_ENDPOINT = 'http://cusdata.qianlima.com/v1/info/page/';
            NFM502_ENDPOINT = 'http://cusdata.qianlima.com/v1/info/detailHtml?url=';
            NFM504_ENDPOINT = 'http://cusdata.qianlima.com/v1/customer/albs/feedback';
            CBPR_Auth_Sap = 'Basic U0ZEQ19XU1VTRVI6cG9wMTIzNDU=';
@@ -176,6 +174,9 @@
            // 智慧医疗&服务新系统通信 用户接口
            NFM621_ENDPOINT = 'https://wdp.olympus.com.cn:44302/RESTAdapter/NFM621';
            NFM622_ENDPOINT = 'https://api-platform.olympuschina.com/prod-api/api/sso/sfdc_activitydata';
            NFM701_ENDPOINT = 'https://wdp.olympus.com.cn:44302/RESTAdapter/NFM701';
            NFM702_ENDPOINT = 'https://wdp.olympus.com.cn:44302/RESTAdapter/NFM702';
            NFM703_ENDPOINT = 'https://wdp.olympus.com.cn:44302/RESTAdapter/NFM703';
            //样本管理
            NFM115_ENDPOINT = 'https://wdp.olympus.com.cn:44302/RESTAdapter/NFM115';
@@ -230,25 +231,7 @@
        webservice String timestamp;
        webservice String appKey;
    }
    global class NFMResponse{
        public Boolean SFStatus;
        public String SFMessage;
        public StaticResponse staticResponse;
    }
    global class StaticResponse{
        public string status;
        public String Message;
        public StaticResponse(){
            status='Success';
            Message='';
        }
    }
    public static NFMResponse getNFMResponse(){
        NFMResponse  result=new NFMResponse();
        result.staticResponse =new StaticResponse();
        return result;
    }
    /**
     * @return yyyyMMdd の日付文字列
     */
@@ -361,7 +344,7 @@
        return rtn;
    }
     /**
    /**
     * add       wangweipeng       2022/02/11
     * [formatDateTime2StrDateTime description]
     * @param  dt [日期/时间]
@@ -395,7 +378,7 @@
        return parseStr2Date(pDateTime.substring(0, 8));
    }
     /**
    /**
     * add    wangweipeng           2022/02/15
     * [parseStr2DateTime description]
     * @param  pDate [日期(不包括时间)]
@@ -436,13 +419,13 @@
                return null;
            }
            rtn = Datetime.newinstance(
                      Integer.valueOf(pDate.substring(0, 4)),
                      Integer.valueOf(pDate.substring(4, 6)),
                      Integer.valueOf(pDate.substring(6, 8)),
                      Integer.valueOf(pTime.substring(0, 2)),
                      Integer.valueOf(pTime.substring(2, 4)),
                      Integer.valueOf(pTime.substring(4, 6))
                  );
                Integer.valueOf(pDate.substring(0, 4)),
                Integer.valueOf(pDate.substring(4, 6)),
                Integer.valueOf(pDate.substring(6, 8)),
                Integer.valueOf(pTime.substring(0, 2)),
                Integer.valueOf(pTime.substring(2, 4)),
                Integer.valueOf(pTime.substring(4, 6))
            );
        } catch (Exception ex) {
            System.debug(Logginglevel.ERROR, 'NFMUtil#parseStr2DateTime(' + pDate + ', ' + pTime + ')' + ex.getMessage());
        }
@@ -472,10 +455,10 @@
                return null;
            }
            rtn = Date.newinstance(
                      Integer.valueOf(pStr.substring(0, 4)),
                      Integer.valueOf(pStr.substring(4, 6)),
                      Integer.valueOf(pStr.substring(6, 8))
                  );
                Integer.valueOf(pStr.substring(0, 4)),
                Integer.valueOf(pStr.substring(4, 6)),
                Integer.valueOf(pStr.substring(6, 8))
            );
        } catch (Exception ex) {
            System.debug(Logginglevel.ERROR, 'NFMUtil#parseStr2Date(' + pStr + ')' + ex.getMessage());
        }
@@ -621,6 +604,32 @@
        return rowData;
    }
    // public static BatchIF_Log__c makeRowDataToOnline(NFMUtil.MonitoringToOnline Monitoring, String NFMType, Object NFMData) {
    //     BatchIF_Log__c rowData = new BatchIF_Log__c();
    //     rowData.Type__c = NFMType;
    //     rowData.MessageGroupNumber__c = Monitoring.MessageGroupNumber;
    //     rowData.TransmissionDateTime__c = Monitoring.TransmissionDateTime;
    //     rowData.RowDataFlg__c = true;
    //     rowData.Log__c = '';
    //     rowData.ErrorLog__c = '';
    //     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()));
    //         }
    //     }
    //     return rowData;
    // }
    public static BatchIF_Log__c makeRowData(BatchIF_Log__c iflog, String NFMType, Object NFMData) {
        // TransmissionDateTimeの設定
        Datetime nowDT = Datetime.now();
@@ -862,36 +871,13 @@
        system.debug('ress:' + ress);
        return new response(ress, resb);
    }
    // send to aws to sap sushuanhu 20220222
    public static response sendToPiAWS(String rowDataStr, String endpoint,String awsToken) {
        Http http = new Http();
        HttpRequest req = new HttpRequest();
        HTTPResponse res;
        String resb;
        req.setTimeout(120000);
        req.setEndpoint(endpoint);
        req.setMethod('POST');
        req.setHeader('Content-Type', 'application/json');
        req.setHeader('pi-token', awsToken);
        req.setBody(rowDataStr);
        res = http.send(req);
        string ress =String.valueof(res.getStatusCode());
        resb = res.getBody();
        system.debug('ress:' + ress);
        return new response(ress, resb);
    }
    // 获取aws token sushanhu 20220222
    public static response getAwsToken(){
        String responseBody = AWSServiceTool.getAWSToken();
        return new response('success', responseBody);
    }
    public class response {
        public string status;
        public string responseBody;
        public response(string status, string responseBody ) {
            this.status         = status;
            this.responseBody   = responseBody;
        public response(string status, string responseBody) {
            this.status = status;
            this.responseBody = responseBody;
        }
    }
    // WLIG-BXQBH6 end
@@ -923,10 +909,10 @@
            return null;
        }
        return Time.newInstance(
                   Integer.valueOf(timeStr.substring(0, 2)),
                   Integer.valueOf(timeStr.substring(2, 4)),
                   Integer.valueOf(timeStr.substring(4, 6)),
                   0);
            Integer.valueOf(timeStr.substring(0, 2)),
            Integer.valueOf(timeStr.substring(2, 4)),
            Integer.valueOf(timeStr.substring(4, 6)),
            0);
    }
    //insert by rentongxiao 2020-10-12 end
@@ -947,8 +933,8 @@
        //1、 获取token:
        Http http = new Http();
        HttpRequest req = new HttpRequest();
        String content = 'appKey=' + EncodingUtil.urlEncode(appKey, 'UTF-8') +
                         '&appSecret=' + EncodingUtil.urlEncode(appSecret, 'UTF-8');
        String content = 'appKey=' + EncodingUtil.urlEncode(appKey, 'UTF-8') +
            '&appSecret=' + EncodingUtil.urlEncode(appSecret, 'UTF-8');
        //请求路径
        req.setEndpoint(QLM_Token);
        req.setHeader('Content-Type', QLM_NFM501_Point);
@@ -1006,51 +992,6 @@
        //正常执行
        return new response(ress, response.getBody());
    }
    // NEW QLM AWS 501  接口 sushanhu 20220223
    public static response getAWSQLMData(String endpoint, String token) {
        //2、获取招标信息:记得使用1中获取的token
        Http http = new Http();
        HttpRequest req = new HttpRequest();
        req.setHeader('Content-Type', 'application/json');
        req.setHeader('pi-token',  token);
        req.setTimeout(120000);
        req.setEndpoint(endpoint);
        req.setMethod('GET');
        HTTPResponse response = http.send(req);
        String statusCode = response.getStatus();
        System.debug('response:' + response);
        //http:状态和code
        //如果状态不通过 , 则将状态及空的的数据 , 返回
        if (String.isNotBlank(statusCode)) {
            return new response(statusCode, null);
        }
        System.debug('=====2======' + response.getBody());
        //正常执行
        return new response(statusCode, response.getBody());
    }
    // NEW QLM AWS 502 503接口 sushanhu 20220223
    public static response getAWSQLMData(String endpoint,String jsonStr,  String token) {
        //2、获取招标信息:记得使用1中获取的token
        Http http = new Http();
        HttpRequest req = new HttpRequest();
        req.setHeader('Content-Type', 'application/json');
        req.setHeader('pi-token',  token);
        req.setTimeout(120000);
        req.setEndpoint(endpoint);
        req.setMethod('POST');
        req.setBody(jsonStr);
        HTTPResponse response = http.send(req);
        String statusCode = response.getStatus();
        System.debug('response:' + response);
        //http:状态和code
        //如果状态不通过 , 则将状态及空的的数据 , 返回
        if (String.isNotBlank(statusCode)) {
            return new response(statusCode, null);
        }
        System.debug('=====2======' + response.getBody());
        //正常执行
        return new response(statusCode, response.getBody());
    }
    //接口3,获取其他附件
    public static response503 getFileData(String token503, String endpoint) {
@@ -1097,7 +1038,7 @@
    public static String sendTenInfo(String token504, String jsonStr, String endpoint) {
        Http http = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint(endpoint);
        req.setEndpoint('http://cusdata.qianlima.com/test/v1/customer/albs/feedback');
        req.setHeader('open-authorization', 'Bearer' + token504);
        req.setHeader('Content-Type', 'application/x-www-form-urlencoded');
        req.setMethod('POST');
@@ -1215,10 +1156,8 @@
        system.debug('resb:' + resb);
        return resb;
    }
    //发送给共通平台 精琢技术 thh 2021-09-22 end
    public static Integer ControllerUtil() {
        Integer i = 0;
        i++;