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
f582413f
Commit
f582413f
authored
Dec 27, 2018
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
c3155945
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
12 deletions
+21
-12
WebUtilController.java
.../java/com/egolm/film/api/web/admin/WebUtilController.java
+3
-5
Export.java
src/main/java/com/egolm/film/util/Export.java
+18
-7
No files found.
src/main/java/com/egolm/film/api/web/admin/WebUtilController.java
View file @
f582413f
...
...
@@ -81,11 +81,9 @@ public class WebUtilController {
@Transactional
@PostMapping
(
"exportExcel"
)
@ApiOperation
(
"导出Excel"
)
public
void
exportExcel
(
String
db_host
,
String
db_name
,
String
username
,
String
password
,
HttpServletResponse
response
)
throws
SQLException
,
IOException
{
String
filename
=
"export.xls"
;
response
.
addHeader
(
"Content-Disposition"
,
"attachment;filename="
+
new
String
(
filename
.
getBytes
()));
response
.
setContentType
(
"application/octet-stream"
);
new
Export
(
db_host
,
db_name
,
username
,
password
).
export
(
response
.
getOutputStream
());
public
void
exportExcel
(
String
db_host
,
String
db_name
,
String
username
,
String
password
)
throws
SQLException
,
IOException
{
this
.
verifyAuth
();
new
Export
(
db_host
,
db_name
,
username
,
password
).
export
();
}
@ResponseBody
...
...
src/main/java/com/egolm/film/util/Export.java
View file @
f582413f
package
com
.
egolm
.
film
.
util
;
import
java.io.OutputStream
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.ResultSet
;
...
...
@@ -11,6 +12,7 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.Map
;
import
com.alibaba.fastjson.JSON
;
import
com.egolm.common.ExcelUtil
;
import
com.egolm.common.StringUtil
;
import
com.egolm.common.Util
;
...
...
@@ -90,13 +92,17 @@ public class Export {
return
list
;
}
public
void
export
(
OutputStream
os
)
throws
SQLException
{
Export
exp
=
new
Export
(
"10.10.0.111"
,
"tv"
,
"root"
,
"egolm#2018"
);
List
<
Map
<
String
,
Object
>>
desc
=
exp
.
getTableDesc
(
"fc_member_film"
);
List
<
Map
<
String
,
Object
>>
list
=
exp
.
queryDataList
(
"fc_member_film"
);
static
String
json
=
"[{\"COLUMN_NAME\":\"id\",\"COLUMN_TYPE\":\"bigint(11) unsigned\",\"COLUMN_COMMENT\":\"\",\"CONSTRAINT_NAME\":\"PRIMARY\"},{\"COLUMN_NAME\":\"film_no\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"电影编号\"},{\"COLUMN_NAME\":\"origion_name\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"原片名\"},{\"COLUMN_NAME\":\"en_name\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"英文名称\"},{\"COLUMN_NAME\":\"cn_name\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"中文片名\"},{\"COLUMN_NAME\":\"type\",\"COLUMN_TYPE\":\"tinyint(10)\",\"COLUMN_COMMENT\":\"类型 1 电影 2电视\"},{\"COLUMN_NAME\":\"film_group_id\",\"COLUMN_TYPE\":\"bigint(20) unsigned\",\"COLUMN_COMMENT\":\"影片内容分组id\"},{\"COLUMN_NAME\":\"film_type\",\"COLUMN_TYPE\":\"int(10)\",\"COLUMN_COMMENT\":\"影片类型\"},{\"COLUMN_NAME\":\"film_type_name\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"导入时影片类型名称\"},{\"COLUMN_NAME\":\"film_type_name_short\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"短片类型 不知道什么用 但在操作时会填这个值\"},{\"COLUMN_NAME\":\"show_date\",\"COLUMN_TYPE\":\"varchar(100)\",\"COLUMN_COMMENT\":\"放映时间\"},{\"COLUMN_NAME\":\"show_time\",\"COLUMN_TYPE\":\"bigint(20)\",\"COLUMN_COMMENT\":\"上映时间\"},{\"COLUMN_NAME\":\"first_show_date\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"首次上映时间\"},{\"COLUMN_NAME\":\"first_show_city\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"首次上映城市\"},{\"COLUMN_NAME\":\"first_show_channel\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"首映频道\"},{\"COLUMN_NAME\":\"is_apply_other_filmfest\",\"COLUMN_TYPE\":\"int(1)\",\"COLUMN_COMMENT\":\"是否同时参加其他电影节\"},{\"COLUMN_NAME\":\"other_filmfest_name\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"同时参加的电影节的名字\"},{\"COLUMN_NAME\":\"film_medium\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"影片色彩\"},{\"COLUMN_NAME\":\"completion_date\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"完成日期\"},{\"COLUMN_NAME\":\"film_country\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"制片国\"},{\"COLUMN_NAME\":\"co_production_country\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"合拍国\"},{\"COLUMN_NAME\":\"film_producers\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"制片人\"},{\"COLUMN_NAME\":\"production_company\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"制片公司\"},{\"COLUMN_NAME\":\"enroll_type_name\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"报名性质\"},{\"COLUMN_NAME\":\"enroll_type\",\"COLUMN_TYPE\":\"tinyint(2)\",\"COLUMN_COMMENT\":\"报名类型\"},{\"COLUMN_NAME\":\"is_like_show\",\"COLUMN_TYPE\":\"tinyint(2)\",\"COLUMN_COMMENT\":\"是否愿意参展\"},{\"COLUMN_NAME\":\"create_time\",\"COLUMN_TYPE\":\"bigint(20) unsigned\",\"COLUMN_COMMENT\":\"添加时间\"},{\"COLUMN_NAME\":\"member_id\",\"COLUMN_TYPE\":\"int(10) unsigned\",\"COLUMN_COMMENT\":\"管理员id\"},{\"COLUMN_NAME\":\"create_ip\",\"COLUMN_TYPE\":\"varchar(50)\",\"COLUMN_COMMENT\":\"创建ip\"},{\"COLUMN_NAME\":\"state\",\"COLUMN_TYPE\":\"tinyint(2) unsigned\",\"COLUMN_COMMENT\":\"状态 1未提交 2 已提交\"},{\"COLUMN_NAME\":\"prize\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"该片已参加过的电影节及所获奖项\"},{\"COLUMN_NAME\":\"dialogue_lang\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"对白语言\"},{\"COLUMN_NAME\":\"subtitle_lang\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"字幕语言\"},{\"COLUMN_NAME\":\"play_shanghai\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"该片在上海电影节放映是\"},{\"COLUMN_NAME\":\"has_joined_award\",\"COLUMN_TYPE\":\"text\",\"COLUMN_COMMENT\":\"已参加过奖项\"},{\"COLUMN_NAME\":\"intro\",\"COLUMN_TYPE\":\"text\",\"COLUMN_COMMENT\":\"影片简介\"},{\"COLUMN_NAME\":\"en_intro\",\"COLUMN_TYPE\":\"text\",\"COLUMN_COMMENT\":\"影片简介英文\"},{\"COLUMN_NAME\":\"last_modify_time\",\"COLUMN_TYPE\":\"bigint(20) unsigned\",\"COLUMN_COMMENT\":\"最后修改时间\"},{\"COLUMN_NAME\":\"film_side_demand\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"片方要求\"},{\"COLUMN_NAME\":\"film_total_time\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"影片时长\"},{\"COLUMN_NAME\":\"is_show\",\"COLUMN_TYPE\":\"tinyint(2)\",\"COLUMN_COMMENT\":\"是否显示 1显示 2不显示\"},{\"COLUMN_NAME\":\"film_apply_company\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"影片申请公司\"},{\"COLUMN_NAME\":\"film_apply_realname\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"影片人姓名\"},{\"COLUMN_NAME\":\"film_apply_job\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"影片人职务\"},{\"COLUMN_NAME\":\"film_apply_email\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"影片申请人邮箱\"},{\"COLUMN_NAME\":\"film_apply_tel\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"影片申请人电话\"},{\"COLUMN_NAME\":\"film_apply_mobile\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"影片申请人手机\"},{\"COLUMN_NAME\":\"film_apply_country\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"影片申请国籍\"},{\"COLUMN_NAME\":\"film_contract_realname\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"联系人姓名\"},{\"COLUMN_NAME\":\"film_contract_job\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"联系人职务\"},{\"COLUMN_NAME\":\"film_contract_mobile\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"联系人手机\"},{\"COLUMN_NAME\":\"film_contract_email\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"联系人邮箱\"},{\"COLUMN_NAME\":\"enroll_type_name_other\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"报名性质\"},{\"COLUMN_NAME\":\"film_format\",\"COLUMN_TYPE\":\"varchar(10)\",\"COLUMN_COMMENT\":\"样片形式 0为移动存储 1为在线\"},{\"COLUMN_NAME\":\"film_format_url\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"样片url\"},{\"COLUMN_NAME\":\"film_format_passw\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"样片url密码\"},{\"COLUMN_NAME\":\"film_format_other\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"样片url其他\"},{\"COLUMN_NAME\":\"film_is_original\",\"COLUMN_TYPE\":\"varchar(10)\",\"COLUMN_COMMENT\":\"是否原创 0原创 1改编\"},{\"COLUMN_NAME\":\"film_original\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"原著/原IP\"},{\"COLUMN_NAME\":\"lang\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"语言\"},{\"COLUMN_NAME\":\"apply_state\",\"COLUMN_TYPE\":\"tinyint(2) unsigned\",\"COLUMN_COMMENT\":\"初审状态 1 未受理, 2 初审通过,3 初审否决\"},{\"COLUMN_NAME\":\"film_district\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"区域\"},{\"COLUMN_NAME\":\"is_check_director\",\"COLUMN_TYPE\":\"tinyint(2) unsigned\",\"COLUMN_COMMENT\":\"状态\"},{\"COLUMN_NAME\":\"pass_time\",\"COLUMN_TYPE\":\"bigint(20) unsigned\",\"COLUMN_COMMENT\":\"通过时间\"},{\"COLUMN_NAME\":\"tv_steps\",\"COLUMN_TYPE\":\"varchar(25)\",\"COLUMN_COMMENT\":\"节目级数\"},{\"COLUMN_NAME\":\"tv_upstar_channel\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"上星频道\"},{\"COLUMN_NAME\":\"tv_upstar_time\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"上星日期\"},{\"COLUMN_NAME\":\"tv_posters\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"上传海报\"},{\"COLUMN_NAME\":\"plays_is_agree\",\"COLUMN_TYPE\":\"varchar(32)\",\"COLUMN_COMMENT\":\"播放及宣传 yes 同意 no不同意\"},{\"COLUMN_NAME\":\"plays_is_agree1\",\"COLUMN_TYPE\":\"varchar(32)\",\"COLUMN_COMMENT\":\"播放及宣传 yes 同意 no不同意\"},{\"COLUMN_NAME\":\"plays_data\",\"COLUMN_TYPE\":\"varchar(255)\",\"COLUMN_COMMENT\":\"播放及宣传 资料\"},{\"COLUMN_NAME\":\"first_check_result\",\"COLUMN_TYPE\":\"int(1)\",\"COLUMN_COMMENT\":\"第一步检测结果 1为 true 0为 false\"},{\"COLUMN_NAME\":\"upload_id\",\"COLUMN_TYPE\":\"varchar(64)\",\"COLUMN_COMMENT\":\"上传影片标记\"},{\"COLUMN_NAME\":\"upload_state\",\"COLUMN_TYPE\":\"int(11)\",\"COLUMN_COMMENT\":\"上传影片状态(0上传中,1已完成)\"},{\"COLUMN_NAME\":\"upload_time\",\"COLUMN_TYPE\":\"datetime\",\"COLUMN_COMMENT\":\"上传影片时间\"}]\r\n"
;
public
void
export
()
throws
SQLException
,
FileNotFoundException
{
// List<Map<String, Object>> desc = this.getTableDesc("fc_member_film");
// System.out.println(JSON.toJSONString(desc));
List
<
Object
>
desc
=
JSON
.
parseArray
(
json
);
List
<
Map
<
String
,
Object
>>
list
=
this
.
queryDataList
(
"fc_member_film"
);
List
<
String
>
argsList
=
new
ArrayList
<
String
>();
List
<
String
>
titleList
=
new
ArrayList
<
String
>();
for
(
Map
<
String
,
Object
>
map
:
desc
)
{
for
(
Object
obj
:
desc
)
{
Map
<
String
,
Object
>
map
=
(
Map
<
String
,
Object
>)
obj
;
String
columnName
=
(
String
)
map
.
get
(
"COLUMN_NAME"
);
argsList
.
add
(
columnName
);
String
columnComment
=
(
String
)
map
.
get
(
"COLUMN_COMMENT"
);
...
...
@@ -114,7 +120,12 @@ public class Export {
titleList
.
add
(
"发行方"
);
argsList
.
add
(
"show"
);
titleList
.
add
(
"参加过的电视节"
);
ExcelUtil
.
excel
(
os
,
argsList
.
toArray
(
new
String
[
argsList
.
size
()]),
titleList
.
toArray
(
new
String
[
titleList
.
size
()]),
null
,
list
);
ExcelUtil
.
excel
(
new
FileOutputStream
(
"/data/export.xls"
),
argsList
.
toArray
(
new
String
[
argsList
.
size
()]),
titleList
.
toArray
(
new
String
[
titleList
.
size
()]),
null
,
list
);
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Export
exp
=
new
Export
(
"10.10.0.111"
,
"tv"
,
"root"
,
"egolm#2018"
);
exp
.
export
();
}
}
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