From 33d23213dd19b808a0c9c4cc254cd7cd65099dad Mon Sep 17 00:00:00 2001 From: Kris <2893855659@qq.com> Date: Fri, 10 Oct 2025 10:21:37 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90feat=E3=80=91=20=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E5=85=B3=E8=81=94=E5=AF=B9=E8=B1=A1=E4=B8=8D=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=BC=82=E5=B8=B8=EF=BC=8C=E5=B0=86=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E4=BF=A1=E6=81=AF=E5=86=99=E5=85=A5=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit ceef113fa383b1a147cb97d7373160b26a153c39) --- .../impl/DataImportBatchServiceImpl.java | 29 ++++++++++---- .../impl/DataImportNewServiceImpl.java | 40 ++++++++++++++----- 2 files changed, 53 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/celnet/datadump/service/impl/DataImportBatchServiceImpl.java b/src/main/java/com/celnet/datadump/service/impl/DataImportBatchServiceImpl.java index 60e7f87..ffa7b43 100644 --- a/src/main/java/com/celnet/datadump/service/impl/DataImportBatchServiceImpl.java +++ b/src/main/java/com/celnet/datadump/service/impl/DataImportBatchServiceImpl.java @@ -878,10 +878,10 @@ public class DataImportBatchServiceImpl implements DataImportBatchService { continue; } Map 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> maps = new ArrayList<>(); Map linkMap = new HashMap<>(); linkMap.put("key", "is_update"); @@ -1336,10 +1336,10 @@ public class DataImportBatchServiceImpl implements DataImportBatchService { } Map 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> maps = new ArrayList<>(); + Map 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> maps = new ArrayList<>(); + Map 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(); diff --git a/src/main/java/com/celnet/datadump/service/impl/DataImportNewServiceImpl.java b/src/main/java/com/celnet/datadump/service/impl/DataImportNewServiceImpl.java index 7dc8990..33f8c7e 100644 --- a/src/main/java/com/celnet/datadump/service/impl/DataImportNewServiceImpl.java +++ b/src/main/java/com/celnet/datadump/service/impl/DataImportNewServiceImpl.java @@ -856,10 +856,10 @@ public class DataImportNewServiceImpl implements DataImportNewService { continue; } Map 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> maps = new ArrayList<>(); Map linkMap = new HashMap<>(); linkMap.put("key", "is_update"); @@ -1038,8 +1038,10 @@ public class DataImportNewServiceImpl implements DataImportNewService { int j = 0; try { for (Map 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 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> maps = new ArrayList<>(); + Map 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 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> maps = new ArrayList<>(); + Map 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 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> maps = new ArrayList<>(); + Map 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()){