| | |
| | | */ |
| | | @PostMapping("/uploadExt") |
| | | public R uploadExt(@RequestParam("file") MultipartFile file) { |
| | | //ExcelReader excelReader = null; |
| | | //try { |
| | | // ExcelReaderBuilder excelReaderBuilder = EasyExcel.read(file.getInputStream()); |
| | | // excelReader = excelReaderBuilder.build(); |
| | | // List<ReadSheet> sheets = excelReader.excelExecutor().sheetList(); |
| | | // List<ReadSheet> readSheetList = new ArrayList<>(); |
| | | // for (ReadSheet sheet : sheets) { |
| | | // ReadSheet readSheet = EasyExcel.readSheet(sheet.getSheetName()).registerReadListener(new StructureUploadExtListener(structureService)).build(); |
| | | // readSheetList.add(readSheet); |
| | | // } |
| | | // excelReader.read(readSheetList); |
| | | //} catch (IOException e) { |
| | | // e.printStackTrace(); |
| | | // return R.failed(e.getMessage()); |
| | | //} finally { |
| | | // if (excelReader != null) { |
| | | // // 这里千万别忘记关闭,读的时候会创建临时文件,到时磁盘会崩的 |
| | | // excelReader.finish(); |
| | | // } |
| | | //} |
| | | ExcelReader excelReader = null; |
| | | try { |
| | | excelReader = EasyExcel.read(file.getInputStream(), StructureData.class, new StructureUploadListener(structureService, dictUtils)).build(); |
| | | excelReader = EasyExcel.read(file.getInputStream(), StructureData.class, new StructureUploadListener(structureService)).build(); |
| | | ReadSheet readSheet = EasyExcel.readSheet(0).build(); |
| | | ReadSheet readSheet2 = EasyExcel.readSheet(1).build(); |
| | | excelReader.read(readSheet,readSheet2); |
| | |
| | | * 竖着导入 |
| | | * |
| | | * @param file |
| | | * @return |
| | | */ |
| | | @PostMapping("/upload") |
| | | public R simpleRead(@RequestParam("file") MultipartFile file) { |
| | | ExcelReader excelReader = null; |
| | | try { |
| | | excelReader = EasyExcel.read(file.getInputStream(), StructureData.class, new StructureUploadListener(structureService, dictUtils)).build(); |
| | | ReadSheet readSheet = EasyExcel.readSheet(0).build(); |
| | | ReadSheet readSheet2 = EasyExcel.readSheet(1).build(); |
| | | excelReader.read(readSheet,readSheet2); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | return R.failed(e.getMessage()); |
| | | } finally { |
| | | if (excelReader != null) { |
| | | // 这里千万别忘记关闭,读的时候会创建临时文件,到时磁盘会崩的 |
| | | excelReader.finish(); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | // * @return |
| | | // */ |
| | | // @PostMapping("/upload") |
| | | // public R simpleRead(@RequestParam("file") MultipartFile file) { |
| | | // ExcelReader excelReader = null; |
| | | // try { |
| | | // excelReader = EasyExcel.read(file.getInputStream(), StructureData.class, new StructureUploadListener(structureService)).build(); |
| | | // ReadSheet readSheet = EasyExcel.readSheet(0).build(); |
| | | // ReadSheet readSheet2 = EasyExcel.readSheet(1).build(); |
| | | // excelReader.read(readSheet,readSheet2); |
| | | // } catch (IOException e) { |
| | | // e.printStackTrace(); |
| | | // return R.failed(e.getMessage()); |
| | | // } finally { |
| | | // if (excelReader != null) { |
| | | // // 这里千万别忘记关闭,读的时候会创建临时文件,到时磁盘会崩的 |
| | | // excelReader.finish(); |
| | | // } |
| | | // } |
| | | // return R.ok(); |
| | | // } |
| | | |
| | | /** |
| | | * 根据零件号查询默认BOM |