Commit 9f3d5a6d authored by 吴琼's avatar 吴琼

判断非空

parent 255e1fc6
...@@ -129,6 +129,7 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR ...@@ -129,6 +129,7 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
//读取所有数据 //读取所有数据
List<TransactionReceiptRecord> readList = read(file.getOriginalFilename(), file.getInputStream()); List<TransactionReceiptRecord> readList = read(file.getOriginalFilename(), file.getInputStream());
if(readList.size()>0){
//0代表初始状态,1代表导入成功,2代表导入失败 //0代表初始状态,1代表导入成功,2代表导入失败
for(TransactionReceiptRecord record : readList){ for(TransactionReceiptRecord record : readList){
//保存时如果有其中一项为空则默认为导入失败,其他则默认初始状态 //保存时如果有其中一项为空则默认为导入失败,其他则默认初始状态
...@@ -147,6 +148,8 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR ...@@ -147,6 +148,8 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
} }
return JsonResult.buildSuccessResult("success",null); return JsonResult.buildSuccessResult("success",null);
} }
return JsonResult.buildErrorStateResult("未读取到数据或读取失败");
}
public List<TransactionReceiptRecord> read(String filename, InputStream is) throws IOException { public List<TransactionReceiptRecord> read(String filename, InputStream is) throws IOException {
/** /**
...@@ -192,6 +195,9 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR ...@@ -192,6 +195,9 @@ 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);
if(cell == null){
continue;
}
cell.setCellType(cell.CELL_TYPE_STRING); cell.setCellType(cell.CELL_TYPE_STRING);
String cellValue = cell.getStringCellValue(); String cellValue = cell.getStringCellValue();
if (org.springframework.util.StringUtils.isEmpty(cellValue)) { if (org.springframework.util.StringUtils.isEmpty(cellValue)) {
......
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