Skip to content

Enterprise customer risk radar (finance / credit platform) — generate this PDF with Java (RADAR)

JQuick-PdfBiz Demo

RADAR2 页 A4 · 177 KB

Scores enterprise customers on solvency, profitability and operational stability and renders the risk profile as a radar chart.

Download the PDFView raw template fileBack to all demos

Enterprise customer risk radar (finance / credit platform) — RADAR
Rendered output

Output specs

PDF pages
2
Chart type
RADAR
Template lines
120
Source lines
93

Java source · JQuickBiz23RiskRadarTest.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.JRadar;
import com.github.paohaijiao.code.JSeriesType;
import com.github.paohaijiao.code.JTrigger;
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 com.github.paohaijiao.series.JRadarSeries;
import org.junit.Test;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * 业务场景 Demo 23:企业客户风险等级雷达评估(金融/信用平台)
 *
 * <p>业务场景:金融/信用平台对某企业客户做风险等级多维评估,从偿债能力、盈利能力、
 * 经营稳定性、行业景气度、担保充足度、历史履约六个维度打分(满分100),并与上期评分对比。</p>
 * <p>实际图表类型:{@link JChartType#RADAR} 雷达图(双系列:本期评分 / 上期评分)。</p>
 *
 * <p>模板:{@code report/biz/23_risk_radar.txt};图表以 SVG 文本形式绑定到模板的
 * {@code ${svg}} 占位符,输出到 {@code D:\test\biz\23_risk_radar.pdf}。</p>
 *
 * <p>图表尺寸说明:图表按 700pt × 380pt(宽 × 高)的横版比例设计;模板中 {@code <svg>}
 * 只声明宽度、不声明高度,因此宽度被页面自动收窄时高度会按原比例同步缩放,不会纵向拉伸变形。</p>
 *
 * @author Martin
 * @version 1.0.0
 */
public class JQuickBiz23RiskRadarTest {

    public static final String path = JQuickConstant.path;

    @Test
    public void biz23RiskRadar() throws IOException {
        JOption option = new JOption();
        option.title().text("企业客户风险等级多维评估").subtext("各维度评分(满分100,分值越高越稳健)");
        option.tooltip().trigger(JTrigger.item);
        JRadar radar = new JRadar();
        radar.indicator(
                new JRadar.Indicator().name("偿债能力").max(100),
                new JRadar.Indicator().name("盈利能力").max(100),
                new JRadar.Indicator().name("经营稳定性").max(100),
                new JRadar.Indicator().name("行业景气度").max(100),
                new JRadar.Indicator().name("担保充足度").max(100),
                new JRadar.Indicator().name("历史履约").max(100)
        );
        option.radar(radar);
        // 双系列对比:本期评分与上期评分
        JRadarSeries current = new JRadarSeries();
        current.name("本期评分").type(JSeriesType.radar).data(86, 78, 88, 72, 90, 93);
        JRadarSeries last = new JRadarSeries();
        last.name("上期评分").type(JSeriesType.radar).data(80, 83, 82, 77, 86, 89);
        option.series(current, last);

        String svg = JChartRendererFactory.renderChart(JChartType.RADAR, option);

        File dir = new File(path + "biz");
        if (!dir.exists()) {
            dir.mkdirs();
        }
        FileOutputStream fileOutputStream = new FileOutputStream(path + "biz/23_risk_radar.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/23_risk_radar.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/23_risk_radar.txt");

Template file · 23_risk_radar.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="background:#6A1B9A; padding:14px; borderRadius:4px; marginBottom:12px; keepTogether:true">
    <div style="display:flex; justifyContent:space-between">
      <div style="width:300px">
        <h1 style="color:white; fontSize:18; bold:true; marginBottom:4px">'企业客户风险等级多维评估'</h1>
        <p style="color:#E6D6EF; fontSize:9">'六维风险模型评分(满分100,分值越高越稳健)'</p>
      </div>
      <div style="width:240px; textAlignment:right; borderLeft:1px solid #8E5BA6; paddingLeft:10px">
        <p style="color:white; fontSize:9">'评估周期:2024年第四季度'</p>
        <p style="color:#E6D6EF; fontSize:9">'编制单位:风险管理部信用评估岗'</p>
        <p style="color:#E6D6EF; fontSize:9">'报送对象:信贷审查委员会'</p>
      </div>
    </div>
  </div>

  <div style="display:flex; justifyContent:space-between; marginBottom:12px; keepTogether:true">
    <div style="width:132px; minHeight:54px; background:#F3EAF7; borderRadius:4px; padding:8px; verticalAlignment:middle">
      <p style="color:#6A1B9A; fontSize:16; bold:true; textAlignment:center; marginBottom:2px">'84.5'</p>
      <p style="color:#5A6B7C; fontSize:9; textAlignment:center">'本期综合评分'</p>
    </div>
    <div style="width:132px; minHeight:54px; background:#F3EAF7; borderRadius:4px; padding:8px; verticalAlignment:middle">
      <p style="color:#1B5E20; fontSize:16; bold:true; textAlignment:center; marginBottom:2px">'+1.7'</p>
      <p style="color:#5A6B7C; fontSize:9; textAlignment:center">'较上期提升'</p>
    </div>
    <div style="width:132px; minHeight:54px; background:#F3EAF7; borderRadius:4px; padding:8px; verticalAlignment:middle">
      <p style="color:#1B5E20; fontSize:16; bold:true; textAlignment:center; marginBottom:2px">'93'</p>
      <p style="color:#5A6B7C; fontSize:9; textAlignment:center">'最高维度:历史履约'</p>
    </div>
    <div style="width:132px; minHeight:54px; background:#F3EAF7; borderRadius:4px; padding:8px; verticalAlignment:middle">
      <p style="color:#BF360C; fontSize:16; bold:true; textAlignment:center; marginBottom:2px">'72'</p>
      <p style="color:#5A6B7C; fontSize:9; textAlignment:center">'最低维度:行业景气度'</p>
    </div>
  </div>

  <div style="marginBottom:10px">
    <h2 style="color:#6A1B9A; fontSize:13; bold:true; marginBottom:6px">'一、多维风险评分雷达图'</h2>
    <div style="display:flex; justifyContent:center">
      <svg style="width:700pt">${svg}</svg>
    </div>
    <p style="fontSize:9; color:#6c757d; italic:true; marginTop:6px">'图 1  企业客户六维风险评分(本期 vs 上期;数据来源:信用评估系统)'</p>
  </div>

  <div style="marginBottom:10px">
    <h2 style="color:#6A1B9A; fontSize:13; bold:true; marginBottom:6px">'二、六维评分明细'</h2>
    <table style="width:540px; fontSize:10">
      <tr>
        <th style="backgroundColor:#6A1B9A; color:white; padding:6px; textAlign:center; border:1px solid #DCE3EC">'评估维度'</th>
        <th style="backgroundColor:#6A1B9A; color:white; padding:6px; textAlign:center; border:1px solid #DCE3EC">'本期评分'</th>
        <th style="backgroundColor:#6A1B9A; color:white; padding:6px; textAlign:center; border:1px solid #DCE3EC">'上期评分'</th>
        <th style="backgroundColor:#6A1B9A; color:white; padding:6px; textAlign:center; border:1px solid #DCE3EC">'环比变动'</th>
        <th style="backgroundColor:#6A1B9A; color:white; padding:6px; textAlign:center; border:1px solid #DCE3EC">'状态评价'</th>
      </tr>
      <tr>
        <td style="padding:5px; border:1px solid #DCE3EC">'偿债能力'</td>
        <td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'86'</td>
        <td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'80'</td>
        <td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'+6'</td>
        <td style="padding:5px; border:1px solid #DCE3EC">'改善'</td>
      </tr>
      <tr>
        <td style="padding:5px; backgroundColor:#F3EAF7; border:1px solid #DCE3EC">'盈利能力'</td>
        <td style="padding:5px; textAlign:right; backgroundColor:#F3EAF7; border:1px solid #DCE3EC">'78'</td>
        <td style="padding:5px; textAlign:right; backgroundColor:#F3EAF7; border:1px solid #DCE3EC">'83'</td>
        <td style="padding:5px; textAlign:right; backgroundColor:#F3EAF7; border:1px solid #DCE3EC">'-5'</td>
        <td style="padding:5px; backgroundColor:#F3EAF7; border:1px solid #DCE3EC">'小幅下滑'</td>
      </tr>
      <tr>
        <td style="padding:5px; border:1px solid #DCE3EC">'经营稳定性'</td>
        <td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'88'</td>
        <td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'82'</td>
        <td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'+6'</td>
        <td style="padding:5px; border:1px solid #DCE3EC">'改善'</td>
      </tr>
      <tr>
        <td style="padding:5px; backgroundColor:#F3EAF7; border:1px solid #DCE3EC">'行业景气度'</td>
        <td style="padding:5px; textAlign:right; backgroundColor:#F3EAF7; border:1px solid #DCE3EC">'72'</td>
        <td style="padding:5px; textAlign:right; backgroundColor:#F3EAF7; border:1px solid #DCE3EC">'77'</td>
        <td style="padding:5px; textAlign:right; backgroundColor:#F3EAF7; border:1px solid #DCE3EC">'-5'</td>
        <td style="padding:5px; backgroundColor:#F3EAF7; border:1px solid #DCE3EC">'持续承压'</td>
      </tr>
      <tr>
        <td style="padding:5px; border:1px solid #DCE3EC">'担保充足度'</td>
        <td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'90'</td>
        <td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'86'</td>
        <td style="padding:5px; textAlign:right; border:1px solid #DCE3EC">'+4'</td>
        <td style="padding:5px; border:1px solid #DCE3EC">'优'</td>
      </tr>
      <tr>
        <td style="padding:5px; backgroundColor:#F3EAF7; border:1px solid #DCE3EC">'历史履约'</td>
        <td style="padding:5px; textAlign:right; backgroundColor:#F3EAF7; border:1px solid #DCE3EC">'93'</td>
        <td style="padding:5px; textAlign:right; backgroundColor:#F3EAF7; border:1px solid #DCE3EC">'89'</td>
        <td style="padding:5px; textAlign:right; backgroundColor:#F3EAF7; border:1px solid #DCE3EC">'+4'</td>
        <td style="padding:5px; backgroundColor:#F3EAF7; border:1px solid #DCE3EC">'优'</td>
      </tr>
    </table>
  </div>

  <div style="marginBottom:10px">
    <h2 style="color:#6A1B9A; fontSize:13; bold:true; marginBottom:6px">'三、评估结论与授信建议'</h2>
    <list style="list-style-type:none; padding-left:0; fontSize:10">
      <li style="marginBottom:6px; padding:8px; backgroundColor:#F3EAF7; border-left:3px solid #6A1B9A">
        '整体评级上调:本期六维综合评分84.5分,上期82.8分,环比提升1.7分,风险等级由B+上调至A(低风险)。'
      </li>
      <li style="marginBottom:6px; padding:8px; backgroundColor:#F3EAF7; border-left:3px solid #6A1B9A">
        '优势维度突出:历史履约93分、担保充足度90分、经营稳定性88分稳居优秀区间,履约记录扎实、增信措施充分。'
      </li>
      <li style="marginBottom:6px; padding:8px; backgroundColor:#F3EAF7; border-left:3px solid #6A1B9A">
        '短板维度预警:行业景气度72分、盈利能力78分均环比下降5分,是本期唯一两项走弱的指标,需持续跟踪。'
      </li>
      <li style="marginBottom:6px; padding:8px; backgroundColor:#F3EAF7; border-left:3px solid #6A1B9A">
        '授信建议:维持现有授信额度并允许上浮10%;将行业景气度纳入季度监测,连续两期低于70分即触发额度重检。'
      </li>
    </list>
  </div>

  <p style="textAlignment:center; color:#8a939b; fontSize:8; italic:true; marginTop:10px">'数据来源:信用评估系统(六维风险模型 V3.2) | 生成时间:2025年1月6日 | 密级:秘密'</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.