|
|
@@ -1,28 +1,34 @@
|
|
1
|
1
|
package com.sundot.airport.ledger.service.impl;
|
|
2
|
2
|
|
|
3
|
|
-import java.util.Collections;
|
|
4
|
|
-import java.util.List;
|
|
5
|
|
-
|
|
6
|
3
|
import cn.hutool.core.collection.CollUtil;
|
|
7
|
4
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
5
|
+import com.google.common.collect.Lists;
|
|
8
|
6
|
import com.sundot.airport.common.utils.DateUtils;
|
|
9
|
7
|
import com.sundot.airport.ledger.domain.LedgerSeizureStats;
|
|
10
|
8
|
import com.sundot.airport.ledger.domain.vo.CountQueryReqVO;
|
|
11
|
9
|
import com.sundot.airport.ledger.domain.vo.CountSeizureSingleQuantityResVO;
|
|
12
|
10
|
import com.sundot.airport.ledger.domain.vo.CountSeizureTotalQuantityResVO;
|
|
|
11
|
+import com.sundot.airport.ledger.domain.vo.LaneThroughputResVO;
|
|
13
|
12
|
import com.sundot.airport.ledger.domain.vo.SeizeCategoryQuantityVO;
|
|
14
|
13
|
import com.sundot.airport.ledger.domain.vo.SeizeItemVO;
|
|
15
|
14
|
import com.sundot.airport.ledger.domain.vo.SeizeTotalAndItemVO;
|
|
16
|
15
|
import com.sundot.airport.ledger.domain.vo.SeizureAreaVO;
|
|
17
|
16
|
import com.sundot.airport.ledger.mapper.LedgerSeizureStatsMapper;
|
|
18
|
17
|
import com.sundot.airport.ledger.service.ILedgerSeizureStatsService;
|
|
|
18
|
+import lombok.extern.slf4j.Slf4j;
|
|
19
|
19
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
20
|
20
|
import org.springframework.stereotype.Service;
|
|
21
|
21
|
import org.springframework.transaction.annotation.Transactional;
|
|
22
|
22
|
|
|
|
23
|
+import java.util.Date;
|
|
|
24
|
+import java.util.List;
|
|
|
25
|
+import java.util.Map;
|
|
|
26
|
+import java.util.stream.Collectors;
|
|
|
27
|
+
|
|
23
|
28
|
/**
|
|
24
|
29
|
* 查获违规品统计Service实现
|
|
25
|
30
|
*/
|
|
|
31
|
+@Slf4j
|
|
26
|
32
|
@Service
|
|
27
|
33
|
public class LedgerSeizureStatsServiceImpl extends ServiceImpl<LedgerSeizureStatsMapper, LedgerSeizureStats> implements ILedgerSeizureStatsService {
|
|
28
|
34
|
|
|
|
@@ -54,7 +60,43 @@ public class LedgerSeizureStatsServiceImpl extends ServiceImpl<LedgerSeizureStat
|
|
54
|
60
|
@Override
|
|
55
|
61
|
public List<CountSeizureTotalQuantityResVO> countSeizureTotalQuantity(CountQueryReqVO countQueryReq) {
|
|
56
|
62
|
List<CountSeizureTotalQuantityResVO> seizureQuantityResList = this.baseMapper.countSeizureTotalQuantity(countQueryReq);
|
|
57
|
|
- return CollUtil.emptyIfNull(seizureQuantityResList);
|
|
|
63
|
+ seizureQuantityResList = CollUtil.emptyIfNull(seizureQuantityResList);
|
|
|
64
|
+
|
|
|
65
|
+ log.info("SQL查询返回数据条数: {}", seizureQuantityResList.size());
|
|
|
66
|
+
|
|
|
67
|
+ // 生成近30天的日期列表
|
|
|
68
|
+ List<Date> last30Days = DateUtils.generateLast30Days();
|
|
|
69
|
+
|
|
|
70
|
+ // 将查询结果按日期建立映射(只比较日期部分,忽略时间)
|
|
|
71
|
+ Map<String, CountSeizureTotalQuantityResVO> dataMap = seizureQuantityResList.stream()
|
|
|
72
|
+ .collect(Collectors.toMap(
|
|
|
73
|
+ vo -> DateUtils.formatDateKey(vo.getRecordDate()),
|
|
|
74
|
+ vo -> vo,
|
|
|
75
|
+ (existing, replacement) -> existing
|
|
|
76
|
+ ));
|
|
|
77
|
+
|
|
|
78
|
+ log.info("数据Map中的日期键: {}", dataMap.keySet());
|
|
|
79
|
+
|
|
|
80
|
+ // 获取小组名称
|
|
|
81
|
+ String groupName = "";
|
|
|
82
|
+ if (CollUtil.isNotEmpty(seizureQuantityResList)) {
|
|
|
83
|
+ groupName = seizureQuantityResList.get(0).getGroupName();
|
|
|
84
|
+ }
|
|
|
85
|
+
|
|
|
86
|
+ // 补齐缺失的日期数据
|
|
|
87
|
+ List<CountSeizureTotalQuantityResVO> resultList = Lists.newArrayList();
|
|
|
88
|
+ for (Date date : last30Days) {
|
|
|
89
|
+ String dateKey = DateUtils.formatDateKey(date);
|
|
|
90
|
+ if (dataMap.containsKey(dateKey)) {
|
|
|
91
|
+ // 存在的日期,使用查询结果
|
|
|
92
|
+ resultList.add(dataMap.get(dateKey));
|
|
|
93
|
+ } else {
|
|
|
94
|
+ // 缺失的日期,补充0数据
|
|
|
95
|
+ CountSeizureTotalQuantityResVO countSeizureTotalQuantity = new CountSeizureTotalQuantityResVO(date, groupName);
|
|
|
96
|
+ resultList.add(countSeizureTotalQuantity);
|
|
|
97
|
+ }
|
|
|
98
|
+ }
|
|
|
99
|
+ return resultList;
|
|
58
|
100
|
}
|
|
59
|
101
|
|
|
60
|
102
|
/**
|
|
|
@@ -69,7 +111,43 @@ public class LedgerSeizureStatsServiceImpl extends ServiceImpl<LedgerSeizureStat
|
|
69
|
111
|
@Override
|
|
70
|
112
|
public List<CountSeizureSingleQuantityResVO> countSeizureSingleQuantity(CountQueryReqVO countQueryReq) {
|
|
71
|
113
|
List<CountSeizureSingleQuantityResVO> seizureQuantityResList = this.baseMapper.countSeizureSingleQuantity(countQueryReq);
|
|
72
|
|
- return CollUtil.emptyIfNull(seizureQuantityResList);
|
|
|
114
|
+ seizureQuantityResList = CollUtil.emptyIfNull(seizureQuantityResList);
|
|
|
115
|
+
|
|
|
116
|
+ log.info("SQL查询返回数据条数: {}", seizureQuantityResList.size());
|
|
|
117
|
+
|
|
|
118
|
+ // 生成近30天的日期列表
|
|
|
119
|
+ List<Date> last30Days = DateUtils.generateLast30Days();
|
|
|
120
|
+
|
|
|
121
|
+ // 将查询结果按日期建立映射(只比较日期部分,忽略时间)
|
|
|
122
|
+ Map<String, CountSeizureSingleQuantityResVO> dataMap = seizureQuantityResList.stream()
|
|
|
123
|
+ .collect(Collectors.toMap(
|
|
|
124
|
+ vo -> DateUtils.formatDateKey(vo.getRecordDate()),
|
|
|
125
|
+ vo -> vo,
|
|
|
126
|
+ (existing, replacement) -> existing
|
|
|
127
|
+ ));
|
|
|
128
|
+
|
|
|
129
|
+ log.info("数据Map中的日期键: {}", dataMap.keySet());
|
|
|
130
|
+
|
|
|
131
|
+ // 获取小组名称
|
|
|
132
|
+ String groupName = "";
|
|
|
133
|
+ if (CollUtil.isNotEmpty(seizureQuantityResList)) {
|
|
|
134
|
+ groupName = seizureQuantityResList.get(0).getGroupName();
|
|
|
135
|
+ }
|
|
|
136
|
+
|
|
|
137
|
+ // 补齐缺失的日期数据
|
|
|
138
|
+ List<CountSeizureSingleQuantityResVO> resultList = Lists.newArrayList();
|
|
|
139
|
+ for (Date date : last30Days) {
|
|
|
140
|
+ String dateKey = DateUtils.formatDateKey(date);
|
|
|
141
|
+ if (dataMap.containsKey(dateKey)) {
|
|
|
142
|
+ // 存在的日期,使用查询结果
|
|
|
143
|
+ resultList.add(dataMap.get(dateKey));
|
|
|
144
|
+ } else {
|
|
|
145
|
+ // 缺失的日期,补充0数据
|
|
|
146
|
+ CountSeizureSingleQuantityResVO countSeizureTotalQuantity = new CountSeizureSingleQuantityResVO(date, groupName);
|
|
|
147
|
+ resultList.add(countSeizureTotalQuantity);
|
|
|
148
|
+ }
|
|
|
149
|
+ }
|
|
|
150
|
+ return resultList;
|
|
73
|
151
|
}
|
|
74
|
152
|
|
|
75
|
153
|
/**
|