From d8dc84a3d56df839895f1c417a4d9cbee763d262 Mon Sep 17 00:00:00 2001
From: 高章伟 <gaozhangwei@prec-tech.com>
Date: 星期五, 03 三月 2023 14:50:59 +0800
Subject: [PATCH] gzw 测试环境代码更新

---
 force-app/main/default/classes/NFM501FutureController.cls |  147 +++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 130 insertions(+), 17 deletions(-)

diff --git a/force-app/main/default/classes/NFM501FutureController.cls b/force-app/main/default/classes/NFM501FutureController.cls
index fc47917..f8352ff 100644
--- a/force-app/main/default/classes/NFM501FutureController.cls
+++ b/force-app/main/default/classes/NFM501FutureController.cls
@@ -3,32 +3,56 @@
     //鍏堝畾涔�
     // 	鎶曟爣鎴鏃堕棿
     // 2021/01/04 18:00
+    //add by sushanhu for pi 20220310 start
+    public  String txId;
+    
+    //add by sushanhu for pi 20220310 end
     public String rowData_id;
     public NFM501FutureController(String rowData_id) {
         this.rowData_id = rowData_id;
     }
+     //add by sushanhu for pi 20220310 start
+    //  public NFM501FutureController(String rowData_id,String txId) {
+    //      this.rowData_id = rowData_id;
+    //     this.txId = txId;
+    //  }
+     //add by sushanhu for pi 20220310 end
     public static Integer batch_retry_max_cnt = Integer.valueOf(System.Label.batch_retry_max_cnt);
     public void execute(QueueableContext context /*, String iflog_Id*/ ) {
         //闇�鍔犱竴鏁板瓧鍙橀噺锛堝鏋滆幏鍙栧埌 html闄勪欢锛屽叾浠栭檮浠讹紝鍦ㄦ棩蹇椾腑鏄剧ず鏁伴噺锛�
         BatchIF_Log__c rowData = [Select Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c,
             Log4__c, Log5__c, Log6__c, Log7__c, Log8__c, Log9__c, Log10__c, Log11__c,
             Log12__c, MessageGroupNumber__c, retry_cnt__c, NFM501Future_Count__c,
-            NFM501_Web_Annex_Count__c
+            NFM501_Web_Annex_Count__c,
+            AWS_Transaction_Id__c //ADD BY SUSHANHU for pi 20220310
             from BatchIF_Log__c where RowDataFlg__c = true and Id = : rowData_id
         ];
         //瀛樻斁鎶ラ敊淇℃伅
+        //add by sushanhu for pipl 20220311 start
+        system.debug('txId from log'+rowData.AWS_Transaction_Id__c);
+        if (!String.isEmpty(rowData.AWS_Transaction_Id__c)) {
+            txId =rowData.AWS_Transaction_Id__c; //add by sushanhu for pipl 20220310
+        }else {
+            system.debug('txId from NF501'+txId);
+        }
+         //add by sushanhu for pipl 20220311 end
+        system.debug('nfm501future awsid'+txId);
         BatchIF_Log__c iflog501Future = new BatchIF_Log__c();
         iflog501Future.Type__c = 'NFM501';
         iflog501Future.MessageGroupNumber__c = rowData.MessageGroupNumber__c;
         iflog501Future.Log__c = ' ';
         iflog501Future.ErrorLog__c = ' ';
         iflog501Future.RowDataFlg__c = false;
+        iflog501Future.AWS_Transaction_Id__c=rowData.AWS_Transaction_Id__c;
         insert iflog501Future;
-        NFM501FutureController.main(rowData.Id, iflog501Future.Id, false);
+        NFM501FutureController.main(rowData.Id, iflog501Future.Id, false,txId);
     }
+    
     @future(callout = true)
     //閲嶅彂锛堟妸浠庢帴鍙h幏鍙栧埌鐨勬暟鎹瓨鍏ユ棩蹇椾腑锛屽啀鎶婃棩蹇椾腑瀛樺叆鐨勬暟鎹噸鏂癑OSN瑙f瀽涓�閬嶏級
-    public static void main(String rowData_id, String iflog_id, boolean Manual_execution501future) {
+    public static void main(String rowData_id, String iflog_id, boolean Manual_execution501future,
+                                String txId //澧炲姞浜嬪姟id forpipl 20220310 
+            ) {
         BatchIF_Log__c rowData = [Select Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c,
             Log4__c, Log5__c, Log6__c, Log7__c, Log8__c, Log9__c, Log10__c, Log11__c,
             Log12__c, MessageGroupNumber__c, retry_cnt__c, NFM501Future_Count__c,
@@ -47,11 +71,15 @@
         rowData.ErrorLog__c = rowData.ErrorLog__c == null ? '' : rowData.ErrorLog__c;
         // System.debug('+++++++1+++++++'+iflog501Future);
         String QLMDataStr = NFMUtil.QLMgetRowDataStr(rowData);
+        system.debug('QLMDataStr---'+QLMDataStr);
         NFM501controller.AllData getQLMData1 = (NFM501controller.AllData)
         JSON.deserialize(QLMDataStr, NFM501controller.AllData.class);
+        system.debug('getQLMData1---'+json.serialize(getQLMData1));
         if (getQLMData1 == null) {
             return;
         }
+        List<PIHelper.IdList> idList = new List<PIHelper.IdList>();//瀛樺偍鏇存柊鍚庡緱sfid鍜宎wsid add by sushanhu 20220310
+        PIHelper.PIIntegration NFM501AWS =PIHelper.getPIIntegrationInfo('QLMNFM501'); //add by sushanhu 20220310
         Savepoint sp = Database.setSavepoint();
         //IF杞崲琛紙涓哄疄鐜伴�夐」鍒楄〃鐨勪笅鎷夐�夐」锛�
         Map < String, String > transferMap = new Map < String, String > ();
@@ -95,7 +123,8 @@
             SumUnit__c, AreaCity__c, AreaCountry__c, AgentUnit1__c,
             AgentUnit2__c, AgentUnit3__c, AgentUnit4__c, AgentUnit5__c,
             ZhaoRelationName__c, ZhongRelationName__c,
-            publicDate__c, noticeDate__c, ResultDate__c
+            publicDate__c, noticeDate__c, ResultDate__c,
+            AWS_Data_Id__c //ADD FOR pi SUSHANHU 20220311
             FROM Tender_information__c Where ProjectId__c in : projectIdList
         ];
         Map < String, Tender_information__c > TenMap = new Map < String, Tender_information__c > ();
@@ -122,15 +151,24 @@
             tempbidInfoFileURLList.add(bidInfoFile.infoAddress__c);
             SelectbidInfoFileMap.put(bidInfoFile.Tender_information__r.ProjectId__c, tempbidInfoFileURLList);
         }
+        
         try {
             // 鎷涙爣淇℃伅
             Map < string, List < bidInfoFile__c >> createbidInfoFileMap = new map < string, List < bidInfoFile__c >> ();
             Map < String, List < Tender_information_details__c >> tempList1 = new Map < String, List < Tender_information_details__c >> ();
             Map < string, Tender_information__c > updateTenderMap = new map < string, Tender_information__c > ();
             Set < String > TarDetailSet = new Set < String > ();
+            
             for (NFM501Controller.ListItem LI: getQLMData1.data.list1) {
+                system.debug('LI----'+json.serialize(LI));
                 // 闋呯洰杌㈤�併伄銈汇儍銉�
                 Tender_information__c te1 = new Tender_information__c();
+                //add aws dataid sushanhu 20220223 start
+                if(String.isEmpty(LI.DataId)){
+                    continue;
+                }
+                te1.AWS_Data_Id__c = LI.DataId;
+                //add aws dataid sushanhu 20220223 end
                 if (String.isBlank(LI.projectId)) {
                     iflog501Future.ErrorLog__c += 'Error! [' + LI.projectId + ']NotExist. This information is skipped.\n';
                     continue;
@@ -180,11 +218,19 @@
                 //杞崲琛紙瀹炵幇閫夐」鍒楄〃鐨勪笅鎷夐�夐」锛�
                 te1.BiddingType__c = NFMUtil.getMapValue(transferMap, 'BiddingType__c', LI.biddingType, iflog501Future);
                 te1.InfoQianlimaUrl__c = String.isBlank(LI.infoQianlimaUrl) ? te1.InfoQianlimaUrl__c : LI.infoQianlimaUrl;
+                System.debug('======111111111111========');
                 //鎷兼帴瀛楃涓�
                 if (LI.ZhaoRelationWay != null && LI.ZhaoRelationWay.size() > 0) {
+                    System.debug('======LI.ZhaoRelationWay========'+LI.ZhaoRelationWay);
                     te1.ZhaoRelationWay__c = String.join(LI.ZhaoRelationWay, '锛�');
+                     //add 瀵嗘枃 sushanhu 20220223 start
+                     //System.debug('======LI.ZhaoRelationWayEncrypted========'+LI.ZhaoRelationWayEncrypted);       //zhj 鏂版柟妗堟敼閫� 2022-12-09
+                     //te1.ZhaoRelationWay_Encrypted__c =String.join(LI.ZhaoRelationWayEncrypted,'锛�');             //zhj 鏂版柟妗堟敼閫� 2022-12-09
+                     System.debug('======2222222222222========');
+                     //add 瀵嗘枃 sushanhu 20220223 end
                 }
                 //杞崲琛紙閫夐」鍒楄〃鐨勪笅鎷夐�夐」锛�
+                System.debug('======3333333333333333========');
                 te1.IsElectronic__c = NFMUtil.getMapValue(transferMap, 'IsElectronic__c', LI.isElectronic, iflog501Future);
                 te1.XmNumber__c = String.isBlank(LI.xmNumber) ? te1.XmNumber__c : LI.xmNumber;
                 if ( String.isnotBlank(LI.tenderEndTime) ) {
@@ -216,7 +262,7 @@
                 //杞崲琛紙閫夐」鍒楄〃鐨勪笅鎷夐�夐」锛�
                 //鎺ュ彛浼犳潵鍏朵粬鍏憡
                 if (String.isBlank(te1.Id)) { //鍒ゆ柇鎷涙爣椤圭洰鏄惁瀛樺湪
-                    if ('5'.equals(LI.infoType)) {
+                    if ('5'.equals(LI.infoType) || '2'.equals(LI.infoType)) {  //20220510 lt SWAG-CE6C45
                         //鎷涙姇鏍囬」鐩悕绉�
                         te1.InfoTitle__c = LI.infoTitle == null ? te1.InfoTitle__c : LI.infoTitle;
                         //椤圭洰闃舵
@@ -256,33 +302,38 @@
                     }
                 }
                 // 涓爣鏃堕棿(OpenBidingTime__c)
-                if (String.isNotBlank(LI.openBidingTime) ) {
-                    te1.OpenBidingTime__c = Datetime.valueOf(LI.openBidingTime);
-                    System.debug('OpenBidingTime__c1:' + te1.OpenBidingTime__c);
-                } else if (te1.OpenBidingTime__c == null && '3'.equals(LI.infoType)) {
+                // 2022-05-17 涓爣鏃ラ�昏緫閿欒锛屾帴鍙i噷娌℃湁涓爣鏃ュ瓧娈碉紝浠呬腑鏍囬樁娈垫椂锛岀敤褰撳墠鏃ユ湡濉厖 ssm
+                // if (String.isNotBlank(LI.openBidingTime) ) {
+                //     te1.OpenBidingTime__c = Datetime.valueOf(LI.openBidingTime);
+                //     System.debug('OpenBidingTime__c1:' + te1.OpenBidingTime__c);
+                // } else 
+                if (te1.OpenBidingTime__c == null && '3'.equals(LI.infoType)) {
                     te1.OpenBidingTime__c = Date.today();
                     System.debug('OpenBidingTime__c2:' + te1.OpenBidingTime__c);
                 }
                 // 棰勫憡璁板綍鏃�	鍙栫涓�娆¤幏鍙栧埌棰勫憡鐨勫綋鍓嶆椂闂�
                 // 濡傛灉鏈夊�硷紝涓嶆槸绗竴娆★紝濡傛灉娌″��
-                if ('1'.equals(LI.infoType) && te1.noticeDate__c == null) {
+                if (('1'.equals(LI.infoType)) && te1.noticeDate__c == null) {  //20220510 lt SWAG-CE6C45
                     te1.noticeDate__c = Date.today();
                     System.debug('noticeDate__c:' + te1.noticeDate__c);
                 }
                 System.debug('LI.infoType:' + LI.infoType);
                 System.debug('te1.ResultDate__c:' + te1.ResultDate__c);
                 // 缁撴灉璁板綍鏃�	鍙栫涓�娆¤幏鍙栧埌缁撴灉鐨勫綋鍓嶆椂闂�
-                if ('3'.equals(LI.infoType) && te1.ResultDate__c == null) {
+                if (('3'.equals(LI.infoType)) && te1.ResultDate__c == null) {  //20220510 lt SWAG-CE6C45
                     te1.ResultDate__c = Date.today();
                     System.debug('ResultDate__c:' + te1.ResultDate__c);
                 }
                 // 鍏憡璁板綍鏃�	鍙栫涓�娆¤幏鍙栧埌鍏憡鐨勫綋鍓嶆椂闂�
-                if ('0'.equals(LI.infoType) && te1.publicDate__c == null) {
+                if (('0'.equals(LI.infoType)) && te1.publicDate__c == null) {  //20220510 lt SWAG-CE6C45
                     te1.publicDate__c = Date.today();
                     System.debug('publicDate__c:' + te1.publicDate__c);
                 }
                 if (LI.AgentRelationWay != null && LI.AgentRelationWay.size() > 0) {
                     te1.AgentRelationWay__c = String.join(LI.AgentRelationWay, '锛�');
+                    //add 瀵嗘枃 sushanhu 20220223 start
+                    //te1.AgentRelationWay_Encrypted__c =String.join(LI.AgentRelationWayEncrypted,'锛�');  //zhj 鏂版柟妗堟敼閫� 2022-12-09
+                    //add 瀵嗘枃 sushanhu 20220223 end
                 }
                 // 灏嗘敼闄勪欢瀛樺叆鎷涙姇鏍囬」鐩瓙瀵硅薄涓�
                 if (LI.InfoFile != null && LI.InfoFile.size() > 0) {
@@ -327,6 +378,9 @@
                 }
                 if (LI.AgentRelationName != null && LI.AgentRelationName.size() > 0) {
                     te1.AgentRelationName__c = String.join(LI.AgentRelationName, '锛�');
+                    //add 瀵嗘枃 sushanhu 20220223 start
+                    //te1.AgentRelationName_Encrypted__c =String.join(LI.AgentRelationNameEncrypted,'锛�');      //zhj 鏂版柟妗堟敼閫� 2022-12-09
+                    //add 瀵嗘枃 sushanhu 20220223 end
                 }
                 if (String.isNotBlank(LI.bidingEndTime)) {
                     te1.BidingEndTime__c = Datetime.valueOf(LI.bidingEndTime);
@@ -355,6 +409,9 @@
                 }
                 if (LI.ZhongRelationWay != null && LI.ZhongRelationWay.size() > 0) {
                     te1.ZhongRelationWay__c = String.join(LI.ZhongRelationWay, '锛�');
+                    //add 瀵嗘枃 sushanhu 20220223 start
+                    //te1.ZhongRelationWay_Encrypted__c =String.join(LI.ZhongRelationWayEncrypted,'锛�');        //zhj 鏂版柟妗堟敼閫� 2022-12-09
+                    //add 瀵嗘枃 sushanhu 20220223 end
                 }
                 if (String.isNotBlank(LI.bidingAcquireTime)) {
                     te1.BidingAcquireTime__c = Datetime.valueOf(LI.bidingAcquireTime);
@@ -432,6 +489,9 @@
                             te.ProjectId__c = te1.ProjectId__c;
                             //tempList1.put(te1.InfoId__c, te);
                             //tempList1.add(te);
+                            // 濡傛灉鏇存柊鐨勬暟鎹樁娈典负3.缁撴灉涓旇ˉ鍏呰鏄庝负3-5锛氫腑鏍囬�氱煡锛岃缃渶缁堟爣鐨勭墿涓簍rue
+                            te.Is_Final__c = String.isNotBlank(LI.infoType) && '3'.equals(LI.infoType) && String.isNotBlank(LI.infoTypeSegment) && '11'.equals(LI.infoTypeSegment) ? true : false;
+
                         }
                     }
                 }
@@ -462,10 +522,18 @@
                 }
                 if (LI.ZhaoRelationName != null && LI.ZhaoRelationName.size() > 0) {
                     te1.ZhaoRelationName__c = String.join(LI.ZhaoRelationName, '锛�');
+                    //add 瀵嗘枃 sushanhu 20220223 start
+                    //te1.ZhaoRelationName_Encrypted__c =String.join(LI.ZhaoRelationNameEncrypted,'锛�');        //zhj 鏂版柟妗堟敼閫� 2022-12-09
+                    //add 瀵嗘枃 sushanhu 20220223 end
                 }
                 if (LI.ZhongRelationName != null && LI.ZhongRelationName.size() > 0) {
                     te1.ZhongRelationName__c = String.join(LI.ZhaoRelationName, '锛�');
+                     //add 瀵嗘枃 sushanhu 20220223 start
+                     //te1.ZhongRelationName_Encrypted__c =String.join(LI.ZhongRelationNameEncrypted,'锛�');     //zhj 鏂版柟妗堟敼閫� 2022-12-09
+                     //add 瀵嗘枃 sushanhu 20220223 end
                 }
+                    
+                System.debug('te1-----'+json.serialize(te1));
                 //绮剧悽绉戞妧   zxk   2021-11-11  SWAG-C637NF   start
                 // 濡傛灉绗竴娆¢」鐩樁娈靛氨浼犳潵鍙樻洿鐘舵�佺殑璇濓紝閭d箞灏变笉鐢熸垚鎷涙姇鏍囬」鐩紙鐢变簬鍙樻洿闃舵椤圭洰鍚嶇О浼犳潵涓虹┖锛屼负浜嗕笉璁╅」鐩悕鑷姩璧嬪�间负Id锛�
                 if (String.isNotBlank(te1.InfoType__c) && String.isNotBlank(LI.projectId)) {
@@ -487,27 +555,55 @@
             }
             // System.debug('12345678!!!!!'+updateTenderMap.values());
             //3銆侀�氳繃list鏌ユ嫑鏍囨槑缁嗭紝鍒犻櫎鎵�浠ユ煡鍑虹殑鏄庣粏
-            List < Tender_information_details__c > DetlList = [Select Id FROM Tender_information_details__c
+            // 2022-06-06 涓爣閫氱煡鐨勬爣鐨勭墿涓烘渶缁堟爣鐨勭墿锛屼笉鍐嶄慨鏀癸紝鍏朵粬闃舵鐨勬爣鐨勭墿鍙垹闄�
+            List < Tender_information_details__c > DetlList = [Select Id, Name, Name__c, ProjectId__c, Brand__c, Model__c, Keywords__c, 
+                    NumberUnit__c, TotalPrice__c, Price__c, PriceUnit__c, TotalPriceUnit__c, Is_Final__c  
+                FROM Tender_information_details__c
                 Where ProjectId__c in : TarDetailSet
             ];
-            if (DetlList.size() > 0) {
-                delete DetlList;
-            }
+            // if (DetlList.size() > 0) {
+            //     delete DetlList;
+            // }
+            system.debug('updateTenderMap---'+json.serialize(updateTenderMap));
             if (updateTenderMap.values().size() > 0) {
                 upsert updateTenderMap.values();
             }
             System.debug('123456789123456789:' + updateTenderMap);
             //灏嗘嫑鏍囦俊鎭拰鎷涙爣淇℃伅璇︽儏鍏宠仈璧锋潵锛堥�氳繃ProjectId杩欎竴鍞竴鏍囪瘑锛�
             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
+                il.awsId =TMap.AWS_Data_Id__c;
+                il.sfRecordId=TMap.Id;
+                idList.add(il);
+                // add for pipl  sushanhu 20220310 end
             }
             System.debug('12345678!!!!!' + TenderMap.values());
             List < Tender_information_details__c > TenList = new List < Tender_information_details__c > ();
+            // 鏂扮殑鏍囩殑鐗╁唴瀹逛笉涓虹┖鏃惰繘鍏ヤ互涓嬮�昏緫
             if (tempList1.size() > 0) {
+                // 鍏堝惊鐜幇鏈夋爣鐨勭墿锛屽垽鏂摢浜涘垹闄わ紝鍝簺淇濈暀
+                Map<String, String> undelete_projects = new Map<String, String>();
+                List<Tender_information_details__c> delete_list = new List<Tender_information_details__c>();
+                for (Tender_information_details__c det : DetlList) {
+                    // 鍒ゆ柇鏈�缁堟爣鐨勭墿鏍囪鏄惁涓簍rue鎴栨柊鏍囩殑鐗╅噷涓嶅寘鍚玴roject
+                    if (det.Is_Final__c || !tempList1.containsKey(det.ProjectId__c)) {
+                        undelete_projects.put(det.ProjectId__c, det.ProjectId__c);
+                    } else {
+                        delete_list.add(det);
+                    }
+                }
+                if (delete_list != null && delete_list.size() > 0) {
+                    delete delete_list;
+                }
                 for (String projectId: tempList1.keySet()) {
                     for (Tender_information_details__c vma: tempList1.get(projectId)) {
-                        if (vma != null && TenderMap.containskey(projectId)) {
+                        // 2022-06-06 澧炲姞鍒ゆ柇 projectId涓嶅啀undelete鐨勫垪琛ㄩ噷
+                        if (vma != null && TenderMap.containskey(projectId) && !undelete_projects.containsKey(projectId)) {
                             vma.Tender_information__c = TenderMap.get(projectId).id;
                             TenList.add(vma);
                         }
@@ -529,6 +625,7 @@
                 insert insertbidInfoFileList;
             }
             if (!Manual_execution501future) {
+                //娴嬭瘯 Open the comment by Li Jun 20220404
                 System.enqueueJob(new NFM502Controller(rowData.id));
             }
             // logstr += '\nend';
@@ -537,9 +634,25 @@
             if (System.Test.isRunningTest()) {
                 throw new ControllerUtil.myException('aaa');
             }
+            //纭浜嬪姟 add for pi sushanhu 20220310 start
+            // 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);
+            Integer rowDataStr = Integer.valueOf(rowData.get('NFM501Future_Count__c'));
+            if (rowDataStr == null) {
+                rowDataStr = 0;
+            }
+            System.debug('rowDataStr' + rowDataStr);
+            if (rowDataStr >= batch_retry_max_cnt) {
+            	PIHelper.insertConfirmTrans('NFM501',0,null,txId,1,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());
             // logstr += '\n' + ex.getMessage();

--
Gitblit v1.9.1