重置残留的Running状态任务为Pending,确保程序异常关闭后恢复状态
This commit is contained in:
parent
2930ea71da
commit
f9f8b5f9aa
@ -4,7 +4,7 @@
|
||||
|
||||
### [2026/2/3]
|
||||
|
||||
1. [ ] (优化)预计算高亮正确,结果高亮错误,高亮了很多不相干的同名物体
|
||||
1. [x] (优化)预计算高亮正确,结果高亮错误,高亮了很多不相干的同名物体
|
||||
2. [ ] (BUG)预计算一个目标物体,161帧碰撞,机制有问题
|
||||
3. [ ] (BUG)吊装路径,终点前的一段拐弯,通行空间方向不对
|
||||
4. [ ] (BUG)批处理时杀死程序,重新打开有执行中的任务,但删除选中没激活,再运行批处理,收到停止信号结束
|
||||
|
||||
@ -64,6 +64,43 @@ namespace NavisworksTransport.Core
|
||||
{
|
||||
_database = pathPlanningManager?.GetPathDatabase();
|
||||
LogManager.Info("BatchQueueManager已设置PathPlanningManager");
|
||||
|
||||
// 重置残留的Running状态任务(程序异常关闭后重启)
|
||||
_ = ResetStaleRunningItemsAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置残留的Running状态任务为Pending
|
||||
/// 用于程序异常关闭后重启时恢复状态
|
||||
/// </summary>
|
||||
private async Task ResetStaleRunningItemsAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_database == null) return;
|
||||
|
||||
var allItems = await _database.GetBatchQueueItemsAsync(statusFilter: BatchQueueStatus.All, limit: 1000);
|
||||
var staleItems = allItems.Where(item => item.Status == BatchQueueStatus.Running).ToList();
|
||||
|
||||
if (staleItems.Count > 0)
|
||||
{
|
||||
LogManager.Info($"[批处理队列] 发现 {staleItems.Count} 个残留的Running状态任务,重置为Pending");
|
||||
|
||||
foreach (var item in staleItems)
|
||||
{
|
||||
item.Status = BatchQueueStatus.Pending;
|
||||
item.StartTime = null;
|
||||
item.EndTime = null;
|
||||
item.ErrorMessage = null;
|
||||
await _database.UpdateBatchQueueItemAsync(item);
|
||||
LogManager.Info($"[批处理队列] 已重置任务: {item.PathRouteName} (ID: {item.Id})");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.Error($"[批处理队列] 重置残留Running任务失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user