| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.springblade.common.cache.SysCache; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springblade.common.param.CommonParamSet; |
| | | import org.springblade.common.utils.IdUtils; |
| | | import org.springblade.common.utils.NodeTreeUtil; |
| | | import org.springblade.common.utils.SpringUtils; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.modules.doorplateAddress.entity.DoorplateAddressEntity; |
| | | import org.springblade.modules.doorplateAddress.service.IDoorplateAddressService; |
| | | import org.springblade.modules.grid.entity.GridEntity; |
| | |
| | | import org.springblade.modules.label.entity.LabelEntity; |
| | | import org.springblade.modules.label.service.ILabelService; |
| | | import org.springblade.modules.label.vo.LabelVO; |
| | | import org.springblade.modules.place.excel.PlaceExcel; |
| | | import org.springblade.modules.place.vo.PlaceVO; |
| | | import org.springblade.modules.police.entity.PoliceAffairsGridEntity; |
| | | import org.springblade.modules.police.service.IPoliceAffairsGridService; |
| | | import org.springblade.modules.system.entity.Region; |
| | |
| | | public class HouseServiceImpl extends ServiceImpl<HouseMapper, HouseEntity> implements IHouseService { |
| | | |
| | | |
| | | private static final Logger logger = LoggerFactory.getLogger(HouseServiceImpl.class); |
| | | |
| | | @Autowired |
| | | private IGridService gridService; |
| | | |
| | |
| | | public IPage<HouseVO> selectHousePage(IPage<HouseVO> page, HouseVO house) { |
| | | // List<String> regionChildCodesList = SysCache.getRegionChildCodesByDeptId(AuthUtil.getDeptId()); |
| | | // Integer isAdministrator = AuthUtil.isAdministrator() == true ? 1 : 2; |
| | | CommonParamSet commonParamSet = new CommonParamSet().invoke(HouseVO.class,house); |
| | | CommonParamSet commonParamSet = new CommonParamSet().invoke(HouseVO.class, house); |
| | | |
| | | List<HouseVO> houseVOS = baseMapper.selectHousePage(page, house, |
| | | commonParamSet.getRegionChildCodesList(),commonParamSet.getGridCodeList(), commonParamSet.getIsAdministrator() |
| | | ); |
| | | commonParamSet.getRegionChildCodesList(), commonParamSet.getGridCodeList(), commonParamSet.getIsAdministrator() |
| | | ); |
| | | return page.setRecords(houseVOS); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public HouseVO getHouseDetail(HouseVO house) { |
| | | if (ObjectUtils.isEmpty(house)) { |
| | | logger.error("house是空值", house); |
| | | return new HouseVO(); |
| | | } |
| | | if (StringUtils.isBlank(house.getHouseCode()) && ObjectUtils.isEmpty(house.getId())) { |
| | | logger.error("house.HouseCode是空值", house); |
| | | return new HouseVO(); |
| | | } |
| | | return baseMapper.getHouseDetail(house); |
| | | } |
| | | |
| | |
| | | if (null != houseParam.getRoleName() && !houseParam.getRoleName().equals("")) { |
| | | if (houseParam.getRoleName().equals("网格员")) { |
| | | // 查询对应的房屋地址code |
| | | stringList = gridService.getAddressCodeListByUserId(AuthUtil.getUserId(),null); |
| | | stringList = gridService.getAddressCodeListByUserId(AuthUtil.getUserId(), null); |
| | | } |
| | | } |
| | | return stringList; |
| | |
| | | if (Strings.isBlank(houseAndHoldExcel.getHouseName())) { |
| | | // 查询地址总表对应的数据 |
| | | QueryWrapper<DoorplateAddressEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("address_code",houseAndHoldExcel.getHouseCode()); |
| | | queryWrapper.eq("address_code", houseAndHoldExcel.getHouseCode()); |
| | | DoorplateAddressEntity addressEntity = doorplateAddressService.getOne(queryWrapper); |
| | | if (null!=addressEntity){ |
| | | if (null != addressEntity) { |
| | | houseEntity.setHouseName(addressEntity.getAddressName()); |
| | | houseEntity.setAddress(addressEntity.getAddressName()); |
| | | houseEntity.setDistrictCode(addressEntity.getAoiCode()); |
| | |
| | | houseEntity.setLng(addressEntity.getX()); |
| | | houseEntity.setLat(addressEntity.getY()); |
| | | } |
| | | }else { |
| | | } else { |
| | | houseEntity.setHouseName(houseAndHoldExcel.getHouseName()); |
| | | houseEntity.setAddress(houseAndHoldExcel.getHouseName()); |
| | | } |
| | |
| | | houseEntity.setSource(2); |
| | | } |
| | | // 网格处理 |
| | | importGridHandle(houseAndHoldExcel,houseEntity); |
| | | importGridHandle(houseAndHoldExcel, houseEntity); |
| | | // 新增 |
| | | save(houseEntity); |
| | | }else { |
| | | } else { |
| | | // 更新 |
| | | if (Strings.isBlank(houseAndHoldExcel.getHouseName())) { |
| | | // 查询地址总表对应的数据 |
| | | QueryWrapper<DoorplateAddressEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("address_code",houseAndHoldExcel.getHouseCode()); |
| | | queryWrapper.eq("address_code", houseAndHoldExcel.getHouseCode()); |
| | | DoorplateAddressEntity addressEntity = doorplateAddressService.getOne(queryWrapper); |
| | | if (null!=addressEntity){ |
| | | if (null != addressEntity) { |
| | | one.setHouseName(addressEntity.getAddressName()); |
| | | one.setAddress(addressEntity.getAddressName()); |
| | | one.setDistrictCode(addressEntity.getAoiCode()); |
| | |
| | | one.setLng(addressEntity.getX()); |
| | | one.setLat(addressEntity.getY()); |
| | | } |
| | | }else { |
| | | } else { |
| | | one.setHouseName(houseAndHoldExcel.getHouseName()); |
| | | one.setAddress(houseAndHoldExcel.getHouseName()); |
| | | } |
| | |
| | | one.setArea(houseAndHoldExcel.getArea()); |
| | | one.setPropertyPrice(houseAndHoldExcel.getPropertyPrice()); |
| | | // 网格处理 |
| | | importGridHandle(houseAndHoldExcel,one); |
| | | importGridHandle(houseAndHoldExcel, one); |
| | | // 更新 |
| | | updateById(one); |
| | | } |
| | |
| | | // 身份证类型为居民身份证 |
| | | householdEntity.setCardType(111); |
| | | householdEntity.setIdCard(houseAndHoldExcel.getIdCard()); |
| | | }else { |
| | | } else { |
| | | householdEntity.setIdCard(houseAndHoldExcel.getIdCard()); |
| | | } |
| | | } |
| | |
| | | // 身份证类型为居民身份证 |
| | | one.setCardType(111); |
| | | one.setIdCard(houseAndHoldExcel.getIdCard()); |
| | | }else { |
| | | } else { |
| | | one.setIdCard(houseAndHoldExcel.getIdCard()); |
| | | } |
| | | } |
| | |
| | | boolean update = householdService.updateById(one); |
| | | if (update) { |
| | | // 住户标签处理 |
| | | householdLabelHandle(houseAndHoldExcel,one); |
| | | householdLabelHandle(houseAndHoldExcel, one); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * 导入是网格数据绑定处理 |
| | | * |
| | | * @param houseAndHoldExcel |
| | | * @param houseEntity |
| | | */ |
| | | public void importGridHandle(HouseAndHoldExcel houseAndHoldExcel, HouseEntity houseEntity) { |
| | | if (!Strings.isBlank(houseAndHoldExcel.getCommunityName()) && |
| | | !Strings.isBlank(houseAndHoldExcel.getGridName())){ |
| | | !Strings.isBlank(houseAndHoldExcel.getGridName())) { |
| | | // 查询对应的网格信息 |
| | | GridEntity gridEntity = gridService.getGridInfoByParam(houseAndHoldExcel.getCommunityName(),houseAndHoldExcel.getGridName()); |
| | | if (null!=gridEntity){ |
| | | GridEntity gridEntity = gridService.getGridInfoByParam(houseAndHoldExcel.getCommunityName(), houseAndHoldExcel.getGridName()); |
| | | if (null != gridEntity) { |
| | | // 设置场所范围 |
| | | houseEntity.setGridId(gridEntity.getId()); |
| | | houseEntity.setGridCode(gridEntity.getGridCode()); |
| | |
| | | gridRangeEntity.setGridCode(gridEntity.getGridCode()); |
| | | gridRangeEntity.setHouseCode(houseEntity.getHouseCode()); |
| | | UpdateWrapper<GridRangeEntity> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.eq("house_code",houseEntity.getHouseCode()); |
| | | gridRangeService.update(gridRangeEntity,updateWrapper); |
| | | updateWrapper.eq("house_code", houseEntity.getHouseCode()); |
| | | gridRangeService.update(gridRangeEntity, updateWrapper); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 住户标签处理 |
| | | * |
| | | * @param houseAndHoldExcel |
| | | * @param householdEntity |
| | | */ |
| | |
| | | if (one1 != null) { |
| | | // 判断是否已存在关联关系,没有则新增 |
| | | QueryWrapper<UserHouseLabelEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("label_id",one1.getId()) |
| | | .eq("house_code",householdEntity.getHouseCode()) |
| | | .eq("household_id",householdEntity.getId()); |
| | | wrapper.eq("label_id", one1.getId()) |
| | | .eq("house_code", householdEntity.getHouseCode()) |
| | | .eq("household_id", householdEntity.getId()); |
| | | UserHouseLabelEntity houseLabelEntity = bean.getOne(wrapper); |
| | | if (null==houseLabelEntity) { |
| | | if (null == houseLabelEntity) { |
| | | UserHouseLabelEntity userHouseLabelEntity = new UserHouseLabelEntity(); |
| | | userHouseLabelEntity.setLabelId(BigDecimal.valueOf(one1.getId()).longValue()); |
| | | userHouseLabelEntity.setHouseholdId(householdEntity.getId()); |
| | |
| | | if (null != householdEntity.getPhoneNumber() && !householdEntity.getPhoneNumber().equals("")) { |
| | | //根据手机号查询库里的数据 |
| | | List<User> list = userService.getUserListByPhoneOrAccount(householdEntity.getPhoneNumber()); |
| | | if (list.size()>0) { |
| | | if (list.size() > 0) { |
| | | User user = list.get(0); |
| | | //如果用户存在,则该用户id绑定住户 |
| | | householdEntity.setAssociatedUserId(user.getId()); |
| | |
| | | |
| | | @Override |
| | | public Map<String, Object> getHouseStatistics(String code, String roleType, String aoiCode, String buildingCode, String unitCode) { |
| | | HouseVO house = new HouseVO(); |
| | | CommonParamSet commonParamSet = new CommonParamSet<>().invoke(HouseVO.class, house); |
| | | Map<String, Object> objectObjectHashMap = new HashMap<>(); |
| | | if (roleType.equals("2")) { |
| | | // result1 查询楼栋数 result2 查询房屋套数 result3 查询住户数 result4 查询单元数 |
| | | Integer result1 = baseMapper.getHouseStatisticsOne(code, null, aoiCode, buildingCode, unitCode, roleType); |
| | | Integer result2 = baseMapper.getHouseStatisticsTwo(code, null, aoiCode, buildingCode, unitCode, roleType); |
| | | Integer result3 = baseMapper.getHouseStatisticsThree(code, null, aoiCode, buildingCode, unitCode, roleType); |
| | | Integer result4 = baseMapper.getHouseStatisticsFour(code, null, aoiCode, buildingCode, unitCode, roleType); |
| | | objectObjectHashMap.put("result1", result1); |
| | | objectObjectHashMap.put("result2", result2); |
| | | objectObjectHashMap.put("result3", result3); |
| | | objectObjectHashMap.put("result4", result4); |
| | | } else { |
| | | |
| | | Integer result1 = baseMapper.getHouseStatisticsOne(code, AuthUtil.getUserId(), aoiCode, buildingCode, unitCode, roleType); |
| | | Integer result2 = baseMapper.getHouseStatisticsTwo(code, AuthUtil.getUserId(), aoiCode, buildingCode, unitCode, roleType); |
| | | Integer result3 = baseMapper.getHouseStatisticsThree(code, AuthUtil.getUserId(), aoiCode, buildingCode, unitCode, roleType); |
| | | Integer result4 = baseMapper.getHouseStatisticsFour(code, AuthUtil.getUserId(), aoiCode, buildingCode, unitCode, roleType); |
| | | objectObjectHashMap.put("result1", result1); |
| | | objectObjectHashMap.put("result2", result2); |
| | | objectObjectHashMap.put("result3", result3); |
| | | objectObjectHashMap.put("result4", result4); |
| | | Long userId = null; |
| | | String roleName = SpringUtils.getRequestParam("roleName"); |
| | | if (!Strings.isBlank(roleName) && roleName.equals("mj")){ |
| | | userId = AuthUtil.getUserId(); |
| | | } |
| | | List<String> communityCodeList = Func.toStrList(code); |
| | | Integer result1 = baseMapper.getHouseStatisticsOne(communityCodeList, userId, aoiCode, buildingCode, unitCode, roleType); |
| | | Integer result2 = baseMapper.getHouseStatisticsTwo(communityCodeList, aoiCode, buildingCode, unitCode, house, |
| | | commonParamSet.getIsAdministrator(), |
| | | commonParamSet.getRegionChildCodesList(), |
| | | commonParamSet.getGridCodeList()); |
| | | Integer result3 = baseMapper.getHouseStatisticsThree(communityCodeList, userId, aoiCode, buildingCode, unitCode, roleType); |
| | | Integer result4 = baseMapper.getHouseStatisticsFour(communityCodeList, userId, aoiCode, buildingCode, unitCode, roleType); |
| | | objectObjectHashMap.put("result1", result1); |
| | | objectObjectHashMap.put("result2", result2); |
| | | objectObjectHashMap.put("result3", result3); |
| | | objectObjectHashMap.put("result4", result4); |
| | | return objectObjectHashMap; |
| | | } |
| | | |
| | |
| | | commonParamSet.getRegionChildCodesList(), |
| | | commonParamSet.getIsAdministrator(), |
| | | map.get("code").toString()); |
| | | map.put("child",code); |
| | | map.put("child", code); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 房屋网格处理 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | |
| | | for (HouseEntity houseEntity : houseEntityList) { |
| | | String point = "'POINT(" + houseEntity.getLng() + " " + houseEntity.getLat() + ")'"; |
| | | List<GridEntity> gridEntityList = SpringUtils.getBean(IGridService.class).spatialAnalysis(point); |
| | | if (gridEntityList.size()>0){ |
| | | if (gridEntityList.size() > 0) { |
| | | houseEntity.setGridCode(gridEntityList.get(0).getGridCode()); |
| | | houseEntity.setGridId(gridEntityList.get(0).getId()); |
| | | // 更新 |
| | |
| | | |
| | | /** |
| | | * 房屋警格处理 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | |
| | | for (HouseEntity houseEntity : houseEntityList) { |
| | | String point = "'POINT(" + houseEntity.getLng() + " " + houseEntity.getLat() + ")'"; |
| | | List<PoliceAffairsGridEntity> policeAffairsGridEntityList = SpringUtils.getBean(IPoliceAffairsGridService.class).spatialAnalysis(point); |
| | | if (policeAffairsGridEntityList.size()>0){ |
| | | if (policeAffairsGridEntityList.size() > 0) { |
| | | houseEntity.setJwGridCode(policeAffairsGridEntityList.get(0).getJwGridCode()); |
| | | // 更新 |
| | | updateById(houseEntity); |
| | |
| | | |
| | | /** |
| | | * 房屋画像统计-按房屋标签统计 |
| | | * |
| | | * @param house |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Map<String,Object>> getHouseLabelStatistic(HouseVO house) { |
| | | public List<Map<String, Object>> getHouseLabelStatistic(HouseVO house) { |
| | | CommonParamSet commonParamSet = new CommonParamSet<>().invoke(HouseVO.class, house); |
| | | // 按房屋标签统计 |
| | | List<Map<String,Object>> list = baseMapper.getHouseLabelStatistic(house, |
| | | commonParamSet.getIsAdministrator(), |
| | | commonParamSet.getRegionChildCodesList(), |
| | | commonParamSet.getGridCodeList()); |
| | | List<String> communityCodeList = Func.toStrList(house.getCode()); |
| | | List<Map<String, Object>> list = baseMapper.getHouseLabelStatistic(house,communityCodeList); |
| | | // 返回 |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 查询对应的社区编号 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询所有房屋总数 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | |
| | | |
| | | /** |
| | | * 查询所有的房屋 |
| | | * |
| | | * @param i |
| | | * @param size |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<HouseVO> getAllList(int i, int size) { |
| | | return baseMapper.getAllList(i,size); |
| | | return baseMapper.getAllList(i, size); |
| | | } |
| | | |
| | | /** |
| | | * 房屋标签初始化处置-根据有租客的,初始成出租,有业主没租客的初始化成自主,业主都没的就是闲置 |
| | | * |
| | | * @param house |
| | | * @return |
| | | */ |
| | |
| | | houseLabelEntity.setHouseCode(houseEntity.getHouseCode()); |
| | | houseLabelEntity.setLableType(2); |
| | | houseLabelEntity.setCreateTime(new Date()); |
| | | if (houseEntity.getStatus()==1) { |
| | | if (houseEntity.getStatus() == 1) { |
| | | // 闲置 |
| | | houseLabelEntity.setColor("green"); |
| | | houseLabelEntity.setLabelName("闲置"); |
| | | houseLabelEntity.setLabelId(1037L); |
| | | } |
| | | if (houseEntity.getStatus()==2) { |
| | | if (houseEntity.getStatus() == 2) { |
| | | // 自住 |
| | | houseLabelEntity.setColor("blue"); |
| | | houseLabelEntity.setLabelName("自住"); |
| | | houseLabelEntity.setLabelId(1038L); |
| | | } |
| | | if (houseEntity.getStatus()==3) { |
| | | if (houseEntity.getStatus() == 3) { |
| | | // 出租 |
| | | houseLabelEntity.setColor("yellow"); |
| | | houseLabelEntity.setLabelName("出租"); |
| | |
| | | } |
| | | // 查询当前房屋是否已有,有则更新,无则新增 |
| | | QueryWrapper<UserHouseLabelEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("house_code",houseEntity.getHouseCode()) |
| | | .eq("lable_type",2); |
| | | wrapper.eq("house_code", houseEntity.getHouseCode()) |
| | | .eq("lable_type", 2); |
| | | UserHouseLabelEntity userHouseLabelEntity = userHouseLabelService.getOne(wrapper); |
| | | if (null!=userHouseLabelEntity){ |
| | | if (null != userHouseLabelEntity) { |
| | | // 更新 |
| | | houseLabelEntity.setId(userHouseLabelEntity.getId()); |
| | | userHouseLabelService.updateById(houseLabelEntity); |
| | | }else { |
| | | } else { |
| | | // 新增 |
| | | userHouseLabelService.save(houseLabelEntity); |
| | | } |
| | |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getHoseTotalAndAreaTotalByDistrictCode(List<String> aoiCodeList) { |
| | | return baseMapper.getHoseTotalAndAreaTotalByDistrictCode(aoiCodeList); |
| | | } |
| | | } |