From b231a67dd7b10bfe0dff515eaa6c1629b44d45cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E8=87=AA=E8=BE=BE?= <980324341@qq.com> Date: Thu, 5 Nov 2026 01:34:00 +0800 Subject: [PATCH] =?UTF-8?q?fix(b82-01):=20=E4=BB=BB=E5=8A=A1=E8=A1=8C?= =?UTF-8?q?=E9=83=A8=E5=88=86=E5=AD=97=E6=AE=B5=E8=90=BD=E5=BA=93=E6=94=B9?= =?UTF-8?q?=20update(null,=20wrapper)=EF=BC=8C13=20=E5=A4=84=E9=83=A8?= =?UTF-8?q?=E5=88=86=E5=AE=9E=E4=BD=93=20updateById=20=E4=B8=8D=E5=86=8D?= =?UTF-8?q?=E6=8A=B9=20failure=5Fcategory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit B82-01:failureCategory 标 FieldStrategy.ALWAYS(V186 让清错误分支的 null 真落库)的代价是任何 new 出来的部分实体走 updateById 都把该列无条件抹回 NULL。现网只读探针(2026-11-05,SSH 主机B)实证列全表零非空:近 7 天 194 条 FAILED 全空,9 条文案命中 CREDENTIAL/DELIVERY markers 的行列也是空。本笔只动调用点一边;注解半边由 TaskFailureCategoryMigrationV186Test 的 ALWAYS 钉守住。 写点转换(13 处 updateById,12 个条目,DedupeRunService 收尾一处两调用):convert/split/productrisk/queryasin/withdraw/similarasin/appearance-patent/pricetrack 显式两到四列;shopdatacrawl 快照+归属三列;deletebrand 终态分支 error_message 与分类同笔配对 TaskFailureLedger.categoryOf(护栏格1连线语义);dedupe FAILED 收尾同笔配对;similarasin 归属绑定(rustfs 回退)。Explore 初判 12 处漏了 withdraw/pricetrack 族——逐支验明全是 loadTaskForExecution 全实体(selectById/缓存血统),非抹列点,留痕不扩 scope;DELIVERY/CREDENTIAL 两族终态写点接 ledger 属后续批,不在本笔。 护栏 TaskFailureCategoryGuardrailTest 5→7:① ledger 对六组 markers 各出一条值非空断言(配对写恒 NULL 也绿那半堵上);② .updateById( 总量棘轮 173→160(本仓 ALWAYS 字段还有 PriceTrackLoopRun/ShopKey/SkipPriceAsin 四实体,棘轮按全量钉,新增写法必须登记复审)。测试适配:共享探针 UpdateWrapperProbe(getSqlSet 列序+MPGENVAL 精确取值+列名 snake 归一——单测 JVM 的 Lambda 列缓存可能被自动初始化成驼峰,不归一则快照取决于测试类执行顺序);4 份 golden 重钉 11 行(窄写面 status 不在写面渲染成 -);ShopDataCrawlOwnerColumnTest 假 DB 从只会 CAS 升级为按 SQL 语义应用 SET 段(whereEq 校验 id/status eq);SimilarAsinTaskServiceSubmitTest 归属断言改为录 SET 段断言零 owner_instance_id(touchJavaSideTaskActivity 本就合法走 update(null,wrapper),verify(never) 会误杀)。 门禁:受影响七支定向 50/0 失败/0 错误/3 skipped(既有 skip,零新增);mvn -o test 整量 5321/0 失败/0 错误/19 skipped BUILD SUCCESS(5:01,skip 数与在册基线逐字相同);后端无 lint/格式器如实跳过;未动 application.yml/路由/Flyway/env,门禁5不适用。 --- .../AppearancePatentParsePipeline.java | 7 +- .../convert/service/ConvertRunService.java | 10 +- .../dedupe/service/DedupeRunService.java | 21 ++- .../service/DeleteBrandRunService.java | 17 +- .../service/PriceTrackTaskService.java | 8 +- .../service/ProductRiskTaskService.java | 8 +- .../service/QueryAsinTaskService.java | 6 +- .../service/ShopDataCrawlTaskService.java | 7 +- .../service/SimilarAsinTaskService.java | 6 +- .../SimilarAsinTaskOwnershipSupport.java | 12 +- .../split/service/SplitRunService.java | 10 +- .../withdraw/service/WithdrawTaskService.java | 6 +- ...ppearancePatentCreateTaskSnapshotTest.java | 20 ++- .../support/DeleteBrandSnapshotTest.java | 12 +- .../support/PriceTrackSnapshotTest.java | 12 +- .../service/ShopDataCrawlOwnerColumnTest.java | 29 ++-- .../ShopDataCrawlCreateTaskSnapshotTest.java | 12 +- .../SimilarAsinTaskServiceSubmitTest.java | 17 +- .../SimilarAsinCreateTaskSnapshotTest.java | 11 +- .../TaskFailureCategoryGuardrailTest.java | 76 +++++++++ .../aiimage/testutil/UpdateWrapperProbe.java | 156 ++++++++++++++++++ .../deletebrand/golden/run-snapshot.txt | 4 +- .../golden/create-task-snapshot.txt | 12 +- .../golden/create-task-snapshot.txt | 4 +- .../golden/create-task-snapshot.txt | 4 +- 25 files changed, 429 insertions(+), 58 deletions(-) create mode 100644 backend-java/src/test/java/com/nanri/aiimage/testutil/UpdateWrapperProbe.java diff --git a/backend-java/src/main/java/com/nanri/aiimage/modules/appearancepatent/service/support/AppearancePatentParsePipeline.java b/backend-java/src/main/java/com/nanri/aiimage/modules/appearancepatent/service/support/AppearancePatentParsePipeline.java index a79c8d3c9..239262edb 100644 --- a/backend-java/src/main/java/com/nanri/aiimage/modules/appearancepatent/service/support/AppearancePatentParsePipeline.java +++ b/backend-java/src/main/java/com/nanri/aiimage/modules/appearancepatent/service/support/AppearancePatentParsePipeline.java @@ -1,6 +1,7 @@ package com.nanri.aiimage.modules.appearancepatent.service.support; import cn.hutool.crypto.digest.DigestUtil; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.nanri.aiimage.common.exception.BusinessException; import com.nanri.aiimage.common.task.FailedStatusRowFilter; import com.nanri.aiimage.config.AppearancePatentProperties; @@ -212,7 +213,11 @@ public final class AppearancePatentParsePipeline { long payloadStoredAt = System.nanoTime(); task.setResultJson(payloadSupport.get().buildTaskResultJson(request.getAiPrompt(), request.getApiKey(), sourceFiles, parsedPayloadPointer)); task.setUpdatedAt(LocalDateTime.now()); - fileTaskMapper.updateById(task); + // B82-01:显式 wrapper 只写载荷与心跳两列——updateById 会把 ALWAYS 的 failure_category 抹回 NULL + fileTaskMapper.update(null, new LambdaUpdateWrapper() + .eq(FileTaskEntity::getId, task.getId()) + .set(FileTaskEntity::getResultJson, task.getResultJson()) + .set(FileTaskEntity::getUpdatedAt, task.getUpdatedAt())); String sourceFilename = buildAggregateSourceFilenameLabel(sourceFiles); // rowCount 记接受行数、success 留 NULL(本支建单不写占位值),这两列底座刻意不替它定 diff --git a/backend-java/src/main/java/com/nanri/aiimage/modules/convert/service/ConvertRunService.java b/backend-java/src/main/java/com/nanri/aiimage/modules/convert/service/ConvertRunService.java index 58fc82d45..d74251139 100644 --- a/backend-java/src/main/java/com/nanri/aiimage/modules/convert/service/ConvertRunService.java +++ b/backend-java/src/main/java/com/nanri/aiimage/modules/convert/service/ConvertRunService.java @@ -5,6 +5,7 @@ import cn.hutool.core.io.FileUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.nanri.aiimage.common.exception.BusinessException; @@ -191,7 +192,14 @@ public class ConvertRunService { task.setFailedFileCount(failedCount); task.setResultJson(JSONUtil.toJsonStr(items)); task.setUpdatedAt(LocalDateTime.now()); - fileTaskMapper.updateById(task); + // B82-01:显式 wrapper 只写计数/载荷/心跳四列——部分实体 updateById 会把 ALWAYS 的 + // failure_category 抹回 NULL + fileTaskMapper.update(null, new LambdaUpdateWrapper() + .eq(FileTaskEntity::getId, task.getId()) + .set(FileTaskEntity::getSuccessFileCount, task.getSuccessFileCount()) + .set(FileTaskEntity::getFailedFileCount, task.getFailedFileCount()) + .set(FileTaskEntity::getResultJson, task.getResultJson()) + .set(FileTaskEntity::getUpdatedAt, task.getUpdatedAt())); ConvertRunVo vo = new ConvertRunVo(); vo.setTotal(request.getFiles().size()); diff --git a/backend-java/src/main/java/com/nanri/aiimage/modules/dedupe/service/DedupeRunService.java b/backend-java/src/main/java/com/nanri/aiimage/modules/dedupe/service/DedupeRunService.java index 33a1067ba..c16f014c7 100644 --- a/backend-java/src/main/java/com/nanri/aiimage/modules/dedupe/service/DedupeRunService.java +++ b/backend-java/src/main/java/com/nanri/aiimage/modules/dedupe/service/DedupeRunService.java @@ -404,7 +404,16 @@ public class DedupeRunService { task.setErrorMessage(progress.getError()); task.setUpdatedAt(LocalDateTime.now()); task.setFinishedAt(LocalDateTime.now()); - fileTaskMapper.updateById(task); + // B82-01:收尾用的还是建单那枚内存实体,updateById 会把 ALWAYS 的 failure_category + // 抹回 NULL(陈旧修复面刚写进的分类一并被抹)。显式 wrapper 只写本方法的四列, + // error_message 与分类同笔落库(护栏格 1 的连线语义) + fileTaskMapper.update(null, new LambdaUpdateWrapper() + .eq(FileTaskEntity::getId, task.getId()) + .set(FileTaskEntity::getStatus, task.getStatus()) + .set(FileTaskEntity::getErrorMessage, task.getErrorMessage()) + .set(FileTaskEntity::getFailureCategory, TaskFailureLedger.categoryOf(task.getErrorMessage())) + .set(FileTaskEntity::getUpdatedAt, task.getUpdatedAt()) + .set(FileTaskEntity::getFinishedAt, task.getFinishedAt())); } finally { // 终态必须绕过节流立刻共享:客户端下一次轮询可能落到另一节点 runProgressMap.putNow(runId, snapshot(progress)); @@ -496,7 +505,15 @@ public class DedupeRunService { task.setResultJson(JSONUtil.toJsonStr(result.getItems())); task.setUpdatedAt(LocalDateTime.now()); task.setFinishedAt(LocalDateTime.now()); - fileTaskMapper.updateById(task); + // B82-01:同收尾分支——显式 wrapper 只写本方法的六列,不带抹 failure_category + fileTaskMapper.update(null, new LambdaUpdateWrapper() + .eq(FileTaskEntity::getId, task.getId()) + .set(FileTaskEntity::getStatus, task.getStatus()) + .set(FileTaskEntity::getSuccessFileCount, task.getSuccessFileCount()) + .set(FileTaskEntity::getFailedFileCount, task.getFailedFileCount()) + .set(FileTaskEntity::getResultJson, task.getResultJson()) + .set(FileTaskEntity::getUpdatedAt, task.getUpdatedAt()) + .set(FileTaskEntity::getFinishedAt, task.getFinishedAt())); } /** diff --git a/backend-java/src/main/java/com/nanri/aiimage/modules/deletebrand/service/DeleteBrandRunService.java b/backend-java/src/main/java/com/nanri/aiimage/modules/deletebrand/service/DeleteBrandRunService.java index 535875933..7147b9e53 100644 --- a/backend-java/src/main/java/com/nanri/aiimage/modules/deletebrand/service/DeleteBrandRunService.java +++ b/backend-java/src/main/java/com/nanri/aiimage/modules/deletebrand/service/DeleteBrandRunService.java @@ -4,6 +4,7 @@ import com.nanri.aiimage.common.text.UserMessages; import cn.hutool.core.io.FileUtil; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.nanri.aiimage.common.exception.BusinessException; @@ -41,6 +42,7 @@ import com.nanri.aiimage.modules.task.service.TaskDistributedLockService; import com.nanri.aiimage.modules.task.service.TaskFileJobService; import com.nanri.aiimage.modules.task.service.TaskFinalizeSupport; import com.nanri.aiimage.modules.task.service.pipeline.AbstractFileTaskPipeline; +import com.nanri.aiimage.modules.task.service.support.TaskFailureLedger; import com.nanri.aiimage.modules.ziniao.model.vo.ZiniaoShopMatchResultVo; import com.nanri.aiimage.modules.ziniao.service.ZiniaoShopIndexService; import com.nanri.aiimage.modules.ziniao.service.ZiniaoShopSwitchService; @@ -282,12 +284,25 @@ public class DeleteBrandRunService extends AbstractFileTaskPipeline persist = new LambdaUpdateWrapper() + .eq(FileTaskEntity::getId, task.getId()) + .set(FileTaskEntity::getSuccessFileCount, parsedSuccessCount) + .set(FileTaskEntity::getFailedFileCount, parsedFailedCount) + .set(FileTaskEntity::getResultJson, task.getResultJson()) + .set(FileTaskEntity::getUpdatedAt, LocalDateTime.now()) + .set(FileTaskEntity::getSourceFileCount, processableFileCount); if (processableFileCount <= 0) { task.setStatus("FAILED"); task.setErrorMessage(parsedFailedCount > 0 ? "全部文件解析或匹配失败" : null); task.setFinishedAt(LocalDateTime.now()); + persist.set(FileTaskEntity::getStatus, task.getStatus()) + .set(FileTaskEntity::getErrorMessage, task.getErrorMessage()) + .set(FileTaskEntity::getFailureCategory, TaskFailureLedger.categoryOf(task.getErrorMessage())) + .set(FileTaskEntity::getFinishedAt, task.getFinishedAt()); } - fileTaskMapper.updateById(task); + fileTaskMapper.update(null, persist); if ("RUNNING".equals(task.getStatus())) { deleteBrandTaskCacheService.saveTaskCache(task); } diff --git a/backend-java/src/main/java/com/nanri/aiimage/modules/pricetrack/service/PriceTrackTaskService.java b/backend-java/src/main/java/com/nanri/aiimage/modules/pricetrack/service/PriceTrackTaskService.java index 056f7f3df..a75181219 100644 --- a/backend-java/src/main/java/com/nanri/aiimage/modules/pricetrack/service/PriceTrackTaskService.java +++ b/backend-java/src/main/java/com/nanri/aiimage/modules/pricetrack/service/PriceTrackTaskService.java @@ -3,6 +3,7 @@ package com.nanri.aiimage.modules.pricetrack.service; import com.nanri.aiimage.common.task.TaskStatuses; import com.nanri.aiimage.common.text.UserMessages; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.nanri.aiimage.common.exception.BusinessException; @@ -660,7 +661,12 @@ public class PriceTrackTaskService extends AbstractShopPayloadTaskPipeline() + .eq(FileTaskEntity::getId, task.getId()) + .set(FileTaskEntity::getRequestJson, task.getRequestJson()) + .set(FileTaskEntity::getResultJson, task.getResultJson())); priceTrackTaskCacheService.saveTaskCache(task); // TODO: Python 侧轮询 RUNNING 任务,pickup 后开始处理 diff --git a/backend-java/src/main/java/com/nanri/aiimage/modules/productrisk/service/ProductRiskTaskService.java b/backend-java/src/main/java/com/nanri/aiimage/modules/productrisk/service/ProductRiskTaskService.java index 63980fcbc..522b52078 100644 --- a/backend-java/src/main/java/com/nanri/aiimage/modules/productrisk/service/ProductRiskTaskService.java +++ b/backend-java/src/main/java/com/nanri/aiimage/modules/productrisk/service/ProductRiskTaskService.java @@ -1,6 +1,7 @@ package com.nanri.aiimage.modules.productrisk.service; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.fasterxml.jackson.databind.ObjectMapper; import com.nanri.aiimage.common.exception.BusinessException; import com.nanri.aiimage.common.security.AdminAuthSupport; @@ -560,7 +561,12 @@ public class ProductRiskTaskService { } catch (Exception ex) { throw new BusinessException("序列化任务数据失败"); } - fileTaskMapper.updateById(task); + // B82-01:显式 wrapper 只写快照两列——task 是建单内存实体,updateById 会把 ALWAYS 的 + // failure_category 抹回 NULL + fileTaskMapper.update(null, new LambdaUpdateWrapper() + .eq(FileTaskEntity::getId, task.getId()) + .set(FileTaskEntity::getRequestJson, task.getRequestJson()) + .set(FileTaskEntity::getResultJson, task.getResultJson())); ProductRiskCreateTaskVo vo = new ProductRiskCreateTaskVo(); vo.setTaskId(task.getId()); diff --git a/backend-java/src/main/java/com/nanri/aiimage/modules/queryasin/service/QueryAsinTaskService.java b/backend-java/src/main/java/com/nanri/aiimage/modules/queryasin/service/QueryAsinTaskService.java index ef93145b6..8f4237e05 100644 --- a/backend-java/src/main/java/com/nanri/aiimage/modules/queryasin/service/QueryAsinTaskService.java +++ b/backend-java/src/main/java/com/nanri/aiimage/modules/queryasin/service/QueryAsinTaskService.java @@ -706,7 +706,11 @@ public class QueryAsinTaskService { task.setRequestJson(objectMapper.writeValueAsString(requestItems)); task.setResultJson(objectMapper.writeValueAsString(snapshots)); syncSnapshotTables(task, snapshots); - fileTaskMapper.updateById(task); + // B82-01:显式 wrapper 只写快照两列——updateById 会把 ALWAYS 的 failure_category 抹回 NULL + fileTaskMapper.update(null, new LambdaUpdateWrapper() + .eq(FileTaskEntity::getId, task.getId()) + .set(FileTaskEntity::getRequestJson, task.getRequestJson()) + .set(FileTaskEntity::getResultJson, task.getResultJson())); } catch (Exception ex) { throw new BusinessException("查询ASIN任务快照保存失败"); } diff --git a/backend-java/src/main/java/com/nanri/aiimage/modules/shopdatacrawl/service/ShopDataCrawlTaskService.java b/backend-java/src/main/java/com/nanri/aiimage/modules/shopdatacrawl/service/ShopDataCrawlTaskService.java index f49a167a5..ec5b00472 100644 --- a/backend-java/src/main/java/com/nanri/aiimage/modules/shopdatacrawl/service/ShopDataCrawlTaskService.java +++ b/backend-java/src/main/java/com/nanri/aiimage/modules/shopdatacrawl/service/ShopDataCrawlTaskService.java @@ -1361,7 +1361,12 @@ public class ShopDataCrawlTaskService extends AbstractFileTaskPipeline() + .eq(FileTaskEntity::getId, task.getId()) + .set(FileTaskEntity::getRequestJson, task.getRequestJson()) + .set(FileTaskEntity::getOwnerInstanceId, task.getOwnerInstanceId()) + .set(FileTaskEntity::getResultJson, task.getResultJson())); } catch (Exception ex) { throw new BusinessException("店铺数据抓取任务快照保存失败"); } diff --git a/backend-java/src/main/java/com/nanri/aiimage/modules/similarasin/service/SimilarAsinTaskService.java b/backend-java/src/main/java/com/nanri/aiimage/modules/similarasin/service/SimilarAsinTaskService.java index 8a5f37b6e..3cf18fb51 100644 --- a/backend-java/src/main/java/com/nanri/aiimage/modules/similarasin/service/SimilarAsinTaskService.java +++ b/backend-java/src/main/java/com/nanri/aiimage/modules/similarasin/service/SimilarAsinTaskService.java @@ -482,7 +482,11 @@ public class SimilarAsinTaskService implements SimilarAsinPipelineHost { long payloadStoredAt = System.nanoTime(); task.setResultJson(payloadSupport().buildTaskResultJson(request.getAiPrompt(), request.getApiKey(), request.getImgSwitch(), request.getCategorySwitch(), sourceFiles, parsedPayloadPointer)); task.setUpdatedAt(LocalDateTime.now()); - fileTaskMapper.updateById(task); + // B82-01:显式 wrapper 只写载荷与心跳两列——updateById 会把 ALWAYS 的 failure_category 抹回 NULL + fileTaskMapper.update(null, new LambdaUpdateWrapper() + .eq(FileTaskEntity::getId, task.getId()) + .set(FileTaskEntity::getResultJson, task.getResultJson()) + .set(FileTaskEntity::getUpdatedAt, task.getUpdatedAt())); String sourceFilename = buildAggregateSourceFilenameLabel(sourceFiles); FileResultEntity result = new FileResultEntity(); diff --git a/backend-java/src/main/java/com/nanri/aiimage/modules/similarasin/service/support/SimilarAsinTaskOwnershipSupport.java b/backend-java/src/main/java/com/nanri/aiimage/modules/similarasin/service/support/SimilarAsinTaskOwnershipSupport.java index da0f597c7..df24f4b46 100644 --- a/backend-java/src/main/java/com/nanri/aiimage/modules/similarasin/service/support/SimilarAsinTaskOwnershipSupport.java +++ b/backend-java/src/main/java/com/nanri/aiimage/modules/similarasin/service/support/SimilarAsinTaskOwnershipSupport.java @@ -1,6 +1,7 @@ package com.nanri.aiimage.modules.similarasin.service.support; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; @@ -164,11 +165,12 @@ public class SimilarAsinTaskOwnershipSupport { payload.put("ownerInstanceReason", "rustfs-fallback-local"); String updatedJson = objectMapper.writeValueAsString(payload); task.setResultJson(updatedJson); - FileTaskEntity update = new FileTaskEntity(); - update.setId(task.getId()); - update.setResultJson(updatedJson); - update.setUpdatedAt(LocalDateTime.now()); - if (fileTaskMapper.updateById(update) != 1) { + // B82-01:部分实体 updateById 会借 failure_category 的 ALWAYS 策略把已登记分类抹回 + // NULL——显式 wrapper 只写本方法要改的两列 + if (fileTaskMapper.update(null, new LambdaUpdateWrapper() + .eq(FileTaskEntity::getId, task.getId()) + .set(FileTaskEntity::getResultJson, updatedJson) + .set(FileTaskEntity::getUpdatedAt, LocalDateTime.now())) != 1) { throw new IllegalStateException("Task owner update affected no row"); } log.warn("[similar-asin] task bound to current instance due to rustfs fallback taskId={} instanceId={} chunk={}", diff --git a/backend-java/src/main/java/com/nanri/aiimage/modules/split/service/SplitRunService.java b/backend-java/src/main/java/com/nanri/aiimage/modules/split/service/SplitRunService.java index fe4ce436a..e2faebad4 100644 --- a/backend-java/src/main/java/com/nanri/aiimage/modules/split/service/SplitRunService.java +++ b/backend-java/src/main/java/com/nanri/aiimage/modules/split/service/SplitRunService.java @@ -5,6 +5,7 @@ import cn.hutool.core.io.FileUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.nanri.aiimage.common.exception.BusinessException; import com.nanri.aiimage.common.excel.ExcelStreamReader; import com.nanri.aiimage.config.StorageProperties; @@ -152,7 +153,14 @@ public class SplitRunService { task.setFailedFileCount(failedCount); task.setResultJson(JSONUtil.toJsonStr(items)); task.setUpdatedAt(LocalDateTime.now()); - fileTaskMapper.updateById(task); + // B82-01:显式 wrapper 只写计数/载荷/心跳四列——部分实体 updateById 会把 ALWAYS 的 + // failure_category 抹回 NULL + fileTaskMapper.update(null, new LambdaUpdateWrapper() + .eq(FileTaskEntity::getId, task.getId()) + .set(FileTaskEntity::getSuccessFileCount, task.getSuccessFileCount()) + .set(FileTaskEntity::getFailedFileCount, task.getFailedFileCount()) + .set(FileTaskEntity::getResultJson, task.getResultJson()) + .set(FileTaskEntity::getUpdatedAt, task.getUpdatedAt())); SplitRunVo vo = new SplitRunVo(); vo.setTotal(request.getFiles().size()); diff --git a/backend-java/src/main/java/com/nanri/aiimage/modules/withdraw/service/WithdrawTaskService.java b/backend-java/src/main/java/com/nanri/aiimage/modules/withdraw/service/WithdrawTaskService.java index d0186a6f3..6e035095e 100644 --- a/backend-java/src/main/java/com/nanri/aiimage/modules/withdraw/service/WithdrawTaskService.java +++ b/backend-java/src/main/java/com/nanri/aiimage/modules/withdraw/service/WithdrawTaskService.java @@ -702,7 +702,11 @@ public class WithdrawTaskService { task.setRequestJson(objectMapper.writeValueAsString(requestPayload)); task.setResultJson(objectMapper.writeValueAsString(snapshots == null ? List.of() : snapshots)); syncSnapshotTables(task, snapshots); - fileTaskMapper.updateById(task); + // B82-01:显式 wrapper 只写快照两列——updateById 会把 ALWAYS 的 failure_category 抹回 NULL + fileTaskMapper.update(null, new LambdaUpdateWrapper() + .eq(FileTaskEntity::getId, task.getId()) + .set(FileTaskEntity::getRequestJson, task.getRequestJson()) + .set(FileTaskEntity::getResultJson, task.getResultJson())); } catch (Exception ex) { throw new BusinessException("取款任务快照保存失败"); } diff --git a/backend-java/src/test/java/com/nanri/aiimage/modules/appearancepatent/service/support/AppearancePatentCreateTaskSnapshotTest.java b/backend-java/src/test/java/com/nanri/aiimage/modules/appearancepatent/service/support/AppearancePatentCreateTaskSnapshotTest.java index e6fe55f91..5d5f8b601 100644 --- a/backend-java/src/test/java/com/nanri/aiimage/modules/appearancepatent/service/support/AppearancePatentCreateTaskSnapshotTest.java +++ b/backend-java/src/test/java/com/nanri/aiimage/modules/appearancepatent/service/support/AppearancePatentCreateTaskSnapshotTest.java @@ -178,13 +178,19 @@ class AppearancePatentCreateTaskSnapshotTest { + " resultJson=" + task.getResultJson()); return 1; }).when(fileTaskMapper).insert(any(FileTaskEntity.class)); - when(fileTaskMapper.updateById(any(FileTaskEntity.class))).thenAnswer(invocation -> { - FileTaskEntity task = invocation.getArgument(0); - events.add("task.update id=" + task.getId() - + " resultJson.keys=" + jsonKeys(task.getResultJson()) - + " resultJson=" + task.getResultJson()); - return 1; - }); + when(fileTaskMapper.update(org.mockito.ArgumentMatchers.isNull(), + org.mockito.ArgumentMatchers.any(com.baomidou.mybatisplus.core.conditions.Wrapper.class))) + .thenAnswer(invocation -> { + // B82-01:任务行部分字段落库改走 update(null, wrapper),从 SET 段取值 + FileTaskEntity task = new FileTaskEntity(); + com.baomidou.mybatisplus.core.conditions.Wrapper wrapper = invocation.getArgument(1); + task.setId(com.nanri.aiimage.testutil.UpdateWrapperProbe.eqId(wrapper)); + task.setResultJson((String) com.nanri.aiimage.testutil.UpdateWrapperProbe.setValues(wrapper).get("result_json")); + events.add("task.update id=" + task.getId() + + " resultJson.keys=" + jsonKeys(task.getResultJson()) + + " resultJson=" + task.getResultJson()); + return 1; + }); when(fileResultMapper.insert(any(FileResultEntity.class))).thenAnswer(invocation -> { FileResultEntity row = invocation.getArgument(0); row.setId(7001L); diff --git a/backend-java/src/test/java/com/nanri/aiimage/modules/deletebrand/service/support/DeleteBrandSnapshotTest.java b/backend-java/src/test/java/com/nanri/aiimage/modules/deletebrand/service/support/DeleteBrandSnapshotTest.java index 18b6b8857..26e1a2a8d 100644 --- a/backend-java/src/test/java/com/nanri/aiimage/modules/deletebrand/service/support/DeleteBrandSnapshotTest.java +++ b/backend-java/src/test/java/com/nanri/aiimage/modules/deletebrand/service/support/DeleteBrandSnapshotTest.java @@ -159,9 +159,17 @@ class DeleteBrandSnapshotTest { return 1; }).when(fileTaskMapper).insert(any(FileTaskEntity.class)); doAnswer(invocation -> { - captured.taskUpdates.add(invocation.getArgument(0)); + // B82-01:部分字段落库走 update(null, wrapper)——按 SET 段重建探针实体再进快照 + // (status 不在 RUNNING 分支的写面里 ⇒ 渲染成 "-";FAILED 分支显式带 status/error_message) + com.baomidou.mybatisplus.core.conditions.Wrapper wrapper = invocation.getArgument(1); + FileTaskEntity probe = new FileTaskEntity(); + probe.setId(com.nanri.aiimage.testutil.UpdateWrapperProbe.eqId(wrapper)); + com.nanri.aiimage.testutil.UpdateWrapperProbe.apply(probe, + com.nanri.aiimage.testutil.UpdateWrapperProbe.setValues(wrapper)); + captured.taskUpdates.add(probe); return 1; - }).when(fileTaskMapper).updateById(any(FileTaskEntity.class)); + }).when(fileTaskMapper).update(org.mockito.ArgumentMatchers.isNull(), + org.mockito.ArgumentMatchers.any(com.baomidou.mybatisplus.core.conditions.Wrapper.class)); doAnswer(invocation -> { FileResultEntity entity = invocation.getArgument(0); entity.setId(2001L + captured.resultInserts.size()); diff --git a/backend-java/src/test/java/com/nanri/aiimage/modules/pricetrack/service/support/PriceTrackSnapshotTest.java b/backend-java/src/test/java/com/nanri/aiimage/modules/pricetrack/service/support/PriceTrackSnapshotTest.java index 66a0527a1..66003970b 100644 --- a/backend-java/src/test/java/com/nanri/aiimage/modules/pricetrack/service/support/PriceTrackSnapshotTest.java +++ b/backend-java/src/test/java/com/nanri/aiimage/modules/pricetrack/service/support/PriceTrackSnapshotTest.java @@ -134,9 +134,17 @@ class PriceTrackSnapshotTest { return 1; }).when(fileTaskMapper).insert(any(FileTaskEntity.class)); doAnswer(invocation -> { - captured.taskUpdates.add(invocation.getArgument(0)); + // B82-01:部分字段落库走 update(null, wrapper)——按 SET 段重建探针实体再进快照 + // (status 不在建单写面里 ⇒ 渲染成 "-") + com.baomidou.mybatisplus.core.conditions.Wrapper wrapper = invocation.getArgument(1); + FileTaskEntity probe = new FileTaskEntity(); + probe.setId(com.nanri.aiimage.testutil.UpdateWrapperProbe.eqId(wrapper)); + com.nanri.aiimage.testutil.UpdateWrapperProbe.apply(probe, + com.nanri.aiimage.testutil.UpdateWrapperProbe.setValues(wrapper)); + captured.taskUpdates.add(probe); return 1; - }).when(fileTaskMapper).updateById(any(FileTaskEntity.class)); + }).when(fileTaskMapper).update(org.mockito.ArgumentMatchers.isNull(), + org.mockito.ArgumentMatchers.any(com.baomidou.mybatisplus.core.conditions.Wrapper.class)); doAnswer(invocation -> { FileResultEntity entity = invocation.getArgument(0); entity.setId(2001L + captured.resultInserts.size()); diff --git a/backend-java/src/test/java/com/nanri/aiimage/modules/shopdatacrawl/service/ShopDataCrawlOwnerColumnTest.java b/backend-java/src/test/java/com/nanri/aiimage/modules/shopdatacrawl/service/ShopDataCrawlOwnerColumnTest.java index cd08672f3..277f4af52 100644 --- a/backend-java/src/test/java/com/nanri/aiimage/modules/shopdatacrawl/service/ShopDataCrawlOwnerColumnTest.java +++ b/backend-java/src/test/java/com/nanri/aiimage/modules/shopdatacrawl/service/ShopDataCrawlOwnerColumnTest.java @@ -164,28 +164,31 @@ class ShopDataCrawlOwnerColumnTest { }); lenient().when(fileTaskMapper.updateById(any(FileTaskEntity.class))).thenReturn(1); // 2026-09:陈旧扫描的 FAILED 写入改为条件更新(where id=? and status='RUNNING' 的 CAS), - // 走的是 update(entity=null, wrapper)。这里按 wrapper 参数模拟 DB:只有仍为 RUNNING 的行才命中, - // 命中后落回内存表(与真实 DB 语义一致,第二次扫描因终态不再命中)。 - // 注意用 isNull():Mockito 2+ 的 any(Class) 不匹配 null。 + // 走的是 update(entity=null, wrapper)。B82-01 后建单快照写(request_json/owner_instance_id/ + // result_json)也是同一形状——这里按 SQL 语义模拟假 DB:先校验 WHERE 段(id 必有;CAS 形状 + // 还有 eq(status,'RUNNING')),命中才把 SET 段逐列应用到内存行(与真实 DB 语义一致, + // 第二次扫描因终态不再命中)。注意用 isNull():Mockito 2+ 的 any(Class) 不匹配 null。 lenient().when(fileTaskMapper.update(org.mockito.ArgumentMatchers.isNull(), any(com.baomidou.mybatisplus.core.conditions.Wrapper.class))) .thenAnswer(invocation -> { com.baomidou.mybatisplus.core.conditions.Wrapper wrapper = invocation.getArgument(1); - java.util.Map params = extractParamValues(wrapper); - java.util.Optional idValue = params.values().stream() - .filter(value -> value instanceof Long) - .findFirst(); - if (idValue.isEmpty()) { + java.util.Map sets = + com.nanri.aiimage.testutil.UpdateWrapperProbe.setValues(wrapper); + java.util.Map where = + com.nanri.aiimage.testutil.UpdateWrapperProbe.whereEq(wrapper); + if (!(where.get("id") instanceof Long id)) { return 0; } - FileTaskEntity stored = dbTask((Long) idValue.get()); - if (stored == null || !"RUNNING".equals(stored.getStatus())) { + FileTaskEntity stored = dbTask(id); + if (stored == null) { return 0; } - stored.setStatus("FAILED"); - stored.setUpdatedAt(LocalDateTime.now()); - stored.setFinishedAt(LocalDateTime.now()); + Object eqStatus = where.get("status"); + if (eqStatus != null && !eqStatus.equals(stored.getStatus())) { + return 0; + } + com.nanri.aiimage.testutil.UpdateWrapperProbe.apply(stored, sets); return 1; }); lenient().when(fileTaskMapper.selectById(anyLong())).thenReturn(null); diff --git a/backend-java/src/test/java/com/nanri/aiimage/modules/shopdatacrawl/service/support/ShopDataCrawlCreateTaskSnapshotTest.java b/backend-java/src/test/java/com/nanri/aiimage/modules/shopdatacrawl/service/support/ShopDataCrawlCreateTaskSnapshotTest.java index 8a86f4d80..3e6d48a37 100644 --- a/backend-java/src/test/java/com/nanri/aiimage/modules/shopdatacrawl/service/support/ShopDataCrawlCreateTaskSnapshotTest.java +++ b/backend-java/src/test/java/com/nanri/aiimage/modules/shopdatacrawl/service/support/ShopDataCrawlCreateTaskSnapshotTest.java @@ -150,9 +150,17 @@ class ShopDataCrawlCreateTaskSnapshotTest { return 1; }).when(fileTaskMapper).insert(any(FileTaskEntity.class)); doAnswer(invocation -> { - events.add("task.update: " + renderTaskUpdate(invocation.getArgument(0))); + // B82-01:任务行部分字段落库改走 update(null, wrapper)——从 SET 段重建探针实体, + // 只带 request_json/owner_instance_id/result_json 三列(status/计数不在写面 ⇒ 渲染成 "-") + com.baomidou.mybatisplus.core.conditions.Wrapper wrapper = invocation.getArgument(1); + FileTaskEntity probe = new FileTaskEntity(); + probe.setId(com.nanri.aiimage.testutil.UpdateWrapperProbe.eqId(wrapper)); + com.nanri.aiimage.testutil.UpdateWrapperProbe.apply(probe, + com.nanri.aiimage.testutil.UpdateWrapperProbe.setValues(wrapper)); + events.add("task.update: " + renderTaskUpdate(probe)); return 1; - }).when(fileTaskMapper).updateById(any(FileTaskEntity.class)); + }).when(fileTaskMapper).update(org.mockito.ArgumentMatchers.isNull(), + org.mockito.ArgumentMatchers.any(com.baomidou.mybatisplus.core.conditions.Wrapper.class)); doAnswer(invocation -> { FileResultEntity entity = invocation.getArgument(0); entity.setId(2001L + resultInserts.size()); diff --git a/backend-java/src/test/java/com/nanri/aiimage/modules/similarasin/service/SimilarAsinTaskServiceSubmitTest.java b/backend-java/src/test/java/com/nanri/aiimage/modules/similarasin/service/SimilarAsinTaskServiceSubmitTest.java index 47f1ed6de..76d2b9499 100644 --- a/backend-java/src/test/java/com/nanri/aiimage/modules/similarasin/service/SimilarAsinTaskServiceSubmitTest.java +++ b/backend-java/src/test/java/com/nanri/aiimage/modules/similarasin/service/SimilarAsinTaskServiceSubmitTest.java @@ -226,7 +226,10 @@ class SimilarAsinTaskServiceSubmitTest { configureNewChunkAndScope(); when(taskChunkMapper.selectCount(any())).thenReturn(1L); configureChunkStore(true); - when(fileTaskMapper.updateById(any(FileTaskEntity.class))).thenReturn(0); + // B82-01:owner 绑定失败的注入点改打 update(null, wrapper)——部分实体 updateById 已从写面退场 + when(fileTaskMapper.update(org.mockito.ArgumentMatchers.isNull(), + org.mockito.ArgumentMatchers.any(com.baomidou.mybatisplus.core.conditions.Wrapper.class))) + .thenReturn(0); IllegalStateException thrown = assertThrows(IllegalStateException.class, () -> service.submitResult(TASK_ID, request(false))); @@ -248,11 +251,23 @@ class SimilarAsinTaskServiceSubmitTest { configureChunkStore(true); when(transientPayloadStorageService.extractPointer(STORED_CHUNK_POINTER)).thenReturn(CHUNK_POINTER); when(taskChunkMapper.selectCount(any())).thenReturn(1L); + // B82-01:owner 绑定也改走 update(null, wrapper)——但活动心跳(touchJavaSideTaskActivity) + // 本来就合法地走同一形状,所以不能 verify(never()).update;改成录下每一笔 SET 段, + // 断言「没有任何一次写 owner_instance_id」=重复候选确实没被改绑归属。 + java.util.List> updateSets = new java.util.ArrayList<>(); + when(fileTaskMapper.update(org.mockito.ArgumentMatchers.isNull(), + org.mockito.ArgumentMatchers.any(com.baomidou.mybatisplus.core.conditions.Wrapper.class))) + .thenAnswer(invocation -> { + updateSets.add(com.nanri.aiimage.testutil.UpdateWrapperProbe.setValues(invocation.getArgument(1))); + return 1; + }); service.submitResult(TASK_ID, request(false)); verify(taskChunkMapper, never()).insert(any(TaskChunkEntity.class)); verify(fileTaskMapper, never()).updateById(any(FileTaskEntity.class)); + assertTrue(updateSets.stream().noneMatch(sets -> sets.containsKey("owner_instance_id")), + "重复候选不得改写归属列(owner 绑定只许发生在新增 chunk 的路径上)"); verify(transientPayloadStorageService, never()).deletePayloadIfPresent(STORED_CHUNK_POINTER); } 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 index 35881d6e5..271411e0b 100644 --- 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 @@ -171,9 +171,16 @@ class SimilarAsinCreateTaskSnapshotTest { return 1; }).when(fileTaskMapper).insert(any(FileTaskEntity.class)); doAnswer(invocation -> { - captured.events.add("task.update: " + renderTaskUpdate(invocation.getArgument(0))); + // B82-01:任务行部分字段落库改走 update(null, wrapper)——从 SET 段重建探针实体, + // moduleType/status 不在写面里 ⇒ 渲染成 "-",快照把「窄写」钉在脸上 + com.baomidou.mybatisplus.core.conditions.Wrapper wrapper = invocation.getArgument(1); + FileTaskEntity probe = new FileTaskEntity(); + probe.setId(com.nanri.aiimage.testutil.UpdateWrapperProbe.eqId(wrapper)); + probe.setResultJson((String) com.nanri.aiimage.testutil.UpdateWrapperProbe.setValues(wrapper).get("result_json")); + captured.events.add("task.update: " + renderTaskUpdate(probe)); return 1; - }).when(fileTaskMapper).updateById(any(FileTaskEntity.class)); + }).when(fileTaskMapper).update(org.mockito.ArgumentMatchers.isNull(), + org.mockito.ArgumentMatchers.any(com.baomidou.mybatisplus.core.conditions.Wrapper.class)); doAnswer(invocation -> { captured.events.add("result.insert: " + renderResultInsert(invocation.getArgument(0))); return 1; diff --git a/backend-java/src/test/java/com/nanri/aiimage/modules/task/service/TaskFailureCategoryGuardrailTest.java b/backend-java/src/test/java/com/nanri/aiimage/modules/task/service/TaskFailureCategoryGuardrailTest.java index 23be365c4..a7595cc0a 100644 --- a/backend-java/src/test/java/com/nanri/aiimage/modules/task/service/TaskFailureCategoryGuardrailTest.java +++ b/backend-java/src/test/java/com/nanri/aiimage/modules/task/service/TaskFailureCategoryGuardrailTest.java @@ -1,6 +1,7 @@ package com.nanri.aiimage.modules.task.service; import com.nanri.aiimage.modules.task.model.entity.FileTaskEntity; +import com.nanri.aiimage.modules.task.service.support.TaskFailureLedger; import com.nanri.aiimage.testutil.SourceScan; import org.junit.jupiter.api.Test; @@ -51,6 +52,20 @@ class TaskFailureCategoryGuardrailTest { /** 名单内在册写点数(AP 4 +相似ASIN 4 +采集 1);低于它=写点被挪走或改了写法。 */ private static final int ENTITY_FACE_MIN_WRITE_SITES = 9; + /** + * {@code .updateById(} 写法总量的在册棘轮(B82-01 收口时的换算值:改前 173,本笔把 12 处 + * 部分实体写点——13 处 {@code updateById} 调用,{@code DedupeRunService} 的收尾一处两调用—— + * 改成 {@code update(null, wrapper)} 后余 160)。 + * + *

为什么钉总量而不是逐点名单:failure_category 只是本仓 {@code FieldStrategy.ALWAYS} 的 + * 五分之一({@code PriceTrackLoopRunEntity.active_task_id}、{@code ShopKeyEntity}×2、 + * {@code SkipPriceAsinEntity}×5 个最低价列都标了它)——任何实体上新增一处 + * {@code updateById},都值得先审一遍「实体里有没有 ALWAYS 字段、传进去的是不是新鲜实体」。 + * 部分字段落库的正本形状是 {@code update(null, wrapper)} 显式 {@code .set} + * ({@code CollectDataService} 结果文件组装的条件更新)。 + */ + private static final int REGISTERED_UPDATE_BY_ID_SITES = 160; + @Test void 任务失败文案写点必须同笔写分类列() { List violations = new ArrayList<>(); @@ -178,6 +193,67 @@ class TaskFailureCategoryGuardrailTest { assertThat(TaskRetryEligibility.category(null)).isNull(); } + /** + * B82-01 抓出的判据缺口:上面两格只验「写文案的行旁边出现了写列的行」这条连线, + * 配对写一个恒为 {@code null} 的值也照样绿——而这正是现网实况(2026-11-05 只读探针: + * {@code failure_category} 全表非空 0、近 7 天 194 条 FAILED 全空,另有 9 条文案命中 + * CREDENTIAL/DELIVERY markers 的行列也是空)。连线格买到的是零免疫力。 + * 这里把「值本身非空」钉住:六组 markers(KEY 并入 BALANCE,共 5 个枚举值)各出一条样本, + * {@link TaskFailureLedger#categoryOf} 必须给出对应的非空分类名。 + */ + @Test + void ledger_对六组markers各出一条非空分类() { + // 停止文案取常量不抄字面量(与 STOPPED_MARKERS 同一条纪律:两处各写一遍,改一处就静默失效) + assertThat(TaskFailureLedger.categoryOf(TaskResumeService.DUPLICATE_STOP_REASON)) + .as("STOPPED 组必须判得出:这是六组里最先判、语义唯一的一条") + .isEqualTo(TaskRetryEligibility.Category.STOPPED.name()); + assertThat(TaskFailureLedger.categoryOf("已收到 73 个结果分片,但结果文件生成多次失败,任务已自动结束")) + .isEqualTo(TaskRetryEligibility.Category.DELIVERY.name()); + assertThat(TaskFailureLedger.categoryOf("LLM 服务余额欠费(上游账户额度不足,非本行数据问题)")) + .isEqualTo(TaskRetryEligibility.Category.BALANCE.name()); + assertThat(TaskFailureLedger.categoryOf("upstream error: invalid_api_key")) + .as("KEY 组并入 BALANCE:密钥失效不许被误判成别的类,更不许判空") + .isEqualTo(TaskRetryEligibility.Category.BALANCE.name()); + assertThat(TaskFailureLedger.categoryOf("对象存储出口不可达,无法写入结果")) + .isEqualTo(TaskRetryEligibility.Category.SERVICE_DOWN.name()); + assertThat(TaskFailureLedger.categoryOf("aiprice 未登录且自动登录失败")) + .isEqualTo(TaskRetryEligibility.Category.CREDENTIAL.name()); + // 反向:值域外的普通可重试文案必须判不出——写侧落 null=未登记,读侧逐字回落文案 + assertThat(TaskFailureLedger.categoryOf("第 3 行数据格式不合法")).isNull(); + } + + /** + * {@code .updateById(} 写法总量棘轮(B82-01 的另一半:抹列面)。 + * + *

{@code failure_category} 标了 {@code updateStrategy = ALWAYS}(V186,让「清错误」分支的 + * null 真落库),代价是任何「{@code new} 出来的部分实体」走 {@code updateById} 都会把 + * 这一列连同 ALWAYS 家族的其它列无条件抹回 NULL——12 处这种写法本笔已全部改成 + * {@code update(null, wrapper)} 显式 {@code .set}。本格钉住改后的总量:再多出一处 + * {@code updateById} 就当场红,逼着先审「实体有没有 ALWAYS 字段、传的是不是新鲜实体」, + * 审过再登记基线。只报违规清零不报总量漂移的护栏,会把复发藏进平均值(B82-02 同族教训)。 + */ + @Test + void 任务行updateById写法总量棘轮_新增必须登记() { + int sites = 0; + for (Path file : mainJavaFiles()) { + for (String line : readLines(file)) { + String stripped = line.trim(); + if (isComment(stripped)) { + continue; + } + int idx = stripped.indexOf(".updateById("); + while (idx >= 0) { + sites++; + idx = stripped.indexOf(".updateById(", idx + 1); + } + } + } + assertThat(sites) + .as("updateById 写法总量偏离在册棘轮 ⇒ 要么有新写法没登记(先审 ALWAYS 抹列风险)," + + "要么有在册写点被改掉(把基线改到新值并在注释里留痕)") + .isEqualTo(REGISTERED_UPDATE_BY_ID_SITES); + } + /** 配对行必须引用同一个表达式来源,防止「写了列但写的是另一句文案的分类」。 */ private static boolean pairingIsForSameMessage(String messageLine, String categoryLine) { String messageExpr = expressionOf(messageLine, MESSAGE_SET); diff --git a/backend-java/src/test/java/com/nanri/aiimage/testutil/UpdateWrapperProbe.java b/backend-java/src/test/java/com/nanri/aiimage/testutil/UpdateWrapperProbe.java new file mode 100644 index 000000000..f98e0d33f --- /dev/null +++ b/backend-java/src/test/java/com/nanri/aiimage/testutil/UpdateWrapperProbe.java @@ -0,0 +1,156 @@ +package com.nanri.aiimage.testutil; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.nanri.aiimage.modules.task.model.entity.FileTaskEntity; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * 从 MyBatis-Plus 的 {@code update(null, wrapper)} 入参里取回「SET 了哪些列、各是什么值」(B82-01 收口配套)。 + * + *

任务行的部分字段落库已统一改成 {@code update(null, wrapper)} 显式 {@code .set}——部分实体 + * {@code updateById} 会把 {@code FieldStrategy.ALWAYS} 的 {@code failure_category} 无条件抹回 NULL。 + * mock 侧的事件捕获与假 DB 因此要从 wrapper 里取证,而不是从实体字段上读。列名与值的配对来自 + * {@code getSqlSet()} 的拼写顺序(与 {@code .set()} 调用顺序一致),值按 {@code MPGENVALn} + * 精确取键——不依赖 {@code paramNameValuePairs} 的迭代序(那是 HashMap)。 + */ +public final class UpdateWrapperProbe { + + private static final Pattern SET_ITEM = + Pattern.compile("([a-zA-Z_]+)=#\\{ew\\.paramNameValuePairs\\.(MPGENVAL\\d+)}"); + + private static final Pattern WHERE_ITEM = + Pattern.compile("([a-zA-Z_]+)\\s*=\\s*#\\{ew\\.paramNameValuePairs\\.([A-Za-z0-9]+)}"); + + private UpdateWrapperProbe() { + } + + private record SetItem(String column, Object value, String paramKey) { + } + + private static List setItems(Wrapper wrapper) { + List out = new ArrayList<>(); + String sqlSet = sqlSet(wrapper); + if (sqlSet == null || sqlSet.isBlank()) { + return out; + } + Map params = paramNameValuePairs(wrapper); + Matcher matcher = SET_ITEM.matcher(sqlSet); + while (matcher.find()) { + String paramKey = matcher.group(2); + out.add(new SetItem(matcher.group(1), params.get(paramKey), paramKey)); + } + return out; + } + + /** {@code getSqlSet()} 与 {@code getParamNameValuePairs()} 都挂在 AbstractWrapper 上,不在 Wrapper 接口。 */ + private static String sqlSet(Wrapper wrapper) { + if (wrapper instanceof com.baomidou.mybatisplus.core.conditions.AbstractWrapper abstractWrapper) { + return abstractWrapper.getSqlSet(); + } + throw new IllegalArgumentException("update(null, x) 的第二参不是 AbstractWrapper:" + wrapper.getClass()); + } + + /** {@code getParamNameValuePairs()} 挂在 {@link com.baomidou.mybatisplus.core.conditions.AbstractWrapper} 上。 */ + public static Map paramNameValuePairs(Wrapper wrapper) { + if (wrapper instanceof com.baomidou.mybatisplus.core.conditions.AbstractWrapper abstractWrapper) { + return abstractWrapper.getParamNameValuePairs(); + } + throw new IllegalArgumentException("update(null, x) 的第二参不是 AbstractWrapper:" + wrapper.getClass()); + } + + /** SET 段的「列名 → 值」,顺序与 {@code .set()} 调用顺序一致;列名一律归一成 snake_case。 */ + public static Map setValues(Wrapper wrapper) { + Map out = new LinkedHashMap<>(); + for (SetItem item : setItems(wrapper)) { + out.put(snake(item.column()), item.value()); + } + return out; + } + + /** + * 列名归一成 snake_case。单测 JVM 里 FileTaskEntity 的 Lambda 列缓存可能被先行自动初始化成 + * 驼峰(无 GlobalConfig 的裸 MybatisConfiguration 下 underCamel=false),而生产 Spring 上下文 + * 恒为下划线——探针两种都得认,否则快照结果取决于测试类的执行顺序。 + */ + private static String snake(String column) { + StringBuilder out = new StringBuilder(column.length() + 4); + for (int i = 0; i < column.length(); i++) { + char c = column.charAt(i); + if (Character.isUpperCase(c)) { + out.append('_').append(Character.toLowerCase(c)); + } else { + out.append(c); + } + } + return out.toString(); + } + + /** + * WHERE 段的「列名 → 值」(等值条件;列名归一 snake_case)。判据与仓内 + * {@code applyTaskScanFilter} 同款:直接读 {@code getSqlSegment()} 的拼写, + * 不靠 paramNameValuePairs 的键册回溯(那是 HashMap,序不可依赖)。 + */ + public static Map whereEq(Wrapper wrapper) { + Map out = new LinkedHashMap<>(); + if (!(wrapper instanceof com.baomidou.mybatisplus.core.conditions.AbstractWrapper abstractWrapper)) { + return out; + } + String segment = abstractWrapper.getSqlSegment(); + if (segment == null || segment.isBlank()) { + return out; + } + Map params = abstractWrapper.getParamNameValuePairs(); + Matcher matcher = WHERE_ITEM.matcher(segment); + while (matcher.find()) { + out.put(snake(matcher.group(1)), params.get(matcher.group(2))); + } + return out; + } + + /** WHERE 段 {@code eq(id, …)} 的值(没有 eq(id) 或值不是 Long 时返回 null)。 */ + public static Long eqId(Wrapper wrapper) { + Object value = whereEq(wrapper).get("id"); + return value instanceof Long longValue ? longValue : null; + } + + /** + * 把 SET 段按列名应用到内存实体上(假 DB 用;只认 {@code biz_file_task} 的列名)。 + * 未知列当场炸而不是静默跳过——假 DB 不认识的列会让快照测试说谎。 + */ + public static void apply(FileTaskEntity entity, Map sets) { + for (Map.Entry entry : sets.entrySet()) { + String column = entry.getKey(); + Object value = entry.getValue(); + switch (column) { + case "task_no" -> entity.setTaskNo((String) value); + case "module_type" -> entity.setModuleType((String) value); + case "task_mode" -> entity.setTaskMode((String) value); + case "collect_channel" -> entity.setCollectChannel((String) value); + case "status" -> entity.setStatus((String) value); + case "source_file_count" -> entity.setSourceFileCount((Integer) value); + case "success_file_count" -> entity.setSuccessFileCount((Integer) value); + case "failed_file_count" -> entity.setFailedFileCount((Integer) value); + case "request_json" -> entity.setRequestJson((String) value); + case "result_json" -> entity.setResultJson((String) value); + case "error_message" -> entity.setErrorMessage((String) value); + case "failure_category" -> entity.setFailureCategory((String) value); + case "created_by" -> entity.setCreatedBy((String) value); + case "user_id" -> entity.setUserId((Long) value); + case "device_id" -> entity.setDeviceId((String) value); + case "owner_instance_id" -> entity.setOwnerInstanceId((String) value); + case "updated_at" -> entity.setUpdatedAt((LocalDateTime) value); + case "finished_at" -> entity.setFinishedAt((LocalDateTime) value); + case "created_at" -> entity.setCreatedAt((LocalDateTime) value); + default -> throw new IllegalStateException("UpdateWrapperProbe 不认识的列:" + column + + "(假 DB 拒绝静默跳过——把它登记进 apply 的列册再继续)"); + } + } + } +} diff --git a/backend-java/src/test/resources/deletebrand/golden/run-snapshot.txt b/backend-java/src/test/resources/deletebrand/golden/run-snapshot.txt index 5c4600f7d..5282fe8b3 100644 --- a/backend-java/src/test/resources/deletebrand/golden/run-snapshot.txt +++ b/backend-java/src/test/resources/deletebrand/golden/run-snapshot.txt @@ -1,6 +1,6 @@ == case=main files=1 task.insert: id=1001 moduleType=DELETE_BRAND status=RUNNING taskMode=IMMEDIATE userId=7 createdBy=user:7 deviceId=dev-1 sourceFileCount=1 -task.update: id=1001 status=RUNNING sourceFileCount=1 successFileCount=1 failedFileCount=0 errorMessage=- +task.update: id=1001 status=- sourceFileCount=1 successFileCount=1 failedFileCount=0 errorMessage=- result.insert: id=2001 taskId=1001 moduleType=DELETE_BRAND sourceFileUrl=uploads/魏振峰.xlsx rowCount=4 success=0 resultFilename=- errorMessage=- vo: total=1 successCount=1 failedCount=0 item: resultId=2001 fileKey=uploads/魏振峰.xlsx shopName=魏振峰 matched=true matchStatus=MATCHED countryCount=2 totalRows=4 truncated=false success=true error=- taskStatus=RUNNING @@ -48,7 +48,7 @@ item: resultId=2001 fileKey=uploads/缺字段行.xlsx shopName=缺字段行 matc payload.files=0 == case=shopNameColumnSkipped files=1 task.insert: id=1001 moduleType=DELETE_BRAND status=RUNNING taskMode=IMMEDIATE userId=7 createdBy=user:7 deviceId=dev-1 sourceFileCount=1 -task.update: id=1001 status=RUNNING sourceFileCount=1 successFileCount=1 failedFileCount=0 errorMessage=- +task.update: id=1001 status=- sourceFileCount=1 successFileCount=1 failedFileCount=0 errorMessage=- result.insert: id=2001 taskId=1001 moduleType=DELETE_BRAND sourceFileUrl=uploads/英国.xlsx rowCount=3 success=0 resultFilename=- errorMessage=- vo: total=1 successCount=1 failedCount=0 item: resultId=2001 fileKey=uploads/英国.xlsx shopName=英国 matched=true matchStatus=MATCHED countryCount=1 totalRows=3 truncated=false success=true error=- taskStatus=RUNNING diff --git a/backend-java/src/test/resources/pricetrack/golden/create-task-snapshot.txt b/backend-java/src/test/resources/pricetrack/golden/create-task-snapshot.txt index 9821fdfa1..1aa226c7c 100644 --- a/backend-java/src/test/resources/pricetrack/golden/create-task-snapshot.txt +++ b/backend-java/src/test/resources/pricetrack/golden/create-task-snapshot.txt @@ -4,7 +4,7 @@ vo: taskId=1001 items=2 item: resultId=2002 shopName=店铺B matched=true taskStatus=RUNNING success=false vo: asinRowsByCountry=0 skipAsinsByCountry=0 minimumPriceByCountry=0 task.insert: id=1001 moduleType=PRICE_TRACK taskMode=PYTHON_QUEUE status=RUNNING sourceFileCount=2 -task.update: id=1001 status=RUNNING requestJsonHasAsinFiles=true requestJsonHasListingStatuses=true resultJsonItems=2 +task.update: id=1001 status=- requestJsonHasAsinFiles=true requestJsonHasListingStatuses=true resultJsonItems=2 result.insert: id=2001 moduleType=PRICE_TRACK sourceFilename=店铺A sourceFileUrl=shop-店铺A success=0 result.insert: id=2002 moduleType=PRICE_TRACK sourceFilename=店铺B sourceFileUrl=shop-店铺B success=0 payloadSaves=1 @@ -19,7 +19,7 @@ vo: taskId=1001 items=1 item: resultId=2001 shopName=店铺A matched=true taskStatus=RUNNING success=false vo: asinRowsByCountry=0 skipAsinsByCountry=0 minimumPriceByCountry=0 task.insert: id=1001 moduleType=PRICE_TRACK taskMode=PYTHON_QUEUE status=RUNNING sourceFileCount=1 -task.update: id=1001 status=RUNNING requestJsonHasAsinFiles=true requestJsonHasListingStatuses=true resultJsonItems=1 +task.update: id=1001 status=- requestJsonHasAsinFiles=true requestJsonHasListingStatuses=true resultJsonItems=1 result.insert: id=2001 moduleType=PRICE_TRACK sourceFilename=店铺A sourceFileUrl=shop-店铺A success=0 payloadSaves=1 payload country=FR rows=1 @@ -30,7 +30,7 @@ vo: taskId=1001 items=1 item: resultId=2001 shopName=店铺A matched=true taskStatus=RUNNING success=false vo: asinRowsByCountry=0 skipAsinsByCountry=0 minimumPriceByCountry=0 task.insert: id=1001 moduleType=PRICE_TRACK taskMode=PYTHON_QUEUE status=RUNNING sourceFileCount=1 -task.update: id=1001 status=RUNNING requestJsonHasAsinFiles=true requestJsonHasListingStatuses=true resultJsonItems=1 +task.update: id=1001 status=- requestJsonHasAsinFiles=true requestJsonHasListingStatuses=true resultJsonItems=1 result.insert: id=2001 moduleType=PRICE_TRACK sourceFilename=店铺A sourceFileUrl=shop-店铺A success=0 payloadSaves=1 heartbeatTouches=1 @@ -39,7 +39,7 @@ vo: taskId=1001 items=1 item: resultId=2001 shopName=店铺A matched=true taskStatus=RUNNING success=false vo: asinRowsByCountry=0 skipAsinsByCountry=0 minimumPriceByCountry=0 task.insert: id=1001 moduleType=PRICE_TRACK taskMode=PYTHON_QUEUE status=RUNNING sourceFileCount=1 -task.update: id=1001 status=RUNNING requestJsonHasAsinFiles=true requestJsonHasListingStatuses=true resultJsonItems=1 +task.update: id=1001 status=- requestJsonHasAsinFiles=true requestJsonHasListingStatuses=true resultJsonItems=1 result.insert: id=2001 moduleType=PRICE_TRACK sourceFilename=店铺A sourceFileUrl=shop-店铺A success=0 payloadSaves=1 payload country=UK rows=2 @@ -63,7 +63,7 @@ vo: taskId=1001 items=1 item: resultId=2001 shopName=店铺A matched=true taskStatus=RUNNING success=false vo: asinRowsByCountry=0 skipAsinsByCountry=0 minimumPriceByCountry=0 task.insert: id=1001 moduleType=PRICE_TRACK taskMode=PYTHON_QUEUE status=RUNNING sourceFileCount=1 -task.update: id=1001 status=RUNNING requestJsonHasAsinFiles=true requestJsonHasListingStatuses=true resultJsonItems=1 +task.update: id=1001 status=- requestJsonHasAsinFiles=true requestJsonHasListingStatuses=true resultJsonItems=1 result.insert: id=2001 moduleType=PRICE_TRACK sourceFilename=店铺A sourceFileUrl=shop-店铺A success=0 payloadSaves=1 payload country=UK rows=2 @@ -77,7 +77,7 @@ vo: taskId=1001 items=1 item: resultId=2001 shopName=店铺A matched=true taskStatus=RUNNING success=false vo: asinRowsByCountry=0 skipAsinsByCountry=0 minimumPriceByCountry=0 task.insert: id=1001 moduleType=PRICE_TRACK taskMode=PYTHON_QUEUE status=RUNNING sourceFileCount=1 -task.update: id=1001 status=RUNNING requestJsonHasAsinFiles=false requestJsonHasListingStatuses=true resultJsonItems=1 +task.update: id=1001 status=- requestJsonHasAsinFiles=false requestJsonHasListingStatuses=true resultJsonItems=1 result.insert: id=2001 moduleType=PRICE_TRACK sourceFilename=店铺A sourceFileUrl=shop-店铺A success=0 payloadSaves=0 heartbeatTouches=1 diff --git a/backend-java/src/test/resources/shopdatacrawl/golden/create-task-snapshot.txt b/backend-java/src/test/resources/shopdatacrawl/golden/create-task-snapshot.txt index eb538d027..621e7b350 100644 --- a/backend-java/src/test/resources/shopdatacrawl/golden/create-task-snapshot.txt +++ b/backend-java/src/test/resources/shopdatacrawl/golden/create-task-snapshot.txt @@ -7,7 +7,7 @@ events=7 taskInserts=1 resultInserts=1 heartbeatTouches=1 evt: result.insert: id=2001 taskId=1001 moduleType=SHOP_DATA_CRAWL sourceFilename=Demo Shop sourceFileUrl=shop-Demo Shop userId=7 success=-1 rowCount=- createdAtEqualsTaskCreatedAt=true evt: snapshotTable.replace: taskId=1001 items=1 evt: progressSave: taskId=1001 status=RUNNING total=1 ok=0 fail=0 - evt: task.update: id=1001 status=RUNNING ok=0 fail=0 requestJsonHasOwner=true requestJsonItems=1 resultJsonItems=1 createdAtEqualsUpdatedAt=true + evt: task.update: id=1001 status=- ok=null fail=null requestJsonHasOwner=true requestJsonItems=1 resultJsonItems=1 createdAtEqualsUpdatedAt=false evt: taskCacheSave: id=1001 == case=requestFieldsOverwrittenByMatch vo: taskId=1001 items=1 @@ -18,7 +18,7 @@ events=7 taskInserts=1 resultInserts=1 heartbeatTouches=1 evt: result.insert: id=2001 taskId=1001 moduleType=SHOP_DATA_CRAWL sourceFilename=Demo Shop sourceFileUrl=shop-Demo Shop userId=7 success=-1 rowCount=- createdAtEqualsTaskCreatedAt=true evt: snapshotTable.replace: taskId=1001 items=1 evt: progressSave: taskId=1001 status=RUNNING total=1 ok=0 fail=0 - evt: task.update: id=1001 status=RUNNING ok=0 fail=0 requestJsonHasOwner=true requestJsonItems=1 resultJsonItems=1 createdAtEqualsUpdatedAt=true + evt: task.update: id=1001 status=- ok=null fail=null requestJsonHasOwner=true requestJsonItems=1 resultJsonItems=1 createdAtEqualsUpdatedAt=false evt: taskCacheSave: id=1001 == case=twoItemsRejected thrown: BusinessException code=- message=items 必须且只能包含一个店铺 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 index 92169c03f..ac8b4a07e 100644 --- a/backend-java/src/test/resources/similarasin/golden/create-task-snapshot.txt +++ b/backend-java/src/test/resources/similarasin/golden/create-task-snapshot.txt @@ -1,7 +1,7 @@ == case: single-file task.insert: id=90001 taskNoPrefix=SIMILAR_ASIN moduleType=SIMILAR_ASIN taskMode=PYTHON_QUEUE collectChannel=- 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"} +task.update: id=90001 moduleType=- status=- 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] @@ -9,7 +9,7 @@ vo: taskId=90001 sourceFilename=one.xlsx sourceFileCount=1 totalRows=5 acceptedR == case: two-files task.insert: id=90001 taskNoPrefix=SIMILAR_ASIN moduleType=SIMILAR_ASIN taskMode=PYTHON_QUEUE collectChannel=- 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"} +task.update: id=90001 moduleType=- status=- 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]