【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.SalesforceTargetConnect;
|
||||
import com.celnet.datadump.entity.*;
|
||||
import com.celnet.datadump.enums.FileType;
|
||||
import com.celnet.datadump.global.Const;
|
||||
import com.celnet.datadump.global.SystemConfigCode;
|
||||
import com.celnet.datadump.mapper.CustomMapper;
|
||||
@ -142,21 +143,17 @@ public class CommonBatchServiceImpl implements CommonBatchService {
|
||||
|
||||
@Override
|
||||
public ReturnT<String> dumpBigObject(SalesforceParam param) throws Exception {
|
||||
List<Future<?>> futures = Lists.newArrayList();
|
||||
try {
|
||||
if (StringUtils.isNotBlank(param.getApi())) {
|
||||
// 手动任务
|
||||
ReturnT<String> result = manualBigObjectDump(param, futures);
|
||||
ReturnT<String> result = manualBigObjectDump(param);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return ReturnT.SUCCESS;
|
||||
} catch (Throwable throwable) {
|
||||
salesforceExecutor.remove(futures.toArray(new Future<?>[]{}));
|
||||
log.error("dump error", throwable);
|
||||
throw throwable;
|
||||
}
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
|
||||
@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();
|
||||
|
||||
@ -215,15 +212,20 @@ public class CommonBatchServiceImpl implements CommonBatchService {
|
||||
QueryResultList queryResultList = bulkConnect.getQueryResultList(job.getId(), batchInfo.getId());
|
||||
log.info("获取查询结果列表, 结果数量: {}", queryResultList.getResult().length);
|
||||
|
||||
if (Const.FILE_TYPE == FileType.SERVER) {
|
||||
// 检测路径是否存在 不存在则创建
|
||||
Path apiPath = Paths.get(param.getApi());
|
||||
if (!Files.exists(apiPath)) {
|
||||
Files.createDirectories(apiPath);
|
||||
log.info("创建目录: {}", apiPath.toAbsolutePath());
|
||||
File excel = new File(Const.SERVER_FILE_PATH + "/" + api);
|
||||
if (!excel.exists()) {
|
||||
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
|
||||
|
||||
int fileIndex = 0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user