Commit 649e6cd3 authored by 吴琼's avatar 吴琼

交易凭证添加批次号

parent c4934057
......@@ -39,10 +39,10 @@ public class TransactionReceiptRecord {
private Integer batchNo;
@Column(name = "sign_status")
private Long signStatus;
private Integer signStatus;
@Column(name = "pdf_status")
private Long pdfStatus;
@Column(name = "export_batch_no")
private Integer exportBatchNo;
public TransactionReceiptRecord() {
......
......@@ -11,7 +11,10 @@ import java.util.List;
public interface TransactionReceiptRecordRepo extends JpaRepository<TransactionReceiptRecord, Long>, JpaSpecificationExecutor<TransactionReceiptRecord> {
@Query(value = "select max(batch_no) from transaction_receipt_record where export_status =?1 ", nativeQuery = true)
Integer findMaxbatchNo(Integer status);
Integer findMaxBatchNo(Integer status);
@Query(value = "select max(export_batch_no) from transaction_receipt_record where import_status = ?1 ", nativeQuery = true)
Integer findExportMaxBatchNo(Integer status);
@Query(value = "select count(1) from transaction_receipt_record where user_id =?1 and user_name =?2 and order_no =?3 ", nativeQuery = true)
Integer selectCountByUserIdAndOrderNo(Integer userId,String userName,String orderNo);
......
......@@ -144,7 +144,7 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
public JsonResult importTransactionReceiptRecord(MultipartFile file) throws RuntimeException {
log.info("[TransactionReceiptRecordServiceImpl importTransactionReceiptRecord] end,query={} ", file);
//查询未导出数据最大批次号
Integer maxBatchNo = transactionReceiptRecordRepo.findMaxbatchNo(0);
Integer maxBatchNo = transactionReceiptRecordRepo.findMaxBatchNo(0);
if(maxBatchNo == null || maxBatchNo ==0 ){
maxBatchNo = 1;
}
......@@ -269,7 +269,8 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
}
//导出zip压缩包文件
public JsonResult exportZipFile(HttpServletRequest request, HttpServletResponse response) throws Exception {
@Transactional
public JsonResult exportZipFile(HttpServletRequest request, HttpServletResponse response) throws RuntimeException {
//调用电商接口获取对应数据
log.info("[TransactionReceiptRecordServiceImpl.exportZipFile begin]");
//查询需要导出的数据-导入成功的数据,但未导出成功的数据
......@@ -277,6 +278,11 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
if(CollectionUtils.isEmpty(transactionReceiptRecordList)){
return JsonResult.buildErrorStateResult("没有可以导出得数据");
}
//查询导入成功数据的导出的最大批次号
Integer maxExportBatchNo = transactionReceiptRecordRepo.findExportMaxBatchNo(1);
if(maxExportBatchNo == null || maxExportBatchNo ==0 ){
maxExportBatchNo = 1;
}
List <Map<String,Object>> filePathList =new ArrayList<>();
log.info("[TransactionReceiptRecordServiceImpl.kdspOperationUrl 调用kdsp-op 接口begin]", System.currentTimeMillis());
SFTPUtil sftpUtil = new SFTPUtil(username,password,host,port);
......@@ -329,6 +335,7 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
transactionReceiptRecordRepo.save(record);
continue;
}
record.setExportBatchNo(maxExportBatchNo.intValue()+1);
//生成pdf
String directory =record.getBatchNo()+record.getUserName();
String pdfFileName = record.getOrderNo()+".pdf";
......@@ -336,11 +343,11 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
generatePDF(transactionReceiptVOList.get(0),uploadLocalPath+"/"+directory+"/"+pdfFileName);
File file1 = new File(uploadLocalPath+"/"+directory+"/"+pdfFileName);
InputStream inputStream = new FileInputStream(file1);
sftpUtil.upload(basePath,directory,pdfFileName,inputStream);
sftpUtil.upload(basePath+maxExportBatchNo+"/交易凭证/",directory,pdfFileName,inputStream);
//将文件路径和useId放入list,进行签章
Map<String,Object> map =Maps.newHashMap();
map.put("userId",record.getUserId());
map.put("fileAddress",basePath+directory+"/"+pdfFileName);
map.put("fileAddress",basePath+maxExportBatchNo+"/交易凭证/"+directory+"/"+pdfFileName);
filePathList.add(map);
}
} catch (Exception e) {
......@@ -392,13 +399,19 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
//File file = ZipUtil.zip("D:/0301/交易凭证", "D:/0301/交易凭证"+".zip");//zip 包保存路径
//FileToZip.mkdir(downloadLocalPath);
File file = ZipUtil.zip(downloadLocalPath, downloadLocalPath+".zip");//zip 包保存路径
FileInputStream is = new FileInputStream(file);
byte[] fileData = IOUtils.readNBytes(is, is.available());
Map<String,Object> map = new HashMap<>();
map.put("base64",Base64.getEncoder().encodeToString(fileData));
map.put("successCount",100);
map.put("failCount",20);
return JsonResult.buildSuccessResult("ok",map);
FileInputStream is = null;
try {
is = new FileInputStream(file);
byte[] fileData = IOUtils.readNBytes(is, is.available());
Map<String,Object> map = new HashMap<>();
map.put("base64",Base64.getEncoder().encodeToString(fileData));
map.put("successCount",100);
map.put("failCount",20);
return JsonResult.buildSuccessResult("ok",map);
} catch (Exception e) {
throw new RuntimeException("文件转换失败");
}
//返回给前端
//sreturn this.outputFile(response,"交易凭证.zip",fileData ,100,20);
}
......
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