feat(task-interrupt): 任务「中断+继续」——在跑可停、部分表可下载、已中断可续跑
用户口径(2026-11-03,33179 卡 80%「正在提交检测」的救援出口):任务卡片加
「中断/继续」;中断后已完成检测的数据生成结果文件供下载,未完成行不再检测;
继续在原任务上续跑剩余行(断点续传,已检测行不重检)。
中断(POST /api/tasks/{taskId}/interrupt,鉴权镜像 retry:resolveOwnershipUserId
+归属校验,普通账号只能中断自己名下的任务;终态重按幂等 no-op):
- TaskHeartbeatService.markCancelledByUser:ACTIVE→CANCELLED 条件更新(词表走
TaskStatuses.FileTask 常量),写「用户中断任务,已完成部分可下载」+finished_at,
syncTerminalState 同步模块缓存与进度快照;客户端心跳拿到 notAlive 即协作停止
(app_client/maixiang 零改动,≤60s 自停)。
- LLM 批循环批间查终态即停:当前批跑完不再发新批(isOwningTaskTerminal)。
- 中断任务的组装跳过候选申领/LLM/补检,直接按已有行账出部分表(allowPartial),
状态保持 CANCELLED 不改写,只补行账缺口文案;cleanupResultFileJob 对 CANCELLED
任务保留分片/范围态/瞬态载荷(这就是「继续」的续跑点),常规交付照旧清理。
继续(retry 链路放宽 CANCELLED,全部在原任务上):
- retryInPlace 条件更新放宽 FAILED/CANCELLED;CAS 前经 ResultFileJobHandler
新钩子 onTaskResumed 清模块补检预算(AP:删 __recheck__ 哨兵键;不清则继续后
第一轮就被「预算耗尽」直接按部分表收尾,钩子抛错即中止不留半态)。
- 中断已交付过的:清 result.result_file_url/size(让位给新表)+把 SUCCESS 的
ASSEMBLE_RESULT 作业复位 PENDING(retry/stuck 计数清零、清错误与 finished_at);
FAILED 仍走既有 resetTerminalFailedForRecovery。
- 校验文案「只有失败或已中断的任务可以继续」;成功任务不可继续。
前端(用户端外观专利 Tab 先行,后端端点本身通用):中断按钮进当前/历史两个
动作槽(确认框说明「未完成行不再检测、已完成检测的数据会生成结果文件供下载」);
CANCELLED 显示「已中断」(判定先于 isResultPreparing,不掉「等待中」兜底);
重试按钮文案 CANCELLED→「继续」,继续的确认框警示部分结果文件将被替换请先下载;
轮询收敛集合与 keepPendingFileTask 补 CANCELLED。棘轮:前端 catch 块 310→311
(interruptTaskRecord 一支,两处 ElMessageBox 确认走 .then 两臂不新增 catch);
状态词表全走 TaskStatuses 常量。
测试:TaskHeartbeatServiceTest +4(CAS 落库+缓存同步/终态幂等/非本人 403/
任务不存在明确报错)、TaskInPlaceRetryServiceTest +3(继续复位+作业复位+
补检钩子只对 CANCELLED 触发/成功不可继续)、新增 AppearancePatentInterrupted
ResumeTest(3)(保留分片=续跑点/常规交付照旧清理/中断收尾不改写状态)与
AppearancePatentLlmBatchPipelineInterruptTest(2)(批间终态即停);后端定向
79+22 全绿。前端新增 appearance-patent-interrupt-continue.test.ts(9);npm test
1003/1003、test:mount 55/55、vue-tsc 零错;ops 快检 overall=pass(grep 需
Git usr/bin 在 PATH,两红格系本机 shell 环境非代码红)。
并发边界:同工作树另一会话的在飞件(TaskFileJobService 卡死归属守卫、
TaskResultFileJobWorker、DeliverySupport 补检闸及其 3 支测试、useLiveTaskBoard、
task-delete 三件)未卷入本提交;本提交不依赖其中任何符号(appendDeliveryGapMessage/
resetTerminalFailedForRecovery/registry.asMap 均在 HEAD 已在)。
This commit is contained in:
@@ -71,15 +71,19 @@
|
||||
<template #item-actions="{ item }">
|
||||
<button v-if="canDownload(itemSource(item))" type="button" class="download"
|
||||
@click="downloadResult(itemSource(item))">下载</button>
|
||||
<button v-if="canInterruptTask(itemSource(item))" type="button" class="btn-interrupt"
|
||||
@click="interruptTaskRecord(itemSource(item))">中断</button>
|
||||
<button v-if="canRetryTask(itemSource(item))" type="button" class="btn-retry"
|
||||
@click="retryTaskRecord(itemSource(item))">重试</button>
|
||||
@click="retryTaskRecord(itemSource(item))">{{ retryLabel(itemSource(item)) }}</button>
|
||||
<button type="button" class="btn-delete" @click="deleteTaskRecord(itemSource(item))">删除</button>
|
||||
</template>
|
||||
<template #history-item-actions="{ item }">
|
||||
<button v-if="canDownload(itemSource(item))" type="button" class="download"
|
||||
@click="downloadResult(itemSource(item))">下载</button>
|
||||
<button v-if="canInterruptTask(itemSource(item))" type="button" class="btn-interrupt"
|
||||
@click="interruptTaskRecord(itemSource(item))">中断</button>
|
||||
<button v-if="canRetryTask(itemSource(item))" type="button" class="btn-retry"
|
||||
@click="retryTaskRecord(itemSource(item))">重试</button>
|
||||
@click="retryTaskRecord(itemSource(item))">{{ retryLabel(itemSource(item)) }}</button>
|
||||
<button v-if="itemSource(item).taskId || itemSource(item).resultId" type="button" class="btn-delete"
|
||||
@click="deleteTaskRecord(itemSource(item))">删除</button>
|
||||
</template>
|
||||
@@ -103,6 +107,7 @@ import {
|
||||
activateAppearancePatentTask,
|
||||
deleteAppearancePatentHistory,
|
||||
deleteAppearancePatentTask,
|
||||
interruptAppearancePatentTask,
|
||||
retryAppearancePatentTask,
|
||||
getAppearancePatentDashboard,
|
||||
getAppearancePatentHistory,
|
||||
@@ -191,8 +196,9 @@ const board = useLiveTaskBoard<AppearancePatentHistoryItem>({
|
||||
normalizeTaskStatus,
|
||||
isResultPreparing,
|
||||
addPendingAfterFinalStatus: (_task, item) => Boolean(item && isResultPreparing(item)),
|
||||
keepPendingFileTask: (_item, taskStatus) => taskStatus === 'SUCCESS' || taskStatus === 'FAILED',
|
||||
settleOnTaskStatuses: ['SUCCESS', 'FAILED'],
|
||||
keepPendingFileTask: (_item, taskStatus) =>
|
||||
taskStatus === 'SUCCESS' || taskStatus === 'FAILED' || taskStatus === 'CANCELLED',
|
||||
settleOnTaskStatuses: ['SUCCESS', 'FAILED', 'CANCELLED'],
|
||||
beforeBatch: async (taskIds, pendingIds) => {
|
||||
// 行数据按需拉取(审查 F5 后续):等结果文件(pending)时必须强刷;其余情况版本未变的任务跳过
|
||||
const mustForce = pendingIds.length > 0
|
||||
@@ -228,23 +234,78 @@ const board = useLiveTaskBoard<AppearancePatentHistoryItem>({
|
||||
},
|
||||
})
|
||||
|
||||
/** 只有失败的任务能重试:在原任务上复位续跑(不新建任务),成功/进行中的任务不该出现这个按钮。 */
|
||||
/** 失败/已中断的任务能续跑:在原任务上复位(不新建任务),成功/进行中的任务不该出现这个按钮。 */
|
||||
function canRetryTask(item: AppearancePatentHistoryItem | null | undefined): boolean {
|
||||
return Boolean(item?.taskId) && String(item?.taskStatus || '').toUpperCase() === 'FAILED'
|
||||
if (!item?.taskId) return false
|
||||
const status = String(item?.taskStatus || '').toUpperCase()
|
||||
return status === 'FAILED' || status === 'CANCELLED'
|
||||
}
|
||||
|
||||
/** 按钮文案:已中断的任务显示「继续」(从中断点接着跑),失败任务仍是「重试」。 */
|
||||
function retryLabel(item: AppearancePatentHistoryItem | null | undefined): string {
|
||||
return String(item?.taskStatus || '').toUpperCase() === 'CANCELLED' ? '继续' : '重试'
|
||||
}
|
||||
|
||||
/**
|
||||
* 在跑/待跑的任务可中断(2026-11-03):PENDING/RUNNING/SCHEDULED 是服务端 CAS 的同一
|
||||
* ACTIVE 集合;终态任务重按是幂等 no-op,不显示按钮让用户少猜一次。
|
||||
*/
|
||||
function canInterruptTask(item: AppearancePatentHistoryItem | null | undefined): boolean {
|
||||
if (!item?.taskId) return false
|
||||
const status = normalizeTaskStatus(item)
|
||||
return status === 'PENDING' || status === 'RUNNING' || status === 'SCHEDULED'
|
||||
}
|
||||
|
||||
async function retryTaskRecord(item: AppearancePatentHistoryItem | null | undefined) {
|
||||
const taskId = item?.taskId
|
||||
if (!taskId) return
|
||||
const isResume = String(item?.taskStatus || '').toUpperCase() === 'CANCELLED'
|
||||
if (isResume && canDownload(item)) {
|
||||
// 确认框以 reject 收尾属正常交互而不是错误(与 ensureBrandCheckProxyReady 同一口径,
|
||||
// 不新增 catch 块):.then 两臂分别接「确认/取消」。
|
||||
const confirmed = await ElMessageBox.confirm(
|
||||
'继续将重新检测剩余行并生成新的完整结果:当前已生成的部分结果文件会被替换,请先下载留存。确定继续吗?',
|
||||
'继续任务',
|
||||
{ type: 'warning', confirmButtonText: '继续', cancelButtonText: '先不继续' },
|
||||
).then(
|
||||
() => true,
|
||||
() => false,
|
||||
)
|
||||
if (!confirmed) return
|
||||
}
|
||||
try {
|
||||
await retryAppearancePatentTask(taskId)
|
||||
ElMessage.success('已提交重试:在这条任务上继续跑(不新建任务)')
|
||||
ElMessage.success(isResume
|
||||
? '已继续:在这条任务上接着跑(已检测的行不会重检)'
|
||||
: '已提交重试:在这条任务上继续跑(不新建任务)')
|
||||
await refreshBoard()
|
||||
} catch (error) {
|
||||
ElMessage.error(error instanceof Error ? error.message : '重试失败')
|
||||
}
|
||||
}
|
||||
|
||||
async function interruptTaskRecord(item: AppearancePatentHistoryItem | null | undefined) {
|
||||
const taskId = item?.taskId
|
||||
if (!taskId) return
|
||||
// 同上:确认框取消走 reject 两臂,不新增 catch 块
|
||||
const confirmed = await ElMessageBox.confirm(
|
||||
'中断后:未完成的行不再检测,已完成检测的数据会生成结果文件供下载。确定中断吗?',
|
||||
'中断任务',
|
||||
{ type: 'warning', confirmButtonText: '中断', cancelButtonText: '先不中断' },
|
||||
).then(
|
||||
() => true,
|
||||
() => false,
|
||||
)
|
||||
if (!confirmed) return
|
||||
try {
|
||||
await interruptAppearancePatentTask(taskId)
|
||||
ElMessage.success('已中断:已完成部分正在生成结果文件,下载按钮稍后出现')
|
||||
await refreshBoard()
|
||||
} catch (error) {
|
||||
ElMessage.error(error instanceof Error ? error.message : '中断失败')
|
||||
}
|
||||
}
|
||||
|
||||
const visibleTaskSummary = computed(() => parseResult.value || queuedTaskSummary.value)
|
||||
|
||||
/** 手动刷新:强拉历史 + 统计 + 当前轮询任务进度(轮询意外中断后的自救出口) */
|
||||
@@ -321,6 +382,11 @@ function statusText(item: AppearancePatentHistoryItem) {
|
||||
const status = normalizeTaskStatus(item)
|
||||
if (status === 'RUNNING') return taskStatusText(status)
|
||||
if (status === 'PENDING') return taskStatusText(status, { text: { PENDING: '已解析,等待后台执行' } })
|
||||
if (status === 'CANCELLED') {
|
||||
// 已中断:检测/采集已停,部分结果文件生成后下载按钮会自动出现。
|
||||
// 不能掉进函数末尾的「等待中」兜底——那是 task-status-text.ts 点名过的取消态误显形状。
|
||||
return '已中断'
|
||||
}
|
||||
// 已判死(含心跳超时)的任务始终显示失败:后台检测可能仍在跑、文件生成后下载按钮会自动出现,
|
||||
// 但状态文案不能是"结果生成中",否则用户会以为任务还在执行(2026-09-28 29473/29479)
|
||||
if (status === 'FAILED') return isResultBuildFailed(item) ? '结果生成失败' : taskStatusText('FAILED')
|
||||
@@ -333,6 +399,7 @@ function statusText(item: AppearancePatentHistoryItem) {
|
||||
|
||||
function statusClass(item: AppearancePatentHistoryItem) {
|
||||
const status = normalizeTaskStatus(item)
|
||||
if (status === 'CANCELLED') return taskStatusClass('CANCELLED')
|
||||
if (status === 'FAILED' || isResultBuildFailed(item)) return taskStatusClass('FAILED')
|
||||
if (status === 'RUNNING' || isResultPreparing(item)) return taskStatusClass('RUNNING')
|
||||
if (hasDownloadableResult(item)) return taskStatusClass('SUCCESS')
|
||||
@@ -656,7 +723,7 @@ onUnmounted(() => {
|
||||
.channel-title { color: #5e6878; }
|
||||
.channel-opt { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
|
||||
.channel-opt:has(input:disabled) { opacity: .55; cursor: not-allowed; }
|
||||
.btn-run, .btn-delete, .btn-retry, .download { border: none; cursor: pointer; border-radius: 7px; }
|
||||
.btn-run, .btn-delete, .btn-retry, .btn-interrupt, .download { border: none; cursor: pointer; border-radius: 7px; }
|
||||
.btn-run { padding: 10px 18px; color: #f5f8fc; background: #3498db; font-weight: 600; }
|
||||
.btn-queue { background: #27ae60; }
|
||||
.btn-run:disabled { opacity: .55; cursor: not-allowed; }
|
||||
@@ -671,6 +738,8 @@ onUnmounted(() => {
|
||||
.download { padding: 6px 10px; color: #c8d2e2; background: rgba(52, 152, 219, .18); }
|
||||
.btn-delete { padding: 6px 10px; color: #ff8f8f; background: rgba(231, 76, 60, .12); }
|
||||
.btn-retry { padding: 6px 10px; color: #7fd1a0; background: rgba(39, 174, 96, .14); }
|
||||
/* 中断是带后果的警示动作(未完成行不再检测):琥珀色区别于「重试」的绿与「删除」的红 */
|
||||
.btn-interrupt { padding: 6px 10px; color: #f0b35e; background: rgba(240, 179, 94, .12); }
|
||||
@media (max-width: 1100px) {
|
||||
.main-content { flex-direction: column; height: auto; }
|
||||
.left-panel { width: 100%; border-right: none; border-bottom: 1px solid #2e3a52; }
|
||||
|
||||
@@ -277,6 +277,21 @@ export function retryAppearancePatentTask(taskId: number) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户中断任务(2026-11-03「中断+继续」):在跑/待跑的任务落 CANCELLED——停检测与采集
|
||||
* (客户端心跳拿到 notAlive 后协作停止),已完成部分按部分结果出表,下载按钮随文件出现。
|
||||
* 终态任务重按是幂等 no-op;普通账号只能中断自己名下的任务。
|
||||
*/
|
||||
export function interruptAppearancePatentTask(taskId: number) {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<null>>(
|
||||
`${JAVA_API_PREFIX}/tasks/${taskId}/interrupt`,
|
||||
undefined,
|
||||
{ params: { user_id: getCurrentUserId() } },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function deleteAppearancePatentHistory(resultId: number) {
|
||||
return unwrapJavaResponse(
|
||||
del<JavaApiResponse<null>>(
|
||||
|
||||
Reference in New Issue
Block a user