结算接口查询条件修改

This commit is contained in:
lulz1 2024-04-11 08:28:42 +08:00
parent 94c52aabce
commit a39f3e50af
1 changed files with 16 additions and 1 deletions

View File

@ -18,7 +18,13 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.stream.Collectors;
import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_AIRPLANE;
@ -61,7 +67,16 @@ public class LocationController {
.toList();
}
if (locations != null && !locations.isEmpty()) {
//
// 在每个分组中 locationId Location 进行排序然后取出每组的第一个元素
locations = new ArrayList<>(locations.stream()
// Location 对象映射为 locationPath locationPathName 的组合作为 keyLocation 对象本身作为 value
.collect(Collectors.toMap(location -> new AbstractMap.SimpleEntry<>(location.getLocationPath(),
location.getLocationPathName()), Function.identity(),
BinaryOperator.minBy(Comparator.comparingLong(Location::getLocationId))))
.values()); // Stream 转换为 List
if (!locations.isEmpty()) {
locationRes = locations
.stream()
.map(LocationRes::copyFrom).toList();