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
343364b4
Commit
343364b4
authored
Mar 05, 2022
by
吴琼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xiugai
parent
df2178f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
6 deletions
+55
-6
TransactionReceiptRecordServiceImpl.java
...mer/service/impl/TransactionReceiptRecordServiceImpl.java
+33
-4
FileToZip.java
src/main/java/cn/quantgroup/customer/util/FileToZip.java
+22
-2
No files found.
src/main/java/cn/quantgroup/customer/service/impl/TransactionReceiptRecordServiceImpl.java
View file @
343364b4
...
...
@@ -288,7 +288,7 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
log
.
info
(
"[TransactionReceiptRecordServiceImpl.exportZipFile begin]"
);
//查询需要导出的数据-导入成功的数据,但未导出成功的数据
List
<
TransactionReceiptRecord
>
transactionReceiptRecordList
=
transactionReceiptRecordRepo
.
selectRecordsByImportStatusAndExportStatus
(
1
,
limit
);
log
.
info
(
"[TransactionReceiptRecordServiceImpl.exportZipFile transactionReceiptRecordList]
"
,
transactionReceiptRecordList
);
log
.
info
(
"[TransactionReceiptRecordServiceImpl.exportZipFile transactionReceiptRecordList]
可导出数据为:"
,
transactionReceiptRecordList
.
size
()
);
if
(
CollectionUtils
.
isEmpty
(
transactionReceiptRecordList
)){
return
JsonResult
.
buildErrorStateResult
(
"没有可以导出得数据"
);
}
...
...
@@ -323,6 +323,7 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
paramList
.
add
(
param
);
//得到json字符串
String
result
=
httpService
.
post
(
url
,
header
,
paramList
);
log
.
info
(
"调用kdsp查询订单接口返回结果,result:"
,
result
);
//转换成json 对象
if
(
StringUtils
.
isBlank
(
result
)){
throw
new
RuntimeException
(
"未查询到订单数据"
);
...
...
@@ -358,7 +359,9 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
String
directory
=
record
.
getSerialNo
()+
record
.
getUserName
();
String
pdfFileName
=
record
.
getOrderNo
()+
".pdf"
;
FileToZip
.
mkdir
(
uploadLocalPath
+
directory
);
log
.
info
(
"导出文件生成pdf begin"
,
pdfFileName
);
generatePDF
(
transactionReceiptVOList
.
get
(
0
),
uploadLocalPath
+
"/"
+
directory
+
"/"
+
pdfFileName
);
log
.
info
(
"导出文件生成pdf end"
,
pdfFileName
);
File
file1
=
new
File
(
uploadLocalPath
+
"/"
+
directory
+
"/"
+
pdfFileName
);
InputStream
inputStream
=
new
FileInputStream
(
file1
);
sftpUtil
.
upload
(
basePath
+
maxExportBatchNo
+
"/交易凭证/"
,
directory
,
pdfFileName
,
inputStream
);
...
...
@@ -378,14 +381,16 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
log
.
info
(
"[TransactionReceiptRecordServiceImpl.kdspOperationUrl 调用kdsp-op 接口end]"
,
System
.
currentTimeMillis
());
//调用签章接口
if
(
filePathList
.
isEmpty
()){
throw
new
RuntimeException
(
"没有可以
签章
的数据"
);
throw
new
RuntimeException
(
"没有可以
导出
的数据"
);
}
log
.
info
(
"contractUrl /contract/batch/sign 调用签章接口"
);
String
url
=
contractUrl
+
"/contract/batch/sign"
;
Map
<
String
,
String
>
header
=
Maps
.
newHashMap
();
header
.
put
(
"Content-type"
,
"application/json"
);
log
.
info
(
"contractUrl /contract/batch/sign 调用签章接口 begin"
,
filePathList
);
String
contractResult
=
httpService
.
post
(
url
,
header
,
filePathList
);
JSONObject
json
=
JSONObject
.
parseObject
(
contractResult
);
log
.
info
(
"contractUrl /contract/batch/sign 调用签章接口 end"
,
json
);
String
jsonResult
=
json
.
getString
(
"data"
);
String
businessCode
=
json
.
getString
(
"businessCode"
);
if
(!
"0000"
.
equals
(
businessCode
)){
...
...
@@ -423,15 +428,16 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
if
(
failList
!=
null
&&
failList
.
size
()>
0
){
for
(
int
i
=
0
;
i
<
jsonArray
.
size
()
;
i
++){
String
path
=
(
String
)
jsonArray
.
get
(
i
);
//String path = "/6/jiaoyipingzheng/zhangsan/1496386728293023744.pdf";
int
begin
=
path
.
lastIndexOf
(
"/"
)+
1
;
int
end
=
path
.
indexOf
(
"."
);
path
=
path
.
substring
(
begin
,
end
);
updateFailList
.
add
(
path
);
}
}
//更新导出状态
log
.
info
(
"交易凭证导出接口更新导出状态 begin"
,
updateSuccessList
,
updateFailList
);
updatePDFSignStatus
(
updateSuccessList
,
updateFailList
);
log
.
info
(
"交易凭证导出接口更新导出状态 end"
);
File
file
=
ZipUtil
.
zip
(
downloadLocalPath
,
downloadLocalPath
+
".zip"
);
//zip 包保存路径
FileInputStream
is
=
null
;
try
{
...
...
@@ -443,12 +449,35 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
int
failCount
=
(
int
)
jsonObject
.
get
(
"failCount"
);
map
.
put
(
"successCount"
,
successCount
);
map
.
put
(
"failCount"
,
failCount
);
//删除生成的文件
File
deleteFile
=
new
File
(
"D:/tmp0/"
);
deleteDirectory
(
deleteFile
);
File
deleteFile1
=
new
File
(
downloadLocalPath
);
deleteDirectory
(
deleteFile1
);
return
JsonResult
.
buildSuccessResult
(
"ok"
,
map
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"文件转换失败"
);
}
}
/**
* 删除文件
* @param file
*/
private
void
deleteDirectory
(
File
file
){
if
(
file
.
isFile
()){
//表示该文件不是文件夹
file
.
delete
();
}
else
{
//首先得到当前路径
String
[]
childPaths
=
file
.
list
();
for
(
String
childPath
:
childPaths
){
File
childFile
=
new
File
(
file
.
getAbsolutePath
()+
"/"
+
childPath
);
deleteDirectory
(
childFile
);
}
file
.
delete
();
}
}
/**
* 根据byte数组,生成文件
*/
...
...
src/main/java/cn/quantgroup/customer/util/FileToZip.java
View file @
343364b4
...
...
@@ -167,11 +167,31 @@ public final class FileToZip {
FileToZip
.
compress
(
file
,
zos
,
zipName
,
KeepDirStructure
);
zos
.
close
();
//切记关闭资源否则zip包出错
}
/**
* 删除文件
* @param file
*/
private
static
void
deleteDirectory
(
File
file
){
if
(
file
.
isFile
()){
//表示该文件不是文件夹
file
.
delete
();
}
else
{
//首先得到当前路径
String
[]
childPaths
=
file
.
list
();
for
(
String
childPath
:
childPaths
){
File
childFile
=
new
File
(
file
.
getAbsolutePath
()+
"/"
+
childPath
);
deleteDirectory
(
childFile
);
}
file
.
delete
();
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
/** 测试压缩方法1 */
File
deleteFile
=
new
File
(
"D:/tmp1/交易凭证\n"
);
deleteDirectory
(
deleteFile
);
/* *//** 测试压缩方法1 *//*
FileOutputStream fos1 = new FileOutputStream(new File("D:/交易凭证.zip"));
FileToZip.toZip("D:/交易凭证0219", fos1,true);
*/
/** 测试压缩方法2 */
/* List<File> fileList = new ArrayList<File>();
...
...
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