|
@@ -2,7 +2,6 @@ package cn.cslg.report.common.utils;
|
|
|
|
|
|
import cn.cslg.report.common.model.BaseVO;
|
|
|
import cn.dev33.satoken.secure.SaSecureUtil;
|
|
|
-import cn.dev33.satoken.stp.StpUtil;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -10,6 +9,7 @@ import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.function.Predicate;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -68,23 +68,22 @@ public class DataUtils {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @return 租户ID
|
|
|
+ * @return 去重后的数据
|
|
|
* @author 沈永艺
|
|
|
- * @description 获取租户ID
|
|
|
+ * @description 在对象数组中按照某一类属性进行去重
|
|
|
*/
|
|
|
- public Integer getTenantId() {
|
|
|
- return cacheUtils.getLoginUser(StpUtil.getLoginIdAsInt()).getTenantId();
|
|
|
+ //用例:待去重List.stream().filter(DataUtils.distinctByKey(对象::get属性字段)).collect(Collectors.toList());
|
|
|
+ public static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
|
|
|
+ Map<Object, Boolean> seen = new ConcurrentHashMap<>();
|
|
|
+ return t -> seen.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
- * @return 去重后的数据
|
|
|
+ * @return 计算完成度
|
|
|
* @author 沈永艺
|
|
|
- * @description 在对象数组中按照某一属性进行去重
|
|
|
+ * @description 输入完成数量和全部数量计算完成百分比
|
|
|
*/
|
|
|
- //用例:待去重List.stream().filter(DataUtils.distinctByKey(对象::get属性字段)).collect(Collectors.toList());
|
|
|
- public static <T> Predicate<T> distinctByKey(java.util.function.Function<? super T, ?> keyExtractor) {
|
|
|
- Map<Object, Boolean> seen = new ConcurrentHashMap<>();
|
|
|
- return t -> seen.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null;
|
|
|
+ public String calculateCompletion(Integer finishNum, Integer allNum) {
|
|
|
+ return finishNum / allNum + "%";
|
|
|
}
|
|
|
}
|