| | |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.common.constant.FeeTypeConstant; |
| | | import com.java110.common.constant.ResponseConstant; |
| | | import com.java110.common.constant.ServiceConstant; |
| | | import com.java110.common.exception.ListenerExecuteException; |
| | | import com.java110.common.util.Assert; |
| | | import com.java110.common.util.DateUtil; |
| | | import com.java110.common.util.ImportExcelUtils; |
| | | import com.java110.common.util.StringUtil; |
| | | import com.java110.core.context.IPageData; |
| | | import com.java110.dto.FeeConfigDto; |
| | | import com.java110.dto.ParkingSpaceDto; |
| | | import com.java110.entity.assetImport.ImportFloor; |
| | | import com.java110.entity.assetImport.ImportOwner; |
| | | import com.java110.entity.assetImport.ImportParkingSpace; |
| | |
| | | //保存单元信息 和 楼栋信息 |
| | | responseEntity = savedFloorAndUnitInfo(pd, floors, result); |
| | | |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { |
| | | if (responseEntity == null || responseEntity.getStatusCode() != HttpStatus.OK) { |
| | | return responseEntity; |
| | | } |
| | | |
| | | // 保存业主信息 |
| | | responseEntity = savedOwnerInfo(pd, owners, result); |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { |
| | | if (responseEntity == null || responseEntity.getStatusCode() != HttpStatus.OK) { |
| | | return responseEntity; |
| | | } |
| | | |
| | | //保存房屋 |
| | | responseEntity = savedRoomInfo(pd,rooms,result); |
| | | responseEntity = savedRoomInfo(pd, rooms, result); |
| | | if (responseEntity == null || responseEntity.getStatusCode() != HttpStatus.OK) { |
| | | return responseEntity; |
| | | } |
| | | |
| | | //保存车位 |
| | | responseEntity = savedParkingSpaceInfo(pd, parkingSpaces, result); |
| | | |
| | | if (responseEntity == null || responseEntity.getStatusCode() != HttpStatus.OK) { |
| | | return responseEntity; |
| | | } |
| | | |
| | | return responseEntity; |
| | | } |
| | | |
| | | /** |
| | | * 保存车位信息 |
| | | * |
| | | * @param pd |
| | | * @param parkingSpaces |
| | | * @param result |
| | | * @return |
| | | */ |
| | | private ResponseEntity<String> savedParkingSpaceInfo(IPageData pd, List<ImportParkingSpace> parkingSpaces, ComponentValidateResult result) { |
| | | String apiUrl = ""; |
| | | JSONObject paramIn = null; |
| | | ResponseEntity<String> responseEntity = new ResponseEntity<String>("成功",HttpStatus.OK); |
| | | ImportOwner owner = null; |
| | | for (ImportParkingSpace parkingSpace : parkingSpaces) { |
| | | JSONObject savedParkingSpaceInfo = getExistsParkSpace(pd, result, parkingSpace); |
| | | if (savedParkingSpaceInfo != null) { |
| | | continue; |
| | | } |
| | | |
| | | paramIn = new JSONObject(); |
| | | |
| | | apiUrl = ServiceConstant.SERVICE_API_URL + "/api/parkingSpace.saveParkingSpace"; |
| | | |
| | | paramIn.put("communityId", result.getCommunityId()); |
| | | paramIn.put("num", parkingSpace.getPsNum()); |
| | | paramIn.put("area", parkingSpace.getArea()); |
| | | paramIn.put("typeCd", parkingSpace.getTypeCd()); |
| | | |
| | | responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(), apiUrl, HttpMethod.POST); |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { |
| | | continue; |
| | | } |
| | | |
| | | savedParkingSpaceInfo = getExistsParkSpace(pd, result, parkingSpace); |
| | | if (savedParkingSpaceInfo != null) { |
| | | continue; |
| | | } |
| | | |
| | | //是否有业主信息 |
| | | if (parkingSpace.getImportOwner() == null) { |
| | | continue; |
| | | } |
| | | |
| | | paramIn.clear(); |
| | | |
| | | paramIn.put("communityId", result.getCommunityId()); |
| | | paramIn.put("ownerId", parkingSpace.getImportOwner().getOwnerId()); |
| | | paramIn.put("carNum", parkingSpace.getCarNum()); |
| | | paramIn.put("carBrand", parkingSpace.getCarBrand()); |
| | | paramIn.put("carType", parkingSpace.getCarType()); |
| | | paramIn.put("carColor", parkingSpace.getCarColor()); |
| | | paramIn.put("psId", savedParkingSpaceInfo.getString("psId")); |
| | | paramIn.put("storeId", result.getStoreId()); |
| | | paramIn.put("sellOrHire", parkingSpace.getSellOrHire()); |
| | | |
| | | String feeTypeCd = "1001".equals(parkingSpace.getTypeCd()) |
| | | ? FeeTypeConstant.FEE_TYPE_SELL_UP_PARKING_SPACE : FeeTypeConstant.FEE_TYPE_SELL_DOWN_PARKING_SPACE; |
| | | apiUrl = ServiceConstant.SERVICE_API_URL + "/api/fee.queryFeeConfig?communityId=" + result.getCommunityId() + "&feeTypeCd=" + feeTypeCd; |
| | | responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET); |
| | | |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { |
| | | continue; |
| | | } |
| | | |
| | | JSONObject configInfo = JSONObject.parseObject(responseEntity.getBody()); |
| | | if(!configInfo.containsKey("additionalAmount")){ |
| | | continue; |
| | | } |
| | | |
| | | paramIn.put("receivedAmount", configInfo.getString("additionalAmount")); |
| | | |
| | | apiUrl = ServiceConstant.SERVICE_API_URL + "/api/parkingSpace.sellParkingSpace"; |
| | | responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(), apiUrl, HttpMethod.POST); |
| | | } |
| | | |
| | | return responseEntity; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保存房屋信息 |
| | | * |
| | | * @param pd |
| | | * @param rooms |
| | | * @param result |
| | |
| | | private ResponseEntity<String> savedRoomInfo(IPageData pd, List<ImportRoom> rooms, ComponentValidateResult result) { |
| | | String apiUrl = ""; |
| | | JSONObject paramIn = null; |
| | | ResponseEntity<String> responseEntity = null; |
| | | for(ImportRoom room : rooms){ |
| | | ResponseEntity<String> responseEntity = new ResponseEntity<String>("成功",HttpStatus.OK); |
| | | ImportOwner owner = null; |
| | | for (ImportRoom room : rooms) { |
| | | JSONObject savedRoomInfo = getExistsRoom(pd, result, room); |
| | | |
| | | if (savedRoomInfo != null) { |
| | | continue; |
| | | } |
| | | |
| | | paramIn = new JSONObject(); |
| | | |
| | | |
| | | //保存 房屋 |
| | | |
| | | apiUrl = ServiceConstant.SERVICE_API_URL + "/api/room.saveRoom"; |
| | | |
| | | paramIn.put("communityId", result.getCommunityId()); |
| | | paramIn.put("unitId", room.getFloor().getUnitId()); |
| | | paramIn.put("roomNum", room.getRoomNum()); |
| | | paramIn.put("layer", room.getLayer()); |
| | | paramIn.put("section", "1"); |
| | | paramIn.put("apartment", room.getSection()); |
| | | paramIn.put("state", "2002"); |
| | | paramIn.put("builtUpArea", room.getBuiltUpArea()); |
| | | paramIn.put("unitPrice", "1000.00"); |
| | | |
| | | responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(), apiUrl, HttpMethod.POST); |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { |
| | | continue; |
| | | } |
| | | |
| | | savedRoomInfo = getExistsRoom(pd, result, room); |
| | | if (savedRoomInfo == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (room.getImportOwner() == null) { |
| | | continue; |
| | | } |
| | | paramIn.clear(); |
| | | apiUrl = ServiceConstant.SERVICE_API_URL + "/api/room.sellRoom"; |
| | | paramIn.put("communityId", result.getCommunityId()); |
| | | paramIn.put("ownerId", room.getImportOwner().getOwnerId()); |
| | | paramIn.put("roomId", savedRoomInfo.getString("roomId")); |
| | | paramIn.put("state", "2001"); |
| | | paramIn.put("storeId", result.getStoreId()); |
| | | responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(), apiUrl, HttpMethod.POST); |
| | | |
| | | } |
| | | |
| | | return responseEntity; |
| | |
| | | |
| | | /** |
| | | * 查询存在的房屋信息 |
| | | * room.queryRooms |
| | | * |
| | | * @param pd |
| | | * @param result |
| | | * @param parkingSpace |
| | | * @return |
| | | */ |
| | | private JSONObject getExistsParkSpace(IPageData pd, ComponentValidateResult result, ImportParkingSpace parkingSpace) { |
| | | String apiUrl = ""; |
| | | ResponseEntity<String> responseEntity = null; |
| | | apiUrl = ServiceConstant.SERVICE_API_URL + "/api/parkingSpace.queryParkingSpaces?page=1&row=1&communityId=" + result.getCommunityId() |
| | | + "&num=" + parkingSpace.getPsNum(); |
| | | responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET); |
| | | |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { //跳过 保存单元信息 |
| | | return null; |
| | | } |
| | | |
| | | JSONObject savedParkingSpaceInfoResults = JSONObject.parseObject(responseEntity.getBody()); |
| | | |
| | | |
| | | if (!savedParkingSpaceInfoResults.containsKey("parkingSpaces") || savedParkingSpaceInfoResults.getJSONArray("parkingSpaces").size() != 1) { |
| | | return null; |
| | | } |
| | | |
| | | |
| | | JSONObject savedParkingSpaceInfo = savedParkingSpaceInfoResults.getJSONArray("parkingSpaces").getJSONObject(0); |
| | | |
| | | return savedParkingSpaceInfo; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询存在的房屋信息 |
| | | * room.queryRooms |
| | | * |
| | | * @param pd |
| | | * @param result |
| | | * @param room |
| | | * @return |
| | | */ |
| | | private JSONObject getExistsRoom(IPageData pd, ComponentValidateResult result, ImportRoom room) { |
| | | return null; |
| | | String apiUrl = ""; |
| | | ResponseEntity<String> responseEntity = null; |
| | | apiUrl = ServiceConstant.SERVICE_API_URL + "/api/room.queryRooms?page=1&row=1&communityId=" + result.getCommunityId() |
| | | + "&floorId=" + room.getFloor().getFloorId() + "&unitId=" + room.getFloor().getUnitId() + "&roomNum=" + room.getRoomNum(); |
| | | responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET); |
| | | |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { //跳过 保存单元信息 |
| | | return null; |
| | | } |
| | | |
| | | JSONObject savedRoomInfoResults = JSONObject.parseObject(responseEntity.getBody()); |
| | | |
| | | |
| | | if (!savedRoomInfoResults.containsKey("rooms") || savedRoomInfoResults.getJSONArray("rooms").size() != 1) { |
| | | return null; |
| | | } |
| | | |
| | | |
| | | JSONObject savedRoomInfo = savedRoomInfoResults.getJSONArray("rooms").getJSONObject(0); |
| | | |
| | | return savedRoomInfo; |
| | | } |
| | | |
| | | /** |
| | |
| | | private ResponseEntity<String> savedOwnerInfo(IPageData pd, List<ImportOwner> owners, ComponentValidateResult result) { |
| | | String apiUrl = ""; |
| | | JSONObject paramIn = null; |
| | | ResponseEntity<String> responseEntity = null; |
| | | ResponseEntity<String> responseEntity = new ResponseEntity<String>("成功",HttpStatus.OK); |
| | | |
| | | for (ImportOwner owner : owners) { |
| | | JSONObject savedOwnerInfo = getExistsOwner(pd, result, owner); |
| | | |
| | | if (savedOwnerInfo != null) { |
| | | owner.setOwnerId(savedOwnerInfo.getString("ownerId")); |
| | | continue; |
| | | } |
| | | paramIn = new JSONObject(); |
| | |
| | | paramIn.put("sex", owner.getSex()); |
| | | paramIn.put("ownerTypeCd", "1001"); |
| | | responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(), apiUrl, HttpMethod.POST); |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { |
| | | if (responseEntity.getStatusCode() == HttpStatus.OK) { |
| | | savedOwnerInfo = getExistsOwner(pd, result, owner); |
| | | owner.setOwnerId(savedOwnerInfo.getString("ownerId")); |
| | | } |
| | |
| | | private ResponseEntity<String> savedFloorAndUnitInfo(IPageData pd, List<ImportFloor> floors, ComponentValidateResult result) { |
| | | String apiUrl = ""; |
| | | JSONObject paramIn = null; |
| | | ResponseEntity<String> responseEntity = null; |
| | | ResponseEntity<String> responseEntity = new ResponseEntity<String>("成功",HttpStatus.OK); |
| | | for (ImportFloor importFloor : floors) { |
| | | paramIn = new JSONObject(); |
| | | //先保存 楼栋信息 |
| | |
| | | paramIn.put("name", importFloor.getFloorNum() + "号楼"); |
| | | responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(), apiUrl, HttpMethod.POST); |
| | | } |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { //跳过 保存单元信息 |
| | | if (responseEntity != null && responseEntity.getStatusCode() != HttpStatus.OK) { //跳过 保存单元信息 |
| | | continue; |
| | | } |
| | | |
| | |
| | | importFloor.setFloorId(savedFloorInfo.getString("floorId")); |
| | | paramIn.clear(); |
| | | //判断单元信息是否已经存在,如果存在则不保存数据unit.queryUnits |
| | | if (getExistsUnit(pd, result, importFloor) != null) { |
| | | JSONObject savedUnitInfo = getExistsUnit(pd, result, importFloor); |
| | | if ( savedUnitInfo != null) { |
| | | importFloor.setUnitId(savedUnitInfo.getString("unitId")); |
| | | continue; |
| | | } |
| | | |
| | |
| | | responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(), apiUrl, HttpMethod.POST); |
| | | |
| | | //将unitId 刷入ImportFloor对象 |
| | | JSONObject savedUnitInfo = getExistsUnit(pd, result, importFloor); |
| | | savedUnitInfo = getExistsUnit(pd, result, importFloor); |
| | | importFloor.setUnitId(savedUnitInfo.getString("unitId")); |
| | | |
| | | } |
| | |
| | | String apiUrl = ""; |
| | | ResponseEntity<String> responseEntity = null; |
| | | apiUrl = ServiceConstant.SERVICE_API_URL + "/api/unit.queryUnits?communityId=" + result.getCommunityId() |
| | | + "&floorId=" + importFloor.getFloorId() + "&unitNum=" + importFloor.getFloorNum(); |
| | | + "&floorId=" + importFloor.getFloorId() + "&unitNum=" + importFloor.getUnitNum(); |
| | | responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET); |
| | | |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { //跳过 保存单元信息 |
| | |
| | | if (osIndex == 0) { // 第一行是 头部信息 直接跳过 |
| | | continue; |
| | | } |
| | | if(StringUtil.isNullOrNone(os[0])){ |
| | | continue; |
| | | } |
| | | importParkingSpace = new ImportParkingSpace(); |
| | | importParkingSpace.setPsNum(os[0].toString()); |
| | | importParkingSpace.setTypeCd(os[1].toString()); |
| | | importParkingSpace.setArea(Double.parseDouble(os[2].toString())); |
| | | if(StringUtil.isNullOrNone(os[3])){ |
| | | parkingSpaces.add(importParkingSpace); |
| | | continue; |
| | | } |
| | | ImportOwner importOwner = getImportOwner(owners, os[3].toString()); |
| | | importParkingSpace.setImportOwner(importOwner); |
| | | if (importOwner != null) { |
| | |
| | | importParkingSpace.setCarBrand(os[5].toString()); |
| | | importParkingSpace.setCarType(os[6].toString()); |
| | | importParkingSpace.setCarColor(os[7].toString()); |
| | | importParkingSpace.setSellOrHire(os[8].toString()); |
| | | } |
| | | |
| | | parkingSpaces.add(importParkingSpace); |
| | |
| | | if (osIndex == 0) { // 第一行是 头部信息 直接跳过 |
| | | continue; |
| | | } |
| | | if(StringUtil.isNullOrNone(os[0])){ |
| | | continue; |
| | | } |
| | | importRoom = new ImportRoom(); |
| | | importRoom.setRoomNum(os[0].toString()); |
| | | importRoom.setFloor(getImportFloor(floors, os[1].toString(), os[2].toString())); |
| | | importRoom.setLayer(Integer.parseInt(os[3].toString())); |
| | | importRoom.setSection(os[4].toString()); |
| | | importRoom.setBuiltUpArea(Double.parseDouble(os[5].toString())); |
| | | if(StringUtil.isNullOrNone(os[6])){ |
| | | rooms.add(importRoom); |
| | | continue; |
| | | } |
| | | importRoom.setImportOwner(getImportOwner(owners, os[6].toString())); |
| | | rooms.add(importRoom); |
| | | } |
| | |
| | | if (osIndex == 0) { // 第一行是 头部信息 直接跳过 |
| | | continue; |
| | | } |
| | | if(StringUtil.isNullOrNone(os[0])){ |
| | | continue; |
| | | } |
| | | importOwner = new ImportOwner(); |
| | | importOwner.setOwnerNum(os[0].toString()); |
| | | importOwner.setOwnerName(os[1].toString()); |
| | |
| | | if (osIndex == 0) { // 第一行是 头部信息 直接跳过 |
| | | continue; |
| | | } |
| | | |
| | | if(StringUtil.isNullOrNone(os[0])){ |
| | | continue; |
| | | } |
| | | importFloor = new ImportFloor(); |
| | | importFloor.setFloorNum(os[0].toString()); |
| | | importFloor.setUnitNum(os[1].toString()); |
| | | importFloor.setLayerCount(os[2].toString()); |
| | | importFloor.setLift("有".equals(os[3].toString()) ? "Y" : "N"); |
| | | importFloor.setLift("有".equals(os[3].toString()) ? "1010" : "2020"); |
| | | floors.add(importFloor); |
| | | } |
| | | } |