| | |
| | | List<ScaleSplitTransport> list = new ArrayList<>(); |
| | | int failRows = 0; |
| | | try (Workbook wb = WorkbookFactory.create(file.getInputStream())) { |
| | | int targetMonth = Integer.parseInt(period.split("-")[1]); // 仅导入目标期所在月的页签(1-N月文件按目标期取当月/累计) |
| | | boolean hasPeriodSheet = false; |
| | | for (int i = 0; i < wb.getNumberOfSheets(); i++) { |
| | | String sn = wb.getSheetAt(i).getSheetName(); |
| | |
| | | Sheet sheet = wb.getSheetAt(i); |
| | | String sheetName = sheet.getSheetName(); |
| | | String periodType = null; |
| | | if (sheetName.contains("当月") || sheetName.contains("月份")) periodType = "MONTH"; |
| | | java.util.regex.Matcher mSheetMonth = java.util.regex.Pattern.compile("(\\d{1,2})\\u6708(\\u4efd|\\u7d2f\\u8ba1)").matcher(sheetName); |
| | | if (mSheetMonth.find()) { |
| | | int sheetMonth = Integer.parseInt(mSheetMonth.group(1)); |
| | | if (sheetMonth == targetMonth) { |
| | | periodType = "份".equals(mSheetMonth.group(2)) ? "MONTH" : "CUMULATIVE"; |
| | | } |
| | | } else { |
| | | if (sheetName.contains("当月")) periodType = "MONTH"; |
| | | else if (sheetName.contains("累计")) periodType = "CUMULATIVE"; |
| | | } |
| | | if (periodType == null) continue; |
| | | |
| | | // 校验 sheet 布局:第2行应含「市州/规上企业运输量」,第3行子表头应含「周转量」或「货运量」(扩展布局) |