Commit 4f37832b authored by 赵啸非's avatar 赵啸非

物联网1.0

parent 89ffdf16
......@@ -7,6 +7,10 @@ import org.apache.commons.collections4.CollectionUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
......@@ -55,4 +59,9 @@ public class MemoryPagination {
}
return results;
}
public static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
Set<Object> seen = ConcurrentHashMap.newKeySet();
return t -> seen.add(keyExtractor.apply(t));
}
}
......@@ -77,6 +77,9 @@ public class SitestatServiceImpl extends AbstractCRUDServiceImpl<SitestatDao, Si
return new ArrayList<SitestatEntity>().stream();
}).collect(Collectors.toList());
//列表去重
collect = collect.stream().filter(MemoryPagination.distinctByKey(SitestatEntity::getId)).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(entity.getSiteName())) {
collect = MemoryPagination.search(entity.getSiteName(), collect);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment