feat(task-retry): 失败任务改为原任务上重试 + 重试按钮(用户拍板)
用户口径(2026-11-01):失败不再自动克隆(一单失败几次就多几行结果),
改成「删除」旁边的「重试」按钮,在原任务上断点续传;自动重试也只复位原任务。
- 新增 TaskInPlaceRetryService:FAILED→PENDING,清错误/终态时间,代数+1,
保留分片/解析载荷/已检测标记;结果行清错误、组装作业复位(含卡死重排计数清零)
- TaskResumeService 自动重试改为调用原地复位(不再 cloneForRetry)
- TaskRetryEligibility 新增 DELIVERY(结果文件生成多次失败/卡死重排不重试)
- 新端点 POST /api/appearance-patent/tasks/{id}/retry;前端失败任务显示重试按钮
- ⚠ 本笔的 BrandAppearancePatentTab.vue 里另含他路在飞的「删除失败任务时一并删任务行」
两小段(同一文件无法分块提交),随本笔一并入库
- 用例:TaskInPlaceRetryServiceTest 2、TaskResumeServiceTest 19、Eligibility 9、
契约 8、前端 catch 棘轮 4,均绿
This commit is contained in:
@@ -71,12 +71,16 @@
|
||||
<template #item-actions="{ item }">
|
||||
<button v-if="canDownload(itemSource(item))" type="button" class="download"
|
||||
@click="downloadResult(itemSource(item))">下载</button>
|
||||
<button v-if="canRetryTask(itemSource(item))" type="button" class="btn-retry"
|
||||
@click="retryTaskRecord(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="itemSource(item).resultId" type="button" class="btn-delete"
|
||||
<button v-if="canRetryTask(itemSource(item))" type="button" class="btn-retry"
|
||||
@click="retryTaskRecord(itemSource(item))">重试</button>
|
||||
<button v-if="itemSource(item).taskId || itemSource(item).resultId" type="button" class="btn-delete"
|
||||
@click="deleteTaskRecord(itemSource(item))">删除</button>
|
||||
</template>
|
||||
</TaskCenterPanel>
|
||||
@@ -99,6 +103,7 @@ import {
|
||||
activateAppearancePatentTask,
|
||||
deleteAppearancePatentHistory,
|
||||
deleteAppearancePatentTask,
|
||||
retryAppearancePatentTask,
|
||||
getAppearancePatentDashboard,
|
||||
getAppearancePatentHistory,
|
||||
getAppearancePatentQueuePayload,
|
||||
@@ -214,13 +219,32 @@ const board = useLiveTaskBoard<AppearancePatentHistoryItem>({
|
||||
progressKeyPrefix: 'appearance-patent',
|
||||
},
|
||||
deleteTask: {
|
||||
shouldDeleteTask: (item) => item.taskStatus === 'RUNNING' && item.taskId != null,
|
||||
// 有任务就删任务:失败任务常被自动克隆重试(克隆件没有结果行),只删结果行等于
|
||||
// 删不掉那条任务——统计不降、任务还会被再克隆一次,用户看到的就是「删了又回来」。
|
||||
shouldDeleteTask: (item) => item.taskId != null,
|
||||
deleteTask: (taskId) => deleteAppearancePatentTask(taskId),
|
||||
deleteHistory: (resultId) => deleteAppearancePatentHistory(resultId),
|
||||
onTaskDeleted: (item) => board.removePollingTask(item.taskId as number),
|
||||
},
|
||||
})
|
||||
|
||||
/** 只有失败的任务能重试:在原任务上复位续跑(不新建任务),成功/进行中的任务不该出现这个按钮。 */
|
||||
function canRetryTask(item: AppearancePatentHistoryItem | null | undefined): boolean {
|
||||
return Boolean(item?.taskId) && String(item?.taskStatus || '').toUpperCase() === 'FAILED'
|
||||
}
|
||||
|
||||
async function retryTaskRecord(item: AppearancePatentHistoryItem | null | undefined) {
|
||||
const taskId = item?.taskId
|
||||
if (!taskId) return
|
||||
try {
|
||||
await retryAppearancePatentTask(taskId)
|
||||
ElMessage.success('已提交重试:在这条任务上继续跑(不新建任务)')
|
||||
await refreshBoard()
|
||||
} catch (error) {
|
||||
ElMessage.error(error instanceof Error ? error.message : '重试失败')
|
||||
}
|
||||
}
|
||||
|
||||
const visibleTaskSummary = computed(() => parseResult.value || queuedTaskSummary.value)
|
||||
|
||||
/** 手动刷新:强拉历史 + 统计 + 当前轮询任务进度(轮询意外中断后的自救出口) */
|
||||
@@ -632,7 +656,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, .download { border: none; cursor: pointer; border-radius: 7px; }
|
||||
.btn-run, .btn-delete, .btn-retry, .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; }
|
||||
@@ -646,6 +670,7 @@ onUnmounted(() => {
|
||||
.result-hint { margin-top: 6px; color: #e0b96d; }
|
||||
.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); }
|
||||
@media (max-width: 1100px) {
|
||||
.main-content { flex-direction: column; height: auto; }
|
||||
.left-panel { width: 100%; border-right: none; border-bottom: 1px solid #2e3a52; }
|
||||
|
||||
@@ -263,6 +263,20 @@ export function deleteAppearancePatentTask(taskId: number) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败任务重试:在原任务上复位(保留已收分片/解析载荷,断点续传),**不创建新任务**。
|
||||
* 2026-11-01 用户口径:失败任务靠「删除」旁边的「重试」按钮,不再自动克隆。
|
||||
*/
|
||||
export function retryAppearancePatentTask(taskId: number) {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<null>>(
|
||||
`${JAVA_API_PREFIX}/appearance-patent/tasks/${taskId}/retry`,
|
||||
undefined,
|
||||
{ params: { user_id: getCurrentUserId() } },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function deleteAppearancePatentHistory(resultId: number) {
|
||||
return unwrapJavaResponse(
|
||||
del<JavaApiResponse<null>>(
|
||||
|
||||
Reference in New Issue
Block a user