【feat】 bigobject文件下载初版
This commit is contained in:
parent
ff6f9c0ee1
commit
89dcbb48bd
@ -10,6 +10,7 @@ import com.celnet.datadump.config.SalesforceConnect;
|
|||||||
import com.celnet.datadump.config.SalesforceExecutor;
|
import com.celnet.datadump.config.SalesforceExecutor;
|
||||||
import com.celnet.datadump.config.SalesforceTargetConnect;
|
import com.celnet.datadump.config.SalesforceTargetConnect;
|
||||||
import com.celnet.datadump.entity.*;
|
import com.celnet.datadump.entity.*;
|
||||||
|
import com.celnet.datadump.enums.FileType;
|
||||||
import com.celnet.datadump.global.Const;
|
import com.celnet.datadump.global.Const;
|
||||||
import com.celnet.datadump.global.SystemConfigCode;
|
import com.celnet.datadump.global.SystemConfigCode;
|
||||||
import com.celnet.datadump.mapper.CustomMapper;
|
import com.celnet.datadump.mapper.CustomMapper;
|
||||||
@ -142,21 +143,17 @@ public class CommonBatchServiceImpl implements CommonBatchService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReturnT<String> dumpBigObject(SalesforceParam param) throws Exception {
|
public ReturnT<String> dumpBigObject(SalesforceParam param) throws Exception {
|
||||||
List<Future<?>> futures = Lists.newArrayList();
|
|
||||||
try {
|
try {
|
||||||
if (StringUtils.isNotBlank(param.getApi())) {
|
// 手动任务
|
||||||
// 手动任务
|
ReturnT<String> result = manualBigObjectDump(param);
|
||||||
ReturnT<String> result = manualBigObjectDump(param, futures);
|
if (result != null) {
|
||||||
if (result != null) {
|
return result;
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ReturnT.SUCCESS;
|
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
salesforceExecutor.remove(futures.toArray(new Future<?>[]{}));
|
|
||||||
log.error("dump error", throwable);
|
log.error("dump error", throwable);
|
||||||
throw throwable;
|
throw throwable;
|
||||||
}
|
}
|
||||||
|
return ReturnT.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -178,7 +175,7 @@ public class CommonBatchServiceImpl implements CommonBatchService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReturnT<String> manualBigObjectDump(SalesforceParam param, List<Future<?>> futures) throws Exception {
|
private ReturnT<String> manualBigObjectDump(SalesforceParam param) throws Exception {
|
||||||
|
|
||||||
String api = param.getApi();
|
String api = param.getApi();
|
||||||
|
|
||||||
@ -215,15 +212,20 @@ public class CommonBatchServiceImpl implements CommonBatchService {
|
|||||||
QueryResultList queryResultList = bulkConnect.getQueryResultList(job.getId(), batchInfo.getId());
|
QueryResultList queryResultList = bulkConnect.getQueryResultList(job.getId(), batchInfo.getId());
|
||||||
log.info("获取查询结果列表, 结果数量: {}", queryResultList.getResult().length);
|
log.info("获取查询结果列表, 结果数量: {}", queryResultList.getResult().length);
|
||||||
|
|
||||||
// 检测路径是否存在 不存在则创建
|
if (Const.FILE_TYPE == FileType.SERVER) {
|
||||||
Path apiPath = Paths.get(param.getApi());
|
// 检测路径是否存在 不存在则创建
|
||||||
if (!Files.exists(apiPath)) {
|
File excel = new File(Const.SERVER_FILE_PATH + "/" + api);
|
||||||
Files.createDirectories(apiPath);
|
if (!excel.exists()) {
|
||||||
log.info("创建目录: {}", apiPath.toAbsolutePath());
|
log.info("创建API目录: {}", excel.getAbsolutePath());
|
||||||
|
boolean mkdir = excel.mkdir();
|
||||||
|
if (!mkdir) {
|
||||||
|
log.info("创建文件存储目录失败!");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 使用确定性命名策略,避免使用随机时间戳
|
// 使用确定性命名策略,避免使用随机时间戳
|
||||||
String fileName = param.getApi() + "/" + DateFormatUtils.format(new Date(), "yyyyMMddHHmmss");
|
String fileName = Const.SERVER_FILE_PATH + "/" + api+ "/" + DateFormatUtils.format(new Date(), "yyyyMMddHHmmss");
|
||||||
final long maxFileSize = 50 * 1024 * 1024; // 50MB
|
final long maxFileSize = 50 * 1024 * 1024; // 50MB
|
||||||
|
|
||||||
int fileIndex = 0;
|
int fileIndex = 0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user