liusheng
2026-10-12 b25c3b5188e402695f3792ad7da53e452682cd80
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.ruoyi.satisfaction.api;
 
import com.ruoyi.common.utils.poi.ExcelUtil;
 
import java.util.Collections;
import java.util.List;
 
/**
 * 「问题详情占比」导出包(满意度模块对外暴露的导出载体)。
 * <p>
 * <b>为什么需要它</b>:随访导出({@code ServiceSubtaskController#patItemExport})需要把满意度占比行
 * 交给 {@code ExcelUtil.exportExcelTwoSheetWithChart(...)},而这个方法要求同时给出
 * 「行列表 + 行类型 {@code Class} + 图表构建器」。如果让调用方自己拿这三样,
 * 它就必须 import 满意度模块内部的 {@code domain} 与 {@code support} 包,
 * 违反「其它模块只能用本模块暴露的 api」的约束。
 * <p>
 * 因此这里把三样东西打包成一个 <b>api 层的值对象</b>:
 * <ul>
 *   <li>{@link #getRows()} —— 占比行(调用方只当作 {@code List<?>} 透传,不需要知道具体类型);</li>
 *   <li>{@link #getRowClass()} —— 行类型(同样只是透传给 {@code ExcelUtil});</li>
 *   <li>{@link #getChartBuilder()} —— 柱状图构建器(以 ruoyi-common 的
 *       {@link ExcelUtil.ChartSheetBuilder} 接口类型暴露,实现在模块内部,
 *       模块关闭时为 {@code null})。</li>
 * </ul>
 * 调用方只需 import 本类与 {@link SatisfactionFacade} 即可完成整个导出。
 */
public class SatisfactionExportBundle {
 
    /**
     * 模块关闭时使用的空导出包(无行、无图表构建器)
     */
    private static final SatisfactionExportBundle EMPTY =
            new SatisfactionExportBundle(Collections.emptyList(), null, null);
 
    private final List<?> rows;
 
    private final Class<?> rowClass;
 
    private final ExcelUtil.ChartSheetBuilder chartBuilder;
 
    public SatisfactionExportBundle(List<?> rows, Class<?> rowClass, ExcelUtil.ChartSheetBuilder chartBuilder) {
        this.rows = rows == null ? Collections.emptyList() : rows;
        this.rowClass = rowClass;
        this.chartBuilder = chartBuilder;
    }
 
    /**
     * 模块关闭时的空包(行列表为空、行类型与图表构建器为 null)。
     * <p>配合 {@code ExcelUtil} 的"行列表为空则跳过该 Sheet"行为,导出可以照常完成。
     */
    public static SatisfactionExportBundle empty() {
        return EMPTY;
    }
 
    /**
     * 占比行(调用方只作透传,不建议自行解析其字段语义)
     */
    public List<?> getRows() {
        return rows;
    }
 
    /**
     * 占比行的类型(透传给 {@code ExcelUtil} 用;模块关闭时为 null)
     */
    public Class<?> getRowClass() {
        return rowClass;
    }
 
    /**
     * 柱状图 Sheet 构建器(透传给 {@code ExcelUtil} 用;无数据或模块关闭时为 null)
     */
    public ExcelUtil.ChartSheetBuilder getChartBuilder() {
        return chartBuilder;
    }
 
    /**
     * 是否没有可导出的行
     */
    public boolean isEmpty() {
        return rows.isEmpty();
    }
}