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

判断非空

parent 255e1fc6
......@@ -129,23 +129,26 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
//读取所有数据
List<TransactionReceiptRecord> readList = read(file.getOriginalFilename(), file.getInputStream());
//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);
//默认导出失败
record.setExportStatus(2);
}else{
record.setImportStatus(0);
//默认导出初始状态
record.setExportStatus(0);
if(readList.size()>0){
//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);
//默认导出失败
record.setExportStatus(2);
}else{
record.setImportStatus(0);
//默认导出初始状态
record.setExportStatus(0);
}
//存储批次号
record.setBatchNo(maxBatchNo);
transactionReceiptRecordRepo.save(record);
}
//存储批次号
record.setBatchNo(maxBatchNo);
transactionReceiptRecordRepo.save(record);
return JsonResult.buildSuccessResult("success",null);
}
return JsonResult.buildSuccessResult("success",null);
return JsonResult.buildErrorStateResult("未读取到数据或读取失败");
}
public List<TransactionReceiptRecord> read(String filename, InputStream is) throws IOException {
......@@ -192,6 +195,9 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
TransactionReceiptRecord record = new TransactionReceiptRecord();
for (int c = 0; c < totalCols; c++) {
Cell cell = row.getCell(c);
if(cell == null){
continue;
}
cell.setCellType(cell.CELL_TYPE_STRING);
String cellValue = cell.getStringCellValue();
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