Commit 1ea75692 authored by 吴琼's avatar 吴琼

修改

parent e24b5c07
......@@ -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 RuntimeException;
JsonResult checkCanExport();
......
......@@ -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);
//deleteRedis("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));
//deleteDirectory(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 RuntimeException {
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);
}
}
......
......@@ -106,6 +106,7 @@ public class MailUtil implements Serializable {
mailSender.send(mimeMessage);
} catch (Exception e) {
logger.error("[MailUtilSendMail] 邮件发送失败。", e);
throw new RuntimeException(e);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment