67,512
社区成员
发帖
与我相关
我的任务
分享
String windowId = this.getPara("windowId");
List<ItemBean> list = windowManagerService.getItemList(windowId);//查询本地缓存的所有事项
StringBuffer ids = new StringBuffer();
StringBuffer sbWhere = new StringBuffer();
for (ItemBean sb : list) {
if (ids.length() > 0) {
ids.append(",");
}
ids.append(sb.getItemCode());
}
String is = ids.toString().replaceAll(",", "','");
if (ids.length() > 0) {
sbWhere.append(" and CODE in ('").append(is).append("')");
} else {
sbWhere.append(" and CODE in ('").append("-").append("')");
}
}
//这里拼接SQL语句,执行 SELECT * FROM ... WHERE 1=1 AND + sbWhere.toString()
SELECT * FROM ... WHERE 1=1 AND CODE IN(
'E27848C2D72E46F9A5368CBF549787E4',
'E27848C2D72E46F9A5368CBF549787E5',
'E27848C2D72E46F9A5368CBF549787E6',
'E27848C2D72E46F9A5368CBF549787E7',
'E27848C2D72E46F9A5368CBF549787E8',
'E27848C2D72E46F9A5368CBF549787E9',
......
)