global class OPDPlanMarkBatchSchedule implements Schedulable { //SWAG-BA65JL 2019/03/22 XHL AddStart global void execute(SchedulableContext sc) { Date toDate = Date.today(); Date yesterDate = toDate.addDays(-1); Date mon1stDate = Date.newInstance(toDate.year(), toDate.month(), 1); //每月到今天的工作日 Integer workdays = UpdateUserTextColBatch.getOlympusWorkDayCount(mon1stDate, toDate); //每月到昨天的工作日 Integer workdays1 = UpdateUserTextColBatch.getOlympusWorkDayCount(mon1stDate, yesterDate); Integer OSFBacth_Execute_Day = Integer.valueOf(System.Label.OSFBacth_Execute_Day); //以下为每个季度的第一个工作日执行,分别为4月、7月、10月、1月的第一个工作日执行, //OPD计划的特别执行,季度计划不参与执行,若需要执行,请调OPDQuarterPlanPhotographBatch里面的方法去执行,特此说明 //获取这个月的月份 Integer executeMonth = toDate.month(); if (workdays1 != OSFBacth_Execute_Day && workdays == OSFBacth_Execute_Day) { if ( executeMonth == 1 || executeMonth == 4 || executeMonth == 7 || executeMonth == 10) { Database.executebatch(new OPDQuarterPlanPhotographBatch(), 100); } } // 2020-11-6 mzy update //if (workdays1 != OSFBacth_Execute_Day && workdays == OSFBacth_Execute_Day) { // Id execBTId = database.executebatch(new OPDPlanMarkBatch(),100); //} 2020-11-6 mzy update // 2020-11-6 mzy SWAG-BSC5WP add start //每个月的倒数第二个工作日需要进行执行 //获取这个月的最后一天 Date days = Date.newInstance(toDate.year(), toDate.month() + 1, 0); Integer monDays = days.day(); Date dayEnd = Date.newInstance(toDate.year(), toDate.month(), monDays); //获取这个月有多少个工作日 Integer monWorkDays = UpdateUserTextColBatch.getOlympusWorkDayCount(mon1stDate, dayEnd); //获取判断今天是否是工作日 List ssDay = [Select IsWorkDay__c From OlympusCalendar__c Where Date__c = :toDate]; //如果 这个月的工作日天数 - 每个月开始到今天的工作日天数 = 1 并且 今天是工作日 , 则说明今天是倒数第二个工作日 if (monWorkDays - workdays == 1 && ssDay != null && ssDay.size() > 0 && ssDay.get(0).IsWorkDay__c == 1 ) { // 将此执行语句转移至OPDPlanSystemDelayBatch finish内 SWAG-BXW4AH 【委托】 OPD计划再申请逻辑设置 // Id execBTId = Database.executebatch(new OPDPlanMarkBatch(), 100); Id execBTId = Database.executebatch(new OPDPlanSystemDelayBatch(), 100); } // 2020-11-6 mzy SWAG-BSC5WP add end // ========================================================================================== // 2021-02-19 XHL SWAG-BYD6DD Start // 这个月的工作日天数 - 每个月开始到今天的工作日天数 = 3 并且 今天是工作日 , 则说明今天是倒数第4个工作日 if (monWorkDays - workdays == 3 && ssDay != null && ssDay.size() > 0 && ssDay.get(0).IsWorkDay__c == 1) { Id execBTId = Database.executebatch(new OPDLendSortCopyToSortBeforeBatch(), 100); } // 2021-02-19 XHL SWAG-BYD6DD End // ========================================================================================== Id execBTId5 = Database.executebatch(new AssetWhereabouts(),20); Id execBTId1 = Database.executebatch(new EquipmentRepairBatch(),20); } }