新增车辆表及OTA权限与逻辑优化
新增车辆任务与报警表,完善实体与DbContext配置。细化OTA权限校验,增强回传会话IP安全。优化OTA上传与设置面板,调度器支持重启恢复。报警采集逻辑支持历史分段。
This commit is contained in:
@@ -16,6 +16,35 @@ public sealed class OtaJobRunner
|
||||
_wd = wd;
|
||||
_vehicles = vehicles;
|
||||
_log = log;
|
||||
RecoverInterruptedJobs();
|
||||
}
|
||||
|
||||
/// <summary>进程重启后把落盘中非终态 job 标为 failed,避免 UI 永久显示 running。</summary>
|
||||
private void RecoverInterruptedJobs()
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var job in _store.ListJobs(500))
|
||||
{
|
||||
if (job.Status is not ("running" or "pending")) continue;
|
||||
job.Status = "failed";
|
||||
job.Message = string.IsNullOrWhiteSpace(job.Message)
|
||||
? "进程重启,任务中断"
|
||||
: job.Message;
|
||||
job.FinishedAt = DateTimeOffset.UtcNow;
|
||||
foreach (var step in job.Steps.Where(s => s.Status is "pending" or "running"))
|
||||
{
|
||||
step.Status = "failed";
|
||||
step.Error ??= "进程重启,任务中断";
|
||||
}
|
||||
_store.SaveJob(job);
|
||||
_log.LogWarning("OTA job {Id} marked failed after process restart", job.Id);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.LogWarning(ex, "OTA interrupted job recovery failed");
|
||||
}
|
||||
}
|
||||
|
||||
public OtaJob EnqueueSync(CreateSyncJobRequest req, string? user)
|
||||
|
||||
Reference in New Issue
Block a user