From 572b3f4b0248130d692621827ac167e6981bc771 Mon Sep 17 00:00:00 2001
From: 彭锟 <pengkun@prec-tech.com>
Date: 星期一, 28 三月 2022 18:27:00 +0800
Subject: [PATCH] UpdateContractAimAmountHandler,NFM601修改

---
 force-app/main/default/classes/UpdateContractAimAmountHandler.cls |   27 +++++++++++++++++++--------
 force-app/main/default/classes/NFM601Batch.cls                    |   21 ++++++++++++++++-----
 2 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/force-app/main/default/classes/NFM601Batch.cls b/force-app/main/default/classes/NFM601Batch.cls
index e5de4fb..05c17b5 100644
--- a/force-app/main/default/classes/NFM601Batch.cls
+++ b/force-app/main/default/classes/NFM601Batch.cls
@@ -8,8 +8,9 @@
         this.accountIdList = accountIdList;
     }
 
-    global Database.QueryLocator start(Database.BatchableContext bc) {
-        return null;
+    global Database.QueryLocator start(Database.BatchableContext bc) {  
+        return Database.getQueryLocator([select Id,NFM601Tag__c from Account where NFM601Tag__c = true]);
+        //return null;
         // if (accountIdList != null && accountIdList.size() > 0) {
         //     return Database.getQueryLocator([SELECT Id, RecordTypeId, Is_Active_Formula__c,AwaitToSendAWS__c
                     
@@ -41,8 +42,18 @@
 
     }
 
-    global void execute(Database.BatchableContext BC, list < Account > accountList) {
-
+    global void execute(Database.BatchableContext BC , List<Account> accList) {
+        List<String> accIdList = new List<String>();
+        if(accList.size()>0){
+            for(Account temp : accList){
+                accIdList.add(temp.Id);
+            }
+            NFM601Controller.executefuture('', accIdList);
+            for(Account temp : accList){
+                temp.NFM601Tag__c = false;
+            }
+        }
+        update accList;
         // List < String > accIdList = new List < String > ();
         // for (Account account: accountList) {
         //     account.AwaitToSendAWS__c = false;
@@ -66,6 +77,6 @@
     }
 
     global void finish(Database.BatchableContext BC) {
-
+        Id execBTId = Database.executeBatch(new NFM606Batch(), 200);
     }
 }
\ No newline at end of file
diff --git a/force-app/main/default/classes/UpdateContractAimAmountHandler.cls b/force-app/main/default/classes/UpdateContractAimAmountHandler.cls
index bfbcf19..3fbe80a 100644
--- a/force-app/main/default/classes/UpdateContractAimAmountHandler.cls
+++ b/force-app/main/default/classes/UpdateContractAimAmountHandler.cls
@@ -12,11 +12,16 @@
     }
     protected override void beforeUpdate() {
         changeAssume();
+        SetAwaitToSendAWS();//new
+    }
+    //new
+    protected override void beforeInsert() {
+        SetAwaitToSendAWS();//new
     }
 
     protected override void afterInsert() {
         createAgencyTarget();
-        SetAwaitToSendAWS();
+        //SetAwaitToSendAWS();//old
 
     }
 
@@ -25,8 +30,7 @@
         // LHJ KWAG-BQMA89 202006 Start
         updateAgencyAccout();
         // LHJ KWAG-BQMA89 202006 End
-        
-        SetAwaitToSendAWS();
+        //SetAwaitToSendAWS();//old
     }
     
 
@@ -207,7 +211,11 @@
                     if (!NFM601_IdMap.containsKey(acc.Id)) {
                         // 鍒ゆ柇鏄惁鏄帴鍙g敤鎴�
                         if(UserInfo.getUserId().equals(System.Label.interfaceUserID)){
-                            interfaceUserUpsertAccount.add(acc.Id);
+                            //姝ゅ鍋氫慨鏀癸紝NFM624Rest鎺ユ敹鏁版嵁鍚庤Е鍙憈rigger锛宼rigger鍐嶅幓璋冪敤601瀛樺湪bug锛屼慨鏀逛负澧炲姞鏍囪锛屼娇鐢˙atch鍙戦��
+                            //interfaceUserUpsertAccount.add(acc.Id);
+                            //2022-3-28 pk start
+                            acc.NFM601Tag__c = true;
+                            //2022-3-28 pk end
                         } else {
                             queueableAccountIdList.add(acc.Id); 
                         }
@@ -235,7 +243,10 @@
                         ) {
                         if (!NFM601_IdMap.containsKey(acc.Id)) {
                             if(UserInfo.getUserId().equals(System.Label.interfaceUserID)){
-                                interfaceUserUpsertAccount.add(acc.Id);
+                                //interfaceUserUpsertAccount.add(acc.Id);
+                                 //2022-3-28 pk start
+                                acc.NFM601tag__c = true;
+                                 //2022-3-28 pk start
                             } else {
                                 queueableAccountIdList.add(acc.Id);
                             } 
@@ -256,9 +267,9 @@
             if (queueableAccountIdList.size() > 0) {
                 NFM601Controller.callout('', queueableAccountIdList);
             }
-            if (interfaceUserUpsertAccount.size() > 0) {
-                NFM601Controller.executefuture('', interfaceUserUpsertAccount);
-            }
+            // if (interfaceUserUpsertAccount.size() > 0) {
+            //     NFM601Controller.executefuture('', interfaceUserUpsertAccount);
+            // }
         }
 
     }

--
Gitblit v1.9.1