QA 巡检修复:report 兜底端点 404 + 引擎异常裸 500 → 优雅化

运行时 API 抽样(46 页分层)发现 LIST_API_ERROR 一类,两个根因:

1) report 无 selectservice 时,转换器兜底 api=/api/report/{entityId}/list —— 此端点不存在(404),
   12 个报表页列表崩。改:兜底用合成搜索流 /api/flow/{TABLE}_SEARCH(列实体行;真聚合报表
   JOR/C 类仍待 univer 方案)。entityId 已 resolveTableName→表名。实证 063fdf2a 由 404 →
   /api/flow/PM_PROJECTCOSTSPLIT_SEARCH。

2) 部分实体已登记 SYS_ENTITY 但物理表/视图在当前库缺失(VIEW_*/VM_* 报表视图,生产库存在、
   dev 副本未建)→ 合成 _SEARCH 触发 SQL 异常直冒 Spring 裸 500,amis crud 崩。改:FlowController
   executeGet/Post 兜 RuntimeException → 200+{status:1,msg:友好,data:{}},前端显提示不崩。
   写流回滚在引擎 @Transactional 边界已完成,此兜底仅兜响应不影响回滚。

验证:converter 60 测 + FlowController 26 测过(新增 report兜底_SEARCH、引擎异常优雅 两测);
重转+重导入 sys_page_schema(更新 454);运行时 VIEW_JGGL_SEARCH 由 500 → 200+status:1,
report 063fdf2a → _SEARCH。重扫:46 页样本无裸 500/404,余 10 为 dev 库缺视图(physical=0,
生产存在),已优雅降级,非产品缺陷。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-13 19:39:06 +08:00
parent 012ab211a1
commit e6054a376b
5 changed files with 82 additions and 16 deletions

View File

@@ -952,7 +952,7 @@ public class TemplateToAmisConverter {
: UiTypeMapper.firstNonBlank(report.attributeValue("title"),
attrOf(report.element("search"), "reporttitle"), "报表");
String entityId = report.attributeValue("entityid", "");
resolveTableName(entityId, result);
String reportTable = resolveTableName(entityId, result);
// display → columns(含 ismoney/issummer 合计列)
Element display = report.element("display");
@@ -980,9 +980,16 @@ public class TemplateToAmisConverter {
crudSchema.put("api", "/api/flow/" + selectservice + "?page=${page}&perPage=${perPage}");
result.note("report@search selectservice=" + selectservice + " → crud api /api/flow/" + selectservice
+ "(服务流 REST 化,报表迁移方案 D 节)");
} else if (reportTable != null && !reportTable.isBlank()) {
// report 无 selectservice → 兜底合成搜索流(列出实体行)。原 /api/report/{id}/list 是不存在的
// 占位端点(404),改用 _SEARCH 至少出数据。真聚合报表(JOR/C 类)仍待 univer 方案(§4.2 报表)。
crudSchema.put("api", "/api/flow/" + reportTable.toUpperCase()
+ "_SEARCH?page=${page}&perPage=${perPage}");
result.degrade("report 无 selectservice → 兜底合成搜索流 /api/flow/" + reportTable.toUpperCase()
+ "_SEARCH(列实体行;真聚合报表[JOR/C 类]待 univer 方案)");
} else {
crudSchema.put("api", "/api/report/" + entityId + "/list");
result.degrade("report 无 selectservice → 兜底 api /api/report,数据源待补");
result.degrade("report 无 selectservice 且实体表未解析 → 兜底 /api/report,数据源待补");
}
crudSchema.put("syncLocation", false);
if (filter != null) {

View File

@@ -231,6 +231,22 @@ class TemplateToAmisConverterTest {
assertNull(year.get("source"), "年/月用内建 options 而非 source");
}
@Test
@SuppressWarnings("unchecked")
void report无selectservice兜底合成搜索流而非不存在的apiReport() throws Exception {
// QA 巡检:report 无 selectservice 时,旧兜底 /api/report/{id}/list 是不存在端点(404)。
// 改兜底合成搜索流 /api/flow/{TABLE}_SEARCH(列实体行)。
TemplateToAmisConverter c = converterWithMeta(new String[0][], new String[0][]); // queryForObject→PM_DEMO
String xml = "<report title='X' entityid='e1'><display><field name='A' text='A'/></display>"
+ "<search></search></report>";
ConversionResult r = c.convertGraded(xml, new ArrayList<>(), noPage);
Map<String, Object> crud = body(r.getSchema());
String api = (String) crud.get("api");
assertTrue(api.startsWith("/api/flow/") && api.contains("_SEARCH"),
"report 无 selectservice 应兜底 _SEARCH,实际: " + api);
assertFalse(api.contains("/api/report/"), "不应再用不存在的 /api/report 占位端点");
}
@Test
void crud_button删除转ajax() {
String xml = "<crud entityid='e1'><display/>"