| | |
| | | //用于执行batch同时记录日志信息 |
| | | private BatchIF_Log__c iflog; |
| | | |
| | | Boolean IsNeedExecute = false; // 2021-03-09 mzy WLIG-BYHD79 SFDC环境batch合并调查 是否符合执行条件 |
| | | |
| | | |
| | | global NextMonthVisitBatch() { |
| | |
| | | iflog.ErrorLog__c = ''; |
| | | insert iflog; |
| | | } |
| | | // 2021-03-09 mzy WLIG-BYHD79 SFDC环境batch合并调查 start |
| | | global NextMonthVisitBatch(Boolean NeedExecute) { |
| | | this.IsNeedExecute = NeedExecute; |
| | | iflog = new BatchIF_Log__c(); |
| | | iflog.Type__c = 'PushNotification'; |
| | | iflog.Is_Error__c = 0; |
| | | iflog.Log__c = 'NextMonthVisitBatch start1\n'; |
| | | iflog.ErrorLog__c = ''; |
| | | insert iflog; |
| | | } |
| | | // 2021-03-09 mzy WLIG-BYHD79 SFDC环境batch合并调查 end |
| | | global NextMonthVisitBatch(String oppoId) { |
| | | this.oppoId = oppoId; |
| | | iflog = new BatchIF_Log__c(); |
| | |
| | | |
| | | global Database.QueryLocator start(Database.BatchableContext bc) { |
| | | |
| | | // String query ='select id from Opportunity where IsNextMonthOfVisit__c =true'; |
| | | //String query ='select id from Opportunity where IsNextMonthOfVisit__c =true OR IsThisMonthOfVisit__c = true'; //20201214 zh CHAN-BW35VV |
| | | String query ='select id from Opportunity where (IsNextMonthOfVisit__c =true OR IsThisMonthOfVisit__c = true)'; // 2021-03-10 mzy WLIG-BYHD79 |
| | | String query ='select id from Opportunity where IsNextMonthOfVisit__c =true'; |
| | | |
| | | if (!string.isblank(oppoId)) { |
| | | query += ' and id = :oppoId'; |
| | | query += ' and id = :oppoId '; |
| | | } |
| | | |
| | | if (oppoList != null) { |
| | | query += ' and id in :oppoList '; |
| | | query += ' and id in: oppoList '; |
| | | } |
| | | System.debug('sql语句:'+query); |
| | | |
| | | // 2021-03-09 mzy WLIG-BYHD79 SFDC环境batch合并调查 start |
| | | // 每月最后一天 运行 不满足运行时间,可以使查询到的结果为空 |
| | | //获取这个月的最后一天 |
| | | Date toDate = Date.today(); |
| | | Date days = Date.newInstance(toDate.year(), toDate.month() + 1, 0); |
| | | Integer monDays = days.day(); |
| | | Date dayEnd = Date.newInstance(toDate.year(), toDate.month(), monDays); |
| | | |
| | | if(toDate != dayEnd && IsNeedExecute == true){ |
| | | query = 'Select Id from Opportunity where Name = \'\' AND Name != \'\' '; |
| | | } |
| | | //2021-03-09 mzy WLIG-BYHD79 SFDC环境batch合并调查 end |
| | | |
| | | return Database.getQueryLocator(query); |
| | | } |
| | |
| | | Opportunity oppo = new Opportunity(); |
| | | oppo.Id = o.Id; |
| | | oppo.IsNextMonthOfVisit__c = false; |
| | | oppo.IsThisMonthOfVisit__c = false;//20201214 zh CHAN-BW35VV |
| | | opportunityList.add(oppo); |
| | | } |
| | | if (opportunityList.size() > 0){ |