Skip to content

Commit c31786e

Browse files
authored
Merge pull request #1 from MatrixSeven/dev
Dev
2 parents 08abea5 + d3ba3e5 commit c31786e

29 files changed

+1224
-307
lines changed

src/main/java/seven/ExcelFactory.java

Lines changed: 114 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
package seven;
22

3+
import org.apache.poi.ss.formula.functions.T;
34
import seven.callBack.PackageDataInterface;
5+
import seven.config.Config;
46
import seven.savewapper.SaveExcel;
57
import seven.savewapper.wapperRef.sysWppers.ResExportDBMap;
68
import seven.savewapper.wapperRef.sysWppers.ResExportDBObj;
79
import seven.savewapper.wapperRef.sysWppers.ResExportMap;
810
import seven.savewapper.wapperRef.sysWppers.ResExportObj;
9-
import seven.wapperInt.Wrapper;
11+
import seven.wapperInt.ReaderMap;
12+
import seven.wapperInt.ReaderObj;
1013
import seven.wapperInt.wapperRef.WrapperObj;
14+
import seven.wapperInt.wapperRef.sysWppers.ResWrapperMap;
15+
import seven.wapperInt.wapperRef.sysWppers.ResWrapperObj;
1116

17+
import java.io.File;
1218
import java.sql.ResultSet;
1319
import java.util.List;
1420
import java.util.Map;
21+
import java.util.function.Consumer;
1522

1623

1724
//=======================================================
@@ -29,6 +36,7 @@
2936
// ___`. | .'___
3037
// (______|______)
3138
//=======================================================
39+
3240
/**
3341
* @author Seven<p>
3442
* date 2016年6月4日-下午4:08:19
@@ -41,15 +49,116 @@ private ExcelFactory() {
4149

4250
/**
4351
* 读取Excel
52+
*
53+
* @param FilePath 路径
54+
* @param r 包装类
55+
* @return Wrapper
56+
* @throws Exception
57+
*/
58+
public static ReaderMap getMaps(String FilePath) throws Exception {
59+
return (ReaderMap) new ResWrapperMap(it->{}).init(FilePath);
60+
}
61+
62+
/**
63+
* 读取Excel
64+
*
65+
* @param FilePath 路径
66+
* @param r 包装类
67+
* @return Wrapper
68+
* @throws Exception
69+
*/
70+
public static <T> ReaderObj<T> getBeans(Class clazz,String FilePath) throws Exception {
71+
return new ResWrapperObj(clazz,it->{}).init(FilePath);
72+
}
73+
74+
/**
75+
* 读取Excel
76+
*
77+
* @param FilePath 路径
78+
* @param r 包装类
79+
* @return Wrapper
80+
* @throws Exception
81+
*/
82+
public static ReaderMap getMaps(String FilePath, Consumer<Config> config) throws Exception {
83+
return (ReaderMap) new ResWrapperMap(config).init(FilePath);
84+
}
85+
86+
/**
87+
* 读取Excel
88+
*
89+
* @param FilePath 路径
90+
* @param r 包装类
91+
* @return Wrapper
92+
* @throws Exception
93+
*/
94+
public static <T> ReaderObj<T> getBeans(Class clazz,String FilePath, Consumer<Config> config) throws Exception {
95+
return new ResWrapperObj(clazz, config).init(FilePath);
96+
}
97+
98+
/**
99+
* 读取Excel
100+
*
101+
* @param FilePath 路径
102+
* @param r 包装类
103+
* @return Wrapper
104+
* @throws Exception
105+
*/
106+
public static ReaderMap getMaps(File file) throws Exception {
107+
return (ReaderMap) new ResWrapperMap(it->{}).init(file);
108+
}
109+
110+
/**
111+
* 读取Excel
112+
*
113+
* @param FilePath 路径
114+
* @param r 包装类
115+
* @return Wrapper
116+
* @throws Exception
117+
*/
118+
public static <T> ReaderObj<T> getBeans(Class clazz,File file) throws Exception {
119+
return new ResWrapperObj(clazz,it->{}).init(file);
120+
}
121+
122+
/**
123+
* 读取Excel
124+
*
125+
* @param FilePath 路径
126+
* @param r 包装类
127+
* @return Wrapper
128+
* @throws Exception
129+
*/
130+
public static ReaderMap getMaps(File file, Consumer<Config> config) throws Exception {
131+
return (ReaderMap) new ResWrapperMap(config).init(file);
132+
}
133+
134+
/**
135+
* 读取Excel
136+
*
44137
* @param FilePath 路径
45138
* @param r 包装类
46139
* @return Wrapper
47140
* @throws Exception
48141
*/
49-
public static <T> Wrapper<T> getBeans(String FilePath, WrapperObj<T> r) throws Exception {
50-
return r.init(FilePath);
142+
public static <T> ReaderObj<T> getBeans(Class clazz,File file, Consumer<Config> config) throws Exception {
143+
return new ResWrapperObj(clazz, config).init(file);
51144
}
52145

146+
147+
148+
149+
150+
151+
152+
153+
154+
155+
156+
157+
158+
159+
160+
161+
53162
/**
54163
* 保存Excel
55164
*
@@ -58,12 +167,12 @@ public static <T> Wrapper<T> getBeans(String FilePath, WrapperObj<T> r) throws E
58167
* @return SaveExcel
59168
* @throws Exception
60169
*/
61-
public static <T> SaveExcel<T> saveExcel(List<? extends T> bean, String FilePath) throws Exception {
170+
public static <T> SaveExcel<T> saveExcel(List<? extends T> bean, String FilePath) throws Exception {
62171
if (bean.size() < 1) {
63172
throw new Exception("请传入数据");
64173
}
65174
if (bean.get(0) instanceof Map) {
66-
return (SaveExcel<T>) new ResExportMap((List<Map>)bean, FilePath);
175+
return (SaveExcel<T>) new ResExportMap((List<Map>) bean, FilePath);
67176
}
68177
return new ResExportObj(bean, FilePath);
69178
}

src/main/java/seven/ExcelSuperInterface.java

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,54 @@
1515
// (______|______)
1616
//=======================================================
1717

18+
import seven.callBack.DataFilterColumnInterface;
19+
import seven.callBack.DataFilterInterface;
20+
import seven.callBack.DataFilterProcessInterface;
21+
import seven.wapperInt.Wrapper;
22+
23+
import java.util.Comparator;
24+
import java.util.List;
25+
import java.util.function.Consumer;
26+
1827
/**
1928
* [Zhihu]https://www.zhihu.com/people/Sweets07
2029
* [Github]https://github.com/MatrixSeven
2130
* Created by seven on 2016/12/1.
2231
*/
23-
public interface ExcelSuperInterface {
32+
public interface ExcelSuperInterface<T,R> {
33+
34+
/**
35+
* 对要包装的数据进行过滤,对应实体Bean\n
36+
* 如果返回false将放弃此条数据
37+
*
38+
* @param filter {@link DataFilterInterface}
39+
* @return Wrapper
40+
*/
41+
T Filter(DataFilterInterface<? extends R> filter);
42+
43+
/**
44+
* 此处传入每一行打包好的数据。对应一个实体\n
45+
* 在process方法里可对属性进行处理加工
46+
*
47+
* @param process {@link DataFilterProcessInterface}
48+
* @return Wrapper
49+
*/
50+
T Process(DataFilterProcessInterface<? extends R> process);
51+
52+
/**
53+
* 对结果的List进行排序
54+
*
55+
* @param c
56+
* @return Wrapper
57+
*/
58+
T Sort(Comparator<? extends R> c);
59+
60+
/**
61+
* 此处过滤Excel的列数据(列名)\n
62+
* 如果加入后,将不对实体进行赋值
63+
*
64+
* @param consumer {@link DataFilterColumnInterface}
65+
*/
66+
T FilterCol(Consumer<List<String>> consumer);
2467

2568
}

src/main/java/seven/anno/ExcelAnno.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package seven.anno;
22

3+
import seven.callBack.ConvertInterface;
4+
import seven.callBack.imp.DefaultConvert;
5+
6+
import javax.swing.text.DateFormatter;
37
import java.lang.annotation.ElementType;
48
import java.lang.annotation.Retention;
59
import java.lang.annotation.RetentionPolicy;
@@ -20,14 +24,24 @@
2024
// ___`. | .'___
2125
// (______|______)
2226
//=======================================================
27+
2328
/**
2429
* @author Seven
2530
*/
2631
@Target(ElementType.FIELD)
2732
@Retention(RetentionPolicy.RUNTIME)
2833
public @interface ExcelAnno {
29-
String Value()default "Null";
30-
boolean Pass() default false;
31-
String Required() default "Null";
32-
short Align() default 0x2;
33-
}
34+
35+
String Value() default "Null";
36+
37+
boolean Pass() default false;
38+
39+
String Required() default "Null";
40+
41+
short Align() default 0x2;
42+
43+
@Deprecated
44+
Class<? extends ConvertInterface> Convert() default DefaultConvert.class;
45+
46+
String DateTimeFormatter() default "yyyy-MM-dd hh:mm:ss";
47+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package seven.callBack;
2+
3+
//=======================================================
4+
// .----.
5+
// _.'__ `.
6+
// .--(^)(^^)---/!\
7+
// .' @ /!!!\
8+
// : , !!!!
9+
// `-..__.-' _.-\!!!/
10+
// `;_: `"'
11+
// .'"""""`.
12+
// /, ya ,\\
13+
// //狗神保佑\\
14+
// `-._______.-'
15+
// ___`. | .'___
16+
// (______|______)
17+
//=======================================================
18+
19+
/**
20+
* @author Seven
21+
* FileName: FiledConvert.java
22+
* Created by Seven on 2019/12/2
23+
**/
24+
@FunctionalInterface
25+
public interface ConvertInterface<T> {
26+
T convert(Object o);
27+
}
28+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package seven.callBack.imp;
2+
3+
//=======================================================
4+
// .----.
5+
// _.'__ `.
6+
// .--(^)(^^)---/!\
7+
// .' @ /!!!\
8+
// : , !!!!
9+
// `-..__.-' _.-\!!!/
10+
// `;_: `"'
11+
// .'"""""`.
12+
// /, ya ,\\
13+
// //狗神保佑\\
14+
// `-._______.-'
15+
// ___`. | .'___
16+
// (______|______)
17+
//=======================================================
18+
19+
import seven.callBack.ConvertInterface;
20+
21+
/**
22+
* @author Seven
23+
* FileName: DefaultConvert.java
24+
* Created by Seven on 2019/12/2
25+
**/
26+
public class DefaultConvert implements ConvertInterface<Object> {
27+
@Override
28+
public Object convert(Object o) {
29+
return o;
30+
}
31+
}

0 commit comments

Comments
 (0)