ParkingLotUseStatisticDaoImpl.java
11.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
package com.zteits.park.dao.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.clouds.common.utils.DateUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xiaoleilu.hutool.util.CollectionUtil;
import com.zteits.clouds.api.apibase.constants.DataStatusEnum;
import com.zteits.clouds.api.dto.clouds.dto.TurnoverRatioDTO;
import com.zteits.clouds.api.dto.govclouds.dto.ParkingOccupyDTO;
import com.zteits.clouds.api.dto.govclouds.param.QueryParkingOccupyRequest;
import com.zteits.clouds.api.dto.park.dto.MonthVehicleFlowAndVacancyRateAndTurnoverDTO;
import com.zteits.clouds.api.dto.park.dto.ParkingLotUseStatisticDTO;
import com.zteits.clouds.api.dto.park.dto.TodayVehicleFlowOccupyRateAndTurnOverDTO;
import com.zteits.clouds.api.dto.park.param.ParkingLotUseStatisticForPageRequest;
import com.zteits.park.dao.ParkingLotUseStatisticDao;
import com.zteits.park.domain.ParkingLotUseStatistic;
import com.zteits.park.domain.ParkingLotUseStatisticExample;
import com.zteits.park.domain.ParkingLotUseStatisticExample.Criteria;
import com.zteits.park.domain.ParkingLotUseStatisticMaxAndMin;
import com.zteits.park.domain.ParkingLotUseStatisticSum;
import com.zteits.park.domain.ParkingOccupyDO;
import com.zteits.park.mapper.ParkingLotUseStatisticMapper;
import com.zteits.park.mapper.smapper.ParkingLotUseStatisticSMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
@Component
public class ParkingLotUseStatisticDaoImpl implements ParkingLotUseStatisticDao {
@Autowired
private ParkingLotUseStatisticMapper parkingLotUseStatisticMapper;
@Autowired
private ParkingLotUseStatisticSMapper parkingLotUseStatisticSMapper;
@Override
public int insertSelective(ParkingLotUseStatistic record) {
return parkingLotUseStatisticMapper.insertSelective(record);
}
@Override
public int batchSave(List<ParkingLotUseStatistic> records) {
if (CollectionUtil.isEmpty(records)) {
return 0;
}
return parkingLotUseStatisticSMapper.batchSave(records);
}
@Override
public PageInfo<ParkingLotUseStatistic> queryParkingLotUseStatisticForPage(
Date beginTime, Date endTime, Integer statisticType, List<String> plNos, Integer pageNum, Integer pageSize) {
// 1.设置分页信息
PageHelper.startPage(pageNum, pageSize);
//2.查询数据
ParkingLotUseStatisticExample example = new ParkingLotUseStatisticExample();
Criteria sql = example.createCriteria();
sql.andDataStatusEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
if (!CollectionUtils.isEmpty(plNos)) {
sql.andPlNoIn(plNos);
}
if (null != statisticType) {
sql.andStatisticTypeEqualTo(statisticType);
}
if (null != beginTime && null != endTime) {
sql.andStatisticBeginTimeBetween(beginTime, endTime);
} else if (null != beginTime) {
sql.andStatisticBeginTimeGreaterThanOrEqualTo(beginTime);
} else if (null != endTime) {
sql.andStatisticBeginTimeLessThanOrEqualTo(endTime);
}
example.setOrderByClause("statistic_begin_time desc,pl_no asc");
List<ParkingLotUseStatistic> list = parkingLotUseStatisticMapper.selectByExample(example);
return new PageInfo<>(list);
}
@Override
public PageInfo<ParkingLotUseStatisticDTO> queryCarFlowByMonthForPage(
ParkingLotUseStatisticForPageRequest request) {
Integer pageNum = request.getBaseRequest().getPageNum();
pageNum = pageNum == null ? 1 : pageNum;
Integer pageSize = request.getBaseRequest().getPageSize();
pageSize = pageSize == null ? 10 : pageSize;
PageHelper.startPage(pageNum, pageSize);
List<ParkingLotUseStatisticDTO> dtoList = parkingLotUseStatisticSMapper.queryCarFlowByMonthForPage(request);
return new PageInfo<>(dtoList);
}
@Override
public ParkingLotUseStatisticMaxAndMin QueryVehicleFlowStatisticMaxAndMin(
Date beginTime,
Date endTime, Integer statisticType, List<String> plNos) {
return parkingLotUseStatisticSMapper.QueryVehicleFlowStatisticMaxAndMin(beginTime, endTime, statisticType,
plNos);
}
@Override
public ParkingLotUseStatisticMaxAndMin QueryBerthUseStatisticMaxAndMin(
Date beginTime,
Date endTime, Integer statisticType, List<String> plNos) {
return parkingLotUseStatisticSMapper.QueryBerthUseStatisticMaxAndMin(beginTime, endTime, statisticType, plNos);
}
@Override
public long countByExample(ParkingLotUseStatisticExample example) {
return parkingLotUseStatisticMapper.countByExample(example);
}
@Override
public ParkingLotUseStatisticSum QueryInOutParkStatisticSum(Date beginTime, Date endTime, Integer statisticType,
List<String> plNos) {
return parkingLotUseStatisticSMapper.QueryInOutParkStatisticSum(beginTime, endTime, statisticType, plNos);
}
@Override
public List<TodayVehicleFlowOccupyRateAndTurnOverDTO> queryTodayVehicleFlowOccupyRateAndTurnOver(Date beginTime,
Date endTime, Integer statisticType, List<String> plNos) {
return parkingLotUseStatisticSMapper.queryTodayVehicleFlowOccupyRateAndTurnOver(beginTime, endTime,
statisticType, plNos);
}
@Override
public PageInfo<MonthVehicleFlowAndVacancyRateAndTurnoverDTO> queryMonthVehicleFlowAndVacancyRateAndTurnover(
Date beginTime, Date endTime, List<String> plNos, Integer pageNum, Integer pageSize) {
// 1.set page information
// 设置分页信息
PageHelper.startPage(pageNum, pageSize);
//2.query Monthly parking volume, vacancy rate and turnover rate are examined
//按月统计进出场车流量和占用率和周转率
List<MonthVehicleFlowAndVacancyRateAndTurnoverDTO> list = parkingLotUseStatisticSMapper
.queryMonthVehicleFlowAndVacancyRateAndTurnover(beginTime, endTime, plNos);
return new PageInfo<MonthVehicleFlowAndVacancyRateAndTurnoverDTO>(list);
}
@Override
public List<ParkingOccupyDTO> queryTwentyFourHoursOccupyRate(QueryParkingOccupyRequest request) {
List<ParkingOccupyDTO> dtoList = new ArrayList<>();
List<ParkingOccupyDO> doList = parkingLotUseStatisticSMapper.queryTwentyFourHoursOccupyRate(request);
if (!(CollectionUtils.isEmpty(doList))) {
for (ParkingOccupyDO pdo : doList) {
ParkingOccupyDTO dto = new ParkingOccupyDTO();
BeanUtils.copyProperties(pdo, dto);
dtoList.add(dto);
}
}
return dtoList;
}
@Override
public void statistic20MinData(Date startDate, Date endDate, List<Integer> states) {
parkingLotUseStatisticSMapper.statistic20MinData(startDate, endDate, states);
}
@Override
public void statistic20MinDataForSelectByLCPark(Date startDate, Date endDate, List<Integer> states) {
int pageSize = 100;
List<ParkingLotUseStatistic> temps;
String startDateStr = com.xiaoleilu.hutool.date.DateUtil.format(startDate,"yyyy-MM-dd HH:mm:ss");
String endDateStr = com.xiaoleilu.hutool.date.DateUtil.format(endDate,"yyyy-MM-dd HH:mm:ss");
String recordStr = com.xiaoleilu.hutool.date.DateUtil.date().toString("yyyyMM");
//统计路侧的
List<ParkingLotUseStatistic> parkingLotUseStatistics = parkingLotUseStatisticSMapper.statistic20MinDataForSelectByLCPark(startDateStr,endDateStr,states,recordStr);
//分页处理
if(CollectionUtil.isNotEmpty(parkingLotUseStatistics)){
int totals = parkingLotUseStatistics.size();
int page = totals/pageSize;
for (int i=0;i<page;i++) {
temps = parkingLotUseStatistics.subList(i*pageSize, i*pageSize+pageSize);
parkingLotUseStatisticSMapper.statistic20MinDataForInsert(temps);
}
;
if(totals%100 > 0){
temps = parkingLotUseStatistics.subList(page*pageSize, page*pageSize+totals%pageSize);
parkingLotUseStatisticSMapper.statistic20MinDataForInsert(temps);
}
}
}
@Override
public void statistic20MinDataForSelectByFBPark(Date startDate, Date endDate, List<Integer> states) {
int pageSize = 100;
List<ParkingLotUseStatistic> temps = new ArrayList<ParkingLotUseStatistic>();
String startDateStr = com.xiaoleilu.hutool.date.DateUtil.format(startDate,"yyyy-MM-dd HH:mm:ss");
String endDateStr = com.xiaoleilu.hutool.date.DateUtil.format(endDate,"yyyy-MM-dd HH:mm:ss");
String recordStr = com.xiaoleilu.hutool.date.DateUtil.date().toString("yyyyMM");
//List<ParkingLotUseStatistic> parkingLotUseStatistics = parkingLotUseStatisticSMapper.statistic20MinDataForSelect(startDate, endDate, states);
//统计封闭的
List<ParkingLotUseStatistic> parkingLotUseStatistics = parkingLotUseStatisticSMapper.statistic20MinDataForSelectByFBPark(startDate,endDate,states);
//分页处理
if(CollectionUtil.isNotEmpty(parkingLotUseStatistics)){
int totals = parkingLotUseStatistics.size();
int page = totals/pageSize;
for (int i=0;i<page;i++) {
temps = parkingLotUseStatistics.subList(i*pageSize, i*pageSize+pageSize);
parkingLotUseStatisticSMapper.statistic20MinDataForInsert(temps);
}
if(totals%100 > 0){
temps = parkingLotUseStatistics.subList(page*pageSize, page*pageSize+totals%pageSize);
parkingLotUseStatisticSMapper.statistic20MinDataForInsert(temps);
}
}
}
@Override
public void static1HourAnd1DayData(Date startDate, Date endDate, Integer type) {
parkingLotUseStatisticSMapper.static1HourAnd1DayData(startDate, endDate, type);
}
@Override
public List<ParkingLotUseStatisticDTO> queryCarFlowChartByDay(ParkingLotUseStatisticForPageRequest request) {
return parkingLotUseStatisticSMapper.queryCarFlowChartByDay(request);
}
@Override
public List<ParkingLotUseStatisticDTO> queryCarFlowChartByMonth(ParkingLotUseStatisticForPageRequest request) {
return parkingLotUseStatisticSMapper.queryCarFlowChartByMonth(request);
}
@Override
public PageInfo<TurnoverRatioDTO> queryTurnoverRatioNew(ParkingLotUseStatisticForPageRequest request) {
PageHelper.startPage(request.getBaseRequest().getPageNum(),request.getBaseRequest().getPageSize());
List<TurnoverRatioDTO> list=parkingLotUseStatisticSMapper.queryTurnoverRatioNew(request);
return new PageInfo<>(list);
}
@Override
public PageInfo<TurnoverRatioDTO> queryTurnoverRatioNewForChart(ParkingLotUseStatisticForPageRequest request) {
PageHelper.startPage(request.getBaseRequest().getPageNum(),request.getBaseRequest().getPageSize());
List<TurnoverRatioDTO> list=parkingLotUseStatisticSMapper.queryTurnoverRatioNewForChart(request);
return new PageInfo<>(list);
}
@Override
public List<ParkingLotUseStatistic> query20MinNewDataGroupByPlNO() {
return parkingLotUseStatisticSMapper.query20MinNewDataGroupByPlNO();
}
}