配置文件 applicationContext.xml java shedule轮询任务 ActivetimeScheduleQuartz.java package com.cstor.ctape.schedule;import java.sql.Timestamp;import java.util.ArrayList;import java.util.List;import com.cstor.ctape.dao.CtapeUserTapeD
java shedule轮询任务 ActivetimeScheduleQuartz.java
package com.cstor.ctape.schedule;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import com.cstor.ctape.dao.CtapeUserTapeDao;
import com.cstor.ctape.dao.TapeDao;
import com.cstor.ctape.entity.CtapeUserTape;
import com.cstor.ctape.entity.Tape;
public class ActivetimeScheduleQuartz {
private CtapeUserTapeDao ctapeUserTapeDao;
public CtapeUserTapeDao getCtapeUserTapeDao() {
return ctapeUserTapeDao;
}
public void setCtapeUserTapeDao(CtapeUserTapeDao ctapeUserTapeDao) {
this.ctapeUserTapeDao = ctapeUserTapeDao;
}
private TapeDao tapeDao;
public TapeDao getTapeDao() {
return tapeDao;
}
public void setTapeDao(TapeDao tapeDao) {
this.tapeDao = tapeDao;
}
public void activetimeSchedule() {
List
cutlist = new ArrayList
(); cutlist = ctapeUserTapeDao.list(); for (CtapeUserTape ctapeUserTape : cutlist) { long ct = System.currentTimeMillis(); Timestamp endtime = ctapeUserTape.getEnd_time(); long et = endtime.getTime(); long remaintime = et - ct; if (remaintime > 0) { ctapeUserTape.setRemaining_time(remaintime); ctapeUserTapeDao.update(ctapeUserTape); } else { int id = ctapeUserTape.getUser_id(); String physical_tape_id = ctapeUserTape.getPhysical_tape_id(); ctapeUserTapeDao.delete(id, physical_tape_id); } String tapeid = ctapeUserTape.getPhysical_tape_id(); Tape tape = tapeDao.findById(tapeid); if(tape.getWrite_protect_status()!=1){ int id = ctapeUserTape.getUser_id(); ctapeUserTapeDao.delete(id, tapeid); } } } }
quartz所需jar包
