| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | try { |
| | | List<SparePart> list = ExcelImportUtil.importExcel(file.getInputStream(), SparePart.class, params); |
| | | long start = System.currentTimeMillis(); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | SparePart sparePart = list.get(i); |
| | | if (!StringUtils.isNotEmpty(sparePart.getName())) |
| | | return Result.error("文件导入失败: 第" + (i + 1) + "行备件名称不能为空"); |
| | | if (!StringUtils.isNotEmpty(sparePart.getNum())) |
| | | return Result.error("文件导入失败: 第" + (i + 1) + "行备件编码不能为空"); |
| | | if (!StringUtils.isNotEmpty(sparePart.getSpecification())) |
| | | return Result.error("文件导入失败: 第" + (i + 1) + "行备件规格不能为空"); |
| | | if (!StringUtils.isNotEmpty(sparePart.getModel())) |
| | | return Result.error("文件导入失败: 第" + (i + 1) + "行备件型号不能为空"); |
| | | } |
| | | |
| | | sparePartService.saveBatch(list); |
| | | log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒"); |
| | | return Result.OK("文件导入成功!数据行数:" + list.size()); |