TreeGrid 树模板渲染:运行时构树端点 + 左树右表联动(QA 剩余成规模代码缺口)
106 个 tree 模板此前转换成占位 input-tree + 不存在的 /api/template/{id}/tree|list 端点
(404/400),左树右表全不可用。本次打通:
后端 TemplateTreeController(新)— GET /api/template/{treetemplateRef}/tree:
- 解析树模板 XML(<node>+<nextnodes><levelnode entityid parentid>),按"全层级行装进单一
id→节点映射、按各级 parentid 列值链父"的算法构嵌套树——支持自嵌套(PARENTID)与跨实体
(如分类→事件 MEMORABILIASORTID)。display 取 isentitydisplay 列、value=原始主键(供右表过滤)、
节点封顶 5000、标识符 IDENT 守卫。返 amis input-tree options。
转换器 convertTreeGrid:
- 左树 source=/api/template/{ref}/tree(运行时构树),onEvent.change→reload 右表。
- 右表改用合成搜索流 /api/flow/{gridTable}_SEARCH?{rcol}=${tree}(复用既有、按选中树节点过滤;
原 /api/template/{id}/list 是不存在端点)。右表列取自 gridtemplate 引用模板的 <display>
(loadRefDisplayColumns 跨模板只读 1 次,仅列定义)。
- 布局修正:flex/items 误用 → grid/columns({md,body} 是 grid 栅格格式,flex 会「找不到渲染器」)。
验证:converter 60 测过;运行时 /api/template/{大事记分类树}/tree 返 4 分类×事件子节点正确层级;
浏览器(查看大事记管理)左树渲染分类层级 + 右表列出,点叶子节点 onEvent 触发右表
reload 携 EVENTID=节点 UUID。重转后分级 SUCCESS 283→328(tree 模板升级)。已重导入 sys_page_schema。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -913,35 +913,91 @@ public class TemplateToAmisConverter {
|
|||||||
|
|
||||||
private Map<String, Object> convertTreeGrid(Element tree, Element treeTemplate, Element gridTemplate,
|
private Map<String, Object> convertTreeGrid(Element tree, Element treeTemplate, Element gridTemplate,
|
||||||
ConversionResult result, String templateName) {
|
ConversionResult result, String templateName) {
|
||||||
|
final String gridCrudId = "treegrid_crud";
|
||||||
Map<String, Object> treeSchema = new LinkedHashMap<>();
|
Map<String, Object> treeSchema = new LinkedHashMap<>();
|
||||||
treeSchema.put("type", "input-tree");
|
treeSchema.put("type", "input-tree");
|
||||||
treeSchema.put("name", "tree");
|
treeSchema.put("name", "tree");
|
||||||
|
treeSchema.put("showOutline", true);
|
||||||
|
treeSchema.put("initiallyOpen", true);
|
||||||
if (treeTemplate != null) {
|
if (treeTemplate != null) {
|
||||||
String ref = treeTemplate.attributeValue("ref", "");
|
String ref = treeTemplate.attributeValue("ref", "");
|
||||||
|
if (!ref.isBlank()) {
|
||||||
treeSchema.put("source", "/api/template/" + ref + "/tree");
|
treeSchema.put("source", "/api/template/" + ref + "/tree");
|
||||||
result.degrade("tree+grid: treetemplate ref=" + ref + " → 跨模板引用,树数据源 /api/template 待联动");
|
// 选中树节点 → 重载右表(${tree} 进右表 api 过滤);TemplateTreeController 运行时构树
|
||||||
|
treeSchema.put("onEvent", new LinkedHashMap<>(Map.of(
|
||||||
|
"change", Map.of("actions", List.of(
|
||||||
|
new LinkedHashMap<>(Map.of("actionType", "reload", "componentId", gridCrudId)))))));
|
||||||
|
result.note("tree+grid: treetemplate ref=" + ref
|
||||||
|
+ " → input-tree source /api/template/" + ref + "/tree(运行时构树)+ 选中重载右表");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Map<String, Object> gridSchema = new LinkedHashMap<>();
|
Map<String, Object> gridSchema = new LinkedHashMap<>();
|
||||||
gridSchema.put("type", "crud");
|
gridSchema.put("type", "crud");
|
||||||
|
gridSchema.put("id", gridCrudId);
|
||||||
|
gridSchema.put("syncLocation", false);
|
||||||
|
List<Map<String, Object>> gridCols = new ArrayList<>();
|
||||||
if (gridTemplate != null) {
|
if (gridTemplate != null) {
|
||||||
String ref = gridTemplate.attributeValue("ref", "");
|
String ref = gridTemplate.attributeValue("ref", "");
|
||||||
String rcol = gridTemplate.attributeValue("rcolumnname", "");
|
String rcol = gridTemplate.attributeValue("rcolumnname", "");
|
||||||
gridSchema.put("api", "/api/template/" + ref + "/list?" + rcol + "=${tree}");
|
String gridEntityId = gridTemplate.attributeValue("entityid", "");
|
||||||
result.degrade("tree+grid: gridtemplate ref=" + ref + "(rcolumn=" + rcol
|
String gridTable = resolveTableName(gridEntityId, result);
|
||||||
+ ") → 跨模板引用,右侧列表数据源待联动");
|
if (gridTable != null && !gridTable.isBlank() && !rcol.isBlank()) {
|
||||||
|
// 右表复用合成搜索流(已存在、可用),按选中树节点值过滤;原 /api/template/{id}/list 是不存在端点(404)
|
||||||
|
gridSchema.put("api", "/api/flow/" + gridTable.toUpperCase() + "_SEARCH?"
|
||||||
|
+ rcol + "=${tree}&page=${page}&perPage=${perPage}");
|
||||||
|
result.note("tree+grid: gridtemplate 实体=" + gridTable + " rcolumn=" + rcol
|
||||||
|
+ " → 右表 /api/flow/" + gridTable.toUpperCase() + "_SEARCH?" + rcol + "=${tree}(合成搜索流按树节点过滤)");
|
||||||
|
} else {
|
||||||
|
result.degrade("tree+grid: gridtemplate 实体/rcolumn 解析失败(entityid=" + gridEntityId
|
||||||
|
+ ",rcol=" + rcol + ") → 右表数据源缺");
|
||||||
}
|
}
|
||||||
gridSchema.put("columns", new ArrayList<>());
|
// 右表列取自 gridtemplate 引用模板的 <display>(跨模板读 1 次,仅为列定义)
|
||||||
|
List<Map<String, Object>> refCols = loadRefDisplayColumns(ref, gridEntityId, result);
|
||||||
|
if (refCols != null && !refCols.isEmpty()) {
|
||||||
|
gridCols = refCols;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gridSchema.put("columns", gridCols);
|
||||||
|
|
||||||
|
// amis grid(12 栅格):左树 3 列、右表 9 列。{md,body} 是 grid.columns 格式
|
||||||
|
// (非 flex.items——flex 的 items 必须是渲染器本身,误用会「找不到对应的渲染器」)。
|
||||||
Map<String, Object> hbox = new LinkedHashMap<>();
|
Map<String, Object> hbox = new LinkedHashMap<>();
|
||||||
hbox.put("type", "flex");
|
hbox.put("type", "grid");
|
||||||
hbox.put("items", List.of(
|
hbox.put("columns", List.of(
|
||||||
Map.of("md", 3, "body", treeSchema),
|
new LinkedHashMap<>(Map.of("md", 3, "body", treeSchema)),
|
||||||
Map.of("md", 9, "body", gridSchema)));
|
new LinkedHashMap<>(Map.of("md", 9, "body", gridSchema))));
|
||||||
// F2-13:title 优先取 view_template.name
|
// F2-13:title 优先取 view_template.name
|
||||||
String treeGridTitle = templateName != null ? templateName : "树+列表";
|
String treeGridTitle = templateName != null ? templateName : "树+列表";
|
||||||
return page(treeGridTitle, hbox);
|
return page(treeGridTitle, hbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取 gridtemplate 引用模板(另一 view_template)的 {@code <display>} 列定义(TreeGrid 右表列)。
|
||||||
|
* 跨模板只读 1 次 XML、仅为列定义(列数据仍走 _SEARCH 运行时),不深化 XML 耦合。失败返 null。
|
||||||
|
*/
|
||||||
|
private List<Map<String, Object>> loadRefDisplayColumns(String ref, String entityId, ConversionResult result) {
|
||||||
|
if (ref == null || ref.isBlank()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
List<String> xmls = jdbcTemplate.queryForList(
|
||||||
|
"SELECT xml::text FROM VIEW_TEMPLATE WHERE VIEW_TEMPLATE_ID=? AND xml IS NOT NULL",
|
||||||
|
String.class, ref);
|
||||||
|
if (xmls.isEmpty() || xmls.get(0) == null || xmls.get(0).isBlank()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Document doc = DocumentHelper.parseText(xmls.get(0).trim());
|
||||||
|
Element display = doc.getRootElement().element("display");
|
||||||
|
if (display == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return buildColumns(display, entityId, result);
|
||||||
|
} catch (Exception e) {
|
||||||
|
result.note("tree+grid: 取右表列失败 ref=" + ref + ": " + safeMsg(e));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ──────────────────────────────────────────────────────────────────────
|
// ──────────────────────────────────────────────────────────────────────
|
||||||
// report(A 类表格式报表)—— 报表迁移方案口径
|
// report(A 类表格式报表)—— 报表迁移方案口径
|
||||||
// ──────────────────────────────────────────────────────────────────────
|
// ──────────────────────────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -401,14 +401,28 @@ class TemplateToAmisConverterTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void tree_treeGrid引用式() {
|
@SuppressWarnings("unchecked")
|
||||||
|
void tree_treeGrid引用式() throws Exception {
|
||||||
|
// TreeGrid:左 input-tree 走 /api/template/{ref}/tree(运行时构树),右 crud 走合成 _SEARCH
|
||||||
|
// 按 rcolumn 过滤,选中树节点 onEvent 重载右表。converterWithMeta 使 resolveTableName→PM_DEMO。
|
||||||
|
TemplateToAmisConverter c = converterWithMeta(new String[0][], new String[0][]);
|
||||||
String xml = "<tree>"
|
String xml = "<tree>"
|
||||||
+ "<treetemplate ref='t1' entityid='e1'/>"
|
+ "<treetemplate ref='t1' entityid='e1'/>"
|
||||||
+ "<gridtemplate ref='g1' entityid='e2' rcolumnname='EVENTID'/></tree>";
|
+ "<gridtemplate ref='g1' entityid='e2' rcolumnname='EVENTID'/></tree>";
|
||||||
ConversionResult r = converter.convertGraded(xml, new ArrayList<>(), noPage);
|
ConversionResult r = c.convertGraded(xml, new ArrayList<>(), noPage);
|
||||||
Map<String, Object> root = body(r.getSchema());
|
Map<String, Object> root = body(r.getSchema());
|
||||||
assertEquals("flex", root.get("type"));
|
assertEquals("grid", root.get("type")); // amis grid 栅格(非 flex)
|
||||||
assertEquals(ConversionGrade.PARTIAL, r.getGrade()); // 跨模板引用 → 降级
|
List<Map<String, Object>> cols = (List<Map<String, Object>>) root.get("columns");
|
||||||
|
Map<String, Object> treeItem = (Map<String, Object>) cols.get(0).get("body");
|
||||||
|
Map<String, Object> gridItem = (Map<String, Object>) cols.get(1).get("body");
|
||||||
|
assertEquals("input-tree", treeItem.get("type"));
|
||||||
|
assertEquals("/api/template/t1/tree", treeItem.get("source"));
|
||||||
|
assertNotNull(treeItem.get("onEvent"), "选中树节点应触发右表重载");
|
||||||
|
assertEquals("crud", gridItem.get("type"));
|
||||||
|
String api = (String) gridItem.get("api");
|
||||||
|
assertTrue(api.startsWith("/api/flow/PM_DEMO_SEARCH?EVENTID=${tree}"),
|
||||||
|
"右表应走合成搜索流按 rcol 过滤,实际: " + api);
|
||||||
|
assertFalse(api.contains("/api/template/"), "不应再用不存在的 /api/template/list 端点");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── report (A 类) ────────────────────────────────────────────────────
|
// ── report (A 类) ────────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -907,51 +907,51 @@ f359a080-6f0a-4026-9c33-6dcd9d62b31a,通知收藏分类,3,tree,PARTIAL,true,3,fa
|
|||||||
f91a6d73-ac2a-44f8-bd4f-697569c87364,用品类别,3,tree,PARTIAL,true,4,false,转换器缺陷:tree@node 含 buttons(增删改保存) → input-tree 不原生支持节点级按钮,需自定义工具栏
|
f91a6d73-ac2a-44f8-bd4f-697569c87364,用品类别,3,tree,PARTIAL,true,4,false,转换器缺陷:tree@node 含 buttons(增删改保存) → input-tree 不原生支持节点级按钮,需自定义工具栏
|
||||||
fc6cf547-5739-4c57-b41d-3df1a84ea47b,费率组,3,tree,PARTIAL,true,4,false,转换器缺陷:tree@node 含 buttons(增删改保存) → input-tree 不原生支持节点级按钮,需自定义工具栏
|
fc6cf547-5739-4c57-b41d-3df1a84ea47b,费率组,3,tree,PARTIAL,true,4,false,转换器缺陷:tree@node 含 buttons(增删改保存) → input-tree 不原生支持节点级按钮,需自定义工具栏
|
||||||
fdd10db0-963d-4e67-bf2a-584ba48fca33,物资分类,3,tree,PARTIAL,true,4,false,转换器缺陷:tree@node 含 buttons(增删改保存) → input-tree 不原生支持节点级按钮,需自定义工具栏
|
fdd10db0-963d-4e67-bf2a-584ba48fca33,物资分类,3,tree,PARTIAL,true,4,false,转换器缺陷:tree@node 含 buttons(增删改保存) → input-tree 不原生支持节点级按钮,需自定义工具栏
|
||||||
19e418d1-ea62-47c1-9fb4-c33f94c306c4,档案维护,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=5ff68003-e790-40e9-be37-46f33ce62a9c → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=ea698b19-c8b2-437f-8f88-5451e835a89e(rcolumn=FILEID) → 跨模板引用,右侧列表数据源待联动
|
19e418d1-ea62-47c1-9fb4-c33f94c306c4,档案维护,4,tree,SUCCESS,true,4,false,
|
||||||
1b7af860-f11d-4b64-931c-13264207d57c,查阅档案,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=a0fcb9f6-518d-4784-b775-c1a43eb450e5 → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=30faea2c-95f0-4685-b3e8-358e6b73ab41(rcolumn=FILEID) → 跨模板引用,右侧列表数据源待联动
|
1b7af860-f11d-4b64-931c-13264207d57c,查阅档案,4,tree,SUCCESS,true,6,false,
|
||||||
21d82b1c-1db0-499a-b2c7-48befd42a9d7,质量管理-知识库,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=58560483-3405-4e42-a7af-5bdbc99c7d7f → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=49054275-964d-49c7-820a-d6a0fa944d9e(rcolumn=LIBRARYID) → 跨模板引用,右侧列表数据源待联动
|
21d82b1c-1db0-499a-b2c7-48befd42a9d7,质量管理-知识库,4,tree,SUCCESS,true,9,false,
|
||||||
22786b70-5802-40ff-8fad-c1bd9b12ea8c,通知收藏,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=f359a080-6f0a-4026-9c33-6dcd9d62b31a → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=22f31c98-4054-4d96-87af-e5fb75d5a246(rcolumn=COLLECTTYPE_ID) → 跨模板引用,右侧列表数据源待联动
|
22786b70-5802-40ff-8fad-c1bd9b12ea8c,通知收藏,4,tree,SUCCESS,true,7,false,
|
||||||
28807c26-61fa-467e-88fa-d797fb8b580d,材料信息库选择框(可添加新材料),4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=2bbaa367-f054-480d-bb06-e81bf9a892a6 → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=5441d42f-2769-450b-b4fd-b52e60584341(rcolumn=RESOURCETYPEID) → 跨模板引用,右侧列表数据源待联动
|
28807c26-61fa-467e-88fa-d797fb8b580d,材料信息库选择框(可添加新材料),4,tree,SUCCESS,true,9,false,
|
||||||
2a863c20-3d71-4481-9eb3-846b1a1d28e2,用品档案,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=f91a6d73-ac2a-44f8-bd4f-697569c87364 → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=98f89c49-e242-46c4-aab6-774fa79a9328(rcolumn=GOODSSORT_ID) → 跨模板引用,右侧列表数据源待联动
|
2a863c20-3d71-4481-9eb3-846b1a1d28e2,用品档案,4,tree,SUCCESS,true,8,false,
|
||||||
2ae58883-090f-415a-a64c-735ea21fca24,材料信息库管理,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=fdd10db0-963d-4e67-bf2a-584ba48fca33 → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=1d3c0d8c-b74b-45f4-87c4-79ff17fdd180(rcolumn=RESOURCETYPEID) → 跨模板引用,右侧列表数据源待联动
|
2ae58883-090f-415a-a64c-735ea21fca24,材料信息库管理,4,tree,SUCCESS,true,7,false,
|
||||||
360fe5ce-b2dd-4546-abd8-8bc6815cf7d3,枚举项,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=b114351f-2a16-4e98-937a-07e973b85c1e → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=ddb51949-e2a1-4a9d-b936-48609473755a(rcolumn=SYS_ENUMERATETYPE_ID) → 跨模板引用,右侧列表数据源待联动
|
360fe5ce-b2dd-4546-abd8-8bc6815cf7d3,枚举项,4,tree,SUCCESS,true,5,false,
|
||||||
370be16b-b9f0-41d7-a5d6-f764634df5ba,清单费率组配置,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=fc6cf547-5739-4c57-b41d-3df1a84ea47b → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=4fbeee32-c713-4ff1-aafa-a1d709ba61d2(rcolumn=FEERATEGROUPID) → 跨模板引用,右侧列表数据源待联动
|
370be16b-b9f0-41d7-a5d6-f764634df5ba,清单费率组配置,4,tree,SUCCESS,true,17,false,
|
||||||
3acc8bb1-f787-4968-88cf-121fbd30b292,公司危险源,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=82b68117-5b61-4c9f-b188-4592782af30b → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=ee3ba981-218a-4e66-9dfd-6ebc312dab37(rcolumn=DANGERID) → 跨模板引用,右侧列表数据源待联动
|
3acc8bb1-f787-4968-88cf-121fbd30b292,公司危险源,4,tree,SUCCESS,true,8,false,
|
||||||
3ecf2a40-2798-489d-b6b7-911ef8429e84,网络文件柜共享内容,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=ac0106ec-21b3-4554-adf0-6f5607ede095 → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=6a13c1dc-2be3-4c2d-babe-97b1f194ea80(rcolumn=FOLDERID) → 跨模板引用,右侧列表数据源待联动
|
3ecf2a40-2798-489d-b6b7-911ef8429e84,网络文件柜共享内容,4,tree,SUCCESS,true,7,false,
|
||||||
4403b15f-ec3e-4dfd-8792-0e3ef071485d,招聘管理-指标管理,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=52ed0153-bd30-4e84-806e-94c91fca37bb → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=ede36445-8b25-48fd-acc8-7c7c78f8dc33(rcolumn=CATEGROY) → 跨模板引用,右侧列表数据源待联动
|
4403b15f-ec3e-4dfd-8792-0e3ef071485d,招聘管理-指标管理,4,tree,SUCCESS,true,6,false,
|
||||||
50ac13b2-42e8-4533-9541-ce2512e579e3,新闻收藏,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=a763d48d-89a5-466e-9e3b-9977054023b1 → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=7f9c9266-47a7-4ef1-95b3-327e1de7312f(rcolumn=COLLECTTYPE_ID) → 跨模板引用,右侧列表数据源待联动
|
50ac13b2-42e8-4533-9541-ce2512e579e3,新闻收藏,4,tree,SUCCESS,true,12,false,
|
||||||
54b5e23b-5dc1-4821-9ffb-71306245a822,供应材料历史成交价格(土建),4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=fdd10db0-963d-4e67-bf2a-584ba48fca33 → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=1bb942c4-e5cd-405c-96e8-acc26754e39d(rcolumn=RESOURCETYPEID) → 跨模板引用,右侧列表数据源待联动
|
54b5e23b-5dc1-4821-9ffb-71306245a822,供应材料历史成交价格(土建),4,tree,SUCCESS,true,11,false,
|
||||||
56d4bba4-d9d7-4a89-9d4a-22941c046af8,资料库,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=c93e813f-150a-491e-a440-4e5b733989ad → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=c1e1c114-1ac5-4a9b-acf7-ca747087a61c(rcolumn=FOLDERID) → 跨模板引用,右侧列表数据源待联动
|
56d4bba4-d9d7-4a89-9d4a-22941c046af8,资料库,4,tree,SUCCESS,true,10,false,
|
||||||
642ac525-b40c-43c2-b826-42f4e6e432be,实体排序,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=e6b69e2d-a8ab-49e9-8d79-e2bc4f2f45fd → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=1c40364e-a252-4c03-8815-b17233bd38d6(rcolumn=SYS_ENTITYTYPE) → 跨模板引用,右侧列表数据源待联动
|
642ac525-b40c-43c2-b826-42f4e6e432be,实体排序,4,tree,SUCCESS,true,5,false,
|
||||||
67a54e0e-e386-450f-9e5f-2507abe284c7,安全管理-知识库,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=739a2949-a021-4757-94d1-b6c416b803af → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=22fee249-2e94-4c18-81a0-55063830877e(rcolumn=LIBRARYID) → 跨模板引用,右侧列表数据源待联动
|
67a54e0e-e386-450f-9e5f-2507abe284c7,安全管理-知识库,4,tree,SUCCESS,true,9,false,
|
||||||
6d149867-eb1b-4593-8878-d30d48f97195,图片管理-公司,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=3a5efa11-2b6b-43d8-aceb-c4e34f3b06e7 → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=62773567-6113-42da-96c5-fbffa76751e7(rcolumn=FOLDERID) → 跨模板引用,右侧列表数据源待联动
|
6d149867-eb1b-4593-8878-d30d48f97195,图片管理-公司,4,tree,SUCCESS,true,16,false,
|
||||||
6e4f6c96-eb0c-44bd-b4e0-fd817bb10c83,机械信息库,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=814d3da1-b354-4cd7-9ca5-e54e74849358 → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=433f6b07-06a7-482f-90c5-cb7aa6a5d252(rcolumn=RESOURCETYPEID) → 跨模板引用,右侧列表数据源待联动
|
6e4f6c96-eb0c-44bd-b4e0-fd817bb10c83,机械信息库,4,tree,SUCCESS,true,6,false,
|
||||||
743c2f4d-df7f-4886-9415-71a173dbaeac,材料信息库选择框(可添加新材料)-废品材料,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=7fba974a-c980-45df-b56a-08e29e39277e → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=f7bebd80-f7bb-4a37-aa8e-1cb52d1866e9(rcolumn=RESOURCETYPEID) → 跨模板引用,右侧列表数据源待联动
|
743c2f4d-df7f-4886-9415-71a173dbaeac,材料信息库选择框(可添加新材料)-废品材料,4,tree,SUCCESS,true,9,false,
|
||||||
75079e3d-80f6-4829-9428-f5efc3b5403f,大事记事件管理,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=09f5fb86-5ea4-46e4-91c4-26115216129c → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=84c5abcf-f59e-4c7e-b2de-00ab75fee762(rcolumn=MEMORABILIASORTID) → 跨模板引用,右侧列表数据源待联动
|
75079e3d-80f6-4829-9428-f5efc3b5403f,大事记事件管理,4,tree,SUCCESS,true,7,false,
|
||||||
76ff564a-c318-4fee-8f74-71ae1fd911f6,服务配置,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=66a0376f-d314-46b4-a47b-d8b4526d2293 → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=ad7849ec-e46c-499f-b8db-17b1f985fe14(rcolumn=ENTITYID) → 跨模板引用,右侧列表数据源待联动
|
76ff564a-c318-4fee-8f74-71ae1fd911f6,服务配置,4,tree,SUCCESS,true,6,false,
|
||||||
7a1e59ad-372a-4919-aa7f-74255e246d6b,查看大事记管理,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=e26ea392-8001-46c5-b554-56b3d686a7af → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=21e8c5e9-7853-4466-828b-1d16bb774ffe(rcolumn=EVENTID) → 跨模板引用,右侧列表数据源待联动
|
7a1e59ad-372a-4919-aa7f-74255e246d6b,查看大事记管理,4,tree,SUCCESS,true,11,false,
|
||||||
81266f2b-661e-43ad-9fb6-f050cfe9cd3c,岗位管理,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=a53e2aab-5fd5-4362-944e-9d5f64fdc20e → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=a7974378-73e4-4daa-95cf-c2ea37cdf5ab(rcolumn=POSITIONID) → 跨模板引用,右侧列表数据源待联动
|
81266f2b-661e-43ad-9fb6-f050cfe9cd3c,岗位管理,4,tree,SUCCESS,true,7,false,
|
||||||
839671be-a53e-4f59-9e9a-5c1f56e8f382,验工月报导入,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=4f81df00-5629-47e8-a991-ac40389f6b9e → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=bca132d1-48c5-4b53-924b-9e61a68a7c4d(rcolumn=MREPORTINTERVALID) → 跨模板引用,右侧列表数据源待联动
|
839671be-a53e-4f59-9e9a-5c1f56e8f382,验工月报导入,4,tree,SUCCESS,true,7,false,
|
||||||
8ad90753-a4a9-417f-a476-1ac44649e079,绩效管理-指标管理,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=082f27b4-7ae9-4b21-acc9-2b2a6f7d9797 → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=36a0ceaa-001b-4a05-a709-8e6659d1d5e3(rcolumn=CATEGORY) → 跨模板引用,右侧列表数据源待联动
|
8ad90753-a4a9-417f-a476-1ac44649e079,绩效管理-指标管理,4,tree,SUCCESS,true,5,false,
|
||||||
8b89fd29-8338-4c0f-94fe-6f81da2b0410,功能管理,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=e6b69e2d-a8ab-49e9-8d79-e2bc4f2f45fd → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=a1002c5c-7496-4227-98a9-8aebd2cdeb91(rcolumn=ENTITYTYPE) → 跨模板引用,右侧列表数据源待联动
|
8b89fd29-8338-4c0f-94fe-6f81da2b0410,功能管理,4,tree,SUCCESS,true,7,false,
|
||||||
8b968e9c-15c8-462c-b4d7-3517c671882d,总包合同登记(五建定制),4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=6fa33eab-c45e-4fcd-82fa-32c8e090475f → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=09aaa5dd-56d3-4364-a5ad-e77480d4d0a9(rcolumn=ENGINEERINGSCALE) → 跨模板引用,右侧列表数据源待联动
|
8b968e9c-15c8-462c-b4d7-3517c671882d,总包合同登记(五建定制),4,tree,SUCCESS,true,20,false,
|
||||||
8deb8967-9ad1-45c6-a210-e6a1fc49f3f7,档案中心-管理,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=9816262d-53c7-425a-b4c9-eb46007a8e1a → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=ea698b19-c8b2-437f-8f88-5451e835a89e(rcolumn=FILEID) → 跨模板引用,右侧列表数据源待联动
|
8deb8967-9ad1-45c6-a210-e6a1fc49f3f7,档案中心-管理,4,tree,SUCCESS,true,4,false,
|
||||||
a716324f-8386-46d7-8ef3-f9bc4d05d6ac,指定清单分类,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=406da8dd-aca2-488f-8e9d-fd3f975c2dd8 → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=b1f65661-e884-4a97-b581-13e99996e42a(rcolumn=PROJECTLISTSORTID) → 跨模板引用,右侧列表数据源待联动
|
a716324f-8386-46d7-8ef3-f9bc4d05d6ac,指定清单分类,4,tree,SUCCESS,true,7,false,
|
||||||
bad92259-1092-4c46-a331-16530d06fa2a,分公司岗位管理,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=8570bf9d-0f18-45bf-865e-6e4e93a51e77 → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=a7974378-73e4-4daa-95cf-c2ea37cdf5ab(rcolumn=POSITIONID) → 跨模板引用,右侧列表数据源待联动
|
bad92259-1092-4c46-a331-16530d06fa2a,分公司岗位管理,4,tree,SUCCESS,true,7,false,
|
||||||
c6809415-1f0e-4852-9fdd-5422422b000e,实体配置,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=e6b69e2d-a8ab-49e9-8d79-e2bc4f2f45fd → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=b4154b1f-3f27-4b0a-854d-6be2deea4b38(rcolumn=ENTITYTYPE) → 跨模板引用,右侧列表数据源待联动
|
c6809415-1f0e-4852-9fdd-5422422b000e,实体配置,4,tree,SUCCESS,true,13,false,
|
||||||
d7e12a83-904d-42ed-ae05-39a83bee8c76,视图管理,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=e6b69e2d-a8ab-49e9-8d79-e2bc4f2f45fd → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=15fcc491-74e1-422a-862b-ebe027ba8bd7(rcolumn=ENTITYTYPE) → 跨模板引用,右侧列表数据源待联动
|
d7e12a83-904d-42ed-ae05-39a83bee8c76,视图管理,4,tree,SUCCESS,true,3,false,
|
||||||
d99b5760-ce63-4e15-aa5d-05430cc25d10,定义定时任务,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=e6b69e2d-a8ab-49e9-8d79-e2bc4f2f45fd → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=b3ba3d9d-0158-4bee-8f61-2426382f4c69(rcolumn=ENTITYTYPE) → 跨模板引用,右侧列表数据源待联动
|
d99b5760-ce63-4e15-aa5d-05430cc25d10,定义定时任务,4,tree,SUCCESS,true,4,false,
|
||||||
db5da6c5-69ad-4269-9e45-5c151a15ffdd,公告收藏,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=6ac79ba5-08bf-49fa-b15b-03f0e30767d0 → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=8b381e83-d454-4e63-b9bf-3ffa7044f3ff(rcolumn=COLLECTTYPE_ID) → 跨模板引用,右侧列表数据源待联动
|
db5da6c5-69ad-4269-9e45-5c151a15ffdd,公告收藏,4,tree,SUCCESS,true,8,false,
|
||||||
de7c8e28-c910-4553-9ad0-d53fddcdf93e,图片管理-资料员,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=3a5efa11-2b6b-43d8-aceb-c4e34f3b06e7 → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=6704b839-cf20-4407-8cea-92039a440977(rcolumn=FOLDERID) → 跨模板引用,右侧列表数据源待联动
|
de7c8e28-c910-4553-9ad0-d53fddcdf93e,图片管理-资料员,4,tree,SUCCESS,true,17,false,
|
||||||
df32c567-72ca-4545-84c4-fe86852755ec,个人文件柜,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=40cb8b6f-cd9b-4077-ba4a-5b7045b8ecdd → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=ef8b6543-87cc-49cc-b617-f24dd65f55e8(rcolumn=FOLDERID) → 跨模板引用,右侧列表数据源待联动
|
df32c567-72ca-4545-84c4-fe86852755ec,个人文件柜,4,tree,SUCCESS,true,7,false,
|
||||||
dfe0c40e-2ce2-4272-b18d-067611a9ac22,总包合同评审(五建定制),4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=6fa33eab-c45e-4fcd-82fa-32c8e090475f → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=18fb15c9-160d-4bc3-b013-859d793ac8ba(rcolumn=ENGINEERINGSCALE) → 跨模板引用,右侧列表数据源待联动
|
dfe0c40e-2ce2-4272-b18d-067611a9ac22,总包合同评审(五建定制),4,tree,SUCCESS,true,24,false,
|
||||||
e214cc65-4d5c-4927-8014-936ca6a689a7,材料信息库选择框(可添加新材料)-招待物资,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=6876297b-7193-4e19-aa6e-89a639ce55ba → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=05e99b05-2362-4c16-b905-ae9f6b3750b9(rcolumn=RESOURCETYPEID) → 跨模板引用,右侧列表数据源待联动
|
e214cc65-4d5c-4927-8014-936ca6a689a7,材料信息库选择框(可添加新材料)-招待物资,4,tree,SUCCESS,true,9,false,
|
||||||
e2971139-7c99-4af8-ad12-7d93477a4511,资料库查看,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=75c5f614-b927-4d94-bd09-ecac3f2506da → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=d572b755-319f-47eb-ad49-24f11fa34b31(rcolumn=FOLDERID) → 跨模板引用,右侧列表数据源待联动
|
e2971139-7c99-4af8-ad12-7d93477a4511,资料库查看,4,tree,SUCCESS,true,10,false,
|
||||||
e4e88a2d-377a-49ee-bb2c-e27c0fd9407e,枚举项维护,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=b9401f70-ee50-4e8b-9a26-270936b41ab5 → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=ddb51949-e2a1-4a9d-b936-48609473755a(rcolumn=SYS_ENUMERATETYPE_ID) → 跨模板引用,右侧列表数据源待联动
|
e4e88a2d-377a-49ee-bb2c-e27c0fd9407e,枚举项维护,4,tree,SUCCESS,true,5,false,
|
||||||
e9cdcd53-9bc9-4503-84f7-94c074f89789,公司污染源,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=3ccd2705-ae8f-450f-9537-8e2e19fac5c7 → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=55ff56f1-14e0-41e7-9e84-72b120d26980(rcolumn=POLLUTIONID) → 跨模板引用,右侧列表数据源待联动
|
e9cdcd53-9bc9-4503-84f7-94c074f89789,公司污染源,4,tree,SUCCESS,true,9,false,
|
||||||
ecadc741-23a3-487a-a322-9ef7242cd8c2,设备管理-知识库,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=8e19932b-94c2-40c0-907d-1f937dfd0817 → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=31f2d403-3e09-4607-93fc-084ab271b7e9(rcolumn=LIBRARYID) → 跨模板引用,右侧列表数据源待联动
|
ecadc741-23a3-487a-a322-9ef7242cd8c2,设备管理-知识库,4,tree,SUCCESS,true,9,false,
|
||||||
f038a6dc-4166-4af7-9506-9a69ba9ea722,材料信息库管理查看,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=fdd10db0-963d-4e67-bf2a-584ba48fca33 → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=5f442be1-5e97-437f-8de2-c7a383fc17cf(rcolumn=RESOURCETYPEID) → 跨模板引用,右侧列表数据源待联动
|
f038a6dc-4166-4af7-9506-9a69ba9ea722,材料信息库管理查看,4,tree,SUCCESS,true,7,false,
|
||||||
ff630e64-4a89-4ba6-b34e-d186206c0141,大事记管理,4,tree,PARTIAL,true,2,false,转换器缺陷:tree+grid: treetemplate ref=e26ea392-8001-46c5-b554-56b3d686a7af → 跨模板引用,树数据源 /api/template 待联动 | 转换器缺陷:tree+grid: gridtemplate ref=480df2ac-043b-4f96-a8f1-6f815f7ef62d(rcolumn=EVENTID) → 跨模板引用,右侧列表数据源待联动
|
ff630e64-4a89-4ba6-b34e-d186206c0141,大事记管理,4,tree,SUCCESS,true,11,false,
|
||||||
062041e3-0862-49b1-a304-34c873ac5b9e,单个员工排班,5,crud,PARTIAL,true,20,false,转换器缺陷:button pageid=1e9da14b-02f3-405d-b200-382a983b2714 无对应 EDITFORM(type=7) 模板,实体级回退也无命中 → 诚实降级 | 转换器缺陷:button dialog 无 EDITFORM 模板映射(templateId=MISSING_1e9da14b-02f3-405d-b200-382a983b2714)→ 诚实降级 | 转换器缺陷:button pageid=1e9da14b-02f3-405d-b200-382a983b2714 无对应 EDITFORM(type=7) 模板,实体级回退也无命中 → 诚实降级 | 转换器缺陷:button dialog 无 EDITFORM 模板映射(templateId=MISSING_1e9da14b-02f3-405d-b200-382a983b2714)→ 诚实降级
|
062041e3-0862-49b1-a304-34c873ac5b9e,单个员工排班,5,crud,PARTIAL,true,20,false,转换器缺陷:button pageid=1e9da14b-02f3-405d-b200-382a983b2714 无对应 EDITFORM(type=7) 模板,实体级回退也无命中 → 诚实降级 | 转换器缺陷:button dialog 无 EDITFORM 模板映射(templateId=MISSING_1e9da14b-02f3-405d-b200-382a983b2714)→ 诚实降级 | 转换器缺陷:button pageid=1e9da14b-02f3-405d-b200-382a983b2714 无对应 EDITFORM(type=7) 模板,实体级回退也无命中 → 诚实降级 | 转换器缺陷:button dialog 无 EDITFORM 模板映射(templateId=MISSING_1e9da14b-02f3-405d-b200-382a983b2714)→ 诚实降级
|
||||||
f4446608-68e3-40f3-8546-2511de73fbdc,查看会议室调度,5,crud,PARTIAL,true,8,false,转换器缺陷:button pageid=df4eef73-0393-45a3-a113-b1d2c29c82cd 无对应 EDITFORM(type=7) 模板,实体级回退也无命中 → 诚实降级 | 转换器缺陷:button dialog 无 EDITFORM 模板映射(templateId=MISSING_df4eef73-0393-45a3-a113-b1d2c29c82cd)→ 诚实降级
|
f4446608-68e3-40f3-8546-2511de73fbdc,查看会议室调度,5,crud,PARTIAL,true,8,false,转换器缺陷:button pageid=df4eef73-0393-45a3-a113-b1d2c29c82cd 无对应 EDITFORM(type=7) 模板,实体级回退也无命中 → 诚实降级 | 转换器缺陷:button dialog 无 EDITFORM 模板映射(templateId=MISSING_df4eef73-0393-45a3-a113-b1d2c29c82cd)→ 诚实降级
|
||||||
05226af5-5c77-470f-b039-d894fc55714d,现场材料管理(土建-无订单),6,group,PARTIAL,true,4,false,转换器缺陷:group 分组容器仅转 tabs 壳 → 各 tab 子模板需跨模板联动加载(本批不联动)
|
05226af5-5c77-470f-b039-d894fc55714d,现场材料管理(土建-无订单),6,group,PARTIAL,true,4,false,转换器缺陷:group 分组容器仅转 tabs 壳 → 各 tab 子模板需跨模板联动加载(本批不联动)
|
||||||
|
|||||||
|
Can't render this file because it is too large.
|
@@ -0,0 +1,242 @@
|
|||||||
|
package com.eip4.platform.metadata.web;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import org.dom4j.Document;
|
||||||
|
import org.dom4j.DocumentHelper;
|
||||||
|
import org.dom4j.Element;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.dao.DataAccessException;
|
||||||
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 树模板数据源端点(TreeGrid 左树)。转换器对 {@code <tree>} 的 treetemplate 引用产出
|
||||||
|
* {@code source=/api/template/{treetemplateRef}/tree}(见 TemplateToAmisConverter.convertTreeGrid),
|
||||||
|
* 本端点把该树模板渲染成 amis {@code input-tree} 的嵌套 options。
|
||||||
|
*
|
||||||
|
* <p><b>树模型(老引擎 view_template <tree>)</b>:{@code <node entityid>} 为根级,
|
||||||
|
* {@code <nextnodes><levelnode entityid parentid>} 声明各子级——<b>跨多实体、按各级 parentid 列链接</b>
|
||||||
|
* (如「大事记分类」自嵌套 PARENTID,其下「事件」按 MEMORABILIASORTID 挂到分类)。
|
||||||
|
*
|
||||||
|
* <p><b>构树算法</b>:把所有层级的行装进单一 {@code id→节点} 映射(id 归一化大写去空白),再按各行所在
|
||||||
|
* 层级的 parentid 列值找父节点(父在任意层级皆可,id 全局唯一)——父在则挂为 children,否则为根。
|
||||||
|
* 一次性 eager 构建(树/分类表通常小);节点总数封顶 {@code MAX_NODES},超限截断并 WARN。
|
||||||
|
* 每个节点 {@code value}=原始主键(供右表 {@code ?rcol=${tree}} 过滤),{@code label}=实体显示列。
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
public class TemplateTreeController {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(TemplateTreeController.class);
|
||||||
|
private static final Pattern IDENT = Pattern.compile("^[A-Za-z0-9_]+$");
|
||||||
|
private static final int MAX_NODES = 5000;
|
||||||
|
private static final String[] NAME_FALLBACKS = {"NAME", "SORT_NAME", "FULLNAME", "TITLE", "SUBJECT", "DISPLAYNAME"};
|
||||||
|
|
||||||
|
private final JdbcTemplate jdbcTemplate;
|
||||||
|
|
||||||
|
public TemplateTreeController(JdbcTemplate jdbcTemplate) {
|
||||||
|
this.jdbcTemplate = jdbcTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 树层级:实体表 + 该级的 parentid 列(null=该级行为根)。 */
|
||||||
|
private record Level(String table, String parentCol) {}
|
||||||
|
|
||||||
|
/** 构树中间节点:opt 是即将返回的 amis option(含 children),parentRef 是归一化的父键。 */
|
||||||
|
private static final class Node {
|
||||||
|
final Map<String, Object> opt = new LinkedHashMap<>();
|
||||||
|
final List<Map<String, Object>> children = new ArrayList<>();
|
||||||
|
String parentRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/api/template/{templateId}/tree")
|
||||||
|
public Map<String, Object> tree(@PathVariable String templateId) {
|
||||||
|
List<Map<String, Object>> options = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
List<Level> levels = resolveLevels(templateId);
|
||||||
|
Map<String, Node> byId = new LinkedHashMap<>();
|
||||||
|
List<Node> order = new ArrayList<>();
|
||||||
|
for (Level lv : levels) {
|
||||||
|
if (order.size() >= MAX_NODES) {
|
||||||
|
log.warn("[TREE] {} 节点超 {} 截断", templateId, MAX_NODES);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
loadLevel(lv, byId, order);
|
||||||
|
}
|
||||||
|
for (Node n : order) {
|
||||||
|
Node parent = n.parentRef != null ? byId.get(n.parentRef) : null;
|
||||||
|
if (parent != null && parent != n) {
|
||||||
|
parent.children.add(n.opt);
|
||||||
|
} else {
|
||||||
|
options.add(n.opt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (DataAccessException ex) {
|
||||||
|
log.warn("[TREE] 构树失败 template={}: {}", templateId, ex.getMessage());
|
||||||
|
}
|
||||||
|
Map<String, Object> data = new LinkedHashMap<>();
|
||||||
|
data.put("options", options);
|
||||||
|
Map<String, Object> resp = new LinkedHashMap<>();
|
||||||
|
resp.put("status", 0);
|
||||||
|
resp.put("msg", "");
|
||||||
|
resp.put("data", data);
|
||||||
|
return resp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 解析树模板 XML → 各层级(实体表 + parentid 列)。entityId→tablename;同实体取有 parentid 的声明(自嵌套)。 */
|
||||||
|
private List<Level> resolveLevels(String templateId) {
|
||||||
|
List<String> xmls = jdbcTemplate.queryForList(
|
||||||
|
"SELECT xml::text FROM eip3.view_template WHERE view_template_id = ? AND xml IS NOT NULL",
|
||||||
|
String.class, templateId);
|
||||||
|
if (xmls.isEmpty() || xmls.get(0) == null || xmls.get(0).isBlank()) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
// entityId → parentCol(后写覆盖:levelnode 的 parentid 优先于根节点的 null)
|
||||||
|
Map<String, String> entityParent = new LinkedHashMap<>();
|
||||||
|
try {
|
||||||
|
Document doc = DocumentHelper.parseText(xmls.get(0).trim());
|
||||||
|
Element root = doc.getRootElement();
|
||||||
|
Element node = root.element("node");
|
||||||
|
if (node != null) {
|
||||||
|
putEntity(entityParent, node.attributeValue("entityid"), node.attributeValue("parentid"));
|
||||||
|
Element nexts = node.element("nextnodes");
|
||||||
|
if (nexts != null) {
|
||||||
|
for (Element ln : nexts.elements("levelnode")) {
|
||||||
|
putEntity(entityParent, ln.attributeValue("entityid"), ln.attributeValue("parentid"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("[TREE] 解析树 XML 失败 template={}: {}", templateId, e.getMessage());
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
List<Level> levels = new ArrayList<>();
|
||||||
|
for (Map.Entry<String, String> e : entityParent.entrySet()) {
|
||||||
|
String table = tableOfEntity(e.getKey());
|
||||||
|
if (table != null && IDENT.matcher(table).matches()) {
|
||||||
|
levels.add(new Level(table, e.getValue()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return levels;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void putEntity(Map<String, String> map, String entityId, String parentCol) {
|
||||||
|
if (entityId == null || entityId.isBlank()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String pc = parentCol != null && !parentCol.isBlank() && IDENT.matcher(parentCol).matches()
|
||||||
|
? parentCol.toUpperCase() : null;
|
||||||
|
// 已有非空 parentCol 时不被 null 覆盖(保留自嵌套声明)
|
||||||
|
if (!map.containsKey(entityId) || (pc != null && map.get(entityId) == null)) {
|
||||||
|
map.put(entityId, pc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String tableOfEntity(String entityId) {
|
||||||
|
try {
|
||||||
|
List<String> t = jdbcTemplate.queryForList(
|
||||||
|
"SELECT tablename FROM eip3.sys_entity WHERE UPPER(sys_entity_id) = UPPER(?)",
|
||||||
|
String.class, entityId);
|
||||||
|
return t.isEmpty() ? null : (t.get(0) == null ? null : t.get(0).toUpperCase());
|
||||||
|
} catch (DataAccessException ex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 加载一个层级的行,装进 byId/order。key/display/parent 列均经 IDENT 守卫;display 解析失败回落主键。 */
|
||||||
|
private void loadLevel(Level lv, Map<String, Node> byId, List<Node> order) {
|
||||||
|
String table = lv.table();
|
||||||
|
String keyCol = table + "_ID";
|
||||||
|
String displayCol = displayColumn(table, keyCol);
|
||||||
|
if (!IDENT.matcher(keyCol).matches() || !IDENT.matcher(displayCol).matches()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String parentCol = lv.parentCol();
|
||||||
|
StringBuilder sql = new StringBuilder("SELECT ").append(keyCol).append(" AS k, ")
|
||||||
|
.append(displayCol).append(" AS lbl");
|
||||||
|
if (parentCol != null) {
|
||||||
|
sql.append(", ").append(parentCol).append(" AS pref");
|
||||||
|
}
|
||||||
|
sql.append(" FROM eip3.").append(table);
|
||||||
|
try {
|
||||||
|
List<Map<String, Object>> rows = jdbcTemplate.queryForList(sql.toString());
|
||||||
|
for (Map<String, Object> r : rows) {
|
||||||
|
if (order.size() >= MAX_NODES) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Object rawKey = r.get("k");
|
||||||
|
if (rawKey == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String idNorm = String.valueOf(rawKey).trim().toUpperCase();
|
||||||
|
Object lbl = r.get("lbl");
|
||||||
|
String label = lbl != null && !String.valueOf(lbl).isBlank()
|
||||||
|
? String.valueOf(lbl).trim() : String.valueOf(rawKey).trim();
|
||||||
|
Node n = new Node();
|
||||||
|
n.opt.put("label", label);
|
||||||
|
n.opt.put("value", String.valueOf(rawKey).trim()); // 原始主键(供右表过滤)
|
||||||
|
n.opt.put("children", n.children);
|
||||||
|
Object pref = parentCol != null ? r.get("pref") : null;
|
||||||
|
n.parentRef = pref != null && !String.valueOf(pref).isBlank()
|
||||||
|
? String.valueOf(pref).trim().toUpperCase() : null;
|
||||||
|
// 同 id 跨级去重(自嵌套时同实体只装一次)
|
||||||
|
if (!byId.containsKey(idNorm)) {
|
||||||
|
byId.put(idNorm, n);
|
||||||
|
order.add(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (DataAccessException ex) {
|
||||||
|
log.warn("[TREE] 加载层级失败 table={}: {}", table, ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 实体显示列:isentitydisplay=1 → 物理名称列回落 → 主键。守卫物理存在(防虚拟列)。 */
|
||||||
|
private String displayColumn(String table, String keyCol) {
|
||||||
|
Set<String> phys = physicalColumns(table);
|
||||||
|
String entityDisplay = null;
|
||||||
|
try {
|
||||||
|
List<String> cols = jdbcTemplate.queryForList(
|
||||||
|
"SELECT UPPER(ea.columnname) FROM eip3.sys_entityattribute ea "
|
||||||
|
+ "JOIN eip3.sys_entity e ON UPPER(e.sys_entity_id) = UPPER(ea.entityid) "
|
||||||
|
+ "WHERE UPPER(e.tablename) = ? AND ea.isentitydisplay = 1",
|
||||||
|
String.class, table);
|
||||||
|
if (!cols.isEmpty()) {
|
||||||
|
entityDisplay = cols.get(0);
|
||||||
|
}
|
||||||
|
} catch (DataAccessException ignore) {
|
||||||
|
// 回落
|
||||||
|
}
|
||||||
|
if (entityDisplay != null && physExists(phys, entityDisplay)) {
|
||||||
|
return entityDisplay;
|
||||||
|
}
|
||||||
|
for (String cand : NAME_FALLBACKS) {
|
||||||
|
if (physExists(phys, cand)) {
|
||||||
|
return cand;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return keyCol;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Set<String> physicalColumns(String table) {
|
||||||
|
try {
|
||||||
|
return new LinkedHashSet<>(jdbcTemplate.queryForList(
|
||||||
|
"SELECT UPPER(column_name) FROM information_schema.columns "
|
||||||
|
+ "WHERE table_schema='eip3' AND UPPER(table_name)=?",
|
||||||
|
String.class, table));
|
||||||
|
} catch (DataAccessException ex) {
|
||||||
|
return Set.of();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean physExists(Set<String> phys, String colUpper) {
|
||||||
|
return phys.isEmpty() || phys.contains(colUpper);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user