|
@@ -1,6 +1,7 @@
|
|
package com.boman.file.service;
|
|
package com.boman.file.service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.boman.common.core.utils.SecurityUtils;
|
|
import com.boman.common.core.utils.obj.ObjectUtils;
|
|
import com.boman.common.core.utils.obj.ObjectUtils;
|
|
import com.boman.common.core.utils.poi.ExcelUtil;
|
|
import com.boman.common.core.utils.poi.ExcelUtil;
|
|
import com.boman.common.redis.RedisKey;
|
|
import com.boman.common.redis.RedisKey;
|
|
@@ -31,6 +32,7 @@ import java.io.File;
|
|
import java.io.FileOutputStream;
|
|
import java.io.FileOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
import static com.boman.common.core.utils.obj.ObjectUtils.map;
|
|
import static com.boman.common.core.utils.obj.ObjectUtils.map;
|
|
|
|
|
|
@@ -46,6 +48,7 @@ public class LocalSysFileServiceImpl implements ISysFileService
|
|
{
|
|
{
|
|
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(LocalSysFileServiceImpl.class);
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(LocalSysFileServiceImpl.class);
|
|
|
|
+ public static final String DOWNLOADING = "downloading";
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private RemoteObjService remoteObjService;
|
|
private RemoteObjService remoteObjService;
|
|
@@ -201,26 +204,35 @@ public class LocalSysFileServiceImpl implements ISysFileService
|
|
ExcelUtil<JSONObject> util = new ExcelUtil<>(JSONObject.class);
|
|
ExcelUtil<JSONObject> util = new ExcelUtil<>(JSONObject.class);
|
|
|
|
|
|
ThreadPoolService.execute(() -> {
|
|
ThreadPoolService.execute(() -> {
|
|
- List<Map<String, Object>> list = null;
|
|
|
|
|
|
+ List<Map<String, Object>> list;
|
|
|
|
+ int size = 0;
|
|
if (BooleanUtils.isTrue(empty)) {
|
|
if (BooleanUtils.isTrue(empty)) {
|
|
list = new ArrayList<>(0);
|
|
list = new ArrayList<>(0);
|
|
} else {
|
|
} else {
|
|
LOGGER.info("开始查询, 线程名称: {}", Thread.currentThread().getName());
|
|
LOGGER.info("开始查询, 线程名称: {}", Thread.currentThread().getName());
|
|
long currentTimeMillis = System.currentTimeMillis();
|
|
long currentTimeMillis = System.currentTimeMillis();
|
|
list = getData(dto, tableName, columns);
|
|
list = getData(dto, tableName, columns);
|
|
- LOGGER.info("查询到的数据长度为: {}", list.size());
|
|
|
|
- LOGGER.info("查询耗时:{}秒", (System.currentTimeMillis() - currentTimeMillis) / 1000);
|
|
|
|
|
|
+ size = list.size();
|
|
|
|
+ LOGGER.info("查询到的数据长度为: {}, 查询耗时:{}秒", size, (System.currentTimeMillis() - currentTimeMillis) / 1000);
|
|
}
|
|
}
|
|
|
|
|
|
try {
|
|
try {
|
|
util.asyncExportExcelCommon(new FileOutputStream(file), list, "sheet1", columns, empty, false);
|
|
util.asyncExportExcelCommon(new FileOutputStream(file), list, "sheet1", columns, empty, false);
|
|
|
|
+ long timeout = 1L;
|
|
|
|
+ if (size > 100000 && size < 500000) {
|
|
|
|
+ timeout = 2L;
|
|
|
|
+ } else if(size > 500000){
|
|
|
|
+ timeout = 4L;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ redisService.setCacheObject(RedisKey.ASYNC_DOWNLOAD_SIGN + SecurityUtils.getUsername(), DOWNLOADING, timeout, TimeUnit.MINUTES);
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
LOGGER.error("导出失败", e);
|
|
LOGGER.error("导出失败", e);
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
- redisService.setCacheObject("",null);
|
|
|
|
|
|
+
|
|
return AjaxResult.success("成功", fileStaticPath);
|
|
return AjaxResult.success("成功", fileStaticPath);
|
|
}
|
|
}
|
|
|
|
|