| | |
| | | /** |
| | | * @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; |
| | | } |
| | |
| | | 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; |
| | |
| | | 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,DealerSalesStaffNameA__c,Dealer_A__r.ManagementCode_Ext__c,Dealer_B__r.ManagementCode_F__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 |
| | | 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, |
| | |
| | | |
| | | //CBPR |
| | | if (ord.Opportunity.Dealer__r.DummyDealer__c == true || ord.Opportunity.SalesChannel__c == 'direct'){ |
| | | quotation.DealerCode = ord.Opportunity.Account.ManagementCode_F__c; |
| | | if (ord.Opportunity.TradeType__c == 'Tax Exemption' && ord.Opportunity.SalesChannel__c == 'direct') { |
| | | quotation.SalesAccountCode = ord.Opportunity.Account.ManagementCode_F__c; |
| | | }else { |
| | | quotation.SalesAccountCode = ord.SpecialDeliveryAccount_D__r.ManagementCode_F__c; |
| | | quotation.DealerCode = ord.Opportunity.Account.ManagementCode_F__c; |
| | | if (ord.Opportunity.TradeType__c == 'Tax Exemption' && ord.Opportunity.SalesChannel__c == 'direct') { |
| | | quotation.SalesAccountCode = ord.Opportunity.Account.ManagementCode_F__c; |
| | | }else { |
| | | quotation.SalesAccountCode = ord.SpecialDeliveryAccount_D__r.ManagementCode_F__c; |
| | | } |
| | | } |
| | | } |
| | | |
| | | else{ |
| | | quotation.DealerCode = ord.Opportunity.Dealer__r.ManagementCode_Ext__c; |
| | | quotation.SalesAccountCode = ord.Opportunity.Account.ManagementCode_F__c; |
| | |
| | | quotations.GeData.add(quotation); |
| | | quotation.OrderCode = ord.OrderNumber; |
| | | quotation.OpportunityCode = ord.Opportunity.InquiryNumber__c; |
| | | // //quotation.SalesAccountCode = ord.Opportunity.Account.ManagementCode_F__c; |
| | | // quotation.SalesAccountCode = ord.Opportunity.Account.ManagementCode_F__c; |
| | | quotation.ProductSegment = ord.Opportunity.ProductSegment__c; |
| | | quotation.TradeType = ord.Opportunity.TradeType__c; |
| | | quotation.MachineParts = ord.Opportunity.Machine_Parts__c; |
| | | quotation.SalesChannel = ord.Opportunity.Machine_Parts__c == 'Parts' ? '40' : ord.Opportunity.SalesChannel__c == 'dealer' ? '41' : '42'; |
| | | quotation.DeliveryDate = NFMUtil.formatDate2Str(ord.Opportunity.ExpectedDeliveryDate__c); |
| | | // // quotation.DealerCode = ord.Opportunity.Dealer__r.ManagementCode_Ext__c; |
| | | // quotation.DealerCode = ord.Opportunity.Dealer__r.ManagementCode_Ext__c; |
| | | quotation.DealerSalesStaffName = ord.Opportunity.DealerSalesStaffName__c; |
| | | quotation.ForeignTradeCompany = ord.ForeignTradeCompany_D__r.ManagementCode_F__c; |
| | | quotation.PaymentCondition = ord.PaymentTerms__c; |
| | | 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; |
| | |
| | | logstr = iflog.Log__c; |
| | | } |
| | | try{ |
| | | |
| | | NFMUtil.sendToSap(rowDataStr, NFMUtil.SBG027_ENDPOINT); |
| | | rowData.retry_cnt__c = 0; |
| | | |
| | | //update to aws 2022/3/9 dennis |
| | | PIHelper.PIIntegration pi =PIHelper.getPIIntegrationInfo('SBG027'); |
| | | 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)) { |
| | | logstr += status + '\n'; |
| | | rowData.retry_cnt__c = 0; |
| | | } |
| | | //add by sushanhu 20220406 写入错误日志 start |
| | | else { |
| | | iflog.ErrorLog__c +=responseBody; |
| | | } |
| | | //add by sushanhu 20220406 写入错误日志 end |
| | | // NFMUtil.sendToSap(rowDataStr, NFMUtil.SBG027_ENDPOINT); |
| | | // rowData.retry_cnt__c = 0; |
| | | }catch(Exception ex) { |
| | | // TODO IOException |
| | | // エラーが発生した場合 |