【feat】支持SF底层对象Update数据时,无需写入Old ID和Old Owner ID
This commit is contained in:
parent
1e91bbb67b
commit
27eb434539
@ -772,9 +772,16 @@ public class CommonServiceImpl implements CommonService {
|
||||
paramwhoMap.put("value", jsonObject.get("Who_Type"));
|
||||
maps.add(paramwhoMap);
|
||||
Map<String, Object> paramwhatMap = Maps.newHashMap();
|
||||
paramwhoMap.put("key", "WhatId_Type__c");
|
||||
paramwhoMap.put("value", jsonObject.get("What_Type"));
|
||||
maps.add(paramwhoMap);
|
||||
paramwhatMap.put("key", "WhatId_Type__c");
|
||||
paramwhatMap.put("value", jsonObject.get("What_Type"));
|
||||
maps.add(paramwhatMap);
|
||||
}
|
||||
|
||||
if ("TaskRelation".equals(api) || "EventRelation".equals(api)){
|
||||
Map<String, Object> paramMap = Maps.newHashMap();
|
||||
paramMap.put("key", "Relation_Type__c");
|
||||
paramMap.put("value", jsonObject.get("Relation_Type"));
|
||||
maps.add(paramMap);
|
||||
}
|
||||
|
||||
//附件关联表 插入更新时给关联对象赋值
|
||||
@ -958,6 +965,18 @@ public class CommonServiceImpl implements CommonService {
|
||||
LinkedMap1.put("comment", "whoId关联对象");
|
||||
LinkedMap1.put("name", "WhoId_Type__c");
|
||||
list.add(LinkedMap1);
|
||||
|
||||
// DataField dataField = new DataField();
|
||||
// dataField.setApi(apiName);
|
||||
// dataField.setField("WhoId_Type__c");
|
||||
// dataField.setName("whoId关联对象");
|
||||
// fieldList.add(dataField);
|
||||
//
|
||||
// DataField dataField1 = new DataField();
|
||||
// dataField1.setApi(apiName);
|
||||
// dataField1.setField("WhatId_Type__c");
|
||||
// dataField1.setName("whatId关联对象");
|
||||
// fieldList.add(dataField1);
|
||||
}
|
||||
|
||||
if ("TaskRelation".equals(apiName) || "EventRelation".equals(apiName)){
|
||||
@ -966,6 +985,12 @@ public class CommonServiceImpl implements CommonService {
|
||||
LinkedMap.put("comment", "relationId关联对象");
|
||||
LinkedMap.put("name", "Relation_Type__c");
|
||||
list.add(LinkedMap);
|
||||
|
||||
// DataField dataField = new DataField();
|
||||
// dataField.setApi(apiName);
|
||||
// dataField.setField("Relation_Type__c");
|
||||
// dataField.setName("relationId关联对象");
|
||||
// fieldList.add(dataField);
|
||||
}
|
||||
|
||||
if ("ContentDocumentLink".equals(apiName)){
|
||||
@ -986,11 +1011,11 @@ public class CommonServiceImpl implements CommonService {
|
||||
LinkedMap.put("name", "Parent_Type");
|
||||
list.add(LinkedMap);
|
||||
|
||||
DataField dataField = new DataField();
|
||||
dataField.setApi(apiName);
|
||||
dataField.setField("Parent.Type");
|
||||
dataField.setName("关联对象");
|
||||
fieldList.add(dataField);
|
||||
// DataField dataField = new DataField();
|
||||
// dataField.setApi(apiName);
|
||||
// dataField.setField("Parent.Type");
|
||||
// dataField.setName("关联对象");
|
||||
// fieldList.add(dataField);
|
||||
}
|
||||
|
||||
customMapper.createTable(apiName, label, list, index);
|
||||
|
@ -234,11 +234,19 @@ public class DataImportBatchServiceImpl implements DataImportBatchService {
|
||||
|| "Id".equals(dataField.getField())){
|
||||
continue;
|
||||
}
|
||||
if (dataField.getIsCreateable() && !dataField.getIsNillable() && !dataField.getIsDefaultedOnCreate()) {
|
||||
if (dataField.getIsCreateable() !=null && dataField.getIsCreateable() && !dataField.getIsNillable() && !dataField.getIsDefaultedOnCreate()) {
|
||||
if ("reference".equals(dataField.getSfType())){
|
||||
String reference = dataField.getReferenceTo();
|
||||
if (reference == null){
|
||||
if (StringUtils.isEmpty(reference)){
|
||||
if ("ParentId".equals(dataField.getField())){
|
||||
reference = data.get(j-1).get("Parent_Type").toString();
|
||||
}else if ("RelationId".equals(dataField.getField())){
|
||||
reference = data.get(j-1).get("Relation_Type__c").toString();
|
||||
}else if ("WhatId".equals(dataField.getField())){
|
||||
reference = data.get(j-1).get("WhatId_Type__c").toString();
|
||||
}else if ("WhoId".equals(dataField.getField())){
|
||||
reference = data.get(j-1).get("WhoId_Type__c").toString();
|
||||
}
|
||||
}
|
||||
List<Map<String, Object>> referenceMap = customMapper.list("new_id", reference, "new_id is not null limit 1");
|
||||
if (referenceMap.isEmpty()){
|
||||
@ -362,7 +370,7 @@ public class DataImportBatchServiceImpl implements DataImportBatchService {
|
||||
index ++;
|
||||
log.info("Created Success row with id " + id);
|
||||
} else if (!insertStatus) {
|
||||
log.info("Created Fail with error: " + error);
|
||||
log.error("Created Fail with error: " + error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -626,7 +634,7 @@ public class DataImportBatchServiceImpl implements DataImportBatchService {
|
||||
index ++;
|
||||
log.info("Update Success row with id " + id);
|
||||
} else {
|
||||
log.info("Update Fail with error: " + error);
|
||||
log.error("Update Fail with error: " + error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -767,17 +767,6 @@ public class DataImportNewServiceImpl implements DataImportNewService {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ("WhatId_Type__c".equals(field) || "WhoId_Type__c".equals(field) || "Relation_Type__c".equals(field)){
|
||||
Map<String, Object> m = customMapper.getById("new_id", String.valueOf(map.get(field)), value);
|
||||
if (m != null && !m.isEmpty()) {
|
||||
account.setField(field, m.get("new_id"));
|
||||
}else {
|
||||
String message = "对象类型:" + api + "的数据:"+ map.get("Id") +"的引用对象:" + dataField.getReferenceTo() + "的数据:"+ map.get(field) +"不存在!";
|
||||
EmailUtil.send("DataDump ERROR", message);
|
||||
log.info(message);
|
||||
return;
|
||||
}
|
||||
}else {
|
||||
if (map.get(field) != null && StringUtils.isNotBlank(dataField.getSfType())) {
|
||||
account.setField(field, DataUtil.localDataToSfData(dataField.getSfType(), value));
|
||||
}else {
|
||||
@ -785,7 +774,6 @@ public class DataImportNewServiceImpl implements DataImportNewService {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dataObject.getIsEditable()){
|
||||
account.setField("old_owner_id__c", map.get("OwnerId"));
|
||||
account.setField("old_sfdc_id__c", map.get("Id"));
|
||||
|
@ -296,12 +296,20 @@ public class DataImportServiceImpl implements DataImportService {
|
||||
|| "Id".equals(dataField.getField())){
|
||||
continue;
|
||||
}
|
||||
if (dataField.getIsCreateable() && !dataField.getIsNillable() && !dataField.getIsDefaultedOnCreate()) {
|
||||
if (dataField.getIsCreateable() != null && dataField.getIsCreateable() && !dataField.getIsNillable() && !dataField.getIsDefaultedOnCreate()) {
|
||||
if ("reference".equals(dataField.getSfType())){
|
||||
log.info("----------" + dataField.getField() + " ------------" + dataField.getSfType());
|
||||
String reference = dataField.getReferenceTo();
|
||||
if (reference == null){
|
||||
if (StringUtils.isEmpty(reference)){
|
||||
if ("ParentId".equals(dataField.getField())){
|
||||
reference = data.get(j-1).get("Parent_Type").toString();
|
||||
}else if ("RelationId".equals(dataField.getField())){
|
||||
reference = data.get(j-1).get("Relation_Type__c").toString();
|
||||
}else if ("WhatId".equals(dataField.getField())){
|
||||
reference = data.get(j-1).get("WhatId_Type__c").toString();
|
||||
}else if ("WhoId".equals(dataField.getField())){
|
||||
reference = data.get(j-1).get("WhoId_Type__c").toString();
|
||||
}
|
||||
}
|
||||
List<Map<String, Object>> referenceMap = customMapper.list("new_id", reference, "new_id is not null limit 1");
|
||||
if (referenceMap.isEmpty()){
|
||||
@ -326,7 +334,6 @@ public class DataImportServiceImpl implements DataImportService {
|
||||
account.setField(dataField.getField(), DataUtil.fieldTypeToSf(dataField));
|
||||
}
|
||||
}
|
||||
if (!api.equals("Product2")){
|
||||
//object类型转Date类型
|
||||
Date date;
|
||||
try {
|
||||
@ -342,19 +349,7 @@ public class DataImportServiceImpl implements DataImportService {
|
||||
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"));
|
||||
}
|
||||
|
||||
if (api.equals("Event")){
|
||||
account.setField("EventSubtype", String.valueOf(data.get(j - 1).get("EventSubtype")));
|
||||
// account.setField("IsRecurrence", String.valueOf(data.get(j - 1).get("IsRecurrence")));
|
||||
}
|
||||
// if (api.equals("Account")){
|
||||
// Map<String, Object> referenceMap = customMapper.list("new_id","RecordType", "new_id is not null and id = '"+ data.get(j - 1).get("RecordTypeId")+"' limit 1").get(0);
|
||||
// account.setField("RecordTypeId", referenceMap.get("new_id") );
|
||||
// }
|
||||
if (api.equals("vlink__Wechat_User__c")){
|
||||
List<Map<String, Object>> maps = customMapper.list("new_id", "vlink__Wechat_Account__c", "new_id is not null and id = '" + data.get(j - 1).get("vlink__Wechat_Account__c") + "' limit 1");
|
||||
if (!maps.isEmpty()){
|
||||
|
Loading…
Reference in New Issue
Block a user