【feat】 获取NewId增加oldId传值
This commit is contained in:
parent
912efda685
commit
186100bb96
14
.run/data-dump(亚数) .run.xml
Normal file
14
.run/data-dump(亚数) .run.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="data-dump(亚数) " type="docker-deploy" factoryName="dockerfile" server-name="亚数Docker">
|
||||
<deployment type="dockerfile">
|
||||
<settings>
|
||||
<option name="imageTag" value="data-dump" />
|
||||
<option name="buildCliOptions" value="--platform=linux/amd64" />
|
||||
<option name="containerName" value="data-dump" />
|
||||
<option name="commandLineOptions" value="-p 90:80 -v /usr/local/data-dump/file:/data-dump/file -v /usr/local/data-dump/logs:/data-dump/logs --restart=always --network=host" />
|
||||
<option name="sourceFilePath" value="Dockerfile" />
|
||||
</settings>
|
||||
</deployment>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
@ -238,6 +238,7 @@ public class CommonServiceImpl implements CommonService {
|
||||
}
|
||||
dumpDataNew(salesforceParam, dataReport,dataObject);
|
||||
dataObject.setLastUpdateDate(updateTime);
|
||||
dataObject.setNeedUpdate( false);
|
||||
dataObjectService.updateById(dataObject);
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
@ -867,7 +868,7 @@ public class CommonServiceImpl implements CommonService {
|
||||
DataObject one = dataObjectService.getById(api);
|
||||
QueryWrapper<DataField> dbQw = new QueryWrapper<>();
|
||||
dbQw.eq("api", api);
|
||||
List<String> list = dataFieldService.list(dbQw).stream().map(DataField::getField).collect(Collectors.toList());
|
||||
List<DataField> listed = dataFieldService.list(dbQw);
|
||||
List<String> existsIds = customMapper.getIds(api, ids);
|
||||
for (int i = 0; i < objects.size(); i++) {
|
||||
JSONObject jsonObject = objects.getJSONObject(i);
|
||||
@ -875,10 +876,10 @@ public class CommonServiceImpl implements CommonService {
|
||||
// update
|
||||
String id = jsonObject.getString(Const.ID);
|
||||
List<Map<String, Object>> maps = Lists.newArrayList();
|
||||
for (String key : list) {
|
||||
if (fields.stream().anyMatch(key::equalsIgnoreCase)) {
|
||||
for (DataField field : listed) {
|
||||
if (StringUtils.isNotEmpty(field.getSfType())) {
|
||||
// ContentVersion表,插入更新时把title中的/替换为-
|
||||
if ("ContentVersion".equals(one.getName()) && "Title".equals(key)){
|
||||
if ("ContentVersion".equals(one.getName()) && "Title".equals(field.getField())){
|
||||
String title = StringUtils.replace(String.valueOf(jsonObject.get("Title")), "/", "-");
|
||||
Map<String, Object> paramMap = Maps.newHashMap();
|
||||
paramMap.put("key", "Title");
|
||||
@ -888,7 +889,7 @@ public class CommonServiceImpl implements CommonService {
|
||||
}
|
||||
|
||||
// Document,Attachment,插入更新时把Name中的/替换为-
|
||||
if (("Document".equals(one.getName()) || "Attachment".equals(one.getName())) && "Name".equals(key)){
|
||||
if (("Document".equals(one.getName()) || "Attachment".equals(one.getName())) && "Name".equals(field.getField())){
|
||||
String name = StringUtils.replace(String.valueOf(jsonObject.get("Name")), "/", "-");
|
||||
Map<String, Object> paramMap = Maps.newHashMap();
|
||||
paramMap.put("key", "Name");
|
||||
@ -898,8 +899,8 @@ public class CommonServiceImpl implements CommonService {
|
||||
}
|
||||
|
||||
Map<String, Object> paramMap = Maps.newHashMap();
|
||||
paramMap.put("key", key);
|
||||
paramMap.put("value", jsonObject.get(key));
|
||||
paramMap.put("key", field.getField());
|
||||
paramMap.put("value", jsonObject.get(field.getField()));
|
||||
maps.add(paramMap);
|
||||
}
|
||||
}
|
||||
|
||||
@ -295,6 +295,7 @@ public class DataDumpSpecialServiceImpl implements DataDumpSpecialService {
|
||||
}
|
||||
updateDataBatch(connect, api);
|
||||
dataObject.setLastUpdateDate(new Date());
|
||||
dataObject.setNeedUpdate( false);
|
||||
dataObjectService.updateById(dataObject);
|
||||
} catch (Throwable throwable) {
|
||||
String format = String.format("数据特殊表迁移 error, api name: %s, \nparam: %s, \ncause:\n%s", api, JSON.toJSONString(param), throwable);
|
||||
|
||||
@ -2245,14 +2245,14 @@ public class DataImportNewServiceImpl implements DataImportNewService {
|
||||
public ReturnT<String> checkDeletedData(SalesforceParam param) throws Exception {
|
||||
|
||||
if (param.getType() == 1){
|
||||
return munalCheckDeletedData(param);
|
||||
return manualCheckDeletedData(param);
|
||||
}else {
|
||||
return autoCheckDeletedData(param);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private ReturnT<String> munalCheckDeletedData(SalesforceParam param) throws Exception {
|
||||
private ReturnT<String> manualCheckDeletedData(SalesforceParam param) throws Exception {
|
||||
|
||||
String api = "DeleteEvent";
|
||||
|
||||
@ -2954,7 +2954,6 @@ public class DataImportNewServiceImpl implements DataImportNewService {
|
||||
List<Map<String, Object>> data = mapsList.subList(startIndex, endIndex);
|
||||
|
||||
int sized = data.size();
|
||||
log.info("执行api:{}, 执行批次:{}, 执行数据量:{},开始时间:{},结束时间:{}", api, i+1, size,beginDateStr,endDateStr);
|
||||
SObject[] accounts = new SObject[sized];
|
||||
String[] ids = new String[sized];
|
||||
try {
|
||||
|
||||
@ -262,6 +262,9 @@ public class DataImportServiceImpl implements DataImportService {
|
||||
dbQw.eq("api", api);
|
||||
List<DataField> list = dataFieldService.list(dbQw);
|
||||
TimeUnit.MILLISECONDS.sleep(1);
|
||||
QueryWrapper<DataObject> dbQw2 = new QueryWrapper<>();
|
||||
dbQw2.eq("name", api);
|
||||
DataObject dataObject = dataObjectService.getOne(dbQw2);
|
||||
|
||||
String beginDateStr = null;
|
||||
String endDateStr = null;
|
||||
@ -292,8 +295,6 @@ public class DataImportServiceImpl implements DataImportService {
|
||||
}
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||
DataObject update = new DataObject();
|
||||
update.setName(api);
|
||||
|
||||
int num = count%10000 == 0 ? count/10000 : (count/10000) + 1;
|
||||
|
||||
@ -378,8 +379,8 @@ public class DataImportServiceImpl implements DataImportService {
|
||||
maxIndex.ne("name", api);
|
||||
Map<String, Object> map = dataObjectService.getMap(maxIndex);
|
||||
//如果必填lookup字段没有值,跳过
|
||||
update.setDataIndex(Integer.parseInt(map.get("data_index").toString()) + 1);
|
||||
dataObjectService.updateById(update);
|
||||
dataObject.setDataIndex(Integer.parseInt(map.get("data_index").toString()) + 1);
|
||||
dataObjectService.updateById(dataObject);
|
||||
return;
|
||||
}else{
|
||||
account.setField(dataField.getField(), referenceMap.get(0).get("new_id"));
|
||||
@ -395,6 +396,11 @@ public class DataImportServiceImpl implements DataImportService {
|
||||
}
|
||||
}
|
||||
|
||||
if (dataObject.getIsEditable()){
|
||||
account.setField("old_owner_id__c", mapList.get(j - 1).get("OwnerId"));
|
||||
account.setField("old_sfdc_id__c", mapList.get(j - 1).get("Id"));
|
||||
}
|
||||
|
||||
ids[j-1] = mapList.get(j-1).get("Id").toString();
|
||||
accounts[j-1] = account;
|
||||
if (i*200+j == size){
|
||||
|
||||
@ -157,19 +157,21 @@ public class DataVerifyServiceImpl implements DataVerifyService {
|
||||
for (DataObject dataObject : list) {
|
||||
String api = dataObject.getName();
|
||||
String extraSql = "";
|
||||
String andexSql = "";
|
||||
SalesforceParam salesforceParam = new SalesforceParam();
|
||||
salesforceParam.setApi(api);
|
||||
Boolean hasDeleted = dataFieldService.hasDeleted(api);
|
||||
if (hasDeleted) {
|
||||
salesforceParam.setIsDeleted(false);
|
||||
extraSql = " WHERE IsDeleted = false ";
|
||||
andexSql = " AND IsDeleted = false ";
|
||||
}
|
||||
|
||||
String sql = "SELECT Count(Id) num FROM " + api + extraSql;
|
||||
|
||||
String oldIdSql = sql.contains("WHERE") ? sql + " AND old_sfdc_id__c != null":sql + " WHERE old_sfdc_id__c != null";
|
||||
String oldIdSql = sql.contains("WHERE") ? sql + " AND old_sfdc_id__c != null":sql + " WHERE old_sfdc_id__c != null" + andexSql;
|
||||
|
||||
String duplicateIdSql = "SELECT old_sfdc_id__c FROM " + api + " WHERE old_sfdc_id__c != NULL GROUP BY old_sfdc_id__c HAVING COUNT(old_sfdc_id__c) > 1";
|
||||
String duplicateIdSql = "SELECT old_sfdc_id__c FROM " + api + " WHERE old_sfdc_id__c != NULL "+ andexSql +" GROUP BY old_sfdc_id__c HAVING COUNT(old_sfdc_id__c) > 1" ;
|
||||
|
||||
if (param.getBeginDate() != null){
|
||||
String dateField = dataFieldService.returnDateField(api);
|
||||
@ -297,7 +299,7 @@ public class DataVerifyServiceImpl implements DataVerifyService {
|
||||
}
|
||||
idStr += ")";
|
||||
|
||||
String duplicateOldIdSql = "SELECT Id,old_sfdc_id__c FROM " + api + " WHERE old_sfdc_id__c IN " + idStr;
|
||||
String duplicateOldIdSql = "SELECT Id,old_sfdc_id__c FROM " + api + " WHERE old_sfdc_id__c IN " + idStr + andexSql;
|
||||
QueryResult queryResult1 = targetConnect.queryAll(duplicateOldIdSql);
|
||||
if (queryResult1 != null && queryResult1.getRecords() != null && queryResult1.getRecords().length > 0) {
|
||||
for (SObject record : queryResult1.getRecords()) {
|
||||
@ -368,6 +370,7 @@ public class DataVerifyServiceImpl implements DataVerifyService {
|
||||
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user