List移除有空值的记录,并将记录拼接成一个字符串,用逗号分隔
List<BsWmsAllotForm> vs = this.sqlQueryUtils.queryAll(sql, new Object[] { allotId }, BsWmsAllotForm.class);
Iterator<BsWmsAllotForm> iterator = vs.iterator();
while (iterator.hasNext()) {
BsWmsAllotForm bwa = (BsWmsAllotForm)iterator.next();
if (StringUtils.isBlank(bwa.getAllotNo())) {
iterator.remove();
}
}
if (CollectionUtils.isNotEmpty(vs)) {
for (int i = 0; i < vs.size(); i++) {
allotNos.append(((BsWmsAllotForm)vs.get(i)).getAllotNo());
allotNos.append(",");
}
return allotNos.toString();
}
return null;
效果