Commit 2e79ff4ee2032ba4396943f6a9879a9d1b224f7f
1 parent
5049cdb0
实时停车
Showing
2 changed files
with
145 additions
and
0 deletions
src/main/java/com/zteits/irain/portal/web/govclouds/RealTimeInfoController.java
0 → 100644
1 | +/** | |
2 | + * | |
3 | + */ | |
4 | +package com.zteits.irain.portal.web.govclouds; | |
5 | + | |
6 | +import java.util.ArrayList; | |
7 | +import java.util.List; | |
8 | + | |
9 | +import org.slf4j.Logger; | |
10 | +import org.slf4j.LoggerFactory; | |
11 | +import org.springframework.beans.factory.annotation.Autowired; | |
12 | +import org.springframework.beans.factory.annotation.Value; | |
13 | +import org.springframework.util.CollectionUtils; | |
14 | +import org.springframework.web.bind.annotation.PostMapping; | |
15 | +import org.springframework.web.bind.annotation.RequestBody; | |
16 | +import org.springframework.web.bind.annotation.RequestMapping; | |
17 | +import org.springframework.web.bind.annotation.RequestParam; | |
18 | +import org.springframework.web.bind.annotation.RestController; | |
19 | + | |
20 | +import com.alibaba.fastjson.JSON; | |
21 | +import com.clouds.common.cache.park.ParkFreeBerthsCacheUtil; | |
22 | +import com.clouds.common.cache.park.ParkingLotGeoCacheUtil; | |
23 | +import com.clouds.common.entity.UserArea; | |
24 | +import com.clouds.common.entity.UserInfo; | |
25 | +import com.clouds.common.web.SessionCommUtil; | |
26 | +import com.clouds.common.web.vo.BizResultVO; | |
27 | +import com.zteits.clouds.api.apibase.bean.BizResult; | |
28 | +import com.zteits.clouds.api.apibase.constants.LonLatTypeEnum; | |
29 | +import com.zteits.clouds.api.dto.govclouds.dto.BerthInfoDTO; | |
30 | +import com.zteits.clouds.api.dto.govclouds.dto.EscapesPaymentDataDTO; | |
31 | +import com.zteits.clouds.api.dto.govclouds.dto.WarningInfoDTO; | |
32 | +import com.zteits.clouds.api.dto.govclouds.dto.ZeroBerthParkingLotDTO; | |
33 | +import com.zteits.clouds.api.dto.govclouds.param.EscapePaymentRequest; | |
34 | +import com.zteits.clouds.api.dto.govclouds.param.ParkingBerthInfoRequest; | |
35 | +import com.zteits.clouds.api.dto.govclouds.param.UserAreaInfo; | |
36 | +import com.zteits.clouds.api.dto.govclouds.param.WarningInfoRequest; | |
37 | +import com.zteits.clouds.api.dto.park.dto.ParkinglotAndGeoInfoDTO; | |
38 | +import com.zteits.clouds.api.service.govclouds.RealtimeInfoService; | |
39 | +import com.zteits.clouds.api.service.park.ParkingLotBerthsService; | |
40 | + | |
41 | +import io.swagger.annotations.Api; | |
42 | +import io.swagger.annotations.ApiOperation; | |
43 | + | |
44 | +/** | |
45 | + * @author hxz | |
46 | + * | |
47 | + */ | |
48 | +@Api(value="实时停车", description="实时停车") | |
49 | +@RestController | |
50 | +@RequestMapping("/rtinfo") | |
51 | +public class RealTimeInfoController { | |
52 | + private static final Logger logger = LoggerFactory.getLogger(RealTimeInfoController.class); | |
53 | + | |
54 | + @Value("${project.syscode}") | |
55 | + private String sysCode; | |
56 | + @Autowired | |
57 | + private SessionCommUtil sessionCommUtil; | |
58 | + | |
59 | + @Autowired | |
60 | + private RealtimeInfoService rtInfoService; | |
61 | + @Autowired | |
62 | + private ParkingLotBerthsService plBerthsService; | |
63 | + | |
64 | + @ApiOperation("24小时逃逸补缴情况") | |
65 | + @PostMapping("/escapePaymentInfo") | |
66 | + public BizResultVO<EscapesPaymentDataDTO> getEscapePaymentInfoDuring24hs(@RequestBody EscapePaymentRequest request) { | |
67 | + BizResult<EscapesPaymentDataDTO> result = null; | |
68 | + try { | |
69 | + result = rtInfoService.getEscapePaymentInfoDuring24hs(request); | |
70 | + } catch (Exception e) { | |
71 | + logger.error(e.toString()); | |
72 | + e.printStackTrace(); | |
73 | + } | |
74 | + | |
75 | + return new BizResultVO<EscapesPaymentDataDTO>(result); | |
76 | + } | |
77 | + | |
78 | + @ApiOperation("停车指数,根据登录人所属市区id获取计算所需数据") | |
79 | + @PostMapping("/berthinfo") | |
80 | + public BizResultVO<BerthInfoDTO> getParkingBerthInfo(@RequestParam String sysCode) { | |
81 | + ParkingBerthInfoRequest request = new ParkingBerthInfoRequest(); | |
82 | + request.setSysCode(sysCode); | |
83 | + | |
84 | + UserInfo userInfo = sessionCommUtil.getUserInfo(); | |
85 | + List<UserArea> userAreaList = userInfo.getUserAreas(); | |
86 | + List<UserAreaInfo> userAreaInfoList = null; | |
87 | + if (null != userAreaList && !CollectionUtils.isEmpty(userAreaList)) { | |
88 | + userAreaInfoList = JSON.parseArray(JSON.toJSONString(userAreaList, false), UserAreaInfo.class); | |
89 | + } | |
90 | + request.setUserAreaInfoList(userAreaInfoList); | |
91 | + | |
92 | + BizResult<BerthInfoDTO> result = plBerthsService.getParkingBerthInfo(request); | |
93 | + | |
94 | + return new BizResultVO<BerthInfoDTO>(result); | |
95 | + } | |
96 | + | |
97 | + @ApiOperation("停车预警") | |
98 | + @PostMapping("/warninginfo") | |
99 | + public BizResultVO<List<WarningInfoDTO>> getPreWarningInfo(@RequestParam String sysCode) { | |
100 | + WarningInfoRequest request = new WarningInfoRequest(); | |
101 | + request.setSysCode(sysCode); | |
102 | + | |
103 | + UserInfo userInfo = sessionCommUtil.getUserInfo(); | |
104 | + List<UserArea> userAreaList = userInfo.getUserAreas(); | |
105 | + List<UserAreaInfo> userAreaInfoList = null; | |
106 | + if (null != userAreaList && !CollectionUtils.isEmpty(userAreaList)) { | |
107 | + userAreaInfoList = JSON.parseArray(JSON.toJSONString(userAreaList, false), UserAreaInfo.class); | |
108 | + } | |
109 | + request.setUserAreaInfoList(userAreaInfoList); | |
110 | + | |
111 | + // 获取所有空闲车位为零的停车场信息列表 | |
112 | + List<ZeroBerthParkingLotDTO> zeroBerthplDTOList = plBerthsService.getZeroBerthParkinglotList(request); | |
113 | + | |
114 | + List<WarningInfoDTO> warningInfoList = new ArrayList<WarningInfoDTO>(); | |
115 | + | |
116 | + for (ZeroBerthParkingLotDTO zeroBerthpl: zeroBerthplDTOList) { | |
117 | + | |
118 | + List<ParkinglotAndGeoInfoDTO> plgInfoList = ParkingLotGeoCacheUtil.queryParkLotsWithDistanceAndCoordinateByAsc( | |
119 | + LonLatTypeEnum.LON_LAT_TYPE_1, zeroBerthpl.getLongitude(), zeroBerthpl.getLatitude(), 5000D, 50L); | |
120 | + | |
121 | + int notZeroBerthPlCount = 0;// 非零空闲泊位数的停车场个数 | |
122 | + if (null != plgInfoList && !CollectionUtils.isEmpty(plgInfoList)) { | |
123 | + WarningInfoDTO warningInfoDTO = new WarningInfoDTO(); | |
124 | + for (ParkinglotAndGeoInfoDTO ParkinglotAndGeoInfoDTO: plgInfoList) { | |
125 | + if (0 < ParkFreeBerthsCacheUtil.getFreeBerthsByPlNo(ParkinglotAndGeoInfoDTO.getPlNo())) | |
126 | + { | |
127 | + notZeroBerthPlCount += 1; | |
128 | + } | |
129 | + } | |
130 | + | |
131 | + if (0 < notZeroBerthPlCount) { | |
132 | + warningInfoDTO.setParkingLotName(zeroBerthpl.getParkingLotName()); | |
133 | + warningInfoDTO.setPlCountHavingFreeBerth(notZeroBerthPlCount); | |
134 | + | |
135 | + warningInfoList.add(warningInfoDTO); | |
136 | + } | |
137 | + } | |
138 | + } | |
139 | + | |
140 | + return new BizResultVO<>(new BizResult<>(warningInfoList)) ; | |
141 | + } | |
142 | +} | ... | ... |
src/main/resources/dubbo/dubbo-park-consumer.xml
... | ... | @@ -149,4 +149,7 @@ |
149 | 149 | version="${spring.dubbo.provider.version}" |
150 | 150 | timeout="30000"/> |
151 | 151 | |
152 | + <!-- 实时停车 --> | |
153 | + <dubbo:reference id="realtimeInfoService" interface="com.zteits.clouds.api.service.govclouds.RealtimeInfoService" | |
154 | + version="${spring.dubbo.provider.version}" timeout="30000"/> | |
152 | 155 | </beans> |
153 | 156 | \ No newline at end of file | ... | ... |