From 421d9da1b3bcb2642e62307c0a181c8c49529da2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E8=87=AA=E8=BE=BE?= <980324341@qq.com> Date: Tue, 20 Oct 2026 15:23:06 +0800 Subject: [PATCH] =?UTF-8?q?refactor(phase-3):=203A=20=E6=8B=86=E8=96=84?= =?UTF-8?q?=E7=AC=AC=E5=85=AB=E7=AC=94=E2=80=94=E2=80=94AP=20=E8=BF=9B?= =?UTF-8?q?=E5=BA=A6=E4=B8=8E=E8=A7=86=E5=9B=BE=E7=BB=84=E8=A3=85=E5=87=BA?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E6=9C=8D=E5=8A=A1=202377=E2=86=922161?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit G 聚类(看板/历史/批量进度、文件构建进度百分比与快照落库)原样搬进 AppearancePatentProgressSupport;四个公开入口与 saveFileBuildProgress 保留同名薄委托。SourceScan 面数 34→35、support 11→12 并点名新件。 --- .../service/AppearancePatentTaskService.java | 248 +------------- .../AppearancePatentProgressSupport.java | 321 ++++++++++++++++++ .../aiimage/testutil/SourceScanTest.java | 19 +- 3 files changed, 347 insertions(+), 241 deletions(-) create mode 100644 backend-java/src/main/java/com/nanri/aiimage/modules/appearancepatent/service/support/AppearancePatentProgressSupport.java diff --git a/backend-java/src/main/java/com/nanri/aiimage/modules/appearancepatent/service/AppearancePatentTaskService.java b/backend-java/src/main/java/com/nanri/aiimage/modules/appearancepatent/service/AppearancePatentTaskService.java index 29be2e1dd..21a75211d 100644 --- a/backend-java/src/main/java/com/nanri/aiimage/modules/appearancepatent/service/AppearancePatentTaskService.java +++ b/backend-java/src/main/java/com/nanri/aiimage/modules/appearancepatent/service/AppearancePatentTaskService.java @@ -26,6 +26,7 @@ import com.nanri.aiimage.modules.appearancepatent.model.vo.AppearancePatentHisto import com.nanri.aiimage.modules.appearancepatent.service.support.AppearancePatentHistoryAssembler; import com.nanri.aiimage.modules.appearancepatent.service.support.AppearancePatentLlmBatchPipeline; import com.nanri.aiimage.modules.appearancepatent.service.support.AppearancePatentPayloadSupport; +import com.nanri.aiimage.modules.appearancepatent.service.support.AppearancePatentProgressSupport; import com.nanri.aiimage.modules.appearancepatent.service.support.AppearancePatentResultRowReader; import com.nanri.aiimage.modules.appearancepatent.model.vo.AppearancePatentHistoryVo; import com.nanri.aiimage.modules.appearancepatent.model.vo.AppearancePatentParsedGroupVo; @@ -100,7 +101,7 @@ public class AppearancePatentTaskService extends AbstractFileTaskPipeline taskIds, Long userId) { - return taskProgressLightAssembler.assemble(MODULE_TYPE, userId, taskIds); + return progressSupport().progressLight(taskIds, userId); } private static final String STATUS_PENDING = "PENDING"; private static final String STATUS_RUNNING = "RUNNING"; @@ -329,124 +330,15 @@ public class AppearancePatentTaskService extends AbstractFileTaskPipeline rows = fileResultMapper.selectList(new LambdaQueryWrapper() - .select(FileResultEntity::getId, - FileResultEntity::getTaskId, - FileResultEntity::getSourceFilename, - FileResultEntity::getResultFilename, - FileResultEntity::getResultFileUrl, - FileResultEntity::getRowCount, - FileResultEntity::getSuccess, - FileResultEntity::getErrorMessage, - FileResultEntity::getCreatedAt) - .eq(FileResultEntity::getModuleType, MODULE_TYPE) - .eq(FileResultEntity::getUserId, userId) - .orderByDesc(FileResultEntity::getCreatedAt) - .last("limit " + safeLimit)); - Map taskMap = new LinkedHashMap<>(); - List taskIds = rows.stream().map(FileResultEntity::getTaskId).filter(Objects::nonNull).distinct().toList(); - if (!taskIds.isEmpty()) { - for (FileTaskEntity task : fileTaskMapper.selectList(new LambdaQueryWrapper() - .select(FileTaskEntity::getId, - FileTaskEntity::getStatus, - FileTaskEntity::getCreatedAt, - FileTaskEntity::getUpdatedAt, - FileTaskEntity::getFinishedAt) - .in(FileTaskEntity::getId, taskIds))) { - taskMap.put(task.getId(), task); - } - } - Map jobMap = taskFileJobService.findAssembleJobsByResultIds(MODULE_TYPE, rows.stream() - .map(FileResultEntity::getId) - .filter(Objects::nonNull) - .toList()); - List sortedRows = new ArrayList<>(rows); - sortedRows.sort(Comparator - .comparingInt((FileResultEntity row) -> historyPriority(row, taskMap.get(row.getTaskId()), jobMap.get(row.getId()))) - .thenComparing((FileResultEntity row) -> historyActivityTime(row, taskMap.get(row.getTaskId()), jobMap.get(row.getId())), - Comparator.nullsLast(Comparator.reverseOrder())) - .thenComparing(FileResultEntity::getCreatedAt, Comparator.nullsLast(Comparator.reverseOrder())) - .thenComparing(FileResultEntity::getId, Comparator.nullsLast(Comparator.reverseOrder()))); - for (FileResultEntity row : sortedRows) { - FileTaskEntity task = taskMap.get(row.getTaskId()); - vo.getItems().add(toHistoryItem(row, task, jobMap.get(row.getId()))); - } - return vo; + return progressSupport().history(userId, limit); } public AppearancePatentTaskBatchVo progressBatch(List taskIds) { - AppearancePatentTaskBatchVo vo = new AppearancePatentTaskBatchVo(); - List normalizedIds = taskIds == null ? List.of() : taskIds.stream() - .filter(id -> id != null && id > 0) - .distinct() - .toList(); - if (normalizedIds.isEmpty()) { - return vo; - } - Map taskMap = new LinkedHashMap<>(); - for (FileTaskEntity task : fileTaskMapper.selectList(new LambdaQueryWrapper() - .select(FileTaskEntity::getId, - FileTaskEntity::getTaskNo, - FileTaskEntity::getModuleType, - FileTaskEntity::getStatus, - FileTaskEntity::getErrorMessage, - FileTaskEntity::getCreatedAt, - FileTaskEntity::getUpdatedAt, - FileTaskEntity::getFinishedAt) - .in(FileTaskEntity::getId, normalizedIds))) { - if (task != null && MODULE_TYPE.equals(task.getModuleType())) { - taskMap.put(task.getId(), task); - } - } - List resultRows = fileResultMapper.selectList(new LambdaQueryWrapper() - .select(FileResultEntity::getId, - FileResultEntity::getTaskId, - FileResultEntity::getSourceFilename, - FileResultEntity::getResultFilename, - FileResultEntity::getResultFileUrl, - FileResultEntity::getRowCount, - FileResultEntity::getSuccess, - FileResultEntity::getErrorMessage, - FileResultEntity::getCreatedAt) - .eq(FileResultEntity::getModuleType, MODULE_TYPE) - .in(FileResultEntity::getTaskId, normalizedIds) - .orderByDesc(FileResultEntity::getCreatedAt)); - Map resultByTaskId = new LinkedHashMap<>(); - for (FileResultEntity row : resultRows) { - if (row.getTaskId() != null) { - resultByTaskId.putIfAbsent(row.getTaskId(), row); - } - } - Map jobMap = taskFileJobService.findAssembleJobsByResultIds(MODULE_TYPE, resultRows.stream() - .map(FileResultEntity::getId) - .filter(Objects::nonNull) - .toList()); - for (Long taskId : normalizedIds) { - FileTaskEntity task = taskMap.get(taskId); - if (task == null) { - vo.getMissingTaskIds().add(taskId); - continue; - } - AppearancePatentTaskDetailVo detail = new AppearancePatentTaskDetailVo(); - detail.setTask(toTaskItem(task)); - FileResultEntity resultRow = resultByTaskId.get(taskId); - if (resultRow != null) { - detail.getItems().add(toHistoryItem(resultRow, task, jobMap.get(resultRow.getId()))); - } - vo.getItems().add(detail); - } - return vo; + return progressSupport().progressBatch(taskIds); } public void submitResult(Long taskId, AppearancePatentSubmitResultRequest request) { @@ -855,6 +747,16 @@ public class AppearancePatentTaskService extends AbstractFileTaskPipeline displayPercent && safeCompleted < safeTotal) { - displayPercent = previousDisplayPercent; - } - // 终态必须带任务真实状态落库:save() 只对终态豁免 500ms 节流,收尾三连写(组装/上传/完成) - // 都在同一次调用里,若全按 RUNNING 写,只有第一条落地,满格「结果文件已生成」必被吞—— - // 看板就会永远停在 0/N 或 N-2/N(2026-10-04 生产实测)。对齐货源查询 isTerminalFileBuildProgress。 - boolean terminalProgress = safeCompleted >= safeTotal - && (STATUS_SUCCESS.equals(task.getStatus()) || STATUS_FAILED.equals(task.getStatus())); - if (terminalProgress) { - displayPercent = 100; - } - taskProgressSnapshotService.save( - task.getId(), - MODULE_TYPE, - terminalProgress ? task.getStatus() : STATUS_RUNNING, - safeTotal, - safeCompleted, - 0, - job.getScopeKey(), - message, - Map.of("phase", "RESULT_FILE", "jobId", job.getId(), "displayPercent", displayPercent) - ); - } - - private int calculateDisplayProgressPercent(int current, - int total, - TaskFileJobEntity job, - LocalDateTime baseTime) { - if (total <= 0) { - return 0; - } - current = Math.max(0, Math.min(current, total)); - int percent = Math.max(1, Math.min(99, (int) Math.floor(current * 100.0 / total))); - if (job != null && STATUS_RUNNING.equals(job.getStatus())) { - long elapsedSeconds = baseTime == null ? 0 : Math.max(0, Duration.between(baseTime, LocalDateTime.now()).getSeconds()); - if (current <= 0) { - int firstRealProgressPercent = Math.max(1, Math.min(99, (int) Math.floor(100.0 / total))); - int waitingCap = Math.max(8, Math.min(35, firstRealProgressPercent - 1)); - percent = Math.max(percent, Math.min(waitingCap, 8 + (int) (elapsedSeconds / 6))); - } else if (current < total) { - percent = Math.max(percent, Math.min(92, percent + (int) (elapsedSeconds / 10))); - } - } - return percent; - } - - private int calculateSnapshotDisplayPercent(TaskProgressSnapshotEntity snapshot, TaskFileJobEntity job) { - if (snapshot == null) { - return 0; - } - int total = snapshot.getTotalCount() == null ? 0 : snapshot.getTotalCount(); - int current = snapshot.getSuccessCount() == null ? 0 : snapshot.getSuccessCount(); - int percent = total <= 0 ? 0 : calculateDisplayProgressPercent(current, total, job, snapshot.getUpdatedAt()); - return Math.max(percent, extractSnapshotDisplayPercent(snapshot)); - } - - private int extractSnapshotDisplayPercent(TaskProgressSnapshotEntity snapshot) { - if (snapshot == null || snapshot.getSnapshotJson() == null || snapshot.getSnapshotJson().isBlank()) { - return 0; - } - try { - JsonNode displayPercent = objectMapper.readTree(snapshot.getSnapshotJson()).path("displayPercent"); - if (!displayPercent.isNumber()) { - return 0; - } - return Math.max(0, Math.min(100, displayPercent.asInt())); - } catch (Exception ignored) { - return 0; - } + progressSupport().saveFileBuildProgress(task, job, total, completed, message); } public void cleanupResultFileJob(TaskFileJobEntity job) { @@ -2257,14 +2083,6 @@ public class AppearancePatentTaskService extends AbstractFileTaskPipeline() - .eq(FileTaskEntity::getModuleType, MODULE_TYPE) - .eq(FileTaskEntity::getUserId, userId) - .eq(FileTaskEntity::getStatus, status)); - return count == null ? 0L : count; - } - private int countChunks(Long taskId, String scopeHash) { Long count = taskChunkMapper.selectCount(new LambdaQueryWrapper() .eq(TaskChunkEntity::getTaskId, taskId) @@ -2273,40 +2091,6 @@ public class AppearancePatentTaskService extends AbstractFileTaskPipeline原样搬移 + * (3A 拆薄第八笔):看板计数、历史列表、批量进度、文件构建进度百分比与快照节流落库, + * 连同 500ms 节流豁免、终态带真实状态、显示百分比只增不减这些判据一个字没改。 + * + *

无状态、按调用现取(与 {@code historyAssembler()} 同一先例),不新增 Spring bean。 + */ +public class AppearancePatentProgressSupport { + + private static final String STATUS_RUNNING = TaskStatuses.FileTask.RUNNING; + private static final String STATUS_SUCCESS = TaskStatuses.FileTask.SUCCESS; + private static final String STATUS_FAILED = TaskStatuses.FileTask.FAILED; + + private final String moduleType; + private final TaskProgressLightAssembler taskProgressLightAssembler; + private final FileTaskMapper fileTaskMapper; + private final FileResultMapper fileResultMapper; + private final TaskFileJobService taskFileJobService; + private final TaskProgressSnapshotService taskProgressSnapshotService; + private final ObjectMapper objectMapper; + + public AppearancePatentProgressSupport(String moduleType, + TaskProgressLightAssembler taskProgressLightAssembler, + FileTaskMapper fileTaskMapper, + FileResultMapper fileResultMapper, + TaskFileJobService taskFileJobService, + TaskProgressSnapshotService taskProgressSnapshotService, + ObjectMapper objectMapper) { + this.moduleType = moduleType; + this.taskProgressLightAssembler = taskProgressLightAssembler; + this.fileTaskMapper = fileTaskMapper; + this.fileResultMapper = fileResultMapper; + this.taskFileJobService = taskFileJobService; + this.taskProgressSnapshotService = taskProgressSnapshotService; + this.objectMapper = objectMapper; + } + + public TaskProgressLightBatchVo progressLight(List taskIds, Long userId) { + return taskProgressLightAssembler.assemble(moduleType, userId, taskIds); + } + + public AppearancePatentDashboardVo dashboard(Long userId) { + AppearancePatentDashboardVo vo = new AppearancePatentDashboardVo(); + vo.setPendingTaskCount(countTask(userId, STATUS_RUNNING)); + vo.setSuccessTaskCount(countTask(userId, STATUS_SUCCESS)); + vo.setFailedTaskCount(countTask(userId, STATUS_FAILED)); + vo.setProcessedTaskCount(vo.getSuccessTaskCount() + vo.getFailedTaskCount()); + return vo; + } + + public AppearancePatentHistoryVo history(Long userId, Integer limit) { + AppearancePatentHistoryVo vo = new AppearancePatentHistoryVo(); + int safeLimit = Math.max(1, Math.min(limit == null ? 50 : limit, 100)); + List rows = fileResultMapper.selectList(new LambdaQueryWrapper() + .select(FileResultEntity::getId, + FileResultEntity::getTaskId, + FileResultEntity::getSourceFilename, + FileResultEntity::getResultFilename, + FileResultEntity::getResultFileUrl, + FileResultEntity::getRowCount, + FileResultEntity::getSuccess, + FileResultEntity::getErrorMessage, + FileResultEntity::getCreatedAt) + .eq(FileResultEntity::getModuleType, moduleType) + .eq(FileResultEntity::getUserId, userId) + .orderByDesc(FileResultEntity::getCreatedAt) + .last("limit " + safeLimit)); + Map taskMap = new LinkedHashMap<>(); + List taskIds = rows.stream().map(FileResultEntity::getTaskId).filter(Objects::nonNull).distinct().toList(); + if (!taskIds.isEmpty()) { + for (FileTaskEntity task : fileTaskMapper.selectList(new LambdaQueryWrapper() + .select(FileTaskEntity::getId, + FileTaskEntity::getStatus, + FileTaskEntity::getCreatedAt, + FileTaskEntity::getUpdatedAt, + FileTaskEntity::getFinishedAt) + .in(FileTaskEntity::getId, taskIds))) { + taskMap.put(task.getId(), task); + } + } + Map jobMap = taskFileJobService.findAssembleJobsByResultIds(moduleType, rows.stream() + .map(FileResultEntity::getId) + .filter(Objects::nonNull) + .toList()); + List sortedRows = new ArrayList<>(rows); + sortedRows.sort(Comparator + .comparingInt((FileResultEntity row) -> historyPriority(row, taskMap.get(row.getTaskId()), jobMap.get(row.getId()))) + .thenComparing((FileResultEntity row) -> historyActivityTime(row, taskMap.get(row.getTaskId()), jobMap.get(row.getId())), + Comparator.nullsLast(Comparator.reverseOrder())) + .thenComparing(FileResultEntity::getCreatedAt, Comparator.nullsLast(Comparator.reverseOrder())) + .thenComparing(FileResultEntity::getId, Comparator.nullsLast(Comparator.reverseOrder()))); + for (FileResultEntity row : sortedRows) { + FileTaskEntity task = taskMap.get(row.getTaskId()); + vo.getItems().add(toHistoryItem(row, task, jobMap.get(row.getId()))); + } + return vo; + } + + public AppearancePatentTaskBatchVo progressBatch(List taskIds) { + AppearancePatentTaskBatchVo vo = new AppearancePatentTaskBatchVo(); + List normalizedIds = taskIds == null ? List.of() : taskIds.stream() + .filter(id -> id != null && id > 0) + .distinct() + .toList(); + if (normalizedIds.isEmpty()) { + return vo; + } + Map taskMap = new LinkedHashMap<>(); + for (FileTaskEntity task : fileTaskMapper.selectList(new LambdaQueryWrapper() + .select(FileTaskEntity::getId, + FileTaskEntity::getTaskNo, + FileTaskEntity::getModuleType, + FileTaskEntity::getStatus, + FileTaskEntity::getErrorMessage, + FileTaskEntity::getCreatedAt, + FileTaskEntity::getUpdatedAt, + FileTaskEntity::getFinishedAt) + .in(FileTaskEntity::getId, normalizedIds))) { + if (task != null && moduleType.equals(task.getModuleType())) { + taskMap.put(task.getId(), task); + } + } + List resultRows = fileResultMapper.selectList(new LambdaQueryWrapper() + .select(FileResultEntity::getId, + FileResultEntity::getTaskId, + FileResultEntity::getSourceFilename, + FileResultEntity::getResultFilename, + FileResultEntity::getResultFileUrl, + FileResultEntity::getRowCount, + FileResultEntity::getSuccess, + FileResultEntity::getErrorMessage, + FileResultEntity::getCreatedAt) + .eq(FileResultEntity::getModuleType, moduleType) + .in(FileResultEntity::getTaskId, normalizedIds) + .orderByDesc(FileResultEntity::getCreatedAt)); + Map resultByTaskId = new LinkedHashMap<>(); + for (FileResultEntity row : resultRows) { + if (row.getTaskId() != null) { + resultByTaskId.putIfAbsent(row.getTaskId(), row); + } + } + Map jobMap = taskFileJobService.findAssembleJobsByResultIds(moduleType, resultRows.stream() + .map(FileResultEntity::getId) + .filter(Objects::nonNull) + .toList()); + for (Long taskId : normalizedIds) { + FileTaskEntity task = taskMap.get(taskId); + if (task == null) { + vo.getMissingTaskIds().add(taskId); + continue; + } + AppearancePatentTaskDetailVo detail = new AppearancePatentTaskDetailVo(); + detail.setTask(toTaskItem(task)); + FileResultEntity resultRow = resultByTaskId.get(taskId); + if (resultRow != null) { + detail.getItems().add(toHistoryItem(resultRow, task, jobMap.get(resultRow.getId()))); + } + vo.getItems().add(detail); + } + return vo; + } + + public void saveFileBuildProgress(FileTaskEntity task, + TaskFileJobEntity job, + int total, + int completed, + String message) { + if (task == null || task.getId() == null || job == null || job.getId() == null) { + return; + } + int safeTotal = Math.max(1, total); + int safeCompleted = Math.max(0, Math.min(completed, safeTotal)); + TaskProgressSnapshotEntity existing = taskProgressSnapshotService.find(task.getId(), moduleType); + int displayPercent = calculateDisplayProgressPercent(safeCompleted, safeTotal, job, LocalDateTime.now()); + int previousDisplayPercent = calculateSnapshotDisplayPercent(existing, job); + if (previousDisplayPercent > displayPercent && safeCompleted < safeTotal) { + displayPercent = previousDisplayPercent; + } + // 终态必须带任务真实状态落库:save() 只对终态豁免 500ms 节流,收尾三连写(组装/上传/完成) + // 都在同一次调用里,若全按 RUNNING 写,只有第一条落地,满格「结果文件已生成」必被吞—— + // 看板就会永远停在 0/N 或 N-2/N(2026-10-04 生产实测)。对齐货源查询 isTerminalFileBuildProgress。 + boolean terminalProgress = safeCompleted >= safeTotal + && (STATUS_SUCCESS.equals(task.getStatus()) || STATUS_FAILED.equals(task.getStatus())); + if (terminalProgress) { + displayPercent = 100; + } + taskProgressSnapshotService.save( + task.getId(), + moduleType, + terminalProgress ? task.getStatus() : STATUS_RUNNING, + safeTotal, + safeCompleted, + 0, + job.getScopeKey(), + message, + Map.of("phase", "RESULT_FILE", "jobId", job.getId(), "displayPercent", displayPercent) + ); + } + + private int calculateDisplayProgressPercent(int current, + int total, + TaskFileJobEntity job, + LocalDateTime baseTime) { + if (total <= 0) { + return 0; + } + current = Math.max(0, Math.min(current, total)); + int percent = Math.max(1, Math.min(99, (int) Math.floor(current * 100.0 / total))); + if (job != null && STATUS_RUNNING.equals(job.getStatus())) { + long elapsedSeconds = baseTime == null ? 0 : Math.max(0, Duration.between(baseTime, LocalDateTime.now()).getSeconds()); + if (current <= 0) { + int firstRealProgressPercent = Math.max(1, Math.min(99, (int) Math.floor(100.0 / total))); + int waitingCap = Math.max(8, Math.min(35, firstRealProgressPercent - 1)); + percent = Math.max(percent, Math.min(waitingCap, 8 + (int) (elapsedSeconds / 6))); + } else if (current < total) { + percent = Math.max(percent, Math.min(92, percent + (int) (elapsedSeconds / 10))); + } + } + return percent; + } + + private int calculateSnapshotDisplayPercent(TaskProgressSnapshotEntity snapshot, TaskFileJobEntity job) { + if (snapshot == null) { + return 0; + } + int total = snapshot.getTotalCount() == null ? 0 : snapshot.getTotalCount(); + int current = snapshot.getSuccessCount() == null ? 0 : snapshot.getSuccessCount(); + int percent = total <= 0 ? 0 : calculateDisplayProgressPercent(current, total, job, snapshot.getUpdatedAt()); + return Math.max(percent, extractSnapshotDisplayPercent(snapshot)); + } + + private int extractSnapshotDisplayPercent(TaskProgressSnapshotEntity snapshot) { + if (snapshot == null || snapshot.getSnapshotJson() == null || snapshot.getSnapshotJson().isBlank()) { + return 0; + } + try { + JsonNode displayPercent = objectMapper.readTree(snapshot.getSnapshotJson()).path("displayPercent"); + if (!displayPercent.isNumber()) { + return 0; + } + return Math.max(0, Math.min(100, displayPercent.asInt())); + } catch (Exception ignored) { + return 0; + } + } + + private long countTask(Long userId, String status) { + Long count = fileTaskMapper.selectCount(new LambdaQueryWrapper() + .eq(FileTaskEntity::getModuleType, moduleType) + .eq(FileTaskEntity::getUserId, userId) + .eq(FileTaskEntity::getStatus, status)); + return count == null ? 0L : count; + } + + private AppearancePatentTaskItemVo toTaskItem(FileTaskEntity task) { + AppearancePatentTaskItemVo vo = new AppearancePatentTaskItemVo(); + vo.setId(task.getId()); + vo.setTaskNo(task.getTaskNo()); + vo.setStatus(task.getStatus()); + vo.setErrorMessage(task.getErrorMessage()); + vo.setCreatedAt(fmt(task.getCreatedAt())); + vo.setUpdatedAt(fmt(task.getUpdatedAt())); + vo.setFinishedAt(fmt(task.getFinishedAt())); + return vo; + } + + private AppearancePatentHistoryAssembler historyAssembler() { + return new AppearancePatentHistoryAssembler( + taskProgressSnapshotService, + this::calculateDisplayProgressPercent, + this::extractSnapshotDisplayPercent); + } + + private AppearancePatentHistoryItemVo toHistoryItem(FileResultEntity row, FileTaskEntity task, TaskFileJobEntity job) { + return historyAssembler().toHistoryItem(row, task, job); + } + + private int historyPriority(FileResultEntity row, FileTaskEntity task, TaskFileJobEntity job) { + return historyAssembler().historyPriority(row, task, job); + } + + private LocalDateTime historyActivityTime(FileResultEntity row, FileTaskEntity task, TaskFileJobEntity job) { + return historyAssembler().historyActivityTime(row, task, job); + } + + private String fmt(LocalDateTime t) { + return t == null ? null : t.toString(); + } +} diff --git a/backend-java/src/test/java/com/nanri/aiimage/testutil/SourceScanTest.java b/backend-java/src/test/java/com/nanri/aiimage/testutil/SourceScanTest.java index 101a8465b..8d3c967e1 100644 --- a/backend-java/src/test/java/com/nanri/aiimage/testutil/SourceScanTest.java +++ b/backend-java/src/test/java/com/nanri/aiimage/testutil/SourceScanTest.java @@ -266,13 +266,13 @@ class SourceScanTest { // ---------------------------------------------------------------- N6 moduleSources @Test - void moduleSources_appearancepatent返回34支含拆分后的support件() { + void moduleSources_appearancepatent返回35支含拆分后的support件() { List files = SourceScan.moduleSources("modules/appearancepatent"); assertThat(files) - .as("真实集成:对真仓目录求值。34 支=1 controller+1 client+1 service 主件+3 spi/cache+" - + "11 service/support+16 model(dto7/vo9),与 find 实测同号") - .hasSize(34); + .as("真实集成:对真仓目录求值。35 支=1 controller+1 client+1 service 主件+3 spi/cache+" + + "12 service/support+16 model(dto7/vo9),与 find 实测同号") + .hasSize(35); assertThat(files.stream().map(p -> p.toString().replace('\\', '/')).toList()) .as("support 目录里的既有件必须在面里——聚合入口存在的理由就是拆分后的新文件要自动被看到") .anyMatch(rel -> rel.endsWith("service/support/AppearancePatentRowNormalizer.java")); @@ -366,25 +366,26 @@ class SourceScanTest { } @Test - void recursive_包含service_support下的既有11件() { + void recursive_包含service_support下的既有12件() { List support = SourceScan.moduleSources("modules/appearancepatent").stream() .map(p -> p.toString().replace('\\', '/')) .filter(rel -> rel.contains("/service/support/")) .toList(); assertThat(support) - .as("真实集成:对真仓 modules/appearancepatent/service/support 求值,实测 11 支(3A 拆薄把归属谓词、陈旧扫描、结果打包、LLM 批管线、载荷读写、结果行读取抽成六枚 support 件,5→11)。" + .as("真实集成:对真仓 modules/appearancepatent/service/support 求值,实测 12 支(3A 拆薄把归属谓词、陈旧扫描、结果打包、LLM 批管线、载荷读写、结果行读取、进度视图抽成七枚 support 件,5→12)。" + "这一格就是聚合入口存在的理由——拆分出去的新文件必须自动进面") - .hasSize(11); + .hasSize(12); assertThat(support) - .as("3A 拆出去的六枚新件必须被逐枚点名扫到:只把分母数字改大,下一回拆件又只剩「数不对」" + .as("3A 拆出去的七枚新件必须被逐枚点名扫到:只把分母数字改大,下一回拆件又只剩「数不对」" + "一记红,证不了「扫得到」这件事") .anyMatch(rel -> rel.endsWith("service/support/AppearancePatentTaskOwnership.java")) .anyMatch(rel -> rel.endsWith("service/support/AppearancePatentStaleTaskScanner.java")) .anyMatch(rel -> rel.endsWith("service/support/AppearancePatentResultPackager.java")) .anyMatch(rel -> rel.endsWith("service/support/AppearancePatentLlmBatchPipeline.java")) .anyMatch(rel -> rel.endsWith("service/support/AppearancePatentPayloadSupport.java")) - .anyMatch(rel -> rel.endsWith("service/support/AppearancePatentResultRowReader.java")); + .anyMatch(rel -> rel.endsWith("service/support/AppearancePatentResultRowReader.java")) + .anyMatch(rel -> rel.endsWith("service/support/AppearancePatentProgressSupport.java")); } @Test