所以,我想将触发器特定值传递给作业。似乎值被覆盖并导致最后一个值。
.box-popup {
opacity: 0;
position: absolute;
color: #ccc; /* removed quotes */
z-index: 1; /* try not to use higher z-index values unnecessarily */
top: -72px;
left: 165px;
width: 250px;
height: 200px;
background-color: #ccc; /* removed quotes or use currentColor if the color is same as of color property */
padding: 30px 50px 40px 50px;
border-radius: 3px;
transition: opacity .4s ease-in-out; /* used 'seconds' unit just to make it shorter */
-moz-transition: opacity .4s ease-in-out;
-webkit-transition: opacity .4s ease-in-out;
}
**这就是我将数据发送给工作的地方** jobDetail.getJobDataMap()。put(Constants.TASK_MONTH_YEAR,months [i] +" - " + year);
public void createControlTask(String name, String id, String freq) throws SchedulerException {
JobBuilder jobBuilder;
JobDetail jobDetail;
TriggerBuilder trigBuilder;
Trigger trigger = null;
Set<Trigger> triggerList = new HashSet<Trigger>();
String[] months = null;
String cronFreq;
//Get current year from properties file -- kavitha
String year = props.getProperty("task.year");
log.info("in createSchedulerTask() for : [" + name + "] id [" + id + "] freq [" + freq + "]");
// Consider the control only if the frequency is monthly, quarterly, semi-annually or annually
if ((freq != null) && !(freq.equals(Constants.AS_NEEDED))) {
jobBuilder = JobBuilder.newJob(QuraJob.class);
jobBuilder = jobBuilder.withIdentity(name + "_JOB", Constants.CONTROL_TASK);
jobBuilder = jobBuilder.usingJobData(Constants.NAME, name);
jobBuilder = jobBuilder.usingJobData(Constants.ID, id);
jobBuilder = jobBuilder.usingJobData(Constants.FREQUENCY, freq);
jobDetail = jobBuilder.build();
log.info("Job created -- [" + jobDetail.getKey() + "]");
if(freq.equals(Constants.MONTHLY)){
months = Constants.MONTHLY_PERIOD;
}
if(freq.equals(Constants.QUARTERLY)){
months = Constants.QUARTERLY_PERIOD;
}
if(freq.equals(Constants.ANNUAL)){
months = Constants.ANNUAL_PERIOD;
}
if(freq.equals(Constants.SEMI_ANNUALLY)){
months = Constants.SEMI_ANNUALLY_PERIOD;
}
for(int i = 0; i < months.length; i++){
cronFreq = props.getProperty(Constants.PID_CRON_CONTROLTASK + months[i]);
trigBuilder = TriggerBuilder.newTrigger();
trigBuilder = trigBuilder.withIdentity(name + "_TRIGGER_" + i, Constants.CONTROL_TASK);
trigBuilder = trigBuilder.startNow();
trigBuilder = trigBuilder.withSchedule(CronScheduleBuilder.cronSchedule(cronFreq));
//Add year and month (Eg: "January-2016") as job data
答案 0 :(得分:0)
所以, context.getMergedJobDataMap()帮助了我。
我将触发器特定的jobdata添加如下(假设语句处于循环中):
trigBuilder = trigBuilder.usingJobData(Constants.TASK_MONTH_YEAR, months[i]+"-"+year);
在JOB类中获取数据,如
taskMonthYear = (String)context.getMergedJobDataMap().get(Constants.TASK_MONTH_YEAR);