性能测试接口删除时移除定时任务
This commit is contained in:
@@ -212,11 +212,12 @@ public class PerformanceTestController extends BaseController {
|
|||||||
@Log(title = "性能测试", businessType = BusinessType.UPDATE)
|
@Log(title = "性能测试", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/{ids}")
|
@PutMapping("/{ids}")
|
||||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||||
|
dynamicTaskManager.removeTasks(ids);
|
||||||
return toAjax(performanceTestService.deletePerformanceTestByIds(ids));
|
return toAjax(performanceTestService.deletePerformanceTestByIds(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除性能测试
|
* 立即执行性能测试
|
||||||
*/
|
*/
|
||||||
// @PreAuthorize("@ss.hasPermi('system:test:remove')")
|
// @PreAuthorize("@ss.hasPermi('system:test:remove')")
|
||||||
@GetMapping("/executeNow")
|
@GetMapping("/executeNow")
|
||||||
|
|||||||
@@ -75,6 +75,28 @@ public class DynamicTaskManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除定时任务
|
||||||
|
* @param taskId 任务ID
|
||||||
|
*/
|
||||||
|
public void removeTask(Long taskId) {
|
||||||
|
if (scheduledTasks.containsKey(taskId)) {
|
||||||
|
scheduledTasks.get(taskId).cancel(true);
|
||||||
|
scheduledTasks.remove(taskId);
|
||||||
|
taskCache.remove(taskId);
|
||||||
|
log.info("已移除定时任务: {}", taskId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 批量移除定时任务
|
||||||
|
* @param taskIds 任务ID数组
|
||||||
|
*/
|
||||||
|
public void removeTasks(Long[] taskIds) {
|
||||||
|
for (Long taskId : taskIds) {
|
||||||
|
removeTask(taskId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void loadTasks() {
|
private void loadTasks() {
|
||||||
PerformanceTest performanceTest =new PerformanceTest();
|
PerformanceTest performanceTest =new PerformanceTest();
|
||||||
performanceTest.setCrontabStatus(1);
|
performanceTest.setCrontabStatus(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user