Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
customer-service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
QG
customer-service
Commits
b0dad9e9
Commit
b0dad9e9
authored
Sep 30, 2020
by
suntao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
结清文件下载
parent
26b1d9cd
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
187 additions
and
0 deletions
+187
-0
FileRest.java
src/main/java/cn/quantgroup/customer/rest/FileRest.java
+72
-0
OrderRest.java
src/main/java/cn/quantgroup/customer/rest/OrderRest.java
+11
-0
IFileService.java
...ain/java/cn/quantgroup/customer/service/IFileService.java
+13
-0
IIceService.java
...main/java/cn/quantgroup/customer/service/IIceService.java
+2
-0
IOrderService.java
...in/java/cn/quantgroup/customer/service/IOrderService.java
+12
-0
FileServiceImpl.java
.../cn/quantgroup/customer/service/impl/FileServiceImpl.java
+67
-0
IceServiceImpl.java
...a/cn/quantgroup/customer/service/impl/IceServiceImpl.java
+5
-0
OrderServiceImpl.java
...cn/quantgroup/customer/service/impl/OrderServiceImpl.java
+5
-0
No files found.
src/main/java/cn/quantgroup/customer/rest/FileRest.java
0 → 100644
View file @
b0dad9e9
package
cn
.
quantgroup
.
customer
.
rest
;
import
cn.quantgroup.customer.service.IFileService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
/**
* 文件下载
*
* @author tao
* @version 2020-09-30 17:12
*/
@Controller
@RequestMapping
(
"/download"
)
public
class
FileRest
{
@Autowired
private
HttpServletRequest
request
;
@Autowired
private
IFileService
fileService
;
// 文件下载相关代码
@RequestMapping
(
"/settle_prove/{loanId}"
)
public
String
downloadFile
(
HttpServletResponse
response
,
@PathVariable
Long
loanId
)
throws
Exception
{
BufferedInputStream
bis
=
fileService
.
getBufferedInputStream
(
loanId
);
if
(
bis
!=
null
)
{
response
.
setContentType
(
"application/force-download"
);
// 设置强制下载不打开
//response.addHeader("Content-Disposition", "attachment;fileName=" + fileName);// 设置文件名
//response.setContentType("multipart/form-data;charset=UTF-8");也可以明确的设置一下UTF-8,测试中不设置也可以。
response
.
setHeader
(
"Content-Disposition"
,
"attachment;fileName="
+
new
String
((
"结清证明_"
+
loanId
).
getBytes
(
"GB2312"
),
"ISO-8859-1"
));
byte
[]
buffer
=
new
byte
[
1024
];
FileInputStream
fis
=
null
;
try
{
OutputStream
os
=
response
.
getOutputStream
();
int
i
=
bis
.
read
(
buffer
);
while
(
i
!=
-
1
)
{
os
.
write
(
buffer
,
0
,
i
);
i
=
bis
.
read
(
buffer
);
}
System
.
out
.
println
(
"下载成功"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
bis
!=
null
)
{
try
{
bis
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
if
(
fis
!=
null
)
{
try
{
fis
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
return
null
;
}
}
src/main/java/cn/quantgroup/customer/rest/OrderRest.java
View file @
b0dad9e9
...
@@ -96,4 +96,15 @@ public class OrderRest {
...
@@ -96,4 +96,15 @@ public class OrderRest {
log
.
info
(
"[申请结清证明],请求参数:loanId={}"
,
loanId
);
log
.
info
(
"[申请结清证明],请求参数:loanId={}"
,
loanId
);
return
orderService
.
applySettle
(
loanId
);
return
orderService
.
applySettle
(
loanId
);
}
}
/**
* 结清证明下载
*
* @param loanId
* @return
*/
@GetMapping
(
"/download_settle/{loanId}"
)
public
JsonResult
downloadSettle
(
@PathVariable
Long
loanId
)
{
log
.
info
(
"[结清证明下载],请求参数:loanId={}"
,
loanId
);
return
orderService
.
downloadSettle
(
loanId
);
}
}
}
src/main/java/cn/quantgroup/customer/service/IFileService.java
0 → 100644
View file @
b0dad9e9
package
cn
.
quantgroup
.
customer
.
service
;
import
java.io.BufferedInputStream
;
import
java.net.MalformedURLException
;
/**
* @author tao
* @version 2020-09-30 17:27
*/
public
interface
IFileService
{
BufferedInputStream
getBufferedInputStream
(
Long
loanId
)
throws
MalformedURLException
,
Exception
;
}
src/main/java/cn/quantgroup/customer/service/IIceService.java
View file @
b0dad9e9
...
@@ -17,4 +17,6 @@ public interface IIceService {
...
@@ -17,4 +17,6 @@ public interface IIceService {
JsonResult
<
Map
<
Long
,
Integer
>>
findSettleFlag
(
List
<
Long
>
loanIds
);
JsonResult
<
Map
<
Long
,
Integer
>>
findSettleFlag
(
List
<
Long
>
loanIds
);
JsonResult
applySettle
(
Long
loanId
);
JsonResult
applySettle
(
Long
loanId
);
JsonResult
downloadSettle
(
Long
loanId
);
}
}
src/main/java/cn/quantgroup/customer/service/IOrderService.java
View file @
b0dad9e9
...
@@ -65,5 +65,17 @@ public interface IOrderService{
...
@@ -65,5 +65,17 @@ public interface IOrderService{
*/
*/
JsonResult
<
List
<
OpLog
>>
queryOperateLog
(
Long
loanId
);
JsonResult
<
List
<
OpLog
>>
queryOperateLog
(
Long
loanId
);
/**
* 申请结清证明
* @param loanId
* @return
*/
JsonResult
applySettle
(
Long
loanId
);
JsonResult
applySettle
(
Long
loanId
);
/**
* 结清证明下载
* @param loanId
* @return
*/
JsonResult
downloadSettle
(
Long
loanId
);
}
}
src/main/java/cn/quantgroup/customer/service/impl/FileServiceImpl.java
0 → 100644
View file @
b0dad9e9
package
cn
.
quantgroup
.
customer
.
service
.
impl
;
import
cn.quantgroup.customer.service.IFileService
;
import
org.springframework.stereotype.Service
;
import
java.io.BufferedInputStream
;
import
java.net.HttpURLConnection
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
/**
* 文件流转发
*
* @author tao
* @version 2020-09-30 17:28
*/
@Service
public
class
FileServiceImpl
implements
IFileService
{
//随便写一个
private
static
final
String
boundary
=
java
.
util
.
UUID
.
randomUUID
().
toString
();
@Override
public
BufferedInputStream
getBufferedInputStream
(
Long
loanId
)
throws
Exception
{
HttpURLConnection
con
=
(
HttpURLConnection
)
new
URL
(
""
).
openConnection
();
// 设置是否向httpUrlConnection输出,因为这个是post请求,参数要放在
// http正文内,因此需要设为true, 默认情况下是false;
con
.
setDoOutput
(
true
);
// 设置是否从httpUrlConnection读入,默认情况下是true;
con
.
setDoInput
(
true
);
// 设定请求的方法为"POST",默认是GET
con
.
setRequestMethod
(
"POST"
);
// Post 请求不能使用缓存
con
.
setUseCaches
(
false
);
//设置接收返回值的格式
con
.
setRequestProperty
(
"Accept"
,
"text/plain, */*"
);
//设置接收编码
con
.
setRequestProperty
(
"Accept-Language"
,
"zh-cn"
);
con
.
setRequestProperty
(
"Host"
,
"127.0.0.1"
);
//设置请求参数格式以及boundary分割线
con
.
setRequestProperty
(
"Content-Type"
,
"multipart/form-data;boundary="
+
boundary
);
con
.
setRequestProperty
(
"User-Agent"
,
" WinHttpClient"
);
//开启长连接可以持续传输
con
.
setRequestProperty
(
"Connection"
,
"Keep-Alive"
);
//连接超时时间20秒
con
.
setConnectTimeout
(
20000
);
//读取超时时间20秒
con
.
setReadTimeout
(
20000
);
int
responseCode
=
con
.
getResponseCode
();
if
(
responseCode
==
HttpURLConnection
.
HTTP_OK
)
{
String
fileName
=
""
;
try
{
fileName
=
con
.
getHeaderField
(
1
).
substring
(
21
,
con
.
getHeaderField
(
1
).
length
()
-
1
);
fileName
=
"EBDT"
+
fileName
.
split
(
"_"
)[
1
];
System
.
out
.
println
(
fileName
);
}
catch
(
Exception
e
)
{
return
null
;
}
return
new
BufferedInputStream
(
con
.
getInputStream
());
}
return
null
;
}
}
src/main/java/cn/quantgroup/customer/service/impl/IceServiceImpl.java
View file @
b0dad9e9
...
@@ -202,4 +202,9 @@ public class IceServiceImpl implements IIceService {
...
@@ -202,4 +202,9 @@ public class IceServiceImpl implements IIceService {
JsonResult
<
Boolean
>
jsonResult
=
JSONTools
.
deserialize
(
result
,
typeToken
);
JsonResult
<
Boolean
>
jsonResult
=
JSONTools
.
deserialize
(
result
,
typeToken
);
return
jsonResult
;
return
jsonResult
;
}
}
@Override
public
JsonResult
downloadSettle
(
Long
loanId
)
{
return
null
;
}
}
}
src/main/java/cn/quantgroup/customer/service/impl/OrderServiceImpl.java
View file @
b0dad9e9
...
@@ -473,6 +473,11 @@ public class OrderServiceImpl implements IOrderService {
...
@@ -473,6 +473,11 @@ public class OrderServiceImpl implements IOrderService {
return
iceService
.
applySettle
(
loanId
);
return
iceService
.
applySettle
(
loanId
);
}
}
@Override
public
JsonResult
downloadSettle
(
Long
loanId
)
{
return
iceService
.
downloadSettle
(
loanId
);
}
/**
/**
* 处理查询不到orderMapping的情况,可能是进件失败,也可能不存在该笔订单
* 处理查询不到orderMapping的情况,可能是进件失败,也可能不存在该笔订单
*
*
...
...
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