From 1312ba82d4c880bdb5357d28e0d4af5b285f610f Mon Sep 17 00:00:00 2001
From: 高章伟 <gaozhangwei@prec-tech.com>
Date: 星期四, 10 三月 2022 15:54:39 +0800
Subject: [PATCH] 最近一月修改内容

---
 force-app/main/default/classes/InquiryVerifyBatch.cls |   42 +++++++++++++++++++++++++++++++++---------
 1 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/force-app/main/default/classes/InquiryVerifyBatch.cls b/force-app/main/default/classes/InquiryVerifyBatch.cls
index 8bda608..335c567 100644
--- a/force-app/main/default/classes/InquiryVerifyBatch.cls
+++ b/force-app/main/default/classes/InquiryVerifyBatch.cls
@@ -1,13 +1,35 @@
-global class InquiryVerifyBatch implements Schedulable, Database.Batchable<sObject>, Database.Stateful {
+global class InquiryVerifyBatch  implements Schedulable,Database.Batchable<SObject>,Database.Stateful {
     public String query;
-    global InquiryVerifyBatch() {
 
+    public Date start_date;
+
+    global InquiryVerifyBatch() {
+        // if(Test.isRunningTest()){
+            this.query = 'select id,quoteSavedDate__c,Opportunity.Id,Opportunity.Department_Class__c from quote where Quote_No_last2__c = \'01\' and CreatedDate = today';
+        // }else{
+            // this.query = 'select id,quoteSavedDate__c,Opportunity.Id,Opportunity.Department_Class__c from quote where Quote_No__c like \'%01\' and CreatedDate = today';
+        // }
+        
     }
-    global void execute(SchedulableContext sc){Database.executebatch(this);}
+
+    global InquiryVerifyBatch(Integer year, Integer month) {
+        if (year == null) {
+            year = 2021;
+        }
+        if (month == null) {
+            month = 4;
+        }
+        start_date = Date.newInstance(year, month, 1);
+
+        this.query = 'select id,quoteSavedDate__c,Opportunity.Id,Opportunity.Department_Class__c from quote where Quote_No_last2__c = \'01\' and CreatedDate >= :start_date';
+    }
+
+    public void execute(SchedulableContext sc) {
+        Database.executeBatch(this);
+    }
+    // global void execute(SchedulableContext sc){Database.executebatch(this);}
     global Database.QueryLocator start(Database.BatchableContext bc) {
-       String quoteLN = '%01';
         // 鑾峰彇鎶ヤ环鍗曟暟鎹�
-         query = 'select id,quoteSavedDate__c,Opportunity.Id,Opportunity.Department_Class__c from quote where Quote_No__c like :quoteLN and CreatedDate = today';
         return Database.getQueryLocator(query);
     }
  
@@ -26,7 +48,7 @@
                 createdDateStr = Date.today();
             }
             // 鑾峰彇鎶ヤ环浜у搧鏁版嵁锛岃幏鍙栫鍥涘垎绫�
-             List<QuoteLineItem> qlts = [Select Id,Product2.Category4__c from QuoteLineItem where QuoteId  = :quo.Id];
+             List<QuoteLineItem> qlts = [Select Id,Product2.Category4__c from QuoteLineItem where QuoteId  = :quo.Id and Product2.Important_product__c = true];
              List<String> c4  = new List<String>();
              List<String> qdept  = new List<String>();
              // 绗洓鍒嗙被鏀惧叆list
@@ -36,13 +58,15 @@
             
               // 涓�骞村墠鐨勬棩鏈�
             Date createdDateYear = createdDateStr.addYears(-1);
+
             // 鑾峰彇澶囧搧閰嶅涓�瑙堟槑缁�
             List<Rental_Apply_Equipment_Set_Detail__c> raesdList = [select id, product__c, Bollow_Date__c,Category4__c, Rental_Apply__r.Hospital__c 
                                                                 from Rental_Apply_Equipment_Set_Detail__c 
                                                                 where Rental_Apply__r.Strategic_dept__c = : quo.Opportunity.Department_Class__c 
-                                                                and Category4__c IN :c4 and Key_product__c != null 
+                                                                and Category4__c IN :c4 
                                                                 and Rental_Apply__r.Demo_purpose2__c = '璇曠敤锛堟棤璇环锛�'
-                                                                and Bollow_Date__c >= :createdDateYear order by Bollow_Date__c ];
+                                                                and Bollow_Date__c >= :createdDateYear order by Bollow_Date__c limit 200 ];
+
 
               for (Rental_Apply_Equipment_Set_Detail__c raesd : raesdList) {
                 o.WhetherTrySpareParts_3m__c = false;
@@ -70,6 +94,6 @@
     }
 
     global void finish(Database.BatchableContext BC) {
-
+        
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1