Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
member-api
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
曲欣亮
member-api
Commits
8e933df0
Commit
8e933df0
authored
Dec 28, 2018
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
28491703
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
26 deletions
+37
-26
Export.java
src/main/java/com/egolm/film/util/Export.java
+37
-26
No files found.
src/main/java/com/egolm/film/util/Export.java
View file @
8e933df0
package
com
.
egolm
.
film
.
util
;
package
com
.
egolm
.
film
.
util
;
import
java.io.FileNotFoundException
;
import
java.io.OutputStream
;
import
java.io.FileOutputStream
;
import
java.lang.reflect.Field
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
javax.persistence.Column
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
com.alibaba.fastjson.JSON
;
import
com.egolm.common.ExcelUtil
;
import
com.egolm.common.ExcelUtil
;
import
com.egolm.common.StringUtil
;
import
com.egolm.common.StringUtil
;
import
com.egolm.common.Util
;
import
com.egolm.common.Util
;
import
com.egolm.common.jdbc.JUtil
;
import
com.egolm.common.jdbc.JdbcTemplate
;
import
com.egolm.common.jdbc.JdbcTemplate
;
import
com.egolm.film.bean.Fc_member_film
;
import
com.egolm.film.bean.Fc_member_film
;
...
@@ -47,6 +42,8 @@ public class Export {
...
@@ -47,6 +42,8 @@ public class Export {
types
.
put
(
"heroine"
,
"女主演"
);
types
.
put
(
"heroine"
,
"女主演"
);
types
.
put
(
"supportingActor"
,
"男配角"
);
types
.
put
(
"supportingActor"
,
"男配角"
);
types
.
put
(
"supportingActress"
,
"女配角"
);
types
.
put
(
"supportingActress"
,
"女配角"
);
types
.
put
(
"issuser"
,
"发行方"
);
types
.
put
(
"show"
,
"参加过的电视节"
);
}
}
private
List
<
Map
<
String
,
Object
>>
queryDataList
()
{
private
List
<
Map
<
String
,
Object
>>
queryDataList
()
{
String
sql
=
"select t.* from fc_member_film t"
;
String
sql
=
"select t.* from fc_member_film t"
;
...
@@ -75,23 +72,37 @@ public class Export {
...
@@ -75,23 +72,37 @@ public class Export {
return
list
;
return
list
;
}
}
public
void
export
()
{
public
void
export
(
OutputStream
os
)
{
// String[] attrs = Util.clzAttributes(Fc_member_film.class);
List
<
Map
<
String
,
Object
>>
list
=
this
.
queryDataList
();
// List<Map<String, Object>> list = this.queryDataList();
List
<
String
>
argsList
=
new
ArrayList
<
String
>();
// List<String> argsList = new ArrayList<String>();
List
<
String
>
titleList
=
new
ArrayList
<
String
>();
// for(String attr : attrs) {
Class
<?>
clz
=
Fc_member_film
.
class
;
// argsList.add(attr);
Field
[]
fs
=
clz
.
getDeclaredFields
();
// }
for
(
Field
f
:
fs
)
{
//
String
columnName
=
f
.
getName
();
// for(String key : types.keySet()) {
String
columnComment
=
columnName
;
// argsList.add(key);
if
(
f
.
isAnnotationPresent
(
Column
.
class
))
{
// titleList.add(types.get(key));
Column
column
=
f
.
getAnnotation
(
Column
.
class
);
// }
if
(
StringUtil
.
isNotBlank
(
column
.
name
()))
{
// argsList.add("issuser");
columnName
=
column
.
name
();
// titleList.add("发行方");
}
// argsList.add("show");
String
columnDefinition
=
column
.
columnDefinition
();
// titleList.add("参加过的电视节");
if
(
StringUtil
.
isNotBlank
(
columnDefinition
))
{
// ExcelUtil.excel(new FileOutputStream("/data/export.xls"), argsList.toArray(new String[argsList.size()]), titleList.toArray(new String[titleList.size()]), null, list);
String
regex
=
"COMMENT '(.+)'"
;
String
comment
=
StringUtil
.
search
(
columnDefinition
,
regex
,
1
)[
0
];
if
(
StringUtil
.
isNotBlank
(
comment
))
{
columnComment
=
comment
;
}
}
}
argsList
.
add
(
columnName
);
titleList
.
add
(
columnComment
);
}
for
(
String
key
:
types
.
keySet
())
{
argsList
.
add
(
key
);
titleList
.
add
(
types
.
get
(
key
));
}
ExcelUtil
.
excel
(
os
,
argsList
.
toArray
(
new
String
[
argsList
.
size
()]),
titleList
.
toArray
(
new
String
[
titleList
.
size
()]),
null
,
list
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment