//excel文件上传数据
List list = importResult.getList();
if (list.size() >200) {
String error = Constants.OPERATE_ERROR +"导入数量不能大于200条";
result.setSubMessage(error);
result.setSubCode(0);
return result;
}
//过滤表格重复数据
//临时存储数据
List billSku =new ArrayList();
//重复数据
List existSkuList =new ArrayList();
List tempSkuList = list.stream().filter(v->{
boolean flag = !billSku.contains(v.getProdSku());
billSku.add(v.getProdSku());
if (!flag){
//重复数据里过滤重复,打印到客户端
boolean existFlag = !existSkuList.contains(v.getProdSku());
if (existFlag){
existSkuList.add(v.getProdSku());
}
}
return flag;
}).collect(Collectors.toList());
if (tempSkuList.size() <list.size()) {
String error ="excel表格中" + existSkuList +"重复!";
result.setSubMessage(error);
result.setSubCode(0);
return result;
}