【feat】优化更新数据时的逻辑
This commit is contained in:
parent
bc9ed880ff
commit
da2ae51a90
@ -298,13 +298,12 @@ public class DataImportBatchServiceImpl implements DataImportBatchService {
|
|||||||
|
|
||||||
List<BatchInfo> batchInfos = BulkUtil.createBatchesFromCSVFile(bulkConnection, salesforceInsertJob, fullPath);
|
List<BatchInfo> batchInfos = BulkUtil.createBatchesFromCSVFile(bulkConnection, salesforceInsertJob, fullPath);
|
||||||
|
|
||||||
BulkUtil.closeJob(bulkConnection, salesforceInsertJob.getId());
|
|
||||||
|
|
||||||
BulkUtil.awaitCompletion(bulkConnection, salesforceInsertJob, batchInfos);
|
BulkUtil.awaitCompletion(bulkConnection, salesforceInsertJob, batchInfos);
|
||||||
|
|
||||||
sfNum = sfNum + checkInsertResults(bulkConnection, salesforceInsertJob, batchInfos, api, ids);
|
sfNum = sfNum + checkInsertResults(bulkConnection, salesforceInsertJob, batchInfos, api, ids);
|
||||||
|
|
||||||
new File(fullPath).delete();
|
BulkUtil.closeJob(bulkConnection, salesforceInsertJob.getId());
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("manualCreatedNewId error api:{}", api, e);
|
log.error("manualCreatedNewId error api:{}", api, e);
|
||||||
throw e;
|
throw e;
|
||||||
@ -528,8 +527,8 @@ public class DataImportBatchServiceImpl implements DataImportBatchService {
|
|||||||
} else if (!DataUtil.isUpdate(field) || (dataField.getIsCreateable() != null && !dataField.getIsCreateable())) {
|
} else if (!DataUtil.isUpdate(field) || (dataField.getIsCreateable() != null && !dataField.getIsCreateable())) {
|
||||||
continue;
|
continue;
|
||||||
} else if (StringUtils.isNotBlank(reference_to) && !"data_picklist".equals(reference_to)) {
|
} else if (StringUtils.isNotBlank(reference_to) && !"data_picklist".equals(reference_to)) {
|
||||||
if (!"null".equals(map.get(field)) && null != map.get(field) && !"OwnerId".equals(field)
|
if ( StringUtils.isNotEmpty(String.valueOf(map.get(field))) && !"OwnerId".equals(field)
|
||||||
|| !"Owner_Type".equals(field)) {
|
&& !"Owner_Type".equals(field)) {
|
||||||
//判断reference_to内是否包含User字符串
|
//判断reference_to内是否包含User字符串
|
||||||
if (reference_to.contains("User")) {
|
if (reference_to.contains("User")) {
|
||||||
reference_to = "User";
|
reference_to = "User";
|
||||||
@ -538,16 +537,14 @@ public class DataImportBatchServiceImpl implements DataImportBatchService {
|
|||||||
if (m != null && !m.isEmpty()) {
|
if (m != null && !m.isEmpty()) {
|
||||||
account.put(field, m.get("new_id"));
|
account.put(field, m.get("new_id"));
|
||||||
}else {
|
}else {
|
||||||
String message = "对象类型:" + api + "的数据:"+ m.get("Id") +"的引用对象:" + dataField.getReferenceTo() + "的数据:"+ map.get(field) +"不存在!"; String format = String.format("数据导入 error, api name: %s, \nparam: %s, \ncause:\n%s", api, com.alibaba.fastjson2.JSON.toJSONString(param, DataDumpParam.getFilter()), message);
|
String message = "对象类型:" + api + "的数据:"+ map.get("Id") +"的引用对象:" + dataField.getReferenceTo() + "的数据:"+ map.get(field) +"不存在!";
|
||||||
EmailUtil.send("DataDump ERROR", format);
|
EmailUtil.send("DataDump ERROR", message);
|
||||||
log.info(message);
|
log.info(message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (map.get(field) != null && StringUtils.isNotBlank(dataField.getSfType())) {
|
if (map.get(field) != null && StringUtils.isNotBlank(dataField.getSfType())) {
|
||||||
|
|
||||||
|
|
||||||
account.put(field, DataUtil.localBulkDataToSfData(dataField.getSfType(), String.valueOf(map.get(field))));
|
account.put(field, DataUtil.localBulkDataToSfData(dataField.getSfType(), String.valueOf(map.get(field))));
|
||||||
}else {
|
}else {
|
||||||
account.put(field, map.get(field));
|
account.put(field, map.get(field));
|
||||||
@ -568,12 +565,12 @@ public class DataImportBatchServiceImpl implements DataImportBatchService {
|
|||||||
|
|
||||||
List<BatchInfo> batchInfos = BulkUtil.createBatchesFromCSVFile(bulkConnection, salesforceInsertJob, fullPath);
|
List<BatchInfo> batchInfos = BulkUtil.createBatchesFromCSVFile(bulkConnection, salesforceInsertJob, fullPath);
|
||||||
|
|
||||||
BulkUtil.closeJob(bulkConnection, salesforceInsertJob.getId());
|
|
||||||
|
|
||||||
BulkUtil.awaitCompletion(bulkConnection, salesforceInsertJob, batchInfos);
|
BulkUtil.awaitCompletion(bulkConnection, salesforceInsertJob, batchInfos);
|
||||||
|
|
||||||
sfNum = sfNum + checkUpdateResults(bulkConnection, salesforceInsertJob, batchInfos,api);
|
sfNum = sfNum + checkUpdateResults(bulkConnection, salesforceInsertJob, batchInfos,api);
|
||||||
|
|
||||||
|
BulkUtil.closeJob(bulkConnection, salesforceInsertJob.getId());
|
||||||
|
|
||||||
new File(fullPath).delete();
|
new File(fullPath).delete();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
log.info(e.getMessage());
|
log.info(e.getMessage());
|
||||||
|
@ -742,41 +742,35 @@ public class DataImportNewServiceImpl implements DataImportNewService {
|
|||||||
String field = dataField.getField();
|
String field = dataField.getField();
|
||||||
String reference_to = dataField.getReferenceTo();
|
String reference_to = dataField.getReferenceTo();
|
||||||
|
|
||||||
|
String value = String.valueOf(map.get(field));
|
||||||
//根据旧sfid查找引用对象新sfid
|
//根据旧sfid查找引用对象新sfid
|
||||||
if (field.equals("Id")) {
|
if (field.equals("Id")) {
|
||||||
account.setId(String.valueOf(map.get("new_id")));
|
account.setId(String.valueOf(map.get("new_id")));
|
||||||
} else if (!DataUtil.isUpdate(field) || (dataField.getIsCreateable() != null && !dataField.getIsCreateable())) {
|
} else if (!DataUtil.isUpdate(field) || (dataField.getIsCreateable() != null && !dataField.getIsCreateable())) {
|
||||||
continue;
|
continue;
|
||||||
} else if (StringUtils.isNotBlank(reference_to) && !"data_picklist".equals(reference_to)) {
|
} else if (StringUtils.isNotBlank(reference_to) && !"data_picklist".equals(reference_to)) {
|
||||||
if (!"null".equals(map.get(field)) && null != map.get(field) && !"OwnerId".equals(field)
|
|
||||||
|| !"Owner_Type".equals(field)) {
|
if (!"null".equals(value) && StringUtils.isNotEmpty(value) && (!"OwnerId".equals(field)
|
||||||
|
&& !"Owner_Type".equals(field))) {
|
||||||
//判断reference_to内是否包含User字符串
|
//判断reference_to内是否包含User字符串
|
||||||
if (reference_to.contains("User")) {
|
if (reference_to.contains("User")) {
|
||||||
reference_to = "User";
|
reference_to = "User";
|
||||||
}
|
}
|
||||||
Map<String, Object> m = customMapper.getById("new_id", reference_to, String.valueOf(map.get(field)));
|
Map<String, Object> m = customMapper.getById("new_id", reference_to, value);
|
||||||
if (m != null && !m.isEmpty()) {
|
if (m != null && !m.isEmpty()) {
|
||||||
account.setField(field, m.get("new_id"));
|
account.setField(field, m.get("new_id"));
|
||||||
}else {
|
}else {
|
||||||
String message = "对象类型:" + api + "的数据:"+ m.get("Id") +"的引用对象:" + dataField.getReferenceTo() + "的数据:"+ map.get(field) +"不存在!"; String format = String.format("数据导入 error, api name: %s, \nparam: %s, \ncause:\n%s", api, com.alibaba.fastjson2.JSON.toJSONString(param, DataDumpParam.getFilter()), message);
|
String message = "对象类型:" + api + "的数据:"+ map.get("Id") +"的引用对象:" + dataField.getReferenceTo() + "的数据:"+ map.get(field) +"不存在!";
|
||||||
EmailUtil.send("DataDump ERROR", format);
|
EmailUtil.send("DataDump ERROR", message);
|
||||||
log.info(message);
|
log.info(message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (map.get(field) != null && StringUtils.isNotBlank(dataField.getSfType())) {
|
if (map.get(field) != null && StringUtils.isNotBlank(dataField.getSfType())) {
|
||||||
account.setField(field, DataUtil.localDataToSfData(dataField.getSfType(), String.valueOf(map.get(field))));
|
account.setField(field, DataUtil.localDataToSfData(dataField.getSfType(), value));
|
||||||
}else {
|
}else {
|
||||||
if (api.equals("Account")){
|
account.setField(field, map.get(field));
|
||||||
if ("1".equals(map.get("IsPersonAccount")) && field.equals("Name")){
|
|
||||||
continue;
|
|
||||||
}else if("0".equals(map.get("IsPersonAccount")) && field.equals("LastName")){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
account.setField(field, map.get(field));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user