目录

自定义任务执行条件示例


import java.sql.ResultSet;
import java.util.List;
import com.runqianapp.schedule.TaskThread;
import com.runqianapp.schedule.interfaces.IDBAccess;
import com.runqianapp.schedule.interfaces.ITest;
import com.runqianapp.schedule.utils.ScheduleConfig;

/**
 * 库存量判断
 * @author DYC
 *
 */
public class StockJudgeTest implements ITest {

 /**
  * 查询数据库,如果库存中有某商品库存量低于1000就执行库存短信预警任务
  */
 public boolean canExecute(String params) {
  boolean canExcute = false;
  IDBAccess idba = null;
  List<TaskThread> list=null;
  String sql = "";
  ResultSet rs = null;
  try {
   idba =ScheduleConfig.getInitDBAccess();
   sql = "select name from stock where account<1000";//查询库存小于1000t的产品名称
   rs = idba.executeQuery(sql);
   if(rs.next()){//若查询结果不为空,则需要执行任务,返回true,反之,返回false
    canExcute = true;
   }
  } catch (Exception ex) {
   ex.printStackTrace();
  } finally {
   if (idba != null) {
    idba.close();
   }
  }
  return canExcute;
 }
}