黄千龙
2022-09-21 48714ff500f3321ed71da185fcbc75143120686b
force-app/main/default/classes/InquiryVerifyBatch.cls
@@ -1,9 +1,7 @@
global class InquiryVerifyBatch implements  Database.Batchable<sObject>, Database.Stateful {
global class InquiryVerifyBatch  implements Schedulable,Database.Batchable<SObject>,Database.Stateful {
    public String query;
    public Date start_date;
    public Date end_date;
    global InquiryVerifyBatch() {
        // if(Test.isRunningTest()){
@@ -14,6 +12,7 @@
        
    }
    global InquiryVerifyBatch(Integer year, Integer month) {
        if (year == null) {
            year = 2021;
@@ -22,11 +21,13 @@
            month = 4;
        }
        start_date = Date.newInstance(year, month, 1);
        end_date = start_date.addMonths(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 and CreatedDate < :end_date';
        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) {
        // 获取报价单数据
@@ -48,7 +49,7 @@
                createdDateStr = Date.today();
            }
            // 获取报价产品数据,获取第四分类
             List<QuoteLineItem> qlts = [Select Id,Product2.Category4__c from QuoteLineItem where QuoteId  = :quo.Id limit 200];
             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