| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.InputStream; |
| | | import java.math.BigDecimal; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | |
| | | throw new ServiceException("请选择要导入的Excel文件"); |
| | | } |
| | | ExcelUtil<SiteExcelDTO> util = new ExcelUtil<>(SiteExcelDTO.class); |
| | | List<SiteExcelDTO> rows = util.importExcel(file.getInputStream(), 0); |
| | | List<SiteExcelDTO> rows; |
| | | try (InputStream inputStream = file.getInputStream()) { |
| | | rows = util.importExcel(inputStream, 0); |
| | | } catch (Exception e) { |
| | | throw new ServiceException("Excel文件已损坏或格式不正确,请重新下载站点导入模板后填写") |
| | | .setDetailMessage(e.getMessage()); |
| | | } |
| | | if (rows == null || rows.isEmpty()) { |
| | | throw new ServiceException("导入文件没有数据"); |
| | | } |