Commit 1ba0bae0b4017997123b7f9b7a0d8ef891371771
1 parent
4aae2c97
首页4,5,6图
Showing
1 changed file
with
205 additions
and
3 deletions
src/main/java/com/zteits/irain/portal/web/govclouds/DataGeneralizeController.java
1 | package com.zteits.irain.portal.web.govclouds; | 1 | package com.zteits.irain.portal.web.govclouds; |
2 | import java.util.ArrayList; | 2 | import java.util.ArrayList; |
3 | +import java.util.Calendar; | ||
4 | +import java.util.Date; | ||
3 | import java.util.HashMap; | 5 | import java.util.HashMap; |
4 | import java.util.List; | 6 | import java.util.List; |
5 | import java.util.Map; | 7 | import java.util.Map; |
6 | import java.util.Map.Entry; | 8 | import java.util.Map.Entry; |
7 | 9 | ||
8 | -import org.apache.commons.collections.functors.AllPredicate; | ||
9 | -import org.apache.poi.util.StringUtil; | ||
10 | import org.slf4j.Logger; | 10 | import org.slf4j.Logger; |
11 | import org.slf4j.LoggerFactory; | 11 | import org.slf4j.LoggerFactory; |
12 | +import org.springframework.beans.BeanUtils; | ||
12 | import org.springframework.beans.factory.annotation.Autowired; | 13 | import org.springframework.beans.factory.annotation.Autowired; |
13 | import org.springframework.beans.factory.annotation.Value; | 14 | import org.springframework.beans.factory.annotation.Value; |
14 | import org.springframework.web.bind.annotation.PostMapping; | 15 | import org.springframework.web.bind.annotation.PostMapping; |
@@ -17,7 +18,6 @@ import org.springframework.web.bind.annotation.RequestMapping; | @@ -17,7 +18,6 @@ import org.springframework.web.bind.annotation.RequestMapping; | ||
17 | import org.springframework.web.bind.annotation.ResponseBody; | 18 | import org.springframework.web.bind.annotation.ResponseBody; |
18 | import org.springframework.web.bind.annotation.RestController; | 19 | import org.springframework.web.bind.annotation.RestController; |
19 | 20 | ||
20 | -import com.alibaba.druid.util.StringUtils; | ||
21 | import com.alibaba.dubbo.common.utils.CollectionUtils; | 21 | import com.alibaba.dubbo.common.utils.CollectionUtils; |
22 | import com.alibaba.fastjson.JSONObject; | 22 | import com.alibaba.fastjson.JSONObject; |
23 | import com.clouds.common.cache.park.EqpAndPosStatusSyncCacheUtil; | 23 | import com.clouds.common.cache.park.EqpAndPosStatusSyncCacheUtil; |
@@ -30,20 +30,29 @@ import com.google.common.collect.Maps; | @@ -30,20 +30,29 @@ import com.google.common.collect.Maps; | ||
30 | import com.zteits.clouds.api.apibase.bean.BizResult; | 30 | import com.zteits.clouds.api.apibase.bean.BizResult; |
31 | import com.zteits.clouds.api.apibase.constants.ErrorType; | 31 | import com.zteits.clouds.api.apibase.constants.ErrorType; |
32 | import com.zteits.clouds.api.apibase.exception.BizException; | 32 | import com.zteits.clouds.api.apibase.exception.BizException; |
33 | +import com.zteits.clouds.api.dto.clouds.dto.OrderTransDTO; | ||
34 | +import com.zteits.clouds.api.dto.clouds.param.OrderTransactionQueryRequest; | ||
33 | import com.zteits.clouds.api.dto.govclouds.ParkTransactionDTO; | 35 | import com.zteits.clouds.api.dto.govclouds.ParkTransactionDTO; |
34 | import com.zteits.clouds.api.dto.govclouds.dto.ParkEqpAndPDACountDTO; | 36 | import com.zteits.clouds.api.dto.govclouds.dto.ParkEqpAndPDACountDTO; |
37 | +import com.zteits.clouds.api.dto.govclouds.dto.ParkingOccupyDTO; | ||
35 | import com.zteits.clouds.api.dto.govclouds.param.QueryParkEqpAndPDACountRequest; | 38 | import com.zteits.clouds.api.dto.govclouds.param.QueryParkEqpAndPDACountRequest; |
39 | +import com.zteits.clouds.api.dto.govclouds.param.QueryParkingOccupyRequest; | ||
36 | import com.zteits.clouds.api.dto.park.dto.ParkFreeBerthsCountStatisticByCountryDTO; | 40 | import com.zteits.clouds.api.dto.park.dto.ParkFreeBerthsCountStatisticByCountryDTO; |
37 | import com.zteits.clouds.api.dto.park.dto.ParkLotCountStatisticByCountryDTO; | 41 | import com.zteits.clouds.api.dto.park.dto.ParkLotCountStatisticByCountryDTO; |
38 | import com.zteits.clouds.api.dto.park.dto.ParkLotEqpTypeCountStatisticByCountryDTO; | 42 | import com.zteits.clouds.api.dto.park.dto.ParkLotEqpTypeCountStatisticByCountryDTO; |
39 | import com.zteits.clouds.api.dto.park.dto.ParkingLotDTO; | 43 | import com.zteits.clouds.api.dto.park.dto.ParkingLotDTO; |
40 | import com.zteits.clouds.api.dto.park.param.ParkTransactionRequest; | 44 | import com.zteits.clouds.api.dto.park.param.ParkTransactionRequest; |
41 | import com.zteits.clouds.api.dto.park.param.StatisticParkLotCountByCountryRequest; | 45 | import com.zteits.clouds.api.dto.park.param.StatisticParkLotCountByCountryRequest; |
46 | +import com.zteits.clouds.api.dto.pay.ParkingFlowCountDTO; | ||
47 | +import com.zteits.clouds.api.dto.pay.param.QueryTodayFlowRequest; | ||
48 | +import com.zteits.clouds.api.service.govclouds.ParkOccupyService; | ||
42 | import com.zteits.clouds.api.service.govclouds.ParkTransactionService; | 49 | import com.zteits.clouds.api.service.govclouds.ParkTransactionService; |
43 | import com.zteits.clouds.api.service.park.ParkFreeBerthService; | 50 | import com.zteits.clouds.api.service.park.ParkFreeBerthService; |
44 | import com.zteits.clouds.api.service.park.ParkingLotEqpService; | 51 | import com.zteits.clouds.api.service.park.ParkingLotEqpService; |
45 | import com.zteits.clouds.api.service.park.ParkingLotQueryService; | 52 | import com.zteits.clouds.api.service.park.ParkingLotQueryService; |
46 | import com.zteits.clouds.api.service.park.TpPPdaService; | 53 | import com.zteits.clouds.api.service.park.TpPPdaService; |
54 | +import com.zteits.clouds.api.service.pay.TdBOrderService; | ||
55 | +import com.zteits.irain.portal.constant.ParkConstant; | ||
47 | import com.zteits.irain.portal.vo.govclouds.StatisticParkLotEqpCountByCountryVO; | 56 | import com.zteits.irain.portal.vo.govclouds.StatisticParkLotEqpCountByCountryVO; |
48 | import com.zteits.irain.portal.vo.parkinglotdatacenter.BerthSpaceRatioVO; | 57 | import com.zteits.irain.portal.vo.parkinglotdatacenter.BerthSpaceRatioVO; |
49 | import com.zteits.irain.portal.vo.parkinglotdatacenter.BerthSpaceRatioVO.BerthSeriesVO; | 58 | import com.zteits.irain.portal.vo.parkinglotdatacenter.BerthSpaceRatioVO.BerthSeriesVO; |
@@ -85,6 +94,11 @@ public class DataGeneralizeController { | @@ -85,6 +94,11 @@ public class DataGeneralizeController { | ||
85 | private ParkTransactionService parkTransactionService; | 94 | private ParkTransactionService parkTransactionService; |
86 | @Autowired | 95 | @Autowired |
87 | private TpPPdaService tpPPdaService; | 96 | private TpPPdaService tpPPdaService; |
97 | + @Autowired | ||
98 | + private TdBOrderService tdBOrderService; | ||
99 | + @Autowired | ||
100 | + private ParkOccupyService parkOccupyService; | ||
101 | + | ||
88 | 102 | ||
89 | /** | 103 | /** |
90 | * 这里用的是@SendToUser,这就是发送给单一客户端的标志。本例中, | 104 | * 这里用的是@SendToUser,这就是发送给单一客户端的标志。本例中, |
@@ -511,4 +525,192 @@ public class DataGeneralizeController { | @@ -511,4 +525,192 @@ public class DataGeneralizeController { | ||
511 | parkLotAndBerthsCountVO.setPkCountMap(parkLotCountObjMap); | 525 | parkLotAndBerthsCountVO.setPkCountMap(parkLotCountObjMap); |
512 | return new BizResultVO<ParkLotAndBerthsCountVO>().setData(parkLotAndBerthsCountVO); | 526 | return new BizResultVO<ParkLotAndBerthsCountVO>().setData(parkLotAndBerthsCountVO); |
513 | } | 527 | } |
528 | + | ||
529 | + | ||
530 | + @SuppressWarnings("serial") | ||
531 | + @ApiOperation(value="今日车流量") | ||
532 | + @PostMapping("queryTodayVehicleFlow") | ||
533 | + @ResponseBody | ||
534 | + public BizResultVO<List<ParkingFlowCountDTO>> queryTodayVehicleFlow(@RequestBody StatisticParkLotCountByCountryRequest request){ | ||
535 | + BizResultVO<List<ParkingFlowCountDTO>> parkFlowDTOs = new BizResultVO<>(); | ||
536 | + List<ParkingFlowCountDTO> parkingFlowCountDTOs = new ArrayList<>(); | ||
537 | + | ||
538 | + List<QueryTodayFlowRequest> requests = new ArrayList<>(); | ||
539 | + List<String> HSPlNos = new ArrayList<String>(){{add("-1");}}; | ||
540 | + List<String> SSPlNos = new ArrayList<String>(){{add("-1");}}; | ||
541 | + List<String> YBSPlNos = new ArrayList<String>(){{add("-1");}}; | ||
542 | + List<String> QTPlNos = new ArrayList<String>(){{add("-1");}}; | ||
543 | + | ||
544 | + | ||
545 | + //先查询城市下面的停车场 | ||
546 | + BizResult<List<ParkingLotDTO>> parkResult = parkingLotQueryService.queryParkLotByCountry(request); | ||
547 | + if (ResultUtils.isError(parkResult)) { | ||
548 | + //如果失败 | ||
549 | + parkFlowDTOs.setCode(parkResult.getErrCode().getCode()); | ||
550 | + parkFlowDTOs.setMsg(parkResult.getErrMsg()); | ||
551 | + return parkFlowDTOs; | ||
552 | + } | ||
553 | + QueryTodayFlowRequest HSRequest = new QueryTodayFlowRequest(); | ||
554 | + QueryTodayFlowRequest SSRequest = new QueryTodayFlowRequest(); | ||
555 | + QueryTodayFlowRequest YBSRequest = new QueryTodayFlowRequest(); | ||
556 | + QueryTodayFlowRequest QTRequest = new QueryTodayFlowRequest(); | ||
557 | + QueryTodayFlowRequest flowRequest = new QueryTodayFlowRequest(); | ||
558 | + BeanUtils.copyProperties(request, flowRequest); | ||
559 | + Calendar calendar = Calendar.getInstance(); | ||
560 | + calendar.setTime(new Date()); | ||
561 | + calendar.set(Calendar.HOUR_OF_DAY, 0); | ||
562 | + calendar.set(Calendar.MINUTE, 0); | ||
563 | + calendar.set(Calendar.SECOND, 0); | ||
564 | + Date beginTime = calendar.getTime(); | ||
565 | + flowRequest.setBeginTime(beginTime); | ||
566 | + flowRequest.setEndTime(new Date()); | ||
567 | + flowRequest.setDataState(1); | ||
568 | + flowRequest.setOrderType(1); | ||
569 | + for (ParkingLotDTO dto : parkResult.getData()) { | ||
570 | + switch (dto.getPlCountryId().intValue()) { | ||
571 | + case 923://红山区 | ||
572 | + HSPlNos.add(dto.getPlNo()); | ||
573 | + BeanUtils.copyProperties(flowRequest, HSRequest); | ||
574 | + HSRequest.setPlCountryId(dto.getPlCountryId()); | ||
575 | + HSRequest.setPlCountryName(dto.getPlCountryName()); | ||
576 | + break; | ||
577 | + case 925://松山区 | ||
578 | + SSPlNos.add(dto.getPlNo()); | ||
579 | + BeanUtils.copyProperties(flowRequest, SSRequest); | ||
580 | + SSRequest.setPlCountryId(dto.getPlCountryId()); | ||
581 | + SSRequest.setPlCountryName(dto.getPlCountryName()); | ||
582 | + break; | ||
583 | + case 924://元宝山区 | ||
584 | + YBSPlNos.add(dto.getPlNo()); | ||
585 | + BeanUtils.copyProperties(flowRequest, YBSRequest); | ||
586 | + YBSRequest.setPlCountryId(dto.getPlCountryId()); | ||
587 | + YBSRequest.setPlCountryName(dto.getPlCountryName()); | ||
588 | + break; | ||
589 | + default://其他 | ||
590 | + QTPlNos.add(dto.getPlNo()); | ||
591 | + BeanUtils.copyProperties(flowRequest, QTRequest); | ||
592 | + QTRequest.setPlCountryId(9999L); | ||
593 | + QTRequest.setPlCountryName("其他"); | ||
594 | + | ||
595 | + break; | ||
596 | + } | ||
597 | + } | ||
598 | + | ||
599 | + HSRequest.setPlNos(HSPlNos); | ||
600 | + SSRequest.setPlNos(SSPlNos); | ||
601 | + YBSRequest.setPlNos(YBSPlNos); | ||
602 | + QTRequest.setPlNos(QTPlNos); | ||
603 | + requests.add(HSRequest); | ||
604 | + requests.add(SSRequest); | ||
605 | + requests.add(YBSRequest); | ||
606 | + requests.add(QTRequest); | ||
607 | + for (QueryTodayFlowRequest re : requests) { | ||
608 | + BizResult<ParkingFlowCountDTO> dtoBiz = tdBOrderService.queryTodayVehicleFlow(re); | ||
609 | + if(dtoBiz.getData()!=null){ | ||
610 | + BeanUtils.copyProperties(re, dtoBiz.getData()); | ||
611 | + parkingFlowCountDTOs.add(dtoBiz.getData()); | ||
612 | + } | ||
613 | + } | ||
614 | + parkFlowDTOs.setData(parkingFlowCountDTOs); | ||
615 | + logger.info("调用后场dubbo服务,响应为: result={}", JSONObject.toJSONString(parkFlowDTOs)); | ||
616 | + return parkFlowDTOs; | ||
617 | + } | ||
618 | + | ||
619 | + @ApiOperation(value="24小时占用率") | ||
620 | + @PostMapping("queryTwentyFourHoursOccupyRate") | ||
621 | + @ResponseBody | ||
622 | + public BizResultVO<List<ParkingOccupyDTO>> queryTwentyFourHoursOccupyRate(@RequestBody StatisticParkLotCountByCountryRequest request){ | ||
623 | + BizResultVO<List<ParkingOccupyDTO>> parkOccupyDTOs = new BizResultVO<>(); | ||
624 | + QueryParkingOccupyRequest occupyRequest = new QueryParkingOccupyRequest(); | ||
625 | + List<String> plNos = new ArrayList<>(); | ||
626 | + //先查询城市下面的停车场 | ||
627 | + BizResult<List<ParkingLotDTO>> parkResult = parkingLotQueryService.queryParkLotByCountry(request); | ||
628 | + if (ResultUtils.isError(parkResult)) { | ||
629 | + //如果失败 | ||
630 | + parkOccupyDTOs.setCode(parkResult.getErrCode().getCode()); | ||
631 | + parkOccupyDTOs.setMsg(parkResult.getErrMsg()); | ||
632 | + return parkOccupyDTOs; | ||
633 | + } | ||
634 | + for (ParkingLotDTO parkDto : parkResult.getData()) { | ||
635 | + plNos.add(parkDto.getPlNo()); | ||
636 | + } | ||
637 | + if(plNos.size()<1){ | ||
638 | + throw new BizException(ErrorType.PARAMM_NULL,"停车场编号"); | ||
639 | + } | ||
640 | + BeanUtils.copyProperties(request, occupyRequest); | ||
641 | + occupyRequest.setPlNos(plNos); | ||
642 | + occupyRequest.setDataStatus(1); | ||
643 | + occupyRequest.setStatisticType(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR); | ||
644 | + Calendar calendar = Calendar.getInstance(); | ||
645 | + calendar.setTime(new Date()); | ||
646 | + calendar.set(Calendar.MINUTE, 0); | ||
647 | + calendar.set(Calendar.SECOND, 0); | ||
648 | + Date endTime = calendar.getTime(); | ||
649 | + | ||
650 | + //往前倒三个月 | ||
651 | + calendar.add(Calendar.MONTH, -3); | ||
652 | + calendar.add(Calendar.DAY_OF_MONTH, -1); | ||
653 | + calendar.set(Calendar.MINUTE, 0); | ||
654 | + calendar.set(Calendar.SECOND, 0); | ||
655 | + Date beginTime = calendar.getTime(); | ||
656 | + | ||
657 | + occupyRequest.setBeginTime(beginTime); | ||
658 | + occupyRequest.setEndTime(endTime); | ||
659 | + | ||
660 | + BizResult<List<ParkingOccupyDTO>> result = parkOccupyService.queryTwentyFourHoursOccupyRate(occupyRequest); | ||
661 | + if(!(result.isSuccess())){ | ||
662 | + //如果失败 | ||
663 | + parkOccupyDTOs.setCode(result.getErrCode().getCode()); | ||
664 | + parkOccupyDTOs.setMsg(result.getErrMsg()); | ||
665 | + return parkOccupyDTOs; | ||
666 | + } | ||
667 | + parkOccupyDTOs.setData(result.getData()); | ||
668 | + logger.info("调用后场dubbo服务,响应为: result={}", JSONObject.toJSONString(parkOccupyDTOs)); | ||
669 | + return parkOccupyDTOs; | ||
670 | + } | ||
671 | + | ||
672 | + @ApiOperation(value="今日交易") | ||
673 | + @PostMapping("queryTodayOrderTrans") | ||
674 | + @ResponseBody | ||
675 | + public BizResultVO<OrderTransDTO> queryTodayOrderTrans(@RequestBody StatisticParkLotCountByCountryRequest request){ | ||
676 | + BizResultVO<OrderTransDTO> orderDTO = new BizResultVO<>(); | ||
677 | + OrderTransactionQueryRequest orderTransRequest = new OrderTransactionQueryRequest(); | ||
678 | + List<String> plNos = new ArrayList<>(); | ||
679 | + //先查询城市下面的停车场 | ||
680 | + BizResult<List<ParkingLotDTO>> parkResult = parkingLotQueryService.queryParkLotByCountry(request); | ||
681 | + if (ResultUtils.isError(parkResult)) { | ||
682 | + //如果失败 | ||
683 | + orderDTO.setCode(parkResult.getErrCode().getCode()); | ||
684 | + orderDTO.setMsg(parkResult.getErrMsg()); | ||
685 | + return orderDTO; | ||
686 | + } | ||
687 | + for (ParkingLotDTO parkDto : parkResult.getData()) { | ||
688 | + plNos.add(parkDto.getPlNo()); | ||
689 | + } | ||
690 | + if(plNos.size()<1){ | ||
691 | + throw new BizException(ErrorType.PARAMM_NULL,"停车场编号"); | ||
692 | + } | ||
693 | + BeanUtils.copyProperties(request, orderTransRequest); | ||
694 | + orderTransRequest.setParkIds(plNos); | ||
695 | + | ||
696 | + Calendar calendar = Calendar.getInstance(); | ||
697 | + calendar.setTime(new Date()); | ||
698 | + calendar.set(Calendar.HOUR_OF_DAY, 0); | ||
699 | + calendar.set(Calendar.MINUTE, 0); | ||
700 | + calendar.set(Calendar.SECOND, 0); | ||
701 | + Date beginTime = calendar.getTime(); | ||
702 | + orderTransRequest.setBeginTime(beginTime); | ||
703 | + orderTransRequest.setEndTime(new Date()); | ||
704 | + | ||
705 | + BizResult<OrderTransDTO> result = tdBOrderService.queryOrderTrans(orderTransRequest); | ||
706 | + if(!(result.isSuccess())){ | ||
707 | + //如果失败 | ||
708 | + orderDTO.setCode(result.getErrCode().getCode()); | ||
709 | + orderDTO.setMsg(result.getErrMsg()); | ||
710 | + return orderDTO; | ||
711 | + } | ||
712 | + orderDTO.setData(result.getData()); | ||
713 | + logger.info("调用后场dubbo服务,响应为: result={}", JSONObject.toJSONString(orderDTO)); | ||
714 | + return orderDTO; | ||
715 | + } | ||
514 | } | 716 | } |