ParkingLotUseStatisticServiceImpl.java
11.1 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
package com.zteits.park.biz;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.github.pagehelper.PageInfo;
import com.xiaoleilu.hutool.date.DateField;
import com.xiaoleilu.hutool.date.DateTime;
import com.xiaoleilu.hutool.util.CollectionUtil;
import com.zteits.clouds.api.apibase.bean.BizResult;
import com.zteits.clouds.api.apibase.bean.PageBean;
import com.zteits.clouds.api.apibase.constants.ErrorType;
import com.zteits.clouds.api.apibase.exception.BizException;
import com.zteits.clouds.api.dto.clouds.dto.TurnoverRatioDTO;
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.ParkingLotUseStatisticMaxAndMinDTO;
import com.zteits.clouds.api.dto.park.dto.ParkingLotUseStatisticSumDTO;
import com.zteits.clouds.api.dto.park.dto.TodayVehicleFlowOccupyRateAndTurnOverDTO;
import com.zteits.clouds.api.dto.park.param.CommonPlnosQueryRequest;
import com.zteits.clouds.api.dto.park.param.ParkingLotUseStatisticForPageRequest;
import com.zteits.clouds.api.service.park.ParkingLotUseStatisticService;
import com.zteits.park.constant.ParkConstant.ParkingLotUseStatistic.StatisticType;
import com.zteits.park.dao.ParkingLotDao;
import com.zteits.park.dao.ParkingLotUseStatisticDao;
import com.zteits.park.domain.ParkingLotUseStatistic;
import com.zteits.park.domain.ParkingLotUseStatisticMaxAndMin;
import com.zteits.park.domain.ParkingLotUseStatisticSum;
import com.zteits.park.pagepager.PageBeanUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service("com.zteits.park.biz.ParkingLotUseStatisticServiceImpl")
public class ParkingLotUseStatisticServiceImpl implements ParkingLotUseStatisticService {
@Autowired
private ParkingLotUseStatisticDao parkingLotUseStatisticDao;
@Autowired
private ParkingLotDao parkingLotDao;
@Override
public BizResult<PageBean<ParkingLotUseStatisticDTO>> queryParkingLotUseStatisticForPage(
ParkingLotUseStatisticForPageRequest request) {
if (request.getBaseRequest() == null) {
throw new BizException(ErrorType.PARAMM_NULL, "分页参数为空");
}
PageInfo<ParkingLotUseStatistic> pageInfo = parkingLotUseStatisticDao.queryParkingLotUseStatisticForPage(
request.getBeginTime(), request.getEndTime(), request.getQueryKind(), request.getPlNos(),
request.getBaseRequest().getPageNum(), request.getBaseRequest().getPageSize());
PageBean<ParkingLotUseStatisticDTO> pageBean = new PageBean<ParkingLotUseStatisticDTO>();
if (pageInfo != null) {
PageBeanUtil.copyProperties(pageInfo, pageBean, ParkingLotUseStatisticDTO.class);
}
return new BizResult<PageBean<ParkingLotUseStatisticDTO>>(pageBean);
}
@Override
public BizResult<PageBean<ParkingLotUseStatisticDTO>> queryCarFlowByMonthForPage(
ParkingLotUseStatisticForPageRequest request) {
PageInfo<ParkingLotUseStatisticDTO> pageInfo = parkingLotUseStatisticDao.queryCarFlowByMonthForPage(request);
PageBean<ParkingLotUseStatisticDTO> pageBean = new PageBean<>();
if (pageInfo != null) {
PageBeanUtil.copyProperties(pageInfo, pageBean, ParkingLotUseStatisticDTO.class);
}
return new BizResult<>(pageBean);
}
@Override
public BizResult<List<ParkingLotUseStatisticDTO>> queryCarFlowChartByDay(
ParkingLotUseStatisticForPageRequest request) {
List<ParkingLotUseStatisticDTO> list = parkingLotUseStatisticDao.queryCarFlowChartByDay(request);
return new BizResult<>(list);
}
@Override
public BizResult<List<ParkingLotUseStatisticDTO>> queryCarFlowChartByMonth(
ParkingLotUseStatisticForPageRequest request) {
List<ParkingLotUseStatisticDTO> list = parkingLotUseStatisticDao.queryCarFlowChartByMonth(request);
return new BizResult<>(list);
}
@Override
public BizResult<ParkingLotUseStatisticMaxAndMinDTO> QueryVehicleFlowStatisticMaxAndMin(
ParkingLotUseStatisticForPageRequest request) {
ParkingLotUseStatisticMaxAndMin parkingLotUseStatisticMaxAndMin = parkingLotUseStatisticDao
.QueryVehicleFlowStatisticMaxAndMin(request.getBeginTime(), request.getEndTime(),
request.getQueryKind(), request.getPlNos());
ParkingLotUseStatisticMaxAndMinDTO dto = new ParkingLotUseStatisticMaxAndMinDTO();
if (null != parkingLotUseStatisticMaxAndMin) {
BeanUtils.copyProperties(parkingLotUseStatisticMaxAndMin, dto);
}
return new BizResult<ParkingLotUseStatisticMaxAndMinDTO>(dto);
}
@Override
public BizResult<ParkingLotUseStatisticMaxAndMinDTO> QueryBerthUseStatisticMaxAndMin(
ParkingLotUseStatisticForPageRequest request) {
ParkingLotUseStatisticMaxAndMin parkingLotUseStatisticMaxAndMin = parkingLotUseStatisticDao
.QueryBerthUseStatisticMaxAndMin(request.getBeginTime(), request.getEndTime(), request.getQueryKind(),
request.getPlNos());
ParkingLotUseStatisticMaxAndMinDTO dto = new ParkingLotUseStatisticMaxAndMinDTO();
if (null != parkingLotUseStatisticMaxAndMin) {
BeanUtils.copyProperties(parkingLotUseStatisticMaxAndMin, dto);
}
return new BizResult<ParkingLotUseStatisticMaxAndMinDTO>(dto);
}
@Override
public BizResult<ParkingLotUseStatisticSumDTO> QueryInOutParkStatisticSum(
ParkingLotUseStatisticForPageRequest request) {
ParkingLotUseStatisticSum parkingLotUseStatisticSum = parkingLotUseStatisticDao.QueryInOutParkStatisticSum(
request.getBeginTime(), request.getEndTime(), request.getQueryKind(), request.getPlNos());
ParkingLotUseStatisticSumDTO dto = new ParkingLotUseStatisticSumDTO();
if (null != parkingLotUseStatisticSum) {
BeanUtils.copyProperties(parkingLotUseStatisticSum, dto);
}
return new BizResult<ParkingLotUseStatisticSumDTO>(dto);
}
@Override
public BizResult<List<TodayVehicleFlowOccupyRateAndTurnOverDTO>> queryTodayVehicleFlowOccupyRateAndTurnOver(
CommonPlnosQueryRequest request) {
DateTime beginTime = new DateTime().setField(DateField.HOUR_OF_DAY, 0).setField(DateField.MINUTE, 0)
.setField(DateField.SECOND, 0);
DateTime endTime = new DateTime().setField(DateField.HOUR_OF_DAY, 23).setField(DateField.MINUTE, 59)
.setField(DateField.SECOND, 59);
List<TodayVehicleFlowOccupyRateAndTurnOverDTO> result = parkingLotUseStatisticDao
.queryTodayVehicleFlowOccupyRateAndTurnOver(beginTime, endTime, StatisticType.PER1HOUR,
request.getPlNos());
result = fixTodayVehicleFlowOccupyRateAndTurnOverData(result);
return new BizResult<>(result);
}
private List<TodayVehicleFlowOccupyRateAndTurnOverDTO> fixTodayVehicleFlowOccupyRateAndTurnOverData(
List<TodayVehicleFlowOccupyRateAndTurnOverDTO> datas) {
List<TodayVehicleFlowOccupyRateAndTurnOverDTO> realDatas = new ArrayList<>();
Map<Integer, TodayVehicleFlowOccupyRateAndTurnOverDTO> dataMap
= initTodayVehicleFlowOccupyRateAndTurnOverDTOToMap(
datas);
for (int i = 0; i <= 23; i++) {
TodayVehicleFlowOccupyRateAndTurnOverDTO realDTO = null;
if (dataMap.containsKey(i)) {
realDTO = dataMap.get(i);
} else {
realDTO = new TodayVehicleFlowOccupyRateAndTurnOverDTO();
realDTO.setHour(i);
realDTO.setAvgOccupyRate(0.0);
realDTO.setAvgTurnoverRate(0.0);
realDTO.setInCount(0);
realDTO.setOutCount(0);
}
realDatas.add(realDTO);
}
return realDatas;
}
private Map<Integer, TodayVehicleFlowOccupyRateAndTurnOverDTO> initTodayVehicleFlowOccupyRateAndTurnOverDTOToMap(
List<TodayVehicleFlowOccupyRateAndTurnOverDTO> datas) {
Map<Integer, TodayVehicleFlowOccupyRateAndTurnOverDTO> map = new HashMap<>();
for (TodayVehicleFlowOccupyRateAndTurnOverDTO dto : datas) {
map.put(dto.getHour(), dto);
}
return map;
}
@Override
public BizResult<PageBean<MonthVehicleFlowAndVacancyRateAndTurnoverDTO>>
queryMonthVehicleFlowAndVacancyRateAndTurnover(
ParkingLotUseStatisticForPageRequest request) {
if (request == null) {
throw new BizException(ErrorType.PARAMM_NULL, "参数为空");
}
PageInfo<MonthVehicleFlowAndVacancyRateAndTurnoverDTO> pageInfo = parkingLotUseStatisticDao
.queryMonthVehicleFlowAndVacancyRateAndTurnover(request.getBeginTime(), request.getEndTime(),
request.getPlNos(), request.getBaseRequest().getPageNum(),
request.getBaseRequest().getPageSize());
PageBean<MonthVehicleFlowAndVacancyRateAndTurnoverDTO> pageBean
= new PageBean<MonthVehicleFlowAndVacancyRateAndTurnoverDTO>();
if (pageInfo != null) {
PageBeanUtil.copyProperties(pageInfo, pageBean, MonthVehicleFlowAndVacancyRateAndTurnoverDTO.class);
}
return new BizResult<PageBean<MonthVehicleFlowAndVacancyRateAndTurnoverDTO>>(pageBean);
}
@Override
public BizResult<PageBean<TurnoverRatioDTO>> queryTurnoverRatioNew(ParkingLotUseStatisticForPageRequest request) {
if(null ==request.getBeginTime() ){
throw new BizException(ErrorType.PARAMM_NULL, "开始时间参数为空");
}
if(null ==request.getEndTime() ){
throw new BizException(ErrorType.PARAMM_NULL, "结束时间参数为空");
}
if(CollectionUtil.isEmpty(request.getPlNos())){
throw new BizException(ErrorType.PARAMM_NULL, "停车场编号参数为空");
}
PageBean<TurnoverRatioDTO> pageBean=new PageBean<>();
PageInfo<TurnoverRatioDTO> pageInfo = parkingLotUseStatisticDao.queryTurnoverRatioNew(request);
if (pageInfo != null) {
PageBeanUtil.copyProperties(pageInfo, pageBean, TurnoverRatioDTO.class);
}
return new BizResult<>(pageBean);
}
@Override
public BizResult<PageBean<TurnoverRatioDTO>> queryTurnoverRatioNewForChart(ParkingLotUseStatisticForPageRequest request) {
if(null ==request.getBeginTime() ){
throw new BizException(ErrorType.PARAMM_NULL, "开始时间参数为空");
}
if(null ==request.getEndTime() ){
throw new BizException(ErrorType.PARAMM_NULL, "结束时间参数为空");
}
if(CollectionUtil.isEmpty(request.getPlNos())){
throw new BizException(ErrorType.PARAMM_NULL, "停车场编号参数为空");
}
PageBean<TurnoverRatioDTO> pageBean=new PageBean<>();
PageInfo<TurnoverRatioDTO> pageInfo = parkingLotUseStatisticDao.queryTurnoverRatioNewForChart(request);
if (pageInfo == null) {
return new BizResult<>(pageBean);
}
PageBeanUtil.copyProperties(pageInfo, pageBean, TurnoverRatioDTO.class);
return new BizResult<>(pageBean);
}
}