Browse Source

#单位属性去重

zhongwei
yang_shj 1 year ago
parent
commit
6d9f4697b3
  1. 7
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/station/impl/StationAttributeServiceImpl.java

7
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/station/impl/StationAttributeServiceImpl.java

@ -9,8 +9,7 @@ import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.CollectionUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -31,6 +30,8 @@ public class StationAttributeServiceImpl extends BaseServiceImpl<StationAttribut
if(CollectionUtil.isEmpty(list)){ if(CollectionUtil.isEmpty(list)){
return null; return null;
} }
return list.stream().collect(Collectors.toMap(StationAttributeEntity::getAttributes, StationAttributeEntity::getUnit)); // 属性去重
return list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(StationAttributeEntity::getAttributes))), ArrayList::new))
.stream().collect(Collectors.toMap(StationAttributeEntity::getAttributes, StationAttributeEntity::getUnit));
} }
} }

Loading…
Cancel
Save