Browse Source

feat(eds): 新增电子数据包上传与进度管理,表格上传恢复 MD5 去重

- 数据页「数据上传」弹窗选择电子数据/表格数据;新增电子数据上传页(左上传 + 右进度表,2 秒静默轮询)
- eds_material_process 进度表:上传中/完成/失败、解析中/失败/完成状态,5 路并发解析,超出排队
- 退出上传页校验进行中任务并提示,退出清空进度表
- file_info 新增 eds 类型:列表隐藏导入数/治理状态/清洗方式,失败展示提取原因,隐藏重新清洗
- EdsExtra 增加进度回调、materialType 回填,失败清理解压产物
- csv/xls/xlsx 恢复 MD5 重复校验并明确提示,其他类型不校验
- 删除失效的 DirTreeRegistryTest
cc 3 weeks ago
parent
commit
7c523b5ca8
21 changed files with 2412 additions and 191 deletions
  1. 72 0
      ai-electron/frontend/src/case/api/eds/edsApi.ts
  2. 8 3
      ai-electron/frontend/src/case/api/govern/governApi.ts
  3. 51 39
      ai-electron/frontend/src/case/types/enum.ts
  4. 1088 0
      ai-electron/frontend/src/case/views/data/edsUpload.vue
  5. 54 26
      ai-electron/frontend/src/case/views/data/importList.vue
  6. 140 4
      ai-electron/frontend/src/case/views/data/index.vue
  7. 10 3
      ai-electron/frontend/src/case/views/data/upload.vue
  8. 2 0
      ai-electron/frontend/src/core/enums/pageEnum.ts
  9. 16 0
      ai-electron/frontend/src/core/router/routes/index.ts
  10. 8 0
      ai-server/src/main/java/com/zsjz/ai/common/constants/FileTypeConstants.java
  11. 16 1
      ai-server/src/main/java/com/zsjz/ai/common/enums/FileSheetStateEnum.java
  12. 1 1
      ai-server/src/main/java/com/zsjz/ai/module/dm/controller/DmController.java
  13. 107 13
      ai-server/src/main/java/com/zsjz/ai/module/dm/service/DmService.java
  14. 64 0
      ai-server/src/main/java/com/zsjz/ai/module/eds/controller/EdsMaterialProcessController.java
  15. 89 0
      ai-server/src/main/java/com/zsjz/ai/module/eds/mapper/EdsMaterialProcessMapper.java
  16. 108 0
      ai-server/src/main/java/com/zsjz/ai/module/eds/po/EdsMaterialProcess.java
  17. 363 0
      ai-server/src/main/java/com/zsjz/ai/module/eds/service/EdsMaterialProcessService.java
  18. 144 23
      ai-server/src/main/java/com/zsjz/ai/module/eds/xml/EdsExtra.java
  19. 21 3
      ai-server/src/main/java/com/zsjz/ai/module/eds/xml/EdsExtraFile.java
  20. 50 0
      ai-server/src/main/java/com/zsjz/ai/module/eds/xml/EdsProgressListener.java
  21. 0 75
      ai-server/src/test/java/com/zsjz/ai/module/eds/duckdb/DirTreeRegistryTest.java

+ 72 - 0
ai-electron/frontend/src/case/api/eds/edsApi.ts

@@ -0,0 +1,72 @@
+import { defHttp } from '@/core/utils/http/axios';
+import type { CreateAxiosOptions } from '@/core/utils/http/axios/axiosTransform';
+import { useGlobSetting } from '@/core/hooks/setting';
+
+const { ctxPath, adminPath } = useGlobSetting();
+
+/** 上传接口返回的轻量 Result 形状(uploadFile 不自动解包,业务数据在 res.data.data) */
+interface UploadResult<T> {
+  code?: number;
+  message?: string;
+  data?: T | null;
+}
+
+/** 电子数据包进度记录(案件 DuckDB:eds_material_process) */
+export interface EdsMaterialProcessRow {
+  id?: ApiId | number | null;
+  /** 原始上传文件名 */
+  fileName?: ApiText | null;
+  /** 采集编号(解析成功后回填) */
+  cti?: ApiText | null;
+  /** 检材类型 */
+  materialType?: ApiText | null;
+  /** 压缩包落盘路径 */
+  filePath?: ApiText | null;
+  /** 压缩包大小(字节) */
+  size?: ApiCount | null;
+  /** 1 上传中 / 2 上传完成 / 3 上传失败 / 4 解析中 / 5 解析失败 / 6 解析完成 */
+  status?: ApiCount | null;
+  /** 提取进度 0-100 */
+  progress?: ApiCount | null;
+  /** 失败原因(成功时为空) */
+  errorMessage?: ApiText | null;
+  /** 上传人 */
+  createName?: ApiText | null;
+}
+
+/**
+ * 上传一个电子数据包(zip)。
+ *
+ * <p>后端落盘登记后立即返回,解压与入库在后台进行;进度与错误信息由
+ * {@link edsProcessList} 轮询获取。注意 uploadFile 不走统一解包,
+ * 业务数据在 `res.data.data`。</p>
+ */
+export const uploadEdsPackage = (file: File, onProgress?: (percent: number) => void) =>
+  defHttp.uploadFile<UploadResult<EdsMaterialProcessRow>>(
+    {
+      url: ctxPath + adminPath + '/eds/upload',
+      // 业务错误由页面按 res.data.code/message 提示,避免全局弹窗 + 页面提示重复
+      requestOptions: { errorMessageMode: 'none' },
+      onUploadProgress: (progressEvent: any) => {
+        if (!onProgress || !progressEvent.total) return;
+        onProgress(Math.round((progressEvent.loaded * 100) / progressEvent.total));
+      },
+    } as CreateAxiosOptions,
+    {
+      name: 'file',
+      file,
+      filename: file.name,
+    },
+  );
+
+/**
+ * 当前案件的电子数据包进度列表(最新在前)。
+ * 电子数据上传页每 2 秒轮询一次,离开页面即停止。
+ */
+export const edsProcessList = () => defHttp.get<EdsMaterialProcessRow[]>({ url: adminPath + '/eds/list' });
+
+/**
+ * 清空当前案件的电子数据包进度表(退出电子数据上传页时调用)。
+ * 完成 / 失败记录一并清空;已提交的后台解析任务不会被中断。
+ */
+export const clearEdsProcess = () => defHttp.postJson<void>({ url: adminPath + '/eds/clear' });

+ 8 - 3
ai-electron/frontend/src/case/api/govern/governApi.ts

@@ -1,4 +1,5 @@
 import { defHttp } from '@/core/utils/http/axios';
+import type { CreateAxiosOptions } from '@/core/utils/http/axios/axiosTransform';
 import { useGlobSetting } from '@/core/hooks/setting';
 import type { Result } from '@/types/axios';
 import type { FileInfo } from '@/types/api';
@@ -220,22 +221,26 @@ export const preFile = (data: PrepareProcessFileDTO) =>
  * 1. 不会自动补齐 urlPrefix/apiUrl,必须像其他上传接口一样手动拼接 ctxPath(如 /js)+ adminPath(如 /a);
  * 2. 不回自动解包,返回原始 AxiosResponse,业务数据在 res.data.data。
  *
- * 后端返回单个文件节点 FileInfo(文件根内嵌 children sheet 列表);重复文件或无结果时 data 为 null。
+ * 后端返回单个文件节点 FileInfo(文件根内嵌 children sheet 列表);解析无结果时 data 为 null;
+ * MD5 重复的表格文件(csv / xls / xlsx)返回业务错误「文件已存在(MD5 重复),已跳过」。
  */
 export const preFileUpload = (
   file: File,
   onProgress?: (percent: number) => void,
   data?: { batchId?: string | number; reClean?: number },
 ) => {
-  return defHttp.uploadFile<Result<FileInfo>>(
+  return defHttp.uploadFile<Result>(
     {
       url: ctxPath + adminPath + '/dm/preFileUpload',
+      // 业务错误(如 MD5 重复)由调用方按 res.data.code/message 自行提示,
+      // 关闭全局错误弹窗,避免同一次失败弹两条提示
+      requestOptions: { errorMessageMode: 'none' },
       onUploadProgress: (progressEvent: any) => {
         if (!onProgress || !progressEvent.total) return;
         const percent = Math.round((progressEvent.loaded * 100) / progressEvent.total);
         onProgress(percent);
       },
-    },
+    } as CreateAxiosOptions,
     {
       name: 'file',
       file,

+ 51 - 39
ai-electron/frontend/src/case/types/enum.ts

@@ -1,40 +1,52 @@
 export enum FileStatusEnum {
-    /**
-     * 文件读取失败状态。
-     */
-    FILE_READ_FAIL = "文件读取失败",
-    /**
-     * 文件未解析(非表格格式,或表格格式读取失败)。
-     * 文档 / 图片 / 音视频保留原件,可下载、可在对话中 @ 引用。
-     */
-    FILE_UNSUPPORTED_FAIL = "未解析",
-    /**
-     * 文件读取完成状态,
-     */
-    FILE_READ_COMPLETE = "文件读取完成",
-    /**
-     * 加密文件状态。
-     */
-    FILE_ENCRYPTION = "加密文件",
-    /**
-     * 工作表读取失败状态。
-     */
-    SHEET_READ_FAIL = "工作表读取失败",
-    /**
-     * 工作表模板匹配失败状态。也代表这 工作表读取完成
-     */
-    SHEET_TEMPLATE_MATCHED_FAIL = "模板匹配失败",
-    /**
-     * 工作表模板匹配成功状态。也代表这 工作表读取完成
-     */
-    SHEET_TEMPLATE_MATCHED_SUCCESS = "模板匹配成功",
-    /**
-     * 表示在清洗时不需要 清洗此表
-     */
-    SHEET_REMOVE = "移除清洗",
-    /**
-     * 文件清洗完成状态。
-     */
-    FILE_CLEAN_COMPLETE = "清洗完成",
-    FILE_GOVERN_COMPLETE = "已治理",
-}
+  /**
+   * 文件读取失败状态。
+   */
+  FILE_READ_FAIL = '文件读取失败',
+  /**
+   * 文件未解析(非表格格式,或表格格式读取失败)。
+   * 文档 / 图片 / 音视频保留原件,可下载、可在对话中 @ 引用。
+   */
+  FILE_UNSUPPORTED_FAIL = '未解析',
+  /**
+   * 文件读取完成状态,
+   */
+  FILE_READ_COMPLETE = '文件读取完成',
+  /**
+   * 加密文件状态。
+   */
+  FILE_ENCRYPTION = '加密文件',
+  /**
+   * 工作表读取失败状态。
+   */
+  SHEET_READ_FAIL = '工作表读取失败',
+  /**
+   * 工作表模板匹配失败状态。也代表这 工作表读取完成
+   */
+  SHEET_TEMPLATE_MATCHED_FAIL = '模板匹配失败',
+  /**
+   * 工作表模板匹配成功状态。也代表这 工作表读取完成
+   */
+  SHEET_TEMPLATE_MATCHED_SUCCESS = '模板匹配成功',
+  /**
+   * 表示在清洗时不需要 清洗此表
+   */
+  SHEET_REMOVE = '移除清洗',
+  /**
+   * 文件清洗完成状态。
+   */
+  FILE_CLEAN_COMPLETE = '清洗完成',
+  FILE_GOVERN_COMPLETE = '已治理',
+  /**
+   * 电子数据包(zip)提取中。
+   */
+  FILE_EDS_EXTRACTING = '电子数据包提取中',
+  /**
+   * 电子数据包提取完成。
+   */
+  FILE_EDS_COMPLETE = '电子数据包提取完成',
+  /**
+   * 电子数据包提取失败(导入文件列表对电子数据包不展示治理状态列内容)。
+   */
+  FILE_EDS_FAIL = '电子数据包提取失败',
+}

+ 1088 - 0
ai-electron/frontend/src/case/views/data/edsUpload.vue

@@ -0,0 +1,1088 @@
+<template>
+  <div :class="prefixCls" class="case-eds-upload-page">
+    <!-- 清洗流程公共顶栏:品牌 / 案件 / 模板库 / 下载管理 / 窗口控制 -->
+    <CaseFlowTopBar />
+
+    <div class="page-body">
+      <div class="page-header">
+        <div class="page-header__left">
+          <Tooltip title="返回" placement="bottom" :mouseEnterDelay="0.5">
+            <button type="button" class="back-btn" aria-label="返回" @click="handleBack">
+              <LeftOutlined />
+            </button>
+          </Tooltip>
+          <span class="page-header__divider" aria-hidden="true"></span>
+          <div class="page-title-block">
+            <div class="page-title">电子数据上传</div>
+          </div>
+        </div>
+      </div>
+
+      <div class="upload-layout">
+        <aside class="left-panel">
+          <!-- 只能选 zip:电子数据包统一格式,表格文件请走「表格数据」入口 -->
+          <input
+            ref="fileInputRef"
+            type="file"
+            multiple
+            accept=".zip"
+            style="display: none"
+            @change="handleFileInputChange"
+          />
+
+          <div
+            class="upload-dropzone"
+            :class="{ 'is-dragover': dragOver }"
+            @dragover.prevent="handleDragOver"
+            @dragleave="handleDragLeave"
+            @drop.prevent="handleDrop"
+          >
+            <div class="upload-dragger-content">
+              <div class="upload-dragger-icon">
+                <Icon icon="i-ant-design:file-zip-outlined" :size="15" />
+              </div>
+              <div class="upload-dragger-title">拖拽电子数据包到这里,或点击选择文件</div>
+              <Button type="primary" class="upload-action-btn" :disabled="isUploading" @click="handleTriggerFileSelect">
+                选择文件
+              </Button>
+            </div>
+          </div>
+
+          <!-- 已选文件列表(加入后自动上传,成功即移除) -->
+          <div v-if="selectedFiles.length" class="upload-file-list">
+            <div class="upload-file-list__header">
+              <span>待上传 {{ selectedFiles.length }} 个文件</span>
+              <Button type="link" size="small" :disabled="isUploading" @click="clearSelectedFiles"> 清空 </Button>
+            </div>
+            <div class="upload-file-list__body">
+              <div
+                v-for="file in selectedFiles"
+                :key="file.name + file.size + file.lastModified"
+                class="upload-file-item"
+              >
+                <div class="upload-file-item__info">
+                  <span class="upload-file-item__name">{{ file.name }}</span>
+                  <span class="upload-file-item__size">{{ formatFileSize(file.size) }}</span>
+                </div>
+                <div class="upload-file-item__status">
+                  <template v-if="uploadStatuses.get(file) === 'error'">
+                    <span class="upload-file-item__error">✗</span>
+                  </template>
+                  <template v-else-if="uploadStatuses.get(file) === 'uploading'">
+                    <span class="upload-file-item__progress-text">{{ uploadProgressMap.get(file) || 0 }}%</span>
+                  </template>
+                  <template v-else>
+                    <span class="upload-file-item__pending">待上传</span>
+                  </template>
+                </div>
+                <button
+                  v-if="!isUploading && (uploadStatuses.get(file) || 'pending') === 'pending'"
+                  type="button"
+                  class="upload-file-item__remove"
+                  aria-label="移除文件"
+                  @click="removeSelectedFile(file)"
+                >
+                  <CloseOutlined />
+                </button>
+              </div>
+            </div>
+            <!-- 整体进度 -->
+            <div v-if="isUploading" class="upload-overall-progress">
+              <div class="upload-overall-progress__bar">
+                <div class="upload-overall-progress__fill" :style="{ width: overallProgress + '%' }"></div>
+              </div>
+              <span class="upload-overall-progress__text">总进度 {{ overallProgress }}%</span>
+            </div>
+          </div>
+          <div v-else class="upload-file-list upload-file-list--empty">
+            <div class="upload-empty">暂无待上传文件,选择 zip 后将自动上传并开始解压</div>
+          </div>
+        </aside>
+
+        <section class="right-panel">
+          <div class="panel-header">
+            <div>
+              <div class="panel-title">数据包列表(实时)</div>
+              <div class="panel-desc">上传完成后在右侧查看解压提取进度;失败原因显示在「消息」列</div>
+            </div>
+            <div class="panel-header__actions">
+              <Button size="small" :loading="listLoading" @click="handleManualRefresh">
+                <template #icon><ReloadOutlined /></template>
+                刷新
+              </Button>
+            </div>
+            <div class="panel-stats">共 {{ rows.length }} 个数据包</div>
+          </div>
+          <div class="table-wrapper">
+            <Table
+              class="eds-process-table"
+              :columns="tableColumns"
+              :data-source="rows"
+              :loading="initialLoading"
+              :pagination="false"
+              row-key="id"
+              size="small"
+              :scroll="{ x: 950 }"
+              :locale="{ emptyText: '暂无电子数据包,先在左侧上传 zip' }"
+            />
+          </div>
+        </section>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script lang="ts" setup name="ViewsDataEdsUpload">
+  import { computed, h, onBeforeUnmount, onMounted, ref } from 'vue';
+  import { onBeforeRouteLeave } from 'vue-router';
+  import { CloseOutlined, LeftOutlined, ReloadOutlined } from '@ant-design/icons-vue';
+  import { Button, Modal, Progress, Table, Tooltip, type TableColumnsType } from 'ant-design-vue';
+  import { Icon } from '@/core/components/Icon';
+  import { useDesign } from '@/core/hooks/web/useDesign';
+  import { useGo } from '@/core/hooks/web/usePage';
+  import { PageEnum } from '@/core/enums/pageEnum';
+  import { useMessage } from '@/core/hooks/web/useMessage';
+  import { useEmitter } from '@/core/store/modules/case';
+  import { edsProcessList, uploadEdsPackage, clearEdsProcess, type EdsMaterialProcessRow } from '@/case/api/eds/edsApi';
+  import CaseFlowTopBar from './components/CaseFlowTopBar.vue';
+
+  const { prefixCls } = useDesign('case-eds-upload');
+  const go = useGo();
+  const emitter = useEmitter();
+  const { createMessage } = useMessage();
+  const CASE_DATA_REFRESH_EVENT = 'case-data:refresh';
+
+  /** 进度轮询间隔:页面存活期间每 2 秒刷新一次,离开页面立即停止 */
+  const POLL_INTERVAL_MS = 2000;
+  /** 后端 status 口径:1 上传中 / 2 上传完成 / 3 上传失败 / 4 解析中 / 5 解析失败 / 6 解析完成 */
+  const STATUS_UPLOADING = 1;
+  const STATUS_UPLOADED = 2;
+  const STATUS_UPLOAD_FAILED = 3;
+  const STATUS_PARSING = 4;
+  const STATUS_PARSE_FAILED = 5;
+  const STATUS_PARSE_SUCCESS = 6;
+  /** 进行中的任务:上传中 / 排队等待解析 / 解析中 */
+  const ACTIVE_STATUSES = new Set([STATUS_UPLOADING, STATUS_UPLOADED, STATUS_PARSING]);
+
+  const fileInputRef = ref<HTMLInputElement | null>(null);
+  const selectedFiles = ref<File[]>([]);
+  const uploadProgressMap = ref<Map<File, number>>(new Map());
+  const uploadStatuses = ref<Map<File, 'pending' | 'uploading' | 'done' | 'error'>>(new Map());
+  const isUploading = ref(false);
+  const overallProgress = ref(0);
+  const dragOver = ref(false);
+
+  const rows = ref<EdsMaterialProcessRow[]>([]);
+  /** 手动点「刷新」时才显示的 loading(定时轮询不能让它每 2 秒闪一次) */
+  const listLoading = ref(false);
+  /** 首次加载:只在第一帧展示表格 loading,之后轮询完全静默 */
+  const initialLoading = ref(true);
+  let pollTimer: ReturnType<typeof setInterval> | undefined;
+  let listRequesting = false;
+
+  const formatFileSize = (bytes?: number | null) => {
+    if (bytes == null || bytes === 0) return '0 B';
+    const k = 1024;
+    const sizes = ['B', 'KB', 'MB', 'GB'];
+    const i = Math.floor(Math.log(bytes) / Math.log(k));
+    return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
+  };
+
+  const progressStatusOf = (status?: number | null) => {
+    const value = Number(status);
+    if (value === STATUS_UPLOAD_FAILED || value === STATUS_PARSE_FAILED) return 'exception';
+    if (value === STATUS_PARSE_SUCCESS) return 'success';
+    if (value === STATUS_PARSING) return 'active';
+    return 'normal';
+  };
+
+  const tableColumns: TableColumnsType<EdsMaterialProcessRow> = [
+    {
+      title: '序号',
+      key: 'index',
+      width: 70,
+      align: 'center',
+      customRender: ({ index }: { index: number }) => h('span', { class: 'cell-index' }, String(index + 1)),
+    },
+    {
+      title: '文件名',
+      key: 'fileName',
+      width: 300,
+      // 关闭 antd 自动加的 title(浏览器原生提示),统一用 Tooltip
+      ellipsis: { showTitle: false },
+      customRender: ({ record }: { record: EdsMaterialProcessRow }) => {
+        const name = record.fileName || '未命名数据包';
+        return h(
+          Tooltip,
+          { title: name, placement: 'topLeft', mouseEnterDelay: 0.3, overlayClassName: 'eds-cell-tooltip' },
+          () => h('span', { class: 'cell-file-name' }, name),
+        );
+      },
+    },
+    {
+      title: '上传进度条',
+      key: 'progress',
+      width: 260,
+      customRender: ({ record }: { record: EdsMaterialProcessRow }) => {
+        const percent = Math.min(100, Math.max(0, Number(record.progress ?? 0)));
+        return h(Progress, {
+          percent,
+          size: 'small',
+          strokeWidth: 8,
+          status: progressStatusOf(record.status),
+        });
+      },
+    },
+    {
+      title: '消息',
+      key: 'message',
+      width: 320,
+      // 关闭 antd 自动加的 title(浏览器原生提示),统一用 Tooltip
+      ellipsis: { showTitle: false },
+      customRender: ({ record }: { record: EdsMaterialProcessRow }) => {
+        const message = String(record.errorMessage ?? '').trim();
+        if (!message) {
+          return h('span', { class: 'cell-message' }, '');
+        }
+        return h(
+          Tooltip,
+          { title: message, placement: 'topLeft', mouseEnterDelay: 0.3, overlayClassName: 'eds-cell-tooltip' },
+          () => h('span', { class: 'cell-message is-error' }, message),
+        );
+      },
+    },
+  ];
+
+  // ------------------------------------------------------------------
+  // 列表轮询
+  // ------------------------------------------------------------------
+
+  /**
+   * 行数据签名:id + 会变化的展示字段。
+   * 定时轮询大多时候数据没变,签名一致就不替换数组,表格不重渲染,界面无感知。
+   */
+  const rowsSignature = (list: EdsMaterialProcessRow[]) =>
+    list
+      .map(
+        (row) =>
+          `${row.id ?? ''}:${row.status ?? ''}:${row.progress ?? ''}:${row.cti ?? ''}:${
+            row.materialType ?? ''
+          }:${row.errorMessage ?? ''}`,
+      )
+      .join('|');
+
+  /**
+   * 拉取数据包列表。
+   *
+   * @param silent true(默认)= 定时轮询:不显示任何 loading,且数据未变化时不动表格;
+   *               false = 用户手动点刷新:按钮转圈并强制替换
+   */
+  const refreshRows = async (silent = true) => {
+    if (listRequesting) return;
+    listRequesting = true;
+    if (!silent) listLoading.value = true;
+    try {
+      const list = await edsProcessList();
+      const next = Array.isArray(list) ? list : [];
+      if (!silent || rowsSignature(next) !== rowsSignature(rows.value)) {
+        rows.value = next;
+      }
+    } catch (error: any) {
+      // 轮询失败不打断页面,也不每 2 秒弹一次提示;控制台留痕即可
+      console.warn('[eds-upload] 刷新电子数据包列表失败', error?.message || error);
+    } finally {
+      listRequesting = false;
+      initialLoading.value = false;
+      if (!silent) listLoading.value = false;
+    }
+  };
+
+  /** 手动刷新入口:只有用户主动点击时才给 loading 反馈 */
+  const handleManualRefresh = () => {
+    void refreshRows(false);
+  };
+
+  const stopPolling = () => {
+    if (pollTimer !== undefined) {
+      clearInterval(pollTimer);
+      pollTimer = undefined;
+    }
+  };
+
+  // ------------------------------------------------------------------
+  // 上传
+  // ------------------------------------------------------------------
+
+  const handleDragOver = () => {
+    dragOver.value = true;
+  };
+
+  const handleDragLeave = () => {
+    dragOver.value = false;
+  };
+
+  const handleTriggerFileSelect = () => {
+    fileInputRef.value?.click();
+  };
+
+  const clearSelectedFiles = () => {
+    selectedFiles.value = [];
+    uploadProgressMap.value = new Map();
+    uploadStatuses.value = new Map();
+    overallProgress.value = 0;
+  };
+
+  const removeSelectedFile = (target: File) => {
+    if (isUploading.value) return;
+    const index = selectedFiles.value.indexOf(target);
+    if (index === -1) return;
+    if ((uploadStatuses.value.get(target) || 'pending') !== 'pending') return;
+    selectedFiles.value.splice(index, 1);
+    uploadProgressMap.value.delete(target);
+    uploadStatuses.value.delete(target);
+  };
+
+  /**
+   * 加入待上传列表并自动开始上传;只收 zip,其它格式直接跳过并提示。
+   */
+  const addFiles = (files: File[]) => {
+    const zips = files.filter((file) => (file.name.split('.').pop() || '').toLowerCase() === 'zip');
+    const skipped = files.length - zips.length;
+    if (skipped > 0) {
+      createMessage.warning(`${skipped} 个文件不是 zip,已跳过`);
+    }
+    if (!zips.length) return;
+    selectedFiles.value = [...selectedFiles.value, ...zips];
+    void startUpload();
+  };
+
+  const handleFileInputChange = (event: Event) => {
+    const target = event.target as HTMLInputElement;
+    if (!target.files?.length) return;
+    addFiles(Array.from(target.files));
+    target.value = '';
+  };
+
+  const handleDrop = (event: DragEvent) => {
+    dragOver.value = false;
+    const files = Array.from(event.dataTransfer?.files || []);
+    if (files.length) addFiles(files);
+  };
+
+  /**
+   * 自动上传队列:按序上传,成功后从待上传列表移除并刷新右侧表格。
+   * 上传本身只负责落盘与登记,解压提取由后端后台执行,进度通过轮询获取。
+   */
+  const startUpload = async () => {
+    if (isUploading.value) return;
+    isUploading.value = true;
+
+    try {
+      while (true) {
+        const index = selectedFiles.value.findIndex(
+          (file) => (uploadStatuses.value.get(file) || 'pending') === 'pending',
+        );
+        if (index === -1) break;
+        const file = selectedFiles.value[index];
+        uploadStatuses.value.set(file, 'uploading');
+
+        const onProgress = (percent: number) => {
+          uploadProgressMap.value.set(file, percent);
+          const list = selectedFiles.value;
+          const total = list.length || 1;
+          const sum = list.reduce((acc, item) => {
+            const status = uploadStatuses.value.get(item);
+            if (status === 'uploading') return acc + (uploadProgressMap.value.get(item) || 0);
+            if (status === 'error') return acc + 100;
+            return acc;
+          }, 0);
+          overallProgress.value = Math.round(sum / total);
+        };
+
+        try {
+          const res = await uploadEdsPackage(file, onProgress);
+          // errorMessageMode=none 时网络异常会被响应拦截器 resolve 成空值,这里兜底
+          if (!res?.data) {
+            throw new Error('网络异常或服务不可用');
+          }
+          if (Number(res.data.code) !== 200) {
+            throw new Error(res.data.message || '上传失败');
+          }
+          uploadProgressMap.value.delete(file);
+          uploadStatuses.value.delete(file);
+          const currentIndex = selectedFiles.value.indexOf(file);
+          if (currentIndex !== -1) selectedFiles.value.splice(currentIndex, 1);
+          onProgress(100);
+          // 上传成功即刷新一次,新记录立刻出现在右侧(后台进度继续轮询)
+          void refreshRows();
+        } catch (error: any) {
+          uploadStatuses.value.set(file, 'error');
+          uploadProgressMap.value.set(file, 100);
+          createMessage.error(`「${file.name}」上传失败:${error?.message || '未知错误'}`);
+        }
+      }
+      overallProgress.value = 100;
+    } finally {
+      isUploading.value = false;
+    }
+  };
+
+  // ------------------------------------------------------------------
+  // 页面出口
+  // ------------------------------------------------------------------
+
+  /** 进行中的数据包数量(上传中 / 排队等待解析 / 解析中) */
+  const activeTaskCount = computed(() => rows.value.filter((row) => ACTIVE_STATUSES.has(Number(row.status))).length);
+  /** 已确认退出:避免路由守卫重复弹确认框 */
+  const allowedToLeave = ref(false);
+
+  /** 退出前清空进度表(完成 / 失败记录也一并删除) */
+  const clearProcessRows = async () => {
+    stopPolling();
+    try {
+      await clearEdsProcess();
+      rows.value = [];
+    } catch (error: any) {
+      console.warn('[eds-upload] 清空电子数据进度表失败', error?.message || error);
+      createMessage.warning('清空电子数据进度记录失败,可稍后重试');
+    }
+  };
+
+  const leavePage = async () => {
+    allowedToLeave.value = true;
+    await clearProcessRows();
+    go(PageEnum.BASE_HOME, true);
+    emitter.emit(CASE_DATA_REFRESH_EVENT);
+  };
+
+  const handleBack = () => {
+    const active = activeTaskCount.value;
+    if (!isUploading.value && active === 0) {
+      void leavePage();
+      return;
+    }
+    const parts: string[] = [];
+    if (isUploading.value) parts.push('仍有文件正在上传');
+    if (active > 0) parts.push(`${active} 个数据包正在上传或解析`);
+    Modal.confirm({
+      title: '存在进行中的任务',
+      content: `${parts.join(',')}。退出将清空进度记录(已完成 / 失败记录也会删除),是否继续?`,
+      okText: '退出并清空',
+      okType: 'danger',
+      cancelText: '留在本页',
+      onOk: () => leavePage(),
+    });
+  };
+
+  onMounted(() => {
+    void refreshRows();
+    // 页面存活期间轮询;onBeforeUnmount / 路由离开时清除,避免后台空转请求
+    pollTimer = setInterval(() => void refreshRows(), POLL_INTERVAL_MS);
+  });
+
+  onBeforeUnmount(() => {
+    stopPolling();
+  });
+
+  /**
+   * 浏览器返回等非页面按钮的离开路径同样执行「提示 + 清空」,
+   * 保证每次退出电子数据上传页都会清空进度表。
+   */
+  onBeforeRouteLeave((_to, _from, next) => {
+    if (allowedToLeave.value) {
+      next();
+      return;
+    }
+    const active = activeTaskCount.value;
+    if (!isUploading.value && active === 0) {
+      allowedToLeave.value = true;
+      stopPolling();
+      void clearEdsProcess()
+        .catch((error: any) => console.warn('[eds-upload] 清空电子数据进度表失败', error?.message || error))
+        .finally(() => next());
+      return;
+    }
+    Modal.confirm({
+      title: '存在进行中的任务',
+      content: '当前仍有数据包正在上传或解析,退出将清空进度记录(已完成 / 失败记录也会删除),是否继续?',
+      okText: '退出并清空',
+      okType: 'danger',
+      cancelText: '留在本页',
+      onOk: () => {
+        allowedToLeave.value = true;
+        stopPolling();
+        void clearEdsProcess()
+          .catch((error: any) => console.warn('[eds-upload] 清空电子数据进度表失败', error?.message || error))
+          .finally(() => next());
+      },
+      onCancel: () => next(false),
+    });
+  });
+</script>
+
+<style lang="less">
+  @prefix-cls: ~'jeesite-case-eds-upload';
+
+  .@{prefix-cls}.case-eds-upload-page {
+    width: 100%;
+    height: 100vh;
+    background: #f0f2f5;
+    display: flex;
+    flex-direction: column;
+    box-sizing: border-box;
+    overflow: hidden;
+
+    .page-body {
+      flex: 1 1 auto;
+      min-height: 0;
+      padding: 8px 12px;
+      display: flex;
+      flex-direction: column;
+      gap: 8px;
+      box-sizing: border-box;
+      overflow: hidden;
+    }
+
+    .page-header {
+      flex-shrink: 0;
+      display: flex;
+      align-items: center;
+      justify-content: space-between;
+      gap: 16px;
+      padding: 10px 14px;
+      border: 1px solid #e2e8f0;
+      border-radius: 10px;
+      background: #fff;
+      box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
+    }
+
+    .page-header__left {
+      display: flex;
+      align-items: center;
+      gap: 12px;
+      min-width: 0;
+    }
+
+    .page-header__divider {
+      flex: 0 0 auto;
+      width: 1px;
+      height: 22px;
+      background: #e2e8f0;
+    }
+
+    .back-btn {
+      display: inline-flex;
+      align-items: center;
+      justify-content: center;
+      flex: 0 0 auto;
+      width: 32px;
+      height: 32px;
+      padding: 0;
+      border: 1px solid #e2e8f0;
+      border-radius: 8px;
+      background: #f8fafc;
+      color: #475569;
+      font-size: 14px;
+      line-height: 1;
+      cursor: pointer;
+      transition:
+        color 0.2s ease,
+        border-color 0.2s ease,
+        background-color 0.2s ease;
+
+      &:hover,
+      &:focus,
+      &:focus-visible {
+        color: #2563eb;
+        border-color: #bfdbfe;
+        background: #eff6ff;
+        outline: none;
+      }
+    }
+
+    .page-title-block {
+      min-width: 0;
+      overflow: hidden;
+    }
+
+    .page-title {
+      font-size: 16px;
+      line-height: 1.4;
+      font-weight: 600;
+      color: #111827;
+    }
+
+    .upload-layout {
+      flex: 1 1 auto;
+      min-height: 0;
+      display: flex;
+      gap: 8px;
+      align-items: stretch;
+    }
+
+    .left-panel,
+    .right-panel {
+      border: 1px solid #e2e8f0;
+      border-radius: 10px;
+      background: #fff;
+      overflow: hidden;
+    }
+
+    .left-panel {
+      flex: 0 0 460px;
+      display: flex;
+      flex-direction: column;
+      gap: 10px;
+      padding: 12px;
+      box-sizing: border-box;
+      overflow-y: auto;
+    }
+
+    .right-panel {
+      flex: 1 1 auto;
+      min-width: 0;
+      display: flex;
+      flex-direction: column;
+    }
+
+    .panel-header {
+      flex-shrink: 0;
+      display: flex;
+      align-items: center;
+      justify-content: space-between;
+      gap: 12px;
+      padding: 10px 14px 8px;
+      border-bottom: 1px solid #eef2f7;
+    }
+
+    .panel-title {
+      position: relative;
+      padding-left: 11px;
+      font-size: 15px;
+      font-weight: 600;
+      line-height: 22px;
+      color: #111827;
+
+      &::before {
+        content: '';
+        position: absolute;
+        top: 4px;
+        bottom: 4px;
+        left: 0;
+        width: 3px;
+        border-radius: 2px;
+        background: #2a50ec;
+      }
+    }
+
+    .panel-desc {
+      margin-top: 2px;
+      font-size: 12px;
+      color: #6b7280;
+      line-height: 1.5;
+    }
+
+    .panel-header__actions {
+      display: flex;
+      align-items: center;
+      gap: 8px;
+      margin-left: auto;
+    }
+
+    .panel-stats {
+      font-size: 12px;
+      color: #64748b;
+      white-space: nowrap;
+    }
+
+    .table-wrapper {
+      flex: 1 1 auto;
+      min-height: 0;
+      padding: 2px 10px 10px;
+      overflow: auto;
+    }
+
+    .eds-process-table {
+      .ant-table-thead > tr > th {
+        padding: 6px 8px;
+        font-size: 12px;
+        font-weight: 600;
+        color: #6b7280;
+        background: #fafbfc;
+        border-bottom: 1px solid #eef2f7;
+      }
+
+      .ant-table-tbody > tr > td {
+        padding: 8px;
+        font-size: 13px;
+        border-bottom: 1px solid #f6f8fa;
+      }
+
+      .ant-table-tbody > tr:hover > td {
+        background: #f8fafc;
+      }
+
+      .ant-progress {
+        margin: 0;
+        max-width: 220px;
+      }
+    }
+
+    .cell-index {
+      color: #64748b;
+      font-variant-numeric: tabular-nums;
+    }
+
+    .cell-file-name {
+      color: #1e293b;
+      font-size: 13px;
+    }
+
+    .cell-message {
+      color: #64748b;
+      font-size: 12px;
+
+      &.is-error {
+        color: #dc2626;
+      }
+    }
+
+    .upload-dropzone {
+      flex: 0 0 auto;
+      min-height: 180px;
+      border-radius: 8px;
+      /* 2px 虚线:1px 虚线在非整数像素位置时顶部边框可能不渲染 */
+      border: 2px dashed #cbd5e1;
+      background: #fafbfc;
+      transition: all 0.2s ease;
+      cursor: pointer;
+
+      &:hover,
+      &.is-dragover {
+        border-color: #3b82f6;
+      }
+    }
+
+    .upload-dragger-content {
+      display: flex;
+      flex-direction: column;
+      align-items: center;
+      justify-content: center;
+      gap: 6px;
+      min-height: 176px;
+      padding: 24px 0;
+      box-sizing: border-box;
+      color: #475569;
+    }
+
+    .upload-dragger-icon {
+      width: 28px;
+      height: 28px;
+      border-radius: 8px;
+      background: rgba(59, 130, 246, 0.1);
+      color: #2563eb;
+      display: flex;
+      align-items: center;
+      justify-content: center;
+      font-size: 14px;
+    }
+
+    .upload-dragger-title {
+      font-size: 13px;
+      font-weight: 600;
+      color: #334155;
+    }
+
+    .upload-action-btn {
+      margin-top: 2px;
+      height: 26px;
+      padding: 0 14px;
+      border-radius: 6px;
+    }
+
+    .upload-file-list {
+      flex: 1 1 auto;
+      min-height: 0;
+      display: flex;
+      flex-direction: column;
+      border: 1px solid #e2e8f0;
+      border-radius: 12px;
+      background: #ffffff;
+      overflow: hidden;
+
+      &__header {
+        flex-shrink: 0;
+        display: flex;
+        align-items: center;
+        justify-content: space-between;
+        padding: 8px 12px;
+        background: #f8fafc;
+        border-bottom: 1px solid #e2e8f0;
+        font-size: 13px;
+        color: #475569;
+        font-weight: 500;
+      }
+
+      &__body {
+        flex: 1 1 auto;
+        min-height: 0;
+        overflow-y: auto;
+        padding: 4px 0;
+      }
+
+      &--empty {
+        flex: 1 1 auto;
+        border-style: dashed;
+        background: #fafafa;
+      }
+    }
+
+    .upload-empty {
+      margin: auto;
+      padding: 24px 12px;
+      color: #9ca3af;
+      font-size: 13px;
+      text-align: center;
+    }
+
+    .upload-file-item {
+      display: flex;
+      align-items: center;
+      justify-content: space-between;
+      padding: 6px 12px;
+      gap: 12px;
+      transition: background 0.15s ease;
+
+      &:hover {
+        background: #f8fafc;
+      }
+
+      &__info {
+        display: flex;
+        align-items: center;
+        gap: 10px;
+        min-width: 0;
+        flex: 1;
+      }
+
+      &__name {
+        font-size: 13px;
+        color: #1e293b;
+        white-space: nowrap;
+        overflow: hidden;
+        text-overflow: ellipsis;
+        max-width: 300px;
+      }
+
+      &__size {
+        font-size: 12px;
+        color: #94a3b8;
+        flex-shrink: 0;
+      }
+
+      &__status {
+        flex-shrink: 0;
+        font-size: 12px;
+        min-width: 48px;
+        text-align: right;
+      }
+
+      &__remove {
+        flex-shrink: 0;
+        display: inline-flex;
+        align-items: center;
+        justify-content: center;
+        width: 22px;
+        height: 22px;
+        padding: 0;
+        border: none;
+        border-radius: 6px;
+        background: transparent;
+        color: #9ca3af;
+        font-size: 11px;
+        cursor: pointer;
+        transition:
+          background 0.15s ease,
+          color 0.15s ease;
+
+        &:hover {
+          background: #fef2f2;
+          color: #dc2626;
+        }
+      }
+
+      &__error {
+        color: #dc2626;
+        font-weight: 600;
+      }
+
+      &__progress-text {
+        color: #2563eb;
+        font-weight: 500;
+      }
+
+      &__pending {
+        color: #94a3b8;
+      }
+    }
+
+    .upload-overall-progress {
+      flex-shrink: 0;
+      display: flex;
+      align-items: center;
+      gap: 10px;
+      padding: 8px 12px;
+      border-top: 1px solid #e2e8f0;
+
+      &__bar {
+        flex: 1;
+        height: 5px;
+        border-radius: 3px;
+        background: #e2e8f0;
+        overflow: hidden;
+      }
+
+      &__fill {
+        height: 100%;
+        border-radius: 3px;
+        background: #2563eb;
+        transition: width 0.3s ease;
+      }
+
+      &__text {
+        font-size: 12px;
+        color: #475569;
+        font-weight: 500;
+        white-space: nowrap;
+      }
+    }
+
+    @media (max-width: 1080px) {
+      .upload-layout {
+        flex-direction: column;
+      }
+
+      .left-panel {
+        flex: 0 0 auto;
+        width: auto;
+      }
+    }
+  }
+
+  html[data-theme='dark'] {
+    .@{prefix-cls}.case-eds-upload-page {
+      background: #0f172a;
+
+      .page-header {
+        border-color: #1f2937;
+        background: #111827;
+        box-shadow: none;
+      }
+
+      .page-header__divider {
+        background: #1f2937;
+      }
+
+      .back-btn {
+        border-color: #334155;
+        background: #0f172a;
+        color: #cbd5e1;
+
+        &:hover,
+        &:focus,
+        &:focus-visible {
+          border-color: #3b82f6;
+          background: #1e293b;
+          color: #93c5fd;
+        }
+      }
+
+      .page-title,
+      .panel-title,
+      .upload-dragger-title,
+      .upload-file-item__name,
+      .cell-file-name {
+        color: #e5e7eb;
+      }
+
+      .panel-desc,
+      .panel-stats,
+      .upload-file-item__size,
+      .upload-file-item__pending,
+      .cell-index,
+      .cell-message {
+        color: #9ca3af;
+      }
+
+      .cell-message.is-error {
+        color: #f87171;
+      }
+
+      .left-panel,
+      .right-panel,
+      .upload-file-list {
+        background: #111827;
+        border-color: #1f2937;
+      }
+
+      .panel-header,
+      .upload-file-list__header,
+      .upload-overall-progress {
+        border-color: #1f2937;
+      }
+
+      .upload-file-list__header {
+        background: #0f172a;
+        color: #cbd5e1;
+      }
+
+      .upload-file-item:hover {
+        background: #1f2937;
+      }
+
+      .upload-dropzone {
+        border-color: #334155;
+        background: #0f172a;
+      }
+
+      .upload-overall-progress__bar {
+        background: #1f2937;
+      }
+
+      .eds-process-table {
+        :deep(.ant-table-thead > tr > th) {
+          background: #0f172a;
+          color: #94a3b8;
+          border-bottom-color: #1f2937;
+        }
+
+        :deep(.ant-table-tbody > tr > td) {
+          border-bottom-color: #111827;
+        }
+
+        :deep(.ant-table-tbody > tr:hover > td) {
+          background: #1f2937;
+        }
+
+        :deep(.ant-table-empty .ant-table-tbody > tr > td) {
+          color: #9ca3af;
+        }
+      }
+    }
+  }
+
+  /* 超长单元格 Tooltip:限宽 + 自动换行,替代浏览器原生 title 提示 */
+  .eds-cell-tooltip {
+    max-width: 520px;
+
+    .ant-tooltip-inner {
+      max-width: 520px;
+      max-height: 220px;
+      overflow-y: auto;
+      white-space: normal;
+      word-break: break-all;
+      line-height: 1.6;
+      font-size: 12px;
+    }
+  }
+</style>

+ 54 - 26
ai-electron/frontend/src/case/views/data/importList.vue

@@ -152,7 +152,13 @@
   };
 
   /** sheet 子行判断:文件行的 pid 为空/0,sheet 行的 pid 指向所属文件 */
-  const isSheetRecord = (record: Partial<FileInfo>) => !(record.pid == null || record.pid === '0' || record.pid === 0);
+  const isSheetRecord = (record: Partial<FileInfo>) => !(record.pid == null || String(record.pid) === '0');
+
+  /** 电子数据包:fileType=eds,不是表格文件,列表按专用口径展示(不显示导入数/治理状态/清洗方式) */
+  const isEdsPackage = (record?: Partial<FileInfo> | null) =>
+    String(record?.fileType ?? '')
+      .trim()
+      .toLowerCase() === 'eds';
 
   const fileStatusLabelMap = Object.entries(FileStatusEnum).reduce(
     (acc, [key, label]) => {
@@ -200,8 +206,10 @@
       key: 'successNum',
       width: 120,
       align: 'center',
-      customRender: ({ value }: { value?: string | number }) =>
-        h('span', { class: 'table-cell-center' }, getNumberText(value)),
+      customRender: ({ value, record }: { value?: string | number; record: FileInfo }) =>
+        isEdsPackage(record)
+          ? h('span', { class: 'table-cell-center' }, '—')
+          : h('span', { class: 'table-cell-center' }, getNumberText(value)),
     },
     {
       title: '导入失败',
@@ -210,14 +218,16 @@
       width: 120,
       align: 'center',
       customRender: ({ record }: { record: FileInfo }) =>
-        h(
-          'a',
-          {
-            class: 'fail-link',
-            onClick: (event: MouseEvent) => handleViewFailLog(event, record),
-          },
-          getNumberText(record.failNum),
-        ),
+        isEdsPackage(record)
+          ? h('span', { class: 'table-cell-center' }, '—')
+          : h(
+              'a',
+              {
+                class: 'fail-link',
+                onClick: (event: MouseEvent) => handleViewFailLog(event, record),
+              },
+              getNumberText(record.failNum),
+            ),
     },
     {
       title: '治理状态',
@@ -226,12 +236,15 @@
       width: 120,
       align: 'center',
       customRender: ({ value, record }: { value?: string | null; record?: any }) =>
-        // 未解析的文件悬停可看原因(已保留原件 / 仅登记、未保存源文件)
-        h(
-          'span',
-          { class: 'govern-status-text', title: record?.unsupportedReason || undefined },
-          getGovernStatusLabel(value),
-        ),
+        // 电子数据包不参与治理,不展示治理状态
+        isEdsPackage(record)
+          ? ''
+          : // 未解析的文件悬停可看原因(已保留原件 / 仅登记、未保存源文件)
+            h(
+              'span',
+              { class: 'govern-status-text', title: record?.unsupportedReason || undefined },
+              getGovernStatusLabel(value),
+            ),
     },
     {
       // 仅 sheet 行有意义:文件行留空。值由后端 getFiles 按 AI 任务记录回填
@@ -241,14 +254,15 @@
       width: 110,
       align: 'center',
       customRender: ({ record }: { record: FileInfo }) => {
-        if (record.pid == null || record.pid === '0' || record.pid === 0) return '';
+        if (isEdsPackage(record) || !isSheetRecord(record)) return '';
         const mode = getText(record.cleanMode, '');
         if (!mode) return h('span', { class: 'clean-mode-text is-empty' }, '-');
         return h('span', { class: ['clean-mode-text', mode === 'AI清洗' ? 'is-ai' : 'is-system'] }, mode);
       },
     },
     {
-      // 仅 sheet 行有意义:AI 匹配结果(模板名/新建表名)或失败原因
+      // sheet 行:AI 匹配结果(模板名/新建表名)或失败原因;
+      // 电子数据包行:提取失败原因,成功时留空(不显示 -)
       title: '备注',
       dataIndex: 'cleanNote',
       key: 'cleanNote',
@@ -256,7 +270,11 @@
       align: 'left',
       ellipsis: true,
       customRender: ({ record }: { record: FileInfo }) => {
-        if (record.pid == null || record.pid === '0' || record.pid === 0) return '';
+        if (isEdsPackage(record)) {
+          const error = getText(record.cleanNote, '');
+          return error ? h('span', { class: 'clean-note-text is-error' }, error) : '';
+        }
+        if (!isSheetRecord(record)) return '';
         const note = getText(record.cleanNote, '');
         if (!note) return h('span', { class: 'clean-note-text is-empty' }, '-');
         return h('span', { class: 'clean-note-text' }, note);
@@ -279,12 +297,17 @@
       // sheet 子节点只是文件的明细行:重新清洗/删除/下载都只针对文件行,子行不展示任何操作按钮
       if (isSheetRecord(record)) return [];
       return [
-        {
-          label: '重新清洗',
-          title: '重新清洗',
-          disabled: recleaningFileIds.value.includes(String(record.id ?? '').trim()),
-          onClick: handleRecognizeImport.bind(this, record),
-        },
+        // 电子数据包不走清洗流程,不提供「重新清洗」
+        ...(isEdsPackage(record)
+          ? []
+          : [
+              {
+                label: '重新清洗',
+                title: '重新清洗',
+                disabled: recleaningFileIds.value.includes(String(record.id ?? '').trim()),
+                onClick: handleRecognizeImport.bind(this, record),
+              },
+            ]),
         {
           label: '删除',
           title: '删除',
@@ -752,6 +775,11 @@
       color: #9ca3af;
     }
 
+    /* 电子数据包提取失败原因 */
+    .clean-note-text.is-error {
+      color: #dc2626;
+    }
+
     .ant-form {
       padding: 12px 16px 0;
       border: 1px solid #e5e7eb;

+ 140 - 4
ai-electron/frontend/src/case/views/data/index.vue

@@ -25,9 +25,7 @@
           </button>
         </div>
         <div class="header-actions">
-          <Button type="primary" class="header-actions__upload" @click="handleUploadNavigate('single')"
-            >清洗数据</Button
-          >
+          <Button type="primary" class="header-actions__upload" @click="cleanTypeModalOpen = true">数据上传</Button>
           <Button type="primary" class="header-actions__govern" @click="startCalcTask">数据治理</Button>
           <span class="header-actions__divider" aria-hidden="true"></span>
           <Button class="header-actions__config" @click="handleOpenGovernConfig">治理设置</Button>
@@ -202,6 +200,37 @@
       </div>
     </Modal>
 
+    <Modal
+      v-model:open="cleanTypeModalOpen"
+      title="选择数据类型"
+      :centered="true"
+      width="520px"
+      :footer="null"
+      wrapClassName="clean-type-modal"
+      @cancel="cleanTypeModalOpen = false"
+    >
+      <div class="clean-type-options">
+        <button type="button" class="clean-type-option" @click="handleChooseCleanType('eds')">
+          <span class="clean-type-option__icon is-eds">
+            <FileZipOutlined />
+          </span>
+          <span class="clean-type-option__body">
+            <span class="clean-type-option__title">电子数据</span>
+            <span class="clean-type-option__desc">上传 GAB 电子数据包(zip),自动解压并入库</span>
+          </span>
+        </button>
+        <button type="button" class="clean-type-option" @click="handleChooseCleanType('table')">
+          <span class="clean-type-option__icon">
+            <TableOutlined />
+          </span>
+          <span class="clean-type-option__body">
+            <span class="clean-type-option__title">表格数据</span>
+            <span class="clean-type-option__desc">上传 xls / xlsx / csv,走模板匹配与数据清洗</span>
+          </span>
+        </button>
+      </div>
+    </Modal>
+
     <GovernProgressModal
       :open="governProgressVisible"
       @update:open="handleGovernProgressOpenChange"
@@ -216,7 +245,7 @@
 <script lang="ts" setup name="ViewsDataIndex">
   import { computed, h, ref, nextTick, onActivated, onBeforeUnmount, onDeactivated, onMounted } from 'vue';
   import { Button, Select, Pagination, Input, Modal, Radio, Tooltip, Popover, Form, RadioGroup } from 'ant-design-vue';
-  import { ReloadOutlined } from '@ant-design/icons-vue';
+  import { ReloadOutlined, FileZipOutlined, TableOutlined } from '@ant-design/icons-vue';
   import { BasicTable, type BasicColumn } from '@/core/components/Table';
   import TableSetting from '@/core/components/Table/src/components/settings/index.vue';
   import { createTableContext } from '@/core/components/Table/src/hooks/useTableContext';
@@ -384,6 +413,17 @@
     go({ path: PageEnum.BASE_UPLOAD, query: { mode: mode || 'single' } });
   };
 
+  /** 「数据上传」入口先选数据类型:电子数据走 EDS 上传页,表格数据保持原上传/清洗流程 */
+  const cleanTypeModalOpen = ref(false);
+  const handleChooseCleanType = (type: 'eds' | 'table') => {
+    cleanTypeModalOpen.value = false;
+    if (type === 'eds') {
+      go(PageEnum.BASE_EDS_UPLOAD);
+      return;
+    }
+    handleUploadNavigate('single');
+  };
+
   const getRequestErrorMessage = (error: any, fallback = '操作失败') =>
     error?.response?.data?.message || error?.message || fallback;
   const normalizeGovernConfValue = (value?: string | null): GovernConfigValue =>
@@ -3325,4 +3365,100 @@
       padding-top: 8px;
     }
   }
+
+  /* 「清洗数据」数据类型选择:弹窗挂在 body 上,样式不能嵌在页面前缀内 */
+  .clean-type-modal {
+    .clean-type-options {
+      display: flex;
+      flex-direction: column;
+      gap: 12px;
+      padding: 4px 0 8px;
+    }
+
+    .clean-type-option {
+      display: flex;
+      align-items: center;
+      gap: 14px;
+      width: 100%;
+      padding: 16px;
+      border: 1px solid #e2e8f0;
+      border-radius: 10px;
+      background: #fff;
+      text-align: left;
+      cursor: pointer;
+      transition:
+        border-color 0.2s ease,
+        background-color 0.2s ease,
+        box-shadow 0.2s ease;
+
+      &:hover,
+      &:focus-visible {
+        border-color: #93c5fd;
+        background: #f8fbff;
+        box-shadow: 0 4px 14px rgba(37, 99, 235, 0.08);
+        outline: none;
+      }
+
+      &__icon {
+        display: inline-flex;
+        align-items: center;
+        justify-content: center;
+        flex: 0 0 auto;
+        width: 44px;
+        height: 44px;
+        border-radius: 10px;
+        background: #eff6ff;
+        color: #2563eb;
+        font-size: 20px;
+
+        &.is-eds {
+          background: #f0fdf4;
+          color: #16a34a;
+        }
+      }
+
+      &__body {
+        display: flex;
+        flex-direction: column;
+        gap: 4px;
+        min-width: 0;
+      }
+
+      &__title {
+        font-size: 15px;
+        font-weight: 600;
+        color: #111827;
+      }
+
+      &__desc {
+        font-size: 12px;
+        line-height: 1.5;
+        color: #64748b;
+      }
+    }
+  }
+
+  html[data-theme='dark'] {
+    .clean-type-modal {
+      .clean-type-option {
+        border-color: #1f2937;
+        background: #111827;
+
+        &:hover,
+        &:focus-visible {
+          border-color: #3b82f6;
+          background: #1e293b;
+          box-shadow: none;
+        }
+
+        &__title {
+          color: #e5e7eb;
+        }
+
+        &__desc {
+          color: #9ca3af;
+        }
+      }
+    }
+  }
 </style>

+ 10 - 3
ai-electron/frontend/src/case/views/data/upload.vue

@@ -539,10 +539,17 @@
         };
 
         try {
-          // defHttp.uploadFile 返回原始 AxiosResponse,业务数据在 res.data.data
-          // 后端返回单个文件节点:文件根(含 children sheet 列表)
+          // defHttp.uploadFile 返回原始 AxiosResponse,业务数据在 res.data.data;
+          // 非 200 的业务错误(如 MD5 重复)在 res.data.message 里,交给 catch 统一提示
           const res = await preFileUpload(file, onProgress, { batchId: currentBatchId });
           if (isAbandoned.value) break;
+          // errorMessageMode=none 时网络异常会被响应拦截器 resolve 成空值,这里兜底
+          if (!res?.data) {
+            throw new Error('网络异常或服务不可用');
+          }
+          if (Number(res.data.code) !== 200) {
+            throw new Error(res.data.message || '上传失败');
+          }
           const fileNode: FileInfo | null = res?.data?.data ?? null;
           if (fileNode) {
             // 右侧 treetable 直接渲染树(文件根 → sheet 子节点)
@@ -567,7 +574,7 @@
           // 失败保留在列表,标记错误供用户查看/移除
           uploadStatuses.value.set(file, 'error');
           uploadProgressMap.value.set(file, 100);
-          createMessage.error(`「${file.name}」上传解析失败:${error?.message || '未知错误'}`);
+          createMessage.error(`「${file.name}」上传失败:${error?.message || '未知错误'}`);
         }
       }
 

+ 2 - 0
ai-electron/frontend/src/core/enums/pageEnum.ts

@@ -10,6 +10,8 @@ export enum PageEnum {
   // basic home path
   BASE_HOME = '/data/index',
   BASE_UPLOAD = '/data/upload',
+  // 电子数据(zip 电子数据包)上传页
+  BASE_EDS_UPLOAD = '/data/edsUpload',
   BASE_CLEANING = '/data/cleaning',
   BASE_CLEAN_PROGRESS = '/data/cleanProgress',
   // error page path

+ 16 - 0
ai-electron/frontend/src/core/router/routes/index.ts

@@ -114,6 +114,21 @@ export const CaseUploadRoute: AppRouteRecordRaw = {
   },
 };
 
+/**
+ * 电子数据上传页:上传 GAB 电子数据包(zip),后台解压入库,右侧轮询进度。
+ * 与文件上传页同为独立全屏路由(不套 LAYOUT)。
+ */
+export const CaseEdsUploadRoute: AppRouteRecordRaw = {
+  path: PageEnum.BASE_EDS_UPLOAD,
+  name: 'CaseEdsUpload',
+  component: () => import('@/case/views/data/edsUpload.vue'),
+  meta: {
+    title: '电子数据上传',
+    hideMenu: true,
+    hideTab: true,
+  },
+};
+
 /**
  * 数据清洗页:与文件上传页同为独立全屏路由(不套 LAYOUT)
  * <p>上传 → 手动清洗 → 清洗导入是同一条全屏流程,三者路由层级必须保持一致,
@@ -169,6 +184,7 @@ export const basicRoutes = [
   CaseRoute,
   WorkbenchRoute,
   CaseUploadRoute,
+  CaseEdsUploadRoute,
   CaseCleaningRoute,
   CaseCleanProgressRoute,
   DataRoute,

+ 8 - 0
ai-server/src/main/java/com/zsjz/ai/common/constants/FileTypeConstants.java

@@ -3,6 +3,14 @@ package com.zsjz.ai.common.constants;
 import java.util.Set;
 
 public class FileTypeConstants {
+    /**
+     * 电子数据包(zip 电子数据)的 file_info.fileType 取值。
+     *
+     * <p>与后缀类文件区分:它不是表格、不参与清洗/治理,导入文件列表按该类型隐藏
+     * 导入成功/失败、治理状态与清洗方式,只展示提取失败原因。</p>
+     */
+    public static final String EDS_PACKAGE = "eds";
+
     public static final String TXT = "txt";
     public static final String CSV = "csv";
     public static final String MD = "md";

+ 16 - 1
ai-server/src/main/java/com/zsjz/ai/common/enums/FileSheetStateEnum.java

@@ -47,7 +47,22 @@ public enum FileSheetStateEnum implements IEnum<String> {
     /**
      * 已治理
      */
-    FILE_GOVERN_COMPLETE("已治理");
+    FILE_GOVERN_COMPLETE("已治理"),
+
+    /**
+     * 电子数据包(zip)提取中。
+     */
+    FILE_EDS_EXTRACTING("电子数据包提取中"),
+
+    /**
+     * 电子数据包提取完成。
+     */
+    FILE_EDS_COMPLETE("电子数据包提取完成"),
+
+    /**
+     * 电子数据包提取失败(损坏 / 加密 / 非电子数据包 / 采集编号重复等)。
+     */
+    FILE_EDS_FAIL("电子数据包提取失败");
 
     // 枚举值的描述信息
     private final String desc;

+ 1 - 1
ai-server/src/main/java/com/zsjz/ai/module/dm/controller/DmController.java

@@ -80,7 +80,7 @@ public class DmController {
      *                以保证同批文件共用一个批次(进度页/结果页按 batchId 聚合)
      * @param reClean 1=重新清洗(跳过 MD5 去重)
      * @return 该文件的树形结构(文件根内嵌 children sheets);未解析的后缀返回无 children 的失败节点;
-     *         重复文件或解析无结果时 data 为 null
+     *         解析无结果时 data 为 null;MD5 重复的表格文件抛出业务异常(文件已存在(MD5 重复))
      */
     @PostMapping(value = "/preFileUpload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
     public Result<FileInfo> preFileUpload(@RequestPart("file") MultipartFile file,

+ 107 - 13
ai-server/src/main/java/com/zsjz/ai/module/dm/service/DmService.java

@@ -40,6 +40,7 @@ import com.zsjz.ai.module.dm.clean.TaskCompleteCallback;
 import com.zsjz.ai.module.dm.mapper.FileInfoMapper;
 import com.zsjz.ai.module.dm.pre.PreTask;
 import com.zsjz.ai.module.document.DocumentKinds;
+import com.zsjz.ai.module.eds.po.EdsMaterialProcess;
 import com.zsjz.ai.module.govern.serivce.GovernConfService;
 import com.zsjz.ai.module.person.service.PersonBasicInfoService;
 import com.zsjz.ai.module.person.service.PersonLibNoService;
@@ -94,6 +95,9 @@ public class DmService {
     private PersonBasicInfoService personBasicInfoService;
     @Autowired
     private FileInfoMapper fileInfoMapper;
+    /** 电子数据包提取失败原因:导入文件列表按 file_info.id 回填备注 */
+    @Autowired
+    private com.zsjz.ai.module.eds.mapper.EdsMaterialProcessMapper edsMaterialProcessMapper;
     @Autowired
     private GovernConfService governConfService;
     @Autowired
@@ -183,7 +187,8 @@ public class DmService {
      * @param batchId 批次ID;为 null 时自动生成,同批文件应由前端回传首次的 batchId
      * @param reClean 1=重新清洗(跳过 MD5 去重)
      * @return 该文件的树形结构:文件根节点(pid=0)内嵌 children sheet 列表;
-     *         未解析的后缀返回无 children 的失败节点(文档类带 filePath);重复文件返回 null
+     *         未解析的后缀返回无 children 的失败节点(文档类带 filePath);
+     *         MD5 重复的表格文件抛出业务异常「文件已存在(MD5 重复)」
      */
     public FileInfo preProcessUploadedFile(MultipartFile file, Long batchId, Integer reClean) {
         if (file == null || file.isEmpty()) {
@@ -211,17 +216,25 @@ public class DmService {
 
         Path saved = saveUploadedFile(file, currentBatchId, originalName);
 
-        // 【临时禁用:演示测试需要重复上传同一文件,测试完成后还原此段】
-        // 重新清洗时跳过 MD5 去重(历史文件 md5 已存在于 file_info,否则会被全部过滤)
-        // if (reClean == null || reClean != 1) {
-        //     List<Path> kept = filterExistsMd5Files(List.of(saved));
-        //     if (kept.isEmpty()) {
-        //         log.info("上传文件与已导入文件重复,跳过解析: {}, batchId={}", originalName, currentBatchId);
-        //         return null;
-        //     }
-        // }
-
-        // 单文件串行解析,无需并发控制信号量;返回树形根节点(含 children sheets),重复文件返回 null
+        // MD5 去重只对表格文件(csv / xls / xlsx)生效:
+        // 文档、图片、音视频等允许重复上传,不做重复校验;
+        // 重新清洗时跳过(历史文件的 md5 已在 file_info 里,否则会被全部过滤)。
+        if (reClean == null || reClean != 1) {
+            List<Path> kept = filterExistsMd5Files(List.of(saved));
+            if (kept.isEmpty()) {
+                log.info("上传文件与已导入文件重复,跳过解析: {}, batchId={}", originalName, currentBatchId);
+                // 重复文件不再解析,落盘的副本也一并清掉,避免 upload 目录堆积
+                try {
+                    FileUtil.del(saved);
+                } catch (Exception e) {
+                    log.warn("删除重复上传文件失败: path={}, err={}", saved, e.getMessage());
+                }
+                // 明确告知用户是 MD5 重复,而不是含糊的「未识别到可处理文件」
+                throw ServerException.spe("文件已存在(MD5 重复),已跳过");
+            }
+        }
+
+        // 单文件串行解析,无需并发控制信号量;返回树形根节点(含 children sheets)
         FileInfo root = buildPreviewTree(processPreviewFile(saved, currentBatchId)).stream().findFirst().orElse(null);
         backfillFileSize(root, saved);
         saveParsedFileInfos(root);
@@ -524,7 +537,7 @@ public class DmService {
                 }
                 return candidateFiles;
             }
-            return filterExistsMd5Files(candidateFiles);
+            return filterMd5ForTableFiles(candidateFiles);
         } catch (ServerException e) {
             // 路径越界/不存在是安全拒绝,不能让上层当成“没有文件”静默吞掉
             throw e;
@@ -534,6 +547,36 @@ public class DmService {
         }
     }
 
+    /**
+     * 只对表格文件(csv / xls / xlsx)做 MD5 去重,其它类型原样保留。
+     *
+     * <p>文档、图片、音视频、压缩包等允许重复上传,不参与重复校验。</p>
+     *
+     * @param candidateFiles 待处理文件
+     * @return 保留了非表格文件、并按 MD5 过滤后的表格文件列表(保持原有顺序)
+     */
+    private List<Path> filterMd5ForTableFiles(List<Path> candidateFiles) {
+        if (CollUtil.isEmpty(candidateFiles)) {
+            return List.of();
+        }
+        List<Path> tableFiles = candidateFiles.stream().filter(this::isTableFile).toList();
+        if (tableFiles.isEmpty()) {
+            return candidateFiles;
+        }
+        Set<Path> keptTableFiles = new HashSet<>(filterExistsMd5Files(tableFiles));
+        return candidateFiles.stream()
+                .filter(path -> !isTableFile(path) || keptTableFiles.contains(path))
+                .toList();
+    }
+
+    /**
+     * 是否表格文件(与清洗链路支持的格式一致:csv / xls / xlsx)。
+     */
+    private boolean isTableFile(Path path) {
+        String suffix = FileUtil.getSuffix(path.getFileName().toString());
+        return suffix != null && GlobalCache.suffixList.contains(suffix.toLowerCase());
+    }
+
     /**
      * 预处理阶段先做一次 MD5 去重:
      * 1. 过滤数据库中已经存在的文件
@@ -1038,6 +1081,9 @@ public class DmService {
                 .filter(Objects::nonNull)
                 .toList();
         Map<Long, com.zsjz.ai.module.aiclean.entity.AiCleanJob> latestJobs = loadLatestAiJobs(sheetIds);
+        // 电子数据包:提取失败原因存在进度表里,这里回填到列表的「备注」;
+        // 同时兼容早期只写了 fileType=1 的电子数据包记录(按压缩包路径识别)
+        EdsProcessLookup edsLookup = loadEdsProcessLookup();
         Map<Long, List<FileInfo>> fileMap = fileInfos.stream().collect(Collectors.groupingBy(FileInfo::getPid));
         List<FileInfo> rootFiles = Lists.newArrayList();
         for (FileInfo fileInfo : fileInfos) {
@@ -1049,6 +1095,17 @@ public class DmService {
                 // 列表是重新查库的:瞬态原因不会落库,这里按 filePath 是否有值重新生成
                 fileInfo.setUnsupportedReason(unsupportedReasonOf(fileInfo));
             }
+            if (FileTypeConstants.EDS_PACKAGE.equalsIgnoreCase(fileInfo.getFileType())) {
+                EdsMaterialProcess process = edsLookup.byId().get(fileInfo.getId());
+                fileInfo.setCleanNote(process == null ? null : process.getErrorMessage());
+            } else if (StrUtil.isNotBlank(fileInfo.getFilePath())) {
+                EdsMaterialProcess legacy = edsLookup.byPath().get(fileInfo.getFilePath());
+                if (legacy != null) {
+                    // 旧数据:数据包记录是 fileType=1,按路径识别后统一按电子数据包口径展示
+                    fileInfo.setFileType(FileTypeConstants.EDS_PACKAGE);
+                    fileInfo.setCleanNote(legacy.getErrorMessage());
+                }
+            }
             List<FileInfo> childrens = fileMap.getOrDefault(fileInfo.getId(), List.of());
             if (CollUtil.isEmpty(childrens)) {
                 continue;
@@ -1148,6 +1205,43 @@ public class DmService {
         return latestJob;
     }
 
+    /**
+     * 电子数据包进度记录查询结果:同时按 file_info.id 与压缩包路径建索引。
+     *
+     * <p>新数据两者 ID 相同(直接按 id 命中);早期数据包记录 fileType=1 且没有关联 id,
+     * 只能按两者共有的 file_path 识别。</p>
+     */
+    private record EdsProcessLookup(Map<Long, EdsMaterialProcess> byId,
+                                    Map<String, EdsMaterialProcess> byPath) {
+        static final EdsProcessLookup EMPTY = new EdsProcessLookup(Map.of(), Map.of());
+    }
+
+    /**
+     * 查询当前案件的电子数据包进度记录。
+     *
+     * <p>查询失败只记日志:列表展示是辅助信息,不能因此让文件列表接口失败。</p>
+     */
+    private EdsProcessLookup loadEdsProcessLookup() {
+        try {
+            List<EdsMaterialProcess> processes = edsMaterialProcessMapper.selectList(null);
+            if (CollUtil.isEmpty(processes)) {
+                return EdsProcessLookup.EMPTY;
+            }
+            Map<Long, EdsMaterialProcess> byId = new HashMap<>();
+            Map<String, EdsMaterialProcess> byPath = new HashMap<>();
+            for (EdsMaterialProcess process : processes) {
+                byId.put(process.getId(), process);
+                if (StrUtil.isNotBlank(process.getFilePath())) {
+                    byPath.putIfAbsent(process.getFilePath(), process);
+                }
+            }
+            return new EdsProcessLookup(byId, byPath);
+        } catch (Exception e) {
+            log.warn("查询电子数据包进度记录失败: {}", e.getMessage());
+            return EdsProcessLookup.EMPTY;
+        }
+    }
+
     /**
      * 回填 sheet 的清洗方式与备注(瞬态字段,供「导入文件管理」列表展示):
      * <ul>

+ 64 - 0
ai-server/src/main/java/com/zsjz/ai/module/eds/controller/EdsMaterialProcessController.java

@@ -0,0 +1,64 @@
+package com.zsjz.ai.module.eds.controller;
+
+import com.zsjz.ai.common.config.Result;
+import com.zsjz.ai.module.eds.po.EdsMaterialProcess;
+import com.zsjz.ai.module.eds.service.EdsMaterialProcessService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestPart;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+
+/**
+ * 电子数据包上传 / 进度接口。
+ *
+ * <p>与「表格数据上传」({@code /dm/preFileUpload})并列:
+ * 本接口只收 zip,落盘后登记 {@code eds_material_process} 并在后台解压提取;
+ * 前端页面定时轮询 {@code /eds/list} 刷新进度条与错误信息。</p>
+ *
+ * @author zsjz
+ */
+@RestController
+@RequestMapping("/eds")
+@RequiredArgsConstructor
+public class EdsMaterialProcessController {
+
+    private final EdsMaterialProcessService processService;
+
+    /**
+     * 上传一个电子数据包(zip)。
+     *
+     * @param file zip 文件
+     * @return 刚登记的进度记录(status=2 上传完成),后台解析进度通过列表接口轮询
+     */
+    @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
+    public Result<EdsMaterialProcess> upload(@RequestPart("file") MultipartFile file) {
+        return Result.succeed(processService.upload(file));
+    }
+
+    /**
+     * 电子数据包进度列表(最新在前)。
+     *
+     * @return 当前案件全部数据包记录,含 progress / status / errorMessage
+     */
+    @GetMapping("/list")
+    public Result<List<EdsMaterialProcess>> list() {
+        return Result.succeed(processService.list());
+    }
+
+    /**
+     * 清空当前案件的电子数据包进度表(退出电子数据上传页时调用)。
+     *
+     * <p>完成 / 失败记录一并清空;已提交的后台解析任务不会被中断。</p>
+     */
+    @PostMapping("/clear")
+    public Result<Void> clear() {
+        processService.clearProcesses();
+        return Result.succeed();
+    }
+}

+ 89 - 0
ai-server/src/main/java/com/zsjz/ai/module/eds/mapper/EdsMaterialProcessMapper.java

@@ -0,0 +1,89 @@
+package com.zsjz.ai.module.eds.mapper;
+
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zsjz.ai.module.eds.po.EdsMaterialProcess;
+import org.apache.ibatis.annotations.Delete;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Update;
+
+import static com.zsjz.ai.common.constants.StrConsts.DS_KEY_SLAVE;
+
+/**
+ * 电子数据包上传 / 提取进度数据访问接口。
+ *
+ * <p>表在案件 DuckDB 中,必须走逻辑数据源 slave。</p>
+ *
+ * <p>status 口径:1 上传中 / 2 上传完成 / 3 上传失败 / 4 解析中 / 5 解析失败 / 6 解析完成。</p>
+ *
+ * @author zsjz
+ */
+@Mapper
+@DS(DS_KEY_SLAVE)
+public interface EdsMaterialProcessMapper extends BaseMapper<EdsMaterialProcess> {
+
+    /**
+     * 上传完成:回写落盘路径与大小,状态置为「上传完成」,等待解析队列。
+     */
+    @Update("""
+            UPDATE eds_material_process
+               SET status = 2,
+                   file_path = #{filePath},
+                   size = #{size},
+                   progress = 0,
+                   error_message = NULL
+             WHERE id = #{id}""")
+    int updateUploaded(@Param("id") Long id,
+                       @Param("filePath") String filePath,
+                       @Param("size") Long size);
+
+    /**
+     * 解析中:回写解析进度与已解析出的采集编号(cti 为空时保留原值)。
+     */
+    @Update("""
+            UPDATE eds_material_process
+               SET status = 4,
+                   progress = CAST(#{progress} AS SMALLINT),
+                   cti = COALESCE(CAST(#{cti} AS VARCHAR), cti)
+             WHERE id = #{id}""")
+    int updateParsing(@Param("id") Long id,
+                      @Param("progress") int progress,
+                      @Param("cti") String cti);
+
+    /**
+     * 解析完成:进度 100,清空错误信息,并回填采集编号 / 检材类型。
+     */
+    @Update("""
+            UPDATE eds_material_process
+               SET status = 6,
+                   progress = 100,
+                   cti = COALESCE(CAST(#{cti} AS VARCHAR), cti),
+                   material_type = COALESCE(CAST(#{materialType} AS VARCHAR), material_type),
+                   error_message = NULL
+             WHERE id = #{id}""")
+    int updateParseSuccess(@Param("id") Long id,
+                           @Param("cti") String cti,
+                           @Param("materialType") String materialType);
+
+    /**
+     * 上传 / 解析失败:进度 100,写入错误信息。
+     *
+     * @param status 3 上传失败、5 解析失败
+     */
+    @Update("""
+            UPDATE eds_material_process
+               SET status = #{status},
+                   progress = 100,
+                   error_message = #{errorMessage}
+             WHERE id = #{id}""")
+    int updateFailed(@Param("id") Long id,
+                     @Param("status") int status,
+                     @Param("errorMessage") String errorMessage);
+
+    /**
+     * 清空当前案件的进度表(退出电子数据上传页时调用,已完成/失败记录一并删除)。
+     */
+    @Delete("DELETE FROM eds_material_process")
+    int clearAll();
+}

+ 108 - 0
ai-server/src/main/java/com/zsjz/ai/module/eds/po/EdsMaterialProcess.java

@@ -0,0 +1,108 @@
+package com.zsjz.ai.module.eds.po;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+/**
+ * 电子数据包上传 / 提取进度记录(案件 DuckDB:{@code eds_material_process})。
+ *
+ * <p>一次 zip 上传落一条记录:上传开始即插入(status=上传中),上传完成后进入解析队列
+ * (status=上传完成),解析线程启动后回写解析进度,结束时回写解析完成/失败与错误信息。
+ * 前端电子数据上传页轮询本表展示进度条与错误信息。</p>
+ *
+ * @author zsjz
+ */
+@Data
+@TableName(value = "eds_material_process")
+public class EdsMaterialProcess {
+
+    /**
+     * 上传中(HTTP 上传 / 落盘阶段)
+     */
+    public static final int STATUS_UPLOADING = 1;
+
+    /**
+     * 上传完成(等待解析或已进入解析队列)
+     */
+    public static final int STATUS_UPLOADED = 2;
+
+    /**
+     * 上传失败(落盘失败)
+     */
+    public static final int STATUS_UPLOAD_FAILED = 3;
+
+    /**
+     * 解析中
+     */
+    public static final int STATUS_PARSING = 4;
+
+    /**
+     * 解析失败(损坏 / 加密 / 非电子数据包 / 采集编号重复等)
+     */
+    public static final int STATUS_PARSE_FAILED = 5;
+
+    /**
+     * 解析完成
+     */
+    public static final int STATUS_PARSE_SUCCESS = 6;
+
+    @TableId(type = IdType.ASSIGN_ID)
+    private Long id;
+
+    /**
+     * 原始上传文件名
+     */
+    @TableField(value = "file_name")
+    private String fileName;
+
+    /**
+     * 采集编号(解析索引后回填)
+     */
+    @TableField(value = "cti")
+    private String cti;
+
+    /**
+     * 检材类型(从包内 160100 读取)
+     */
+    @TableField(value = "material_type")
+    private String materialType;
+
+    /**
+     * 压缩包落盘路径
+     */
+    @TableField(value = "file_path")
+    private String filePath;
+
+    /**
+     * 压缩包大小(字节)
+     */
+    @TableField(value = "size")
+    private Long size;
+
+    /**
+     * 状态:0 待处理 / 1 提取中 / 2 成功 / 3 失败
+     */
+    @TableField(value = "status")
+    private Integer status;
+
+    /**
+     * 提取进度(0-100)
+     */
+    @TableField(value = "progress")
+    private Short progress;
+
+    /**
+     * 失败原因(成功时为空)
+     */
+    @TableField(value = "error_message")
+    private String errorMessage;
+
+    /**
+     * 上传人(登录账号)
+     */
+    @TableField(value = "create_name")
+    private String createName;
+}

+ 363 - 0
ai-server/src/main/java/com/zsjz/ai/module/eds/service/EdsMaterialProcessService.java

@@ -0,0 +1,363 @@
+package com.zsjz.ai.module.eds.service;
+
+import cn.dev33.satoken.stp.StpUtil;
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.zsjz.ai.common.constants.FileTypeConstants;
+import com.zsjz.ai.common.constants.PathConst;
+import com.zsjz.ai.common.context.CaseContextHolder;
+import com.zsjz.ai.common.enums.DelimiterEnum;
+import com.zsjz.ai.common.enums.FileSheetStateEnum;
+import com.zsjz.ai.common.exception.ServerException;
+import com.zsjz.ai.common.model.dm.entity.FileInfo;
+import com.zsjz.ai.module.dm.mapper.FileInfoMapper;
+import com.zsjz.ai.module.eds.mapper.EdsMaterialProcessMapper;
+import com.zsjz.ai.module.eds.po.EdsMaterialProcess;
+import com.zsjz.ai.module.eds.xml.EdsExtra;
+import com.zsjz.ai.module.eds.xml.EdsExtraFile;
+import com.zsjz.ai.module.eds.xml.EdsProgressListener;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.time.LocalDateTime;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * 电子数据包上传 / 后台解析服务。
+ *
+ * <p>流程:上传 zip → 先写一条 {@code eds_material_process}(status=1 上传中)→ 落盘
+ * (status=2 上传完成)→ 提交后台解析(status=4 解析中)→ 解压并判定
+ * {@code GAB_ZIP_INDEX.xml} → 命中则复用 {@link EdsExtra} 逐表入案件 DuckDB,
+ * 未命中以 status=5 失败收口并展示错误信息。</p>
+ *
+ * <p>解析最多 5 路并发,超出部分由线程池队列排队(status 保持 2,轮到后变 4)。</p>
+ *
+ * @author zsjz
+ */
+@Slf4j
+@Service
+@RequiredArgsConstructor
+public class EdsMaterialProcessService {
+
+    /**
+     * 电子数据包落盘目录名(位于 QingJian/workspace/{caseId}/ 下)
+     */
+    private static final String EDS_DIR_NAME = "eds";
+
+    /**
+     * 单包开始解析时的初始进度(解压前)
+     */
+    private static final int START_PROGRESS = 5;
+
+    /**
+     * 同时解析的数据包上限,超过的进入线程池队列排队
+     */
+    private static final int PARSE_CONCURRENCY = 5;
+
+    private final EdsMaterialProcessMapper processMapper;
+
+    private final FileInfoMapper fileInfoMapper;
+
+    private final EdsExtra edsExtra;
+
+    /**
+     * 解析线程池:固定 5 路并发,其余任务排队;守护线程避免阻塞应用退出
+     */
+    private final ExecutorService executor = Executors.newFixedThreadPool(PARSE_CONCURRENCY,
+            Thread.ofPlatform().name("eds-material-parse-", 0).daemon(true).factory());
+
+    /**
+     * 上传一个电子数据包:落盘 + 登记 + 提交后台解析,立即返回进度记录。
+     *
+     * @param file 上传的 zip
+     * @return 刚插入的进度记录(status=上传完成)
+     */
+    public EdsMaterialProcess upload(MultipartFile file) {
+        if (file == null || file.isEmpty()) {
+            throw ServerException.spe("上传文件为空!");
+        }
+        Long caseId = CaseContextHolder.currentCaseId();
+        if (caseId == null) {
+            throw ServerException.spe("请先打开案件后再上传电子数据!");
+        }
+        String originalName = StrUtil.blankToDefault(file.getOriginalFilename(), "未命名数据包");
+        String suffix = FileUtil.getSuffix(originalName);
+        if (!"zip".equalsIgnoreCase(suffix)) {
+            throw ServerException.spe("仅支持上传 zip 格式的电子数据包:" + originalName);
+        }
+
+        Long id = IdUtil.getSnowflakeNextId();
+        EdsMaterialProcess row = new EdsMaterialProcess();
+        row.setId(id);
+        row.setFileName(originalName);
+        row.setSize(file.getSize());
+        row.setStatus(EdsMaterialProcess.STATUS_UPLOADING);
+        row.setProgress((short) 0);
+        row.setCreateName(currentUserName(CaseContextHolder.currentUserId()));
+        // 上传开始即落一条进度记录:落盘失败也能在进度表里看到「上传失败」原因
+        processMapper.insert(row);
+
+        Path saved;
+        try {
+            saved = saveZip(file, caseId, id, originalName);
+        } catch (RuntimeException e) {
+            log.error("保存电子数据包失败: name={}", originalName, e);
+            markUploadFailed(id, "上传失败:" + rootMessage(e));
+            throw e;
+        }
+        processMapper.updateUploaded(id, saved.toString(), file.getSize());
+        row.setFilePath(saved.toString());
+        row.setStatus(EdsMaterialProcess.STATUS_UPLOADED);
+
+        // 上传成功后再登记 file_info:导入文件列表据此展示电子数据包行(与进度记录共用同一个 ID)
+        createFileInfo(row);
+
+        Long userId = CaseContextHolder.currentUserId();
+        // 交给 5 路解析线程池:超过并发上限的在这里排队(status=2 上传完成),轮到后变 4 解析中
+        executor.submit(() -> CaseContextHolder.runWith(caseId, userId, () -> process(row)));
+        log.info("电子数据包已上传并提交解析: id={}, name={}, size={}", id, originalName, file.getSize());
+        return row;
+    }
+
+    /**
+     * 清空当前案件的进度表(退出电子数据上传页时调用)。
+     *
+     * <p>完成 / 失败记录一并删除,符合「每次退出都清空」的产品约定;
+     * 已在解析中的后台任务不会被中断,只是后续进度回写找不到记录、自然失效。</p>
+     */
+    public void clearProcesses() {
+        if (CaseContextHolder.currentCaseId() == null) {
+            throw ServerException.spe("请先打开案件后再清空电子数据!");
+        }
+        int deleted = processMapper.clearAll();
+        log.info("电子数据包进度表已清空: deleted={}", deleted);
+    }
+
+    /**
+     * 数据包列表(最新在前),前端定时轮询刷新进度。
+     *
+     * @return 当前案件的全部电子数据包记录
+     */
+    public List<EdsMaterialProcess> list() {
+        if (CaseContextHolder.currentCaseId() == null) {
+            throw ServerException.spe("请先打开案件后再查看电子数据!");
+        }
+        return processMapper.selectList(Wrappers.<EdsMaterialProcess>lambdaQuery()
+                .orderByDesc(EdsMaterialProcess::getId));
+    }
+
+    // ------------------------------------------------------------------
+    // 后台提取
+    // ------------------------------------------------------------------
+
+    /**
+     * 单个数据包的提取,调用方已绑定案件上下文。
+     *
+     * @param row 进度记录
+     */
+    private void process(EdsMaterialProcess row) {
+        Long fileId = row.getId();
+        try {
+            updateParsing(fileId, START_PROGRESS, null);
+            EdsExtraFile dto = new EdsExtraFile(
+                    Path.of(row.getFilePath()).getFileName().toString(),
+                    // 与 file_info 共用同一个 ID:提取完成后直接回写该记录
+                    fileId,
+                    Path.of(row.getFilePath()),
+                    row.getCreateName(),
+                    CaseContextHolder.currentCaseId());
+            dto.setDisplayName(row.getFileName());
+
+            // 记录是否已有终态回调,防止流程静默返回时记录永远停在「解析中」
+            AtomicBoolean settled = new AtomicBoolean(false);
+            EdsProgressListener listener = new EdsProgressListener() {
+                @Override
+                public void onProgress(int percent, String message) {
+                    log.info("电子数据包[{}] {}% {}", fileId, percent, message);
+                    updateParsing(fileId, Math.max(START_PROGRESS, percent), dto.getCollectTargetId());
+                }
+
+                @Override
+                public void onDone() {
+                    settled.set(true);
+                    try {
+                        processMapper.updateParseSuccess(fileId,
+                                dto.getCollectTargetId(), dto.getMaterialType());
+                        log.info("电子数据包解析完成: id={}, cti={}", fileId, dto.getCollectTargetId());
+                    } catch (Exception e) {
+                        log.error("回写电子数据包解析完成状态失败: id={}", fileId, e);
+                    }
+                }
+
+                @Override
+                public void onFailed(String message) {
+                    settled.set(true);
+                    markParseFailed(fileId, message);
+                    log.warn("电子数据包解析失败: id={}, err={}", fileId, message);
+                }
+            };
+
+            try {
+                edsExtra.extraZipData(dto, listener);
+                if (!settled.get()) {
+                    listener.onFailed("解析流程未返回完成状态");
+                }
+            } catch (Throwable e) {
+                log.error("电子数据包解析异常: id={}, name={}", fileId, row.getFileName(), e);
+                if (!settled.get()) {
+                    listener.onFailed("解析异常:" + rootMessage(e));
+                }
+            }
+        } catch (Throwable e) {
+            log.error("电子数据包处理异常: id={}, name={}", fileId, row.getFileName(), e);
+            markParseFailed(fileId, "处理异常:" + rootMessage(e));
+        }
+    }
+
+    /**
+     * 上传失败收口:进度记录标记「上传失败」。
+     *
+     * <p>此时还没有登记 file_info,不需要回写导入文件列表。</p>
+     */
+    private void markUploadFailed(Long fileId, String message) {
+        try {
+            processMapper.updateFailed(fileId, EdsMaterialProcess.STATUS_UPLOAD_FAILED, message);
+        } catch (Exception e) {
+            log.error("回写电子数据包上传失败状态失败: id={}", fileId, e);
+        }
+    }
+
+    /**
+     * 解析失败收口:进度记录与 file_info 都标记失败(file_info 供导入文件列表展示错误)。
+     */
+    private void markParseFailed(Long fileId, String message) {
+        try {
+            processMapper.updateFailed(fileId, EdsMaterialProcess.STATUS_PARSE_FAILED, message);
+        } catch (Exception e) {
+            log.error("回写电子数据包解析失败状态失败: id={}", fileId, e);
+        }
+        updateFileInfoStatus(fileId, FileSheetStateEnum.FILE_EDS_FAIL);
+    }
+
+    /**
+     * 回写解析中进度。
+     */
+    private void updateParsing(Long fileId, int progress, String cti) {
+        try {
+            processMapper.updateParsing(fileId, progress, cti);
+        } catch (Exception e) {
+            log.warn("回写电子数据包解析进度失败: id={}, progress={}, err={}", fileId, progress, e.getMessage());
+        }
+    }
+
+    // ------------------------------------------------------------------
+    // file_info 登记 / 工具
+    // ------------------------------------------------------------------
+
+    /**
+     * 登记电子数据包 file_info(导入文件列表的数据源)。
+     *
+     * <p>与进度记录共用同一个 ID,提取完成/失败时直接回写这一行;
+     * 登记失败不阻止提取,只影响导入文件列表的展示。</p>
+     *
+     * @param row 进度记录
+     */
+    private void createFileInfo(EdsMaterialProcess row) {
+        FileInfo info = new FileInfo();
+        info.setId(row.getId());
+        info.setPid(0L);
+        info.setFileName(row.getFileName());
+        info.setFileType(FileTypeConstants.EDS_PACKAGE);
+        info.setFileStatus(FileSheetStateEnum.FILE_EDS_EXTRACTING);
+        info.setFilePath(row.getFilePath());
+        info.setFileSize(row.getSize());
+        info.setDataNum(0);
+        info.setSuccessNum(0);
+        info.setFailNum(0);
+        info.setCharSet(StandardCharsets.UTF_8.displayName());
+        // 电子数据包没有分隔符概念,写 COMMA 只为满足列约束
+        info.setDelimiter(DelimiterEnum.COMMA);
+        info.setCreateDateTime(LocalDateTime.now());
+        try {
+            fileInfoMapper.insert(info);
+        } catch (Exception e) {
+            log.warn("登记电子数据包 file_info 失败(不影响提取): fileId={}, err={}",
+                    row.getId(), e.getMessage());
+        }
+    }
+
+    /**
+     * 回写电子数据包 file_info 状态(成功由 {@code EdsExtra.finish} 回写,这里只处理失败)。
+     */
+    private void updateFileInfoStatus(Long fileId, FileSheetStateEnum status) {
+        try {
+            FileInfo update = new FileInfo();
+            update.setId(fileId);
+            update.setFileStatus(status);
+            fileInfoMapper.updateById(update);
+        } catch (Exception e) {
+            log.warn("回写电子数据包 file_info 状态失败: fileId={}, status={}, err={}",
+                    fileId, status, e.getMessage());
+        }
+    }
+
+    /**
+     * 落盘到 {@code workspace/{caseId}/eds/{id}/原始文件名.zip}。
+     * 每个包独立目录,解压产物与 zip 同目录,不会与其它包重名。
+     */
+    private Path saveZip(MultipartFile file, Long caseId, Long id, String originalName) {
+        Path dir = PathConst.WORKSPACE.resolve(String.valueOf(caseId)).resolve(EDS_DIR_NAME).resolve(String.valueOf(id));
+        try {
+            Files.createDirectories(dir);
+            String safeName = StrUtil.blankToDefault(FileUtil.getName(originalName), "package")
+                    .replaceAll("[\\\\/:*?\"<>|]", "_");
+            if (!safeName.toLowerCase().endsWith(".zip")) {
+                safeName += ".zip";
+            }
+            Path target = dir.resolve(safeName).normalize();
+            if (!target.startsWith(dir)) {
+                throw ServerException.spe("非法文件名:" + originalName);
+            }
+            try (InputStream in = file.getInputStream()) {
+                Files.copy(in, target, StandardCopyOption.REPLACE_EXISTING);
+            }
+            return target;
+        } catch (ServerException e) {
+            throw e;
+        } catch (Exception e) {
+            log.error("保存电子数据包失败: name={}", originalName, e);
+            throw ServerException.spe("保存电子数据包失败:" + originalName);
+        }
+    }
+
+    /**
+     * 当前登录账号(写入 create_name);取不到时用用户 ID 兜底。
+     */
+    private static String currentUserName(Long userId) {
+        try {
+            return StpUtil.getLoginIdAsString();
+        } catch (Exception e) {
+            return userId == null ? null : String.valueOf(userId);
+        }
+    }
+
+    /**
+     * 异常摘要:优先取 message,避免把整段堆栈写进错误信息。
+     */
+    private static String rootMessage(Throwable e) {
+        String message = e == null ? null : e.getMessage();
+        return StrUtil.blankToDefault(message, e == null ? "未知错误" : e.getClass().getSimpleName());
+    }
+}

+ 144 - 23
ai-server/src/main/java/com/zsjz/ai/module/eds/xml/EdsExtra.java

@@ -1,10 +1,13 @@
 package com.zsjz.ai.module.eds.xml;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.io.file.PathUtil;
 import cn.hutool.core.util.StrUtil;
 import com.thoughtworks.xstream.XStream;
+import com.zsjz.ai.common.constants.FileTypeConstants;
 import com.zsjz.ai.common.context.CaseContextHolder;
+import com.zsjz.ai.common.enums.FileSheetStateEnum;
 import com.zsjz.ai.common.model.dm.entity.FileInfo;
 import com.zsjz.ai.module.dm.mapper.FileInfoMapper;
 import com.zsjz.ai.module.eds.duckdb.EdsImportActivityProbe;
@@ -58,11 +61,6 @@ public class EdsExtra {
      */
     private static final int CT_ID_MAX_LENGTH = 69;
 
-    /**
-     * 文件类型:数据包
-     */
-    private static final String FILE_TYPE_DATA_PACKAGE = "1";
-
     private final XStream xStream;
 
     private final StringRedisTemplate stringRedisTemplate;
@@ -86,46 +84,77 @@ public class EdsExtra {
      * @param dto 提取任务信息
      */
     public void extraZipData(EdsExtraFile dto) {
+        extraZipData(dto, EdsProgressListener.NOOP);
+    }
+
+    /**
+     * 解压数据包并完成基础校验,同时回调提取进度。
+     *
+     * @param dto      提取任务信息
+     * @param listener 进度回调(不可为 null,无需进度时传 {@link EdsProgressListener#NOOP})
+     */
+    public void extraZipData(EdsExtraFile dto, EdsProgressListener listener) {
         Long caseId = dto.getCaseId();
         if (caseId == null) {
             log.warn("数据包[{}]:案件 ID 为空,无法确定 DuckDB 数据源。", dto.getFileName());
+            listener.onFailed("案件未打开,无法确定数据源");
             return;
         }
         Long userId = CaseContextHolder.currentUserId();
         activityProbe.begin(caseId);
         try {
-            CaseContextHolder.runWith(caseId, userId, () -> doExtraZipData(dto));
+            CaseContextHolder.runWith(caseId, userId, () -> doExtraZipData(dto, listener));
         } finally {
             activityProbe.end(caseId);
         }
     }
 
-    private void doExtraZipData(EdsExtraFile dto) {
+    private void doExtraZipData(EdsExtraFile dto, EdsProgressListener listener) {
+        String fileName = dto.getFileName();
+        String displayName = dto.displayFileName();
         Path zipPath = dto.getPath();
         if (!PathUtil.exists(zipPath, false)) {
+            listener.onFailed("数据包文件不存在");
             return;
         }
 
-        String fileName = dto.getFileName();
         //计算解压目录并解压
+        listener.onProgress(2, StrUtil.format("正在解压数据包:{}", displayName));
         Path bcpDir = resolveBcpDir(zipPath, fileName);
         if (!Eds.unBcpZip(zipPath, bcpDir.toString(), fileName)) {
             log.warn("数据包[{}]无法解析:压缩包损坏无法解压。", fileName);
+            listener.onFailed("压缩包损坏或已加密,无法解压");
             return;
         }
 
-        //读取并解析包内索引文件
-        Path indexXmlPath = bcpDir.resolve(Eds.INDEX_XML_FILENAME);
-        if (!Files.exists(indexXmlPath)) {
-            log.warn("数据包[{}]无法解析:基本信息文件不存在。", fileName);
+        //读取并解析包内索引文件(允许包内多一层根目录)
+        listener.onProgress(8, "解压完成,正在定位索引文件");
+        Path indexXmlPath = locateIndexXml(bcpDir);
+        if (indexXmlPath == null) {
+            log.warn("数据包[{}]无法解析:未找到索引文件。", fileName);
+            cleanupExtractDir(bcpDir);
+            listener.onFailed("包内未找到 " + Eds.INDEX_XML_FILENAME + ",不是电子数据包");
+            return;
+        }
+        // BCP 文件路径相对索引文件所在目录,嵌套包必须按该目录解析
+        Path dataDir = indexXmlPath.getParent();
+        DataMessage message;
+        try {
+            message = parseIndexXml(indexXmlPath, dataDir);
+        } catch (Exception e) {
+            log.warn("数据包[{}]索引文件解析失败", fileName, e);
+            cleanupExtractDir(bcpDir);
+            listener.onFailed("索引文件解析失败:" + rootMessage(e));
             return;
         }
-        DataMessage message = parseIndexXml(indexXmlPath, bcpDir);
 
         //读取基础信息数据
+        listener.onProgress(12, "索引文件解析完成,正在读取基础信息");
         List<EdsMforensics010100> baseInfoList = message.readRows(EdsConstant.EDS_010100_CLASS);
         if (CollUtil.isEmpty(baseInfoList)) {
             log.warn("数据包[{}]无法解析:基本信息转换错误。", fileName);
+            cleanupExtractDir(bcpDir);
+            listener.onFailed("基本信息(WA_MFORENSICS_010100)读取失败");
             return;
         }
 
@@ -134,12 +163,16 @@ public class EdsExtra {
         String rawCtId = baseInfo.getCollectTargetId();
         if (StrUtil.isBlank(rawCtId)) {
             log.warn("数据包[{}]无法解析:采集编号不存在。", fileName);
+            cleanupExtractDir(bcpDir);
+            listener.onFailed("包内基本信息缺少采集编号");
             return;
         }
         String ctId = Eds.formatCtId(rawCtId);
 
         if (!verifyProcessStep(baseInfoList.size(), ctId, dto.getCaseId())) {
             log.warn("数据包[{}]:采集编号异常或数据包已提取。", fileName);
+            cleanupExtractDir(bcpDir);
+            listener.onFailed("采集编号异常或该数据包已提取过(采集编号:" + ctId + ")");
             return;
         }
 
@@ -153,8 +186,51 @@ public class EdsExtra {
 
         //解析数据并批量入库
         EdsMaterial material = buildMaterial(baseInfo, message, ctId);
-        material.setFileName(dto.getFileName());
-        dataStorage(message, material);
+        dto.setMaterialType(material.getMaterialType());
+        material.setFileName(displayName);
+        listener.onProgress(15, "检材信息校验通过,准备入库");
+        dataStorage(message, material, listener);
+    }
+
+    /**
+     * 定位包内索引文件:优先根目录,其次向下最多三层查找。
+     *
+     * @param bcpDir 解压目录
+     * @return 索引文件路径;不存在时返回 {@code null}
+     */
+    private Path locateIndexXml(Path bcpDir) {
+        Path rootIndex = bcpDir.resolve(Eds.INDEX_XML_FILENAME);
+        if (Files.exists(rootIndex)) {
+            return rootIndex;
+        }
+        try (var paths = Files.find(bcpDir, 3, (path, attrs) -> attrs.isRegularFile()
+                && Eds.INDEX_XML_FILENAME.equalsIgnoreCase(path.getFileName().toString()))) {
+            return paths.findFirst().orElse(null);
+        } catch (Exception e) {
+            log.warn("查找索引文件失败: dir={}, err={}", bcpDir, e.getMessage());
+            return null;
+        }
+    }
+
+    /**
+     * 提取失败时清理解压产物(保留 zip,供用户下载 / 排查)。
+     *
+     * @param bcpDir 解压目录
+     */
+    private void cleanupExtractDir(Path bcpDir) {
+        try {
+            FileUtil.del(bcpDir);
+        } catch (Exception e) {
+            log.warn("清理解压目录失败: dir={}, err={}", bcpDir, e.getMessage());
+        }
+    }
+
+    /**
+     * 异常摘要:优先取异常 message,避免把整段堆栈展示给用户。
+     */
+    private static String rootMessage(Throwable e) {
+        String message = e == null ? null : e.getMessage();
+        return StrUtil.blankToDefault(message, e == null ? "未知错误" : e.getClass().getSimpleName());
     }
 
     /**
@@ -188,7 +264,10 @@ public class EdsExtra {
      * @return 解压目录
      */
     private Path resolveBcpDir(Path zipPath, String fileName) {
-        String dirName = fileName.substring(0, fileName.length() - Eds.ZIP.length());
+        String dirName = StrUtil.blankToDefault(fileName, "eds_package");
+        if (dirName.toLowerCase().endsWith(Eds.ZIP)) {
+            dirName = dirName.substring(0, dirName.length() - Eds.ZIP.length());
+        }
         return zipPath.getParent().resolve(dirName);
     }
 
@@ -211,8 +290,9 @@ public class EdsExtra {
      *
      * @param message  索引文件消息
      * @param material 检材登记草稿
+     * @param listener 进度回调
      */
-    private void dataStorage(DataMessage message, EdsMaterial material) {
+    private void dataStorage(DataMessage message, EdsMaterial material, EdsProgressListener listener) {
         String collectTargetId = message.getCollectTargetId();
         List<DataInfo> dataInfoList = message.tables();
         DataCountInfo dataCountInfo = new DataCountInfo(collectTargetId);
@@ -224,10 +304,20 @@ public class EdsExtra {
         EdsExtraFile dto = message.getTask();
         if (dataInfoList.isEmpty()) {
             //没有需要提取的数据集,也要走清理/登记,否则 Redis key 与 file_info 会残留
+            listener.onProgress(95, "数据包内没有可入库的数据表,正在登记检材信息");
             finish(dto, dataCountInfo, material);
+            listener.onDone();
             return;
         }
+        int total = dataInfoList.size();
+        int index = 0;
         for (DataInfo dataInfo : dataInfoList) {
+            index++;
+            String tableName = StrUtil.blankToDefault(
+                    Eds.normalizeTableName(dataInfo.itemValue(Eds.TABLE_NAME_IK)), "未知数据表");
+            // 15%~90% 留给逐表入库:每表开始前推一次,前端能看到当前在提哪张表
+            listener.onProgress(15 + (int) Math.floor(75.0 * (index - 1) / total),
+                    StrUtil.format("正在提取数据表:{}({}/{})", tableName, index, total));
             log.info("开始提取bcp数据:{}", dataInfo.tableName());
             try {
                 exec(dataInfo, message, dataCountInfo);
@@ -235,7 +325,9 @@ public class EdsExtra {
                 //当前数据集处理完成,剩余计数减一
                 Long remaining = stringRedisTemplate.opsForValue().decrement(remainingKey);
                 if (remaining != null && remaining <= 0) {
+                    listener.onProgress(95, "数据表提取完成,正在登记检材信息");
                     finish(dto, dataCountInfo, material);
+                    listener.onDone();
                 }
             }
         }
@@ -304,6 +396,9 @@ public class EdsExtra {
     /**
      * 提取完成后的清理与登记。
      *
+     * <p>Web 上传链路会先在 file_info 中登记一条电子数据包记录(importId 即该记录 ID),
+     * 提取完成后回写状态与入库行数,不再重复插入;旧调用方没有 importId 时保持插入行为。</p>
+     *
      * @param dto           提取任务信息
      * @param dataCountInfo 目录树统计
      * @param material      检材登记草稿
@@ -317,17 +412,43 @@ public class EdsExtra {
 
         Eds.delZip(dto.getExtractDir(), dto.getArchivePath());
 
-        FileInfo fileInfo = new FileInfo();
-        fileInfo.setPid(0L);
-        fileInfo.setFileName(dto.getFileName());
-        fileInfo.setFileType(FILE_TYPE_DATA_PACKAGE);
-        fileInfo.setFilePath(dto.getPath().toString());
-        fileInfoMapper.insert(fileInfo);
+        if (dto.getImportId() == null || !updateFileInfoComplete(dto, importedRows)) {
+            FileInfo fileInfo = new FileInfo();
+            fileInfo.setPid(0L);
+            fileInfo.setFileName(dto.displayFileName());
+            fileInfo.setFileType(FileTypeConstants.EDS_PACKAGE);
+            fileInfo.setFileStatus(FileSheetStateEnum.FILE_EDS_COMPLETE);
+            fileInfo.setFilePath(dto.getPath().toString());
+            fileInfoMapper.insert(fileInfo);
+        }
         registerMaterial(material, importedRows);
         addDirTreeCount(dataCountInfo);
         log.info("数据包[{}]:已提取完成。", dto.getFileName());
     }
 
+    /**
+     * 回写上传时登记的电子数据包 file_info 记录。
+     *
+     * @param dto          提取任务信息
+     * @param importedRows 入库行数
+     * @return 是否更新成功(记录不存在时返回 false,由 finish 退回插入)
+     */
+    private boolean updateFileInfoComplete(EdsExtraFile dto, int importedRows) {
+        FileInfo update = new FileInfo();
+        update.setId(dto.getImportId());
+        update.setFileName(dto.displayFileName());
+        update.setFileStatus(FileSheetStateEnum.FILE_EDS_COMPLETE);
+        update.setDataNum(importedRows);
+        update.setSuccessNum(importedRows);
+        update.setFailNum(0);
+        try {
+            return fileInfoMapper.updateById(update) > 0;
+        } catch (Exception e) {
+            log.warn("回写电子数据包 file_info 状态失败: fileId={}, err={}", dto.getImportId(), e.getMessage());
+            return false;
+        }
+    }
+
     /**
      * 读取 Redis 中累计的入库数据量。
      */

+ 21 - 3
ai-server/src/main/java/com/zsjz/ai/module/eds/xml/EdsExtraFile.java

@@ -1,5 +1,6 @@
 package com.zsjz.ai.module.eds.xml;
 
+import cn.hutool.core.util.StrUtil;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
@@ -9,7 +10,7 @@ import java.nio.file.Path;
 /**
  * 一个待提取数据包的上下文。
  *
- * <p>前五个字段由调用方填写;后四个字段在解压和索引解析过程中回填,
+ * <p>前五个字段由调用方填写;其余字段在解压和索引解析过程中回填,
  * 供入库完成后的清理与登记使用。</p>
  *
  * @author zsjz
@@ -20,12 +21,17 @@ import java.nio.file.Path;
 public class EdsExtraFile {
 
     /**
-     * 包文件名
+     * 包文件名(落盘文件名,可能带防重前缀;也用于计算解压目录)
      */
     private String fileName;
 
     /**
-     * 导入记录 ID
+     * 展示用文件名(原始上传文件名);为空时退回 {@link #fileName}
+     */
+    private String displayName;
+
+    /**
+     * 导入记录 ID(file_info.id);为空时 finish 阶段按旧逻辑插入一条记录
      */
     private Long importId;
 
@@ -49,6 +55,11 @@ public class EdsExtraFile {
      */
     private String collectTargetId;
 
+    /**
+     * 检材类型(读取 160100 后回填)
+     */
+    private String materialType;
+
     /**
      * 解压目录(解压后回填)
      */
@@ -71,4 +82,11 @@ public class EdsExtraFile {
         this.operatorAccount = operatorAccount;
         this.caseId = caseId;
     }
+
+    /**
+     * 展示用文件名:日志与 file_info 用原始上传名,空时退回落盘名。
+     */
+    public String displayFileName() {
+        return StrUtil.isBlank(displayName) ? fileName : displayName;
+    }
 }

+ 50 - 0
ai-server/src/main/java/com/zsjz/ai/module/eds/xml/EdsProgressListener.java

@@ -0,0 +1,50 @@
+package com.zsjz.ai.module.eds.xml;
+
+/**
+ * 电子数据包提取进度回调。
+ *
+ * <p>提取流程本身不关心进度去向:电子数据上传页用它回写
+ * {@code eds_material_process.progress},其它调用方可以直接传 {@link #NOOP}。
+ * 实现方必须保证回调<b>不抛异常</b>,否则会打断正在进行的入库。</p>
+ *
+ * @author zsjz
+ */
+public interface EdsProgressListener {
+
+    /**
+     * 提取进度变化。
+     *
+     * @param percent 当前数据包的处理进度(0-99,100 由 {@link #onDone()} 表达)
+     * @param message 阶段说明(写日志用)
+     */
+    void onProgress(int percent, String message);
+
+    /**
+     * 数据包提取完成。
+     */
+    void onDone();
+
+    /**
+     * 数据包提取失败(损坏、加密、缺索引、重复包等)。
+     *
+     * @param message 失败原因(直接展示给用户)
+     */
+    void onFailed(String message);
+
+    /**
+     * 空实现:无需进度通知的调用方使用。
+     */
+    EdsProgressListener NOOP = new EdsProgressListener() {
+        @Override
+        public void onProgress(int percent, String message) {
+        }
+
+        @Override
+        public void onDone() {
+        }
+
+        @Override
+        public void onFailed(String message) {
+        }
+    };
+}

+ 0 - 75
ai-server/src/test/java/com/zsjz/ai/module/eds/duckdb/DirTreeRegistryTest.java

@@ -1,75 +0,0 @@
-package com.zsjz.ai.module.eds.duckdb;
-
-import org.duckdb.DuckDBConnection;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.io.TempDir;
-
-import java.nio.file.Path;
-import java.sql.DriverManager;
-import java.sql.Statement;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-/**
- * 目录树注册表测试:只从 eds_tree 读取,空表/缺表返回空注册表。
- *
- * @author zsjz
- */
-class DirTreeRegistryTest {
-
-    @TempDir
-    Path tempDir;
-
-    @Test
-    void missingTreeTableReturnsEmpty() throws Exception {
-        try (DuckDBConnection connection = (DuckDBConnection) DriverManager.getConnection(
-                "jdbc:duckdb:" + tempDir.resolve("tree-missing.duckdb"))) {
-            DirTreeRegistry registry = DirTreeRegistry.load(connection);
-
-            assertTrue(registry.all().isEmpty());
-        }
-    }
-
-    @Test
-    void emptyTreeTableReturnsEmpty() throws Exception {
-        try (DuckDBConnection connection = (DuckDBConnection) DriverManager.getConnection(
-                "jdbc:duckdb:" + tempDir.resolve("tree-empty.duckdb"));
-             Statement st = connection.createStatement()) {
-            st.execute("""
-                    CREATE TABLE eds_tree (
-                        id VARCHAR NOT NULL, name VARCHAR, pid VARCHAR, tb_name VARCHAR,
-                        tree_level INTEGER, has_num INTEGER NOT NULL DEFAULT 1,
-                        sort INTEGER NOT NULL DEFAULT 0
-                    )
-                    """);
-
-            DirTreeRegistry registry = DirTreeRegistry.load(connection);
-
-            assertTrue(registry.all().isEmpty());
-        }
-    }
-
-    @Test
-    void usesDatabaseRowsWhenPresent() throws Exception {
-        try (DuckDBConnection connection = (DuckDBConnection) DriverManager.getConnection(
-                "jdbc:duckdb:" + tempDir.resolve("tree-present.duckdb"));
-             Statement st = connection.createStatement()) {
-            st.execute("""
-                    CREATE TABLE eds_tree (
-                        id VARCHAR, name VARCHAR, pid VARCHAR, tb_name VARCHAR,
-                        tree_level INTEGER, has_num INTEGER, sort INTEGER
-                    )
-                    """);
-            st.execute("insert into eds_tree values ('node1','节点1','','wa_mforensics_010100',1,1,1)");
-            st.execute("insert into eds_tree values ('node2','节点2','node1','wa_mforensics_010400',1,1,2)");
-
-            DirTreeRegistry registry = DirTreeRegistry.load(connection);
-
-            assertEquals(2, registry.all().size());
-            assertEquals("wa_mforensics_010100", registry.byTable("wa_mforensics_010100").getTbName());
-            assertNotNull(registry.byId("node2"));
-        }
-    }
-}