From b5172f8407d1a8b9100f4d3262c1147a33f99d3a Mon Sep 17 00:00:00 2001 From: wangfei <1006884993@qq.com> Date: Fri, 1 Sep 2017 15:57:59 +0800 Subject: [PATCH] berth area_tree --- src/main/java/com/zteits/irain/portal/web/govclouds/TbAreaController.java | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 118 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/zteits/irain/portal/web/govclouds/TbAreaController.java b/src/main/java/com/zteits/irain/portal/web/govclouds/TbAreaController.java index 8f2bb75..8794604 100644 --- a/src/main/java/com/zteits/irain/portal/web/govclouds/TbAreaController.java +++ b/src/main/java/com/zteits/irain/portal/web/govclouds/TbAreaController.java @@ -7,33 +7,38 @@ import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.util.CollectionUtils; -import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import com.alibaba.fastjson.JSONObject; import com.clouds.common.cache.sys.SysCodeValueCacheUtil; import com.clouds.common.constants.CodeValKindEnum; +import com.clouds.common.entity.UserInfo; +import com.clouds.common.web.SessionCommUtil; import com.clouds.common.web.vo.BizResultVO; -import com.google.common.collect.Lists; import com.zteits.clouds.api.apibase.bean.BizResult; import com.zteits.clouds.api.apibase.bean.PageBean; +import com.zteits.clouds.api.apibase.constants.AreaTypeEnum; +import com.zteits.clouds.api.apibase.constants.BasicEnum; import com.zteits.clouds.api.apibase.constants.ErrorType; import com.zteits.clouds.api.apibase.exception.BizException; +import com.zteits.clouds.api.dto.park.dto.TpPRegionAreaDTO; +import com.zteits.clouds.api.dto.park.param.ParkInfoByAreaBlockIdsRequest; +import com.zteits.clouds.api.dto.park.param.QueryTpPRegionAreaForPageRequest; import com.zteits.clouds.api.dto.park.param.StatisticParkLotCountByCountryRequest; -import com.zteits.clouds.api.dto.park.param.UpdateFreeBerthRequest; -import com.zteits.clouds.api.dto.sys.SysRoleDTO; -import com.zteits.clouds.api.dto.sys.TbAreaDTO; -import com.zteits.clouds.api.dto.sys.param.TbAreaQueryRequest; +import com.zteits.clouds.api.dto.sys.AreaTreeDTO; +import com.zteits.clouds.api.dto.sys.param.AreaBlockByOrgIdQueryRequest; +import com.zteits.clouds.api.service.park.ParkingLotService; +import com.zteits.clouds.api.service.park.TpPRegionAreaService; import com.zteits.clouds.api.service.sys.TbAreaService; -import com.zteits.irain.portal.web.irain.UpdateFreeBerthController; +import io.jsonwebtoken.lang.Collections; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -60,6 +65,13 @@ public class TbAreaController { private String sysCode; @Autowired private TbAreaService tbAreaService; + @Autowired + private SessionCommUtil sessionCommUtil; + @Autowired + private ParkingLotService parkingLotService; + + @Autowired + private TpPRegionAreaService tpPRegionAreaService; @ApiOperation("查询区域下一级") @PostMapping("queryNextLowerLeverById") @@ -80,4 +92,102 @@ public class TbAreaController { return new BizResultVO>>().setData(list); } + /** + * 获取泊位区间tree + * @param request + * @return + * @throws Exception + */ + @ApiOperation("获取泊位区间tree") + @PostMapping("/getBerthAreatree") + public BizResultVO> getBerthAreatree(@RequestBody AreaBlockByOrgIdQueryRequest + request) throws Exception { + logger.info("---begin加载泊位区间tree.."); + + UserInfo userInfo = sessionCommUtil.getUserInfo(); + request.setOrgId(userInfo.getOrgId()); + BizResult> result = tbAreaService.queryAreaBlockByOrgId(request); + //2.获取块id列表 + List areaBlockIdList = this.getAreaBlockIds(result); + //3.通过块Ids查询块下面得停车场 + List parklist = this.queryParkInfoByAreaBlockIds(areaBlockIdList); + if (result != null && !CollectionUtils.isEmpty(result.getData())) { + if (!CollectionUtils.isEmpty(parklist)) { + result.getData().addAll(parklist); + + //4.通过停车场编号查询停车场下的泊位区间 + List berthArealist = new ArrayList<>(); + List plNos = new ArrayList<>(); + for (AreaTreeDTO a : parklist) { + plNos.add(a.getPlNo()); + } + QueryTpPRegionAreaForPageRequest areaRequest = new QueryTpPRegionAreaForPageRequest(); + BeanUtils.copyProperties(request, areaRequest); + areaRequest.setPlNos(plNos); + BizResult> arearesult = tpPRegionAreaService.queryTpPRegionAreaForPage(areaRequest); + if (!(arearesult.isSuccess())) { + throw new BizException(arearesult.getErrCode(),arearesult.getErrMsg()); + } + if(!(CollectionUtils.isEmpty(arearesult.getData().getDataList()))){ + for (TpPRegionAreaDTO t : arearesult.getData().getDataList()) { + AreaTreeDTO area = new AreaTreeDTO(); + area.setAreaName(t.getParkAreaName()); + area.setAreaType(AreaTypeEnum.Area.code()); + area.setPlNo(t.getPlNo()); + area.setIdCode(t.getParkAreaCode()); + area.setParentCode(t.getPlNo()); + area.setAreaRangeCode(t.getParkAreaCode()); + berthArealist.add(area); + } + if(!(CollectionUtils.isEmpty(berthArealist))){ + result.getData().addAll(berthArealist); + + } + } + } + } + + + logger.info("---end加载泊位区间tree.."); + return new BizResultVO>(result); + } + /** + * 通过块Ids查询块下面得停车场.
+ * + * @param areaBlockIdList + * @return + */ + private List queryParkInfoByAreaBlockIds(List areaBlockIdList) { + List list = new ArrayList(); + ParkInfoByAreaBlockIdsRequest blockIdRequest = new ParkInfoByAreaBlockIdsRequest(); + if (!CollectionUtils.isEmpty(areaBlockIdList)) { + blockIdRequest.setAreaBlockIds(areaBlockIdList); + blockIdRequest.setSysCode(BasicEnum.SYS_CODE.getValue()); + BizResult> result = parkingLotService.queryParkInfoByAreaBlockIds(blockIdRequest); + if (result != null && !Collections.isEmpty(result.getData())) { + for (AreaTreeDTO a : result.getData()) { + a.setAreaType(AreaTypeEnum.PARK.code()); + } + list.addAll(result.getData()); + } + } + return list; + } + + /** + * 获取块ids列表.
+ * + * @return + */ + private List getAreaBlockIds(BizResult> result) { + List areaBlockIdList = new ArrayList(); + if (result != null && !CollectionUtils.isEmpty(result.getData())) { + for (AreaTreeDTO e : result.getData()) { + if (e != null && AreaTypeEnum.BLOCK.code().equals(e.getAreaType())) { + areaBlockIdList.add(e.getId()); + } + } + } + return areaBlockIdList; + } } -- libgit2 0.21.4