Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
sentinel
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
曲欣亮
sentinel
Commits
859b39c5
Commit
859b39c5
authored
Mar 07, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
b56b386d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
89 deletions
+66
-89
ExportServiceImpl.java
...va/com/egolm/film/api/service/impl/ExportServiceImpl.java
+66
-89
No files found.
src/main/java/com/egolm/film/api/service/impl/ExportServiceImpl.java
View file @
859b39c5
package
com
.
egolm
.
film
.
api
.
service
.
impl
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.HttpURLConnection
;
...
...
@@ -575,48 +574,47 @@ public class ExportServiceImpl implements ExportService {
@Override
public
void
exportPublication
(
ServletOutputStream
os
,
Fc_member_film
film
)
{
Fc_member_film_ext
filmExt
=
filmService
.
queryFilmExt
(
film
.
getId
().
intValue
());
Map
<
String
,
String
>
vars
=
new
HashMap
<
String
,
String
>();
vars
.
put
(
"1,1"
,
film
.
getCn_name
());
vars
.
put
(
"2,1"
,
film
.
getEn_name
());
vars
.
put
(
"3,1"
,
filmExt
.
getDirector_en
());
vars
.
put
(
"6,1"
,
film
.
getFilm_country
());
vars
.
put
(
"7,1"
,
film
.
getCompletion_date
());
vars
.
put
(
"8,1"
,
film
.
getFilm_total_time
());
vars
.
put
(
"9,1"
,
ExportConstant
.
fmtopts
.
get
(
String
.
valueOf
(
filmExt
.
getFormat
())));
vars
.
put
(
"11,1"
,
filmExt
.
getScreenplay
());
vars
.
put
(
"13,1"
,
filmExt
.
getDirector_of_photography
());
vars
.
put
(
"15,1"
,
filmExt
.
getMusic
());
vars
.
put
(
"17,1"
,
filmExt
.
getProduction_designer
());
vars
.
put
(
"19,1"
,
filmExt
.
getExecutive_producer
());
vars
.
put
(
"21,1"
,
filmExt
.
getEditor
());
vars
.
put
(
"23,1"
,
filmExt
.
getProducer_en
());
vars
.
put
(
"25,1"
,
filmExt
.
getCast
());
vars
.
put
(
"27,1"
,
filmExt
.
getProduction_en
());
vars
.
put
(
"29,1"
,
filmExt
.
getWorld_sales
());
vars
.
put
(
"30,1"
,
ExportConstant
.
resolutionopts
.
get
(
String
.
valueOf
(
filmExt
.
getResolution
())));
vars
.
put
(
"31,1"
,
ExportConstant
.
aspectopts
.
get
(
String
.
valueOf
(
filmExt
.
getAspect_ratio
())));
vars
.
put
(
"32,1"
,
ExportConstant
.
soundopts
.
get
(
String
.
valueOf
(
filmExt
.
getSound_format
())));
vars
.
put
(
"33,1"
,
ExportConstant
.
frameopts
.
get
(
String
.
valueOf
(
filmExt
.
getFrame_rate
())));
vars
.
put
(
"34,1"
,
ExportConstant
.
kdmopts
.
get
(
String
.
valueOf
(
filmExt
.
getKdm
())));
vars
.
put
(
"5,3"
,
filmExt
.
getSynopsis_cn
());
vars
.
put
(
"12,3"
,
filmExt
.
getSynopsis_en
());
vars
.
put
(
"20,5"
,
filmExt
.
getDirector_biography_cn
());
vars
.
put
(
"24,5"
,
filmExt
.
getDirector_biography_en
());
HSSFWorkbook
wb
=
null
;
FileInputStream
fis
=
null
;
try
{
fis
=
new
FileInputStream
(
publicationPath
);
wb
=
new
HSSFWorkbook
(
fis
);
HSSFSheet
sheet
=
wb
.
getSheetAt
(
0
);
for
(
String
key
:
vars
.
keySet
())
{
String
value
=
vars
.
get
(
key
);
String
[]
xyAry
=
key
.
split
(
","
,
2
);
Integer
x
=
Integer
.
valueOf
(
xyAry
[
1
]);
Integer
y
=
Integer
.
valueOf
(
xyAry
[
0
]);
Cell
cell
=
sheet
.
getRow
(
y
-
1
).
getCell
(
x
-
1
);
Fc_member_film_ext
filmExt
=
filmService
.
queryFilmExt
(
film
.
getId
().
intValue
());
Map
<
String
,
String
>
stringVars
=
new
HashMap
<
String
,
String
>();
stringVars
.
put
(
"1,1"
,
film
.
getCn_name
());
stringVars
.
put
(
"2,1"
,
film
.
getEn_name
());
stringVars
.
put
(
"3,1"
,
filmExt
.
getDirector_en
());
stringVars
.
put
(
"6,1"
,
film
.
getFilm_country
());
stringVars
.
put
(
"7,1"
,
film
.
getCompletion_date
());
stringVars
.
put
(
"8,1"
,
film
.
getFilm_total_time
());
stringVars
.
put
(
"9,1"
,
ExportConstant
.
fmtopts
.
get
(
String
.
valueOf
(
filmExt
.
getFormat
())));
stringVars
.
put
(
"11,1"
,
filmExt
.
getScreenplay
());
stringVars
.
put
(
"13,1"
,
filmExt
.
getDirector_of_photography
());
stringVars
.
put
(
"15,1"
,
filmExt
.
getMusic
());
stringVars
.
put
(
"17,1"
,
filmExt
.
getProduction_designer
());
stringVars
.
put
(
"19,1"
,
filmExt
.
getExecutive_producer
());
stringVars
.
put
(
"21,1"
,
filmExt
.
getEditor
());
stringVars
.
put
(
"23,1"
,
filmExt
.
getProducer_en
());
stringVars
.
put
(
"25,1"
,
filmExt
.
getCast
());
stringVars
.
put
(
"27,1"
,
filmExt
.
getProduction_en
());
stringVars
.
put
(
"29,1"
,
filmExt
.
getWorld_sales
());
stringVars
.
put
(
"30,1"
,
ExportConstant
.
resolutionopts
.
get
(
String
.
valueOf
(
filmExt
.
getResolution
())));
stringVars
.
put
(
"31,1"
,
ExportConstant
.
aspectopts
.
get
(
String
.
valueOf
(
filmExt
.
getAspect_ratio
())));
stringVars
.
put
(
"32,1"
,
ExportConstant
.
soundopts
.
get
(
String
.
valueOf
(
filmExt
.
getSound_format
())));
stringVars
.
put
(
"33,1"
,
ExportConstant
.
frameopts
.
get
(
String
.
valueOf
(
filmExt
.
getFrame_rate
())));
stringVars
.
put
(
"34,1"
,
ExportConstant
.
kdmopts
.
get
(
String
.
valueOf
(
filmExt
.
getKdm
())));
stringVars
.
put
(
"5,3"
,
filmExt
.
getSynopsis_cn
());
stringVars
.
put
(
"12,3"
,
filmExt
.
getSynopsis_en
());
stringVars
.
put
(
"20,5"
,
filmExt
.
getDirector_biography_cn
());
stringVars
.
put
(
"24,5"
,
filmExt
.
getDirector_biography_en
());
for
(
String
key
:
stringVars
.
keySet
())
{
String
value
=
stringVars
.
get
(
key
);
String
[]
row_col_ary
=
key
.
split
(
","
,
2
);
Integer
row
=
Integer
.
valueOf
(
row_col_ary
[
0
]);
Integer
col
=
Integer
.
valueOf
(
row_col_ary
[
1
]);
Cell
cell
=
sheet
.
getRow
(
row
-
1
).
getCell
(
col
-
1
);
if
(
cell
!=
null
)
{
String
tplValue
=
cell
.
getStringCellValue
();
...
...
@@ -634,60 +632,39 @@ public class ExportServiceImpl implements ExportService {
}
}
Map
<
String
,
String
>
photoVars
=
new
HashMap
<
String
,
String
>();
photoVars
.
put
(
"0,3,9,3"
,
filmExt
.
getPhoto_mv
());
photoVars
.
put
(
"2,18,3,25"
,
filmExt
.
getPhoto_director
());
HSSFPatriarch
patriarch
=
sheet
.
createDrawingPatriarch
();
/**
* 处理剧照
*/
if
(
StringUtil
.
isNotBlank
(
filmExt
.
getPhoto_mv
()))
{
try
{
String
pathMvPhoto
=
ossService
.
getOssPath
(
filmExt
.
getPhoto_mv
(),
10
);
URL
mvPhotoUrl
=
new
URL
(
pathMvPhoto
);
HttpURLConnection
mvPhotoConn
=
(
HttpURLConnection
)
mvPhotoUrl
.
openConnection
();
mvPhotoConn
.
setRequestMethod
(
"GET"
);
mvPhotoConn
.
setConnectTimeout
(
50
*
1000
);
InputStream
mvPhotoInstream
=
mvPhotoConn
.
getInputStream
();
byte
[]
mvPhotoBytes
=
FileUtil
.
streamToBytes
(
mvPhotoInstream
);
ClientAnchor
anchor
=
new
HSSFClientAnchor
(
0
,
0
,
1023
,
255
,(
short
)
0
,
3
,(
short
)
9
,
3
);
int
pritureType
=
HSSFWorkbook
.
PICTURE_TYPE_JPEG
;
String
fileName
=
filmExt
.
getPhoto_director
().
toUpperCase
();
if
(
fileName
.
endsWith
(
".JPG"
)
||
fileName
.
endsWith
(
".JPEG"
))
{
pritureType
=
HSSFWorkbook
.
PICTURE_TYPE_JPEG
;
}
else
if
(
fileName
.
endsWith
(
".PNG"
))
{
pritureType
=
HSSFWorkbook
.
PICTURE_TYPE_PNG
;
}
patriarch
.
createPicture
(
anchor
,
wb
.
addPicture
(
mvPhotoBytes
,
pritureType
));
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
}
}
/**
* 处理导演图片
*/
if
(
StringUtil
.
isNotBlank
(
filmExt
.
getPhoto_director
()))
{
try
{
String
pathDirectorPhoto
=
ossService
.
getOssPath
(
filmExt
.
getPhoto_director
(),
10
);
URL
directorPhotoUrl
=
new
URL
(
pathDirectorPhoto
);
HttpURLConnection
directorPhotoConn
=
(
HttpURLConnection
)
directorPhotoUrl
.
openConnection
();
directorPhotoConn
.
setRequestMethod
(
"GET"
);
directorPhotoConn
.
setConnectTimeout
(
50
*
1000
);
InputStream
directorPhotoInstream
=
directorPhotoConn
.
getInputStream
();
byte
[]
directorPhotoBytes
=
FileUtil
.
streamToBytes
(
directorPhotoInstream
);
ClientAnchor
anchor
=
new
HSSFClientAnchor
(
0
,
0
,
1023
,
255
,(
short
)
2
,
18
,(
short
)
3
,
25
);
int
pritureType
=
HSSFWorkbook
.
PICTURE_TYPE_JPEG
;
String
fileName
=
filmExt
.
getPhoto_director
().
toUpperCase
();
if
(
fileName
.
endsWith
(
".JPG"
)
||
fileName
.
endsWith
(
".JPEG"
))
{
pritureType
=
HSSFWorkbook
.
PICTURE_TYPE_JPEG
;
}
else
if
(
fileName
.
endsWith
(
".PNG"
))
{
pritureType
=
HSSFWorkbook
.
PICTURE_TYPE_PNG
;
}
patriarch
.
createPicture
(
anchor
,
wb
.
addPicture
(
directorPhotoBytes
,
pritureType
));
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
}
for
(
String
key
:
photoVars
.
keySet
())
{
if
(
StringUtil
.
isNotBlank
(
key
))
{
try
{
String
[]
c1_r1_c2_r2_ary
=
key
.
split
(
","
,
4
);
short
c1
=
Short
.
valueOf
(
c1_r1_c2_r2_ary
[
0
]);
int
r1
=
Integer
.
valueOf
(
c1_r1_c2_r2_ary
[
1
]);
short
c2
=
Short
.
valueOf
(
c1_r1_c2_r2_ary
[
2
]);
int
r2
=
Integer
.
valueOf
(
c1_r1_c2_r2_ary
[
3
]);
String
pathMvPhoto
=
ossService
.
getOssPath
(
photoVars
.
get
(
key
),
10
);
URL
mvPhotoUrl
=
new
URL
(
pathMvPhoto
);
HttpURLConnection
mvPhotoConn
=
(
HttpURLConnection
)
mvPhotoUrl
.
openConnection
();
mvPhotoConn
.
setRequestMethod
(
"GET"
);
mvPhotoConn
.
setConnectTimeout
(
50
*
1000
);
InputStream
mvPhotoInstream
=
mvPhotoConn
.
getInputStream
();
byte
[]
mvPhotoBytes
=
FileUtil
.
streamToBytes
(
mvPhotoInstream
);
ClientAnchor
anchor
=
new
HSSFClientAnchor
(
0
,
0
,
1023
,
255
,
c1
,
r1
,
c2
,
r2
);
int
pritureType
=
HSSFWorkbook
.
PICTURE_TYPE_JPEG
;
String
fileName
=
filmExt
.
getPhoto_director
().
toUpperCase
();
if
(
fileName
.
endsWith
(
".JPG"
)
||
fileName
.
endsWith
(
".JPEG"
))
{
pritureType
=
HSSFWorkbook
.
PICTURE_TYPE_JPEG
;
}
else
if
(
fileName
.
endsWith
(
".PNG"
))
{
pritureType
=
HSSFWorkbook
.
PICTURE_TYPE_PNG
;
}
patriarch
.
createPicture
(
anchor
,
wb
.
addPicture
(
mvPhotoBytes
,
pritureType
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
wb
.
write
(
os
);
fis
.
close
();
}
catch
(
Exception
e
)
{
...
...
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