From a081dacbea1e46a9d3f4d77057da7923e9f59d99 Mon Sep 17 00:00:00 2001
From: 彭锟 <pengkun@prec-tech.com>
Date: 星期一, 28 三月 2022 18:27:40 +0800
Subject: [PATCH] Merge branch 'master' of http://47.92.229.245:8089/r/OlyMEBG

---
 force-app/main/default/classes/NFM606Batch.cls |   54 +++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 39 insertions(+), 15 deletions(-)

diff --git a/force-app/main/default/classes/NFM606Batch.cls b/force-app/main/default/classes/NFM606Batch.cls
index a39d198..f022e3d 100644
--- a/force-app/main/default/classes/NFM606Batch.cls
+++ b/force-app/main/default/classes/NFM606Batch.cls
@@ -1,11 +1,19 @@
 global class NFM606Batch implements Database.Batchable < sObject > , Database.AllowsCallouts {
-    public String query;
+    // public String query;
     // public List < String > IdList;
     // public String executeType;
     // public String idStr;
-    // global NFM606Batch() {
 
-    // }
+    // Boolean IsNeedExecute = false; // 2021-03-03  mzy  WLIG-BYHD79  SFDC鐜batch鍚堝苟璋冩煡  鏄惁绗﹀悎鎵ц鏉′欢
+
+    // public SubAuthorizedBatch(Boolean NeedExecute) {
+	//     this.IsNeedExecute = NeedExecute;
+	// }
+
+    public ID recordTypeId;
+    global NFM606Batch() {
+        ID recordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByName().get('绀惧唴鍛樺伐').getRecordTypeId();
+    }
     // global NFM606Batch(String executeType) {
     //     this.executeType = executeType;
     // }
@@ -26,9 +34,11 @@
         //     ]);
         // } else if ('Contact'.equals(executeType)) {
         //     // 鑱旂郴浜烘帴鍙�
-        //     return Database.getQueryLocator([
-        //         select Id, Isactive__c from Contact where Isactive__c = '鏈夋晥' AND RecordTypeId != '01210000000QtkyAAC' AND MobilePhone != ''
-        //     ]);
+        
+        return Database.getQueryLocator([
+            select Id, trigger606Flag__c from Contact where Isactive__c = '鏈夋晥' AND RecordTypeId != :recordTypeId 
+                AND MobilePhone != '' AND trigger606Flag__c = true
+        ]);
         // } else if ('Inspection_Report'.equals(executeType)) {
         //     // 鐐规鎶ュ憡鎺ュ彛
         //     return Database.getQueryLocator([
@@ -60,11 +70,32 @@
         //     ]);
         // }
         // // NewMaintenanceReport_Task__c
-        return Database.getQueryLocator(query);
+        // return Database.getQueryLocator(query);
 
     }
 
-    global void execute(Database.BatchableContext BC, list < Sobject > scope) {
+    global void execute(Database.BatchableContext BC, List<Contact> contactList) {
+        List<String> IdList = new List<String>();
+        List<Contact> trigger606List = new List<Contact>();
+        List<Contact> updateContactList = new List<Contact>();
+        if (contactList != null && contactList.size() > 0) {
+			for (Contact con : contactList) {
+				if(con.trigger606Flag__c){
+                    IdList.add(con.Id);
+                    trigger606List.add(con);
+                }
+			}
+		}
+        if(IdList.size() > 0){
+            NFM606Controller.executeNotFuture(null, IdList);
+            for(Contact con : trigger606List){
+                con.trigger606Flag__c = false;
+                updateContactList.add(con);
+            }
+        }
+        if(updateContactList.size() > 0){
+            update updateContactList;
+        }
         // List < String > sobjectList = new List < String > ();
         // for (Sobject sobj: scope) {
         //     sobjectList.add(sobj.Id);
@@ -81,11 +112,8 @@
         //         //     NFM621Controller.executefuture('', employeeNoList);
         //         // }
         //         NFM621Controller.executefuture('', sobjectList);
-
         //     } else if ('Contact'.equals(executeType)) {
-
         //         NFM606Controller.executeNotFuture(null, sobjectList);
-
         //     } else if ('Inspection_Report'.equals(executeType)) {
         //         NFM602Controller.executeNotFuture(null, sobjectList);
         //     } else if ('NewMaintenanceReport_Task'.equals(executeType)) {
@@ -93,11 +121,7 @@
         //     } else if ('Repair'.equals(executeType)) {
         //         NFM603Controller.executefuture(null, sobjectList);
         //     }
-
-
-
         // }
-
     }
 
     global void finish(Database.BatchableContext BC) {

--
Gitblit v1.9.1