global class ASOTDeleteRealBatch implements Database.Batchable<sObject>,Database.Stateful {
    public String query;
    private BatchIF_Log__c iflog;
    global ASOTDeleteRealBatch() {
        this.query = query;
    }

    global Database.QueryLocator start(Database.BatchableContext bc) {
        system.debug('执行start');
        iflog = new BatchIF_Log__c();
        iflog.Type__c = 'PushNotification';
        iflog.Log__c  = 'CoverageTargetHPBatch start\n';
        iflog.ErrorLog__c = '';
        insert iflog;

        query = 'select id,Renew_Finish_Else__c,Renew_Finish_Correlation_Lightsource__c,Renew_Finish_Rigid_Mirror_3__c,Renew_Finish_Rigid_Mirror_1__c,'
                   +' Finish_Correlation_Lightsource__c,Finish_Rigid_Mirror_2__c,Finish_Rigid_Mirror_1__c '
                   +' from Account_Service_Of_Target__c '
                   +' where (Finish_Asset__c!=0 and Finish_Asset__c!=null) or (Finish_Coverage_Asset__c != 0 and Finish_Coverage_Asset__c!=null)';
        return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext BC, list<Account_Service_Of_Target__c> asotList) {
        List<Account_Service_Of_Target__c> asotL = new  List<Account_Service_Of_Target__c>();
        // 清空客户-目标的实际设备数
        for (Account_Service_Of_Target__c  asot : asotList) {
         asot.Renew_Finish_Else__c = 0;
         asot.Renew_Finish_Correlation_Lightsource__c = 0;
         asot.Renew_Finish_Rigid_Mirror_3__c = 0;
         asot.Renew_Finish_Rigid_Mirror_1__c = 0;
         asot.Finish_Correlation_Lightsource__c = 0;
         asot.Finish_Rigid_Mirror_2__c = 0;
         asot.Finish_Rigid_Mirror_1__c = 0;
         asotL.add(asot);
      }
      update asotL;
    }

    global void finish(Database.BatchableContext BC) {
        iflog.Log__c += '\nASOTDeleteRealBatch end';
        String tmp = iflog.ErrorLog__c;
        if (tmp.length() > 65000) {
            tmp = tmp.substring(0, 65000);
            tmp += ' ...have more lines...';
            iflog.ErrorLog__c = tmp;
        }
        update iflog;
      EquipmentRealCoverageRealBatch batch1 = new EquipmentRealCoverageRealBatch();
      Database.executeBatch(batch1);
      EquipmentRenewMoleculeBatch  batch2 = new EquipmentRenewMoleculeBatch();
      Database.executeBatch(batch2);
    }
}