buli
2022-05-13 2f4492ee18f90274582fcc2bb06f5e9bf64136e8
force-app/main/default/classes/SBG027Controller.cls
@@ -1,13 +1,5 @@
/**
 * @description       :
 * @author            : ChangeMeIn@UserSettingsUnder.SFDoc
 * @group             :
 * @last modified on  : 03-09-2022
 * @last modified by  : ChangeMeIn@UserSettingsUnder.SFDoc
**/
public without sharing class SBG027Controller {
    public static String responseBody;//dennis 2022/3/9
    public static String status;//dennis 2022/3/9
    public class SBG027 {
        public GeDatas_element GeDatas;
    }
@@ -31,7 +23,6 @@
        public String SalesChannel;
        public String DealerCode;
        public String DealerSalesStaffName;
        public String DataId; //dennis update for pi 2022/3/9
        public String DeliveryDate;
        public String PaymentCondition;
        public String SpecialWarranty;
@@ -116,8 +107,7 @@
                                                Opportunity.SalesChannel__c, Opportunity.ExpectedDeliveryDate__c, Opportunity.DealerId__c,Opportunity.DealerSalesStaffName__c,OlympusContractPricesD__c,SpecialDeliveryContact_D__c,Opportunity.SpecialDeliveryContact_D__r.ManagementCode_F__c,
                                                Opportunity.ForeignTradeCompany__c, Opportunity.SpecialDeliveryAddress__c,PaymentTerms__c,SpecialDeliveryContact__c,PDF_Sp_Shipment_Term__c,PDF_Sp_ShippingTerms__c,
                                                ForeignTradeCompany_D__r.ManagementCode_F__c, SpecialDeliveryAccount_D__r.ManagementCode_F__c, SpecialDeliveryContact2_D__r.ManagementCode_F__c,Opportunity.Dealer__r.DummyDealer__c,ContractPriceTotal__c,
                                                If_Supervise__c,CrossCooperativeDealerCode__c,SplitRatio__c,CrossCooperativeProject__c,Level_Category__c,
                                                Opportunity.AWS_Data_Id__c //dennis start for pi 2022/3/3
                                                If_Supervise__c,CrossCooperativeDealerCode__c,SplitRatio__c,CrossCooperativeProject__c,Level_Category__c
                                             from order where Id IN :ordIds ];
            //List<order> ordList = [select Id,Name,Opportunity.Name, Opportunity.CurrencyIsoCode,OrderNumber,Opportunity.ForeignTradeCompany__r.ManagementCode_F__c,CustomerContractPriceD__c,SpecialCondition_text__c,SalesChannel__c,
            //                                    Owner.Name,Opportunity.AccountId__c,Opportunity.InquiryNumber__c,Opportunity.SpecialDeliveryAddress__r.ManagementCode_F__c, ServiceFee_D__c,Opportunity.SpecialDeliveryAddress_D__c,Opportunity.SpecialDeliveryAddress_D__r.ManagementCode_F__c,
@@ -228,7 +218,6 @@
                quotation.EndUser            =  ord.EndUserD__r.ManagementCode_F__c;
                quotation.DeliveryDate = NFMUtil.formatDate2Str(ord.ExpDelDate__c);
                quotation.ServiceFee      =  ord.ServiceFee_D__c;
                quotation.DataId                   = ord.Opportunity.AWS_Data_Id__c;//dennis start for pi 2022/3/9 update to oppotuinity dataid
                //2017/01/15追加
                if(ord.Opportunity.SalesChannel__c == 'direct' && ord.Opportunity.Machine_Parts__c == 'Parts'){
                     quotation.Discount         = 0;
@@ -254,19 +243,6 @@
                quotation.Other2            = other2;//ord.SpecialCondition_text__c;
                quotation.Other3            = ord.Shipment_Term_D__c + ',' + ord.Shipment_Term2_D__c;
                // 跨区域销售 XHL 20210831 Start
                /*quotation.CoopAgent = '';
                quotation.CoopAgentPCT = '';
                if (ord.CrossCooperativeProject__c) {//跨省份合作项目
                    quotation.CoopAgent = ord.Dealer_B__r.ManagementCode_F__c;//合作区域代理商Code
                    quotation.DealerCode         = ord.Dealer_A__r.ManagementCode_Ext__c;
                    quotation.DealerSalesStaffName = ord.DealerSalesStaffNameA__c;
                    String splitRatio = ord.SplitRatio__c;
                    if (String.isNotBlank(splitRatio) && splitRatio.indexof(':') > 0) {
                        Integer pct = Integer.valueOf(splitRatio.split(':')[1].trim())*10;
                        quotation.CoopAgentPCT = String.valueof(pct);//业绩拆分比例(取:后边的值*10)
                    }
                } */
                quotation.CoopAgent = '';
                quotation.CoopAgentPCT = '';
                if (ord.CrossCooperativeProject__c) {//跨省份合作项目
@@ -402,37 +378,10 @@
        } else {
            logstr = iflog.Log__c;
        } 
          // 添加aws上线开关 by sushanhu 20220420
          Boolean piOn =AWSServiceTool.getAWSServiceStatus();
        try{
            //add by sushanhu for test 20220421
            //piOn=false;
            if (piOn) {
                //update to aws 2022/3/9 dennis
            PIHelper.PIIntegration pi =PIHelper.getPIIntegrationInfo('SBG027');
            // NFMUtil.response result =NFMUtil.sendToPiAWS(rowDataStr,pi.newUrl,pi.token);
            AWSServiceTool.response result = AWSServiceTool.sendToPiAWS(rowDataStr,pi.newUrl,pi.token);//update forpipl by sushanhu 20220425
            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)) {
                logstr += status + '\n';
                rowData.retry_cnt__c = 0;
            }
            //add by sushanhu 20220406 写入错误日志 start
            else {
                iflog.ErrorLog__c +=responseBody;
            }
            //add by sushanhu 20220406 写入错误日志 end
            }else {
                NFMUtil.sendToSap(rowDataStr, NFMUtil.SBG027_ENDPOINT);
                rowData.retry_cnt__c = 0;
            }
            
            NFMUtil.sendToSap(rowDataStr, NFMUtil.SBG027_ENDPOINT);
            rowData.retry_cnt__c = 0;
        }catch(Exception ex) {
            // TODO IOException
            // エラーが発生した場合