修复:重置执行周期丢失执行任务 bug

This commit is contained in:
lxy 2020-12-07 17:05:10 +08:00
parent f201a8fe64
commit 363cb73ae7
5 changed files with 9 additions and 2 deletions

View File

@ -18,6 +18,7 @@
</dependencies>
<build>
<finalName>redtimer</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>

View File

@ -39,7 +39,7 @@ public class TimerTask implements Task {
@Override
public void setScheduled(Scheduled scheduled) {
this.scheduled = scheduled;
this.theTime = Date.from(scheduled.theTime().atZone(ZoneId.systemDefault()).toInstant()).getTime();
//this.theTime = Date.from(scheduled.theTime().atZone(ZoneId.systemDefault()).toInstant()).getTime();
}
@Override

View File

@ -25,7 +25,7 @@ public class TimerQueue {
lock.lock();
remove(task.getName());
int inx = queue.size();//目标坐标
while (inx > 0 && queue.get(inx).theTime() > task.theTime()) {
while (inx > 0 && queue.get(inx - 1).theTime() > task.theTime()) {
inx--;
}

View File

@ -66,6 +66,9 @@ public class ScheduledCycle implements Scheduled {
@Override
public LocalDateTime nextTime() {
if (theTime.isAfter(LocalDateTime.now())) {
return theTime;
}
return theTime = theTime.plus(period, unit);
}

View File

@ -112,6 +112,9 @@ public class ScheduledExpres implements Scheduled {
*/
@Override
public LocalDateTime nextTime() {
if (theTime.isAfter(LocalDateTime.now())) {
return theTime;
}
return theTime = carry("m");
}