【feat】 调整关联对象不存在问题异常,将错误信息写入数据库

This commit is contained in:
Kris 2025-10-10 10:21:37 +08:00
parent 9c7757a9c0
commit ceef113fa3
2 changed files with 53 additions and 16 deletions

View File

@ -878,10 +878,10 @@ public class DataImportBatchServiceImpl implements DataImportBatchService {
continue;
}
Map<String, Object> m = customMapper.getById("new_id", reference_to, value);
if (m != null && !m.isEmpty()) {
if (!m.isEmpty() && m.get("new_id") != null) {
account.put(field, m.get("new_id"));
}else {
message = "对象类型:" + api + "的数据:"+ map.get("Id") +"的引用对象:" + reference_to + "的数据:"+ map.get(field) +"不存在";
message = "对象类型:" + api + "的数据:"+ map.get("Id") +"的引用对象:" + reference_to + "的数据:"+ map.get(field) +"异常";
List<Map<String, Object>> maps = new ArrayList<>();
Map<String, Object> linkMap = new HashMap<>();
linkMap.put("key", "is_update");
@ -1336,10 +1336,10 @@ public class DataImportBatchServiceImpl implements DataImportBatchService {
}
Map<String, Object> m = customMapper.getById("new_id", reference_to, data.get(j - 1).get(dataField.getField()).toString());
if (m != null && !m.isEmpty()) {
if (!m.isEmpty() && m.get("new_id") != null) {
account.put(dataField.getField(), m.get("new_id"));
}else {
message = "对象类型:" + api + "的数据:"+ data.get(j - 1).get("Id") +"的引用对象:" + reference_to + "的数据:"+ data.get(j - 1).get(dataField.getField()) +"不存在";
message = "对象类型:" + api + "的数据:"+ data.get(j - 1).get("Id") +"的引用对象:" + reference_to + "的数据:"+ data.get(j - 1).get(dataField.getField()) +"异常";
log.info(message);
break;
}
@ -1353,6 +1353,12 @@ public class DataImportBatchServiceImpl implements DataImportBatchService {
}
}
if (message!=null){
List<Map<String, Object>> maps = new ArrayList<>();
Map<String, Object> linkMap1 = new HashMap<>();
linkMap1.put("key", "error_message");
linkMap1.put("value", message);
maps.add(linkMap1);
customMapper.updateById(api, maps, data.get(j-1).get("Id").toString());
continue;
}
if (dataObject.getIsEditable()) {
@ -1454,12 +1460,12 @@ public class DataImportBatchServiceImpl implements DataImportBatchService {
for (int j = 1; j <= size; j++) {
JSONObject account = new JSONObject();
for (DataField dataField : list) {
String message = null;
for (DataField dataField : list) {
if ("Owner_Type".equals(dataField.getField()) || "Id".equals(dataField.getField())){
continue;
}
if (dataField.getIsCreateable() !=null && dataField.getIsCreateable()) {
if ("reference".equals(dataField.getSfType()) && data.get(j - 1).get(dataField.getField()) != null){
//引用类型
@ -1485,7 +1491,7 @@ public class DataImportBatchServiceImpl implements DataImportBatchService {
if (m != null && !m.isEmpty()) {
account.put(dataField.getField(), m.get("new_id"));
}else {
String message = "对象类型:" + api + "的数据:"+ data.get(j - 1).get("Id") +"的引用对象:" + reference_to + "的数据:"+ data.get(j - 1).get(dataField.getField()) +"不存在";
message = "对象类型:" + api + "的数据:"+ data.get(j - 1).get("Id") +"的引用对象:" + reference_to + "的数据:"+ data.get(j - 1).get(dataField.getField()) +"异常";
EmailUtil.send("DataDump ERROR", message);
log.info(message);
return;
@ -1498,7 +1504,16 @@ public class DataImportBatchServiceImpl implements DataImportBatchService {
}
}
}
}
if (message!=null){
List<Map<String, Object>> maps = new ArrayList<>();
Map<String, Object> linkMap1 = new HashMap<>();
linkMap1.put("key", "error_message");
linkMap1.put("value", message);
maps.add(linkMap1);
customMapper.updateById(api, maps, data.get(j-1).get("Id").toString());
continue;
}
ids[j-1] = data.get(j-1).get("Id").toString();

View File

@ -856,10 +856,10 @@ public class DataImportNewServiceImpl implements DataImportNewService {
continue;
}
Map<String, Object> m = customMapper.getById("new_id", reference_to, value);
if (m != null && !m.isEmpty()) {
if (!m.isEmpty() && m.get("new_id") != null) {
account.setField(field, m.get("new_id"));
}else {
message = "对象类型:" + api + "的数据:"+ map.get("Id") +"的引用对象:" + reference_to + "的数据:"+ map.get(field) +"不存在";
message = "对象类型:" + api + "的数据:"+ map.get("Id") +"的引用对象:" + reference_to + "的数据:"+ map.get(field) +"异常";
List<Map<String, Object>> maps = new ArrayList<>();
Map<String, Object> linkMap = new HashMap<>();
linkMap.put("key", "is_update");
@ -1038,8 +1038,10 @@ public class DataImportNewServiceImpl implements DataImportNewService {
int j = 0;
try {
for (Map<String, Object> map : mapList) {
SObject account = new SObject();
account.setType(api);
String message = null;
//给对象赋值
for (DataField dataField : list) {
String field = dataField.getField();
@ -1071,11 +1073,10 @@ public class DataImportNewServiceImpl implements DataImportNewService {
continue;
}
Map<String, Object> m = customMapper.getById("new_id", reference_to, value);
if (m != null && !m.isEmpty()) {
if (!m.isEmpty() && m.get("new_id") != null) {
account.setField(field, m.get("new_id"));
}else {
String message = "对象类型:" + api + "的数据:"+ map.get("Id") +"的引用对象:" + reference_to + "的数据:"+ map.get(field) +"不存在!";
EmailUtil.send("DataDump ERROR", message);
message = "对象类型:" + api + "的数据:"+ map.get("Id") +"的引用对象:" + reference_to + "的数据:"+ map.get(field) +"异常!";
log.info(message);
break;
}
@ -1088,6 +1089,15 @@ public class DataImportNewServiceImpl implements DataImportNewService {
}
}
}
if (message!=null){
List<Map<String, Object>> maps = new ArrayList<>();
Map<String, Object> linkMap1 = new HashMap<>();
linkMap1.put("key", "error_message");
linkMap1.put("value", message);
maps.add(linkMap1);
customMapper.updateById(api, maps, map.get("Id").toString());
continue;
}
if (dataObject.getIsEditable()){
account.setField("old_owner_id__c", map.get("OwnerId"));
account.setField("old_sfdc_id__c", map.get("Id"));
@ -3495,10 +3505,10 @@ public class DataImportNewServiceImpl implements DataImportNewService {
continue;
}
Map<String, Object> m = customMapper.getById("new_id", reference_to, value);
if (m != null && !m.isEmpty()) {
if (!m.isEmpty() && m.get("new_id") != null) {
account.setField(field, m.get("new_id"));
}else {
message = "对象类型:" + api + "的数据:"+ data.get(j - 1).get("Id") +"的引用对象:" + reference_to + "的数据:"+ data.get(j - 1).get(field) +"不存在";
message = "对象类型:" + api + "的数据:"+ data.get(j - 1).get("Id") +"的引用对象:" + reference_to + "的数据:"+ data.get(j - 1).get(field) +"异常";
log.info(message);
break;
}
@ -3512,6 +3522,12 @@ public class DataImportNewServiceImpl implements DataImportNewService {
}
}
if (message!=null){
List<Map<String, Object>> maps = new ArrayList<>();
Map<String, Object> linkMap1 = new HashMap<>();
linkMap1.put("key", "error_message");
linkMap1.put("value", message);
maps.add(linkMap1);
customMapper.updateById(api, maps, data.get(j-1).get("Id").toString());
continue;
}
if (dataObject.getIsEditable()){
@ -3724,10 +3740,10 @@ public class DataImportNewServiceImpl implements DataImportNewService {
continue;
}
Map<String, Object> m = customMapper.getById("new_id", reference_to, value);
if (m != null && !m.isEmpty()) {
if (!m.isEmpty() && m.get("new_id") != null) {
account.setField(field, m.get("new_id"));
}else {
message = "对象类型:" + api + "的数据:"+ data.get(j - 1).get("Id") +"的引用对象:" + reference_to + "的数据:"+ data.get(j - 1).get(field) +"不存在";
message = "对象类型:" + api + "的数据:"+ data.get(j - 1).get("Id") +"的引用对象:" + reference_to + "的数据:"+ data.get(j - 1).get(field) +"异常";
log.info(message);
break;
}
@ -3741,6 +3757,12 @@ public class DataImportNewServiceImpl implements DataImportNewService {
}
}
if (message != null){
List<Map<String, Object>> maps = new ArrayList<>();
Map<String, Object> linkMap1 = new HashMap<>();
linkMap1.put("key", "error_message");
linkMap1.put("value", message);
maps.add(linkMap1);
customMapper.updateById(api, maps, data.get(j-1).get("Id").toString());
continue;
}
if (dataObject.getIsEditable()){