Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bailuntec-cost
Overview
Overview
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
huluobin
bailuntec-cost
Commits
612c585f
Commit
612c585f
authored
Jul 21, 2021
by
liyanlin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
7c46287b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
5 deletions
+21
-5
CostPlanTempController.java
.../other/module/cost/controller/CostPlanTempController.java
+21
-5
No files found.
cost-service/src/main/java/com/blt/other/module/cost/controller/CostPlanTempController.java
View file @
612c585f
...
...
@@ -19,8 +19,11 @@ import org.springframework.http.HttpHeaders;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.client.RestTemplate
;
import
java.io.ByteArrayInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.math.BigDecimal
;
@Api
(
tags
=
"付款计划详情接口"
)
...
...
@@ -93,16 +96,29 @@ public class CostPlanTempController {
CostPlanTempDomain
temp
=
costPlanTempService
.
getByTempNo
(
tempNo
);
String
filePath
=
temp
.
getFilePath
();
String
fileName
=
null
;
InputStream
inputStream
=
null
;
long
contentLength
=
0
;
if
(
null
!=
filePath
)
{
if
(
filePath
.
startsWith
(
"http"
)){
fileName
=
filePath
.
substring
(
filePath
.
lastIndexOf
(
"/"
)
+
1
);
RestTemplate
restTemplate
=
new
RestTemplate
();
byte
[]
bytes
=
restTemplate
.
getForObject
(
filePath
,
byte
[].
class
);
inputStream
=
new
ByteArrayInputStream
(
bytes
);
contentLength
=
bytes
.
length
;
}
else
{
String
[]
split
=
filePath
.
split
(
"&"
);
if
(
split
.
length
>=
1
)
{
fileName
=
split
[
split
.
length
-
1
];
assert
filePath
!=
null
;
FileSystemResource
file
=
new
FileSystemResource
(
filePath
);
inputStream
=
file
.
getInputStream
();
contentLength
=
file
.
contentLength
();
}
}
}
assert
filePath
!=
null
;
FileSystemResource
file
=
new
FileSystemResource
(
filePath
);
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
add
(
"Cache-Control"
,
"no-cache, no-store, must-revalidate"
);
// new String(fileName.getBytes("UTF-8"),"iso-8859-1") 解决文件下载的时候文件名乱码的问题
...
...
@@ -113,9 +129,9 @@ public class CostPlanTempController {
return
ResponseEntity
.
ok
()
.
headers
(
headers
)
.
contentLength
(
file
.
contentLength
()
)
.
contentLength
(
contentLength
)
.
contentType
(
MediaType
.
parseMediaType
(
"application/octet-stream"
))
.
body
(
new
InputStreamResource
(
file
.
getInputStream
()
));
.
body
(
new
InputStreamResource
(
inputStream
));
}
}
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