//组装查询语句
if(CollectionUtils.isNotEmpty(basicList)){
Set<String> zuheSet = new HashSet<String>();
//获取的Map:{table1*table2:"A as D,B as E,C as F",table3*table4:"O as X,P as Y,Q as Z"}
Map<String, StringBuffer> sqlBuildMap = new HashMap<String, StringBuffer>();
for(Map<String, Object> map : basicList){
String tt = ObjectUtils.toString(map.get("t1"))+"#"+ObjectUtils.toString(map.get("t2"));
if(!zuheSet.contains(tt)){
zuheSet.add(tt);
StringBuffer subBuffer = new StringBuffer(32);
subBuffer.append(map.get("f1")+" as "+map.get("f2"));
sqlBuildMap.put(tt, subBuffer);
}else{
sqlBuildMap.get(tt).append(",").append(map.get("f1")+" as "+map.get("f2"));
}
}
时间: 2024-10-12 17:19:15