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


前端导出触发: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 条完全对不上。修复文件: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("导出条件不能为空,请先查询后再导出");
}