类 DataImportUtils
java.lang.Object
com.iplatform.base.util.DataImportUtils
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static final StringacquireInsertSql(String tableName, List<String> fieldNames) 根据表名、字段信息,生成一个 insert sql语句。static final String生成更新SQL语句acquireUpdateValues(List<Map<String, Object>> dataList, List<String> updateColumns, List<String> whereColumns) 返回更新数据时,所有更新记录的SQL中的值几何。返回组装好的 where in (:param) 参数值集合,字符串类型的。static final Object[]calculateInsertAndUpdateList(List<Map<String, Object>> mapList, List<Map<String, Object>> existList, List<String> whereColumnNames) 计算要写入的数据集合,给定一个已存在的数据集合,判断当前 mapList 中哪些是不存在并需要新写入的数据。把 Map 集合中数据转换成数组集合,方便 SQL 写入。translateToMap(List<Object[]> dataList, List<String> fieldNames) 把数组集合列表数据转换成Map集合。
-
构造器详细资料
-
DataImportUtils
public DataImportUtils()
-
-
方法详细资料
-
calculateInsertAndUpdateList
public static final Object[] calculateInsertAndUpdateList(List<Map<String, Object>> mapList, List<Map<String, Object>> existList, List<String> whereColumnNames) 计算要写入的数据集合,给定一个已存在的数据集合,判断当前 mapList 中哪些是不存在并需要新写入的数据。 目前使用简单的 Map 缓存已存在记录,并使用条件列值拼接字符串作为key,然后遍历 mapList筛查出来。- 参数:
mapList- 给定的原始数据集合existList- 已存在集合whereColumnNames- 条件字段名称集合- 返回:
- 返回结果,数组中包含两个集合: object[0] = insertList, object[1] = updateList
-
acquireWhereInStringValues
public static final List<String> acquireWhereInStringValues(String fieldName, List<Map<String, Object>> mapList) 返回组装好的 where in (:param) 参数值集合,字符串类型的。- 参数:
fieldName- 查找条件的字段名称mapList- 原始数据Map集合。- 返回:
-
acquireUpdateValues
public static final List<Object[]> acquireUpdateValues(List<Map<String, Object>> dataList, List<String> updateColumns, List<String> whereColumns) 返回更新数据时,所有更新记录的SQL中的值几何。 如: [object[5], object[5], object[5]]- 参数:
dataList-updateColumns-whereColumns-- 返回:
-
acquireUpdateSql
public static final String acquireUpdateSql(String tableName, List<String> updateColumns, List<String> whereColumns) 生成更新SQL语句- 参数:
tableName- 表名updateColumns- 更新字段名集合whereColumns- 条件字段名集合,目前只能 and- 返回:
- 返回拼接的SQL语句,占位符使用:?
-
translateToArray
public static final List<Object[]> translateToArray(List<Map<String, Object>> mapList, List<String> fieldNames) 把 Map 集合中数据转换成数组集合,方便 SQL 写入。- 参数:
mapList-fieldNames-- 返回:
-
translateToMap
public static final List<Map<String,Object>> translateToMap(List<Object[]> dataList, List<String> fieldNames) 把数组集合列表数据转换成Map集合。- 参数:
dataList-fieldNames- 字段名称集合- 返回:
- 注意:返回的Map中字段仍然按顺序,为: TreeMap
-
acquireInsertSql
根据表名、字段信息,生成一个 insert sql语句。- 参数:
tableName-fieldNames-- 返回:
-