tuqin
5 天以前 10158625f1096c54664a5f87b3f32d33794e4eee
yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/MdmItemController.java
@@ -333,7 +333,19 @@
    @PreAuthorize("@ss.hasPermission('mdm:item:import')")
    public CommonResult<MdmItemImportRespVO> importExcel(@RequestParam("file") MultipartFile file,
                                                         @RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport) throws Exception {
        List<MdmItemImportExcelVO> list = ExcelUtils.read(file, MdmItemImportExcelVO.class);
        List<MdmItemImportExcelVO> list;
        try {
            list = ExcelUtils.read(file, MdmItemImportExcelVO.class);
        } catch (cn.idev.excel.exception.ExcelDataConvertException e) {
            int row = e.getRowIndex() == null ? 0 : e.getRowIndex() + 1;
            int col = e.getColumnIndex() == null ? 0 : e.getColumnIndex() + 1;
            String cellVal = e.getCellData() == null ? "" : String.valueOf(e.getCellData().getStringValue());
            throw new cn.iocoder.yudao.framework.common.exception.ServiceException(400,
                    "Excel 第 " + row + " 行第 " + col + " 列数据『" + cellVal + "』格式不正确,请检查该列内容(例如“状态”请填 0/1 或 启用/停用)");
        } catch (Exception e) {
            throw new cn.iocoder.yudao.framework.common.exception.ServiceException(400,
                    "Excel 解析失败:" + e.getMessage() + ",请使用系统“下载导入模板”并按模板填写。");
        }
        return success(itemService.importItemList(list, updateSupport));
    }