//刷新数据：9月重复性检查项目合并
//一批一条数据
global class RepeatProMergeBtach implements Database.Batchable<SObject> , Database.Stateful{
    
    private final List<String> proIdList = null;
    
    global RepeatProMergeBtach(){
    }

    global RepeatProMergeBtach(List<String> str){
        proIdList = str;
    }

    global Database.QueryLocator start(Database.BatchableContext BC){

        String soql = 'Select Id,Name,InfoId__c,Logical_delete__c,ProjectId__c,Retain_Tender__c '
                    + 'From Tender_information__c '
                    + 'Where Retain_Tender__c != null '
                    + 'And RepeatProMergeFLG__c = true ' ;
        if(proIdList <> null){
            soql += 'And Id in:proIdList';
        }
        System.debug('20231008---soql:'+soql);
        return Database.getQueryLocator(soql);
    }

    global void execute(Database.BatchableContext BC, List<Tender_information__c> tenList){
        System.debug('20231008---execute---');
        System.debug('20231008---tenList---'+tenList);
        if(tenList.Size() > 0 ){
            for(Tender_information__c ten : tenList){
                String tenJson = JSON.serialize(ten);
                System.debug('20231008---tenJson:'+tenJson);
                TenderDeleteLwcController.saveData(tenJson);
            }
        }
    }

    global void finish(Database.BatchableContext BC){
        
    }
}