From b823c7f3569cf9368e2245846e918f78f32e903a Mon Sep 17 00:00:00 2001
From: GWY <guweiyiscp096@foxmail.com>
Date: 星期五, 15 四月 2022 11:38:47 +0800
Subject: [PATCH] Merge branch 'master' of http://47.92.229.245:8089/r/OlympusSSBG
---
force-app/main/default/classes/PIHelper.cls | 145 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 140 insertions(+), 5 deletions(-)
diff --git a/force-app/main/default/classes/PIHelper.cls b/force-app/main/default/classes/PIHelper.cls
index 3572a68..117d9aa 100644
--- a/force-app/main/default/classes/PIHelper.cls
+++ b/force-app/main/default/classes/PIHelper.cls
@@ -17,7 +17,88 @@
return '';
}
}
+ // confirm file transaction
+ // @future(callout =true)
+ public static void confirmFileTrans(String module,Integer isSuccess, String sfRecordId ,String transId ,String token,String transUrl){
+ Boolean result =false;
+ Transaction_Log__c traLog = new Transaction_Log__c();
+ traLog.Module__c = 'ConfirmFileTransaction '+module;
+ traLog.Interface_URL__c = transUrl;
+ traLog.TransId__c = transId;
+ // traLog.SFRecordId__c=sfRecordId;
+ Integer MaxLogColumnLength = 131072;
+ try {
+ Http http = new Http();
+ HttpRequest request = new HttpRequest();
+ request.setEndpoint(transUrl);
+ request.setMethod('POST');
+ request.setHeader('pi-token',token);
+ request.setHeader('Content-Type', 'application/json');
+ TransRequestBody requestBody =new TransRequestBody();
+ requestBody.isSuccess=isSuccess;
+ requestBody.sfRecordId=sfRecordId;
+ requestBody.txId =transId;
+ request.setBody(JSON.serialize(requestBody));
+ system.debug('request---'+request.tostring());
+ HttpResponse response = http.send(request);
+ system.debug('token--'+token);
+ system.debug('confirm result--'+response.getBody());
+ Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
+ result = (Boolean)results.get('success');
+ System.debug('result = ' + result);
+ traLog.Status__c = 'success';
+ String res=response.getBody();
+ traLog.Response__c=res.substring(0, (res.length() > MaxLogColumnLength ? MaxLogColumnLength : res.length()));
+
+ } catch (Exception e) {
+ traLog.Status__c = 'fail';
+ traLog.Response__c = e.getMessage();
+ }
+ insert traLog;
+ }
+ // confirm tx transaction
+ public static void confirmTrans(String module,Integer isSuccess, String sfRecordId ,String transId ,String token,String transUrl,List<idList> idList){
+ Boolean result =false;
+ Transaction_Log__c traLog = new Transaction_Log__c();
+ traLog.Module__c = 'Confirm Transaction '+module;
+ traLog.Interface_URL__c = transUrl;
+ traLog.TransId__c = transId;
+ Integer MaxLogColumnLength = 131072;
+ if (!String.isEmpty(sfRecordId)) {
+ traLog.SFRecordId__c=sfRecordId;
+ }else {
+ traLog.SFRecordId__c=JSON.serialize(idList);
+ }
+
+ try {
+ Http http = new Http();
+ HttpRequest request = new HttpRequest();
+ request.setEndpoint(transUrl);
+ request.setMethod('POST');
+ request.setHeader('pi-token',token);
+ request.setHeader('Content-Type', 'application/json');
+ TransactionRequestBody requestBody =new TransactionRequestBody();
+ requestBody.isSuccess=isSuccess;
+ requestBody.sfRecordId=sfRecordId;
+ requestBody.idList=idList;
+ requestBody.txId =transId;
+ request.setBody(JSON.serialize(requestBody));
+ system.debug('request---'+request.tostring());
+ HttpResponse response = http.send(request);
+ system.debug('confirm result--'+response.getBody());
+ Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
+ result = (Boolean)results.get('success');
+ System.debug('result = ' + result);
+ traLog.Status__c = 'success';
+ String res=response.getBody();
+ traLog.Response__c=res.substring(0, (res.length() > MaxLogColumnLength ? MaxLogColumnLength : res.length()));
+ } catch (Exception e) {
+ traLog.Status__c = 'fail';
+ traLog.Response__c = e.getMessage();
+ }
+ insert traLog;
+ }
// Use this log method
public static void saveTransLog(String module,String awsDataId,String sfId, String transId,String content,String status,String respMsg){
Transaction_Log__c traLog = new Transaction_Log__c();
@@ -31,14 +112,42 @@
traLog.Interface_URL__c = traLog.Module__c;
insert traLog;
}
+ //save qianlima log method add sushanhu 20220324
+ // model 0 涓烘枃浠� 1涓烘暟鎹�
+ public static void insertConfirmTrans(String module,Integer isSuccess, String sfRecordId ,String transId ,Integer model,String transUrl,List<idList> idList){
+ Boolean result =false;
+ Transaction_Log__c traLog = new Transaction_Log__c();
+ if (model==0) {
+ traLog.Module__c = 'ConfirmFileTransaction '+module;
+ }else {
+ traLog.Module__c = 'Confirm Transaction '+module;
+ }
+ traLog.Interface_URL__c = transUrl;
+ traLog.TransId__c = transId;
+ Integer MaxLogColumnLength = 131072;
+ if (!String.isEmpty(sfRecordId)) {
+ traLog.Request__c=sfRecordId.substring(0, (sfRecordId.length() > MaxLogColumnLength ? MaxLogColumnLength : sfRecordId.length()));
+ }else {
+ String sfIds =JSON.serialize(idList);
+ traLog.Request__c=sfIds.substring(0, (sfIds.length() > MaxLogColumnLength ? MaxLogColumnLength : sfIds.length()));
+ }
+ if(isSuccess==0){
+ traLog.Status__c = 'fail';
+ } else {
+ traLog.Status__c='success';
+ }
+ insert traLog;
+ }
public static PIIntegration getPIIntegrationInfo(String sobjectType){
PIIntegration piIntegration = new PIIntegration();
//鏌ヨurl
+ System.debug('thhsobjectType = ' + sobjectType);
+ // PI_Policy_Configuration__c config = [SELECT Full_New_URL__c,Full_New_Encrypt_URL__c,Full_Update_Encrypt_URL__c,Full_Search_URL__c,Full_Update_URL__c,Full_Undelete_URL__c,Full_Read_URL__c,Full_Delete_URL__c,Full_View_Unified_Contact_URL__c,TransactionURL__c FROM PI_Policy_Configuration__c WHERE Sobject_Type__c =:sobjectType];
PI_Policy_Configuration__c config = [select Full_New_URL__c,Full_Search_URL__c,Full_Update_URL__c,Full_Undelete_URL__c,Full_Read_URL__c,Full_Delete_URL__c,TransactionURL__c from PI_Policy_Configuration__c where Sobject_Type__c =: sobjectType];
- System.debug('config = ' + config);
+ System.debug('thhconfig = ' + config);
//鑾峰彇appid鍜宎ppsecret
- AWS_Integration_Info__mdt awsConfiguration = [SELECT App_Id__c,Token_URL__c,App_Secret__c,Host_URL__c FROM AWS_Integration_Info__mdt WHERE DeveloperName = 'AWS_Default_Configuration'];
+ AWS_Integration_Info__mdt awsConfiguration = [SELECT App_Id__c,Max_Query_Number__c,Token_URL__c,App_Secret__c,Host_URL__c FROM AWS_Integration_Info__mdt WHERE DeveloperName = 'AWS_Default_Configuration'];
if (awsConfiguration == null) {
System.debug('AWS_Integration_Info__mdt娌¢厤缃�');
return null;
@@ -60,13 +169,14 @@
request.setEndpoint(url);
request.setMethod('GET');
HttpResponse response = http.send(request);
- System.debug('response = ' + response);
+ system.debug('response.getBody()='+response.getBody());
Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
token = (String)results.get('object');
System.debug('token = ' + token);
}catch(Exception e){
- // System.debug(e.getMessage());
- // System.debug(e.getStackTraceString());
+ system.debug(e.getMessage());
+ system.debug(e.getStackTraceString());
+
Transaction_Log__c traLog = new Transaction_Log__c();
traLog.Module__c = 'Get Token';
traLog.Status__c = 'fail';
@@ -78,6 +188,7 @@
//Insert Get Token Log
//鑾峰彇鏁忔劅瀛楁
+ // piIntegration.PIDetails = [select id,PI_Policy_Configuration__r.Full_New_URL__c,PI_Policy_Configuration__r.Full_New_Encrypt_URL__c,PI_Policy_Configuration__r.Full_Update_Encrypt_URL__c, Enable_Encrypt__c, SF_Field_API_Name__c,SF_Field_Encrypted_API__c, AWS_Field_API__c,AWS_Encrypted_Field_API__c,Field_Type__c from PI_Field_Policy_Detail__c where PI_Policy_Configuration_Name__c =:sobjectType and Enable_Encrypt__c=true];
piIntegration.PIDetails = [select id,PI_Policy_Configuration__r.Full_New_URL__c, Enable_Encrypt__c, SF_Field_API_Name__c,SF_Field_Encrypted_API__c, AWS_Field_API__c,AWS_Encrypted_Field_API__c,Field_Type__c from PI_Field_Policy_Detail__c where PI_Policy_Configuration_Name__c =:sobjectType and Enable_Encrypt__c=true];
List<String> vLookUpFields = new List<String>();
List<String> PIFields = new List<String>();
@@ -92,11 +203,15 @@
System.debug('PIFields = ' + PIFields.toString());
//濉厖鏁版嵁
+ piIntegration.maxQueryNumber = Integer.valueof(awsConfiguration.Max_Query_Number__c);
piIntegration.newUrl = config.Full_New_URL__c;
piIntegration.updateUrl = config.Full_Update_URL__c;
piIntegration.queryUrl = config.Full_Read_URL__c;
piIntegration.deleteUrl = config.Full_Delete_URL__c;
piIntegration.undeleteUrl = config.Full_Undelete_URL__c;
+ // piIntegration.viewUnifiedContactUrl = config.Full_View_Unified_Contact_URL__c;
+ // piIntegration.newEncryptUrl = config.Full_New_Encrypt_URL__c;
+ // piIntegration.updateEncryptUrl = config.Full_Update_Encrypt_URL__c;
piIntegration.transactionURL = config.TransactionURL__c;
piIntegration.hostUrl = awsConfiguration.Host_URL__c;
piIntegration.searchUrl = config.Full_Search_URL__c;
@@ -110,6 +225,7 @@
return piIntegration;
}
global class PIIntegration{
+ public Integer maxQueryNumber{set;get;}
public String sobjectPrefix{set;get;}
public String searchUrl{set;get;}
public String newUrl{set;get;}
@@ -117,6 +233,9 @@
public String queryUrl{set;get;}
public String deleteUrl{set;get;}
public String undeleteUrl{set;get;}
+ public String viewUnifiedContactUrl{set;get;}
+ public String newEncryptUrl{set;get;}
+ public String updateEncryptUrl{set;get;}
public String hostUrl{set;get;}
public String token{set;get;}
public String awsAppId{set;get;}
@@ -126,4 +245,20 @@
public List<String> PIFields{set;get;}
public List<PI_Field_Policy_Detail__c > PIDetails{set;get;}
}
+ global class TransRequestBody{
+ public Integer isSuccess{set;get;}
+ public String sfRecordId{set;get;}
+ public String txId{set;get;}
+
+ }
+ global class TransactionRequestBody{
+ public Integer isSuccess{set;get;}
+ public String sfRecordId{set;get;}
+ public String txId{set;get;}
+ public List<idList> idList{set;get;}
+ }
+ global class idList{
+ public String awsId{set;get;}
+ public String sfRecordId{set;get;}
+ }
}
\ No newline at end of file
--
Gitblit v1.9.1