Quellcode durchsuchen

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

sunpanhu vor 4 Wochen
Ursprung
Commit
fbab204619

+ 5 - 0
airport-common/pom.xml

@@ -155,6 +155,11 @@
155
             <version>4.5.0</version>
155
             <version>4.5.0</version>
156
         </dependency>
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
     </dependencies>
163
     </dependencies>
159
 
164
 
160
 </project>
165
 </project>

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

@@ -1,6 +1,8 @@
1
 package com.sundot.airport.ledger.domain;
1
 package com.sundot.airport.ledger.domain;
2
 
2
 
3
 import java.math.BigDecimal;
3
 import java.math.BigDecimal;
4
+import java.util.Date;
5
+
4
 import com.baomidou.mybatisplus.annotation.IdType;
6
 import com.baomidou.mybatisplus.annotation.IdType;
5
 import com.baomidou.mybatisplus.annotation.TableId;
7
 import com.baomidou.mybatisplus.annotation.TableId;
6
 import com.baomidou.mybatisplus.annotation.TableName;
8
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -24,7 +26,7 @@ public class OperationStationHourlyThroughput extends BaseEntity {
24
     private Long id;
26
     private Long id;
25
 
27
 
26
     /** 区域ID */
28
     /** 区域ID */
27
-    private String areaId;
29
+    private Long areaId;
28
 
30
 
29
     /** 部门ID */
31
     /** 部门ID */
30
     private Long deptId;
32
     private Long deptId;
@@ -52,9 +54,9 @@ public class OperationStationHourlyThroughput extends BaseEntity {
52
     private String laneId;
54
     private String laneId;
53
 
55
 
54
     /** 记录日期(YYYYMMDD) */
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
     /** 小时(0:00~1:00、1:00~2:00、23:00~24:00等) */
61
     /** 小时(0:00~1:00、1:00~2:00、23:00~24:00等) */
60
     @Excel(name = "小时")
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
      * 区域ID
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
     private String hourOfDay;
16
     private String hourOfDay;
17
     // 区域ID
17
     // 区域ID
18
-    private String areaId;
18
+    private Long areaId;
19
     // 区域名称
19
     // 区域名称
20
     private String areaName;
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
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
 import com.sundot.airport.ledger.domain.OperationStationHourlyThroughput;
5
 import com.sundot.airport.ledger.domain.OperationStationHourlyThroughput;
6
 import com.sundot.airport.ledger.domain.vo.StationHourlyThroughputVO;
6
 import com.sundot.airport.ledger.domain.vo.StationHourlyThroughputVO;
7
+import org.springframework.stereotype.Repository;
7
 
8
 
8
 /**
9
 /**
9
  * 站级时间段别总过检Mapper接口
10
  * 站级时间段别总过检Mapper接口
10
  */
11
  */
12
+@Repository
11
 public interface OperationStationHourlyThroughputMapper extends BaseMapper<OperationStationHourlyThroughput> {
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
 package com.sundot.airport.ledger.service.impl;
1
 package com.sundot.airport.ledger.service.impl;
2
 
2
 
3
 import java.util.Collections;
3
 import java.util.Collections;
4
+import java.util.HashMap;
4
 import java.util.List;
5
 import java.util.List;
5
 import java.util.Map;
6
 import java.util.Map;
7
+import java.util.Objects;
6
 import java.util.Set;
8
 import java.util.Set;
7
 import java.util.stream.Collectors;
9
 import java.util.stream.Collectors;
8
 
10
 
9
 import cn.hutool.core.collection.CollUtil;
11
 import cn.hutool.core.collection.CollUtil;
10
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
12
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
13
+import com.google.common.collect.Maps;
11
 import com.sundot.airport.common.utils.DateUtils;
14
 import com.sundot.airport.common.utils.DateUtils;
12
 import com.sundot.airport.ledger.domain.OperationStationHourlyThroughput;
15
 import com.sundot.airport.ledger.domain.OperationStationHourlyThroughput;
13
 import com.sundot.airport.ledger.domain.vo.AreaFlowVO;
16
 import com.sundot.airport.ledger.domain.vo.AreaFlowVO;
@@ -15,6 +18,8 @@ import com.sundot.airport.ledger.domain.vo.StationHourlyThroughputGroupResVO;
15
 import com.sundot.airport.ledger.domain.vo.StationHourlyThroughputVO;
18
 import com.sundot.airport.ledger.domain.vo.StationHourlyThroughputVO;
16
 import com.sundot.airport.ledger.mapper.OperationStationHourlyThroughputMapper;
19
 import com.sundot.airport.ledger.mapper.OperationStationHourlyThroughputMapper;
17
 import com.sundot.airport.ledger.service.IOperationStationHourlyThroughputService;
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
 import org.springframework.beans.factory.annotation.Autowired;
23
 import org.springframework.beans.factory.annotation.Autowired;
19
 import org.springframework.stereotype.Service;
24
 import org.springframework.stereotype.Service;
20
 import org.springframework.transaction.annotation.Transactional;
25
 import org.springframework.transaction.annotation.Transactional;
@@ -23,11 +28,12 @@ import org.springframework.transaction.annotation.Transactional;
23
  * 站级时间段别总过检Service业务层处理
28
  * 站级时间段别总过检Service业务层处理
24
  */
29
  */
25
 @Service
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
     @Autowired
33
     @Autowired
30
     private OperationStationHourlyThroughputMapper operationStationHourlyThroughputMapper;
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
             return Collections.emptyList();
111
             return Collections.emptyList();
106
         }
112
         }
107
 
113
 
114
+        Map<Long, BasePosition> areaInfoMap = Maps.newHashMap();
108
         // 1. 预处理:获取区域名称
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
         // 2. 核心:按小时分组 → 组装成前端需要的层级结构
127
         // 2. 核心:按小时分组 → 组装成前端需要的层级结构
114
         Map<String, List<StationHourlyThroughputVO>> hourGroupMap = stationHourlyThroughputList.stream().collect(Collectors.groupingBy(StationHourlyThroughputVO::getHourOfDay));
128
         Map<String, List<StationHourlyThroughputVO>> hourGroupMap = stationHourlyThroughputList.stream().collect(Collectors.groupingBy(StationHourlyThroughputVO::getHourOfDay));
115
 
129
 
130
+        Map<Long, BasePosition> finalAreaInfoMap = areaInfoMap;
116
         return hourGroupMap.entrySet().stream().map(entry -> {
131
         return hourGroupMap.entrySet().stream().map(entry -> {
117
             String hour = entry.getKey();
132
             String hour = entry.getKey();
118
             List<StationHourlyThroughputVO> hourDataList = entry.getValue();
133
             List<StationHourlyThroughputVO> hourDataList = entry.getValue();
119
 
134
 
120
             // 构建区域列表
135
             // 构建区域列表
121
             List<AreaFlowVO> areaList = hourDataList.stream().map(stats -> {
136
             List<AreaFlowVO> areaList = hourDataList.stream().map(stats -> {
137
+                BasePosition basePosition = finalAreaInfoMap.get(stats.getAreaId());
138
+
122
                 AreaFlowVO areaFlowVO = new AreaFlowVO();
139
                 AreaFlowVO areaFlowVO = new AreaFlowVO();
123
                 areaFlowVO.setAreaId(stats.getAreaId());
140
                 areaFlowVO.setAreaId(stats.getAreaId());
141
+                areaFlowVO.setAreaName(Objects.nonNull(basePosition) ? basePosition.getName() : "");
124
                 areaFlowVO.setAreaFlow(stats.getAreaFlow());
142
                 areaFlowVO.setAreaFlow(stats.getAreaFlow());
125
                 return areaFlowVO;
143
                 return areaFlowVO;
126
             }).collect(Collectors.toList());
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
             <if test="groupId != null "> and group_id = #{groupId}</if>
45
             <if test="groupId != null "> and group_id = #{groupId}</if>
46
             <if test="groupName != null  and groupName != ''"> and group_name like concat('%', #{groupName}, '%')</if>
46
             <if test="groupName != null  and groupName != ''"> and group_name like concat('%', #{groupName}, '%')</if>
47
             <if test="laneId != null  and laneId != ''"> and lane_id = #{laneId}</if>
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
             <if test="hourOfDay != null  and hourOfDay != ''"> and hour_of_day = #{hourOfDay}</if>
49
             <if test="hourOfDay != null  and hourOfDay != ''"> and hour_of_day = #{hourOfDay}</if>
50
         </where>
50
         </where>
51
         order by record_date desc, create_time desc
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
 package com.sundot.airport.system.mapper;
1
 package com.sundot.airport.system.mapper;
2
 
2
 
3
 import java.util.List;
3
 import java.util.List;
4
+import java.util.Set;
4
 
5
 
5
 import com.sundot.airport.system.domain.BasePosition;
6
 import com.sundot.airport.system.domain.BasePosition;
6
 import com.sundot.airport.system.domain.vo.PositionInfoVO;
7
 import com.sundot.airport.system.domain.vo.PositionInfoVO;
@@ -70,6 +71,17 @@ public interface BasePositionMapper {
70
     public List<BasePosition> selectChildrenById(Long id);
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
      * @param list 子元素
87
      * @param list 子元素

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

@@ -235,5 +235,12 @@
235
         ORDER BY la.code, sa.code, ch.code
235
         ORDER BY la.code, sa.code, ch.code
236
     </select>
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
 </mapper>
246
 </mapper>