| | |
| | | package com.java110.web.smo.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.common.constant.PrivilegeCodeConstant; |
| | | import com.java110.common.constant.ResponseConstant; |
| | | import com.java110.common.constant.ServiceConstant; |
| | | import com.java110.common.exception.SMOException; |
| | | import com.java110.common.util.Assert; |
| | | import com.java110.utils.constant.PrivilegeCodeConstant; |
| | | import com.java110.utils.constant.ResponseConstant; |
| | | import com.java110.utils.constant.ServiceConstant; |
| | | import com.java110.utils.exception.SMOException; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.core.context.IPageData; |
| | | import com.java110.web.core.BaseComponentSMO; |
| | | import com.java110.web.smo.IParkingSpaceServiceSMO; |
| | |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 小区楼实现类 |
| | |
| | | return responseEntity; |
| | | } |
| | | |
| | | @Override |
| | | public ResponseEntity<String> listParkingSpaceByOwner(IPageData pd) { |
| | | validateListParkingSpaceByOwner(pd); |
| | | |
| | | JSONObject paramIn = JSONObject.parseObject(pd.getReqData()); |
| | | String communityId = paramIn.getString("communityId"); |
| | | |
| | | //校验用户是否有权限 |
| | | super.checkUserHasPrivilege(pd, restTemplate, PrivilegeCodeConstant.PRIVILEGE_PARKING_SPACE_FOR_OWNER); |
| | | |
| | | ResponseEntity responseEntity = super.getStoreInfo(pd, restTemplate); |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { |
| | | return responseEntity; |
| | | } |
| | | Assert.jsonObjectHaveKey(responseEntity.getBody().toString(), "storeId", "根据用户ID查询商户ID失败,未包含storeId节点"); |
| | | Assert.jsonObjectHaveKey(responseEntity.getBody().toString(), "storeTypeCd", "根据用户ID查询商户类型失败,未包含storeTypeCd节点"); |
| | | |
| | | String storeId = JSONObject.parseObject(responseEntity.getBody().toString()).getString("storeId"); |
| | | String storeTypeCd = JSONObject.parseObject(responseEntity.getBody().toString()).getString("storeTypeCd"); |
| | | //数据校验是否 商户是否入驻该小区 |
| | | super.checkStoreEnterCommunity(pd, storeId, storeTypeCd, communityId, restTemplate); |
| | | String apiUrl = ServiceConstant.SERVICE_API_URL + "/api/parkingSpace.queryParkingSpacesByOwner" + mapToUrlParam(paramIn); |
| | | |
| | | |
| | | responseEntity = this.callCenterService(restTemplate, pd, "", |
| | | apiUrl, |
| | | HttpMethod.GET); |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { |
| | | return responseEntity; |
| | | } |
| | | |
| | | JSONObject psInfo = JSONObject.parseObject(responseEntity.getBody().toString()); |
| | | JSONArray pss = psInfo.getJSONArray("parkingSpaces"); |
| | | |
| | | Map feeMap = null; |
| | | JSONObject resultFeeInfo = null; |
| | | JSONObject psObj = null; |
| | | for (int roomIndex = 0; roomIndex < pss.size(); roomIndex++) { |
| | | psObj = pss.getJSONObject(roomIndex); |
| | | feeMap = new HashMap(); |
| | | feeMap.put("communityId", communityId); |
| | | feeMap.put("psId", psObj.getString("psId")); |
| | | apiUrl = ServiceConstant.SERVICE_API_URL + "/api/fee.queryFeeByParkingSpace" + mapToUrlParam(feeMap); |
| | | responseEntity = this.callCenterService(restTemplate, pd, "", |
| | | apiUrl, |
| | | HttpMethod.GET); |
| | | |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { |
| | | //throw new SMOException(ResponseConstant.RESULT_CODE_ERROR, "当前房屋[" + roomObj.getString("roomNum") + "]没有物业费信息,数据错误"); |
| | | |
| | | continue; |
| | | } |
| | | |
| | | resultFeeInfo = JSONObject.parseObject(responseEntity.getBody().toString()); |
| | | psObj.putAll(resultFeeInfo); |
| | | |
| | | } |
| | | |
| | | responseEntity = new ResponseEntity(psInfo.toJSONString(), HttpStatus.OK); |
| | | |
| | | return responseEntity; |
| | | } |
| | | |
| | | @Override |
| | | public ResponseEntity<String> exitParkingSpace(IPageData pd) { |
| | | validateExitParkingSpace(pd); |
| | | //校验员工是否有权限操作 |
| | | super.checkUserHasPrivilege(pd, restTemplate, PrivilegeCodeConstant.PRIVILEGE_OWNER_ROOM); |
| | | |
| | | JSONObject paramIn = JSONObject.parseObject(pd.getReqData()); |
| | | String communityId = paramIn.getString("communityId"); |
| | | ResponseEntity responseEntity = super.getStoreInfo(pd, restTemplate); |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { |
| | | return responseEntity; |
| | | } |
| | | Assert.jsonObjectHaveKey(responseEntity.getBody().toString(), "storeId", "根据用户ID查询商户ID失败,未包含storeId节点"); |
| | | Assert.jsonObjectHaveKey(responseEntity.getBody().toString(), "storeTypeCd", "根据用户ID查询商户类型失败,未包含storeTypeCd节点"); |
| | | |
| | | String storeId = JSONObject.parseObject(responseEntity.getBody().toString()).getString("storeId"); |
| | | String storeTypeCd = JSONObject.parseObject(responseEntity.getBody().toString()).getString("storeTypeCd"); |
| | | //数据校验是否 商户是否入驻该小区 |
| | | super.checkStoreEnterCommunity(pd, storeId, storeTypeCd, communityId, restTemplate); |
| | | paramIn.put("userId", pd.getUserId()); |
| | | paramIn.put("storeId", storeId); |
| | | responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(), |
| | | ServiceConstant.SERVICE_API_URL + "/api/parkingSpace.exitParkingSpace", |
| | | HttpMethod.POST); |
| | | |
| | | return responseEntity; |
| | | } |
| | | |
| | | /** |
| | | * 数据合规性校验 |
| | | * @param pd 页面数据封装 |
| | | */ |
| | | private void validateExitParkingSpace(IPageData pd) { |
| | | |
| | | Assert.jsonObjectHaveKey(pd.getReqData(), "communityId", "请求报文中未包含communityId节点"); |
| | | Assert.jsonObjectHaveKey(pd.getReqData(), "ownerId", "请求报文中未包含ownerId节点"); |
| | | Assert.jsonObjectHaveKey(pd.getReqData(), "psId", "请求报文中未包含psId节点"); |
| | | |
| | | JSONObject paramIn = JSONObject.parseObject(pd.getReqData()); |
| | | Assert.hasLength(paramIn.getString("communityId"), "小区ID不能为空"); |
| | | Assert.hasLength(paramIn.getString("ownerId"), "ownerId不能为空"); |
| | | Assert.hasLength(paramIn.getString("psId"), "psId不能为空"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除小区楼 校验 |
| | | * |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 校验查询小区楼信息 |
| | | * |
| | | * @param pd 页面封装对象 |
| | | */ |
| | | private void validateListParkingSpaceByOwner(IPageData pd) { |
| | | Assert.jsonObjectHaveKey(pd.getReqData(), "communityId", "请求报文中未包含communityId节点"); |
| | | Assert.jsonObjectHaveKey(pd.getReqData(), "ownerId", "请求报文中未包含ownerId节点"); |
| | | JSONObject paramIn = JSONObject.parseObject(pd.getReqData()); |
| | | Assert.hasLength(paramIn.getString("communityId"), "小区ID不能为空"); |
| | | Assert.hasLength(paramIn.getString("ownerId"), "业主ID不能为空"); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | public RestTemplate getRestTemplate() { |