| | |
| | | // 设定发送指定签收单的ID |
| | | public String setId; |
| | | // 设定执行日期 |
| | | public Date setDate; |
| | | // 是否发送指定日期30天之后的签收单 |
| | | public Boolean isAfterDate = false; |
| | | public String setDate; |
| | | public String endDate; |
| | | // 是否发送指定的签收单 |
| | | public Boolean isAppoint = false; |
| | | // 是否发送指定日期的签收单 |
| | | public Boolean isSpecifyDate = false; |
| | | // 设定发送的签收单的IdList |
| | | public List<String> setIdList; |
| | | |
| | | // Default 发送当日符合条件的签收单 |
| | | global NFM116Batch() { |
| | | this.setDate = Date.today(); |
| | | // String yesterday = Date.today().addDays(-1).format().replace('/', '-'); |
| | | // String today = Date.today().format().replace('/', '-'); |
| | | // this.setDate = yesterday + 'T00:00:00.000+0000'; |
| | | // this.endDate = today + 'T00:00:00.000+0000'; |
| | | this.setDate = 'and LastModifiedDate = LAST_N_DAYS:1 and LastModifiedDate != LAST_N_DAYS:0 '; |
| | | } |
| | | // 发送指定日期符合条件的签收单, eg: testDate = Date.newInstance(2022, 05, 02),发送20220501完成签收的签收单 |
| | | global NFM116Batch(Date testDate) { |
| | | this.setDate = testDate; |
| | | isAppoint = true; |
| | | isSpecifyDate = true; |
| | | String yesterday = testDate.addDays(-1).format().replace('/', '-'); |
| | | String pointday = testDate.format().replace('/', '-'); |
| | | this.setDate = yesterday + 'T00:00:00.000+0000'; |
| | | this.endDate = pointday + 'T00:00:00.000+0000'; |
| | | } |
| | | // 发送在指定日期30天之后的所有符合条件的签收单(isAfterDate为true的时候) |
| | | // 发送在指定日期30天之前的所有符合条件的签收单(isAfterDate为true的时候) |
| | | global NFM116Batch(Date testDate, Boolean isAfterDate) { |
| | | this.setDate = testDate; |
| | | this.isAppoint = true; |
| | | this.isAfterDate = isAfterDate; |
| | | if(isAfterDate){ |
| | | isAppoint = true; |
| | | isSpecifyDate = true; |
| | | String beforepointday = testDate.addDays(-30).format().replace('/', '-'); |
| | | String pointday = testDate.format().replace('/', '-'); |
| | | this.setDate = beforepointday + 'T00:00:00.000+0000'; |
| | | this.endDate = pointday + 'T00:00:00.000+0000'; |
| | | } |
| | | } |
| | | // 发送指定Id的签收单 |
| | | global NFM116Batch(String setId) { |
| | |
| | | } |
| | | |
| | | global Database.QueryLocator start(Database.BatchableContext bc) { |
| | | String query = 'select Id from eSignForm__c where (agencyAcceptSAPResult__c != null or HPAcceptSAPResult__c != null) '; |
| | | String query = 'select Id from eSignForm__c where (agencyAcceptSAPResult__c != null or HPAcceptSAPResult__c != null) and SAPReportDate__c != null '; |
| | | if(String.isNotBlank(setId)){ |
| | | query += ' and Id =: setId '; |
| | | } else if (setIdList != null && setIdList.size() > 0) { |
| | | query += ' and Id IN: setIdList '; |
| | | } else if(!isAppoint){ |
| | | query += ' and SAPReportDate__c = ' + setDate.addDays(-1).format().replace('/', '-') ; |
| | | } else if(isAfterDate){ |
| | | query += ' and SAPReportDate__c > ' + setDate.addDays(-30).format().replace('/', '-') ; |
| | | query += setDate; |
| | | } else if(isSpecifyDate){ |
| | | query += ' and LastModifiedDate > ' + setDate; |
| | | query += ' and LastModifiedDate < ' + endDate; |
| | | } |
| | | System.debug('thhquery:' + query); |
| | | return Database.getQueryLocator(query); |