【feat】计划重构获取SFID方法,同时增加错误日志记录功能。

This commit is contained in:
Kris 2025-04-30 14:40:07 +08:00
parent 72fbd0fa94
commit cce039dfcf
12 changed files with 84 additions and 35 deletions

View File

@ -2,7 +2,7 @@
# xxl job数据库链接
dbUrl="jdbc:mysql://127.0.0.1:3306/data-dump-xxl-job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai"
dbUsername="root"
dbPassword="shida@202502.Celnet"
dbPassword="celnet@2025.bln"
#dbUrl="jdbc:mysql://127.0.0.113306/data-dump-xxl-job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai"
#dbUsername="msg"
#dbPassword="msg@2021"

View File

@ -122,6 +122,31 @@ public class DataDumpJob {
return dataImportService.immigration(param);
}
/**
* 生成新SFID
* @param paramStr
* @return
* @throws Exception
*/
@XxlJob("dataImportJobNew")
public ReturnT<String> dataImportJobNew(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.immigrationNew(param);
}
/**
* 更新目标org数据
*

View File

@ -14,5 +14,8 @@ public interface DataImportService {
ReturnT<String> immigration(SalesforceParam param) throws Exception;
ReturnT<String> immigrationNew(SalesforceParam param) throws Exception;
ReturnT<String> immigrationUpdate(SalesforceParam param) throws Exception;
}

View File

@ -91,6 +91,28 @@ public class DataImportServiceImpl implements DataImportService {
}
}
@Override
public ReturnT<String> immigrationNew(SalesforceParam param) throws Exception {
List<Future<?>> futures = Lists.newArrayList();
try {
if (StringUtils.isNotBlank(param.getApi())) {
// 手动任务
ReturnT<String> result = manualImmigration(param, futures);
if (result != null) {
return result;
}
} else {
// 自动任务
autoImmigration(param, futures);
}
return ReturnT.SUCCESS;
} catch (Exception exception) {
salesforceExecutor.remove(futures.toArray(new Future<?>[]{}));
log.error("immigration error", exception);
throw exception;
}
}
@Override
public ReturnT<String> manualImmigration(SalesforceParam param, List<Future<?>> futures) throws Exception {
List<String> apis;
@ -314,21 +336,21 @@ public class DataImportServiceImpl implements DataImportService {
}
}
//object类型转Date类型
// Date date;
// try {
// date = sdf.parse(String.valueOf(data.get(j - 1).get("CreatedDate")));
// }catch (ParseException e){
// //解决当时间秒为0时转换秒精度丢失问题
// date = sdf.parse(data.get(j - 1).get("CreatedDate")+":00");
// }
// Calendar calendar = Calendar.getInstance();
// calendar.setTime(date);
// account.setField("CreatedDate", calendar);
// log.info("-----打印时间参数-----" + calendar);
// Map<String, Object> CreatedByIdMap = customMapper.getById("new_id", "User", data.get(j-1).get("CreatedById").toString());
// if(CreatedByIdMap.get("new_id") != null && StringUtils.isNotEmpty(CreatedByIdMap.get("new_id").toString())){
// account.setField("CreatedById", CreatedByIdMap.get("new_id"));
// }
Date date;
try {
date = sdf.parse(String.valueOf(data.get(j - 1).get("CreatedDate")));
}catch (ParseException e){
//解决当时间秒为0时转换秒精度丢失问题
date = sdf.parse(data.get(j - 1).get("CreatedDate")+":00");
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
account.setField("CreatedDate", calendar);
log.info("-----打印时间参数-----" + calendar);
Map<String, Object> CreatedByIdMap = customMapper.getById("new_id", "User", data.get(j-1).get("CreatedById").toString());
if(CreatedByIdMap.get("new_id") != null && StringUtils.isNotEmpty(CreatedByIdMap.get("new_id").toString())){
account.setField("CreatedById", CreatedByIdMap.get("new_id"));
}
if (api.equals("Task")){
account.setField("TaskSubtype",data.get(j - 1).get("TaskSubtype"));
}
@ -345,7 +367,6 @@ public class DataImportServiceImpl implements DataImportService {
}
}
try {
log.info("打印sf对象数据------"+ JSONArray.toJSONString(accounts[0]));
SaveResult[] saveResults = partnerConnection.create(accounts);
log.info("sf return saveResults------"+ JSONArray.toJSONString(saveResults));
int index = 0;

View File

@ -2,9 +2,9 @@ spring:
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/shida?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
url: jdbc:mysql://127.0.0.1:3306/cook?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: shida@202502.Celnet
password: celnet@2025.bln
# url: jdbc:mysql://183.6.105.131:13306/zhonghe_test?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
# username: root
# password: Celnet@2022
@ -19,8 +19,8 @@ spring:
#sf webservice配置
sf:
# 附件下载url
file-download-url: https://zhonghe.my.salesforce.com
file-upload-url: https://yihui-medical.my.sfcrmproducts.cn
file-download-url: https://cookmedicalasia.my.salesforce.com
file-upload-url: https://cookchina--sandbox.sandbox.my.sfcrmproducts.cn
# #线程数
# executor-size: 5
# list:

View File

@ -2,9 +2,9 @@ spring:
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/shida?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
url: jdbc:mysql://127.0.0.1:3306/cook?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root
password: shida@202502.Celnet
password: celnet@2025.bln
mail:
host: smtp.mxhichina.com
port: 465
@ -16,8 +16,8 @@ spring:
#sf webservice配置
sf:
# 附件下载url
file-download-url: https://starrapid.my.salesforce.com
file-upload-url: https://procision.my.salesforce.com
file-download-url: https://cookmedicalasia.my.salesforce.com
file-upload-url: https://cookchina--sandbox.sandbox.my.sfcrmproducts.cn
#线程数
executor-size: 5
list:

View File

@ -2,9 +2,9 @@ spring:
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/shida?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
url: jdbc:mysql://127.0.0.1:3306/cook?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root
password: shida@202502.Celnet
password: celnet@2025.bln
mail:
host: smtp.163.com
port: 465
@ -16,8 +16,8 @@ spring:
#sf webservice配置
sf:
# 附件下载url
file-download-url: https://starrapid.lightning.force.com/
file-upload-url: https://yihui-medical.my.sfcrmproducts.cn
file-download-url: https://cookmedicalasia.my.salesforce.com
file-upload-url: https://cookchina--sandbox.sandbox.my.sfcrmproducts.cn
#线程数
executor-size: 5
list:

View File

@ -2,9 +2,9 @@ spring:
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/shida?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
url: jdbc:mysql://127.0.0.1:3306/cook?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: shida@202502.Celnet
password: celnet@2025.bln
# url: jdbc:mysql://183.6.105.131:13306/zhonghe_test?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
# username: root
# password: Celnet@2022

View File

@ -2,9 +2,9 @@ spring:
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/shida?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
url: jdbc:mysql://127.0.0.1:3306/cook?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root
password: shida@202502.Celnet
password: celnet@2025.bln
mail:
host: smtp.mxhichina.com
port: 465

View File

@ -2,9 +2,9 @@ spring:
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/shida?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
url: jdbc:mysql://127.0.0.1:3306/cook?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root
password: shida@202502.Celnet
password: celnet@2025.bln
mail:
host: smtp.163.com
port: 465

Binary file not shown.

Binary file not shown.