合并分支
This commit is contained in:
+66
-4
@@ -483,8 +483,11 @@ public class SimilarAsinTaskService {
|
||||
|
||||
public SimilarAsinDashboardVo dashboard(Long userId) {
|
||||
SimilarAsinDashboardVo vo = new SimilarAsinDashboardVo();
|
||||
vo.setPendingTaskCount(countTask(userId, STATUS_RUNNING));
|
||||
vo.setSuccessTaskCount(countTask(userId, STATUS_SUCCESS));
|
||||
long completedWithFile = countCompletedTasksWithResultFile(userId);
|
||||
long rawRunning = countTask(userId, STATUS_RUNNING);
|
||||
long rawSuccess = countTask(userId, STATUS_SUCCESS);
|
||||
vo.setPendingTaskCount(Math.max(0L, rawRunning - completedWithFile));
|
||||
vo.setSuccessTaskCount(rawSuccess + completedWithFile);
|
||||
vo.setFailedTaskCount(countTask(userId, STATUS_FAILED));
|
||||
vo.setProcessedTaskCount(vo.getSuccessTaskCount() + vo.getFailedTaskCount());
|
||||
return vo;
|
||||
@@ -4819,6 +4822,22 @@ public class SimilarAsinTaskService {
|
||||
return count == null ? 0L : count;
|
||||
}
|
||||
|
||||
private long countCompletedTasksWithResultFile(Long userId) {
|
||||
if (userId == null || userId <= 0) {
|
||||
return 0L;
|
||||
}
|
||||
Long count = fileTaskMapper.selectCount(new LambdaQueryWrapper<FileTaskEntity>()
|
||||
.eq(FileTaskEntity::getModuleType, MODULE_TYPE)
|
||||
.eq(FileTaskEntity::getUserId, userId)
|
||||
.eq(FileTaskEntity::getStatus, STATUS_RUNNING)
|
||||
.inSql(FileTaskEntity::getId,
|
||||
"select distinct task_id from file_result " +
|
||||
"where module_type = '" + MODULE_TYPE + "' " +
|
||||
"and user_id = " + userId + " " +
|
||||
"and result_file_url is not null and result_file_url <> ''"));
|
||||
return count == null ? 0L : count;
|
||||
}
|
||||
|
||||
private int countChunks(Long taskId, String scopeHash) {
|
||||
Long count = taskChunkMapper.selectCount(new LambdaQueryWrapper<TaskChunkEntity>()
|
||||
.eq(TaskChunkEntity::getTaskId, taskId)
|
||||
@@ -4861,7 +4880,7 @@ public class SimilarAsinTaskService {
|
||||
SimilarAsinTaskItemVo vo = new SimilarAsinTaskItemVo();
|
||||
vo.setId(task.getId());
|
||||
vo.setTaskNo(task.getTaskNo());
|
||||
vo.setStatus(task.getStatus());
|
||||
vo.setStatus(resolveDisplayTaskStatus(task));
|
||||
vo.setErrorMessage(task.getErrorMessage());
|
||||
vo.setCreatedAt(fmt(task.getCreatedAt()));
|
||||
vo.setUpdatedAt(fmt(task.getUpdatedAt()));
|
||||
@@ -4876,7 +4895,7 @@ public class SimilarAsinTaskService {
|
||||
vo.setSourceFilename(row.getSourceFilename());
|
||||
vo.setResultFilename(row.getResultFilename());
|
||||
vo.setDownloadUrl(buildFreshDownloadUrl(row));
|
||||
vo.setTaskStatus(task == null ? null : task.getStatus());
|
||||
vo.setTaskStatus(resolveDisplayTaskStatus(task, row));
|
||||
attachFileJobState(vo, row, job, task);
|
||||
vo.setSuccess(row.getSuccess() != null && row.getSuccess() == 1);
|
||||
vo.setError(row.getErrorMessage());
|
||||
@@ -4931,6 +4950,13 @@ public class SimilarAsinTaskService {
|
||||
int cozePending = countPendingCozeStates(taskId);
|
||||
boolean uploadComplete = isResultSubmissionComplete(taskId);
|
||||
if (!uploadComplete) {
|
||||
if (canTreatTaskAsCompleted(task, row, job)) {
|
||||
vo.setFileProgressCurrent(1);
|
||||
vo.setFileProgressTotal(1);
|
||||
vo.setFileProgressPercent(100);
|
||||
vo.setFileProgressMessage("结果文件已生成");
|
||||
return;
|
||||
}
|
||||
if (task != null && !STATUS_RUNNING.equals(task.getStatus())) {
|
||||
return;
|
||||
}
|
||||
@@ -5088,6 +5114,42 @@ public class SimilarAsinTaskService {
|
||||
return "等待 Python 回传,已回传 " + Math.max(0, current) + "/" + Math.max(1, total) + " " + safeUnit;
|
||||
}
|
||||
|
||||
private String resolveDisplayTaskStatus(FileTaskEntity task) {
|
||||
return resolveDisplayTaskStatus(task, null);
|
||||
}
|
||||
|
||||
private String resolveDisplayTaskStatus(FileTaskEntity task, FileResultEntity row) {
|
||||
if (task == null) {
|
||||
return null;
|
||||
}
|
||||
if (canTreatTaskAsCompleted(task, row, null)) {
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
return task.getStatus();
|
||||
}
|
||||
|
||||
private boolean canTreatTaskAsCompleted(FileTaskEntity task, FileResultEntity row, TaskFileJobEntity job) {
|
||||
if (task == null) {
|
||||
return false;
|
||||
}
|
||||
if (STATUS_SUCCESS.equals(task.getStatus())) {
|
||||
return true;
|
||||
}
|
||||
if (!STATUS_RUNNING.equals(task.getStatus())) {
|
||||
return false;
|
||||
}
|
||||
if (row == null) {
|
||||
return false;
|
||||
}
|
||||
if (row.getResultFileUrl() == null || row.getResultFileUrl().isBlank()) {
|
||||
return false;
|
||||
}
|
||||
if (job != null && "FAILED".equals(job.getStatus())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private int calculateCozeDisplayTotal(TaskProgressSnapshotEntity snapshot, int observedCozeStates) {
|
||||
int observed = Math.max(0, observedCozeStates);
|
||||
// 小任务 totalCount <= 3 时直接使用 observed,避免 totalCount - 3 → 0 引起进度条 0/0。
|
||||
|
||||
Reference in New Issue
Block a user