Merge branch 'refs/heads/dev' into updateMenu
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package org.dromara.cailiaoshebei.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.ExcelReader;
|
||||
import com.alibaba.excel.read.metadata.ReadSheet;
|
||||
@ -239,7 +240,14 @@ public class BusTotalsupplyplanServiceImpl extends ServiceImpl<BusTotalsupplypla
|
||||
}
|
||||
// 关闭读取器
|
||||
excelReader.finish();
|
||||
if (allData.isEmpty()) {
|
||||
if (CollUtil.isEmpty(allData)) {
|
||||
throw new ServiceException("未读取到有效数据", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
// 过滤 id 为空的数据
|
||||
allData = allData.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(data -> data.getId() != null).toList();
|
||||
if (CollUtil.isEmpty(allData)) {
|
||||
throw new ServiceException("未读取到有效数据", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
// 处理导入的数据
|
||||
@ -248,7 +256,7 @@ public class BusTotalsupplyplanServiceImpl extends ServiceImpl<BusTotalsupplypla
|
||||
return this.updateBatchById(list);
|
||||
} catch (Exception e) {
|
||||
log.error("物资供货总计划,导入Excel文件失败", e);
|
||||
throw new ServiceException("导入失败: " + e.getMessage(), HttpStatus.ERROR);
|
||||
throw new ServiceException("导入失败, " + e.getMessage(), HttpStatus.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -162,7 +162,9 @@ public class BusLandBlockController extends BaseController {
|
||||
if (listener.hasError()) {
|
||||
throw new ServiceException("Excel导入失败");
|
||||
}
|
||||
|
||||
if (listener.getSuccessCount() <= 0) {
|
||||
return R.fail("未读取到有效数据");
|
||||
}
|
||||
log.info("地块数据导入完成,成功: {},失败: {}",
|
||||
listener.getSuccessCount(), listener.getFailCount());
|
||||
} catch (IOException e) {
|
||||
|
||||
Reference in New Issue
Block a user