|
|
@@ -1,13 +1,16 @@
|
|
1
|
1
|
package com.sundot.airport.ledger.service.impl;
|
|
2
|
2
|
|
|
3
|
3
|
import java.util.Collections;
|
|
|
4
|
+import java.util.HashMap;
|
|
4
|
5
|
import java.util.List;
|
|
5
|
6
|
import java.util.Map;
|
|
|
7
|
+import java.util.Objects;
|
|
6
|
8
|
import java.util.Set;
|
|
7
|
9
|
import java.util.stream.Collectors;
|
|
8
|
10
|
|
|
9
|
11
|
import cn.hutool.core.collection.CollUtil;
|
|
10
|
12
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
13
|
+import com.google.common.collect.Maps;
|
|
11
|
14
|
import com.sundot.airport.common.utils.DateUtils;
|
|
12
|
15
|
import com.sundot.airport.ledger.domain.OperationStationHourlyThroughput;
|
|
13
|
16
|
import com.sundot.airport.ledger.domain.vo.AreaFlowVO;
|
|
|
@@ -15,6 +18,8 @@ import com.sundot.airport.ledger.domain.vo.StationHourlyThroughputGroupResVO;
|
|
15
|
18
|
import com.sundot.airport.ledger.domain.vo.StationHourlyThroughputVO;
|
|
16
|
19
|
import com.sundot.airport.ledger.mapper.OperationStationHourlyThroughputMapper;
|
|
17
|
20
|
import com.sundot.airport.ledger.service.IOperationStationHourlyThroughputService;
|
|
|
21
|
+import com.sundot.airport.system.domain.BasePosition;
|
|
|
22
|
+import com.sundot.airport.system.mapper.BasePositionMapper;
|
|
18
|
23
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
19
|
24
|
import org.springframework.stereotype.Service;
|
|
20
|
25
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@@ -23,11 +28,12 @@ import org.springframework.transaction.annotation.Transactional;
|
|
23
|
28
|
* 站级时间段别总过检Service业务层处理
|
|
24
|
29
|
*/
|
|
25
|
30
|
@Service
|
|
26
|
|
-public class OperationStationHourlyThroughputServiceImpl extends ServiceImpl<OperationStationHourlyThroughputMapper, OperationStationHourlyThroughput>
|
|
27
|
|
- implements IOperationStationHourlyThroughputService {
|
|
|
31
|
+public class OperationStationHourlyThroughputServiceImpl extends ServiceImpl<OperationStationHourlyThroughputMapper, OperationStationHourlyThroughput> implements IOperationStationHourlyThroughputService {
|
|
28
|
32
|
|
|
29
|
33
|
@Autowired
|
|
30
|
34
|
private OperationStationHourlyThroughputMapper operationStationHourlyThroughputMapper;
|
|
|
35
|
+ @Autowired
|
|
|
36
|
+ private BasePositionMapper basePositionMapper;
|
|
31
|
37
|
|
|
32
|
38
|
/**
|
|
33
|
39
|
* 查询站级时间段别总过检列表
|
|
|
@@ -105,22 +111,34 @@ public class OperationStationHourlyThroughputServiceImpl extends ServiceImpl<Ope
|
|
105
|
111
|
return Collections.emptyList();
|
|
106
|
112
|
}
|
|
107
|
113
|
|
|
|
114
|
+ Map<Long, BasePosition> areaInfoMap = Maps.newHashMap();
|
|
108
|
115
|
// 1. 预处理:获取区域名称
|
|
109
|
|
- Set<String> areaIds = stationHourlyThroughputList.stream().map(StationHourlyThroughputVO::getAreaId).collect(Collectors.toSet());
|
|
110
|
|
-
|
|
111
|
|
- // TODO PanHu Sun 2026/5/19 17:16 待办事项:查询base_position表获取区域名称
|
|
|
116
|
+ Set<Long> areaIds = stationHourlyThroughputList.stream()
|
|
|
117
|
+ .filter(station -> Objects.nonNull(station.getAreaId()))
|
|
|
118
|
+ .map(StationHourlyThroughputVO::getAreaId)
|
|
|
119
|
+ .collect(Collectors.toSet());
|
|
|
120
|
+ if (CollUtil.isNotEmpty(areaIds)) {
|
|
|
121
|
+ // 查询base_position表获取区域名称
|
|
|
122
|
+ List<BasePosition> basePositions = basePositionMapper.selectPositionListByIds(areaIds);
|
|
|
123
|
+ // 将basePositions转成map,key是id,value是BasePosition
|
|
|
124
|
+ areaInfoMap = CollUtil.emptyIfNull(basePositions).stream().collect(Collectors.toMap(BasePosition::getId, v -> v));
|
|
|
125
|
+ }
|
|
112
|
126
|
|
|
113
|
127
|
// 2. 核心:按小时分组 → 组装成前端需要的层级结构
|
|
114
|
128
|
Map<String, List<StationHourlyThroughputVO>> hourGroupMap = stationHourlyThroughputList.stream().collect(Collectors.groupingBy(StationHourlyThroughputVO::getHourOfDay));
|
|
115
|
129
|
|
|
|
130
|
+ Map<Long, BasePosition> finalAreaInfoMap = areaInfoMap;
|
|
116
|
131
|
return hourGroupMap.entrySet().stream().map(entry -> {
|
|
117
|
132
|
String hour = entry.getKey();
|
|
118
|
133
|
List<StationHourlyThroughputVO> hourDataList = entry.getValue();
|
|
119
|
134
|
|
|
120
|
135
|
// 构建区域列表
|
|
121
|
136
|
List<AreaFlowVO> areaList = hourDataList.stream().map(stats -> {
|
|
|
137
|
+ BasePosition basePosition = finalAreaInfoMap.get(stats.getAreaId());
|
|
|
138
|
+
|
|
122
|
139
|
AreaFlowVO areaFlowVO = new AreaFlowVO();
|
|
123
|
140
|
areaFlowVO.setAreaId(stats.getAreaId());
|
|
|
141
|
+ areaFlowVO.setAreaName(Objects.nonNull(basePosition) ? basePosition.getName() : "");
|
|
124
|
142
|
areaFlowVO.setAreaFlow(stats.getAreaFlow());
|
|
125
|
143
|
return areaFlowVO;
|
|
126
|
144
|
}).collect(Collectors.toList());
|