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
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
;
package
com
.
egolm
.
film
.
api
.
service
.
impl
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.net.HttpURLConnection
;
import
java.net.HttpURLConnection
;
...
@@ -575,48 +574,47 @@ public class ExportServiceImpl implements ExportService {
...
@@ -575,48 +574,47 @@ public class ExportServiceImpl implements ExportService {
@Override
@Override
public
void
exportPublication
(
ServletOutputStream
os
,
Fc_member_film
film
)
{
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
;
HSSFWorkbook
wb
=
null
;
FileInputStream
fis
=
null
;
FileInputStream
fis
=
null
;
try
{
try
{
fis
=
new
FileInputStream
(
publicationPath
);
fis
=
new
FileInputStream
(
publicationPath
);
wb
=
new
HSSFWorkbook
(
fis
);
wb
=
new
HSSFWorkbook
(
fis
);
HSSFSheet
sheet
=
wb
.
getSheetAt
(
0
);
HSSFSheet
sheet
=
wb
.
getSheetAt
(
0
);
for
(
String
key
:
vars
.
keySet
())
{
String
value
=
vars
.
get
(
key
);
Fc_member_film_ext
filmExt
=
filmService
.
queryFilmExt
(
film
.
getId
().
intValue
());
String
[]
xyAry
=
key
.
split
(
","
,
2
);
Map
<
String
,
String
>
stringVars
=
new
HashMap
<
String
,
String
>();
Integer
x
=
Integer
.
valueOf
(
xyAry
[
1
]);
stringVars
.
put
(
"1,1"
,
film
.
getCn_name
());
Integer
y
=
Integer
.
valueOf
(
xyAry
[
0
]);
stringVars
.
put
(
"2,1"
,
film
.
getEn_name
());
Cell
cell
=
sheet
.
getRow
(
y
-
1
).
getCell
(
x
-
1
);
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
)
{
if
(
cell
!=
null
)
{
String
tplValue
=
cell
.
getStringCellValue
();
String
tplValue
=
cell
.
getStringCellValue
();
...
@@ -634,60 +632,39 @@ public class ExportServiceImpl implements ExportService {
...
@@ -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
();
HSSFPatriarch
patriarch
=
sheet
.
createDrawingPatriarch
();
for
(
String
key
:
photoVars
.
keySet
())
{
/**
if
(
StringUtil
.
isNotBlank
(
key
))
{
* 处理剧照
try
{
*/
String
[]
c1_r1_c2_r2_ary
=
key
.
split
(
","
,
4
);
if
(
StringUtil
.
isNotBlank
(
filmExt
.
getPhoto_mv
()))
{
short
c1
=
Short
.
valueOf
(
c1_r1_c2_r2_ary
[
0
]);
try
{
int
r1
=
Integer
.
valueOf
(
c1_r1_c2_r2_ary
[
1
]);
String
pathMvPhoto
=
ossService
.
getOssPath
(
filmExt
.
getPhoto_mv
(),
10
);
short
c2
=
Short
.
valueOf
(
c1_r1_c2_r2_ary
[
2
]);
URL
mvPhotoUrl
=
new
URL
(
pathMvPhoto
);
int
r2
=
Integer
.
valueOf
(
c1_r1_c2_r2_ary
[
3
]);
HttpURLConnection
mvPhotoConn
=
(
HttpURLConnection
)
mvPhotoUrl
.
openConnection
();
String
pathMvPhoto
=
ossService
.
getOssPath
(
photoVars
.
get
(
key
),
10
);
mvPhotoConn
.
setRequestMethod
(
"GET"
);
URL
mvPhotoUrl
=
new
URL
(
pathMvPhoto
);
mvPhotoConn
.
setConnectTimeout
(
50
*
1000
);
HttpURLConnection
mvPhotoConn
=
(
HttpURLConnection
)
mvPhotoUrl
.
openConnection
();
InputStream
mvPhotoInstream
=
mvPhotoConn
.
getInputStream
();
mvPhotoConn
.
setRequestMethod
(
"GET"
);
byte
[]
mvPhotoBytes
=
FileUtil
.
streamToBytes
(
mvPhotoInstream
);
mvPhotoConn
.
setConnectTimeout
(
50
*
1000
);
ClientAnchor
anchor
=
new
HSSFClientAnchor
(
0
,
0
,
1023
,
255
,(
short
)
0
,
3
,(
short
)
9
,
3
);
InputStream
mvPhotoInstream
=
mvPhotoConn
.
getInputStream
();
int
pritureType
=
HSSFWorkbook
.
PICTURE_TYPE_JPEG
;
byte
[]
mvPhotoBytes
=
FileUtil
.
streamToBytes
(
mvPhotoInstream
);
String
fileName
=
filmExt
.
getPhoto_director
().
toUpperCase
();
ClientAnchor
anchor
=
new
HSSFClientAnchor
(
0
,
0
,
1023
,
255
,
c1
,
r1
,
c2
,
r2
);
if
(
fileName
.
endsWith
(
".JPG"
)
||
fileName
.
endsWith
(
".JPEG"
))
{
int
pritureType
=
HSSFWorkbook
.
PICTURE_TYPE_JPEG
;
pritureType
=
HSSFWorkbook
.
PICTURE_TYPE_JPEG
;
String
fileName
=
filmExt
.
getPhoto_director
().
toUpperCase
();
}
else
if
(
fileName
.
endsWith
(
".PNG"
))
{
if
(
fileName
.
endsWith
(
".JPG"
)
||
fileName
.
endsWith
(
".JPEG"
))
{
pritureType
=
HSSFWorkbook
.
PICTURE_TYPE_PNG
;
pritureType
=
HSSFWorkbook
.
PICTURE_TYPE_JPEG
;
}
}
else
if
(
fileName
.
endsWith
(
".PNG"
))
{
patriarch
.
createPicture
(
anchor
,
wb
.
addPicture
(
mvPhotoBytes
,
pritureType
));
pritureType
=
HSSFWorkbook
.
PICTURE_TYPE_PNG
;
}
catch
(
FileNotFoundException
e
)
{
}
e
.
printStackTrace
();
patriarch
.
createPicture
(
anchor
,
wb
.
addPicture
(
mvPhotoBytes
,
pritureType
));
}
}
catch
(
Exception
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
();
}
}
}
wb
.
write
(
os
);
wb
.
write
(
os
);
fis
.
close
();
fis
.
close
();
}
catch
(
Exception
e
)
{
}
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