Commit b0673f13 by zhangxingmin

push

parent d408c720
...@@ -62,13 +62,22 @@ public class ApiSpeciesSettingServiceImpl implements ApiSpeciesSettingService { ...@@ -62,13 +62,22 @@ public class ApiSpeciesSettingServiceImpl implements ApiSpeciesSettingService {
@Override @Override
public List<ApiSpeciesTypeDto> querySpeciesTypeDtoList(String productLaunchBizId) { public List<ApiSpeciesTypeDto> querySpeciesTypeDtoList(String productLaunchBizId) {
List<ApiSpeciesTypeDto> apiSpeciesTypeDtoList = new ArrayList<>(); List<ApiSpeciesTypeDto> apiSpeciesTypeDtoList = new ArrayList<>();
List<SpeciesSetting> speciesSettingList = iSpeciesSettingService.queryList(SpeciesSettingDto.builder().productLaunchBizId(productLaunchBizId).build()); List<SpeciesSetting> speciesSettingList = iSpeciesSettingService
.queryList(SpeciesSettingDto.builder().productLaunchBizId(productLaunchBizId).build());
if (!CollectionUtils.isEmpty(speciesSettingList)) { if (!CollectionUtils.isEmpty(speciesSettingList)) {
// 按规格类型分组 // 首先按ID排序
Map<String, List<SpeciesSetting>> speciesSettingByType = speciesSettingList.stream() List<SpeciesSetting> sortedList = speciesSettingList.stream()
.sorted(Comparator.comparing(SpeciesSetting::getId)) .sorted(Comparator.comparing(SpeciesSetting::getId))
.collect(Collectors.groupingBy(SpeciesSetting::getTypeName)); .collect(Collectors.toList());
// 使用LinkedHashMap保持插入顺序,按规格类型分组
Map<String, List<SpeciesSetting>> speciesSettingByType = new LinkedHashMap<>();
for (SpeciesSetting setting : sortedList) {
String typeName = setting.getTypeName();
speciesSettingByType.computeIfAbsent(typeName, k -> new ArrayList<>()).add(setting);
}
// 为每个规格类型创建DTO // 为每个规格类型创建DTO
apiSpeciesTypeDtoList = speciesSettingByType.entrySet().stream().map(entry -> { apiSpeciesTypeDtoList = speciesSettingByType.entrySet().stream().map(entry -> {
......
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