Commit 61268149 authored by 吴琼's avatar 吴琼

xiugai

parent 9f3d5a6d
...@@ -64,9 +64,9 @@ public class TransactionReceiptRecordRest { ...@@ -64,9 +64,9 @@ public class TransactionReceiptRecordRest {
@ResponseBody @ResponseBody
public JsonResult importTransactionReceiptRecord(MultipartFile multipartFile) { public JsonResult importTransactionReceiptRecord(MultipartFile multipartFile) {
try{ try{
/* File excelFile =new File("D://交易凭证.xlsx"); /*File excelFile =new File("D://交易凭证.xlsx");
FileInputStream inputStream =new FileInputStream(excelFile); FileInputStream inputStream =new FileInputStream(excelFile);
MultipartFile multipartFile = new MockMultipartFile(excelFile.getName(), excelFile.getName(), multipartFile = new MockMultipartFile(excelFile.getName(), excelFile.getName(),
ContentType.APPLICATION_OCTET_STREAM.toString(), inputStream);*/ ContentType.APPLICATION_OCTET_STREAM.toString(), inputStream);*/
return transactionReceiptRecordService.importTransactionReceiptRecord(multipartFile); return transactionReceiptRecordService.importTransactionReceiptRecord(multipartFile);
}catch(IOException e){ }catch(IOException e){
......
...@@ -128,12 +128,22 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR ...@@ -128,12 +128,22 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
} }
//读取所有数据 //读取所有数据
log.info("importTransactionReceiptRecord read begin");
List<TransactionReceiptRecord> readList = read(file.getOriginalFilename(), file.getInputStream()); List<TransactionReceiptRecord> readList = read(file.getOriginalFilename(), file.getInputStream());
log.info("importTransactionReceiptRecord read end");
if(readList.size()>0){ if(readList.size()>0){
//0代表初始状态,1代表导入成功,2代表导入失败 //0代表初始状态,1代表导入成功,2代表导入失败
for(TransactionReceiptRecord record : readList){ for(TransactionReceiptRecord record : readList){
//保存时如果有其中一项为空则默认为导入失败,其他则默认初始状态 //保存时如果有其中一项为空则默认为导入失败,其他则默认初始状态
if(record.getUserId() ==null || record.getUserId() ==0 || StringUtils.isEmpty(record.getUserName()) || StringUtils.isEmpty(record.getOrderNo())){ if((record.getUserId() == null || record.getUserId() == 0)
&& StringUtils.isEmpty(record.getUserName()) && StringUtils.isEmpty(record.getOrderNo())
&& StringUtils.isEmpty(record.getSerialNo())
){
continue;
}
if(record.getUserId() ==null || record.getUserId() ==0
|| StringUtils.isEmpty(record.getUserName())
|| StringUtils.isEmpty(record.getOrderNo())){
record.setImportStatus(2); record.setImportStatus(2);
//默认导出失败 //默认导出失败
record.setExportStatus(2); record.setExportStatus(2);
...@@ -152,6 +162,7 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR ...@@ -152,6 +162,7 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
} }
public List<TransactionReceiptRecord> read(String filename, InputStream is) throws IOException { public List<TransactionReceiptRecord> read(String filename, InputStream is) throws IOException {
log.info(" read excel file");
/** /**
* 总行数 * 总行数
*/ */
...@@ -183,7 +194,7 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR ...@@ -183,7 +194,7 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
} }
/** 循环Excel的行 */ /** 循环Excel的行 */
for (int r = 0; r < totalRows; r++) { for (int r = 0; r < totalRows; r++) {
log.info(" read excel file");
if(r == 0){ if(r == 0){
continue; continue;
} }
...@@ -195,6 +206,7 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR ...@@ -195,6 +206,7 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
TransactionReceiptRecord record = new TransactionReceiptRecord(); TransactionReceiptRecord record = new TransactionReceiptRecord();
for (int c = 0; c < totalCols; c++) { for (int c = 0; c < totalCols; c++) {
Cell cell = row.getCell(c); Cell cell = row.getCell(c);
log.info("cell "+cell);
if(cell == null){ if(cell == null){
continue; continue;
} }
...@@ -267,20 +279,21 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR ...@@ -267,20 +279,21 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
return JsonResult.buildErrorStateResult("未查询到对应的订单信息"); return JsonResult.buildErrorStateResult("未查询到对应的订单信息");
} }
//生成pdf //生成pdf
String basicPath="D:\\交易凭证0222"; String basicPath="D:\\交易凭证0222";
String filePath =basicPath +"\\"+record.getBatchNo()+record.getUserName(); String filePath =basicPath +"\\"+record.getBatchNo()+record.getUserName();
FileToZip.mkdir(filePath); FileToZip.mkdir(filePath);
filePath = filePath+"\\"+record.getOrderNo()+".pdf"; filePath = filePath+"\\"+record.getOrderNo()+".pdf";
generatePDF(transactionReceiptVOList.get(0),filePath); generatePDF(transactionReceiptVOList.get(0),filePath);
//调用电子签章接口 //调用电子签章接口
//todo
//保存到文件服务器上 //保存到文件服务器上
SFTPUtil sftpUtil = new SFTPUtil(username,password,host,port); /* SFTPUtil sftpUtil = new SFTPUtil(username,password,host,port);
sftpUtil.login(); sftpUtil.login();
log.info("uploadFile | 成功连接ftp"); log.info("uploadFile | 成功连接ftp");
//sftpUtil.upload(basePath,directory,okFileName,new ByteArrayInputStream(okFileData)); //sftpUtil.upload(basePath,directory,okFileName,new ByteArrayInputStream(okFileData));
sftpUtil.logout(); sftpUtil.logout();*/
//todo
} }
} catch (Exception e) { } catch (Exception e) {
log.error("[TransactionReceiptRecordServiceImpl][exportZipFile] 网络通讯异常,userId:{},ex:{}", ExceptionUtils.getStackTrace(e)); log.error("[TransactionReceiptRecordServiceImpl][exportZipFile] 网络通讯异常,userId:{},ex:{}", ExceptionUtils.getStackTrace(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