buli
2022-05-13 2f4492ee18f90274582fcc2bb06f5e9bf64136e8
force-app/main/default/classes/SBG001TriggerHandler.cls
@@ -8,7 +8,6 @@
    //001修改Rest gwy start 2021-04-06
    //public class SBG001ResrException extends Exception {}
    public static String status;
    public static String responseBody;//dennis update for pi 2022/3/9
    public class SBG001 {
        public SSBDCustomerContacts_element SSBDCustomerContacts;
    }
@@ -34,7 +33,6 @@
        public String ContactCode;  
        public String ContactEffectiveDateFrom;
        public String PurposeOfAdvice;
        public String DataId;//dennis update for pi 2022/3/9
        
    }
        //001修改Rest gwy end 2021-04-06
@@ -67,7 +65,6 @@
                                || acc.RecordTypeId == '01228000000TdFG'    // NDT
                                || acc.RecordTypeId == '01228000000TdFL'    // ANI
                                || acc.RecordTypeId == '01228000000TdF1'    // BS
                                || acc.RecordTypeId == '0120T0000003Cxt'    // IE直销
                            )
                            && acc.stautesD__c == 'Pass') || acc.RecordTypeId == SBG001TriggerHandler.Account_Agency_Id //办事处
                    ) {
@@ -88,7 +85,6 @@
                                || acc.RecordTypeId == '01228000000TdFG'    // NDT
                                || acc.RecordTypeId == '01228000000TdFL'    // ANI
                                || acc.RecordTypeId == '01228000000TdF1'    // BS 
                                || acc.RecordTypeId == '0120T0000003Cxt'    // IE直销
                            )
                            && acc.stautesD__c == 'Pass'
                            && (acc.ManagementCode_Ext__c       != old.ManagementCode_Ext__c
@@ -163,7 +159,6 @@
                                || con.AccountRecordTypeId__c == '01228000000TdFB'      // RVI
                                || con.AccountRecordTypeId__c == '01228000000TdFG'      // NDT
                                || con.AccountRecordTypeId__c == '01228000000TdF1'      // BS
                                || con.AccountRecordTypeId__c == '0120T0000003Cxt'    // IE直销
                            )
                            && con.StatusD__c == 'Pass') || con.AccountRecordTypeId__c == SBG001TriggerHandler.Account_Agency_Id// 办事处
                    ) {
@@ -189,7 +184,6 @@
                                || con.AccountRecordTypeId__c == '01228000000TdFG'      // NDT
                                || con.AccountRecordTypeId__c == '01228000000TdF1'      // BS
                                || con.AccountRecordTypeId__c == SBG001TriggerHandler.Account_Agency_Id // 办事处
                                || con.AccountRecordTypeId__c == '0120T0000003Cxt'    // IE直销
                            )
                            && con.StatusD__c == 'Pass'
                            && (con.ManagementCode_Ext__c   != old.ManagementCode_Ext__c
@@ -330,7 +324,7 @@
                SSBDCustomerContact.CustomerDescription = acc.FacilityName__c;
                SSBDCustomerContact.CustomerDescription2Description3
                                            = (String.isBlank(acc.DivisionName__c) ? '' : (acc.DivisionName__c=='无' ? '' : acc.DivisionName__c));
                if (acc.RecordTypeId == '01228000000TdF6' || acc.RecordTypeId == '01228000000TdFB' ||  acc.RecordTypeId == '01228000000TdFG' ||  acc.RecordTypeId == '01228000000TdFL' || acc.RecordTypeId == '0120T0000003Cxt') {      // IE or RVI
                if (acc.RecordTypeId == '01228000000TdF6' || acc.RecordTypeId == '01228000000TdFB' ||  acc.RecordTypeId == '01228000000TdFG' ||  acc.RecordTypeId == '01228000000TdFL') {      // IE or RVI
                    SSBDCustomerContact.CustomerDescription2Description3 += ',' + (String.isBlank(acc.EnglishName__c) ? '' : acc.EnglishName__c);
                } else {
                    SSBDCustomerContact.CustomerDescription2Description3 += ',' + (String.isBlank(acc.DepartmentName__c) ? '' : acc.Departmentname__c);
@@ -518,8 +512,7 @@
                    Phone, MobilePhone,
                    Fax, Email, PostCode__c, Address1__c,
                    CreatedDate, LastModifiedDate,
                    Account.UserType__c,
                    AWS_Data_Id__c//dennis update for pi 2022/3/9
                    Account.UserType__c
               from Contact where Id IN :conIds];          // 削除データを検索しないはず、All ROWS いらないはず
            // System.debug(Logginglevel.DEBUG, 'SBG001_' + iflog.Name + ' conList.size()=' + conList.size());
@@ -539,7 +532,7 @@
                SSBDCustomerContact.CustomerDescription = con.Account.FacilityName__c;
                SSBDCustomerContact.CustomerDescription2Description3
                                        = (String.isBlank(con.Account.DivisionName__c) ? '' : (con.Account.DivisionName__c=='无' ? '' : con.Account.DivisionName__c));
                if (con.AccountRecordTypeId__c == '01228000000TdF6' || con.AccountRecordTypeId__c == '01228000000TdFB' || con.AccountRecordTypeId__c == '01228000000TdFG' || con.AccountRecordTypeId__c == '01228000000TdFL' || con.AccountRecordTypeId__c == '0120T0000003Cxt') {      // IE or RVI
                if (con.AccountRecordTypeId__c == '01228000000TdF6' || con.AccountRecordTypeId__c == '01228000000TdFB' || con.AccountRecordTypeId__c == '01228000000TdFG' || con.AccountRecordTypeId__c == '01228000000TdFL') {      // IE or RVI
                    SSBDCustomerContact.CustomerDescription2Description3 += ',' + (String.isBlank(con.Account.EnglishName__c) ? '' : con.Account.EnglishName__c);
                } else {
                    SSBDCustomerContact.CustomerDescription2Description3 += ',' + (String.isBlank(con.Account.DepartmentName__c) ? '' : con.Account.Departmentname__c);
@@ -552,7 +545,6 @@
                                                + ',' + (String.isBlank(con.Email) ? '' : con.Email);
                SSBDCustomerContact.PostalCode          = String.isBlank(con.PostCode__c) ? '' : con.PostCode__c;
                SSBDCustomerContact.Address             = String.isBlank(con.Address1__c) ? '' : con.Address1__c;
                SSBDCustomerContact.DataId             = String.isBlank(con.AWS_Data_Id__c) ? '' : con.AWS_Data_Id__c;
                SSBDCustomerContact.CustomerCategory    = GetCustomerCategory(null,con);//'客户' + (String.isBlank(con.Account.ProductSegment__c) ? '' : con.Account.ProductSegment__c);
                //  JZHU-BPQBVK-IE最终用户接口传输逻辑变更(update-Start-20200525)
                SSBDCustomerContact.UserType = '';
@@ -743,54 +735,25 @@
            logstr = iflog.Log__c;
        }
        try{
             //update to aws 2022/3/9 dennis
             PIHelper.PIIntegration pi =PIHelper.getPIIntegrationInfo('SBG001');
             NFMUtil.response result =NFMUtil.sendToPiAWS(rowDataStr,pi.newUrl,pi.token);
             system.debug('aws result---'+result);
             status = result.status;
             system.debug('aws status---'+status);
             responseBody=result.responseBody;
            //  Map<String, Object> res = (Map<String, Object>)JSON.deserializeUntyped(responseBody);
            //  status=(String)res.get(status);
             if ('200'.equals(status)) {
            status = NFMUtil.sendToSapRet(rowDataStr, NFMUtil.SBG001_ENDPOINT);
            system.debug('status--->'+status);
            if (status == 'OK') {
                logstr += '\nstatus='+status;
                rowData.retry_cnt__c = 0;
             } else {
            } else {
                if (rowData.retry_cnt__c == null) rowData.retry_cnt__c = 0;
                if (rowData.retry_cnt__c < batch_retry_max_cnt) {
                    rowData.retry_cnt__c++;
                    LogAutoSendSchedule.assignOneMinute();
                }
                if (rowData.retry_cnt__c >= batch_retry_max_cnt) {
                    //add respomseBody 记录错误信息 by sushanhu 20220406 start
                    rowData.ErrorLog__c = 'status:' + status +responseBody+
                    rowData.ErrorLog__c = 'status:' + status +
                                          '\n错误次数已经超过自动送信设定的最大次数,请手动送信';
                 //add respomseBody 记录错误信息 by sushanhu 20220406 end
                }
             }
             //update to aws 2022/3/9 dennis
             logstr += '\nend';
             // rowData.retry_cnt__c=0;
            // status = NFMUtil.sendToSapRet(rowDataStr, NFMUtil.SBG001_ENDPOINT);
            // system.debug('status--->'+status);
            // if (status == 'OK') {
            //     logstr += '\nstatus='+status;
            //     rowData.retry_cnt__c = 0;
            // } else {
            //     if (rowData.retry_cnt__c == null) rowData.retry_cnt__c = 0;
            //     if (rowData.retry_cnt__c < batch_retry_max_cnt) {
            //         rowData.retry_cnt__c++;
            //         LogAutoSendSchedule.assignOneMinute();
            //     }
            //     if (rowData.retry_cnt__c >= batch_retry_max_cnt) {
            //         rowData.ErrorLog__c = 'status:' + status +
            //                               '\n错误次数已经超过自动送信设定的最大次数,请手动送信';
            //     }
            // }
            // logstr += '\nend';
            // // rowData.retry_cnt__c=0;
            }
            logstr += '\nend';
            // rowData.retry_cnt__c=0;
        }catch(Exception ex) {
            // TODO IOException
            // エラーが発生した場合