Merge branch 'refs/heads/dev' into updateMenu
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
package org.dromara.cailiaoshebei.service.impl;
|
package org.dromara.cailiaoshebei.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import com.alibaba.excel.EasyExcel;
|
import com.alibaba.excel.EasyExcel;
|
||||||
import com.alibaba.excel.ExcelReader;
|
import com.alibaba.excel.ExcelReader;
|
||||||
import com.alibaba.excel.read.metadata.ReadSheet;
|
import com.alibaba.excel.read.metadata.ReadSheet;
|
||||||
@ -104,7 +105,7 @@ public class BusTotalsupplyplanServiceImpl extends ServiceImpl<BusTotalsupplypla
|
|||||||
private LambdaQueryWrapper<BusTotalsupplyplan> buildQueryWrapper(BusTotalsupplyplanBo bo) {
|
private LambdaQueryWrapper<BusTotalsupplyplan> buildQueryWrapper(BusTotalsupplyplanBo bo) {
|
||||||
Map<String, Object> params = bo.getParams();
|
Map<String, Object> params = bo.getParams();
|
||||||
LambdaQueryWrapper<BusTotalsupplyplan> lqw = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<BusTotalsupplyplan> lqw = Wrappers.lambdaQuery();
|
||||||
lqw.eq(bo.getProjectId() != null ,BusTotalsupplyplan::getProjectId,bo.getProjectId());
|
lqw.eq(bo.getProjectId() != null, BusTotalsupplyplan::getProjectId, bo.getProjectId());
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getTexture()), BusTotalsupplyplan::getTexture, bo.getTexture());
|
lqw.eq(StringUtils.isNotBlank(bo.getTexture()), BusTotalsupplyplan::getTexture, bo.getTexture());
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getBrand()), BusTotalsupplyplan::getBrand, bo.getBrand());
|
lqw.eq(StringUtils.isNotBlank(bo.getBrand()), BusTotalsupplyplan::getBrand, bo.getBrand());
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getQualityStandard()), BusTotalsupplyplan::getQualityStandard, bo.getQualityStandard());
|
lqw.eq(StringUtils.isNotBlank(bo.getQualityStandard()), BusTotalsupplyplan::getQualityStandard, bo.getQualityStandard());
|
||||||
@ -239,7 +240,14 @@ public class BusTotalsupplyplanServiceImpl extends ServiceImpl<BusTotalsupplypla
|
|||||||
}
|
}
|
||||||
// 关闭读取器
|
// 关闭读取器
|
||||||
excelReader.finish();
|
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);
|
throw new ServiceException("未读取到有效数据", HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
// 处理导入的数据
|
// 处理导入的数据
|
||||||
@ -248,7 +256,7 @@ public class BusTotalsupplyplanServiceImpl extends ServiceImpl<BusTotalsupplypla
|
|||||||
return this.updateBatchById(list);
|
return this.updateBatchById(list);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("物资供货总计划,导入Excel文件失败", 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()) {
|
if (listener.hasError()) {
|
||||||
throw new ServiceException("Excel导入失败");
|
throw new ServiceException("Excel导入失败");
|
||||||
}
|
}
|
||||||
|
if (listener.getSuccessCount() <= 0) {
|
||||||
|
return R.fail("未读取到有效数据");
|
||||||
|
}
|
||||||
log.info("地块数据导入完成,成功: {},失败: {}",
|
log.info("地块数据导入完成,成功: {},失败: {}",
|
||||||
listener.getSuccessCount(), listener.getFailCount());
|
listener.getSuccessCount(), listener.getFailCount());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user