public void insertBeach(Object obj) {
Gson gsobj = new Gson();
@SuppressWarnings("unchecked")
Map<String, Object> jsonStringToMap = gsobj.fromJson(obj.toString(), HashMap.class);
ii(reList(jsonStringToMap, Projects.class));
}
public <T> void ii(List<T> list) {
if (list != null && !list.isEmpty()) {
String simpleName = list.get(0).getClass().getSimpleName();
simpleName = "com.cn.ag.data.dao.interf.sc." + simpleName + "Mapper.";
insertList(simpleName,list);
} else {
System.out.println("刺激和为空 没有数据插入");
}
}
public String getMapperName(Class clz) {
String simpleName = clz.getSimpleName();
return "com.cn.ag.data.dao.interf.sc." + simpleName + "Mapper.";
}
public <T> List<T> reList(Map<String, Object> map, Class<T> clazz) {
List<Object> object = (List<Object>) map.get(clazz.getSimpleName().toLowerCase());
if (object == null || object.isEmpty()) {
return null;
}
List<T> lsit = new ArrayList<T>();
try {
for (Object t : object) {
Object jsonToAnyObject = gm.jsonToAnyObject(JSON.toJSONString(t), clazz);
lsit.add(clazz.cast(jsonToAnyObject));
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(lsit.toString());
return lsit;
}
public <T> void insertList(String simpleName,List<T> list) {
if (list.size() > 70) {
insertMapperImpl.insertBeach(simpleName, list.subList(0, 70));
insertList(simpleName,list.subList(70,list.size()));
}else {
insertMapperImpl.insertBeach(simpleName, list);
}
}