From 8f6913fb4a7ad857160406683c5ce741ab3f9c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E8=87=AA=E8=BE=BE?= <980324341@qq.com> Date: Fri, 23 Oct 2026 00:35:02 +0800 Subject: [PATCH] =?UTF-8?q?test(phase-4):=20similarasin=20=E5=BB=BA?= =?UTF-8?q?=E5=8D=95=E5=85=A5=E5=8F=A3=E9=BB=84=E9=87=91=E5=BF=AB=E7=85=A7?= =?UTF-8?q?=E2=80=94=E2=80=94=E8=A1=A5=E4=B8=8A=20Phase=203=20=E7=82=B9?= =?UTF-8?q?=E5=90=8D=E7=9A=84=E3=80=8C=E6=8A=84=E7=AE=A1=E7=BA=BF=E3=80=8D?= =?UTF-8?q?=E7=BC=BA=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 现有 SimilarAsinSnapshotTest 自建 parser、再抄一份归一/分组,parseAndCreateTask 一次没进、一行库没碰,对 Phase 4 要动的类似 ASIN 与 common 归位零保护。 本笔打真入口:单文件/双文件聚合两条 case,钉住建单校验、scope key、 解析载荷与指针落盘、头行+结果行+scope 三处落库形状与返回 VO 预览。 时钟、雪花 id 不进快照(id 桩固定,taskNo 只渲染前缀)。 --- .../SimilarAsinCreateTaskSnapshotTest.java | 403 ++++++++++++++++++ .../golden/create-task-snapshot.txt | 15 + 2 files changed, 418 insertions(+) create mode 100644 backend-java/src/test/java/com/nanri/aiimage/modules/similarasin/service/support/SimilarAsinCreateTaskSnapshotTest.java create mode 100644 backend-java/src/test/resources/similarasin/golden/create-task-snapshot.txt diff --git a/backend-java/src/test/java/com/nanri/aiimage/modules/similarasin/service/support/SimilarAsinCreateTaskSnapshotTest.java b/backend-java/src/test/java/com/nanri/aiimage/modules/similarasin/service/support/SimilarAsinCreateTaskSnapshotTest.java new file mode 100644 index 000000000..577dccfd3 --- /dev/null +++ b/backend-java/src/test/java/com/nanri/aiimage/modules/similarasin/service/support/SimilarAsinCreateTaskSnapshotTest.java @@ -0,0 +1,403 @@ +package com.nanri.aiimage.modules.similarasin.service.support; + +import com.baomidou.mybatisplus.core.MybatisConfiguration; +import com.baomidou.mybatisplus.core.metadata.TableInfoHelper; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.nanri.aiimage.config.InstanceMetadata; +import com.nanri.aiimage.config.SimilarAsinProperties; +import com.nanri.aiimage.modules.file.service.LocalFileStorageService; +import com.nanri.aiimage.modules.file.service.oss.OssStorageService; +import com.nanri.aiimage.modules.similarasin.mapper.SimilarAsinFilterConditionMapper; +import com.nanri.aiimage.modules.similarasin.model.dto.SimilarAsinParseRequest; +import com.nanri.aiimage.modules.similarasin.model.dto.SimilarAsinSourceFileDto; +import com.nanri.aiimage.modules.similarasin.model.vo.SimilarAsinParseVo; +import com.nanri.aiimage.modules.similarasin.model.vo.SimilarAsinParsedRowVo; +import com.nanri.aiimage.modules.similarasin.service.SimilarAsinImagePrefetchService; +import com.nanri.aiimage.modules.similarasin.service.SimilarAsinLlmService; +import com.nanri.aiimage.modules.similarasin.service.SimilarAsinTaskCacheService; +import com.nanri.aiimage.modules.similarasin.service.SimilarAsinTaskService; +import com.nanri.aiimage.modules.similarasin.util.SimilarAsinImageEmbedder; +import com.nanri.aiimage.modules.task.mapper.FileResultMapper; +import com.nanri.aiimage.modules.task.mapper.FileTaskMapper; +import com.nanri.aiimage.modules.task.mapper.TaskChunkMapper; +import com.nanri.aiimage.modules.task.mapper.TaskScopeStateMapper; +import com.nanri.aiimage.modules.task.model.entity.FileResultEntity; +import com.nanri.aiimage.modules.task.model.entity.FileTaskEntity; +import com.nanri.aiimage.modules.task.model.entity.TaskScopeStateEntity; +import com.nanri.aiimage.modules.task.service.TaskDistributedLockService; +import com.nanri.aiimage.modules.task.service.TaskFileJobService; +import com.nanri.aiimage.modules.task.service.TaskHeartbeatPositionService; +import com.nanri.aiimage.modules.task.service.TaskProgressSnapshotService; +import com.nanri.aiimage.modules.task.service.TransientPayloadStorageService; +import com.nanri.aiimage.modules.usersecret.service.UserApiSecretService; +import org.apache.ibatis.builder.MapperBuilderAssistant; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.transaction.PlatformTransactionManager; + +import java.io.File; +import java.io.FileOutputStream; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.lenient; + +/** + * 相似 ASIN 建单段的现网行为快照(重构蓝图 Phase 4 开工前置)。 + * + *

为什么必须补这一支:蓝图 Phase 3 收口时逐支验过「有 golden 是否等于有保护」, + * 结论是 {@code SimilarAsinSnapshotTest} **抄管线**——它自建 parser、再抄一份归一/分组, + * {@link SimilarAsinTaskService#parseAndCreateTask} 一次没进、一行库没碰,对服务侧改动零保护。 + * Phase 4 要按业务域搬动 similarasin 的 util 与 common 的 util,动它之前必须有一支 + * 吃真入口的护栏,否则「搬迁前后对撞相等」这句话没有可对撞的对象。 + * + *

快照打的是真 {@code parseAndCreateTask}:建单校验、多文件聚合 scope key、 + * 解析载荷与载荷指针落盘、头行/结果行/scope 三处落库形状,以及返回 VO 的预览字段。 + * 时钟、雪花 taskNo、任务 ID 都不进快照(ID 由桩固定,taskNo 只渲染前缀)。 + * + *

重新生成:{@code SHUFU_SNAPSHOT_WRITE=true mvn -o test -Dtest=SimilarAsinCreateTaskSnapshotTest} + */ +@ExtendWith(MockitoExtension.class) +class SimilarAsinCreateTaskSnapshotTest { + + private static final File GOLDEN_CREATE = + new File("src/test/resources/similarasin/golden/create-task-snapshot.txt"); + + /** 桩固定任务 ID:雪花号随时间和机器漂移,这里换成定值。 */ + private static final long FIXED_TASK_ID = 90001L; + private static final String FIXED_POINTER = "rustfs:task-parsed/similar-asin/90001/payload.json"; + private static final String[] HEADERS = {"id", "asin", "国家", "sku", "价格", "url", "标题"}; + + @Mock private LocalFileStorageService localFileStorageService; + @Mock private OssStorageService ossStorageService; + @Mock private com.nanri.aiimage.config.StorageProperties storageProperties; + @Mock private FileTaskMapper fileTaskMapper; + @Mock private FileResultMapper fileResultMapper; + @Mock private TaskScopeStateMapper taskScopeStateMapper; + @Mock private TaskChunkMapper taskChunkMapper; + @Mock private SimilarAsinFilterConditionMapper filterConditionMapper; + @Spy private ObjectMapper objectMapper = new ObjectMapper(); + @Mock private SimilarAsinLlmService similarAsinLlmService; + @Mock private SimilarAsinTaskCacheService taskCacheService; + @Mock private SimilarAsinProperties properties; + @Mock private TaskFileJobService taskFileJobService; + @Mock private TaskDistributedLockService taskDistributedLockService; + @Mock private TaskProgressSnapshotService taskProgressSnapshotService; + @Mock private TaskHeartbeatPositionService taskHeartbeatPositionService; + @Mock private TransientPayloadStorageService transientPayloadStorageService; + @Mock private PlatformTransactionManager transactionManager; + @Mock private com.nanri.aiimage.common.service.DistributedJobLockService distributedJobLockService; + @Mock private InstanceMetadata instanceMetadata; + @Mock private SimilarAsinImageEmbedder imageEmbedder; + @Mock private SimilarAsinImagePrefetchService imagePrefetchService; + @Mock private UserApiSecretService userApiSecretService; + + @InjectMocks private SimilarAsinTaskService service; + + @BeforeAll + static void initializeMybatisMetadata() { + MapperBuilderAssistant assistant = new MapperBuilderAssistant(new MybatisConfiguration(), ""); + TableInfoHelper.initTableInfo(assistant, FileTaskEntity.class); + } + + @BeforeEach + void setUp() { + lenient().when(properties.isBoundedResultAssemblyEnabled()).thenReturn(true); + lenient().when(properties.getImageCacheMaxBytes()).thenReturn(256L * 1024L * 1024L); + lenient().when(properties.getResultFileTimeoutMinutes()).thenReturn(90); + lenient().when(properties.getParseResponsePreviewLimit()).thenReturn(100); + lenient().when(properties.getMaxSourceFileBytes()).thenReturn(50L * 1024L * 1024L); + lenient().when(properties.getMaxParseRows()).thenReturn(50000); + lenient().when(properties.getMaxFieldLength()).thenReturn(2000); + lenient().when(transientPayloadStorageService.storeParsedPayloadFast( + eq(SimilarAsinTaskService.MODULE_TYPE), anyLong(), anyString(), anyString(), anyBoolean())) + .thenReturn(FIXED_POINTER); + lenient().doAnswer(invocation -> { + FileTaskEntity task = invocation.getArgument(0); + task.setId(FIXED_TASK_ID); + return 1; + }).when(fileTaskMapper).insert(any(FileTaskEntity.class)); + lenient().when(fileTaskMapper.updateById(any(FileTaskEntity.class))).thenReturn(1); + lenient().when(fileResultMapper.insert(any(FileResultEntity.class))).thenReturn(1); + lenient().when(taskScopeStateMapper.insert(any(TaskScopeStateEntity.class))).thenReturn(1); + } + + @AfterEach + void shutdown() { + service.shutdownAssembleExecutor(); + } + + // ------------------------------------------------------------------ + // 落库捕获 + // ------------------------------------------------------------------ + + private static final class Captured { + private final List events = new ArrayList<>(); + private String storedPayload; + private String storedScopeHash; + } + + private Captured capturePersistedEvents() { + Captured captured = new Captured(); + doAnswer(invocation -> { + FileTaskEntity task = invocation.getArgument(0); + task.setId(FIXED_TASK_ID); + captured.events.add("task.insert: " + renderTaskInsert(task)); + return 1; + }).when(fileTaskMapper).insert(any(FileTaskEntity.class)); + doAnswer(invocation -> { + captured.events.add("task.update: " + renderTaskUpdate(invocation.getArgument(0))); + return 1; + }).when(fileTaskMapper).updateById(any(FileTaskEntity.class)); + doAnswer(invocation -> { + captured.events.add("result.insert: " + renderResultInsert(invocation.getArgument(0))); + return 1; + }).when(fileResultMapper).insert(any(FileResultEntity.class)); + doAnswer(invocation -> { + captured.events.add("scope.insert: " + renderScopeInsert(invocation.getArgument(0))); + return 1; + }).when(taskScopeStateMapper).insert(any(TaskScopeStateEntity.class)); + doAnswer(invocation -> { + captured.storedScopeHash = invocation.getArgument(2, String.class); + captured.storedPayload = invocation.getArgument(3, String.class); + captured.events.add("payload.store: moduleType=" + invocation.getArgument(0, String.class) + + " taskId=" + invocation.getArgument(1, Long.class) + + " scopeHash=" + captured.storedScopeHash + + " payload=" + captured.storedPayload); + return FIXED_POINTER; + }).when(transientPayloadStorageService).storeParsedPayloadFast( + anyString(), anyLong(), anyString(), anyString(), anyBoolean()); + return captured; + } + + private static String renderTaskInsert(FileTaskEntity task) { + return "id=" + task.getId() + + " taskNoPrefix=" + taskNoPrefix(task.getTaskNo()) + + " moduleType=" + dash(task.getModuleType()) + + " taskMode=" + dash(task.getTaskMode()) + + " status=" + dash(task.getStatus()) + + " sourceFileCount=" + task.getSourceFileCount() + + " ok=" + task.getSuccessFileCount() + + " fail=" + task.getFailedFileCount() + + " userId=" + dash(task.getUserId()) + + " createdBy=" + dash(task.getCreatedBy()) + + " deviceId=" + dash(task.getDeviceId()) + + " requestJsonPresent=" + (task.getRequestJson() != null) + + " resultJson=" + dash(task.getResultJson()); + } + + private static String renderTaskUpdate(FileTaskEntity task) { + return "id=" + task.getId() + + " moduleType=" + dash(task.getModuleType()) + + " status=" + dash(task.getStatus()) + + " resultJson=" + dash(task.getResultJson()); + } + + private static String renderResultInsert(FileResultEntity row) { + return "taskId=" + dash(row.getTaskId()) + + " moduleType=" + dash(row.getModuleType()) + + " sourceFilename=" + dash(row.getSourceFilename()) + + " sourceFileUrl=" + dash(row.getSourceFileUrl()) + + " rowCount=" + dash(row.getRowCount()) + + " userId=" + dash(row.getUserId()) + + " success=" + dash(row.getSuccess()); + } + + private static String renderScopeInsert(TaskScopeStateEntity scope) { + return "taskId=" + dash(scope.getTaskId()) + + " moduleType=" + dash(scope.getModuleType()) + + " scopeKey=" + dash(scope.getScopeKey()) + + " scopeHash=" + dash(scope.getScopeHash()) + + " parsedPayloadJson=" + dash(scope.getParsedPayloadJson()) + + " stateJson=" + dash(scope.getStateJson()) + + " chunkTotal=" + dash(scope.getChunkTotal()) + + " receivedChunkCount=" + dash(scope.getReceivedChunkCount()) + + " completed=" + dash(scope.getCompleted()); + } + + private static String renderVo(SimilarAsinParseVo vo) { + List asins = new ArrayList<>(); + for (SimilarAsinParsedRowVo item : vo.getItems()) { + asins.add(item.getAsin()); + } + List groupKeys = new ArrayList<>(); + vo.getGroups().forEach(group -> groupKeys.add(group.getGroupKey() + "#" + group.getItemCount())); + return "taskId=" + vo.getTaskId() + + " sourceFilename=" + dash(vo.getSourceFilename()) + + " sourceFileCount=" + vo.getSourceFileCount() + + " totalRows=" + vo.getTotalRows() + + " acceptedRows=" + vo.getAcceptedRows() + + " droppedRows=" + vo.getDroppedRows() + + " groupCount=" + vo.getGroupCount() + + " aiPrompt=" + dash(vo.getAiPrompt()) + + " imgSwitch=" + vo.getImgSwitch() + + " categorySwitch=" + vo.getCategorySwitch() + + " itemAsins=" + asins + + " groups=" + groupKeys; + } + + private static String taskNoPrefix(String taskNo) { + if (taskNo == null) { + return "-"; + } + int index = taskNo.lastIndexOf('-'); + return index < 0 ? taskNo : taskNo.substring(0, index); + } + + private static String dash(Object value) { + String text = value == null ? "" : String.valueOf(value); + return text.isBlank() ? "-" : text; + } + + // ------------------------------------------------------------------ + // 夹具 + // ------------------------------------------------------------------ + + private static File workbook(List rows) throws Exception { + File file = Files.createTempFile("similar-asin-create-snapshot-", ".xlsx").toFile(); + try (XSSFWorkbook wb = new XSSFWorkbook(); FileOutputStream out = new FileOutputStream(file)) { + var sheet = wb.createSheet("Sheet1"); + Row header = sheet.createRow(0); + for (int i = 0; i < HEADERS.length; i++) { + header.createCell(i).setCellValue(HEADERS[i]); + } + for (int r = 0; r < rows.size(); r++) { + Row row = sheet.createRow(r + 1); + String[] data = rows.get(r); + for (int c = 0; c < data.length; c++) { + row.createCell(c).setCellValue(data[c]); + } + } + wb.write(out); + } + return file; + } + + private static SimilarAsinSourceFileDto source(String fileKey, String filename) { + SimilarAsinSourceFileDto dto = new SimilarAsinSourceFileDto(); + dto.setFileKey(fileKey); + dto.setOriginalFilename(filename); + return dto; + } + + private static SimilarAsinParseRequest request(List files) { + SimilarAsinParseRequest request = new SimilarAsinParseRequest(); + request.setUserId(9L); + request.setFiles(files); + request.setAiPrompt(" "); + request.setApiKey("unit-test-key"); + request.setImgSwitch(Boolean.FALSE); + request.setCategorySwitch(Boolean.FALSE); + return request; + } + + private String runSingleFile() throws Exception { + Captured captured = capturePersistedEvents(); + File file = workbook(List.of( + new String[]{"2_1", "B01A", "US", "SKU-1", "19.90", "http://img/a.jpg", "title a"}, + new String[]{"2_2", "B01B", "DE", "SKU-2", "29.90", "http://img/b.jpg", "title b"}, + new String[]{"2_3", "B01C", "FR", "SKU-3", "39.90", "http://img/c.jpg", "title c"}, + new String[]{"3", "B01-ABC", "GB", "SKU-4", "9.90", "http://img/d.jpg", "title d"}, + new String[]{"4", "B01E", "IT", "SKU-5", "49.90", "http://img/e.jpg", "title e"})); + lenient().when(localFileStorageService.findLocalSourceFile("uploads/20261023/one.xlsx")).thenReturn(file); + SimilarAsinParseVo vo = service.parseAndCreateTask( + request(List.of(source("uploads/20261023/one.xlsx", "one.xlsx"))), "snapshot-device"); + return renderCase("single-file", captured, vo); + } + + private String runTwoFiles() throws Exception { + Captured captured = capturePersistedEvents(); + File first = workbook(List.of( + new String[]{"1", "B02A", "US", "SKU-A", "11.00", "http://img/x.jpg", "title x"})); + File second = workbook(List.of( + new String[]{"2", "B02B", "DE", "SKU-B", "12.00", "http://img/y.jpg", "title y"})); + lenient().when(localFileStorageService.findLocalSourceFile("uploads/20261023/a.xlsx")).thenReturn(first); + lenient().when(localFileStorageService.findLocalSourceFile("uploads/20261023/b.xlsx")).thenReturn(second); + SimilarAsinParseVo vo = service.parseAndCreateTask(request(List.of( + source("uploads/20261023/a.xlsx", "a.xlsx"), + source("uploads/20261023/b.xlsx", "b.xlsx"))), "snapshot-device"); + return renderCase("two-files", captured, vo); + } + + private static String renderCase(String name, Captured captured, SimilarAsinParseVo vo) { + StringBuilder sb = new StringBuilder(); + sb.append("== case: ").append(name).append('\n'); + for (String event : captured.events) { + sb.append(event).append('\n'); + } + sb.append("vo: ").append(renderVo(vo)).append('\n'); + return sb.toString(); + } + + private String runAll() throws Exception { + StringBuilder sb = new StringBuilder(); + sb.append(runSingleFile()).append('\n'); + sb.append(runTwoFiles()); + return sb.toString(); + } + + private static String read(File file) throws Exception { + return Files.readString(file.toPath(), StandardCharsets.UTF_8).replace("\r\n", "\n"); + } + + // ------------------------------------------------------------------ + // 用例 + // ------------------------------------------------------------------ + + @Test + void create_task_snapshot_matches_golden() throws Exception { + assertEquals(read(GOLDEN_CREATE), runAll(), "建单落库流水与 golden 一致"); + } + + @Test + void create_task_snapshot_is_reproducible() throws Exception { + assertEquals(runAll(), runAll(), "同一夹具跑两次流水一致(时钟与雪花 id 不得进快照)"); + } + + @Test + void create_task_snapshot_golden_is_committed() { + assertTrue(GOLDEN_CREATE.isFile(), "golden 文件必须存在并入库: " + GOLDEN_CREATE.getAbsolutePath()); + assertTrue(GOLDEN_CREATE.length() > 0, "golden 文件非空"); + } + + @Test + void create_task_snapshot_tamper_is_detected() throws Exception { + String original = read(GOLDEN_CREATE); + assertTrue(original.contains("status=PENDING"), "golden 必须钉住建单初始状态"); + try { + Files.writeString(GOLDEN_CREATE.toPath(), original + "\n# tampered", StandardCharsets.UTF_8); + assertTrue(!read(GOLDEN_CREATE).equals(runAll()), "篡改 golden 后断言应失败"); + } finally { + Files.writeString(GOLDEN_CREATE.toPath(), original, StandardCharsets.UTF_8); + } + assertEquals(original, read(GOLDEN_CREATE), "恢复原始 golden"); + } + + /** 只在显式点名时写 golden:默认跑测试永远不许改是非源。 */ + @Test + @EnabledIfEnvironmentVariable(named = "SHUFU_SNAPSHOT_WRITE", matches = "true") + void write_golden_on_demand() throws Exception { + Files.createDirectories(GOLDEN_CREATE.getParentFile().toPath()); + Files.writeString(GOLDEN_CREATE.toPath(), runAll(), StandardCharsets.UTF_8); + } +} diff --git a/backend-java/src/test/resources/similarasin/golden/create-task-snapshot.txt b/backend-java/src/test/resources/similarasin/golden/create-task-snapshot.txt new file mode 100644 index 000000000..161672f1c --- /dev/null +++ b/backend-java/src/test/resources/similarasin/golden/create-task-snapshot.txt @@ -0,0 +1,15 @@ +== case: single-file +task.insert: id=90001 taskNoPrefix=SIMILAR_ASIN moduleType=SIMILAR_ASIN taskMode=PYTHON_QUEUE status=PENDING sourceFileCount=1 ok=0 fail=0 userId=9 createdBy=user:9 deviceId=snapshot-device requestJsonPresent=true resultJson={} +payload.store: moduleType=SIMILAR_ASIN taskId=90001 scopeHash=2d98526367320243445d84e4e3cb95b4003f12d3228eefd111cbfe494fb6fa38 payload={"aiPrompt":"","apiKey":"unit-test-key","imgSwitch":false,"categorySwitch":false,"sourceFiles":[{"fileKey":"uploads/20261023/one.xlsx","originalFilename":"one.xlsx","relativePath":null}],"headers":["id","asin","国家","sku","价格","url","标题"],"items":[{"sourceFileKey":"uploads/20261023/one.xlsx","sourceFilename":"one.xlsx","rowIndex":2,"sourceId":"2_1","displayId":"2_1","rowToken":"uploads/20261023/one.xlsx::row::2","groupKey":"uploads/20261023/one.xlsx::2@2","asin":"B01A","country":"US","price":"19.90","sku":"SKU-1","url":"http://img/a.jpg","title":"title a","values":{"id":"2_1","asin":"B01A","国家":"US","sku":"SKU-1","价格":"19.90","url":"http://img/a.jpg","标题":"title a"}},{"sourceFileKey":"uploads/20261023/one.xlsx","sourceFilename":"one.xlsx","rowIndex":3,"sourceId":"2_2","displayId":"2_2","rowToken":"uploads/20261023/one.xlsx::row::3","groupKey":"uploads/20261023/one.xlsx::2@2","asin":"B01B","country":"DE","price":"29.90","sku":"SKU-2","url":"http://img/b.jpg","title":"title b","values":{"id":"2_2","asin":"B01B","国家":"DE","sku":"SKU-2","价格":"29.90","url":"http://img/b.jpg","标题":"title b"}},{"sourceFileKey":"uploads/20261023/one.xlsx","sourceFilename":"one.xlsx","rowIndex":4,"sourceId":"2_3","displayId":"2_3","rowToken":"uploads/20261023/one.xlsx::row::4","groupKey":"uploads/20261023/one.xlsx::2@2","asin":"B01C","country":"FR","price":"39.90","sku":"SKU-3","url":"http://img/c.jpg","title":"title c","values":{"id":"2_3","asin":"B01C","国家":"FR","sku":"SKU-3","价格":"39.90","url":"http://img/c.jpg","标题":"title c"}},{"sourceFileKey":"uploads/20261023/one.xlsx","sourceFilename":"one.xlsx","rowIndex":5,"sourceId":"3","displayId":"3","rowToken":"uploads/20261023/one.xlsx::row::5","groupKey":"uploads/20261023/one.xlsx::3@5","asin":"B01-ABC","country":"GB","price":"9.90","sku":"SKU-4","url":"http://img/d.jpg","title":"title d","values":{"id":"3","asin":"B01-ABC","国家":"GB","sku":"SKU-4","价格":"9.90","url":"http://img/d.jpg","标题":"title d"}},{"sourceFileKey":"uploads/20261023/one.xlsx","sourceFilename":"one.xlsx","rowIndex":6,"sourceId":"4","displayId":"4","rowToken":"uploads/20261023/one.xlsx::row::6","groupKey":"uploads/20261023/one.xlsx::4@6","asin":"B01E","country":"IT","price":"49.90","sku":"SKU-5","url":"http://img/e.jpg","title":"title e","values":{"id":"4","asin":"B01E","国家":"IT","sku":"SKU-5","价格":"49.90","url":"http://img/e.jpg","标题":"title e"}}],"groups":[{"sourceFileKey":"uploads/20261023/one.xlsx","sourceFilename":"one.xlsx","groupKey":"uploads/20261023/one.xlsx::2@2","baseId":"2","displayId":"2_1","itemCount":3,"startIndex":0,"endIndex":3,"items":[{"sourceFileKey":"uploads/20261023/one.xlsx","sourceFilename":"one.xlsx","rowIndex":2,"sourceId":"2_1","displayId":"2_1","rowToken":"uploads/20261023/one.xlsx::row::2","groupKey":"uploads/20261023/one.xlsx::2@2","asin":"B01A","country":"US","price":"19.90","sku":"SKU-1","url":"http://img/a.jpg","title":"title a","values":{"id":"2_1","asin":"B01A","国家":"US","sku":"SKU-1","价格":"19.90","url":"http://img/a.jpg","标题":"title a"}},{"sourceFileKey":"uploads/20261023/one.xlsx","sourceFilename":"one.xlsx","rowIndex":3,"sourceId":"2_2","displayId":"2_2","rowToken":"uploads/20261023/one.xlsx::row::3","groupKey":"uploads/20261023/one.xlsx::2@2","asin":"B01B","country":"DE","price":"29.90","sku":"SKU-2","url":"http://img/b.jpg","title":"title b","values":{"id":"2_2","asin":"B01B","国家":"DE","sku":"SKU-2","价格":"29.90","url":"http://img/b.jpg","标题":"title b"}},{"sourceFileKey":"uploads/20261023/one.xlsx","sourceFilename":"one.xlsx","rowIndex":4,"sourceId":"2_3","displayId":"2_3","rowToken":"uploads/20261023/one.xlsx::row::4","groupKey":"uploads/20261023/one.xlsx::2@2","asin":"B01C","country":"FR","price":"39.90","sku":"SKU-3","url":"http://img/c.jpg","title":"title c","values":{"id":"2_3","asin":"B01C","国家":"FR","sku":"SKU-3","价格":"39.90","url":"http://img/c.jpg","标题":"title c"}}]},{"sourceFileKey":"uploads/20261023/one.xlsx","sourceFilename":"one.xlsx","groupKey":"uploads/20261023/one.xlsx::3@5","baseId":"3","displayId":"3","itemCount":1,"startIndex":3,"endIndex":4,"items":[{"sourceFileKey":"uploads/20261023/one.xlsx","sourceFilename":"one.xlsx","rowIndex":5,"sourceId":"3","displayId":"3","rowToken":"uploads/20261023/one.xlsx::row::5","groupKey":"uploads/20261023/one.xlsx::3@5","asin":"B01-ABC","country":"GB","price":"9.90","sku":"SKU-4","url":"http://img/d.jpg","title":"title d","values":{"id":"3","asin":"B01-ABC","国家":"GB","sku":"SKU-4","价格":"9.90","url":"http://img/d.jpg","标题":"title d"}}]},{"sourceFileKey":"uploads/20261023/one.xlsx","sourceFilename":"one.xlsx","groupKey":"uploads/20261023/one.xlsx::4@6","baseId":"4","displayId":"4","itemCount":1,"startIndex":4,"endIndex":5,"items":[{"sourceFileKey":"uploads/20261023/one.xlsx","sourceFilename":"one.xlsx","rowIndex":6,"sourceId":"4","displayId":"4","rowToken":"uploads/20261023/one.xlsx::row::6","groupKey":"uploads/20261023/one.xlsx::4@6","asin":"B01E","country":"IT","price":"49.90","sku":"SKU-5","url":"http://img/e.jpg","title":"title e","values":{"id":"4","asin":"B01E","国家":"IT","sku":"SKU-5","价格":"49.90","url":"http://img/e.jpg","标题":"title e"}}]}]} +task.update: id=90001 moduleType=SIMILAR_ASIN status=PENDING resultJson={"aiPrompt":"","apiKey":"unit-test-key","imgSwitch":false,"categorySwitch":false,"sourceFileKeys":["uploads/20261023/one.xlsx"],"parsedPayloadRef":"rustfs:task-parsed/similar-asin/90001/payload.json","ownerInstanceId":"unknown-instance"} +result.insert: taskId=90001 moduleType=SIMILAR_ASIN sourceFilename=one.xlsx sourceFileUrl=uploads/20261023/one.xlsx rowCount=5 userId=9 success=- +scope.insert: taskId=90001 moduleType=SIMILAR_ASIN scopeKey=uploads/20261023/one.xlsx scopeHash=2d98526367320243445d84e4e3cb95b4003f12d3228eefd111cbfe494fb6fa38 parsedPayloadJson="rustfs:task-parsed/similar-asin/90001/payload.json" stateJson={"phase":"PARSED"} chunkTotal=0 receivedChunkCount=0 completed=0 +vo: taskId=90001 sourceFilename=one.xlsx sourceFileCount=1 totalRows=5 acceptedRows=5 droppedRows=0 groupCount=3 aiPrompt=- imgSwitch=false categorySwitch=false itemAsins=[B01A, B01B, B01C, B01-ABC, B01E] groups=[uploads/20261023/one.xlsx::2@2#3, uploads/20261023/one.xlsx::3@5#1, uploads/20261023/one.xlsx::4@6#1] + +== case: two-files +task.insert: id=90001 taskNoPrefix=SIMILAR_ASIN moduleType=SIMILAR_ASIN taskMode=PYTHON_QUEUE status=PENDING sourceFileCount=2 ok=0 fail=0 userId=9 createdBy=user:9 deviceId=snapshot-device requestJsonPresent=true resultJson={} +payload.store: moduleType=SIMILAR_ASIN taskId=90001 scopeHash=73210c3d2b39e575f665bbc4fc84a8c6daffa6b79e29a1133ebe559f0d6bfa5d payload={"aiPrompt":"","apiKey":"unit-test-key","imgSwitch":false,"categorySwitch":false,"sourceFiles":[{"fileKey":"uploads/20261023/a.xlsx","originalFilename":"a.xlsx","relativePath":null},{"fileKey":"uploads/20261023/b.xlsx","originalFilename":"b.xlsx","relativePath":null}],"headers":["id","asin","国家","sku","价格","url","标题"],"items":[{"sourceFileKey":"uploads/20261023/a.xlsx","sourceFilename":"a.xlsx","rowIndex":2,"sourceId":"1","displayId":"1","rowToken":"uploads/20261023/a.xlsx::row::2","groupKey":"uploads/20261023/a.xlsx::1@2","asin":"B02A","country":"US","price":"11.00","sku":"SKU-A","url":"http://img/x.jpg","title":"title x","values":{"id":"1","asin":"B02A","国家":"US","sku":"SKU-A","价格":"11.00","url":"http://img/x.jpg","标题":"title x"}},{"sourceFileKey":"uploads/20261023/b.xlsx","sourceFilename":"b.xlsx","rowIndex":2,"sourceId":"2","displayId":"2","rowToken":"uploads/20261023/b.xlsx::row::2","groupKey":"uploads/20261023/b.xlsx::2@2","asin":"B02B","country":"DE","price":"12.00","sku":"SKU-B","url":"http://img/y.jpg","title":"title y","values":{"id":"2","asin":"B02B","国家":"DE","sku":"SKU-B","价格":"12.00","url":"http://img/y.jpg","标题":"title y"}}],"groups":[{"sourceFileKey":"uploads/20261023/a.xlsx","sourceFilename":"a.xlsx","groupKey":"uploads/20261023/a.xlsx::1@2","baseId":"1","displayId":"1","itemCount":1,"startIndex":0,"endIndex":1,"items":[{"sourceFileKey":"uploads/20261023/a.xlsx","sourceFilename":"a.xlsx","rowIndex":2,"sourceId":"1","displayId":"1","rowToken":"uploads/20261023/a.xlsx::row::2","groupKey":"uploads/20261023/a.xlsx::1@2","asin":"B02A","country":"US","price":"11.00","sku":"SKU-A","url":"http://img/x.jpg","title":"title x","values":{"id":"1","asin":"B02A","国家":"US","sku":"SKU-A","价格":"11.00","url":"http://img/x.jpg","标题":"title x"}}]},{"sourceFileKey":"uploads/20261023/b.xlsx","sourceFilename":"b.xlsx","groupKey":"uploads/20261023/b.xlsx::2@2","baseId":"2","displayId":"2","itemCount":1,"startIndex":1,"endIndex":2,"items":[{"sourceFileKey":"uploads/20261023/b.xlsx","sourceFilename":"b.xlsx","rowIndex":2,"sourceId":"2","displayId":"2","rowToken":"uploads/20261023/b.xlsx::row::2","groupKey":"uploads/20261023/b.xlsx::2@2","asin":"B02B","country":"DE","price":"12.00","sku":"SKU-B","url":"http://img/y.jpg","title":"title y","values":{"id":"2","asin":"B02B","国家":"DE","sku":"SKU-B","价格":"12.00","url":"http://img/y.jpg","标题":"title y"}}]}]} +task.update: id=90001 moduleType=SIMILAR_ASIN status=PENDING resultJson={"aiPrompt":"","apiKey":"unit-test-key","imgSwitch":false,"categorySwitch":false,"sourceFileKeys":["uploads/20261023/a.xlsx","uploads/20261023/b.xlsx"],"parsedPayloadRef":"rustfs:task-parsed/similar-asin/90001/payload.json","ownerInstanceId":"unknown-instance"} +result.insert: taskId=90001 moduleType=SIMILAR_ASIN sourceFilename=a.xlsx 等 2 个文件 sourceFileUrl=aggregate:30ceb87d45d73f0802326a4f55a481ba3fd8dbccd0ecccf1bbfd7fbcfffcbf8d rowCount=2 userId=9 success=- +scope.insert: taskId=90001 moduleType=SIMILAR_ASIN scopeKey=aggregate:30ceb87d45d73f0802326a4f55a481ba3fd8dbccd0ecccf1bbfd7fbcfffcbf8d scopeHash=73210c3d2b39e575f665bbc4fc84a8c6daffa6b79e29a1133ebe559f0d6bfa5d parsedPayloadJson="rustfs:task-parsed/similar-asin/90001/payload.json" stateJson={"phase":"PARSED"} chunkTotal=0 receivedChunkCount=0 completed=0 +vo: taskId=90001 sourceFilename=a.xlsx 等 2 个文件 sourceFileCount=2 totalRows=2 acceptedRows=2 droppedRows=0 groupCount=2 aiPrompt=- imgSwitch=false categorySwitch=false itemAsins=[B02A, B02B] groups=[uploads/20261023/a.xlsx::1@2#1, uploads/20261023/b.xlsx::2@2#1]