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/Sfdc2SapDealersContractBatch.cls |  172 ++++++++++++++++++++++++--------------------------------
 1 files changed, 74 insertions(+), 98 deletions(-)

diff --git a/force-app/main/default/classes/Sfdc2SapDealersContractBatch.cls b/force-app/main/default/classes/Sfdc2SapDealersContractBatch.cls
index 90352c6..7827d42 100644
--- a/force-app/main/default/classes/Sfdc2SapDealersContractBatch.cls
+++ b/force-app/main/default/classes/Sfdc2SapDealersContractBatch.cls
@@ -1,104 +1,80 @@
 global class Sfdc2SapDealersContractBatch implements Database.Batchable<sObject>, Database.AllowsCallouts {
+  //xinhonglu
+  global Sfdc2SapDealersContractBatch() {
+    
+  }
+  
+  global Database.QueryLocator start(Database.BatchableContext BC) {
+    
+    return Database.getQueryLocator(
+      [SELECT Id,RecordType_DeveloperName__c , RecordTypeId , 
+          Sap2sfdcDealers_ModifycationLogo__c, Is_Active_Formula__c,
+          ContractSfdc2SapLog__c  
+        FROM Account 
+        where Is_Active_Formula__c = '鏈夋晥' 
+        and ((Parent.Sap2sfdcDealers_ModifycationLogo__c = '1' and Parent.RecordType_DeveloperName__c = 'Agency') 
+          or Sap2sfdcDealers_ModifycationLogo__c = '1' )]);
+      //[SELECT Id,RecordType_DeveloperName__c , RecordTypeId , Sap2sfdcDealers_ModifycationLogo__c, Is_Active_Formula__c,ContractSfdc2SapLog__c  FROM Account where Is_Active_Formula__c = '鏈夋晥' and ((Parent.Sap2sfdcDealers_ModifycationLogo__c = '1' and Parent.RecordType_DeveloperName__c = 'Agency') or (Sap2sfdcDealers_ModifycationLogo__c = '1' and RecordType_DeveloperName__c = 'Agency'))]
+      //);
+  }
 
-    Boolean IsNeedExecute = false; // 2021-03-10  mzy  WLIG-BYHD79  SFDC鐜batch鍚堝苟璋冩煡  鏄惁绗﹀悎鎵ц鏉′欢
-
-    //xinhonglu
-    global Sfdc2SapDealersContractBatch() {
-
+  global void execute(Database.BatchableContext BC, List<Account> accList) {
+    String[] needSendTypes = new String[] {'濂戠磩', '璨╁2搴�'};
+    List<Account> updateAccountList = new List<Account>();
+    Map<String, String> purposeOfAdviceMap = new Map<String, String>();
+    List<RecordType> rects = [select Id, Name 
+                                from RecordType 
+                                where IsActive = true 
+                                and SobjectType = 'Account' 
+                                and Name IN :needSendTypes];
+    Map<String, String> needSendRectMap = new Map<String, String>();
+    for (RecordType rect : rects) {
+        needSendRectMap.put(rect.Id, rect.Name);
     }
+    BatchIF_Log__c iflog = new BatchIF_Log__c();
+    //iflog.Type__c = 'NFM001';
+    //iflog.ErrorLog__c = '';
+    //iflog.Log__c  = 'callout start\n';
+    //iflog.Id = '20181211';
+    //insert iflog;
 
-    // 2021-03-10  mzy  WLIG-BYHD79  SFDC鐜batch鍚堝苟璋冩煡  start
-    global Sfdc2SapDealersContractBatch(Boolean NeedExecute) {
-        this.IsNeedExecute = NeedExecute;
-    }
-    // 2021-03-10  mzy  WLIG-BYHD79  SFDC鐜batch鍚堝苟璋冩煡  end
-
-
-    global Database.QueryLocator start(Database.BatchableContext BC) {
-        System.debug('================================杩涘叆batch');
-        return Database.getQueryLocator(
-                   [SELECT Id, RecordType_DeveloperName__c , RecordTypeId ,
-                    Sap2sfdcDealers_ModifycationLogo__c, Is_Active_Formula__c,
-                    ContractSfdc2SapLog__c
-                    FROM Account
-                    where Is_Active_Formula__c = '鏈夋晥'
-                            and ((Parent.Sap2sfdcDealers_ModifycationLogo__c = '1' and Parent.RecordType_DeveloperName__c = 'Agency')
-                                 or Sap2sfdcDealers_ModifycationLogo__c = '1' )]);
-        //[SELECT Id,RecordType_DeveloperName__c , RecordTypeId , Sap2sfdcDealers_ModifycationLogo__c, Is_Active_Formula__c,ContractSfdc2SapLog__c  FROM Account where Is_Active_Formula__c = '鏈夋晥' and ((Parent.Sap2sfdcDealers_ModifycationLogo__c = '1' and Parent.RecordType_DeveloperName__c = 'Agency') or (Sap2sfdcDealers_ModifycationLogo__c = '1' and RecordType_DeveloperName__c = 'Agency'))]
-        //);
-    }
-
-    global void execute(Database.BatchableContext BC, List<Account> accList) {
-        
-        String[] needSendTypes = new String[] {'濂戠磩', '璨╁2搴�'};
-        List<Account> updateAccountList = new List<Account>();
-        Map<String, String> purposeOfAdviceMap = new Map<String, String>();
-        List<RecordType> rects = [select Id, Name
-                                  from RecordType
-                                  where IsActive = true
-                                          and SobjectType = 'Account'
-                                                  and Name IN :needSendTypes];
-        Map<String, String> needSendRectMap = new Map<String, String>();
-        for (RecordType rect : rects) {
-            needSendRectMap.put(rect.Id, rect.Name);
+    //iflog = [Select Id, Name from BatchIF_Log__c where Id = :iflog.Id];
+    System.debug(Logginglevel.DEBUG, 'NFM001_' + iflog.Name + ' start');  
+    
+    //Savepoint sp = Database.setSavepoint();
+    try{
+      List<String> accIds = new List<String>();       
+      for(Account acc:accList){
+        acc.Sap2sfdcDealers_ModifycationLogo__c = '0';
+        if (needSendRectMap.get(acc.RecordTypeId) == '濂戠磩'){
+          accIds.add(acc.Id);
+          
         }
-        BatchIF_Log__c iflog = new BatchIF_Log__c();
-        //iflog.Type__c = 'NFM001';
-        //iflog.ErrorLog__c = '';
-        //iflog.Log__c  = 'callout start\n';
-        //iflog.Id = '20181211';
-        //insert iflog;
-
-        //iflog = [Select Id, Name from BatchIF_Log__c where Id = :iflog.Id];
-        System.debug(Logginglevel.DEBUG, 'NFM001_' + iflog.Name + ' start');
-
-        //Savepoint sp = Database.setSavepoint();
-        try {
-            List<String> accIds = new List<String>();
-            List<String> accIdList2Applet = new List<String>(); 
-            for (Account acc : accList) {
-                acc.Sap2sfdcDealers_ModifycationLogo__c = '0';
-                if (needSendRectMap.get(acc.RecordTypeId) == '濂戠磩') {
-                    accIds.add(acc.Id);
-
-                }
-                purposeOfAdviceMap.put(acc.Id, acc.ContractSfdc2SapLog__c);
-                if (needSendRectMap.get(acc.RecordTypeId) == '璨╁2搴�'){
-                    accIdList2Applet.add(acc.Id);
-                }
-                //if (needSendRectMap.get(acc.RecordTypeId) == '璨╁2搴�'){
-                //  //acc.Sap2sfdcDealers_ModifycationLogo__c = '0';
-                //  updateAccountList.add(acc);
-                //}
-                updateAccountList.add(acc);
-            }
-            //if(updateAccountList.size()>0){
-            //  upsert updateAccountList;
-            //}
-            NFM001Controller.calloutNotFuture(null, accIds, purposeOfAdviceMap, needSendRectMap);
-            system.debug('accIdList2Applet--->'+accIdList2Applet);
-            if (accIdList2Applet.size() > 0) {
-                NFM601Controller.executefuture(null, accIdList2Applet);
-            }
-            if (updateAccountList.size() > 0) {
-                upsert updateAccountList;
-            }
-            // system.debug('accIdList2Applet--->'+accIdList2Applet);
-            // if (accIdList2Applet.size() > 0) {
-            //     NFM601Controller.executefuture(null, accIdList2Applet);
-            // }
-
-            iflog.Log__c  = 'end\n';
-        } catch (Exception ex) {
-            // 銈ㄣ儵銉笺亴鐧虹敓銇椼仧鍫村悎
-            //Database.rollback(sp);
-            iflog.ErrorLog__c = ex.getMessage() + '\n' + ex.getStackTraceString() + '\n' + iflog.ErrorLog__c;
-            iflog.Log__c  = 'end\n';
-        }
-    }
-
-    global void finish(Database.BatchableContext BC) {
-
-    }
-
+        purposeOfAdviceMap.put(acc.Id, acc.ContractSfdc2SapLog__c);
+        //if (needSendRectMap.get(acc.RecordTypeId) == '璨╁2搴�'){
+        //  //acc.Sap2sfdcDealers_ModifycationLogo__c = '0';
+        //  updateAccountList.add(acc);
+        //}
+        updateAccountList.add(acc);
+      }
+      //if(updateAccountList.size()>0){
+      //  upsert updateAccountList;
+      //}
+      NFM001Controller.calloutNotFuture(null, accIds, purposeOfAdviceMap, needSendRectMap);
+      if(updateAccountList.size()>0){
+        upsert updateAccountList;
+      }
+      iflog.Log__c  = 'end\n';
+    }catch (Exception ex) {
+        // 銈ㄣ儵銉笺亴鐧虹敓銇椼仧鍫村悎
+        //Database.rollback(sp);
+        iflog.ErrorLog__c = ex.getMessage() + '\n' + ex.getStackTraceString() + '\n' + iflog.ErrorLog__c;
+        iflog.Log__c  = 'end\n';
+    }         
+}
+  
+  global void finish(Database.BatchableContext BC) {
+    
+  }
+  
 }
\ No newline at end of file

--
Gitblit v1.9.1