ariesy 导出数据不能超过5000条

release
yefei 2 years ago
parent bdf6605a4f
commit 41e1e2c7dc
  1. 29
      dxhy-core/src/main/java/com/dxhy/core/thread/FpcjhzExportThread.java

@ -169,14 +169,18 @@ public class FpcjhzExportThread extends BaseThread {
excelFile.append(ftpFileName.toString()); excelFile.append(ftpFileName.toString());
// 递归导出数据到excel // 递归导出数据到excel
this.cicleExport(pramsMap, default_curr, excelFile.toString(), jsonObject); String ftpFilePath = "";
String rtnMsg = this.cicleExport(pramsMap, default_curr, excelFile.toString(), jsonObject);
// FTP文件存储路径 if("ok".equals(rtnMsg)) {
String[] toDay = DateUtil.today().split("-"); // FTP文件存储路径
String ftpFilePath = fileService.getPathPrefix() + userName + "/" + "excelFile/" + toDay[0] + "/" String[] toDay = DateUtil.today().split("-");
+ toDay[1] + "/" + toDay[2] + "/" + ftpFileName.toString(); ftpFilePath = fileService.getPathPrefix() + userName + "/" + "excelFile/" + toDay[0] + "/"
// 文件上传ftp + toDay[1] + "/" + toDay[2] + "/" + ftpFileName.toString();
fileService.uploadFile(ftpFilePath, excelFile.toString()); // 文件上传ftp
fileService.uploadFile(ftpFilePath, excelFile.toString());
}else{
ftpFilePath = rtnMsg;
}
// 设置成功消息内容 // 设置成功消息内容
msg.put("title", super.getSuccTitle(title)); msg.put("title", super.getSuccTitle(title));
@ -222,12 +226,15 @@ public class FpcjhzExportThread extends BaseThread {
* *
*/ */
private boolean cicleExport(Map<String, Object> pramsMap, int curr, String excelFile, JSONObject jsonObject) private String cicleExport(Map<String, Object> pramsMap, int curr, String excelFile, JSONObject jsonObject)
throws Exception { throws Exception {
// 查询指定页数的数据 // 查询指定页数的数据
JSONObject pageData = fpcjService.selectByGfshAndCjrq(pramsMap, curr, default_size); JSONObject pageData = fpcjService.selectByGfshAndCjrq(pramsMap, curr, default_size);
boolean hasNext = pageData.getBooleanValue("hasNext"); boolean hasNext = pageData.getBooleanValue("hasNext");
List<FpcjCjhzRespVO> dataList = (List<FpcjCjhzRespVO>)pageData.get("datalist"); List<FpcjCjhzRespVO> dataList = (List<FpcjCjhzRespVO>)pageData.get("datalist");
if(dataList.size() > 5000){
return "数据不能超过5000条";
}
boolean firstPage = false; boolean firstPage = false;
if (curr == default_curr) { if (curr == default_curr) {
@ -243,7 +250,7 @@ public class FpcjhzExportThread extends BaseThread {
// 写入当前页数据 // 写入当前页数据
ExcelPoiUtil.exportListArrayToExcel1(excelFile, title, jsonObject, dataList, firstPage, false); ExcelPoiUtil.exportListArrayToExcel1(excelFile, title, jsonObject, dataList, firstPage, false);
// 更新页数 // 更新页数
return cicleExport(pramsMap, nextPage, excelFile, jsonObject); cicleExport(pramsMap, nextPage, excelFile, jsonObject);
} else { } else {
// 写入最后一页数据 // 写入最后一页数据
FpcjCjhzRespVO vo = new FpcjCjhzRespVO(); FpcjCjhzRespVO vo = new FpcjCjhzRespVO();
@ -253,7 +260,7 @@ public class FpcjhzExportThread extends BaseThread {
vo.setSe(hjse); vo.setSe(hjse);
dataList.add(vo); dataList.add(vo);
ExcelPoiUtil.exportListArrayToExcel1(excelFile, title, jsonObject, dataList, firstPage, true); ExcelPoiUtil.exportListArrayToExcel1(excelFile, title, jsonObject, dataList, firstPage, true);
return hasNext;
} }
return "ok";
} }
} }

Loading…
Cancel
Save