fix(mcp): scope 绑定查找工具时兼容 soft_delete 为 NULL 的历史记录
现象:sync 作用域绑定了 4 个工具,硬件统计/设备日均/换纸明细都通了, 但 district.paper.statistics.query 仍 PERMISSION_DENIED。 原因:工具查找用 .eq(Tool::getSoftDelete, 0),而历史记录该列可能为 NULL (建表默认 0,早期插入未显式写),于是被判"工具不存在"跳过绑定。 修复:条件改为 soft_delete = 0 OR IS NULL;新增单测覆盖 NULL 场景。
This commit is contained in:
@@ -82,8 +82,12 @@ public class ScopeToolSyncService implements ApplicationRunner {
|
||||
if (toolName.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
// soft_delete 在历史数据里可能是 NULL(建表默认 0 但早期插入未写),
|
||||
// 只按 =0 过滤会把已注册的工具误判为"不存在"而跳过绑定
|
||||
// (2026-10-21 district.paper.statistics.query 即因此未绑上)。
|
||||
Tool tool = toolMapper.selectOne(new LambdaQueryWrapper<Tool>()
|
||||
.eq(Tool::getName, toolName).eq(Tool::getSoftDelete, 0));
|
||||
.eq(Tool::getName, toolName)
|
||||
.and(w -> w.eq(Tool::getSoftDelete, 0).or().isNull(Tool::getSoftDelete)));
|
||||
if (tool == null) {
|
||||
log.warn("scope-tool binding 跳过:工具不存在 name={}", toolName);
|
||||
skipped++;
|
||||
|
||||
Reference in New Issue
Block a user