175 lines
5.1 KiB
Java
175 lines
5.1 KiB
Java
package com.celnet.datadump.job;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.celnet.datadump.param.SalesforceParam;
|
|
import com.celnet.datadump.service.CommonService;
|
|
import com.celnet.datadump.service.DataImportService;
|
|
import com.celnet.datadump.service.impl.DataImportServiceImpl;
|
|
import com.xxl.job.core.biz.model.ReturnT;
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
/**
|
|
* @author Red
|
|
* @description 数据迁移定时任务
|
|
* @date 2022/09/23
|
|
*/
|
|
@Component
|
|
@Slf4j
|
|
public class DataDumpJob {
|
|
|
|
@Autowired
|
|
private CommonService commonService;
|
|
|
|
@Autowired
|
|
private DataImportService dataImportService;
|
|
|
|
|
|
/**
|
|
* 创建api
|
|
*
|
|
* @param paramStr 参数json
|
|
* @return result
|
|
*/
|
|
@XxlJob("createApiJob")
|
|
public ReturnT<String> createApiJob(String paramStr) throws Exception {
|
|
log.info("createApiJob execute start ..................");
|
|
SalesforceParam param = new SalesforceParam();
|
|
try {
|
|
if (StringUtils.isNotBlank(paramStr)) {
|
|
param = JSON.parseObject(paramStr, SalesforceParam.class);
|
|
}
|
|
} catch (Throwable throwable) {
|
|
return new ReturnT<>(500, "参数解析失败!");
|
|
}
|
|
|
|
return commonService.createApi(param);
|
|
}
|
|
|
|
/**
|
|
* 存量任务
|
|
*
|
|
* @param paramStr 参数json
|
|
* @return result
|
|
*/
|
|
@XxlJob("dataDumpManualJob")
|
|
public ReturnT<String> dataDumpManualJob(String paramStr) throws Exception {
|
|
log.info("dataDumpManualJob execute start ..................");
|
|
SalesforceParam param = new SalesforceParam();
|
|
try {
|
|
if (StringUtils.isNotBlank(paramStr)) {
|
|
param = JSON.parseObject(paramStr, SalesforceParam.class);
|
|
}
|
|
} catch (Throwable throwable) {
|
|
return new ReturnT<>(500, "参数解析失败!");
|
|
}
|
|
param.setType(1);
|
|
// 参数转换
|
|
param.setBeginCreateDate(param.getBeginDate());
|
|
param.setEndCreateDate(param.getEndDate());
|
|
|
|
return commonService.dump(param);
|
|
}
|
|
|
|
|
|
/**
|
|
* 增量任务
|
|
*
|
|
* @param paramStr 参数json
|
|
* @return result
|
|
*/
|
|
@XxlJob("dataDumpIncrementJob")
|
|
public ReturnT<String> dataDumpIncrementJob(String paramStr) throws Exception {
|
|
log.info("dataDumpIncrementJob execute start ..................");
|
|
SalesforceParam param = new SalesforceParam();
|
|
try {
|
|
if (StringUtils.isNotBlank(paramStr)) {
|
|
param = JSON.parseObject(paramStr, SalesforceParam.class);
|
|
}
|
|
} catch (Throwable throwable) {
|
|
return new ReturnT<>(500, "参数解析失败!");
|
|
}
|
|
param.setType(2);
|
|
return commonService.increment(param);
|
|
}
|
|
|
|
|
|
/**
|
|
* 生成新sfid
|
|
*
|
|
* @param paramStr 参数json
|
|
* @return result
|
|
*/
|
|
@XxlJob("dataImportJob")
|
|
public ReturnT<String> dataImportJob(String paramStr) throws Exception {
|
|
log.info("dataImportJob execute start ..................");
|
|
SalesforceParam param = new SalesforceParam();
|
|
try {
|
|
if (StringUtils.isNotBlank(paramStr)) {
|
|
param = JSON.parseObject(paramStr, SalesforceParam.class);
|
|
}
|
|
} catch (Throwable throwable) {
|
|
return new ReturnT<>(500, "参数解析失败!");
|
|
}
|
|
param.setType(1);
|
|
// 参数转换
|
|
param.setBeginCreateDate(param.getBeginDate());
|
|
param.setEndCreateDate(param.getEndDate());
|
|
|
|
return dataImportService.immigration(param);
|
|
}
|
|
|
|
|
|
/**
|
|
* 更新目标org数据
|
|
*
|
|
* @param paramStr 参数json
|
|
* @return result
|
|
*/
|
|
@XxlJob("dataUpdateJob")
|
|
public ReturnT<String> dataUpdateJob(String paramStr) throws Exception {
|
|
log.info("dataUpdateJob execute start ..................");
|
|
SalesforceParam param = new SalesforceParam();
|
|
try {
|
|
if (StringUtils.isNotBlank(paramStr)) {
|
|
param = JSON.parseObject(paramStr, SalesforceParam.class);
|
|
}
|
|
} catch (Throwable throwable) {
|
|
return new ReturnT<>(500, "参数解析失败!");
|
|
}
|
|
param.setType(1);
|
|
// 参数转换
|
|
param.setBeginCreateDate(param.getBeginDate());
|
|
param.setEndCreateDate(param.getEndDate());
|
|
|
|
return dataImportService.immigrationUpdate(param);
|
|
}
|
|
|
|
/**
|
|
* 获取文件关联表
|
|
*
|
|
* @return result
|
|
*/
|
|
@XxlJob("getDocumentLinkJob")
|
|
public ReturnT<String> getDocumentLinkJob(String paramStr) throws Exception{
|
|
log.info("getDocumentLinkJob execute start ..................");
|
|
|
|
return commonService.getDocumentLink(paramStr);
|
|
}
|
|
|
|
/**
|
|
* 获取sf所有对象
|
|
*
|
|
* @return result
|
|
*/
|
|
@XxlJob("getAllApiJob")
|
|
public ReturnT<String> getAllApi(String paramStr) throws Exception {
|
|
log.info("getAllApiJob execute start ..................");
|
|
|
|
return commonService.getAllApi();
|
|
}
|
|
}
|