Commit fd942017c75616b2dd044aac85f310fcc35c8969
Merge branch 'branch0905' of http://192.168.1.195:9998/ZTEITS-Developers/zteits-…
…gcp-portal.git into branch0905
Showing
3 changed files
with
282 additions
and
4 deletions
src/main/java/com/zteits/irain/portal/vo/parkinglotdatacenter/ParkLotAndBerthsCountVO.java
... | ... | @@ -24,6 +24,11 @@ public class ParkLotAndBerthsCountVO { |
24 | 24 | private Map<String,Integer> pkberthsCount; |
25 | 25 | //key:区县名称,value:停车场数 |
26 | 26 | private Map<String,Integer> pkCount; |
27 | + //key:区县名称,value:map{key:plType,停车场类型,value :车位数 } | |
28 | + private Map<String,Object> pkberthsCountMap; | |
29 | + //key:区县名称,value:map{key:plType,停车场类型,value :停车场数 } | |
30 | + private Map<String,Object> pkCountMap; | |
31 | + | |
27 | 32 | public Map<String, Integer> getPkberthsCount() { |
28 | 33 | return pkberthsCount; |
29 | 34 | } |
... | ... | @@ -36,6 +41,18 @@ public class ParkLotAndBerthsCountVO { |
36 | 41 | public void setPkCount(Map<String, Integer> pkCount) { |
37 | 42 | this.pkCount = pkCount; |
38 | 43 | } |
44 | + public Map<String, Object> getPkberthsCountMap() { | |
45 | + return pkberthsCountMap; | |
46 | + } | |
47 | + public void setPkberthsCountMap(Map<String, Object> pkberthsCountMap) { | |
48 | + this.pkberthsCountMap = pkberthsCountMap; | |
49 | + } | |
50 | + public Map<String, Object> getPkCountMap() { | |
51 | + return pkCountMap; | |
52 | + } | |
53 | + public void setPkCountMap(Map<String, Object> pkCountMap) { | |
54 | + this.pkCountMap = pkCountMap; | |
55 | + } | |
39 | 56 | |
40 | 57 | |
41 | 58 | } | ... | ... |
src/main/java/com/zteits/irain/portal/web/govclouds/DataGeneralizeController.java
1 | 1 | package com.zteits.irain.portal.web.govclouds; |
2 | +import java.math.BigDecimal; | |
2 | 3 | import java.util.ArrayList; |
4 | +import java.util.Calendar; | |
5 | +import java.util.Date; | |
3 | 6 | import java.util.HashMap; |
4 | 7 | import java.util.List; |
5 | 8 | import java.util.Map; |
6 | 9 | import java.util.Map.Entry; |
7 | 10 | |
8 | -import org.apache.commons.collections.functors.AllPredicate; | |
9 | -import org.apache.poi.util.StringUtil; | |
10 | 11 | import org.slf4j.Logger; |
11 | 12 | import org.slf4j.LoggerFactory; |
13 | +import org.springframework.beans.BeanUtils; | |
12 | 14 | import org.springframework.beans.factory.annotation.Autowired; |
13 | 15 | import org.springframework.beans.factory.annotation.Value; |
14 | 16 | import org.springframework.web.bind.annotation.PostMapping; |
... | ... | @@ -17,7 +19,6 @@ import org.springframework.web.bind.annotation.RequestMapping; |
17 | 19 | import org.springframework.web.bind.annotation.ResponseBody; |
18 | 20 | import org.springframework.web.bind.annotation.RestController; |
19 | 21 | |
20 | -import com.alibaba.druid.util.StringUtils; | |
21 | 22 | import com.alibaba.dubbo.common.utils.CollectionUtils; |
22 | 23 | import com.alibaba.fastjson.JSONObject; |
23 | 24 | import com.clouds.common.cache.park.EqpAndPosStatusSyncCacheUtil; |
... | ... | @@ -30,20 +31,29 @@ import com.google.common.collect.Maps; |
30 | 31 | import com.zteits.clouds.api.apibase.bean.BizResult; |
31 | 32 | import com.zteits.clouds.api.apibase.constants.ErrorType; |
32 | 33 | import com.zteits.clouds.api.apibase.exception.BizException; |
34 | +import com.zteits.clouds.api.dto.clouds.dto.OrderTransDTO; | |
35 | +import com.zteits.clouds.api.dto.clouds.param.OrderTransactionQueryRequest; | |
33 | 36 | import com.zteits.clouds.api.dto.govclouds.ParkTransactionDTO; |
34 | 37 | import com.zteits.clouds.api.dto.govclouds.dto.ParkEqpAndPDACountDTO; |
38 | +import com.zteits.clouds.api.dto.govclouds.dto.ParkingOccupyDTO; | |
35 | 39 | import com.zteits.clouds.api.dto.govclouds.param.QueryParkEqpAndPDACountRequest; |
40 | +import com.zteits.clouds.api.dto.govclouds.param.QueryParkingOccupyRequest; | |
36 | 41 | import com.zteits.clouds.api.dto.park.dto.ParkFreeBerthsCountStatisticByCountryDTO; |
37 | 42 | import com.zteits.clouds.api.dto.park.dto.ParkLotCountStatisticByCountryDTO; |
38 | 43 | import com.zteits.clouds.api.dto.park.dto.ParkLotEqpTypeCountStatisticByCountryDTO; |
39 | 44 | import com.zteits.clouds.api.dto.park.dto.ParkingLotDTO; |
40 | 45 | import com.zteits.clouds.api.dto.park.param.ParkTransactionRequest; |
41 | 46 | import com.zteits.clouds.api.dto.park.param.StatisticParkLotCountByCountryRequest; |
47 | +import com.zteits.clouds.api.dto.pay.ParkingFlowCountDTO; | |
48 | +import com.zteits.clouds.api.dto.pay.param.QueryTodayFlowRequest; | |
49 | +import com.zteits.clouds.api.service.govclouds.ParkOccupyService; | |
42 | 50 | import com.zteits.clouds.api.service.govclouds.ParkTransactionService; |
43 | 51 | import com.zteits.clouds.api.service.park.ParkFreeBerthService; |
44 | 52 | import com.zteits.clouds.api.service.park.ParkingLotEqpService; |
45 | 53 | import com.zteits.clouds.api.service.park.ParkingLotQueryService; |
46 | 54 | import com.zteits.clouds.api.service.park.TpPPdaService; |
55 | +import com.zteits.clouds.api.service.pay.TdBOrderService; | |
56 | +import com.zteits.irain.portal.constant.ParkConstant; | |
47 | 57 | import com.zteits.irain.portal.vo.govclouds.StatisticParkLotEqpCountByCountryVO; |
48 | 58 | import com.zteits.irain.portal.vo.parkinglotdatacenter.BerthSpaceRatioVO; |
49 | 59 | import com.zteits.irain.portal.vo.parkinglotdatacenter.BerthSpaceRatioVO.BerthSeriesVO; |
... | ... | @@ -85,6 +95,11 @@ public class DataGeneralizeController { |
85 | 95 | private ParkTransactionService parkTransactionService; |
86 | 96 | @Autowired |
87 | 97 | private TpPPdaService tpPPdaService; |
98 | + @Autowired | |
99 | + private TdBOrderService tdBOrderService; | |
100 | + @Autowired | |
101 | + private ParkOccupyService parkOccupyService; | |
102 | + | |
88 | 103 | |
89 | 104 | /** |
90 | 105 | * 这里用的是@SendToUser,这就是发送给单一客户端的标志。本例中, |
... | ... | @@ -463,4 +478,250 @@ public class DataGeneralizeController { |
463 | 478 | |
464 | 479 | return new BizResultVO<ParkEqpAndPDACountDTO>().setData(parkEqpAndPDACountDTO); |
465 | 480 | } |
481 | + | |
482 | + | |
483 | + /** | |
484 | + * 分区统计停车场、停车位数量 | |
485 | + * langlw 2017-9-5 | |
486 | + * @param request | |
487 | + * @return | |
488 | + */ | |
489 | + @ApiOperation(value="分区、停车场类型统计停车场、停车位数量") | |
490 | + @PostMapping("getParkAndBerthAndEquChartForPlType") | |
491 | + @ResponseBody | |
492 | + public BizResultVO<ParkLotAndBerthsCountVO> getParkAndBerthAndEquChartForPlType(@RequestBody StatisticParkLotCountByCountryRequest request){ | |
493 | + if(null == request.getCityId()){ | |
494 | + throw new BizException(ErrorType.PARAMM_NULL, "城市编号"); | |
495 | + } | |
496 | + logger.info("对城市:"+request.getCityId()+" 按照区域统计停车场、车位数量等信息"); | |
497 | + //停车场数量 先查询缓存 | |
498 | + BizResult<List<ParkLotCountStatisticByCountryDTO>> bizResultParkLot = parkingLotQueryService.statisticParkLotCountByCountryForPlType(request); | |
499 | + logger.info("调用后场dubbo服务,响应为: result={}", JSONObject.toJSONString(bizResultParkLot)); | |
500 | + List<ParkLotCountStatisticByCountryDTO> parkLotCountList=bizResultParkLot.getData(); | |
501 | + | |
502 | + Map<String,Object> pkberthsCountObjMap=Maps.newHashMap(); | |
503 | + Map<String,Object> parkLotCountObjMap=Maps.newHashMap(); | |
504 | + | |
505 | + | |
506 | + if(CollectionUtils.isNotEmpty(parkLotCountList)){ | |
507 | + for (ParkLotCountStatisticByCountryDTO dto : parkLotCountList) { | |
508 | + String countryName = dto.getPlCountryName(); | |
509 | + //停车场车位数 | |
510 | + Map<Integer,Integer> berthsCountMap = Maps.newHashMap(); | |
511 | + //停车场数 | |
512 | + Map<Integer,Integer> parkLotCountMap = Maps.newHashMap(); | |
513 | + //停车场个数 | |
514 | + int pkCount = dto.getParkLotCount()==null?0:dto.getParkLotCount(); | |
515 | + Integer plType=dto.getPlType(); | |
516 | + parkLotCountMap.put(plType, pkCount); | |
517 | + parkLotCountObjMap.put(countryName, parkLotCountMap); | |
518 | + //停车位个数 | |
519 | + int pkberthsCount = dto.getTotalBerths(); | |
520 | + berthsCountMap.put(plType, pkberthsCount); | |
521 | + pkberthsCountObjMap.put(countryName, berthsCountMap); | |
522 | + } | |
523 | + } | |
524 | + ParkLotAndBerthsCountVO parkLotAndBerthsCountVO = new ParkLotAndBerthsCountVO(); | |
525 | + parkLotAndBerthsCountVO.setPkberthsCountMap(pkberthsCountObjMap); | |
526 | + parkLotAndBerthsCountVO.setPkCountMap(parkLotCountObjMap); | |
527 | + return new BizResultVO<ParkLotAndBerthsCountVO>().setData(parkLotAndBerthsCountVO); | |
528 | + } | |
529 | + | |
530 | + | |
531 | + @SuppressWarnings("serial") | |
532 | + @ApiOperation(value="今日车流量") | |
533 | + @PostMapping("queryTodayVehicleFlow") | |
534 | + @ResponseBody | |
535 | + public BizResultVO<List<ParkingFlowCountDTO>> queryTodayVehicleFlow(@RequestBody StatisticParkLotCountByCountryRequest request){ | |
536 | + BizResultVO<List<ParkingFlowCountDTO>> parkFlowDTOs = new BizResultVO<>(); | |
537 | + List<ParkingFlowCountDTO> parkingFlowCountDTOs = new ArrayList<>(); | |
538 | + | |
539 | + List<QueryTodayFlowRequest> requests = new ArrayList<>(); | |
540 | + List<String> HSPlNos = new ArrayList<String>(){{add("-1");}}; | |
541 | + List<String> SSPlNos = new ArrayList<String>(){{add("-1");}}; | |
542 | + List<String> YBSPlNos = new ArrayList<String>(){{add("-1");}}; | |
543 | + List<String> QTPlNos = new ArrayList<String>(){{add("-1");}}; | |
544 | + | |
545 | + | |
546 | + //先查询城市下面的停车场 | |
547 | + BizResult<List<ParkingLotDTO>> parkResult = parkingLotQueryService.queryParkLotByCountry(request); | |
548 | + if (ResultUtils.isError(parkResult)) { | |
549 | + //如果失败 | |
550 | + parkFlowDTOs.setCode(parkResult.getErrCode().getCode()); | |
551 | + parkFlowDTOs.setMsg(parkResult.getErrMsg()); | |
552 | + return parkFlowDTOs; | |
553 | + } | |
554 | + QueryTodayFlowRequest HSRequest = new QueryTodayFlowRequest(); | |
555 | + QueryTodayFlowRequest SSRequest = new QueryTodayFlowRequest(); | |
556 | + QueryTodayFlowRequest YBSRequest = new QueryTodayFlowRequest(); | |
557 | + QueryTodayFlowRequest QTRequest = new QueryTodayFlowRequest(); | |
558 | + QueryTodayFlowRequest flowRequest = new QueryTodayFlowRequest(); | |
559 | + BeanUtils.copyProperties(request, flowRequest); | |
560 | + Calendar calendar = Calendar.getInstance(); | |
561 | + calendar.setTime(new Date()); | |
562 | + calendar.set(Calendar.HOUR_OF_DAY, 0); | |
563 | + calendar.set(Calendar.MINUTE, 0); | |
564 | + calendar.set(Calendar.SECOND, 0); | |
565 | + Date beginTime = calendar.getTime(); | |
566 | + flowRequest.setBeginTime(beginTime); | |
567 | + flowRequest.setEndTime(new Date()); | |
568 | + flowRequest.setDataState(1); | |
569 | + flowRequest.setOrderType(1); | |
570 | + for (ParkingLotDTO dto : parkResult.getData()) { | |
571 | + switch (dto.getPlCountryId().intValue()) { | |
572 | + case 923://红山区 | |
573 | + HSPlNos.add(dto.getPlNo()); | |
574 | + BeanUtils.copyProperties(flowRequest, HSRequest); | |
575 | + HSRequest.setPlCountryId(dto.getPlCountryId()); | |
576 | + HSRequest.setPlCountryName(dto.getPlCountryName()); | |
577 | + break; | |
578 | + case 925://松山区 | |
579 | + SSPlNos.add(dto.getPlNo()); | |
580 | + BeanUtils.copyProperties(flowRequest, SSRequest); | |
581 | + SSRequest.setPlCountryId(dto.getPlCountryId()); | |
582 | + SSRequest.setPlCountryName(dto.getPlCountryName()); | |
583 | + break; | |
584 | + case 924://元宝山区 | |
585 | + YBSPlNos.add(dto.getPlNo()); | |
586 | + BeanUtils.copyProperties(flowRequest, YBSRequest); | |
587 | + YBSRequest.setPlCountryId(dto.getPlCountryId()); | |
588 | + YBSRequest.setPlCountryName(dto.getPlCountryName()); | |
589 | + break; | |
590 | + default://其他 | |
591 | + QTPlNos.add(dto.getPlNo()); | |
592 | + BeanUtils.copyProperties(flowRequest, QTRequest); | |
593 | + QTRequest.setPlCountryId(9999L); | |
594 | + QTRequest.setPlCountryName("其他"); | |
595 | + | |
596 | + break; | |
597 | + } | |
598 | + } | |
599 | + | |
600 | + HSRequest.setPlNos(HSPlNos); | |
601 | + SSRequest.setPlNos(SSPlNos); | |
602 | + YBSRequest.setPlNos(YBSPlNos); | |
603 | + QTRequest.setPlNos(QTPlNos); | |
604 | + requests.add(HSRequest); | |
605 | + requests.add(SSRequest); | |
606 | + requests.add(YBSRequest); | |
607 | + requests.add(QTRequest); | |
608 | + for (QueryTodayFlowRequest re : requests) { | |
609 | + BizResult<ParkingFlowCountDTO> dtoBiz = tdBOrderService.queryTodayVehicleFlow(re); | |
610 | + if(dtoBiz.getData()!=null){ | |
611 | + BeanUtils.copyProperties(re, dtoBiz.getData()); | |
612 | + parkingFlowCountDTOs.add(dtoBiz.getData()); | |
613 | + } | |
614 | + } | |
615 | + parkFlowDTOs.setData(parkingFlowCountDTOs); | |
616 | + logger.info("调用后场dubbo服务,响应为: result={}", JSONObject.toJSONString(parkFlowDTOs)); | |
617 | + return parkFlowDTOs; | |
618 | + } | |
619 | + | |
620 | + @ApiOperation(value="24小时占用率") | |
621 | + @PostMapping("queryTwentyFourHoursOccupyRate") | |
622 | + @ResponseBody | |
623 | + public BizResultVO<List<ParkingOccupyDTO>> queryTwentyFourHoursOccupyRate(@RequestBody StatisticParkLotCountByCountryRequest request){ | |
624 | + BizResultVO<List<ParkingOccupyDTO>> parkOccupyDTOs = new BizResultVO<>(); | |
625 | + QueryParkingOccupyRequest occupyRequest = new QueryParkingOccupyRequest(); | |
626 | + List<String> plNos = new ArrayList<>(); | |
627 | + //先查询城市下面的停车场 | |
628 | + BizResult<List<ParkingLotDTO>> parkResult = parkingLotQueryService.queryParkLotByCountry(request); | |
629 | + if (ResultUtils.isError(parkResult)) { | |
630 | + //如果失败 | |
631 | + parkOccupyDTOs.setCode(parkResult.getErrCode().getCode()); | |
632 | + parkOccupyDTOs.setMsg(parkResult.getErrMsg()); | |
633 | + return parkOccupyDTOs; | |
634 | + } | |
635 | + for (ParkingLotDTO parkDto : parkResult.getData()) { | |
636 | + plNos.add(parkDto.getPlNo()); | |
637 | + } | |
638 | + if(plNos.size()<1){ | |
639 | + throw new BizException(ErrorType.PARAMM_NULL,"停车场编号"); | |
640 | + } | |
641 | + BeanUtils.copyProperties(request, occupyRequest); | |
642 | + occupyRequest.setPlNos(plNos); | |
643 | + occupyRequest.setDataStatus(1); | |
644 | + occupyRequest.setStatisticType(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR); | |
645 | + Calendar calendar = Calendar.getInstance(); | |
646 | + calendar.setTime(new Date()); | |
647 | + calendar.set(Calendar.MINUTE, 0); | |
648 | + calendar.set(Calendar.SECOND, 0); | |
649 | + Date endTime = calendar.getTime(); | |
650 | + | |
651 | + //往前倒三个月 | |
652 | + //calendar.add(Calendar.MONTH, -3); | |
653 | + calendar.add(Calendar.DAY_OF_MONTH, -1); | |
654 | + calendar.set(Calendar.MINUTE, 0); | |
655 | + calendar.set(Calendar.SECOND, 0); | |
656 | + Date beginTime = calendar.getTime(); | |
657 | + | |
658 | + occupyRequest.setBeginTime(beginTime); | |
659 | + occupyRequest.setEndTime(endTime); | |
660 | + | |
661 | + BizResult<List<ParkingOccupyDTO>> result = parkOccupyService.queryTwentyFourHoursOccupyRate(occupyRequest); | |
662 | + if(!(result.isSuccess())){ | |
663 | + //如果失败 | |
664 | + parkOccupyDTOs.setCode(result.getErrCode().getCode()); | |
665 | + parkOccupyDTOs.setMsg(result.getErrMsg()); | |
666 | + return parkOccupyDTOs; | |
667 | + } | |
668 | + parkOccupyDTOs.setData(result.getData()); | |
669 | + logger.info("调用后场dubbo服务,响应为: result={}", JSONObject.toJSONString(parkOccupyDTOs)); | |
670 | + return parkOccupyDTOs; | |
671 | + } | |
672 | + | |
673 | + @ApiOperation(value="今日交易") | |
674 | + @PostMapping("queryTodayOrderTrans") | |
675 | + @ResponseBody | |
676 | + public BizResultVO<OrderTransDTO> queryTodayOrderTrans(@RequestBody StatisticParkLotCountByCountryRequest request){ | |
677 | + BizResultVO<OrderTransDTO> orderDTO = new BizResultVO<>(); | |
678 | + OrderTransactionQueryRequest orderTransRequest = new OrderTransactionQueryRequest(); | |
679 | + List<String> plNos = new ArrayList<>(); | |
680 | + //先查询城市下面的停车场 | |
681 | + BizResult<List<ParkingLotDTO>> parkResult = parkingLotQueryService.queryParkLotByCountry(request); | |
682 | + if (ResultUtils.isError(parkResult)) { | |
683 | + //如果失败 | |
684 | + orderDTO.setCode(parkResult.getErrCode().getCode()); | |
685 | + orderDTO.setMsg(parkResult.getErrMsg()); | |
686 | + return orderDTO; | |
687 | + } | |
688 | + for (ParkingLotDTO parkDto : parkResult.getData()) { | |
689 | + plNos.add(parkDto.getPlNo()); | |
690 | + } | |
691 | + if(plNos.size()<1){ | |
692 | + throw new BizException(ErrorType.PARAMM_NULL,"停车场编号"); | |
693 | + } | |
694 | + BeanUtils.copyProperties(request, orderTransRequest); | |
695 | + orderTransRequest.setParkIds(plNos); | |
696 | + | |
697 | + Calendar calendar = Calendar.getInstance(); | |
698 | + calendar.setTime(new Date()); | |
699 | + calendar.set(Calendar.HOUR_OF_DAY, 0); | |
700 | + calendar.set(Calendar.MINUTE, 0); | |
701 | + calendar.set(Calendar.SECOND, 0); | |
702 | + Date beginTime = calendar.getTime(); | |
703 | + orderTransRequest.setBeginTime(beginTime); | |
704 | + orderTransRequest.setEndTime(new Date()); | |
705 | + | |
706 | + BizResult<OrderTransDTO> result = tdBOrderService.queryOrderTrans(orderTransRequest); | |
707 | + if(!(result.isSuccess())){ | |
708 | + //如果失败 | |
709 | + orderDTO.setCode(result.getErrCode().getCode()); | |
710 | + orderDTO.setMsg(result.getErrMsg()); | |
711 | + return orderDTO; | |
712 | + } | |
713 | + orderDTO.setData(result.getData()); | |
714 | + //分->元 | |
715 | + BigDecimal hundred = new BigDecimal("100"); | |
716 | + OrderTransDTO o = orderDTO.getData(); | |
717 | + o.setAliTotalAmount(o.getAliTotalAmount().divide(hundred)); | |
718 | + o.setCashTotalAmount(o.getCashTotalAmount().divide(hundred)); | |
719 | + o.setPayedTotalAmount(o.getPayedTotalAmount().divide(hundred)); | |
720 | + o.setWxTotalAmount(o.getWxTotalAmount().divide(hundred)); | |
721 | + o.setYlTotalAmount(o.getYlTotalAmount().divide(hundred)); | |
722 | + orderDTO.setData(o); | |
723 | + | |
724 | + logger.info("调用后场dubbo服务,响应为: result={}", JSONObject.toJSONString(orderDTO)); | |
725 | + return orderDTO; | |
726 | + } | |
466 | 727 | } | ... | ... |