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

判断非空

parent 255e1fc6
...@@ -129,23 +129,26 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR ...@@ -129,23 +129,26 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
//读取所有数据 //读取所有数据
List<TransactionReceiptRecord> readList = read(file.getOriginalFilename(), file.getInputStream()); List<TransactionReceiptRecord> readList = read(file.getOriginalFilename(), file.getInputStream());
//0代表初始状态,1代表导入成功,2代表导入失败 if(readList.size()>0){
for(TransactionReceiptRecord record : readList){ //0代表初始状态,1代表导入成功,2代表导入失败
//保存时如果有其中一项为空则默认为导入失败,其他则默认初始状态 for(TransactionReceiptRecord record : readList){
if(record.getUserId() ==null || record.getUserId() ==0 || StringUtils.isEmpty(record.getUserName()) || StringUtils.isEmpty(record.getOrderNo())){ //保存时如果有其中一项为空则默认为导入失败,其他则默认初始状态
record.setImportStatus(2); if(record.getUserId() ==null || record.getUserId() ==0 || StringUtils.isEmpty(record.getUserName()) || StringUtils.isEmpty(record.getOrderNo())){
//默认导出失败 record.setImportStatus(2);
record.setExportStatus(2); //默认导出失败
}else{ record.setExportStatus(2);
record.setImportStatus(0); }else{
//默认导出初始状态 record.setImportStatus(0);
record.setExportStatus(0); //默认导出初始状态
record.setExportStatus(0);
}
//存储批次号
record.setBatchNo(maxBatchNo);
transactionReceiptRecordRepo.save(record);
} }
//存储批次号 return JsonResult.buildSuccessResult("success",null);
record.setBatchNo(maxBatchNo);
transactionReceiptRecordRepo.save(record);
} }
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