哈希表用于数据索引
HashMap<String, indexstation> thishashindex = new HashMap<String, indexstation>();
// 判断有没有在列表里
if (thishashindex.containsKey(laccell)) {
thishashindex.get(laccell).listadd(thisindex_cell);
} else {
indexstation thisindexstation = new indexstation(
Integer.parseInt(laccell.split(" ")[0]),
Integer.parseInt(laccell.split(" ")[1]));
thisindexstation.listadd(thisindex_cell);
thishashindex.put(laccell, thisindexstation);
}
// 采用Entry遍历HashMap 并输出
Set<Entry<String, indexstation>> sets = thishashindex.entrySet();
for (Entry<String, indexstation> entry : sets) {
String textvalue="";
// 这里可能会出现重复问题
int count=1;
for (int valueint = 0; valueint < entry.getValue().getlist().size(); valueint++) {
textvalue+=(Long.parseLong(entry.getValue().getlist().get(valueint).getid())) + ","
+ entry.getValue().getlist().get(valueint).getlinenum() + ";";
if(textvalue.length()>1000){
pst.setInt(1,time);
pst.setInt(2,Integer.parseInt(entry.getKey().split(" ")[0]));
pst.setInt(3,Integer.parseInt(entry.getKey().split(" ")[1]));
pst.setInt(4,count);
pst.setString(5,textvalue);
pst.addBatch();
textvalue="";
count++;
}
}
pst.setInt(1,time);
pst.setInt(2,Integer.parseInt(entry.getKey().split(" ")[0]));
pst.setInt(3,Integer.parseInt(entry.getKey().split(" ")[1]));
pst.setInt(4,count);
pst.setString(5,textvalue);
count++;
}