Commit f64a6457729185ca8362cff8563acb31af011f49
1 parent
b316410d
提交首页改造代码
Showing
1 changed file
with
168 additions
and
56 deletions
src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/IndexPageStatisticController.java
| @@ -2,28 +2,21 @@ package com.zteits.irain.portal.web.parkinglotcloudplatform.datastatistic; | @@ -2,28 +2,21 @@ package com.zteits.irain.portal.web.parkinglotcloudplatform.datastatistic; | ||
| 2 | 2 | ||
| 3 | import java.math.BigDecimal; | 3 | import java.math.BigDecimal; |
| 4 | import java.math.RoundingMode; | 4 | import java.math.RoundingMode; |
| 5 | +import java.text.DecimalFormat; | ||
| 5 | import java.util.ArrayList; | 6 | import java.util.ArrayList; |
| 6 | import java.util.Calendar; | 7 | import java.util.Calendar; |
| 7 | import java.util.Date; | 8 | import java.util.Date; |
| 9 | +import java.util.HashMap; | ||
| 8 | import java.util.List; | 10 | import java.util.List; |
| 9 | import java.util.Map; | 11 | import java.util.Map; |
| 10 | import java.util.Map.Entry; | 12 | import java.util.Map.Entry; |
| 11 | 13 | ||
| 12 | import javax.validation.Valid; | 14 | import javax.validation.Valid; |
| 13 | 15 | ||
| 14 | -import org.slf4j.Logger; | ||
| 15 | -import org.slf4j.LoggerFactory; | ||
| 16 | -import org.springframework.beans.BeanUtils; | ||
| 17 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 18 | -import org.springframework.web.bind.annotation.PostMapping; | ||
| 19 | -import org.springframework.web.bind.annotation.RequestBody; | ||
| 20 | -import org.springframework.web.bind.annotation.RequestMapping; | ||
| 21 | -import org.springframework.web.bind.annotation.ResponseBody; | ||
| 22 | -import org.springframework.web.bind.annotation.RestController; | ||
| 23 | - | ||
| 24 | import com.alibaba.dubbo.common.utils.CollectionUtils; | 16 | import com.alibaba.dubbo.common.utils.CollectionUtils; |
| 25 | import com.alibaba.fastjson.JSON; | 17 | import com.alibaba.fastjson.JSON; |
| 26 | import com.alibaba.fastjson.JSONObject; | 18 | import com.alibaba.fastjson.JSONObject; |
| 19 | + | ||
| 27 | import com.clouds.common.cache.park.ParkingLotCacheUtil; | 20 | import com.clouds.common.cache.park.ParkingLotCacheUtil; |
| 28 | import com.clouds.common.utils.DateUtil; | 21 | import com.clouds.common.utils.DateUtil; |
| 29 | import com.clouds.common.utils.ResultUtils; | 22 | import com.clouds.common.utils.ResultUtils; |
| @@ -41,12 +34,16 @@ import com.zteits.clouds.api.dto.clouds.param.CustIncomeTotalQueryRequset; | @@ -41,12 +34,16 @@ import com.zteits.clouds.api.dto.clouds.param.CustIncomeTotalQueryRequset; | ||
| 41 | import com.zteits.clouds.api.dto.park.dto.ParkLotEqpTypeCountStatisticByCountryDTO; | 34 | import com.zteits.clouds.api.dto.park.dto.ParkLotEqpTypeCountStatisticByCountryDTO; |
| 42 | import com.zteits.clouds.api.dto.park.dto.ParkingLotDTO; | 35 | import com.zteits.clouds.api.dto.park.dto.ParkingLotDTO; |
| 43 | import com.zteits.clouds.api.dto.park.dto.ParkingLotUseStatisticDTO; | 36 | import com.zteits.clouds.api.dto.park.dto.ParkingLotUseStatisticDTO; |
| 37 | +import com.zteits.clouds.api.dto.park.dto.TodayVehicleFlowOccupyRateAndTurnOverDTO; | ||
| 38 | +import com.zteits.clouds.api.dto.park.param.CommonPlnosQueryRequest; | ||
| 44 | import com.zteits.clouds.api.dto.park.param.EqpTypeQueryByPlNosRequest; | 39 | import com.zteits.clouds.api.dto.park.param.EqpTypeQueryByPlNosRequest; |
| 45 | import com.zteits.clouds.api.dto.park.param.ParkingLotUseStatisticForPageRequest; | 40 | import com.zteits.clouds.api.dto.park.param.ParkingLotUseStatisticForPageRequest; |
| 46 | import com.zteits.clouds.api.dto.park.param.RealTimeVehicleFlowQueryRequest; | 41 | import com.zteits.clouds.api.dto.park.param.RealTimeVehicleFlowQueryRequest; |
| 47 | import com.zteits.clouds.api.service.clouds.CustIncomeService; | 42 | import com.zteits.clouds.api.service.clouds.CustIncomeService; |
| 48 | import com.zteits.clouds.api.service.park.IInOutParkingService; | 43 | import com.zteits.clouds.api.service.park.IInOutParkingService; |
| 44 | +import com.zteits.clouds.api.service.park.ParkingLotBerthsService; | ||
| 49 | import com.zteits.clouds.api.service.park.ParkingLotEqpService; | 45 | import com.zteits.clouds.api.service.park.ParkingLotEqpService; |
| 46 | +import com.zteits.clouds.api.service.park.ParkingLotQueryService; | ||
| 50 | import com.zteits.clouds.api.service.park.ParkingLotUseStatisticService; | 47 | import com.zteits.clouds.api.service.park.ParkingLotUseStatisticService; |
| 51 | import com.zteits.irain.portal.constant.ParkConstant; | 48 | import com.zteits.irain.portal.constant.ParkConstant; |
| 52 | import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.BerthsAndFlowLineChartVO; | 49 | import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.BerthsAndFlowLineChartVO; |
| @@ -56,8 +53,16 @@ import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.CustInco | @@ -56,8 +53,16 @@ import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.CustInco | ||
| 56 | import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.LineChartVO; | 53 | import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.LineChartVO; |
| 57 | import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.LineChartVO.SerieVO; | 54 | import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.LineChartVO.SerieVO; |
| 58 | import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.ParkLotEqpTypeCountVO; | 55 | import com.zteits.irain.portal.vo.parkinglotcloudplatform.datastatistic.ParkLotEqpTypeCountVO; |
| 59 | - | ||
| 60 | import io.swagger.annotations.ApiOperation; | 56 | import io.swagger.annotations.ApiOperation; |
| 57 | +import org.slf4j.Logger; | ||
| 58 | +import org.slf4j.LoggerFactory; | ||
| 59 | +import org.springframework.beans.BeanUtils; | ||
| 60 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 61 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 62 | +import org.springframework.web.bind.annotation.RequestBody; | ||
| 63 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 64 | +import org.springframework.web.bind.annotation.ResponseBody; | ||
| 65 | +import org.springframework.web.bind.annotation.RestController; | ||
| 61 | 66 | ||
| 62 | /** | 67 | /** |
| 63 | * Copyright: Copyright (c) 2017 zteits | 68 | * Copyright: Copyright (c) 2017 zteits |
| @@ -89,7 +94,13 @@ public class IndexPageStatisticController extends BizController { | @@ -89,7 +94,13 @@ public class IndexPageStatisticController extends BizController { | ||
| 89 | private ParkingLotUseStatisticService parkingLotStatisticService; | 94 | private ParkingLotUseStatisticService parkingLotStatisticService; |
| 90 | @Autowired | 95 | @Autowired |
| 91 | private ParkingLotEqpService parkingLotEqpService; | 96 | private ParkingLotEqpService parkingLotEqpService; |
| 92 | - | 97 | + |
| 98 | + @Autowired | ||
| 99 | + private ParkingLotQueryService parkingLotQueryService; | ||
| 100 | + | ||
| 101 | + @Autowired | ||
| 102 | + private ParkingLotBerthsService parkingLotBerthsService; | ||
| 103 | + | ||
| 93 | /** | 104 | /** |
| 94 | * 云平台首页->企业客户负责所有的停车场汇总.<br/> | 105 | * 云平台首页->企业客户负责所有的停车场汇总.<br/> |
| 95 | * | 106 | * |
| @@ -150,8 +161,6 @@ public class IndexPageStatisticController extends BizController { | @@ -150,8 +161,6 @@ public class IndexPageStatisticController extends BizController { | ||
| 150 | BigDecimal escapeAmount = dto.getEscapeAmount(); | 161 | BigDecimal escapeAmount = dto.getEscapeAmount(); |
| 151 | BigDecimal payedTotalAmount = dto.getPayedTotalAmount(); | 162 | BigDecimal payedTotalAmount = dto.getPayedTotalAmount(); |
| 152 | 163 | ||
| 153 | - | ||
| 154 | - | ||
| 155 | CustIncomeTotalParkVO vo = new CustIncomeTotalParkVO(); | 164 | CustIncomeTotalParkVO vo = new CustIncomeTotalParkVO(); |
| 156 | 165 | ||
| 157 | //金额为分 | 166 | //金额为分 |
| @@ -160,13 +169,14 @@ public class IndexPageStatisticController extends BizController { | @@ -160,13 +169,14 @@ public class IndexPageStatisticController extends BizController { | ||
| 160 | vo.setPayedTotalAmount(payedTotalAmount.setScale(2, BigDecimal.ROUND_HALF_UP).toString()); | 169 | vo.setPayedTotalAmount(payedTotalAmount.setScale(2, BigDecimal.ROUND_HALF_UP).toString()); |
| 161 | //占比乘以100取两位小数 | 170 | //占比乘以100取两位小数 |
| 162 | //应收 | 171 | //应收 |
| 163 | - if (null == amountDueTotal || amountDueTotal.doubleValue()==0) { | 172 | + if (null == amountDueTotal || amountDueTotal.doubleValue() == 0) { |
| 164 | vo.setLoopData(1, "00.00"); | 173 | vo.setLoopData(1, "00.00"); |
| 165 | vo.setLoopData(2, "00.00"); | 174 | vo.setLoopData(2, "00.00"); |
| 166 | 175 | ||
| 167 | } else { | 176 | } else { |
| 168 | //实收 | 177 | //实收 |
| 169 | - vo.setLoopData(1, payedTotalAmount.divide(amountDueTotal, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100.00")) | 178 | + vo.setLoopData(1, payedTotalAmount.divide(amountDueTotal, 4, BigDecimal.ROUND_HALF_UP).multiply( |
| 179 | + new BigDecimal("100.00")) | ||
| 170 | .setScale(2, BigDecimal.ROUND_HALF_UP).toString()); | 180 | .setScale(2, BigDecimal.ROUND_HALF_UP).toString()); |
| 171 | //逃逸 | 181 | //逃逸 |
| 172 | vo.setLoopData(2, escapeAmount.divide(amountDueTotal, 4, BigDecimal.ROUND_HALF_UP).multiply( | 182 | vo.setLoopData(2, escapeAmount.divide(amountDueTotal, 4, BigDecimal.ROUND_HALF_UP).multiply( |
| @@ -233,6 +243,16 @@ public class IndexPageStatisticController extends BizController { | @@ -233,6 +243,16 @@ public class IndexPageStatisticController extends BizController { | ||
| 233 | return resResult; | 243 | return resResult; |
| 234 | } | 244 | } |
| 235 | 245 | ||
| 246 | + @ApiOperation("查询今日车流量占用率周转率") | ||
| 247 | + @PostMapping("/queryTodayVehicleFlowOccupyRateAndTurnOver") | ||
| 248 | + public BizResultVO<List<TodayVehicleFlowOccupyRateAndTurnOverDTO>> queryTodayVehicleFlowOccupyRateAndTurnOver( | ||
| 249 | + @RequestBody CommonPlnosQueryRequest request) { | ||
| 250 | + BizResult<List<TodayVehicleFlowOccupyRateAndTurnOverDTO>> bizResult = parkingLotStatisticService | ||
| 251 | + .queryTodayVehicleFlowOccupyRateAndTurnOver(request); | ||
| 252 | + return new BizResultVO<>(bizResult); | ||
| 253 | + | ||
| 254 | + } | ||
| 255 | + | ||
| 236 | /** | 256 | /** |
| 237 | * 根据停车场编号,获取该停车场今日车流量(当天0:00到操作时间的车流量) 折线图 | 257 | * 根据停车场编号,获取该停车场今日车流量(当天0:00到操作时间的车流量) 折线图 |
| 238 | * | 258 | * |
| @@ -240,10 +260,11 @@ public class IndexPageStatisticController extends BizController { | @@ -240,10 +260,11 @@ public class IndexPageStatisticController extends BizController { | ||
| 240 | * @return 2017年6月19日 zhaowg | 260 | * @return 2017年6月19日 zhaowg |
| 241 | */ | 261 | */ |
| 242 | @ApiOperation("根据停车场编号获取该停车场今日车流量和车位折线图") | 262 | @ApiOperation("根据停车场编号获取该停车场今日车流量和车位折线图") |
| 243 | - @PostMapping("getTodayVehicleFlowForLineChart") | 263 | + @PostMapping("/getTodayVehicleFlowForLineChart") |
| 264 | + @Deprecated | ||
| 244 | public BizResultVO<BerthsAndFlowLineChartVO> getTodayVehicleFlowForLineChart( | 265 | public BizResultVO<BerthsAndFlowLineChartVO> getTodayVehicleFlowForLineChart( |
| 245 | @RequestBody @Valid ParkingLotUseStatisticForPageRequest request) { | 266 | @RequestBody @Valid ParkingLotUseStatisticForPageRequest request) { |
| 246 | - logger.info("根据停车场编号获取该停车场今日车流量和车位折线图"); | 267 | + logger.info("根据停车场编号获取该停车场今日车流量和车位折线图"); |
| 247 | //开始时间 今日0点开始 | 268 | //开始时间 今日0点开始 |
| 248 | Calendar beginTime = Calendar.getInstance(); | 269 | Calendar beginTime = Calendar.getInstance(); |
| 249 | beginTime.set(Calendar.HOUR_OF_DAY, 0); | 270 | beginTime.set(Calendar.HOUR_OF_DAY, 0); |
| @@ -280,7 +301,7 @@ public class IndexPageStatisticController extends BizController { | @@ -280,7 +301,7 @@ public class IndexPageStatisticController extends BizController { | ||
| 280 | //每20分钟统计一次 | 301 | //每20分钟统计一次 |
| 281 | request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER20MINUTE); | 302 | request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER20MINUTE); |
| 282 | request.setBaseRequest(new BaseInfo(1, 0)); | 303 | request.setBaseRequest(new BaseInfo(1, 0)); |
| 283 | - logger.info("调用DUBBO服务入参:"+JSON.toJSONString(request)); | 304 | + logger.info("调用DUBBO服务入参:" + JSON.toJSONString(request)); |
| 284 | BizResult<PageBean<ParkingLotUseStatisticDTO>> bizResult = parkingLotStatisticService | 305 | BizResult<PageBean<ParkingLotUseStatisticDTO>> bizResult = parkingLotStatisticService |
| 285 | .queryParkingLotUseStatisticForPage(request); | 306 | .queryParkingLotUseStatisticForPage(request); |
| 286 | PageBean<ParkingLotUseStatisticDTO> pageBean = ResultUtils.getBizResultData(bizResult); | 307 | PageBean<ParkingLotUseStatisticDTO> pageBean = ResultUtils.getBizResultData(bizResult); |
| @@ -312,19 +333,21 @@ public class IndexPageStatisticController extends BizController { | @@ -312,19 +333,21 @@ public class IndexPageStatisticController extends BizController { | ||
| 312 | } | 333 | } |
| 313 | 334 | ||
| 314 | //保存固定车流量和临时车流量 | 335 | //保存固定车流量和临时车流量 |
| 315 | - fixVehicleFlowMap.put(statisBeginTime, (fixVehicleFlowMap.get(statisBeginTime)==null?0:fixVehicleFlowMap.get(statisBeginTime))+statisticDTO.getFixVehicleFlow()); | ||
| 316 | - tmpVehicleFlowMap.put(statisBeginTime, (tmpVehicleFlowMap.get(statisBeginTime)==null?0:tmpVehicleFlowMap.get(statisBeginTime))+statisticDTO.getTmpVehicleFlow()); | 336 | + fixVehicleFlowMap.put(statisBeginTime, (fixVehicleFlowMap.get(statisBeginTime) == null ? 0 |
| 337 | + : fixVehicleFlowMap.get(statisBeginTime)) + statisticDTO.getFixVehicleFlow()); | ||
| 338 | + tmpVehicleFlowMap.put(statisBeginTime, (tmpVehicleFlowMap.get(statisBeginTime) == null ? 0 | ||
| 339 | + : tmpVehicleFlowMap.get(statisBeginTime)) + statisticDTO.getTmpVehicleFlow()); | ||
| 340 | + } | ||
| 341 | + } | ||
| 342 | + //判断是否包含所有待查询的停车场信息 | ||
| 343 | + if (request.getPlNos().size() > parkLotMap.size()) { | ||
| 344 | + for (String plNo : request.getPlNos()) { | ||
| 345 | + if (!parkLotMap.containsKey(plNo)) { | ||
| 346 | + ParkingLotDTO parkingLotDTO = ParkingLotCacheUtil.getParkLotByPlNo(plNo); | ||
| 347 | + parkNameMap.put(plNo, parkingLotDTO.getPlName()); | ||
| 348 | + parkLotMap.put(plNo, Maps.newHashMap()); | ||
| 349 | + } | ||
| 317 | } | 350 | } |
| 318 | - } | ||
| 319 | - //判断是否包含所有待查询的停车场信息 | ||
| 320 | - if(request.getPlNos().size()>parkLotMap.size()){ | ||
| 321 | - for (String plNo:request.getPlNos()) { | ||
| 322 | - if(!parkLotMap.containsKey(plNo)){ | ||
| 323 | - ParkingLotDTO parkingLotDTO=ParkingLotCacheUtil.getParkLotByPlNo(plNo); | ||
| 324 | - parkNameMap.put(plNo, parkingLotDTO.getPlName()); | ||
| 325 | - parkLotMap.put(plNo, Maps.newHashMap()); | ||
| 326 | - } | ||
| 327 | - } | ||
| 328 | } | 351 | } |
| 329 | //封装车位统计信息 | 352 | //封装车位统计信息 |
| 330 | LineChartVO freeBerthRatios = new LineChartVO(); | 353 | LineChartVO freeBerthRatios = new LineChartVO(); |
| @@ -348,8 +371,8 @@ public class IndexPageStatisticController extends BizController { | @@ -348,8 +371,8 @@ public class IndexPageStatisticController extends BizController { | ||
| 348 | for (String timestamp : xAxisData) { | 371 | for (String timestamp : xAxisData) { |
| 349 | if (freeRatioMaps.containsKey(timestamp)) { | 372 | if (freeRatioMaps.containsKey(timestamp)) { |
| 350 | lastFreeRatio = freeRatioMaps.get(timestamp).intValue(); | 373 | lastFreeRatio = freeRatioMaps.get(timestamp).intValue(); |
| 351 | - }else{ | ||
| 352 | - lastFreeRatio = 0; | 374 | + } else { |
| 375 | + lastFreeRatio = 0; | ||
| 353 | } | 376 | } |
| 354 | freeRations.add(lastFreeRatio); | 377 | freeRations.add(lastFreeRatio); |
| 355 | } | 378 | } |
| @@ -381,15 +404,15 @@ public class IndexPageStatisticController extends BizController { | @@ -381,15 +404,15 @@ public class IndexPageStatisticController extends BizController { | ||
| 381 | for (String timestamp : xAxisData) { | 404 | for (String timestamp : xAxisData) { |
| 382 | if (fixVehicleFlowMap.containsKey(timestamp)) { | 405 | if (fixVehicleFlowMap.containsKey(timestamp)) { |
| 383 | lastfixFlow = fixVehicleFlowMap.get(timestamp).intValue(); | 406 | lastfixFlow = fixVehicleFlowMap.get(timestamp).intValue(); |
| 384 | - }else{ | ||
| 385 | - lastfixFlow = 0; | 407 | + } else { |
| 408 | + lastfixFlow = 0; | ||
| 386 | } | 409 | } |
| 387 | fixSerieVoData.add(lastfixFlow); | 410 | fixSerieVoData.add(lastfixFlow); |
| 388 | 411 | ||
| 389 | if (tmpVehicleFlowMap.containsKey(timestamp)) { | 412 | if (tmpVehicleFlowMap.containsKey(timestamp)) { |
| 390 | lasttmpFlow = tmpVehicleFlowMap.get(timestamp).intValue(); | 413 | lasttmpFlow = tmpVehicleFlowMap.get(timestamp).intValue(); |
| 391 | - }else{ | ||
| 392 | - lasttmpFlow = 0; | 414 | + } else { |
| 415 | + lasttmpFlow = 0; | ||
| 393 | } | 416 | } |
| 394 | tmpSerieVoData.add(lasttmpFlow); | 417 | tmpSerieVoData.add(lasttmpFlow); |
| 395 | } | 418 | } |
| @@ -417,6 +440,96 @@ public class IndexPageStatisticController extends BizController { | @@ -417,6 +440,96 @@ public class IndexPageStatisticController extends BizController { | ||
| 417 | } | 440 | } |
| 418 | 441 | ||
| 419 | /** | 442 | /** |
| 443 | + * 实时统计今日停车次数,停车次数以出场时间进行统计 | ||
| 444 | + * | ||
| 445 | + * @return | ||
| 446 | + */ | ||
| 447 | + @ApiOperation("实时查询当前停车次数") | ||
| 448 | + @PostMapping("/realtimeParkingOutNum") | ||
| 449 | + public BizResultVO<Long> realtimeParkingOutNum(@RequestBody CommonPlnosQueryRequest request) { | ||
| 450 | + BizResult<Long> bizResult = iInOutParkingService.queryRealTimeOutParkNumOfPlNos(request); | ||
| 451 | + return new BizResultVO<>(bizResult); | ||
| 452 | + } | ||
| 453 | + | ||
| 454 | + /** | ||
| 455 | + * 今日实时周转率 | ||
| 456 | + * | ||
| 457 | + * @param request | ||
| 458 | + * @return | ||
| 459 | + * @desc 今日实时进场次数/总车位数 | ||
| 460 | + */ | ||
| 461 | + @ApiOperation("实时查询当前周转率") | ||
| 462 | + @PostMapping("/realtimeTurnoverRate") | ||
| 463 | + public BizResultVO<Map<String,Object>> realtimeTurnoverRate(@RequestBody CommonPlnosQueryRequest request) { | ||
| 464 | + BizResultVO<Map<String,Object>> res = new BizResultVO<>(); | ||
| 465 | + Map<String,Object> resMap = new HashMap<>(); | ||
| 466 | + //1、查询截止当前进场停车次数 | ||
| 467 | + BizResult<Long> bizResult = iInOutParkingService.queryRealTimeInParkNumOfPlNos(request); | ||
| 468 | + if(ResultUtils.isError(bizResult)){ | ||
| 469 | + res.setCode(bizResult.getErrCode().getCode()); | ||
| 470 | + res.setMsg(bizResult.getErrMsg()); | ||
| 471 | + return res; | ||
| 472 | + } | ||
| 473 | + //2、根据停车场编号查询停车场总车位数 | ||
| 474 | + BizResult<Long> berthResult = parkingLotQueryService.queryBerthNumByPlNos(request); | ||
| 475 | + if(ResultUtils.isError(berthResult)){ | ||
| 476 | + res.setCode(berthResult.getErrCode().getCode()); | ||
| 477 | + res.setMsg(berthResult.getErrMsg()); | ||
| 478 | + return res; | ||
| 479 | + } | ||
| 480 | + | ||
| 481 | + //停车次数 | ||
| 482 | + resMap.put("parkNum",bizResult.getData()); | ||
| 483 | + //总车位数 | ||
| 484 | + resMap.put("allBerthNum",berthResult.getData()); | ||
| 485 | + double rate = bizResult.getData() * 1.0 / berthResult.getData() * 100; | ||
| 486 | + String rateStr = new DecimalFormat("#.00").format(rate); | ||
| 487 | + resMap.put("rate",rateStr); | ||
| 488 | + res.setData(resMap); | ||
| 489 | + return res; | ||
| 490 | + } | ||
| 491 | + | ||
| 492 | + /** | ||
| 493 | + * 今日实时占用率 | ||
| 494 | + * | ||
| 495 | + * @param request | ||
| 496 | + * @return | ||
| 497 | + * @desc 1-(今日实时空余车位数/总车位数) | ||
| 498 | + */ | ||
| 499 | + @ApiOperation("实时查询当前占用率") | ||
| 500 | + @PostMapping("/realtimeoccupationRate") | ||
| 501 | + public BizResultVO<Map<String,Object>> realtimeoccupationRate(@RequestBody CommonPlnosQueryRequest request) { | ||
| 502 | + BizResultVO<Map<String,Object>> res = new BizResultVO<>(); | ||
| 503 | + Map<String,Object> resMap = new HashMap<>(); | ||
| 504 | + | ||
| 505 | + //1、查询截止当前空余车位数 | ||
| 506 | + BizResult<Long> bizResult = parkingLotBerthsService.queryAllFreeBerthNum(request); | ||
| 507 | + if(ResultUtils.isError(bizResult)){ | ||
| 508 | + res.setCode(bizResult.getErrCode().getCode()); | ||
| 509 | + res.setMsg(bizResult.getErrMsg()); | ||
| 510 | + return res; | ||
| 511 | + } | ||
| 512 | + //2、根据停车场编号查询停车场总车位数 | ||
| 513 | + BizResult<Long> berthResult = parkingLotQueryService.queryBerthNumByPlNos(request); | ||
| 514 | + if(ResultUtils.isError(berthResult)){ | ||
| 515 | + res.setCode(berthResult.getErrCode().getCode()); | ||
| 516 | + res.setMsg(berthResult.getErrMsg()); | ||
| 517 | + return res; | ||
| 518 | + } | ||
| 519 | + //空余车位数 | ||
| 520 | + resMap.put("freeBerthNum",bizResult.getData()); | ||
| 521 | + //总车位数 | ||
| 522 | + resMap.put("allBerthNum",berthResult.getData()); | ||
| 523 | + | ||
| 524 | + double rate = (1-bizResult.getData() * 1.0 / berthResult.getData()) * 100; | ||
| 525 | + String rateStr = new DecimalFormat("#.00").format(rate); | ||
| 526 | + resMap.put("rate",rateStr); | ||
| 527 | + res.setData(resMap); | ||
| 528 | + return res; | ||
| 529 | + | ||
| 530 | + } | ||
| 531 | + | ||
| 532 | + /** | ||
| 420 | * 实时查询今日空置率<br> | 533 | * 实时查询今日空置率<br> |
| 421 | * 今日空置率:当天0:00到操作时间的每个时间戳的空置率做加权算法,<br> | 534 | * 今日空置率:当天0:00到操作时间的每个时间戳的空置率做加权算法,<br> |
| 422 | * 0:00-7:00加权10%,7:00-9:00加权40%,9:00-17:00加权15%,17:00-21:00加权25%,21:00-24:00加权10%,加权后的空置率之和除以时间戳数,得到“今日空置率” | 535 | * 0:00-7:00加权10%,7:00-9:00加权40%,9:00-17:00加权15%,17:00-21:00加权25%,21:00-24:00加权10%,加权后的空置率之和除以时间戳数,得到“今日空置率” |
| @@ -447,13 +560,13 @@ public class IndexPageStatisticController extends BizController { | @@ -447,13 +560,13 @@ public class IndexPageStatisticController extends BizController { | ||
| 447 | Double totalfreeRatio = 0.00; | 560 | Double totalfreeRatio = 0.00; |
| 448 | for (ParkingLotUseStatisticDTO statisticDTO : pageBean.getDataList()) { | 561 | for (ParkingLotUseStatisticDTO statisticDTO : pageBean.getDataList()) { |
| 449 | totalfreeRatio += statisticDTO.getFreeRatio(); | 562 | totalfreeRatio += statisticDTO.getFreeRatio(); |
| 450 | - //暂时不加权 | ||
| 451 | - //this.weightForFreeRation(statisticDTO.getStatisticBeginTime(), | ||
| 452 | - //statisticDTO.getFreeRatio(), statisticDTO.getPlNo()); | 563 | + //暂时不加权 |
| 564 | + //this.weightForFreeRation(statisticDTO.getStatisticBeginTime(), | ||
| 565 | + //statisticDTO.getFreeRatio(), statisticDTO.getPlNo()); | ||
| 453 | } | 566 | } |
| 454 | logger.info("加权后的空置率之和:" + totalfreeRatio + " 时间戳个数:" + pageBean.getDataList().size()); | 567 | logger.info("加权后的空置率之和:" + totalfreeRatio + " 时间戳个数:" + pageBean.getDataList().size()); |
| 455 | Double avgFreeRation = totalfreeRatio / pageBean.getDataList().size(); | 568 | Double avgFreeRation = totalfreeRatio / pageBean.getDataList().size(); |
| 456 | - String result = String.format("%.2f", avgFreeRation*100); | 569 | + String result = String.format("%.2f", avgFreeRation * 100); |
| 457 | return new BizResultVO<String>().setData(result); | 570 | return new BizResultVO<String>().setData(result); |
| 458 | } | 571 | } |
| 459 | 572 | ||
| @@ -492,26 +605,25 @@ public class IndexPageStatisticController extends BizController { | @@ -492,26 +605,25 @@ public class IndexPageStatisticController extends BizController { | ||
| 492 | } | 605 | } |
| 493 | 606 | ||
| 494 | /** | 607 | /** |
| 495 | - * @param request | ||
| 496 | - * @return | ||
| 497 | - * 2017年8月18日 wangfei | ||
| 498 | - */ | ||
| 499 | - @ApiOperation(value="根据停车场编号统计设备数量") | ||
| 500 | - @PostMapping("statisticParkLotEqpCountByPlNos") | ||
| 501 | - @ResponseBody | ||
| 502 | - public BizResult<List<ParkLotEqpTypeCountVO>> statisticParkLotEqpCountByPlNos(@RequestBody | ||
| 503 | - EqpTypeQueryByPlNosRequest request){ | ||
| 504 | - logger.info("停车场编号:"+request.getPlNos()+" 统计设备数量等信息"); | ||
| 505 | - List<ParkLotEqpTypeCountVO> resultList = new ArrayList<>(); | 608 | + * @param request |
| 609 | + * @return 2017年8月18日 wangfei | ||
| 610 | + */ | ||
| 611 | + @ApiOperation(value = "根据停车场编号统计设备数量") | ||
| 612 | + @PostMapping("statisticParkLotEqpCountByPlNos") | ||
| 613 | + @ResponseBody | ||
| 614 | + public BizResult<List<ParkLotEqpTypeCountVO>> statisticParkLotEqpCountByPlNos(@RequestBody | ||
| 615 | + EqpTypeQueryByPlNosRequest request) { | ||
| 616 | + logger.info("停车场编号:" + request.getPlNos() + " 统计设备数量等信息"); | ||
| 617 | + List<ParkLotEqpTypeCountVO> resultList = new ArrayList<>(); | ||
| 506 | BizResult<List<ParkLotEqpTypeCountStatisticByCountryDTO>> result = parkingLotEqpService | 618 | BizResult<List<ParkLotEqpTypeCountStatisticByCountryDTO>> result = parkingLotEqpService |
| 507 | - .StatisticParkLotEqpCountByPlNos(request); | 619 | + .StatisticParkLotEqpCountByPlNos(request); |
| 508 | if (!CollectionUtils.isEmpty(result.getData())) { | 620 | if (!CollectionUtils.isEmpty(result.getData())) { |
| 509 | - for (ParkLotEqpTypeCountStatisticByCountryDTO i :result.getData()) { | ||
| 510 | - ParkLotEqpTypeCountVO vo = new ParkLotEqpTypeCountVO(); | 621 | + for (ParkLotEqpTypeCountStatisticByCountryDTO i : result.getData()) { |
| 622 | + ParkLotEqpTypeCountVO vo = new ParkLotEqpTypeCountVO(); | ||
| 511 | BeanUtils.copyProperties(i, vo); | 623 | BeanUtils.copyProperties(i, vo); |
| 512 | resultList.add(vo); | 624 | resultList.add(vo); |
| 513 | } | 625 | } |
| 514 | } | 626 | } |
| 515 | return new BizResult<>(resultList); | 627 | return new BizResult<>(resultList); |
| 516 | - } | 628 | + } |
| 517 | } | 629 | } |