修复:重置执行周期丢失执行任务 bug
This commit is contained in:
1
pom.xml
1
pom.xml
@@ -18,6 +18,7 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
<finalName>redtimer</finalName>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
@@ -39,7 +39,7 @@ public class TimerTask implements Task {
|
|||||||
@Override
|
@Override
|
||||||
public void setScheduled(Scheduled scheduled) {
|
public void setScheduled(Scheduled scheduled) {
|
||||||
this.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
|
@Override
|
||||||
|
@@ -25,7 +25,7 @@ public class TimerQueue {
|
|||||||
lock.lock();
|
lock.lock();
|
||||||
remove(task.getName());
|
remove(task.getName());
|
||||||
int inx = queue.size();//目标坐标
|
int inx = queue.size();//目标坐标
|
||||||
while (inx > 0 && queue.get(inx).theTime() > task.theTime()) {
|
while (inx > 0 && queue.get(inx - 1).theTime() > task.theTime()) {
|
||||||
inx--;
|
inx--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -66,6 +66,9 @@ public class ScheduledCycle implements Scheduled {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LocalDateTime nextTime() {
|
public LocalDateTime nextTime() {
|
||||||
|
if (theTime.isAfter(LocalDateTime.now())) {
|
||||||
|
return theTime;
|
||||||
|
}
|
||||||
return theTime = theTime.plus(period, unit);
|
return theTime = theTime.plus(period, unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -112,6 +112,9 @@ public class ScheduledExpres implements Scheduled {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public LocalDateTime nextTime() {
|
public LocalDateTime nextTime() {
|
||||||
|
if (theTime.isAfter(LocalDateTime.now())) {
|
||||||
|
return theTime;
|
||||||
|
}
|
||||||
return theTime = carry("m");
|
return theTime = carry("m");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user