From 4452a59757a30ff31fd05c1c6cc8c46725008827 Mon Sep 17 00:00:00 2001
From: Li Jun <buli@deloitte.com.cn>
Date: 星期四, 24 三月 2022 12:26:23 +0800
Subject: [PATCH] CommitNFM502API

---
 force-app/main/default/classes/NFM501FutureController.cls |    7 ++-
 force-app/main/default/classes/NFM503InfoFileBatch.cls    |   14 +++---
 force-app/main/default/classes/NFM502Controller.cls       |   11 ++++-
 force-app/main/default/classes/PIHelper.cls               |   28 +++++++++++++
 force-app/main/default/classes/NFM501Controller.cls       |   23 +++++++++--
 5 files changed, 66 insertions(+), 17 deletions(-)

diff --git a/force-app/main/default/classes/NFM501Controller.cls b/force-app/main/default/classes/NFM501Controller.cls
index 7b97d5a..dd3b353 100644
--- a/force-app/main/default/classes/NFM501Controller.cls
+++ b/force-app/main/default/classes/NFM501Controller.cls
@@ -213,13 +213,27 @@
             PIHelper.PIIntegration NFM501AWS =PIHelper.getPIIntegrationInfo('QLMNFM501');
             NFMUtil.response response = NFMUtil.getAWSQLMData(NFM501AWS.newUrl+'cursorMark='
                                          + oldMark.Internal_Value__c + '&pageSize=10', token);
+            system.debug('aws response---'+response.responseBody);                             
             //update to aws  sushanhu end 20220223
             //http鐨勬姤閿欏鐞嗭紙閲嶅彂涓夐亶锛�
-            //
-            if (String.isBlank(response.responseBody)) {
+            //update to aws sushanhu for pi 20220323 start
+            // if (String.isBlank(response.responseBody)) {
+            //     System.debug('-------7-------');
+            //     // aaaaaaaa 鎶ラ敊鍘熷洜鍐欑殑涓嶅
+            //     iflog.ErrorLog__c = '501Http鎶ラ敊淇℃伅锛�' + response.status;
+            //     if (!Manual_execution501) {
+            //         NFM501Controller.againSendRequest(iflog, 'retry_cnt__c', rowData);
+            //     }
+            //     update tokenTran;
+            //     update oldTimeTran;
+            //     return;
+            // }
+                system.debug('statuscode---'+response.status);
+                
+            if ('200'!=(response.status)) {
                 System.debug('-------7-------');
                 // aaaaaaaa 鎶ラ敊鍘熷洜鍐欑殑涓嶅
-                iflog.ErrorLog__c = '501Http鎶ラ敊淇℃伅锛�' + response.status;
+                iflog.ErrorLog__c = '501Http鎶ラ敊淇℃伅锛�' + response.status+response.responseBody;
                 if (!Manual_execution501) {
                     NFM501Controller.againSendRequest(iflog, 'retry_cnt__c', rowData);
                 }
@@ -227,12 +241,13 @@
                 update oldTimeTran;
                 return;
             }
-
+            //update to aws sushanhu for pi 20220323 start
             // aaaaaaaa 杩欓噷杩欎釜瀛楁鍙互鏀瑰悕涓篘FM501Response 涔嬬被鐨勶紝杩欐牱灏辨湁鍖哄垎搴︿簡
             // 瑙f瀽鍚庣殑code鎶ラ敊澶勭悊
             String NFM501responseBody = response.responseBody;
             System.debug('-------------NFM501responseBody------------' + NFM501responseBody);
             //update to aws response sushanhu 20220223 start
+            
             Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(NFM501responseBody);
             //String qlmResult =(String)results.get('object');
             String qlmResult =JSON.serialize(results.get('object'));
diff --git a/force-app/main/default/classes/NFM501FutureController.cls b/force-app/main/default/classes/NFM501FutureController.cls
index eef5e5c..9ad53de 100644
--- a/force-app/main/default/classes/NFM501FutureController.cls
+++ b/force-app/main/default/classes/NFM501FutureController.cls
@@ -554,6 +554,7 @@
             Map < string, Tender_information__c > TenderMap = new map < string, Tender_information__c > ();
             
             for (Tender_information__c TMap: updateTenderMap.values()) {
+                system.debug('TMap---'+JSON.serialize(TMap));
                 TenderMap.put(TMap.ProjectId__c, TMap);
                 PIHelper.IdList il= new PIHelper.IdList();
                 // add for pipl  sushanhu 20220310 start
@@ -598,13 +599,15 @@
                 throw new ControllerUtil.myException('aaa');
             }
             //纭浜嬪姟 add for pi sushanhu 20220310 start
-            PIHelper.confirmTrans('NFM501',1,null,txId,NFM501AWS.token,NFM501AWS.transactionURL,idList);
+            // PIHelper.confirmTrans('NFM501',1,null,txId,NFM501AWS.token,NFM501AWS.transactionURL,idList);
+            PIHelper.insertConfirmTrans('NFM501',1,null,txId,1,NFM501AWS.transactionURL,idList);
             //纭浜嬪姟 add for pi sushanhu 20220310 end
         } catch (Exception ex) {
             // 濡傛灉鏁版嵁鑾峰彇杩囩▼涓紝鏈夐敊璇紙鍚屼竴娓告爣锛屽鏋滄姤閿欙紝鏄粬閲嶆柊鑾峰彇涓�閬嶏紝濡傛灉涓夋閮芥病鑳借幏鍙栧埌锛屽氨鍙戦�侀偖浠舵姤閿欎俊鎭紝鐒跺悗鎵嬪姩杩涜鑾峰彇锛�
             Database.rollback(sp);
             //纭浜嬪姟 add for pi sushanhu 20220310 start
-            PIHelper.confirmTrans('NFM501',0,null,txId,NFM501AWS.token,NFM501AWS.transactionURL,idList);
+            // PIHelper.confirmTrans('NFM501',0,null,txId,NFM501AWS.token,NFM501AWS.transactionURL,idList);
+            PIHelper.insertConfirmTrans('NFM501',0,null,txId,1,NFM501AWS.transactionURL,idList);
             //纭浜嬪姟 add for pi sushanhu 20220310 end
             System.debug(Logginglevel.ERROR, 'QLMData_' + rowData.MessageGroupNumber__c + ':' + ex.getMessage());
             System.debug(Logginglevel.ERROR, 'QLMData_' + rowData.MessageGroupNumber__c + ':' + ex.getStackTraceString());
diff --git a/force-app/main/default/classes/NFM502Controller.cls b/force-app/main/default/classes/NFM502Controller.cls
index 128ebe1..c699cea 100644
--- a/force-app/main/default/classes/NFM502Controller.cls
+++ b/force-app/main/default/classes/NFM502Controller.cls
@@ -4,6 +4,7 @@
 	public static String transUrl;
 	public static String transId;
 	public static String token;
+	public static List<String> sfRecordIds =new List<String>();
 	//add staic sushanhu 20220302 end
 	public NFM502Controller(String rowData_id) {
 		this.rowData_id = rowData_id;
@@ -266,12 +267,15 @@
 				upsert fileList;
 			}
 			//纭浜嬪姟
-			List<String> sfRecordIds = new List<String>();
+			 
 			for (FileAddress__c file : fileList) {
+				system.debug('file--'+json.serialize(file));
+				system.debug('file.id'+file.Id);
 				sfRecordIds.add(file.Id);
 			}
 			//update to aws pi  sushanhu 20220301 end
-			 PIHelper.confirmFileTrans('NFM502',1,JSON.serialize(sfRecordIds),transId,token,transUrl);
+			//  PIHelper.confirmFileTrans('NFM502',1,JSON.serialize(sfRecordIds),transId,token,transUrl);
+			PIHelper.insertConfirmTrans('NFM502',1,JSON.serialize(sfRecordIds),transId,0,transUrl,null);
 			// if (!confirm) {
 			// 	//鍥炴粴
 			// }
@@ -282,7 +286,8 @@
 			// System.debug(Logginglevel.ERROR, 'QLMData_' + rowData.MessageGroupNumber__c + ':' + ex.getStackTraceString());
 			// logstr += '\n' + ex.getMessage();
 			//add 浜嬪姟纭 sushanhu 20220302 satrt
-			 PIHelper.confirmFileTrans('NFM502',0,'',transId,token,transUrl);
+			//  PIHelper.confirmFileTrans('NFM502',0,'',transId,token,transUrl);
+			 PIHelper.insertConfirmTrans('NFM502',0,JSON.serialize(sfRecordIds),transId,0,transUrl,null);
 			//add 浜嬪姟纭 sushanhu 20220302 end
 			iflog502.ErrorLog__c = '502鎶涘嚭寮傚父锛�' + ex.getMessage() + '\n'
 			                       + ex.getStackTraceString() + '\n' + iflog502.ErrorLog__c;
diff --git a/force-app/main/default/classes/NFM503InfoFileBatch.cls b/force-app/main/default/classes/NFM503InfoFileBatch.cls
index 4703d3f..5149138 100644
--- a/force-app/main/default/classes/NFM503InfoFileBatch.cls
+++ b/force-app/main/default/classes/NFM503InfoFileBatch.cls
@@ -6,7 +6,7 @@
 	public static String transId;
 	public static String token;
     public static  integer isSuccess=0; 
-    public static List<String> sfRecordIds;
+    public static List<String> sfRecordIds =new List<String>();
 	//add staic sushanhu 20220302 end
     Boolean IsNeedExecute = false;  //2021-06-28 mzy  WLIG-BYHD79  SFDC鐜batch鍚堝苟璋冩煡  鏄惁绗﹀悎鎵ц鏉′欢
     //add nfm 503 aws response start sushanhu 20220301
@@ -192,17 +192,17 @@
 
             update bidInfoFileList;
             // add 纭浜嬪姟 sushanhu 20220302 start
-            isSuccess =1;
+            
             if (fileList.size() > 0 ) {
 			for (FileAddress__c fileAddress : fileList) {
+                system.debug('fileAddress.Id---'+json.serialize(fileAddress));
 				sfRecordIds.add(fileAddress.Id);
                 system.debug('fileAddress.Id---'+fileAddress.Id);
 			}
             }
             system.debug('鎴愬姛鐨則oken'+token);
-            
-            //  PIHelper.confirmFileTrans('NFM503',1,JSON.serialize(sfRecordIds),transId,token,transUrl);
-			
+            isSuccess =1;
+           
             // if (!confirm) {
 			// 	//鍥炴粴
             //     if (sp != null) {
@@ -230,8 +230,8 @@
 
     global void finish(Database.BatchableContext BC) {
         // add confirm transaction for pipl  sushanhu 20220314 start
-        if (sfRecordIds==null) {
-            PIHelper.confirmFileTrans('NFM503',0,'',transId,token,transUrl);
+        if (isSuccess==0) {
+            PIHelper.confirmFileTrans('NFM503',isSuccess,'',transId,token,transUrl);
         }else {
             PIHelper.confirmFileTrans('NFM503',isSuccess,JSON.serialize(sfRecordIds),transId,token,transUrl);
         }
diff --git a/force-app/main/default/classes/PIHelper.cls b/force-app/main/default/classes/PIHelper.cls
index c5a220e..b83a4a5 100644
--- a/force-app/main/default/classes/PIHelper.cls
+++ b/force-app/main/default/classes/PIHelper.cls
@@ -113,12 +113,38 @@
         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.SFRecordId__c=sfRecordId.substring(0, (sfRecordId.length() > MaxLogColumnLength ? MaxLogColumnLength : sfRecordId.length()));
+        }else {
+            String sfIds =JSON.serialize(idList);
+           traLog.SFRecordId__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
         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,Full_View_Unified_Contact_URL__c,TransactionURL__c FROM PI_Policy_Configuration__c WHERE Sobject_Type__c =:sobjectType];
         System.debug('config = ' + config);
-        
+
         //鑾峰彇appid鍜宎ppsecret
         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) {

--
Gitblit v1.9.1