中国算力平台算力登记系统2.0
YZFG
2024-09-30 43dc2996fd2033991539ed35a0429238829a5417
commit | author | age
43dc29 1 package com.odcc.cpzidc.common.annotation;
Y 2
3 import java.lang.annotation.ElementType;
4 import java.lang.annotation.Retention;
5 import java.lang.annotation.RetentionPolicy;
6 import java.lang.annotation.Target;
7 import java.math.BigDecimal;
8 import org.apache.poi.ss.usermodel.HorizontalAlignment;
9 import org.apache.poi.ss.usermodel.IndexedColors;
10 import com.odcc.cpzidc.common.utils.poi.ExcelHandlerAdapter;
11
12 /**
13  * 自定义导出Excel数据注解
14  * 
15  * @author ruoyi
16  */
17 @Retention(RetentionPolicy.RUNTIME)
18 @Target(ElementType.FIELD)
19 public @interface Excel
20 {
21     /**
22      * 导出时在excel中排序
23      */
24     public int sort() default Integer.MAX_VALUE;
25
26     /**
27      * 导出到Excel中的名字.
28      */
29     public String name() default "";
30
31     /**
32      * 日期格式, 如: yyyy-MM-dd
33      */
34     public String dateFormat() default "";
35
36     /**
37      * 如果是字典类型,请设置字典的type值 (如: sys_user_sex)
38      */
39     public String dictType() default "";
40
41     /**
42      * 读取内容转表达式 (如: 0=男,1=女,2=未知)
43      */
44     public String readConverterExp() default "";
45
46     /**
47      * 分隔符,读取字符串组内容
48      */
49     public String separator() default ",";
50
51     /**
52      * BigDecimal 精度 默认:-1(默认不开启BigDecimal格式化)
53      */
54     public int scale() default -1;
55
56     /**
57      * BigDecimal 舍入规则 默认:BigDecimal.ROUND_HALF_EVEN
58      */
59     public int roundingMode() default BigDecimal.ROUND_HALF_EVEN;
60
61     /**
62      * 导出时在excel中每个列的高度
63      */
64     public double height() default 14;
65
66     /**
67      * 导出时在excel中每个列的宽度
68      */
69     public double width() default 16;
70
71     /**
72      * 文字后缀,如% 90 变成90%
73      */
74     public String suffix() default "";
75
76     /**
77      * 当值为空时,字段的默认值
78      */
79     public String defaultValue() default "";
80
81     /**
82      * 提示信息
83      */
84     public String prompt() default "";
85
86     /**
87      * 设置只能选择不能输入的列内容.
88      */
89     public String[] combo() default {};
90
91     /**
92      * 是否从字典读数据到combo,默认不读取,如读取需要设置dictType注解.
93      */
94     public boolean comboReadDict() default false;
95
96     /**
97      * 是否需要纵向合并单元格,应对需求:含有list集合单元格)
98      */
99     public boolean needMerge() default false;
100
101     /**
102      * 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写.
103      */
104     public boolean isExport() default true;
105
106     /**
107      * 另一个类中的属性名称,支持多级获取,以小数点隔开
108      */
109     public String targetAttr() default "";
110
111     /**
112      * 是否自动统计数据,在最后追加一行统计数据总和
113      */
114     public boolean isStatistics() default false;
115
116     /**
117      * 导出类型(0数字 1字符串 2图片)
118      */
119     public ColumnType cellType() default ColumnType.STRING;
120
121     /**
122      * 导出列头背景颜色
123      */
124     public IndexedColors headerBackgroundColor() default IndexedColors.GREY_50_PERCENT;
125
126     /**
127      * 导出列头字体颜色
128      */
129     public IndexedColors headerColor() default IndexedColors.WHITE;
130
131     /**
132      * 导出单元格背景颜色
133      */
134     public IndexedColors backgroundColor() default IndexedColors.WHITE;
135
136     /**
137      * 导出单元格字体颜色
138      */
139     public IndexedColors color() default IndexedColors.BLACK;
140
141     /**
142      * 导出字段对齐方式
143      */
144     public HorizontalAlignment align() default HorizontalAlignment.CENTER;
145
146     /**
147      * 自定义数据处理器
148      */
149     public Class<?> handler() default ExcelHandlerAdapter.class;
150
151     /**
152      * 自定义数据处理器参数
153      */
154     public String[] args() default {};
155
156     /**
157      * 字段类型(0:导出导入;1:仅导出;2:仅导入)
158      */
159     Type type() default Type.ALL;
160
161     public enum Type
162     {
163         ALL(0), EXPORT(1), IMPORT(2);
164         private final int value;
165
166         Type(int value)
167         {
168             this.value = value;
169         }
170
171         public int value()
172         {
173             return this.value;
174         }
175     }
176
177     public enum ColumnType
178     {
179         NUMERIC(0), STRING(1), IMAGE(2), TEXT(3);
180         private final int value;
181
182         ColumnType(int value)
183         {
184             this.value = value;
185         }
186
187         public int value()
188         {
189             return this.value;
190         }
191     }
192 }