Commit b5172f8407d1a8b9100f4d3262c1147a33f99d3a
1 parent
813e3b15
berth area_tree
Showing
1 changed file
with
118 additions
and
8 deletions
src/main/java/com/zteits/irain/portal/web/govclouds/TbAreaController.java
| ... | ... | @@ -7,33 +7,38 @@ import java.util.Map; |
| 7 | 7 | |
| 8 | 8 | import org.slf4j.Logger; |
| 9 | 9 | import org.slf4j.LoggerFactory; |
| 10 | +import org.springframework.beans.BeanUtils; | |
| 10 | 11 | import org.springframework.beans.factory.annotation.Autowired; |
| 11 | 12 | import org.springframework.beans.factory.annotation.Value; |
| 12 | 13 | import org.springframework.util.CollectionUtils; |
| 13 | -import org.springframework.web.bind.annotation.GetMapping; | |
| 14 | 14 | import org.springframework.web.bind.annotation.PostMapping; |
| 15 | 15 | import org.springframework.web.bind.annotation.RequestBody; |
| 16 | 16 | import org.springframework.web.bind.annotation.RequestMapping; |
| 17 | -import org.springframework.web.bind.annotation.RequestParam; | |
| 18 | 17 | import org.springframework.web.bind.annotation.RestController; |
| 19 | 18 | |
| 20 | 19 | import com.alibaba.fastjson.JSONObject; |
| 21 | 20 | import com.clouds.common.cache.sys.SysCodeValueCacheUtil; |
| 22 | 21 | import com.clouds.common.constants.CodeValKindEnum; |
| 22 | +import com.clouds.common.entity.UserInfo; | |
| 23 | +import com.clouds.common.web.SessionCommUtil; | |
| 23 | 24 | import com.clouds.common.web.vo.BizResultVO; |
| 24 | -import com.google.common.collect.Lists; | |
| 25 | 25 | import com.zteits.clouds.api.apibase.bean.BizResult; |
| 26 | 26 | import com.zteits.clouds.api.apibase.bean.PageBean; |
| 27 | +import com.zteits.clouds.api.apibase.constants.AreaTypeEnum; | |
| 28 | +import com.zteits.clouds.api.apibase.constants.BasicEnum; | |
| 27 | 29 | import com.zteits.clouds.api.apibase.constants.ErrorType; |
| 28 | 30 | import com.zteits.clouds.api.apibase.exception.BizException; |
| 31 | +import com.zteits.clouds.api.dto.park.dto.TpPRegionAreaDTO; | |
| 32 | +import com.zteits.clouds.api.dto.park.param.ParkInfoByAreaBlockIdsRequest; | |
| 33 | +import com.zteits.clouds.api.dto.park.param.QueryTpPRegionAreaForPageRequest; | |
| 29 | 34 | import com.zteits.clouds.api.dto.park.param.StatisticParkLotCountByCountryRequest; |
| 30 | -import com.zteits.clouds.api.dto.park.param.UpdateFreeBerthRequest; | |
| 31 | -import com.zteits.clouds.api.dto.sys.SysRoleDTO; | |
| 32 | -import com.zteits.clouds.api.dto.sys.TbAreaDTO; | |
| 33 | -import com.zteits.clouds.api.dto.sys.param.TbAreaQueryRequest; | |
| 35 | +import com.zteits.clouds.api.dto.sys.AreaTreeDTO; | |
| 36 | +import com.zteits.clouds.api.dto.sys.param.AreaBlockByOrgIdQueryRequest; | |
| 37 | +import com.zteits.clouds.api.service.park.ParkingLotService; | |
| 38 | +import com.zteits.clouds.api.service.park.TpPRegionAreaService; | |
| 34 | 39 | import com.zteits.clouds.api.service.sys.TbAreaService; |
| 35 | -import com.zteits.irain.portal.web.irain.UpdateFreeBerthController; | |
| 36 | 40 | |
| 41 | +import io.jsonwebtoken.lang.Collections; | |
| 37 | 42 | import io.swagger.annotations.Api; |
| 38 | 43 | import io.swagger.annotations.ApiOperation; |
| 39 | 44 | |
| ... | ... | @@ -60,6 +65,13 @@ public class TbAreaController { |
| 60 | 65 | private String sysCode; |
| 61 | 66 | @Autowired |
| 62 | 67 | private TbAreaService tbAreaService; |
| 68 | + @Autowired | |
| 69 | + private SessionCommUtil sessionCommUtil; | |
| 70 | + @Autowired | |
| 71 | + private ParkingLotService parkingLotService; | |
| 72 | + | |
| 73 | + @Autowired | |
| 74 | + private TpPRegionAreaService tpPRegionAreaService; | |
| 63 | 75 | |
| 64 | 76 | @ApiOperation("查询区域下一级") |
| 65 | 77 | @PostMapping("queryNextLowerLeverById") |
| ... | ... | @@ -80,4 +92,102 @@ public class TbAreaController { |
| 80 | 92 | return new BizResultVO<List<Map<String, String>>>().setData(list); |
| 81 | 93 | } |
| 82 | 94 | |
| 95 | + /** | |
| 96 | + * 获取泊位区间tree | |
| 97 | + * @param request | |
| 98 | + * @return | |
| 99 | + * @throws Exception | |
| 100 | + */ | |
| 101 | + @ApiOperation("获取泊位区间tree") | |
| 102 | + @PostMapping("/getBerthAreatree") | |
| 103 | + public BizResultVO<List<AreaTreeDTO>> getBerthAreatree(@RequestBody AreaBlockByOrgIdQueryRequest | |
| 104 | + request) throws Exception { | |
| 105 | + logger.info("---begin加载泊位区间tree.."); | |
| 106 | + | |
| 107 | + UserInfo userInfo = sessionCommUtil.getUserInfo(); | |
| 108 | + request.setOrgId(userInfo.getOrgId()); | |
| 109 | + BizResult<List<AreaTreeDTO>> result = tbAreaService.queryAreaBlockByOrgId(request); | |
| 110 | + //2.获取块id列表 | |
| 111 | + List<Long> areaBlockIdList = this.getAreaBlockIds(result); | |
| 112 | + //3.通过块Ids查询块下面得停车场 | |
| 113 | + List<AreaTreeDTO> parklist = this.queryParkInfoByAreaBlockIds(areaBlockIdList); | |
| 114 | + if (result != null && !CollectionUtils.isEmpty(result.getData())) { | |
| 115 | + if (!CollectionUtils.isEmpty(parklist)) { | |
| 116 | + result.getData().addAll(parklist); | |
| 117 | + | |
| 118 | + //4.通过停车场编号查询停车场下的泊位区间 | |
| 119 | + List<AreaTreeDTO> berthArealist = new ArrayList<>(); | |
| 120 | + List<String> plNos = new ArrayList<>(); | |
| 121 | + for (AreaTreeDTO a : parklist) { | |
| 122 | + plNos.add(a.getPlNo()); | |
| 123 | + } | |
| 124 | + QueryTpPRegionAreaForPageRequest areaRequest = new QueryTpPRegionAreaForPageRequest(); | |
| 125 | + BeanUtils.copyProperties(request, areaRequest); | |
| 126 | + areaRequest.setPlNos(plNos); | |
| 127 | + BizResult<PageBean<TpPRegionAreaDTO>> arearesult = tpPRegionAreaService.queryTpPRegionAreaForPage(areaRequest); | |
| 128 | + if (!(arearesult.isSuccess())) { | |
| 129 | + throw new BizException(arearesult.getErrCode(),arearesult.getErrMsg()); | |
| 130 | + } | |
| 131 | + if(!(CollectionUtils.isEmpty(arearesult.getData().getDataList()))){ | |
| 132 | + for (TpPRegionAreaDTO t : arearesult.getData().getDataList()) { | |
| 133 | + AreaTreeDTO area = new AreaTreeDTO(); | |
| 134 | + area.setAreaName(t.getParkAreaName()); | |
| 135 | + area.setAreaType(AreaTypeEnum.Area.code()); | |
| 136 | + area.setPlNo(t.getPlNo()); | |
| 137 | + area.setIdCode(t.getParkAreaCode()); | |
| 138 | + area.setParentCode(t.getPlNo()); | |
| 139 | + area.setAreaRangeCode(t.getParkAreaCode()); | |
| 140 | + berthArealist.add(area); | |
| 141 | + } | |
| 142 | + if(!(CollectionUtils.isEmpty(berthArealist))){ | |
| 143 | + result.getData().addAll(berthArealist); | |
| 144 | + | |
| 145 | + } | |
| 146 | + } | |
| 147 | + } | |
| 148 | + } | |
| 149 | + | |
| 150 | + | |
| 151 | + logger.info("---end加载泊位区间tree.."); | |
| 152 | + return new BizResultVO<List<AreaTreeDTO>>(result); | |
| 153 | + } | |
| 154 | + /** | |
| 155 | + * 通过块Ids查询块下面得停车场.<br/> | |
| 156 | + * | |
| 157 | + * @param areaBlockIdList | |
| 158 | + * @return | |
| 159 | + */ | |
| 160 | + private List<AreaTreeDTO> queryParkInfoByAreaBlockIds(List<Long> areaBlockIdList) { | |
| 161 | + List<AreaTreeDTO> list = new ArrayList<AreaTreeDTO>(); | |
| 162 | + ParkInfoByAreaBlockIdsRequest blockIdRequest = new ParkInfoByAreaBlockIdsRequest(); | |
| 163 | + if (!CollectionUtils.isEmpty(areaBlockIdList)) { | |
| 164 | + blockIdRequest.setAreaBlockIds(areaBlockIdList); | |
| 165 | + blockIdRequest.setSysCode(BasicEnum.SYS_CODE.getValue()); | |
| 166 | + BizResult<List<AreaTreeDTO>> result = parkingLotService.queryParkInfoByAreaBlockIds(blockIdRequest); | |
| 167 | + if (result != null && !Collections.isEmpty(result.getData())) { | |
| 168 | + for (AreaTreeDTO a : result.getData()) { | |
| 169 | + a.setAreaType(AreaTypeEnum.PARK.code()); | |
| 170 | + } | |
| 171 | + list.addAll(result.getData()); | |
| 172 | + } | |
| 173 | + } | |
| 174 | + return list; | |
| 175 | + } | |
| 176 | + | |
| 177 | + /** | |
| 178 | + * 获取块ids列表.<br/> | |
| 179 | + * | |
| 180 | + * @return | |
| 181 | + */ | |
| 182 | + private List<Long> getAreaBlockIds(BizResult<List<AreaTreeDTO>> result) { | |
| 183 | + List<Long> areaBlockIdList = new ArrayList<Long>(); | |
| 184 | + if (result != null && !CollectionUtils.isEmpty(result.getData())) { | |
| 185 | + for (AreaTreeDTO e : result.getData()) { | |
| 186 | + if (e != null && AreaTypeEnum.BLOCK.code().equals(e.getAreaType())) { | |
| 187 | + areaBlockIdList.add(e.getId()); | |
| 188 | + } | |
| 189 | + } | |
| 190 | + } | |
| 191 | + return areaBlockIdList; | |
| 192 | + } | |
| 83 | 193 | } | ... | ... |