Commit f9bd8555 authored by suhuiguang's avatar suhuiguang

fix(bug)bug修复:

1.车用气瓶单位重复处理,按照useCode去重
parent c60c5e8c
......@@ -118,6 +118,7 @@ import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 装备分类服务实现类
......@@ -953,8 +954,15 @@ public class CommonServiceImpl implements ICommonService {
result.forEach(x -> convertAndAddToUnitList(x, unitList));
}
List<Map<String, Object>> unitListByType = needAuth ? commonMapper.getUnitInfoListByType(type) : commonMapper.getUnitListByType(type);
unitList.addAll(unitListByType);
return unitList;
// 数据去重:原因车用气瓶在字典里进行维护,如果维护的单位注册上来,则会出现数据重复,故按照useCode去重
return new ArrayList<>(Stream.concat(
unitList.stream(),
unitListByType.stream()
).collect(Collectors.toMap(
map -> (String) map.get("useCode"), // 以 unitCode 作为 key
map -> map,
(existing, replacement) -> existing // 如果 key 冲突,保留原有的
)).values());
}
@Override
......
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