后端优化修复问题
This commit is contained in:
+40
-11
@@ -5066,6 +5066,7 @@ public class SimilarAsinTaskService {
|
||||
int cozeCompleted = countCompletedCozeStates(taskId);
|
||||
int cozePending = countPendingCozeStates(taskId);
|
||||
boolean uploadComplete = isResultSubmissionComplete(taskId);
|
||||
TaskProgressSnapshotEntity snapshot = taskProgressSnapshotService.find(taskId, MODULE_TYPE);
|
||||
if (!uploadComplete) {
|
||||
if (canTreatTaskAsCompleted(task, row, job)) {
|
||||
vo.setFileProgressCurrent(1);
|
||||
@@ -5077,21 +5078,15 @@ public class SimilarAsinTaskService {
|
||||
if (task != null && !STATUS_RUNNING.equals(task.getStatus())) {
|
||||
return;
|
||||
}
|
||||
if (cozeCompleted + cozePending > 0) {
|
||||
attachCozeProgress(vo, job, snapshot, cozeCompleted, cozePending, false);
|
||||
return;
|
||||
}
|
||||
attachPythonUploadProgress(vo, taskId);
|
||||
return;
|
||||
}
|
||||
TaskProgressSnapshotEntity snapshot = taskProgressSnapshotService.find(taskId, MODULE_TYPE);
|
||||
if (cozeCompleted + cozePending > 0) {
|
||||
int total = calculateCozeDisplayTotal(snapshot, cozeCompleted + cozePending);
|
||||
int current = Math.max(0, Math.min(cozeCompleted, total));
|
||||
vo.setFileProgressCurrent(current);
|
||||
vo.setFileProgressTotal(total);
|
||||
int percent = calculateDisplayProgressPercent(current, total, job, snapshot == null ? null : snapshot.getUpdatedAt());
|
||||
percent = Math.max(percent, calculateSnapshotDisplayPercent(snapshot, job));
|
||||
vo.setFileProgressPercent(Math.min(99, percent));
|
||||
vo.setFileProgressMessage(cozePending > 0
|
||||
? buildCozeProgressMessage(current, total, cozePending)
|
||||
: "Coze 已回流 " + current + "/" + total + " 批次,正在生成结果文件");
|
||||
attachCozeProgress(vo, job, snapshot, cozeCompleted, cozePending, true);
|
||||
return;
|
||||
}
|
||||
if (snapshot == null) {
|
||||
@@ -5112,6 +5107,30 @@ public class SimilarAsinTaskService {
|
||||
vo.setFileProgressMessage(snapshot.getMessage());
|
||||
}
|
||||
|
||||
private void attachCozeProgress(SimilarAsinHistoryItemVo vo,
|
||||
TaskFileJobEntity job,
|
||||
TaskProgressSnapshotEntity snapshot,
|
||||
int cozeCompleted,
|
||||
int cozePending,
|
||||
boolean uploadComplete) {
|
||||
int observed = Math.max(0, cozeCompleted) + Math.max(0, cozePending);
|
||||
int total = calculateCozeDisplayTotal(snapshot, observed);
|
||||
if (!uploadComplete) {
|
||||
total = Math.max(total, observed + 1);
|
||||
}
|
||||
int current = Math.max(0, Math.min(cozeCompleted, total));
|
||||
vo.setFileProgressCurrent(current);
|
||||
vo.setFileProgressTotal(total);
|
||||
int percent = calculateDisplayProgressPercent(current, total, job, snapshot == null ? null : snapshot.getUpdatedAt());
|
||||
percent = Math.max(percent, calculateSnapshotDisplayPercent(snapshot, job));
|
||||
vo.setFileProgressPercent(Math.min(uploadComplete ? 99 : 98, percent));
|
||||
vo.setFileProgressMessage(uploadComplete
|
||||
? (cozePending > 0
|
||||
? buildCozeProgressMessage(current, total, cozePending)
|
||||
: "Coze 已回流 " + current + "/" + total + " 批次,正在生成结果文件")
|
||||
: buildUploadingCozeProgressMessage(current, total, cozePending));
|
||||
}
|
||||
|
||||
private void attachPythonUploadProgress(SimilarAsinHistoryItemVo vo, Long taskId) {
|
||||
PythonUploadProgress progress = resolvePythonUploadProgress(taskId);
|
||||
int total = progress.total() > 0 ? progress.total() : Math.max(1, progress.current() + 1);
|
||||
@@ -5287,6 +5306,16 @@ public class SimilarAsinTaskService {
|
||||
return "Coze 已回流 " + safeCompleted + "/" + safeTotal + " 批次,等待结果文件";
|
||||
}
|
||||
|
||||
private String buildUploadingCozeProgressMessage(int completed, int total, int pending) {
|
||||
int safeTotal = Math.max(1, total);
|
||||
int safeCompleted = Math.max(0, Math.min(completed, safeTotal));
|
||||
int submitted = Math.max(safeCompleted, Math.min(safeTotal, safeCompleted + Math.max(0, pending)));
|
||||
if (pending > 0) {
|
||||
return "Python 仍在回传,Coze 已提交 " + submitted + "/" + safeTotal + " 批次";
|
||||
}
|
||||
return "Python 仍在回传,Coze 已回流 " + safeCompleted + "/" + safeTotal + " 批次";
|
||||
}
|
||||
|
||||
private String fmt(LocalDateTime t) {
|
||||
return t == null ? null : t.toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user