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
ce44d038
Commit
ce44d038
authored
Mar 01, 2022
by
吴琼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
交易凭证
parent
fabd338e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
111 additions
and
33 deletions
+111
-33
TransactionReceiptRecordRest.java
...uantgroup/customer/rest/TransactionReceiptRecordRest.java
+3
-2
ITransactionReceiptRecordService.java
...up/customer/service/ITransactionReceiptRecordService.java
+2
-1
TransactionReceiptRecordServiceImpl.java
...mer/service/impl/TransactionReceiptRecordServiceImpl.java
+103
-23
SFTPUtil.java
src/main/java/cn/quantgroup/customer/util/SFTPUtil.java
+3
-7
No files found.
src/main/java/cn/quantgroup/customer/rest/TransactionReceiptRecordRest.java
View file @
ce44d038
...
@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
...
@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -145,9 +146,9 @@ public class TransactionReceiptRecordRest {
...
@@ -145,9 +146,9 @@ public class TransactionReceiptRecordRest {
//导出压缩包
//导出压缩包
@RequestMapping
(
"/orderQuery/exportTransactionZipFile"
)
@RequestMapping
(
"/orderQuery/exportTransactionZipFile"
)
@ResponseBody
@ResponseBody
public
JsonResult
exportTransactionZipFile
(
HttpServletRequest
request
)
{
public
JsonResult
exportTransactionZipFile
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
try
{
try
{
return
transactionReceiptRecordService
.
exportZipFile
(
request
);
return
transactionReceiptRecordService
.
exportZipFile
(
request
,
response
);
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
e
.
printStackTrace
();
e
.
printStackTrace
();
return
JsonResult
.
buildErrorStateResult
(
"导出文件出现错误"
);
return
JsonResult
.
buildErrorStateResult
(
"导出文件出现错误"
);
...
...
src/main/java/cn/quantgroup/customer/service/ITransactionReceiptRecordService.java
View file @
ce44d038
...
@@ -6,6 +6,7 @@ import cn.quantgroup.customer.rest.vo.transaction.TransactionReceiptVO;
...
@@ -6,6 +6,7 @@ import cn.quantgroup.customer.rest.vo.transaction.TransactionReceiptVO;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.List
;
...
@@ -15,7 +16,7 @@ public interface ITransactionReceiptRecordService {
...
@@ -15,7 +16,7 @@ public interface ITransactionReceiptRecordService {
JsonResult
importTransactionReceiptRecord
(
MultipartFile
file
)
throws
IOException
;
JsonResult
importTransactionReceiptRecord
(
MultipartFile
file
)
throws
IOException
;
JsonResult
exportZipFile
(
HttpServletRequest
request
)
throws
Exception
;
JsonResult
exportZipFile
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
;
JsonResult
checkCanExport
();
JsonResult
checkCanExport
();
...
...
src/main/java/cn/quantgroup/customer/service/impl/TransactionReceiptRecordServiceImpl.java
View file @
ce44d038
package
cn
.
quantgroup
.
customer
.
service
.
impl
;
package
cn
.
quantgroup
.
customer
.
service
.
impl
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.util.ZipUtil
;
import
cn.quantgroup.customer.entity.TransactionReceiptRecord
;
import
cn.quantgroup.customer.entity.TransactionReceiptRecord
;
import
cn.quantgroup.customer.exception.BusinessException
;
import
cn.quantgroup.customer.exception.BusinessException
;
import
cn.quantgroup.customer.rest.vo.transaction.TransactionReceiptRecordVO
;
import
cn.quantgroup.customer.rest.vo.transaction.TransactionReceiptRecordVO
;
...
@@ -7,6 +9,7 @@ import cn.quantgroup.customer.repo.TransactionReceiptRecordRepo;
...
@@ -7,6 +9,7 @@ import cn.quantgroup.customer.repo.TransactionReceiptRecordRepo;
import
cn.quantgroup.customer.rest.param.transactionreceipt.TransactionReceiptRecordQuery
;
import
cn.quantgroup.customer.rest.param.transactionreceipt.TransactionReceiptRecordQuery
;
import
cn.quantgroup.customer.rest.vo.JsonResult
;
import
cn.quantgroup.customer.rest.vo.JsonResult
;
import
cn.quantgroup.customer.rest.vo.transaction.*
;
import
cn.quantgroup.customer.rest.vo.transaction.*
;
import
cn.quantgroup.customer.service.IFileService
;
import
cn.quantgroup.customer.service.ITransactionReceiptRecordService
;
import
cn.quantgroup.customer.service.ITransactionReceiptRecordService
;
import
cn.quantgroup.customer.service.http.IHttpService
;
import
cn.quantgroup.customer.service.http.IHttpService
;
import
cn.quantgroup.customer.util.ExcelUtil
;
import
cn.quantgroup.customer.util.ExcelUtil
;
...
@@ -24,6 +27,7 @@ import com.itextpdf.text.pdf.PdfPTable;
...
@@ -24,6 +27,7 @@ import com.itextpdf.text.pdf.PdfPTable;
import
com.itextpdf.text.pdf.PdfWriter
;
import
com.itextpdf.text.pdf.PdfWriter
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.exception.ExceptionUtils
;
import
org.apache.commons.lang3.exception.ExceptionUtils
;
import
org.apache.poi.hssf.usermodel.HSSFCell
;
import
org.apache.poi.hssf.usermodel.HSSFCell
;
...
@@ -39,9 +43,13 @@ import org.springframework.data.domain.Page;
...
@@ -39,9 +43,13 @@ import org.springframework.data.domain.Page;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
sun.misc.IOUtils
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Predicate
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
import
java.io.*
;
import
java.net.URLEncoder
;
import
java.util.*
;
import
java.util.*
;
import
java.util.List
;
import
java.util.List
;
...
@@ -59,9 +67,15 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
...
@@ -59,9 +67,15 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
@Autowired
@Autowired
private
UserSdkImpl
userSdk
;
private
UserSdkImpl
userSdk
;
@Autowired
private
IFileService
fileService
;
@Value
(
"${kdsp-operation}"
)
@Value
(
"${kdsp-operation}"
)
private
String
kdspOperationUrl
;
private
String
kdspOperationUrl
;
//@Value("${customer.contract.http}")
private
String
contractUrl
;
@Value
(
"${passportapi2.tjzimu.http}"
)
@Value
(
"${passportapi2.tjzimu.http}"
)
private
String
userSysUrl
;
private
String
userSysUrl
;
...
@@ -239,7 +253,7 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
...
@@ -239,7 +253,7 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
}
}
//导出zip压缩包文件
//导出zip压缩包文件
public
JsonResult
exportZipFile
(
HttpServletRequest
request
)
throws
Exception
{
public
JsonResult
exportZipFile
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
{
//调用电商接口获取对应数据
//调用电商接口获取对应数据
log
.
info
(
"[TransactionReceiptRecordServiceImpl.exportZipFile begin]"
);
log
.
info
(
"[TransactionReceiptRecordServiceImpl.exportZipFile begin]"
);
//查询需要导出的数据-导入成功的数据
//查询需要导出的数据-导入成功的数据
...
@@ -247,15 +261,13 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
...
@@ -247,15 +261,13 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
if
(
CollectionUtils
.
isEmpty
(
transactionReceiptRecordList
)){
if
(
CollectionUtils
.
isEmpty
(
transactionReceiptRecordList
)){
return
JsonResult
.
buildErrorStateResult
(
"没有可以导出得数据"
);
return
JsonResult
.
buildErrorStateResult
(
"没有可以导出得数据"
);
}
}
String
realPath
=
request
.
getSession
().
getServletContext
().
getRealPath
(
"/"
);
List
<
Map
<
String
,
Object
>>
filePathList
=
new
ArrayList
<>();
//String basicPath ="/transaction";
log
.
info
(
"[TransactionReceiptRecordServiceImpl.kdspOperationUrl 调用kdsp-op 接口begin]"
);
//String basicPath="D:\\交易凭证0225";
for
(
TransactionReceiptRecord
record
:
transactionReceiptRecordList
){
for
(
TransactionReceiptRecord
record
:
transactionReceiptRecordList
){
Integer
userId
=
record
.
getUserId
();
Integer
userId
=
record
.
getUserId
();
String
orderNo
=
record
.
getOrderNo
();
String
orderNo
=
record
.
getOrderNo
();
//调用kdsp接口获取交易凭证订单信息
//调用kdsp接口获取交易凭证订单信息
String
url
=
kdspOperationUrl
+
"/api/kdsp/op/fa-cui/transaction-proof/query"
;
String
url
=
kdspOperationUrl
+
"/api/kdsp/op/fa-cui/transaction-proof/query"
;
//String url = "http://kdsp-operation-qa2.liangkebang.net/api/kdsp/op/fa-cui/transaction-proof/query";
try
{
try
{
Map
<
String
,
String
>
header
=
Maps
.
newHashMap
();
Map
<
String
,
String
>
header
=
Maps
.
newHashMap
();
header
.
put
(
"Content-type"
,
"application/json"
);
header
.
put
(
"Content-type"
,
"application/json"
);
...
@@ -299,32 +311,102 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
...
@@ -299,32 +311,102 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
continue
;
continue
;
}
}
//生成pdf
//生成pdf
String
filePath
=
basePath
+
"/"
+
record
.
getBatchNo
()+
record
.
getUserName
();
basePath
=
"D:/交易凭证"
;
FileToZip
.
mkdir
(
filePath
);
//String basicPath="D:\\交易凭证0225";
filePath
=
filePath
+
"/"
+
record
.
getOrderNo
()+
".pdf"
;
String
directory
=
"/"
+
record
.
getBatchNo
()+
record
.
getUserName
()+
"/"
;
generatePDF
(
transactionReceiptVOList
.
get
(
0
),
filePath
);
FileToZip
.
mkdir
(
basePath
+
directory
);
String
pdfFileName
=
record
.
getOrderNo
()+
".pdf"
;
generatePDF
(
transactionReceiptVOList
.
get
(
0
),
basePath
+
directory
+
pdfFileName
);
//保存到文件服务器上
//保存到文件服务器上
SFTPUtil
sftpUtil
=
new
SFTPUtil
(
username
,
password
,
host
,
port
);
/*
SFTPUtil sftpUtil = new SFTPUtil(username,password,host,port);
sftpUtil.login();
sftpUtil.login();
log.info("uploadFile | 成功连接ftp");
log.info("uploadFile | 成功连接ftp");
//sftpUtil.upload(basePath,directory,okFileName,new ByteArrayInputStream(okFileData));
File file = new File(pdfFileName);
sftpUtil
.
logout
();
InputStream is = new FileInputStream(file);
//调用电子签章接口,电子签章回调更新签章状态
sftpUtil.upload(basePath,directory,pdfFileName,is);
//todo
sftpUtil.logout();*/
//导出成功
//将文件路径和useId放入list,进行签章
record
.
setExportStatus
(
1
);
Map
<
String
,
Object
>
map
=
Maps
.
newHashMap
();
transactionReceiptRecordRepo
.
save
(
record
);
map
.
put
(
"userId"
,
record
.
getUserId
());
map
.
put
(
"fileAddress"
,
basePath
+
directory
+
pdfFileName
);
filePathList
.
add
(
map
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"[TransactionReceiptRecordServiceImpl][exportZipFile] 网络通讯异常,userId:{},ex:{}"
,
ExceptionUtils
.
getStackTrace
(
e
));
log
.
error
(
"[TransactionReceiptRecordServiceImpl][exportZipFile] 网络通讯异常,userId:{},ex:{}"
,
ExceptionUtils
.
getStackTrace
(
e
));
return
JsonResult
.
buildErrorStateResult
(
e
.
getMessage
());
return
JsonResult
.
buildErrorStateResult
(
e
.
getMessage
());
}
}
}
}
log
.
info
(
"[TransactionReceiptRecordServiceImpl.kdspOperationUrl 调用kdsp-op 接口end]"
);
//调用签章接口
//调用签章接口
FileOutputStream
fos1
=
new
FileOutputStream
(
new
File
(
"D:/交易凭证.zip"
));
/*String url = contractUrl + "/contract/batch/sign";
Map<String, String> header = Maps.newHashMap();
header.put("Content-type", "application/json");
Map param = Maps.newHashMap();
if (CollectionUtils.isNotEmpty(filePathList)) {
param.put("fileList", filePathList);
}
String contractResult = httpService.post(url, header, param);
JSONObject json = JSONObject.parseObject(contractResult);
String jsonResult = json.getString("data");
String businessCode = json.getString("businessCode");*/
//下载签章文件
/* SFTPUtil sftpUtil = new SFTPUtil(username,password,host,port);
sftpUtil.login();
log.info("downloadFile | 成功连接ftp");
sftpUtil.download("","");*/
//转换成zip包
File
file
=
ZipUtil
.
zip
(
basePath
,
basePath
+
"/交易凭证.zip"
);
//zip 包保存路径
//sftpUtil.logout();
FileInputStream
is
=
new
FileInputStream
(
file
);
byte
[]
fileData
=
IOUtils
.
readNBytes
(
is
,
is
.
available
());
//FileOutputStream fos1 = new FileOutputStream(new File("D:/交易凭证.zip"));
//FileToZip.toZip(basicPath, fos1,true);
//FileToZip.toZip(basicPath, fos1,true);
return
JsonResult
.
buildSuccessResult
(
null
,
null
);
//返回给前端
return
this
.
outputFile
(
response
,
"交易凭证.zip"
,
fileData
,
100
,
20
);
}
public
JsonResult
outputFile
(
HttpServletResponse
response
,
String
fileName
,
byte
[]
file
,
Integer
successCount
,
Integer
failCount
){
if
(
ArrayUtils
.
isEmpty
(
file
))
{
log
.
info
(
"get file download url failed."
);
return
JsonResult
.
buildErrorStateResult
(
"file is null"
);
}
// 设置相关头信息
response
.
setContentType
(
"multipart/form-data"
);
try
{
fileName
=
URLEncoder
.
encode
(
fileName
,
"UTF8"
);
}
catch
(
UnsupportedEncodingException
e
)
{
log
.
error
(
"fileName encode failed. errorMessage[{}]"
,
e
.
getMessage
());
return
JsonResult
.
buildErrorStateResult
(
"fileName encode failed"
);
}
response
.
setHeader
(
"Content-disposition"
,
"attachment;filename="
+
fileName
);
response
.
addHeader
(
"Pragma"
,
"no-cache"
);
response
.
addHeader
(
"Cache-Control"
,
"no-cache"
);
response
.
addDateHeader
(
"Expries"
,
0
);
// 返回文件
OutputStream
out
=
null
;
try
{
out
=
response
.
getOutputStream
();
out
.
write
(
file
);
out
.
flush
();
}
catch
(
IOException
e
)
{
log
.
error
(
"download file failed. errorMessage[{}]"
,
e
.
getMessage
());
return
JsonResult
.
buildErrorStateResult
(
"download file failed"
);
}
finally
{
if
(
null
!=
out
)
{
try
{
out
.
close
();
}
catch
(
IOException
e
)
{
log
.
error
(
"OutputStream close failed. errorMessage[{}]"
,
e
.
getMessage
());
}
}
}
Map
map
=
Maps
.
newHashMap
();
map
.
put
(
"successCount"
,
successCount
);
map
.
put
(
"failCount"
,
failCount
);
return
JsonResult
.
buildSuccessResult
(
"ok"
,
map
);
}
}
/**
/**
...
@@ -567,8 +649,6 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
...
@@ -567,8 +649,6 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
ReceiverVO
receiverVO
=
transactionReceiptVO
.
getReceiver
();
ReceiverVO
receiverVO
=
transactionReceiptVO
.
getReceiver
();
//物流信息
//物流信息
List
<
LogisticsVO
>
logisticsVOList
=
transactionReceiptVO
.
getLogisticsList
();
List
<
LogisticsVO
>
logisticsVOList
=
transactionReceiptVO
.
getLogisticsList
();
//物流详情
//List<logisticsDetailVO> logisticsDetails = logisticsVO.getDetailList();
Document
document
=
new
Document
(
PageSize
.
A4
);
Document
document
=
new
Document
(
PageSize
.
A4
);
try
{
try
{
PdfWriter
.
getInstance
(
document
,
new
FileOutputStream
(
filePath
));
PdfWriter
.
getInstance
(
document
,
new
FileOutputStream
(
filePath
));
...
@@ -611,7 +691,7 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
...
@@ -611,7 +691,7 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
table
.
addCell
(
new
PdfPCell
(
new
Phrase
(
ITextPDFUtil
.
getUTF8String
(
"支付方式"
),
font
))).
setMinimumHeight
(
18
);
table
.
addCell
(
new
PdfPCell
(
new
Phrase
(
ITextPDFUtil
.
getUTF8String
(
"支付方式"
),
font
))).
setMinimumHeight
(
18
);
//查询手机号
//查询手机号
UserSysResult
<
XUser
>
user
=
userSdk
.
getService
().
findUserByUserId
(
orderVO
.
getUserId
());
UserSysResult
<
XUser
>
user
=
userSdk
.
getService
().
findUserByUserId
(
orderVO
.
getUserId
());
//第5行数据
iTextITextPDFUtil.
//第5行数据
if
(
user
!=
null
&&
user
.
getData
()
!=
null
){
if
(
user
!=
null
&&
user
.
getData
()
!=
null
){
table
.
addCell
(
new
Phrase
(
ITextPDFUtil
.
getUTF8String
(
user
.
getData
().
getPhoneNo
()),
font
));
table
.
addCell
(
new
Phrase
(
ITextPDFUtil
.
getUTF8String
(
user
.
getData
().
getPhoneNo
()),
font
));
}
else
{
}
else
{
...
...
src/main/java/cn/quantgroup/customer/util/SFTPUtil.java
View file @
ce44d038
...
@@ -7,11 +7,8 @@ import com.jcraft.jsch.JSchException;
...
@@ -7,11 +7,8 @@ import com.jcraft.jsch.JSchException;
import
com.jcraft.jsch.Session
;
import
com.jcraft.jsch.Session
;
import
com.jcraft.jsch.SftpATTRS
;
import
com.jcraft.jsch.SftpATTRS
;
import
com.jcraft.jsch.SftpException
;
import
com.jcraft.jsch.SftpException
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.*
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.Properties
;
import
java.util.Properties
;
import
java.util.Vector
;
import
java.util.Vector
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -109,8 +106,7 @@ public class SFTPUtil {
...
@@ -109,8 +106,7 @@ public class SFTPUtil {
}
}
}
}
this
.
sftp
.
put
(
input
,
sftpFileName
+
".tmp"
);
this
.
sftp
.
put
(
input
,
sftpFileName
);
this
.
sftp
.
rename
(
sftpFileName
+
".tmp"
,
sftpFileName
);
}
}
public
void
download
(
String
directory
,
String
downloadFile
,
String
saveDirectory
,
String
saveFile
)
throws
SftpException
,
FileNotFoundException
{
public
void
download
(
String
directory
,
String
downloadFile
,
String
saveDirectory
,
String
saveFile
)
throws
SftpException
,
FileNotFoundException
{
...
...
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