Commit ec9945afd93415bdb755eb8a61d7ff6324b3f97f
1 parent
6937be2b
提交
Showing
1 changed file
with
125 additions
and
63 deletions
src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/BerthsStatisticController.java
... | ... | @@ -2,6 +2,7 @@ package com.zteits.irain.portal.web.parkinglotcloudplatform.datastatistic; |
2 | 2 | |
3 | 3 | import java.math.BigDecimal; |
4 | 4 | import java.sql.Timestamp; |
5 | +import java.text.DecimalFormat; | |
5 | 6 | import java.text.SimpleDateFormat; |
6 | 7 | import java.util.ArrayList; |
7 | 8 | import java.util.Calendar; |
... | ... | @@ -30,8 +31,6 @@ import org.springframework.web.bind.annotation.ResponseBody; |
30 | 31 | import com.alibaba.dubbo.common.utils.CollectionUtils; |
31 | 32 | import com.alibaba.fastjson.JSON; |
32 | 33 | import com.clouds.common.cache.park.ParkingLotCacheUtil; |
33 | -import com.clouds.common.entity.UserInfo; | |
34 | -import com.clouds.common.redis.RedisCacheUtil; | |
35 | 34 | import com.clouds.common.utils.DateUtil; |
36 | 35 | import com.clouds.common.utils.ResultUtils; |
37 | 36 | import com.clouds.common.utils.excle.ExcelUtil; |
... | ... | @@ -54,14 +53,12 @@ import com.zteits.clouds.api.dto.park.dto.ParkingLotUseStatisticMaxAndMinDTO; |
54 | 53 | import com.zteits.clouds.api.dto.park.param.ParkFreeBerthGetByPlnoRequest; |
55 | 54 | import com.zteits.clouds.api.dto.park.param.ParkingLotUseStatisticForPageRequest; |
56 | 55 | import com.zteits.clouds.api.dto.park.param.QueryParkLotInfoByPkNoRequest; |
57 | -import com.zteits.clouds.api.dto.pay.TdBOrderDTO; | |
58 | 56 | import com.zteits.clouds.api.dto.pay.param.QueryTodayOrderRequest; |
59 | 57 | import com.zteits.clouds.api.service.park.ParkFreeBerthService; |
60 | 58 | import com.zteits.clouds.api.service.park.ParkingLotQueryService; |
61 | 59 | import com.zteits.clouds.api.service.park.ParkingLotUseStatisticService; |
62 | 60 | import com.zteits.clouds.api.service.pay.TdBOrderService; |
63 | 61 | import com.zteits.irain.portal.constant.ParkConstant; |
64 | -import com.zteits.irain.portal.vo.govclouds.ParkLotStatisticVO; | |
65 | 62 | import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.LineChartVO; |
66 | 63 | import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.LineChartVO.SerieVO; |
67 | 64 | import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.ParkStaticsticAndTodayAmountVO; |
... | ... | @@ -94,8 +91,6 @@ public class BerthsStatisticController extends BizController { |
94 | 91 | @Autowired |
95 | 92 | private ParkingLotUseStatisticService parkingLotStatisticService; |
96 | 93 | @Autowired |
97 | - private SessionCommUtil sessionCommUtil; | |
98 | - @Autowired | |
99 | 94 | private TdBOrderService tdBOrderService; |
100 | 95 | @Autowired |
101 | 96 | private ParkFreeBerthService parkFreeBerthService; |
... | ... | @@ -137,6 +132,13 @@ public class BerthsStatisticController extends BizController { |
137 | 132 | return new BizResultVO<>(respondObject); |
138 | 133 | } |
139 | 134 | |
135 | + /** | |
136 | + * langlw 2017-8-24 | |
137 | + * @param requestObject | |
138 | + * @return | |
139 | + * @throws InstantiationException | |
140 | + * @throws IllegalAccessException | |
141 | + */ | |
140 | 142 | @ApiOperation("获取车位使用情况统计列表") |
141 | 143 | @PostMapping("getstatisticlist") |
142 | 144 | @ResponseBody |
... | ... | @@ -146,68 +148,36 @@ public class BerthsStatisticController extends BizController { |
146 | 148 | if (null == requestObject.getBeginTime() || null == requestObject.getEndTime()) { |
147 | 149 | throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间"); |
148 | 150 | } |
149 | - | |
150 | - Calendar beginc = Calendar.getInstance(); | |
151 | - beginc.setTime(requestObject.getBeginTime()); | |
152 | - int beginYear = beginc.get(Calendar.YEAR); | |
153 | - int beginMonth = beginc.get(Calendar.MONTH) + 1; | |
154 | - int beginDay = beginc.get(Calendar.DAY_OF_MONTH); | |
155 | - | |
156 | - Calendar endc = Calendar.getInstance(); | |
157 | - endc.setTime(requestObject.getEndTime()); | |
158 | - int endYear = endc.get(Calendar.YEAR); | |
159 | - int endMonth = endc.get(Calendar.MONTH) + 1; | |
160 | - int endDay = endc.get(Calendar.DAY_OF_MONTH); | |
161 | - | |
162 | - if (beginYear == endYear && beginMonth == endMonth && beginDay == endDay) { | |
163 | - // 2表示按每小时统计 | |
164 | - requestObject.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR); | |
165 | - } else { | |
166 | - // 3表示按每天统计 | |
167 | - requestObject.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY); | |
168 | - } | |
151 | + requestObject.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY); | |
169 | 152 | BizResult<PageBean<ParkingLotUseStatisticDTO>> respondObject = parkingLotStatisticService |
170 | 153 | .queryParkingLotUseStatisticForPage(requestObject); |
171 | 154 | return returnJqGridData(respondObject, ParkingLotUseStatisticDTO.class); |
172 | 155 | } |
173 | 156 | |
174 | - @ApiOperation("导出车流量数据统计excel") | |
157 | + /** | |
158 | + * langlw 2017-8-24 | |
159 | + * @param beginTime | |
160 | + * @param endTime | |
161 | + * @param plNos | |
162 | + * @param requests | |
163 | + * @param response | |
164 | + */ | |
165 | + @ApiOperation("导出车位数据统计excel") | |
175 | 166 | @GetMapping("exportBerthStatisticExcel") |
176 | 167 | public void excelParkingLotUseStatistic(@RequestParam String beginTime, @RequestParam String endTime, |
177 | - @RequestParam String plNos, HttpServletRequest requests, HttpServletResponse response) { | |
168 | + @RequestParam List<String> plNos, HttpServletRequest requests, HttpServletResponse response) { | |
178 | 169 | ParkingLotUseStatisticForPageRequest request = new ParkingLotUseStatisticForPageRequest(); |
179 | 170 | request.setSysCode(sysCode); |
180 | 171 | request.setBeginTime(DateUtil.to_date(beginTime, DateUtil.DATETIME_FORMAT)); |
181 | 172 | request.setEndTime(DateUtil.to_date(endTime, DateUtil.DATETIME_FORMAT)); |
182 | - List<String> plNoslist = new ArrayList<>(); | |
183 | - plNoslist.add(plNos); | |
184 | - request.setPlNos(plNoslist); | |
173 | + request.setPlNos(plNos); | |
185 | 174 | request.setBaseRequest(new BaseInfo(1, 0)); |
186 | - | |
187 | - Calendar beginc = Calendar.getInstance(); | |
188 | - beginc.setTime(request.getBeginTime()); | |
189 | - int beginYear = beginc.get(Calendar.YEAR); | |
190 | - int beginMonth = beginc.get(Calendar.MONTH) + 1; | |
191 | - int beginDay = beginc.get(Calendar.DAY_OF_MONTH); | |
192 | - | |
193 | - Calendar endc = Calendar.getInstance(); | |
194 | - endc.setTime(request.getEndTime()); | |
195 | - int endYear = endc.get(Calendar.YEAR); | |
196 | - int endMonth = endc.get(Calendar.MONTH) + 1; | |
197 | - int endDay = endc.get(Calendar.DAY_OF_MONTH); | |
198 | - | |
199 | - if (beginYear == endYear && beginMonth == endMonth && beginDay == endDay) { | |
200 | - // 2表示按每小时统计 | |
201 | - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR); | |
202 | - } else { | |
203 | - // 3表示按每天统计 | |
204 | - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY); | |
205 | - } | |
175 | + request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1DAY); | |
206 | 176 | BizResult<PageBean<ParkingLotUseStatisticDTO>> bizResult = parkingLotStatisticService |
207 | 177 | .queryParkingLotUseStatisticForPage(request); |
208 | 178 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
209 | 179 | SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd"); |
210 | - String[] title = new String[] { "时间", "空置率", "周转率" }; | |
180 | + String[] title = new String[] { "时间","停车场名称", "占用率", "周转率" }; | |
211 | 181 | String sheetName = "车位管理"; |
212 | 182 | String fileName = "车位管理" + format2.format(new Date()); |
213 | 183 | // 1.创建excel信息 |
... | ... | @@ -220,11 +190,15 @@ public class BerthsStatisticController extends BizController { |
220 | 190 | if (CollectionUtils.isNotEmpty(bizResult.getData().getDataList())) { |
221 | 191 | list = bizResult.getData().getDataList(); |
222 | 192 | } |
193 | + DecimalFormat df=new DecimalFormat(".##"); | |
194 | + | |
223 | 195 | for (ParkingLotUseStatisticDTO e : list) { |
224 | 196 | Object[] obj = new Object[title.length]; |
225 | 197 | int index = 0; |
226 | 198 | obj[index++] = format.format(e.getStatisticBeginTime()); |
227 | - obj[index++] = e.getFreeRatio() * 100 + "%"; | |
199 | + obj[index++] = e.getPlName(); | |
200 | + double d=100-e.getFreeRatio()* 100; | |
201 | + obj[index++] = df.format(d) + "%"; | |
228 | 202 | obj[index++] = e.getTurnoverRatio(); |
229 | 203 | contentList.add(obj); |
230 | 204 | } |
... | ... | @@ -236,7 +210,7 @@ public class BerthsStatisticController extends BizController { |
236 | 210 | |
237 | 211 | /** |
238 | 212 | * 根据时间获取车位空置率折线图 |
239 | - * | |
213 | + * langlw 2017-8-24 | |
240 | 214 | * @param request |
241 | 215 | * @return |
242 | 216 | */ |
... | ... | @@ -252,7 +226,6 @@ public class BerthsStatisticController extends BizController { |
252 | 226 | logger.info("根据停车场编号获取该停车场车位空置率折线图"); |
253 | 227 | Calendar beginTime = Calendar.getInstance(); |
254 | 228 | beginTime.setTime(request.getBeginTime()); |
255 | -// int year = beginTime.get(Calendar.YEAR); | |
256 | 229 | |
257 | 230 | Calendar endTime = Calendar.getInstance(); |
258 | 231 | endTime.setTime(request.getEndTime()); |
... | ... | @@ -335,7 +308,6 @@ public class BerthsStatisticController extends BizController { |
335 | 308 | throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间"); |
336 | 309 | } |
337 | 310 | Calendar beginTime = Calendar.getInstance(); |
338 | -// int year = beginTime.get(Calendar.YEAR); | |
339 | 311 | beginTime.setTime(request.getBeginTime()); |
340 | 312 | |
341 | 313 | Calendar endTime = Calendar.getInstance(); |
... | ... | @@ -398,22 +370,22 @@ public class BerthsStatisticController extends BizController { |
398 | 370 | for (ParkingLotUseStatisticDTO statisticDTO : useStatisticDTOs) { |
399 | 371 | String key = statisticDTO.getPlNo(); |
400 | 372 | parkNameMap.put(key, statisticDTO.getPlName()); |
401 | - String statisBeginTime = DateUtil.getDateString(statisticDTO.getStatisticBeginTime(), dateType); | |
402 | - // 保存空置率 | |
373 | + String statisEndTime = DateUtil.getDateString(statisticDTO.getStatisticEndTime(), dateType); | |
374 | + // 保存占用率 | |
403 | 375 | if (!parkLotMap.containsKey(key)) { |
404 | 376 | Map<String, Double> timeAndVal = Maps.newHashMap(); |
405 | 377 | if (ParkConstant.ParkingLotUseStatistic.BerthRatioType.FREE == berthRatio) { |
406 | - timeAndVal.put(statisBeginTime, statisticDTO.getFreeRatio() * 100); | |
378 | + timeAndVal.put(statisEndTime, statisticDTO.getFreeRatio() * 100); | |
407 | 379 | parkLotMap.put(key, timeAndVal); |
408 | 380 | } else if (ParkConstant.ParkingLotUseStatistic.BerthRatioType.TURNOVER == berthRatio) { |
409 | - timeAndVal.put(statisBeginTime, statisticDTO.getTurnoverRatio() * 100); | |
381 | + timeAndVal.put(statisEndTime, statisticDTO.getTurnoverRatio() * 100); | |
410 | 382 | parkLotMap.put(key, timeAndVal); |
411 | 383 | } |
412 | 384 | } else { |
413 | 385 | if (ParkConstant.ParkingLotUseStatistic.BerthRatioType.FREE == berthRatio) { |
414 | - parkLotMap.get(key).put(statisBeginTime, statisticDTO.getFreeRatio() * 100); | |
386 | + parkLotMap.get(key).put(statisEndTime, statisticDTO.getFreeRatio() * 100); | |
415 | 387 | } else if (ParkConstant.ParkingLotUseStatistic.BerthRatioType.TURNOVER == berthRatio) { |
416 | - parkLotMap.get(key).put(statisBeginTime, statisticDTO.getTurnoverRatio() * 100); | |
388 | + parkLotMap.get(key).put(statisEndTime, statisticDTO.getTurnoverRatio() * 100); | |
417 | 389 | } |
418 | 390 | } |
419 | 391 | |
... | ... | @@ -466,7 +438,12 @@ public class BerthsStatisticController extends BizController { |
466 | 438 | } |
467 | 439 | |
468 | 440 | |
469 | - | |
441 | + /** | |
442 | + * langlw 2017-8-23 | |
443 | + * @param request | |
444 | + * @return | |
445 | + * @throws Exception | |
446 | + */ | |
470 | 447 | @ApiOperation("获取停车场信息统计和今日收益") |
471 | 448 | @PostMapping("getParkStaticsticAndTodayAmount") |
472 | 449 | @ResponseBody |
... | ... | @@ -512,5 +489,90 @@ public class BerthsStatisticController extends BizController { |
512 | 489 | |
513 | 490 | |
514 | 491 | |
492 | + /** | |
493 | + * langlw 2017-8-24 | |
494 | + * @param beginTime | |
495 | + * @param endTime | |
496 | + * @param plNos | |
497 | + * @param requests | |
498 | + * @param response | |
499 | + */ | |
500 | + @ApiOperation("下载车位数据统计详情excel") | |
501 | + @GetMapping("downloadBerthStatisticExcel") | |
502 | + public void downloadBerthStatisticExcel(@RequestParam String beginTime, @RequestParam String endTime, | |
503 | + @RequestParam List<String> plNos, @RequestParam String parkName, | |
504 | + HttpServletRequest requests, HttpServletResponse response) { | |
505 | + ParkingLotUseStatisticForPageRequest request = new ParkingLotUseStatisticForPageRequest(); | |
506 | + request.setSysCode(sysCode); | |
507 | + request.setBeginTime(DateUtil.to_date(beginTime, DateUtil.DATETIME_FORMAT)); | |
508 | + request.setEndTime(DateUtil.to_date(endTime, DateUtil.DATETIME_FORMAT)); | |
509 | + request.setPlNos(plNos); | |
510 | + request.setBaseRequest(new BaseInfo(1, 0)); | |
511 | + request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR); | |
512 | + | |
513 | + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
514 | + SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd"); | |
515 | + | |
516 | + List<String> xAxisData = Lists.newArrayList(); | |
517 | + String[] title = new String[26]; | |
518 | + title[0]=""; | |
519 | + for (int j = 0; j <= 24; j++) { | |
520 | + String hour = String.format("%02d", (j)); | |
521 | + title[j+1]=hour+":00"; | |
522 | + xAxisData.add(hour+":00"); | |
523 | + } | |
524 | + | |
525 | + | |
526 | + String dateType ="HH:mm"; | |
527 | + int berthRatio = ParkConstant.ParkingLotUseStatistic.BerthRatioType.TURNOVER; | |
528 | + LineChartVO turnOverBerthRatios = getFreeBerthRatios(request, xAxisData, dateType, berthRatio); | |
529 | + int berthFreeRatio = ParkConstant.ParkingLotUseStatistic.BerthRatioType.FREE; | |
530 | + LineChartVO freeBerthRatios = getFreeBerthRatios(request, xAxisData, dateType, berthFreeRatio); | |
531 | + | |
532 | + | |
533 | + | |
534 | + String sheetName = "日报表车位使用统计"; | |
535 | + String fileName = "日报表车位使用统计" + format2.format(new Date()); | |
536 | + // 1.创建excel信息 | |
537 | + XSSFSheet workSheet = ExcelUtil.createExcel(sheetName); | |
538 | + // 2.设置excel表头和表体 | |
539 | + Layouter.buildReport(workSheet, title, 0, 0); | |
540 | + // 3.填充数据 | |
541 | + List<Object[]> contentList = new ArrayList<Object[]>(); | |
542 | + | |
543 | + | |
544 | + for (SerieVO e : freeBerthRatios.getSeries()) { | |
545 | + | |
546 | + Object[] obj = new Object[title.length]; | |
547 | + obj[0]="占用率"; | |
548 | + int index = 1; | |
549 | + for (Integer i : e.getData()) { | |
550 | + obj[index++] = 100-i+"%"; | |
551 | + } | |
552 | + contentList.add(obj); | |
553 | + } | |
554 | + | |
555 | + for (SerieVO e : turnOverBerthRatios.getSeries()) { | |
556 | + | |
557 | + Object[] obj = new Object[title.length]; | |
558 | + obj[0]="周转率率"; | |
559 | + int index = 1; | |
560 | + for (Integer i : e.getData()) { | |
561 | + obj[index++] = i ; | |
562 | + } | |
563 | + | |
564 | + | |
565 | + contentList.add(obj); | |
566 | + } | |
567 | + | |
568 | + ExcleFillDateManager fillUserManager = new ExcleFillDateManager(); | |
569 | + fillUserManager.fillSalesOrga(workSheet, title, contentList, 2); | |
570 | + // 4.excel输出配置 | |
571 | + ExcelUtil.write(response, workSheet, fileName); | |
572 | + } | |
573 | + | |
574 | + | |
575 | + | |
576 | + | |
515 | 577 | |
516 | 578 | } | ... | ... |