Bladeren bron

9.根据区域id查询区域名称

sunpanhu 4 weken geleden
bovenliggende
commit
fbab204619

+ 5 - 0
airport-common/pom.xml

@@ -155,6 +155,11 @@
155 155
             <version>4.5.0</version>
156 156
         </dependency>
157 157
 
158
+        <dependency>
159
+            <groupId>com.google.guava</groupId>
160
+            <artifactId>guava</artifactId>
161
+            <version>33.5.0-jre</version>
162
+        </dependency>
158 163
     </dependencies>
159 164
 
160 165
 </project>

+ 6 - 4
airport-ledger/src/main/java/com/sundot/airport/ledger/domain/OperationStationHourlyThroughput.java

@@ -1,6 +1,8 @@
1 1
 package com.sundot.airport.ledger.domain;
2 2
 
3 3
 import java.math.BigDecimal;
4
+import java.util.Date;
5
+
4 6
 import com.baomidou.mybatisplus.annotation.IdType;
5 7
 import com.baomidou.mybatisplus.annotation.TableId;
6 8
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -24,7 +26,7 @@ public class OperationStationHourlyThroughput extends BaseEntity {
24 26
     private Long id;
25 27
 
26 28
     /** 区域ID */
27
-    private String areaId;
29
+    private Long areaId;
28 30
 
29 31
     /** 部门ID */
30 32
     private Long deptId;
@@ -52,9 +54,9 @@ public class OperationStationHourlyThroughput extends BaseEntity {
52 54
     private String laneId;
53 55
 
54 56
     /** 记录日期(YYYYMMDD) */
55
-    @JsonFormat(pattern = "yyyyMMdd")
56
-    @Excel(name = "记录日期", width = 20, dateFormat = "yyyyMMdd")
57
-    private String recordDate;
57
+    @JsonFormat(pattern = "yyyy-MM-dd")
58
+    @Excel(name = "记录日期", width = 20, dateFormat = "yyyy-MM-dd")
59
+    private Date recordDate;
58 60
 
59 61
     /** 小时(0:00~1:00、1:00~2:00、23:00~24:00等) */
60 62
     @Excel(name = "小时")

+ 1 - 1
airport-ledger/src/main/java/com/sundot/airport/ledger/domain/vo/AreaFlowVO.java

@@ -15,7 +15,7 @@ public class AreaFlowVO implements Serializable {
15 15
     /**
16 16
      * 区域ID
17 17
      */
18
-    private String areaId;
18
+    private Long areaId;
19 19
     /**
20 20
      * 区域名称
21 21
      */

+ 1 - 1
airport-ledger/src/main/java/com/sundot/airport/ledger/domain/vo/StationHourlyThroughputVO.java

@@ -15,7 +15,7 @@ public class StationHourlyThroughputVO implements Serializable {
15 15
     // 小时段
16 16
     private String hourOfDay;
17 17
     // 区域ID
18
-    private String areaId;
18
+    private Long areaId;
19 19
     // 区域名称
20 20
     private String areaName;
21 21
     // 当前区域人流量

+ 2 - 0
airport-ledger/src/main/java/com/sundot/airport/ledger/mapper/OperationStationHourlyThroughputMapper.java

@@ -4,10 +4,12 @@ import java.util.List;
4 4
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 5
 import com.sundot.airport.ledger.domain.OperationStationHourlyThroughput;
6 6
 import com.sundot.airport.ledger.domain.vo.StationHourlyThroughputVO;
7
+import org.springframework.stereotype.Repository;
7 8
 
8 9
 /**
9 10
  * 站级时间段别总过检Mapper接口
10 11
  */
12
+@Repository
11 13
 public interface OperationStationHourlyThroughputMapper extends BaseMapper<OperationStationHourlyThroughput> {
12 14
     /**
13 15
      * 查询站级时间段别总过检列表

+ 23 - 5
airport-ledger/src/main/java/com/sundot/airport/ledger/service/impl/OperationStationHourlyThroughputServiceImpl.java

@@ -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());

+ 1 - 1
airport-ledger/src/main/resources/mapper/ledger/OperationStationHourlyThroughputMapper.xml

@@ -45,7 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
45 45
             <if test="groupId != null "> and group_id = #{groupId}</if>
46 46
             <if test="groupName != null  and groupName != ''"> and group_name like concat('%', #{groupName}, '%')</if>
47 47
             <if test="laneId != null  and laneId != ''"> and lane_id = #{laneId}</if>
48
-            <if test="recordDate != null  and recordDate != ''"> and record_date = #{recordDate}</if>
48
+            <if test="recordDate != null"> and record_date = #{recordDate}</if>
49 49
             <if test="hourOfDay != null  and hourOfDay != ''"> and hour_of_day = #{hourOfDay}</if>
50 50
         </where>
51 51
         order by record_date desc, create_time desc

+ 12 - 0
airport-system/src/main/java/com/sundot/airport/system/mapper/BasePositionMapper.java

@@ -1,6 +1,7 @@
1 1
 package com.sundot.airport.system.mapper;
2 2
 
3 3
 import java.util.List;
4
+import java.util.Set;
4 5
 
5 6
 import com.sundot.airport.system.domain.BasePosition;
6 7
 import com.sundot.airport.system.domain.vo.PositionInfoVO;
@@ -70,6 +71,17 @@ public interface BasePositionMapper {
70 71
     public List<BasePosition> selectChildrenById(Long id);
71 72
 
72 73
     /**
74
+     * 功能描述:根据多个id查询元素列表
75
+     *
76
+     * @param ids ID集合
77
+     * @return List<BasePosition>
78
+     * @method selectPositionListByIds
79
+     * @author PanHu Sun
80
+     * @date 2026/5/20 9:36
81
+     */
82
+    List<BasePosition> selectPositionListByIds(Set<Long> ids);
83
+
84
+    /**
73 85
      * 修改子元素关系
74 86
      *
75 87
      * @param list 子元素

+ 8 - 1
airport-system/src/main/resources/mapper/system/BasePositionMapper.xml

@@ -235,5 +235,12 @@
235 235
         ORDER BY la.code, sa.code, ch.code
236 236
     </select>
237 237
 
238
-
238
+    <select id="selectPositionListByIds" resultType="com.sundot.airport.system.domain.BasePosition">
239
+        SELECT *
240
+        FROM base_position
241
+        WHERE id IN
242
+        <foreach item="id" collection="ids" open="(" separator="," close=")">
243
+            #{id}
244
+        </foreach>
245
+    </select>
239 246
 </mapper>