# excel导入到doris **Repository Path**: lightcool820/doris_load_csv ## Basic Information - **Project Name**: excel导入到doris - **Description**: excel导入到doris - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-05-13 - **Last Updated**: 2026-05-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 存量发票 Excel → Doris(Spring Boot) ## 功能 - **浏览器页面**:启动后访问 `http://localhost:8080/?campanyCode=公司1,公司2`(参数名固定为 `campanyCode`,英文逗号分隔),选择 `.xlsx` 后上传;页面将 `campanyCode` 作为 `companyCodes` 提交到接口。 - `POST /api/v1/invoice-import`(`multipart/form-data`) - `companyCodes`:英文逗号分隔 - `file`:与 `docs/存量发票导入模版.xlsx` 表头一致的 `.xlsx` - 可选:`importerEmployeeId`、`importerName` - 流程:校验表头 → 解析数据 → 生成 UTF-8 CSV(默认写入项目下 **`csv-export/`** 目录,与 `docs/` 同级)→ **DELETE**(按 `company_codes`)→ **Stream Load**;接口返回 `savedCsvPath` 为本次 CSV 绝对路径。 ## 运行 需 **JDK 8+**(当前工程使用 Spring Boot **2.7.x** 以兼容 JDK 8;若使用 JDK 17+ 可自行升级到 Spring Boot 3)。 需本机可访问 Doris: - **Stream Load**:通过本机 **`curl`** 子进程请求 FE(默认 `doris.stream-load.use-shell: true`,即 Windows 下 `cmd /c`、Linux 下 `/bin/sh -c` 执行与脚本等价的单行命令;遇 cmd 转义问题可改为 `use-shell: false` 使用无 shell 的 curl 参数列表)。可用环境变量 **`CURL_BIN`** 指定 curl 路径。 - **DELETE(JDBC)**:`doris.query.host` + `doris.query.port`(默认 **9030**,MySQL 协议) ```bash cd d:\doris_load_csv mvn spring-boot:run ``` 口令建议用环境变量覆盖(勿提交到公共仓库): ```bash set DORIS_PASSWORD=你的密码 mvn spring-boot:run ``` ## 调用示例(curl) ```bash curl -s -X POST "http://localhost:8080/api/v1/invoice-import" ^ -F "companyCodes=9898989,9898990" ^ -F "file=@docs/存量发票导入模版.xlsx" ^ -F "importerEmployeeId=E001" ^ -F "importerName=张三" ``` ## 配置项 见 `src/main/resources/application.yml`(`doris.*`、`import.max-rows`、`import.csv-output-dir`)。