Commit 9612ac66 authored by zhh's avatar zhh

定时任务

parent c603860e
......@@ -75,18 +75,29 @@ public class MboDataHander {
System.out.println("设置日期3333---"+calendar.getTime());
CRONMANAGEMbo.setValue("NEXTDATE", calendar.getTime()); //将修改后的日期设置为下一个到期日
}
}else if (unit.equalsIgnoreCase("WEEK")) {//周 每周多次
}else if (unit.equalsIgnoreCase("WEEK")) {//周 每周多次 不同天数
boolean flag=false;
calendar = Calendar.getInstance();
calendar1 = Calendar.getInstance();
calendar1 = Calendar.getInstance(); //当前时间
int weekNowNum=calendar1.get(Calendar.DAY_OF_WEEK);//获取当前星期
for (int i = 0; i < PERIODDATEMboSet.count(); i++) { //每天几次 获取时间
MboRemote PERIODDATEMbo = PERIODDATEMboSet.getMbo(i);
Calendar calendar2 = Calendar.getInstance();
Date runtime=PERIODDATEMbo.getDate("RUNTIME");
Date runtime=PERIODDATEMbo.getDate("RUNTIME");
int WEEKVALUE=PERIODDATEMbo.getInt("WEEKVALUE"); //获取配置的星期
//如果当前日期小于接下来的日期
int day=0;
if (weekNowNum < WEEKVALUE) {
day=WEEKVALUE-weekNowNum;//得出差的天数
}else{
day=weekNowNum+(7-weekNowNum)+WEEKVALUE; //下星期的天数
}
calendar2.add(Calendar.DAY_OF_MONTH, day); //几天后的日期
calendar2.set(Calendar.HOUR_OF_DAY, runtime.getHours());
calendar2.set(Calendar.MINUTE, runtime.getMinutes());
calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
calendar.get(Calendar.DATE), calendar2.get(Calendar.HOUR_OF_DAY), calendar2.get(Calendar.MINUTE));//将获取的小时放入到对象内 一周后的时间
calendar2.get(Calendar.DATE), calendar2.get(Calendar.HOUR_OF_DAY), calendar2.get(Calendar.MINUTE));//将获取的小时放入到对象内
System.out.println("下一个到期日为===="+calendar.getTime());
if (calendar.after(calendar1)) {//如果生成日期在当前日期之后 ,为下一个到期日
flag=true;//标记是否有大于当前时间的计划
......@@ -95,14 +106,14 @@ public class MboDataHander {
}
if (flag) {
CRONMANAGEMbo.setValue("NEXTDATE", calendar.getTime()); //将修改后的日期设置为下一个到期日
}else{
MboRemote PERIODDATEMbo = PERIODDATEMboSet.getMbo(0); //获取第二天初始时间
Date runtime=PERIODDATEMbo.getDate("RUNTIME");
calendar.set(calendar.get(calendar.YEAR), calendar.get(calendar.MONTH), calendar.get(calendar.DAY_OF_MONTH)+7,runtime.getHours(),runtime.getMinutes()); //天数加1
CRONMANAGEMbo.setValue("NEXTDATE", calendar.getTime()); //将修改后的日期设置为下一个到期日
}
// else{
// MboRemote PERIODDATEMbo = PERIODDATEMboSet.getMbo(0); //获取第二天初始时间
// Date runtime=PERIODDATEMbo.getDate("RUNTIME");
// calendar.set(calendar.get(calendar.YEAR), calendar.get(calendar.MONTH), calendar.get(calendar.DAY_OF_MONTH)+7,runtime.getHours(),runtime.getMinutes()); //天数加1
// CRONMANAGEMbo.setValue("NEXTDATE", calendar.getTime()); //将修改后的日期设置为下一个到期日
// }
}else if (unit.equalsIgnoreCase("MONTH")) {//月
boolean flag=false;
calendar = Calendar.getInstance();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment