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
1ea75692
Commit
1ea75692
authored
Mar 11, 2022
by
吴琼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改
parent
e24b5c07
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
35 deletions
+30
-35
ITransactionReceiptRecordService.java
...up/customer/service/ITransactionReceiptRecordService.java
+1
-1
TransactionReceiptRecordServiceImpl.java
...mer/service/impl/TransactionReceiptRecordServiceImpl.java
+28
-34
MailUtil.java
src/main/java/cn/quantgroup/customer/util/MailUtil.java
+1
-0
No files found.
src/main/java/cn/quantgroup/customer/service/ITransactionReceiptRecordService.java
View file @
1ea75692
...
...
@@ -16,7 +16,7 @@ public interface ITransactionReceiptRecordService {
JsonResult
importTransactionReceiptRecord
(
MultipartFile
file
)
throws
IOException
;
void
exportZipFile
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
;
void
exportZipFile
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Runtime
Exception
;
JsonResult
checkCanExport
();
...
...
src/main/java/cn/quantgroup/customer/service/impl/TransactionReceiptRecordServiceImpl.java
View file @
1ea75692
...
...
@@ -3,7 +3,6 @@ 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.exception.BusinessException
;
import
cn.quantgroup.customer.rest.param.mail.SendMailParam
;
import
cn.quantgroup.customer.rest.vo.transaction.TransactionReceiptRecordVO
;
import
cn.quantgroup.customer.repo.TransactionReceiptRecordRepo
;
...
...
@@ -41,6 +40,7 @@ import org.springframework.data.domain.PageRequest;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.interceptor.TransactionAspectSupport
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.persistence.criteria.Predicate
;
...
...
@@ -424,9 +424,12 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
restContract
(
filePathList
,
emailList
);
}
}
catch
(
Exception
e
)
{
sftpUtil
.
logout
();
log
.
info
(
"uploadFile | 断开ftp"
);
deleteRedis
(
"exportZipFile"
);
log
.
error
(
"[TransactionReceiptRecordServiceImpl][exportZipFile] 网络通讯异常,userId:{},ex:{}"
,
ExceptionUtils
.
getStackTrace
(
e
));
throw
new
RuntimeException
(
"调用kdsp接口获取交易凭证订单信息报错"
);
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
throw
new
RuntimeException
(
"导出文件出错了"
);
}
}
sftpUtil
.
logout
();
...
...
@@ -435,6 +438,12 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
//将文件分批放入本地
log
.
info
(
"下载签章完成的文件 begin"
);
if
(
CollectionUtils
.
isEmpty
(
emailList
)){
log
.
info
(
"没有签章成功的文件可以发送"
);
deleteRedis
(
"exportZipFile"
);
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
throw
new
RuntimeException
(
"没有签章成功的文件可以发送"
);
}
int
subListSize
=
0
;
if
(
CollectionUtils
.
isNotEmpty
(
emailList
)){
List
<
List
<
Map
<
String
,
Object
>>>
subList
=
splitList
(
emailList
,
mailSize
);
...
...
@@ -465,39 +474,25 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
InputStreamResource
InputStreamResource
=
new
InputStreamResource
(
is
);
sendCustomerTransactionMail
(
InputStreamResource
);
}
log
.
info
(
"分批发送邮件成功"
);
deleteRedis
(
"exportZipFile"
);
//return JsonResult.buildSuccessResult("ok",null);
}
catch
(
Exception
e
)
{
deleteRedis
(
"exportZipFile"
);
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
log
.
info
(
"邮件发送失败"
);
throw
new
RuntimeException
(
"邮件发送失败"
);
}
//File file = ZipUtil.zip(downloadLocalPath, downloadLocalPath+".zip");//zip 包保存路径
//FileInputStream is = null;
//try {
//is = new FileInputStream(file);
//byte[] fileData = new byte[is.available()];
//is.read(fileData);
//Map<String,Object> map = new HashMap<>();
//map.put("base64",Base64.getEncoder().encodeToString(fileData));
//int successCount = (int) jsonObject.get("successCount");
// int failCount = (int) jsonObject.get("failCount");
//map.put("successCount",successCount);
//map.put("failCount",failCount);
//删除生成的文件
//File deleteFile =new File("/home/quant_group/customer-service/tmp0/");
}
finally
{
//log.info("删除暂存的文件 begin");
//int upload = uploadLocalPath.lastIndexOf("/");
//File deleteFile =new File(uploadLocalPath.substring(0,upload-4));
//deleteDirectory(deleteFile);
//
File deleteFile1 =new File(downloadLocalPath
);
// deleteDirectory(deleteFile1
);
//delete
Redis("exportZipFile"
);
//
return JsonResult.buildSuccessResult("ok",null
);
//return JsonResult.buildSuccessResult("ok",map
);
//} catch (Exception e) {
// deleteRedis("exportZipFile");
// throw new RuntimeException("文件转换失败
");
// }
//
int download = downloadLocalPath.lastIndexOf("/"
);
//File deleteFile1 =new File(downloadLocalPath.substring(0,download+1)
);
//delete
Directory(deleteFile1
);
//
log.info("删除暂存的文件 end"
);
deleteRedis
(
"exportZipFile"
);
log
.
info
(
"分批发送邮件end"
);
}
deleteRedis
(
"exportZipFile
"
);
log
.
info
(
"分批发送邮件成功end"
);
}
/**
...
...
@@ -1017,7 +1012,7 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
return
table
;
}
public
void
sendCustomerTransactionMail
(
InputStreamResource
inputStreamResource
)
throws
Exception
{
public
void
sendCustomerTransactionMail
(
InputStreamResource
inputStreamResource
)
throws
Runtime
Exception
{
try
{
//FileInputStream is = new FileInputStream("D:\\tmp1\\交易凭证.zip");
//InputStreamResource inputStreamResource1 =new InputStreamResource(is);
...
...
@@ -1031,8 +1026,7 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
MailUtil
.
sendHtmlAndAttachmentMail
(
sendMailParam
);
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
throw
new
Exception
(
"发送邮件失败"
);
throw
new
RuntimeException
(
ex
);
}
}
...
...
src/main/java/cn/quantgroup/customer/util/MailUtil.java
View file @
1ea75692
...
...
@@ -106,6 +106,7 @@ public class MailUtil implements Serializable {
mailSender
.
send
(
mimeMessage
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"[MailUtilSendMail] 邮件发送失败。"
,
e
);
throw
new
RuntimeException
(
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