From 3ba0123db48f8bab81ddf0913e1b95280ef545e8 Mon Sep 17 00:00:00 2001
From: Li Jun <buli@deloitte.com.cn>
Date: 星期四, 31 三月 2022 17:56:53 +0800
Subject: [PATCH] Deploy0331

---
 force-app/main/default/classes/NFM503InfoFileBatch.cls |   56 +++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 33 insertions(+), 23 deletions(-)

diff --git a/force-app/main/default/classes/NFM503InfoFileBatch.cls b/force-app/main/default/classes/NFM503InfoFileBatch.cls
index d9199c8..fa5c005 100644
--- a/force-app/main/default/classes/NFM503InfoFileBatch.cls
+++ b/force-app/main/default/classes/NFM503InfoFileBatch.cls
@@ -2,10 +2,12 @@
     public String TenId;
     public String bidInfoFileID;
     //add staic sushanhu 20220302 start
-	public static String transUrl;
-	public static String transId;
-	public static String token;
-	//add staic sushanhu 20220302 end
+    public static String transUrl;
+    public static String transId;
+    public static String token;
+    public static  integer isSuccess=0; 
+    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
     global class File{
@@ -28,8 +30,8 @@
 
     global Database.QueryLocator start(Database.BatchableContext bc) {
         String query = 'select Id, Tender_information__c, infoAddress__c, ' +
-                       'Tender_information__r.InfoType__c, isProcessed__c, ' +
-                       ' ErrorMessage__c from bidInfoFile__c where isProcessed__c = false ';
+                        'Tender_information__r.InfoType__c, isProcessed__c, ' +
+                        ' ErrorMessage__c from bidInfoFile__c where isProcessed__c = false ';
         if (String.isNotBlank(TenId)) {
             query += 'and Tender_information__r.Id =: TenId';
         }
@@ -47,8 +49,8 @@
         queryfileList.add(bidInfoFile.infoAddress__c);
         try {
            //update 鍚宻taic 20220302 satrt
-			// String token;
-			//update 鍚宻taic 20220302 end
+            // String token;
+            //update 鍚宻taic 20220302 end
             Datetime oldTime;
             // 浠庤浆鎹㈣〃涓幏鍙杢oken
             BatchIF_Transfer__c token503 = [Select ID, NFM501_Token__c
@@ -95,7 +97,6 @@
             transUrl =pi.searchUrl;
             NFMUtil.response response = NFMUtil.getAWSQLMData(pi.newUrl ,JSON.serialize(queryfileList), token);
             system.debug('aws result'+response.responseBody);
-        
             Map<String, Object> result = (Map<String, Object>)JSON.deserializeUntyped(response.responseBody);
             system.debug('NFM503 aws result--'+response.responseBody+'status'+response.status);
             transId =(String)result.get('txId');
@@ -191,21 +192,23 @@
 
             update bidInfoFileList;
             // add 纭浜嬪姟 sushanhu 20220302 start
-            List<String> sfRecordIds = new List<String>();
-			for (FileAddress__c fileAddress : fileList) {
-				sfRecordIds.add(fileAddress.Id);
-                system.debug('fileAddress.Id---'+fileAddress.Id);
-			}
-            system.debug('鎴愬姛鐨則oken'+token);
             
-             PIHelper.confirmFileTrans('NFM503',1,JSON.serialize(sfRecordIds),transId,token,transUrl);
-			
+            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);
+            isSuccess =1;
+           
             // if (!confirm) {
-			// 	//鍥炴粴
+            //  //鍥炴粴
             //     if (sp != null) {
             //         Database.rollback(sp);
             //     }
-			// }
+            // }
             // add 纭浜嬪姟 sushanhu 20220302 end
             if (System.Test.isRunningTest()) {
                 throw new ControllerUtil.myException('aaa');
@@ -215,9 +218,9 @@
             if (sp != null) {
                 Database.rollback(sp);
             }
-            //add 纭浜嬪姟 20220302 sushanhu start
-            system.debug('澶辫触鐨則oken'+token);
-             PIHelper.confirmFileTrans('NFM503',0,'',transId,token,transUrl);
+            // //add 纭浜嬪姟 20220302 sushanhu start
+            // system.debug('澶辫触鐨則oken'+token);
+            //  PIHelper.confirmFileTrans('NFM503',0,'',transId,token,transUrl);
             //add 纭浜嬪姟 20220302 sushanhu end
             bidInfoFile.ErrorMessage__c = '503鎶涘嚭寮傚父锛�' + ex.getMessage() + '\n' + ex.getStackTraceString();
             system.debug('ErrorMessage'+bidInfoFile.ErrorMessage__c);
@@ -226,6 +229,13 @@
     }
 
     global void finish(Database.BatchableContext BC) {
-
+        // add confirm transaction for pipl  sushanhu 20220314 start
+        if (isSuccess==0) {
+            PIHelper.confirmFileTrans('NFM503',isSuccess,'',transId,token,transUrl);
+        }else {
+            PIHelper.confirmFileTrans('NFM503',isSuccess,JSON.serialize(sfRecordIds),transId,token,transUrl);
+        }
+         
+         // add confirm transaction for pipl  sushanhu 20220314 end
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1