【feat】优化代码data_index值增形式,bulk同步数据date数据处理方式
This commit is contained in:
parent
e7209d9684
commit
723992f663
@ -247,7 +247,7 @@ public class DataImportBatchServiceImpl implements DataImportBatchService {
|
|||||||
maxIndex.ne("name", api);
|
maxIndex.ne("name", api);
|
||||||
Map<String, Object> map = dataObjectService.getMap(maxIndex);
|
Map<String, Object> map = dataObjectService.getMap(maxIndex);
|
||||||
//如果必填lookup字段没有值,跳过
|
//如果必填lookup字段没有值,跳过
|
||||||
update.setDataIndex(Integer.parseInt(map.get("data_index").toString()+1));
|
update.setDataIndex(Integer.parseInt(map.get("data_index").toString()) + 1);
|
||||||
dataObjectService.updateById(update);
|
dataObjectService.updateById(update);
|
||||||
String message = "api:" + api + "的引用对象:" + reference + "不存在数据!";
|
String message = "api:" + api + "的引用对象:" + reference + "不存在数据!";
|
||||||
String format = String.format("数据导入 error, api name: %s, \nparam: %s, \ncause:\n%s", api, com.alibaba.fastjson2.JSON.toJSONString(param, DataDumpParam.getFilter()), message);
|
String format = String.format("数据导入 error, api name: %s, \nparam: %s, \ncause:\n%s", api, com.alibaba.fastjson2.JSON.toJSONString(param, DataDumpParam.getFilter()), message);
|
||||||
@ -538,13 +538,6 @@ 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 {
|
||||||
QueryWrapper<DataObject> maxIndex = new QueryWrapper<>();
|
|
||||||
maxIndex.select("IFNULL(max(data_index),0) as data_index");
|
|
||||||
maxIndex.ne("name", api);
|
|
||||||
Map<String, Object> mapTo = dataObjectService.getMap(maxIndex);
|
|
||||||
//如果必填lookup字段没有值,跳过
|
|
||||||
update.setDataIndex(Integer.parseInt(mapTo.get("data_index").toString()+1));
|
|
||||||
dataObjectService.updateById(update);
|
|
||||||
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 + "的数据:"+ 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);
|
||||||
EmailUtil.send("DataDump ERROR", format);
|
EmailUtil.send("DataDump ERROR", format);
|
||||||
log.info(message);
|
log.info(message);
|
||||||
@ -553,7 +546,9 @@ public class DataImportBatchServiceImpl implements DataImportBatchService {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (map.get(field) != null && StringUtils.isNotBlank(dataField.getSfType())) {
|
if (map.get(field) != null && StringUtils.isNotBlank(dataField.getSfType())) {
|
||||||
account.put(field, DataUtil.localDataToSfData(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));
|
||||||
}
|
}
|
||||||
|
@ -758,13 +758,6 @@ public class DataImportNewServiceImpl implements DataImportNewService {
|
|||||||
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 {
|
||||||
QueryWrapper<DataObject> maxIndex = new QueryWrapper<>();
|
|
||||||
maxIndex.select("IFNULL(max(data_index),0) as data_index");
|
|
||||||
maxIndex.ne("name", api);
|
|
||||||
Map<String, Object> mapTo = dataObjectService.getMap(maxIndex);
|
|
||||||
//如果必填lookup字段没有值,跳过
|
|
||||||
update.setDataIndex(Integer.parseInt(mapTo.get("data_index").toString()) +1);
|
|
||||||
dataObjectService.updateById(update);
|
|
||||||
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 + "的数据:"+ 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);
|
||||||
EmailUtil.send("DataDump ERROR", format);
|
EmailUtil.send("DataDump ERROR", format);
|
||||||
log.info(message);
|
log.info(message);
|
||||||
|
@ -309,9 +309,8 @@ public class DataImportServiceImpl implements DataImportService {
|
|||||||
maxIndex.select("IFNULL(max(data_index),0) as data_index");
|
maxIndex.select("IFNULL(max(data_index),0) as data_index");
|
||||||
maxIndex.ne("name", api);
|
maxIndex.ne("name", api);
|
||||||
Map<String, Object> map = dataObjectService.getMap(maxIndex);
|
Map<String, Object> map = dataObjectService.getMap(maxIndex);
|
||||||
|
|
||||||
//如果必填lookup字段没有值,跳过
|
//如果必填lookup字段没有值,跳过
|
||||||
update.setDataIndex(Integer.parseInt(map.get("data_index").toString()+1));
|
update.setDataIndex(Integer.parseInt(map.get("data_index").toString()) + 1);
|
||||||
dataObjectService.updateById(update);
|
dataObjectService.updateById(update);
|
||||||
return;
|
return;
|
||||||
}else{
|
}else{
|
||||||
|
@ -392,6 +392,39 @@ public class DataUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Object localBulkDataToSfData(String fieldType, String data) throws ParseException {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||||
|
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
|
Date date;
|
||||||
|
//date转Calendar类型
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
switch (fieldType) {
|
||||||
|
case "int":
|
||||||
|
return Integer.parseInt(data);
|
||||||
|
case "double":
|
||||||
|
case "currency":
|
||||||
|
case "percent":
|
||||||
|
return new BigDecimal(data);
|
||||||
|
case "boolean":
|
||||||
|
return Boolean.valueOf(data);
|
||||||
|
case "date":
|
||||||
|
return data+"T08:00:00Z";
|
||||||
|
case "datetime":
|
||||||
|
try {
|
||||||
|
date = sd.parse(data);
|
||||||
|
}catch (ParseException e){
|
||||||
|
//解决当时间秒为0时,转换秒精度丢失问题
|
||||||
|
date = sd.parse(data+":00");
|
||||||
|
}
|
||||||
|
calendar.setTime(date);
|
||||||
|
return calendar;
|
||||||
|
case "time":
|
||||||
|
return adjustHour(data);
|
||||||
|
default:
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Object localDataToSfData(String fieldType, String data) throws ParseException {
|
public static Object localDataToSfData(String fieldType, String data) throws ParseException {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||||
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
|
Loading…
Reference in New Issue
Block a user