xyc
2026-11-11 d5ca840e64d444705a83df9e393c5df9e085feff
fix(城市客运): 优化出租车运政车辆导入解析性能
2个文件已添加
3个文件已修改
543 ■■■■■ 已修改文件
HANDOFF.md 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
traffic-audit-server/src/main/java/com/trafficaudit/dataimport/service/CityTaxiAuthWorkbookParser.java 321 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
traffic-audit-server/src/main/java/com/trafficaudit/dataimport/service/DataImportService.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
traffic-audit-server/src/test/java/com/trafficaudit/dataimport/service/CityTaxiAuthWorkbookParserTest.java 164 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
traffic-audit-web/src/views/DataImport.vue 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HANDOFF.md
@@ -1814,3 +1814,17 @@
- 打印为A3横向、全部列一页宽:核查概况1页、企业核查结果1页、重点车辆核查结果1页、问题明细2页,共5页;Excel COM导出正常,无 `####`、截断或彩色像素,12组车辆问题均未跨页,“广发”鄂J50898两项问题完整同页。
- 本次覆盖前备份:`work\_backups\2026年9月企业台账抽查核查结果_before_city_group_header_center_20261028_121103.xlsx`(旧版 SHA-256 `C810093F0A849A5DBFEF8801122065491EFC87038D8B20A6DC30AC936D88C80F`)。
- 本地测试记录:`docs\功能测试报告\功能测试报告_企业台账抽查核查结果Excel排版与字段调整_2026-10-28.md`(gitignored)。
## 2026-11-11 出租车运政车辆导入性能优化 【已验收】
- 状态:已验收(2026-11-11);本轮未执行正式数据导入。
- 源文件:`D:\03_公司\02_项目\27_湖北省道路运输事业发展中心\10_业务\203_城市客运\2026\10月\出租车信息列表.xls`,约27 MB、41,469行,SHA-256 `F6402D12C39070F38CBECFF7BB7E92FB8F9DE8A407D1E7E199072B4A8789C2EA`。
- 根因:旧实现使用 `WorkbookFactory.create()`/`HSSFWorkbook` 构建整本 `.xls` 对象模型,正式文件解析约136~223秒;数据库批量写入约28秒,不是主要耗时。
- 修复:新增 `CityTaxiAuthWorkbookParser`,旧版 `.xls` 改用 POI 事件流按行/列读取,`.xlsx` 保持原有兼容路径;解析时按 BIFF 单元格记录的真实列号保存字段,避免中间空列导致字段错位。
- 重点兼容:该 `.xls` 的 `RowRecord` 会先集中出现、单元格记录随后出现,解析器不再用第二个 `RowRecord` 提前结束上一行,而是在单元格记录行号变化时收行。
- 性能验证:正式文件解析 `41,469` 行耗时约 `378~384 ms`;`DataImportService` 已增加 `parse/clear/insert/total` 分段日志,便于用户重导时确认实际耗时。
- 正确性验证:正式文件全部行道路运输证非空;样车 `鄂SD50883绿` 的道路运输证 `随州422903000390`、经营权号 `随州421300600383`、车主 `赵庆` 与源表一致;中间空列合成用例通过。
- 测试结果:`CityTaxiAuthWorkbookParserTest` 5个用例全部通过;完整后端测试 `38` 个、失败 `0`、错误 `0`、跳过 `2`;前端 `npm.cmd run build` 成功,仅有既有 bundle 体积告警。
- 当前服务:后端已重启并加载新代码,启动日志含 `Tomcat started on port(s): 8090`、`Started TrafficAuditApplication`;前端仍运行在 `http://localhost:8080`。
- 用户下一步:在数据导入页重新选择“出租车运政车辆”,报表期 `2026-10`,用户自行导入正式文件;导入完成后查看后端日志中的 `CityTaxiAuth parsed/imported` 分段耗时。
- 本地测试记录:`docs\功能测试报告\功能测试报告_出租车运政车辆导入性能优化_2026-11-11.md`(gitignored)。
traffic-audit-server/src/main/java/com/trafficaudit/dataimport/service/CityTaxiAuthWorkbookParser.java
New file
@@ -0,0 +1,321 @@
package com.trafficaudit.dataimport.service;
import com.trafficaudit.dataimport.entity.CityTaxiAuth;
import org.apache.poi.hssf.eventusermodel.FormatTrackingHSSFListener;
import org.apache.poi.hssf.eventusermodel.HSSFEventFactory;
import org.apache.poi.hssf.eventusermodel.HSSFListener;
import org.apache.poi.hssf.eventusermodel.HSSFRequest;
import org.apache.poi.hssf.record.BOFRecord;
import org.apache.poi.hssf.record.BoolErrRecord;
import org.apache.poi.hssf.record.EOFRecord;
import org.apache.poi.hssf.record.ExtendedFormatRecord;
import org.apache.poi.hssf.record.FormulaRecord;
import org.apache.poi.hssf.record.FormatRecord;
import org.apache.poi.hssf.record.LabelRecord;
import org.apache.poi.hssf.record.LabelSSTRecord;
import org.apache.poi.hssf.record.MulRKRecord;
import org.apache.poi.hssf.record.NumberRecord;
import org.apache.poi.hssf.record.RKRecord;
import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.RecordFactory;
import org.apache.poi.hssf.record.RowRecord;
import org.apache.poi.hssf.record.SSTRecord;
import org.apache.poi.hssf.record.StringRecord;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
public class CityTaxiAuthWorkbookParser {
    private static final byte[] OLE2_SIGNATURE = new byte[] {
        (byte) 0xD0, (byte) 0xCF, 0x11, (byte) 0xE0,
        (byte) 0xA1, (byte) 0xB1, 0x1A, (byte) 0xE1
    };
    private static final int LAST_REQUIRED_COLUMN = 20;
    private static final DataFormatter FORMATTER = new DataFormatter(Locale.CHINA);
    public List<CityTaxiAuth> parse(InputStream source) throws IOException {
        BufferedInputStream input = source instanceof BufferedInputStream
            ? (BufferedInputStream) source
            : new BufferedInputStream(source, 1024 * 1024);
        byte[] signature = readSignature(input);
        if (Arrays.equals(signature, OLE2_SIGNATURE)) {
            return parseLegacyXls(input);
        }
        return parseWorkbook(input);
    }
    private List<CityTaxiAuth> parseLegacyXls(InputStream input) throws IOException {
        try (POIFSFileSystem fs = new POIFSFileSystem(input)) {
            CityTaxiAuthRecordListener listener = new CityTaxiAuthRecordListener();
            FormatTrackingHSSFListener formattingListener =
                new FormatTrackingHSSFListener(listener, Locale.CHINA);
            listener.setFormattingListener(formattingListener);
            HSSFRequest request = new HSSFRequest();
            request.addListenerForAllRecords(formattingListener);
            new HSSFEventFactory().processWorkbookEvents(request, fs.getRoot());
            return listener.finish();
        }
    }
    private List<CityTaxiAuth> parseWorkbook(InputStream input) throws IOException {
        try (Workbook workbook = WorkbookFactory.create(input)) {
            if (workbook.getNumberOfSheets() == 0) throw headerError();
            Sheet sheet = workbook.getSheetAt(0);
            requireHeader(sheet);
            List<CityTaxiAuth> rows = new ArrayList<>(Math.max(16, sheet.getLastRowNum()));
            for (int rowIndex = 1; rowIndex <= sheet.getLastRowNum(); rowIndex++) {
                Row row = sheet.getRow(rowIndex);
                if (row == null) continue;
                String plate = getString(row, 0);
                if (plate == null) continue;
                CityTaxiAuth item = new CityTaxiAuth();
                item.setPlateNo(plate.trim());
                item.setVehicleType(getString(row, 1));
                item.setBizType(getString(row, 2));
                item.setOwnerName(getString(row, 3));
                item.setLicenseNo(getString(row, 4));
                item.setFuelType(getString(row, 7));
                item.setArchiveNo(getString(row, 8));
                item.setRoadCertNo(getString(row, 9));
                item.setOperatorName(getString(row, 17));
                item.setOperatorAddr(getString(row, 18));
                item.setOpStatus(getString(row, 19));
                item.setCertStatus(getString(row, 20));
                rows.add(item);
            }
            return rows;
        }
    }
    private CityTaxiAuth toEntity(String[] values, String plate) {
        CityTaxiAuth item = new CityTaxiAuth();
        item.setPlateNo(plate.trim());
        item.setVehicleType(cell(values, 1));
        item.setBizType(cell(values, 2));
        item.setOwnerName(cell(values, 3));
        item.setLicenseNo(cell(values, 4));
        item.setFuelType(cell(values, 7));
        item.setArchiveNo(cell(values, 8));
        item.setRoadCertNo(cell(values, 9));
        item.setOperatorName(cell(values, 17));
        item.setOperatorAddr(cell(values, 18));
        item.setOpStatus(cell(values, 19));
        item.setCertStatus(cell(values, 20));
        return item;
    }
    private void requireHeader(Sheet sheet) {
        Row header = sheet.getRow(0);
        if (header == null) throw headerError();
        for (Cell cell : header) {
            String value = FORMATTER.formatCellValue(cell);
            if (value != null && value.contains("车牌")) return;
        }
        throw headerError();
    }
    private void requireHeader(String[] header) {
        for (String value : header) {
            if (value != null && value.contains("车牌")) return;
        }
        throw headerError();
    }
    private IllegalStateException headerError() {
        return new IllegalStateException("所选数据类型【出租车运政车辆】与文件内容不符"
            + ":表头未包含【车牌】等列,请确认是否选错了数据类型");
    }
    private String getString(Row row, int index) {
        Cell cell = row.getCell(index);
        if (cell == null) return null;
        if (cell.getCellType() == CellType.FORMULA
                && cell.getCachedFormulaResultType() == CellType.STRING) {
            String cached = cell.getStringCellValue();
            cached = cached == null ? null : cached.trim();
            return cached == null || cached.isEmpty() ? null : cached;
        }
        String value = FORMATTER.formatCellValue(cell).trim();
        return value.isEmpty() ? null : value;
    }
    private String cell(String[] values, int index) {
        if (index >= values.length) return null;
        String value = values[index];
        if (value == null) return null;
        value = value.trim();
        return value.isEmpty() ? null : value;
    }
    private byte[] readSignature(BufferedInputStream input) throws IOException {
        input.mark(8);
        byte[] signature = new byte[8];
        int offset = 0;
        while (offset < signature.length) {
            int read = input.read(signature, offset, signature.length - offset);
            if (read < 0) break;
            offset += read;
        }
        input.reset();
        if (offset < signature.length) {
            throw new IOException("文件内容为空或格式不完整");
        }
        return signature;
    }
    private final class CityTaxiAuthRecordListener implements HSSFListener {
        private final List<CityTaxiAuth> rows = new ArrayList<>(65536);
        private final List<String> headerValues = new ArrayList<>();
        private FormatTrackingHSSFListener formattingListener;
        private SSTRecord sharedStrings;
        private boolean activeSheet = true;
        private boolean headerSeen;
        private int worksheetIndex = -1;
        private int currentRow = -1;
        private String[] currentValues;
        private int pendingFormulaRow = -1;
        private int pendingFormulaColumn = -1;
        private void setFormattingListener(FormatTrackingHSSFListener formattingListener) {
            this.formattingListener = formattingListener;
        }
        @Override
        public void processRecord(Record record) {
            if (record instanceof SSTRecord) {
                sharedStrings = (SSTRecord) record;
                return;
            }
            if (record instanceof BOFRecord) {
                BOFRecord bof = (BOFRecord) record;
                if (bof.getType() == BOFRecord.TYPE_WORKSHEET) {
                    worksheetIndex++;
                    activeSheet = worksheetIndex == 0;
                }
                return;
            }
            if (record instanceof EOFRecord) {
                if (activeSheet) {
                    finishRow();
                    activeSheet = false;
                }
                return;
            }
            if (!activeSheet) return;
            if (record instanceof RowRecord) {
                // RowRecord is row metadata in this BIFF stream. Cell records define
                // the actual row transition and must be allowed to arrive first.
            } else if (record instanceof LabelSSTRecord) {
                LabelSSTRecord cell = (LabelSSTRecord) record;
                startRowIfNeeded(cell.getRow());
                String value = null;
                if (sharedStrings != null) {
                    value = sharedStrings.getString(cell.getSSTIndex()).getString();
                }
                setCell(cell.getRow(), cell.getColumn(), value);
            } else if (record instanceof LabelRecord) {
                LabelRecord cell = (LabelRecord) record;
                setCell(cell.getRow(), cell.getColumn(), cell.getValue());
            } else if (record instanceof NumberRecord) {
                NumberRecord cell = (NumberRecord) record;
                setCell(cell.getRow(), cell.getColumn(), formattingListener.formatNumberDateCell(cell));
            } else if (record instanceof RKRecord) {
                RKRecord cell = (RKRecord) record;
                setCell(cell.getRow(), cell.getColumn(), formattingListener.formatNumberDateCell(cell));
            } else if (record instanceof MulRKRecord) {
                for (NumberRecord number : RecordFactory.convertRKRecords((MulRKRecord) record)) {
                    setCell(number.getRow(), number.getColumn(),
                        formattingListener.formatNumberDateCell(number));
                }
            } else if (record instanceof FormulaRecord) {
                FormulaRecord cell = (FormulaRecord) record;
                startRowIfNeeded(cell.getRow());
                if (cell.hasCachedResultString()) {
                    pendingFormulaRow = cell.getRow();
                    pendingFormulaColumn = cell.getColumn();
                    setCell(cell.getRow(), cell.getColumn(), null);
                } else {
                    setCell(cell.getRow(), cell.getColumn(), formattingListener.formatNumberDateCell(cell));
                }
            } else if (record instanceof StringRecord) {
                if (pendingFormulaRow >= 0) {
                    setCell(pendingFormulaRow, pendingFormulaColumn, ((StringRecord) record).getString());
                    pendingFormulaRow = -1;
                    pendingFormulaColumn = -1;
                }
            } else if (record instanceof BoolErrRecord) {
                BoolErrRecord cell = (BoolErrRecord) record;
                String value = cell.isBoolean()
                    ? Boolean.toString(cell.getBooleanValue())
                    : Byte.toString(cell.getErrorValue());
                setCell(cell.getRow(), cell.getColumn(), value);
            }
        }
        private List<CityTaxiAuth> finish() {
            finishRow();
            if (!headerSeen) {
                throw headerError();
            }
            return rows;
        }
        private void startRowIfNeeded(int row) {
            if (currentRow != row) startRow(row);
        }
        private void startRow(int row) {
            finishRow();
            currentRow = row;
            currentValues = new String[LAST_REQUIRED_COLUMN + 1];
        }
        private void finishRow() {
            if (currentRow < 0) return;
            if (currentRow == 0) {
                requireHeader(headerValues.toArray(new String[0]));
                headerSeen = true;
            } else {
                String plate = cell(currentValues, 0);
                if (plate != null) {
                    rows.add(toEntity(currentValues, plate));
                }
            }
            currentRow = -1;
            currentValues = null;
        }
        private void setCell(int row, int column, String rawValue) {
            startRowIfNeeded(row);
            String value = normalize(rawValue);
            if (row == 0) {
                while (headerValues.size() <= column) headerValues.add(null);
                headerValues.set(column, value);
            } else if (column >= 0 && column <= LAST_REQUIRED_COLUMN) {
                currentValues[column] = value;
            }
        }
        private String normalize(String value) {
            if (value == null) return null;
            String trimmed = value.trim();
            return trimmed.isEmpty() ? null : trimmed;
        }
    }
}
traffic-audit-server/src/main/java/com/trafficaudit/dataimport/service/DataImportService.java
@@ -107,6 +107,8 @@
    private static final DataFormatter FORMATTER = new DataFormatter();
    private final CityTaxiAuthWorkbookParser cityTaxiAuthWorkbookParser = new CityTaxiAuthWorkbookParser();
    /** 能耗导入按报表期互斥,防止同报表期并发重导互相覆盖 */
    private final ConcurrentHashMap<String, Object> energyImportLocks = new ConcurrentHashMap<>();
@@ -3602,40 +3604,27 @@
    /** 出租车运政车辆信息导入(车辆级明细,按市州归属统计用) */
    public synchronized int importCityTaxiAuth(MultipartFile file, String period) throws Exception {
        List<CityTaxiAuth> list = new ArrayList<>();
        try (Workbook wb = WorkbookFactory.create(file.getInputStream())) {
            Sheet sheet = wb.getSheetAt(0);
            requireHeaderKeyword(sheet, "出租车运政车辆", "车牌");
            for (int r = 1; r <= sheet.getLastRowNum(); r++) {
                Row row = sheet.getRow(r);
                if (row == null) continue;
                String plate = getString(row, 0);
                if (plate == null || plate.trim().isEmpty()) continue;
                CityTaxiAuth item = new CityTaxiAuth();
        long startedAt = System.currentTimeMillis();
        List<CityTaxiAuth> list;
        try (InputStream input = file.getInputStream()) {
            list = cityTaxiAuthWorkbookParser.parse(input);
            for (CityTaxiAuth item : list) {
                item.setReportPeriod(period);
                item.setCity(taxiCity(getString(row, 9), getString(row, 8), getString(row, 4), getString(row, 18)));
                item.setPlateNo(plate.trim());
                item.setVehicleType(getString(row, 1));
                item.setBizType(getString(row, 2));
                item.setOwnerName(getString(row, 3));
                item.setLicenseNo(getString(row, 4));
                item.setFuelType(getString(row, 7));
                item.setArchiveNo(getString(row, 8));
                item.setRoadCertNo(getString(row, 9));
                item.setOperatorName(getString(row, 17));
                item.setOperatorAddr(getString(row, 18));
                item.setOpStatus(getString(row, 19));
                item.setCertStatus(getString(row, 20));
                list.add(item);
                item.setCity(taxiCity(item.getRoadCertNo(), item.getArchiveNo(),
                    item.getLicenseNo(), item.getOperatorAddr()));
            }
        } catch (Exception e) {
            log.error("CityTaxiAuth import parse error", e);
            throw e;
        }
        long parsedAt = System.currentTimeMillis();
        log.info("CityTaxiAuth parsed: {} rows for {}, parse={} ms",
            list.size(), period, parsedAt - startedAt);
        // 幂等:同报表期先清旧数据(运政车辆量大,批量清理)
        cityTaxiAuthMapper.delete(new LambdaQueryWrapper<CityTaxiAuth>()
            .eq(CityTaxiAuth::getReportPeriod, period));
        deleteAuditResults(period, "CITY_TAXI");
        long clearedAt = System.currentTimeMillis();
        // 批量插入(BATCH 模式):42636 行约 20~40 秒,逐条插入需约 6 分钟会触发前端超时
        int success = 0;
        int fail = 0;
@@ -3651,8 +3640,11 @@
            fail = list.size();
            log.error("CityTaxiAuth batch insert error", e);
        }
        long finishedAt = System.currentTimeMillis();
        recordBatch(file.getOriginalFilename(), "CITY_TAXI_AUTH", period, list.size(), success, fail, null);
        log.info("CityTaxiAuth imported: {} rows for {}", success, period);
        log.info("CityTaxiAuth imported: {} rows for {}, parse={} ms, clear={} ms, insert={} ms, total={} ms",
            success, period, parsedAt - startedAt, clearedAt - parsedAt,
            finishedAt - clearedAt, finishedAt - startedAt);
        return success;
    }
traffic-audit-server/src/test/java/com/trafficaudit/dataimport/service/CityTaxiAuthWorkbookParserTest.java
New file
@@ -0,0 +1,164 @@
package com.trafficaudit.dataimport.service;
import com.trafficaudit.dataimport.entity.CityTaxiAuth;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
class CityTaxiAuthWorkbookParserTest {
    private static final String HEADER_PLATE = "\u8f66\u724c";
    private static final String PLATE = "\u9102A12345";
    private static final String VEHICLE_TYPE = "\u5c0f\u578b\u8f7f\u8f66";
    private static final String BIZ_TYPE = "\u516c\u53f8\u7ecf\u8425";
    private static final String OWNER = "\u5f20\u4e09";
    private static final String LICENSE = "420100600001";
    private static final String FUEL = "\u6c7d\u6cb9";
    private static final String ARCHIVE = "420100000001";
    private static final String ROAD_CERT = "\u6b66\u6c49" + "420100000002";
    private static final String OPERATOR = "\u6b66\u6c49\u67d0\u516c\u53f8";
    private static final String ADDRESS = "\u6e56\u5317\u7701\u6b66\u6c49\u5e02";
    private static final String OP_STATUS = "\u8425\u8fd0";
    private static final String CERT_STATUS = "\u6709\u6548";
    private final CityTaxiAuthWorkbookParser parser = new CityTaxiAuthWorkbookParser();
    @Test
    void parsesLegacyXlsWithEventExtractor() throws Exception {
        byte[] bytes = workbookBytes(new HSSFWorkbook(), true);
        List<CityTaxiAuth> rows = parser.parse(new ByteArrayInputStream(bytes));
        assertEquals(1, rows.size());
        assertFields(rows.get(0));
    }
    @Test
    void parsesXlsxWithWorkbookFactory() throws Exception {
        byte[] bytes = workbookBytes(new XSSFWorkbook(), true);
        List<CityTaxiAuth> rows = parser.parse(new ByteArrayInputStream(bytes));
        assertEquals(1, rows.size());
        assertFields(rows.get(0));
    }
    @Test
    void rejectsWrongHeader() throws Exception {
        byte[] bytes = workbookBytes(new HSSFWorkbook(), false);
        IllegalStateException error = assertThrows(IllegalStateException.class,
            () -> parser.parse(new ByteArrayInputStream(bytes)));
        assertTrue(error.getMessage().contains(HEADER_PLATE));
    }
    @Test
    void allowsShortLegacyRowAndLeavesMissingFieldsNull() throws Exception {
        byte[] bytes;
        try (HSSFWorkbook workbook = new HSSFWorkbook();
             ByteArrayOutputStream output = new ByteArrayOutputStream()) {
            Sheet sheet = workbook.createSheet();
            sheet.createRow(0).createCell(0).setCellValue(HEADER_PLATE);
            sheet.createRow(1).createCell(0).setCellValue(PLATE);
            workbook.write(output);
            bytes = output.toByteArray();
        }
        List<CityTaxiAuth> rows = parser.parse(new ByteArrayInputStream(bytes));
        assertEquals(1, rows.size());
        assertEquals(PLATE, rows.get(0).getPlateNo());
        assertNull(rows.get(0).getVehicleType());
        assertNull(rows.get(0).getRoadCertNo());
        assertNull(rows.get(0).getCertStatus());
    }
    @Test
    void parsesConfiguredProductionWorkbook() throws Exception {
        String configured = System.getProperty("cityTaxiAuth.source", "");
        Assumptions.assumeTrue(!configured.trim().isEmpty(),
            "cityTaxiAuth.source is not configured");
        Path path = Paths.get(configured);
        Assumptions.assumeTrue(Files.isRegularFile(path), "configured source file does not exist");
        long startedAt = System.nanoTime();
        List<CityTaxiAuth> rows;
        try (InputStream input = Files.newInputStream(path)) {
            rows = parser.parse(input);
        }
        long elapsedMs = (System.nanoTime() - startedAt) / 1_000_000;
        assertEquals(41469, rows.size());
        assertTrue(rows.stream().allMatch(row -> row.getPlateNo() != null));
        assertTrue(rows.stream().allMatch(row -> row.getRoadCertNo() != null));
        CityTaxiAuth sample = rows.stream()
            .filter(row -> "\u9102SD50883\u7eff".equals(row.getPlateNo()))
            .findFirst()
            .orElseThrow(() -> new AssertionError("production sample plate not found"));
        assertEquals("\u968f\u5dde422903000390", sample.getRoadCertNo());
        assertEquals("\u968f\u5dde421300600383", sample.getLicenseNo());
        assertEquals("\u8d75\u5e86", sample.getOwnerName());
        assertTrue(elapsedMs < 30_000, "legacy xls parsing took " + elapsedMs + " ms");
        System.out.println("cityTaxiAuth.source parsed " + rows.size()
            + " rows in " + elapsedMs + " ms");
    }
    private byte[] workbookBytes(Workbook workbook, boolean validHeader) throws Exception {
        try (ByteArrayOutputStream output = new ByteArrayOutputStream()) {
            Sheet sheet = workbook.createSheet();
            Row header = sheet.createRow(0);
            header.createCell(0).setCellValue(validHeader ? HEADER_PLATE : "other");
            Row row = sheet.createRow(1);
            row.createCell(0).setCellValue(PLATE);
            row.createCell(1).setCellValue(VEHICLE_TYPE);
            row.createCell(2).setCellValue(BIZ_TYPE);
            row.createCell(3).setCellValue(OWNER);
            row.createCell(4).setCellValue(LICENSE);
            row.createCell(7).setCellValue(FUEL);
            row.createCell(8).setCellValue(ARCHIVE);
            row.createCell(9).setCellValue(ROAD_CERT);
            row.createCell(17).setCellValue(OPERATOR);
            row.createCell(18).setCellValue(ADDRESS);
            row.createCell(19).setCellValue(OP_STATUS);
            row.createCell(20).setCellValue(CERT_STATUS);
            workbook.write(output);
            return output.toByteArray();
        } finally {
            workbook.close();
        }
    }
    private void assertFields(CityTaxiAuth row) {
        assertNotNull(row);
        assertEquals(PLATE, row.getPlateNo());
        assertEquals(VEHICLE_TYPE, row.getVehicleType());
        assertEquals(BIZ_TYPE, row.getBizType());
        assertEquals(OWNER, row.getOwnerName());
        assertEquals(LICENSE, row.getLicenseNo());
        assertEquals(FUEL, row.getFuelType());
        assertEquals(ARCHIVE, row.getArchiveNo());
        assertEquals(ROAD_CERT, row.getRoadCertNo());
        assertEquals(OPERATOR, row.getOperatorName());
        assertEquals(ADDRESS, row.getOperatorAddr());
        assertEquals(OP_STATUS, row.getOpStatus());
        assertEquals(CERT_STATUS, row.getCertStatus());
    }
}
traffic-audit-web/src/views/DataImport.vue
@@ -49,7 +49,7 @@
                    <span class="tpl-name">模板:{{ templateName }}</span>
                    <el-link v-if="templateUrl" type="primary" icon="el-icon-download" :underline="false"
                             @click="downloadTemplate">下载模板</el-link>
                    <span v-if="importType === 'cityTaxiAuth'" class="slow-tip">该类型约 4 万+ 行,预计耗时 5 分钟左右</span>
                    <span v-if="importType === 'cityTaxiAuth'" class="slow-tip">该类型约 4 万+ 行,预计耗时 1 分钟以内</span>
                  </div>
                </div>
                <div v-if="isCityDirType(moduleSel[g.key])" class="module-file">