public List<ReceiveConfig> validateList(List<ReceiveConfig> list) {
List<Map> listOld = queryReceiveForList();
StringBuffer sb = new StringBuffer();
sb.append("存在重复数据,跳过第 ");
boolean isCount = false;
int col = 2 ;//定义excel行,初始为2
if (null != list && list.size()>0) {
for (int i = 0; i < list.size(); i++) {
String userName = list.get(i).getReceive_user_name();
String deptName = list.get(i).getDept_name();
/*for (int j = 0; j < listOld.size(); j++) {*/
for(Map map : listOld){
if (userName.equals(map.get("RECEIVE_USER_NAME"))&& deptName.equals(map.get("DEPT_NAME"))) {
isCount = true;
sb.append((col) + "; ");
list.remove(i--);//这里要用i--
break;//如果找到重复,结束子循环,提高效率
}
}
col+=1;
}
}
sb.append("行");
// 平台没有log输出,先用这个喽~~
if (isCount) {
System.out.println(sb.toString());
}
return list;
List<Map> listOld = queryReceiveForList();
StringBuffer sb = new StringBuffer();
sb.append("存在重复数据,跳过第 ");
boolean isCount = false;
int col = 2 ;//定义excel行,初始为2
if (null != list && list.size()>0) {
for (int i = 0; i < list.size(); i++) {
String userName = list.get(i).getReceive_user_name();
String deptName = list.get(i).getDept_name();
/*for (int j = 0; j < listOld.size(); j++) {*/
for(Map map : listOld){
if (userName.equals(map.get("RECEIVE_USER_NAME"))&& deptName.equals(map.get("DEPT_NAME"))) {
isCount = true;
sb.append((col) + "; ");
list.remove(i--);//这里要用i--
break;//如果找到重复,结束子循环,提高效率
}
}
col+=1;
}
}
sb.append("行");
// 平台没有log输出,先用这个喽~~
if (isCount) {
System.out.println(sb.toString());
}
return list;
}
public List<Map> queryReceiveForList() {
...略
}