生成时间: 2026-08-03 · 数据来源: xnybw平台需求及工作计划.xlsx(南网在线绿能云缺陷跟踪表)· 仅针对 backup730/730backup 分支代码

Row 33:项目信息查询-集中式新能源导出数据是全网数据,与页面/分页数据对不上

一般 已关闭 · 复测通过 全部类型 模块:项目信息查询 处理人:周小龙

1基本信息

问题描述项目信息-集中式新能源模块导出数据,导出的数据包括全网的数据,与页面上及分页栏上的数据都对不上。
所属模块项目信息查询
严重程度一般(阻断流程:是)
涉及类型全部类型
提出人刘向诚
处理人 / 状态周小龙 / 5.1.已关闭(复测通过)

2问题截图

项目信息查询-集中式新能源列表
图1:项目信息查询-集中式新能源列表,当前查询条件下共22条数据
导出结果按类型筛选2257条中筛出903条集中式光伏
图2:导出的 Excel 中用"类型"列筛选,仅"集中式光伏"就有 903 条,全表共 2257 条——远超页面查询到的 22 条

3旧代码定位(backup730 / 730backup 分支)

前端导出触发:xnybw5f · src/views/projectNew/projectInfoSearchList.vue 第 217-218 行、406-421 行:

// getDataList() 中:每次查询都把当前查询条件缓存到 exportParam
this.exportParam = { ...query }

// handleExport():真正导出时却完全没用 exportParam
handleExport() {
  const msg = this.selectedData.length < 1 ? '是否导出所有数据至Excel' : '是否导出勾选的' + this.selectedData.length + '条数据至Excel'
  this.exportLoading = true
  this.$confirm(msg, '提示', {...}).then(() => {
    const idArr = []
    this.selectedData.forEach(item => { idArr.push(item.planId) })
    projectBaseApi.exportProject({
      planIdList: idArr        // ← 未勾选时 idArr 为空数组,且没有携带任何查询过滤条件
    }).then(res => { ... })
  })
},

后端导出接口:xnybw5b · src/main/java/cn/csg/so/oms/in/newenergy/project/controller/NewNePjController.java 第 143-165 行:

@PostMapping("/exportProject")
public void exportProject(HttpServletResponse response, @RequestBody GetProjectAdjustQueryParam condition) throws IOException {
    List<NePjImplVO> allList = new ArrayList<>();
    int pageNum = 1;
    condition.setPageNum(pageNum);
    condition.setPageSize(100);
    while (true) {
        IPage<NePjImplVO> page = projectImplFacade.selectAll(condition);   // condition 里只有空的 planIdList,没有 types/province/company 等过滤条件
        List<NePjImplVO> batch = (page == null) ? Collections.emptyList() : page.getRecords();
        if (batch == null || batch.isEmpty()) break;
        allList.addAll(batch);
        pageNum++;
        condition.setPageNum(pageNum);
    }
    ...
}
根因说明:前端在 getDataList() 里确实把每次查询的完整过滤条件(省份/地市/调管单位/类型/项目状态等)保存到了 this.exportParam,但 handleExport() 点击导出时根本没有使用这份 exportParam,只构造了一个 { planIdList: idArr } 请求体;当用户没有勾选任何行时("是否导出所有数据"分支),idArr 为空数组,等价于给后端传了一个"没有任何过滤条件"的 GetProjectAdjustQueryParam。后端 exportProject() 拿到这个几乎为空的 condition 后循环分页拉取 selectAll(condition),由于没有任何 type/province/status 等 WHERE 条件,实际上是把整张 SO_IN_NE_PJ_IMPL 表(全网全部项目,2257+条)都导出了,与页面当前查询条件下的 22 条完全对不上。

4修复方案

修复文件:src/views/projectNew/projectInfoSearchList.vue

方案:导出时按"是否勾选"分两种情况分别传参——勾选了就传 planIdList,未勾选(导出全部)则必须把 this.exportParam(当前查询条件)一并传给后端,而不是只传空的 planIdList
handleExport() {
  const msg = this.selectedData.length < 1 ? '是否导出所有数据至Excel' : '是否导出勾选的' + this.selectedData.length + '条数据至Excel'
  this.exportLoading = true
  this.$confirm(msg, '提示', {...}).then(() => {
    let payload
    if (this.selectedData.length > 0) {
      // 勾选了具体行:只按 planIdList 导出
      payload = { planIdList: this.selectedData.map(item => item.planId) }
    } else {
      // 未勾选:导出"当前查询条件"下的全部数据,而不是全网数据
      payload = { ...this.exportParam, pageNum: 1, pageSize: undefined }
    }
    projectBaseApi.exportProject(payload).then(res => {
      this.exportLoading = false
      this.createAloadTag(res.data ? res.data : res, '项目信息查询列表.xlsx')
    }).catch((error) => {
      this.$message.error('调用接口出错:' + error)
      this.exportLoading = false
    })
  }).catch(() => { this.exportLoading = false; this.selectedData = [] })
},
后端加固(建议一并处理):NewNePjController.exportProject() 不应信任一个"完全空"的查询条件当作合法请求,应在 condition 所有过滤字段(types/provinces/companyList/planIdList 等)均为空时拒绝导出或强制要求至少携带查询条件,避免同类"空条件=导出全表"的问题在其它导出入口重复出现:
if (CollectionUtils.isEmpty(condition.getPlanIdList())
        && (condition.getTypes() == null || condition.getTypes().length == 0)
        && CollectionUtils.isEmpty(condition.getProvinces())) {
    throw new IllegalArgumentException("导出条件不能为空,请先查询后再导出");
}
效果:导出结果始终与当前页面查询条件/分页栏统计一致,不再出现"页面22条、导出2257条"的数据错乱。