Commit 343364b4 authored by 吴琼's avatar 吴琼

xiugai

parent df2178f9
...@@ -288,7 +288,7 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR ...@@ -288,7 +288,7 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
log.info("[TransactionReceiptRecordServiceImpl.exportZipFile begin]"); log.info("[TransactionReceiptRecordServiceImpl.exportZipFile begin]");
//查询需要导出的数据-导入成功的数据,但未导出成功的数据 //查询需要导出的数据-导入成功的数据,但未导出成功的数据
List<TransactionReceiptRecord> transactionReceiptRecordList= transactionReceiptRecordRepo.selectRecordsByImportStatusAndExportStatus(1,limit); List<TransactionReceiptRecord> transactionReceiptRecordList= transactionReceiptRecordRepo.selectRecordsByImportStatusAndExportStatus(1,limit);
log.info("[TransactionReceiptRecordServiceImpl.exportZipFile transactionReceiptRecordList]",transactionReceiptRecordList); log.info("[TransactionReceiptRecordServiceImpl.exportZipFile transactionReceiptRecordList] 可导出数据为:",transactionReceiptRecordList.size());
if(CollectionUtils.isEmpty(transactionReceiptRecordList)){ if(CollectionUtils.isEmpty(transactionReceiptRecordList)){
return JsonResult.buildErrorStateResult("没有可以导出得数据"); return JsonResult.buildErrorStateResult("没有可以导出得数据");
} }
...@@ -323,6 +323,7 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR ...@@ -323,6 +323,7 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
paramList.add(param); paramList.add(param);
//得到json字符串 //得到json字符串
String result = httpService.post(url, header, paramList); String result = httpService.post(url, header, paramList);
log.info("调用kdsp查询订单接口返回结果,result:",result);
//转换成json 对象 //转换成json 对象
if(StringUtils.isBlank(result)){ if(StringUtils.isBlank(result)){
throw new RuntimeException("未查询到订单数据"); throw new RuntimeException("未查询到订单数据");
...@@ -358,7 +359,9 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR ...@@ -358,7 +359,9 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
String directory =record.getSerialNo()+record.getUserName(); String directory =record.getSerialNo()+record.getUserName();
String pdfFileName = record.getOrderNo()+".pdf"; String pdfFileName = record.getOrderNo()+".pdf";
FileToZip.mkdir(uploadLocalPath+directory); FileToZip.mkdir(uploadLocalPath+directory);
log.info("导出文件生成pdf begin",pdfFileName);
generatePDF(transactionReceiptVOList.get(0),uploadLocalPath+"/"+directory+"/"+pdfFileName); generatePDF(transactionReceiptVOList.get(0),uploadLocalPath+"/"+directory+"/"+pdfFileName);
log.info("导出文件生成pdf end",pdfFileName);
File file1 = new File(uploadLocalPath+"/"+directory+"/"+pdfFileName); File file1 = new File(uploadLocalPath+"/"+directory+"/"+pdfFileName);
InputStream inputStream = new FileInputStream(file1); InputStream inputStream = new FileInputStream(file1);
sftpUtil.upload(basePath+maxExportBatchNo+"/交易凭证/",directory,pdfFileName,inputStream); sftpUtil.upload(basePath+maxExportBatchNo+"/交易凭证/",directory,pdfFileName,inputStream);
...@@ -378,14 +381,16 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR ...@@ -378,14 +381,16 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
log.info("[TransactionReceiptRecordServiceImpl.kdspOperationUrl 调用kdsp-op 接口end]",System.currentTimeMillis()); log.info("[TransactionReceiptRecordServiceImpl.kdspOperationUrl 调用kdsp-op 接口end]",System.currentTimeMillis());
//调用签章接口 //调用签章接口
if(filePathList.isEmpty()){ if(filePathList.isEmpty()){
throw new RuntimeException("没有可以签章的数据"); throw new RuntimeException("没有可以导出的数据");
} }
log.info("contractUrl /contract/batch/sign 调用签章接口"); log.info("contractUrl /contract/batch/sign 调用签章接口");
String url = contractUrl + "/contract/batch/sign"; String url = contractUrl + "/contract/batch/sign";
Map<String, String> header = Maps.newHashMap(); Map<String, String> header = Maps.newHashMap();
header.put("Content-type", "application/json"); header.put("Content-type", "application/json");
log.info("contractUrl /contract/batch/sign 调用签章接口 begin",filePathList);
String contractResult = httpService.post(url, header, filePathList); String contractResult = httpService.post(url, header, filePathList);
JSONObject json = JSONObject.parseObject(contractResult); JSONObject json = JSONObject.parseObject(contractResult);
log.info("contractUrl /contract/batch/sign 调用签章接口 end",json);
String jsonResult = json.getString("data"); String jsonResult = json.getString("data");
String businessCode = json.getString("businessCode"); String businessCode = json.getString("businessCode");
if(!"0000".equals(businessCode)){ if(!"0000".equals(businessCode)){
...@@ -423,15 +428,16 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR ...@@ -423,15 +428,16 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
if(failList !=null && failList.size()>0){ if(failList !=null && failList.size()>0){
for(int i= 0;i <jsonArray.size() ;i++){ for(int i= 0;i <jsonArray.size() ;i++){
String path = (String) jsonArray.get(i); String path = (String) jsonArray.get(i);
//String path = "/6/jiaoyipingzheng/zhangsan/1496386728293023744.pdf";
int begin = path.lastIndexOf("/")+1; int begin = path.lastIndexOf("/")+1;
int end = path.indexOf("."); int end = path.indexOf(".");
path =path.substring(begin,end); path =path.substring(begin,end);
updateFailList.add(path); updateFailList.add(path);
} }
} }
//更新导出状态
log.info("交易凭证导出接口更新导出状态 begin",updateSuccessList,updateFailList);
updatePDFSignStatus(updateSuccessList,updateFailList); updatePDFSignStatus(updateSuccessList,updateFailList);
log.info("交易凭证导出接口更新导出状态 end");
File file = ZipUtil.zip(downloadLocalPath, downloadLocalPath+".zip");//zip 包保存路径 File file = ZipUtil.zip(downloadLocalPath, downloadLocalPath+".zip");//zip 包保存路径
FileInputStream is = null; FileInputStream is = null;
try { try {
...@@ -443,12 +449,35 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR ...@@ -443,12 +449,35 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
int failCount = (int) jsonObject.get("failCount"); int failCount = (int) jsonObject.get("failCount");
map.put("successCount",successCount); map.put("successCount",successCount);
map.put("failCount",failCount); map.put("failCount",failCount);
//删除生成的文件
File deleteFile =new File("D:/tmp0/");
deleteDirectory(deleteFile);
File deleteFile1 =new File(downloadLocalPath);
deleteDirectory(deleteFile1);
return JsonResult.buildSuccessResult("ok",map); return JsonResult.buildSuccessResult("ok",map);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("文件转换失败"); 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数组,生成文件 * 根据byte数组,生成文件
*/ */
......
...@@ -167,11 +167,31 @@ public final class FileToZip { ...@@ -167,11 +167,31 @@ public final class FileToZip {
FileToZip.compress(file, zos, zipName, KeepDirStructure); FileToZip.compress(file, zos, zipName, KeepDirStructure);
zos.close();//切记关闭资源否则zip包出错 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 { 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")); FileOutputStream fos1 = new FileOutputStream(new File("D:/交易凭证.zip"));
FileToZip.toZip("D:/交易凭证0219", fos1,true); FileToZip.toZip("D:/交易凭证0219", fos1,true);
*/
/** 测试压缩方法2 */ /** 测试压缩方法2 */
/* List<File> fileList = new ArrayList<File>(); /* List<File> fileList = new ArrayList<File>();
......
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