Fund flow tree (group treasury) — generate this PDF with Java (Tree)
Tree3 页 A4 · 344 KB
A tree chart shows how funds are pooled from and allocated back to the group member companies.

Output specs
- PDF pages
- 3
- Chart type
- Tree
- Template lines
- 91
- Source lines
- 116
Java source · JQuickBiz33FundFlowTreeTest.java
This is the complete test class that produced the PDF above — copy it and run as-is; see the quick-start section for the Maven dependency.
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Copyright (c) [2025-2099] Martin ([email protected])
*/
package com.github.paohaijiao.demo.biz;
import com.github.paohaijiao.JOption;
import com.github.paohaijiao.combol.JTreeChartData;
import com.github.paohaijiao.config.JPdfConfig;
import com.github.paohaijiao.demo.constant.JQuickConstant;
import com.github.paohaijiao.enums.JChartType;
import com.github.paohaijiao.executor.JQuickPdfFactory;
import com.github.paohaijiao.factory.JChartRendererFactory;
import org.junit.Test;
import java.awt.Color;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* 业务场景 Demo 33:资金流向树图表(集团资金管理)
*
* <p>业务场景:集团资金管理中心展示「集团总部 → 各业务板块 → 各项目公司」三级资金流向层级结构,
* 用于投融资决策委员会分析资金沉淀与周转效率。</p>
* <p>实际图表类型:{@link JChartType#Tree} 树图(层级水平布局,展示资金归集与下拨的父子层级)。</p>
*
* <p>模板:{@code report/biz/33_fund_flow_tree.txt};树图以 SVG 文本形式绑定到模板的 {@code ${svg}} 占位符,
* 输出到 {@code D:\test\biz\33_fund_flow_tree.pdf}。</p>
*
* <p>图表尺寸说明:树图渲染器画布固定 1000pt × 800pt(宽 × 高),节点总数控制在 12 个(1 个一级 + 3 个二级 + 8 个三级)
* 以避免拥挤;模板中 {@code <svg>} 只声明宽度、不声明高度,宽度被页面自动收窄时高度按原比例同步缩放,不会纵向拉伸变形。</p>
*
* @author Martin
* @version 1.0.0
*/
public class JQuickBiz33FundFlowTreeTest {
public static final String path = JQuickConstant.path;
@Test
public void biz33FundFlowTree() throws IOException {
JTreeChartData data = new JTreeChartData();
data.setTitleText("集团资金流向结构图");
data.setSubtitleText("集团总部 → 业务板块 → 项目公司 · 2025年上半年(单位:亿元)");
data.setFooterText("数据来源:集团资金管理中心资金池台账 · 统计截止2025年6月30日");
// 三级节点尺寸:一级为集团、二级为板块、三级为项目公司
data.setRootNodeWidth(240);
data.setRootNodeHeight(60);
data.setLevelNodeWidth(190);
data.setLevelNodeHeight(54);
data.setLeafNodeWidth(110);
data.setLeafNodeHeight(48);
data.setHorizontalSpacing(70);
data.setVerticalSpacing(60);
List<JTreeChartData.LegendItem> legends = new ArrayList<>();
legends.add(new JTreeChartData.LegendItem("一级节点(集团)", new Color(26, 82, 118)));
legends.add(new JTreeChartData.LegendItem("二级节点(板块)", new Color(44, 127, 184)));
legends.add(new JTreeChartData.LegendItem("三级节点(项目公司)", Color.WHITE));
data.setLegendList(legends);
JTreeChartData.TreeNode root = new JTreeChartData.TreeNode("root", "集团总部(资金池)", "Group Treasury Pool");
root.setColor(new Color(0, 105, 92));
// 二级节点一:基础设施建设板块
JTreeChartData.TreeNode infra = new JTreeChartData.TreeNode("infra", "基础设施建设板块", "Infrastructure");
infra.addChild(new JTreeChartData.TreeNode("road", "路桥项目公司", "Road & Bridge"));
infra.addChild(new JTreeChartData.TreeNode("municipal", "市政工程项目公司", "Municipal Works"));
infra.addChild(new JTreeChartData.TreeNode("rail", "轨道交通项目公司", "Rail Transit"));
// 二级节点二:产业投资板块
JTreeChartData.TreeNode industry = new JTreeChartData.TreeNode("industry", "产业投资板块", "Industry Investment");
industry.addChild(new JTreeChartData.TreeNode("energy", "新能源项目公司", "New Energy"));
industry.addChild(new JTreeChartData.TreeNode("manufacture", "智能制造项目公司", "Smart Manufacturing"));
industry.addChild(new JTreeChartData.TreeNode("material", "新材料项目公司", "New Material"));
// 二级节点三:金融服务板块
JTreeChartData.TreeNode finance = new JTreeChartData.TreeNode("finance", "金融服务板块", "Financial Services");
finance.addChild(new JTreeChartData.TreeNode("leasing", "融资租赁公司", "Financial Leasing"));
finance.addChild(new JTreeChartData.TreeNode("supply", "供应链金融公司", "Supply Chain Finance"));
root.addChild(infra);
root.addChild(industry);
root.addChild(finance);
data.setRootNode(root);
JOption option = new JOption();
option.setData(data);
String svg = JChartRendererFactory.renderChart(JChartType.Tree, option);
File dir = new File(path + "biz");
if (!dir.exists()) {
dir.mkdirs();
}
FileOutputStream fileOutputStream = new FileOutputStream(path + "biz/33_fund_flow_tree.pdf");
JPdfConfig config = new JPdfConfig();
// 开启 flex 行布局,使模板中的 display:flex 生效(图表居中)
config.getLayoutConfig().setFlexLayout(true);
JQuickPdfFactory factory = new JQuickPdfFactory(config);
factory.bind("svg", svg);
byte[] bytes = factory.executeResource("report/biz/33_fund_flow_tree.txt");
fileOutputStream.write(bytes);
fileOutputStream.close();
}
}Minimal invocation (3 lines)
Skip the full test class — the core is these three lines: bind the chart SVG, execute the template, get the PDF bytes. Copy them straight into your project.
// config 可省略;svg 来自 JChartRendererFactory.renderChart(...),见下方完整源码
factory.bind("svg", svg);
byte[] pdf = new JQuickPdfFactory(config).executeResource("report/biz/33_fund_flow_tree.txt");Template file · 33_fund_flow_tree.txt
An HTML-like template with inline CSS that renders to PDF once bound to data. The full template is below — copy it or download the raw file.
<pdf>
<body>
<div style="textAlignment:center; marginBottom:10px; padding:14px; background:#00695C; borderRadius:4px">
<h1 style="textAlignment:center; color:white; marginBottom:6pt; fontSize:18pt; bold:true">'集团资金流向结构图'</h1>
<p style="color:white; fontSize:10pt; margin:2px">'统计周期:2025年1月 - 6月 | 数据来源:集团资金管理中心资金池台账'</p>
<p style="color:white; fontSize:10pt; margin:2px">'编制单位:集团资金管理中心 | 报送对象:投融资决策委员会'</p>
</div>
<div style="marginBottom:10px">
<h2 style="color:#00695C; fontSize:13pt; bold:true; marginBottom:6pt">'一、项目公司资金归集明细'</h2>
<table style="width:540px; fontSize:10pt">
<tr>
<th style="backgroundColor:#00695C; color:white; padding:6px; textAlign:center; border:1px solid #DCE3EC">'项目公司'</th>
<th style="backgroundColor:#00695C; color:white; padding:6px; textAlign:center; border:1px solid #DCE3EC">'所属板块'</th>
<th style="backgroundColor:#00695C; color:white; padding:6px; textAlign:center; border:1px solid #DCE3EC">'归集资金(亿元)'</th>
<th style="backgroundColor:#00695C; color:white; padding:6px; textAlign:center; border:1px solid #DCE3EC">'占比'</th>
</tr>
<tr>
<td style="padding:5px; borderTop:1px solid #DCE3EC; borderRight:1px solid #DCE3EC; borderBottom:1px solid #DCE3EC; borderLeft:3px solid #00695C">'路桥项目公司'</td>
<td style="padding:5px; border:1px solid #DCE3EC">'基础设施建设'</td>
<td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'96.0'</td>
<td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'20.5%'</td>
</tr>
<tr>
<td style="padding:5px; borderTop:1px solid #DCE3EC; borderRight:1px solid #DCE3EC; borderBottom:1px solid #DCE3EC; borderLeft:3px solid #00695C">'市政工程项目公司'</td>
<td style="padding:5px; border:1px solid #DCE3EC">'基础设施建设'</td>
<td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'82.0'</td>
<td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'17.5%'</td>
</tr>
<tr>
<td style="padding:5px; borderTop:1px solid #DCE3EC; borderRight:1px solid #DCE3EC; borderBottom:1px solid #DCE3EC; borderLeft:3px solid #00695C">'轨道交通项目公司'</td>
<td style="padding:5px; border:1px solid #DCE3EC">'基础设施建设'</td>
<td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'58.0'</td>
<td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'12.4%'</td>
</tr>
<tr>
<td style="padding:5px; borderTop:1px solid #DCE3EC; borderRight:1px solid #DCE3EC; borderBottom:1px solid #DCE3EC; borderLeft:3px solid #00695C">'新能源项目公司'</td>
<td style="padding:5px; border:1px solid #DCE3EC">'产业投资'</td>
<td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'62.0'</td>
<td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'13.2%'</td>
</tr>
<tr>
<td style="padding:5px; borderTop:1px solid #DCE3EC; borderRight:1px solid #DCE3EC; borderBottom:1px solid #DCE3EC; borderLeft:3px solid #00695C">'智能制造项目公司'</td>
<td style="padding:5px; border:1px solid #DCE3EC">'产业投资'</td>
<td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'48.0'</td>
<td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'10.3%'</td>
</tr>
<tr>
<td style="padding:5px; borderTop:1px solid #DCE3EC; borderRight:1px solid #DCE3EC; borderBottom:1px solid #DCE3EC; borderLeft:3px solid #00695C">'新材料项目公司'</td>
<td style="padding:5px; border:1px solid #DCE3EC">'产业投资'</td>
<td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'38.0'</td>
<td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'8.1%'</td>
</tr>
<tr>
<td style="padding:5px; borderTop:1px solid #DCE3EC; borderRight:1px solid #DCE3EC; borderBottom:1px solid #DCE3EC; borderLeft:3px solid #00695C">'融资租赁公司'</td>
<td style="padding:5px; border:1px solid #DCE3EC">'金融服务'</td>
<td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'48.0'</td>
<td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'10.3%'</td>
</tr>
<tr>
<td style="padding:5px; borderTop:1px solid #DCE3EC; borderRight:1px solid #DCE3EC; borderBottom:1px solid #DCE3EC; borderLeft:3px solid #00695C">'供应链金融公司'</td>
<td style="padding:5px; border:1px solid #DCE3EC">'金融服务'</td>
<td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'36.0'</td>
<td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'7.7%'</td>
</tr>
</table>
<p style="fontSize:8pt; color:#8a939b; marginTop:4pt">'注:8 家项目公司合计归集 468.0 亿元,占比合计 100.0%。'</p>
</div>
<div style="marginBottom:10px; padding:10px; backgroundColor:#F7FBFA; borderRadius:4px">
<h2 style="color:#00695C; fontSize:13pt; bold:true; marginTop:0; marginBottom:6pt">'二、资金流向层级结构'</h2>
<div style="display:flex; justifyContent:center">
<svg style="width:700pt">${svg}</svg>
</div>
<p style="fontSize:9pt; color:#6c757d; italic:true; marginTop:6pt">'图 1 集团总部 → 业务板块 → 项目公司三级资金流向树图(节点 12 个:1 个一级 + 3 个二级 + 8 个三级)'</p>
</div>
<div style="marginBottom:10px">
<h2 style="color:#00695C; fontSize:13pt; bold:true; marginBottom:6pt">'三、流向特征与管控建议'</h2>
<list style="list-style-type:none; padding-left:0; fontSize:10pt">
<li style="marginBottom:6px; padding:8px; backgroundColor:#E6F2F0; borderLeft:3px solid #00695C">'基础设施板块是资金沉淀主力:三家项目公司合计 236.0 亿元、占集团 50.4%,其中路桥项目公司单点占用 96.0 亿元,为全集团最大资金单元。'</li>
<li style="marginBottom:6px; padding:8px; backgroundColor:#E6F2F0; borderLeft:3px solid #00695C">'产业投资板块合计 148.0 亿元、占 31.6%,新能源项目公司 62.0 亿元为该板块最大节点,与集团战略投资方向一致。'</li>
<li style="marginBottom:6px; padding:8px; backgroundColor:#E6F2F0; borderLeft:3px solid #00695C">'金融服务板块资金效率最高:两家公司以 84.0 亿元资金支撑高周转运营,是集团资金效率的调节阀。'</li>
<li style="marginBottom:6px; padding:8px; backgroundColor:#E6F2F0; borderLeft:3px solid #00695C">'建议:对单一项目公司设置资金占用上限并纳入月度监控,重点关注前三大节点合计 240.0 亿元(占 51.3%)的集中度风险。'</li>
</list>
</div>
<p style="textAlignment:right; color:#8a939b; fontSize:8pt">'注:本表为集团内部资金管理报告附表,未经许可请勿外传。'</p>
</body>
</pdf>More demos in this group
The PDF, preview image, template and source code on this page were all produced by a real JQuick-Pdf run and are free to copy into your own project.