| | |
| | | global class rollupToRepairBatch implements Database.Batchable<sObject>, Database.Stateful { |
| | | |
| | | public String query; |
| | | |
| | | global Integer totalCount = 0; // 总件数 |
| | |
| | | |
| | | |
| | | global Database.QueryLocator start(Database.BatchableContext bc) { |
| | | |
| | | // 20221110 ljh 优化 start |
| | | Date st = Date.today().addMonths(-36); |
| | | Datetime startDatetime = Datetime.newInstance(st.year(), st.month(), st.day(), 8, 0, 0); |
| | | // 20221110 ljh 优化 end |
| | | if (repairId != null && repairId.size() > 0) { |
| | | return Database.getQueryLocator( |
| | | [select Id, |
| | |
| | | from repair__c |
| | | ]); |
| | | } else { |
| | | // 20221110 ljh 优化 start |
| | | // return Database.getQueryLocator( |
| | | // [select Id , |
| | | // if_Rental_Apply__c , |
| | | // Offer_Rental_New__c, |
| | | // Request_approval_day__c, |
| | | // Bollow_Date__c |
| | | // from repair__c |
| | | // where Repair_Completed_Date__c = null Or |
| | | // Repair_Completed_Date__c >= : |
| | | // Date.today().addMonths(-12) |
| | | // ]); |
| | | return Database.getQueryLocator( |
| | | [select Id , |
| | | if_Rental_Apply__c , |
| | |
| | | Request_approval_day__c, |
| | | Bollow_Date__c |
| | | from repair__c |
| | | where Repair_Completed_Date__c = null Or |
| | | Repair_Completed_Date__c >= : |
| | | Date.today().addMonths(-12) |
| | | where Status1__c != '0.取消' |
| | | and Status1__c != '0.删除' |
| | | and Status1__c != '5.完毕' |
| | | and ( |
| | | (Repair_Completed_Date__c = null and CreatedDate > :startDatetime) |
| | | Or Repair_Completed_Date__c >= :Date.today().addMonths(-12) |
| | | ) |
| | | ]); |
| | | // 20221110 ljh 优化 end |
| | | } |
| | | } |
| | | |
| | |
| | | updateRepairMap.remove(newRepair.id); |
| | | } |
| | | } |
| | | |
| | | // 更新发生变化的修理 |
| | | Database.SaveResult[] updateRepairResult = Database.update(updateRepairMap.values(), false); |
| | | for (Database.SaveResult lsrChild : updateRepairResult ) { |