📄 timerjobsub.java
字号:
/*
* Created on 2004-8-6
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package com.gctech.misc.other.time;
import java.sql.Connection;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import com.gctech.misc.CONSTANTS;
import com.gctech.misc.provision.dao.SubrelationDAO;
import com.gctech.misc.sso.handler.SubMessageHandler;
import com.gctech.misc.util.DataBaseUtility;
import com.icss.j2ee.dao.DAOFactory;
/**
* <p>Title:</p>
* <p>Description:</p>
* <p>Copyright: Copyright (c) Gctech 2004-8-6</p>
* <p>Company: 吉芙德资讯有限公司</p>
*
* @version 1.0
* @author liyi
*
*/
/**
* 该例子用于演示如何完成tiemrjob
* 该例子功能是在每天的凌晨一点调用
*/
public class TimerJobSub implements TimerJob {
Calendar nextDate = null;
public TimerJobSub() {
nextDate = Calendar.getInstance();
//nextDate.add(Calendar.DAY_OF_MONTH, 1);
//将设置调用时间是(第二天的)每天凌晨1点
nextDate.add(Calendar.HOUR_OF_DAY, 10);
}
public void execute() {
//nextDate.add(Calendar.DAY_OF_MONTH, 1);
//nextDate.set(Calendar.HOUR_OF_DAY, 1);
nextDate.add(Calendar.HOUR_OF_DAY, 1);
callFunction();
}
public Date getNextExeDate() {
return nextDate.getTime();
}
private void callFunction() {
System.out.println("I am running........");
Connection conn = DataBaseUtility.getConnection();
try {
SubMessageHandler handler = new SubMessageHandler();
DAOFactory factory = new DAOFactory(conn);
SubrelationDAO dao = new SubrelationDAO();
factory.setDAO(dao);
dao.setServiceKey("DZXH");
dao.setStatus(CONSTANTS.START_SERVICE);
List subList = factory.find();
Iterator subIte = subList.iterator();
String feePhon = "";
String desPhon = "";
while (subIte.hasNext()) {
dao = (SubrelationDAO) subIte.next();
if (dao.getFeeterminalType().equals(CONSTANTS.MOBILETYPE_MSISDN))
feePhon = dao.getFeeterminalMsisdn();
else
feePhon = dao.getFeeterminalPseudocode();
if (dao.getDestterminalType().equals(CONSTANTS.MOBILETYPE_MSISDN))
feePhon = dao.getDestterminalMsisdn();
else
feePhon = dao.getDestterminalPseudocode();
handler.handle(dao.getFeeterminalType(), feePhon, dao.getDestterminalType(), desPhon, "");
break;
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String []args){
TimerJobSub sub = new TimerJobSub();
sub.callFunction();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -