| | |
| | | */ |
| | | package org.springblade.modules.house.service.impl; |
| | | |
| | | import cn.hutool.core.util.IdcardUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | 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.StringUtils; |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.springblade.common.cache.SysCache; |
| | | 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.modules.doorplateAddress.entity.DoorplateAddressEntity; |
| | | import org.springblade.modules.doorplateAddress.service.IDoorplateAddressService; |
| | | import org.springblade.modules.grid.entity.GridEntity; |
| | | import org.springblade.modules.grid.entity.GridRangeEntity; |
| | | import org.springblade.modules.grid.service.IGridRangeService; |
| | | import org.springblade.modules.grid.service.IGridService; |
| | |
| | | import org.springblade.modules.house.vo.HouseVO; |
| | | 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; |
| | | import org.springblade.modules.system.entity.User; |
| | | import org.springblade.modules.system.service.IRegionService; |
| | |
| | | |
| | | @Override |
| | | public IPage<HouseVO> selectHousePage(IPage<HouseVO> page, HouseVO house) { |
| | | List<String> regionChildCodesList = SysCache.getRegionChildCodesByDeptId(AuthUtil.getDeptId()); |
| | | Integer isAdministrator = AuthUtil.isAdministrator() == true ? 1 : 2; |
| | | List<HouseVO> houseVOS = baseMapper.selectHousePage(page, house, regionChildCodesList, isAdministrator); |
| | | // List<String> regionChildCodesList = SysCache.getRegionChildCodesByDeptId(AuthUtil.getDeptId()); |
| | | // Integer isAdministrator = AuthUtil.isAdministrator() == true ? 1 : 2; |
| | | CommonParamSet commonParamSet = new CommonParamSet().invoke(HouseVO.class,house); |
| | | |
| | | List<HouseVO> houseVOS = baseMapper.selectHousePage(page, house, |
| | | commonParamSet.getRegionChildCodesList(),commonParamSet.getGridCodeList(), commonParamSet.getIsAdministrator() |
| | | ); |
| | | return page.setRecords(houseVOS); |
| | | } |
| | | |
| | |
| | | if (null != houseParam.getRoleName() && !houseParam.getRoleName().equals("")) { |
| | | if (houseParam.getRoleName().equals("网格员")) { |
| | | // 查询对应的房屋地址code |
| | | stringList = gridService.getAddressCodeListByUserId(AuthUtil.getUserId()); |
| | | stringList = gridService.getAddressCodeListByUserId(AuthUtil.getUserId(),null); |
| | | } |
| | | } |
| | | return stringList; |
| | |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void saveHouseData(HouseAndHoldExcel houseAndHoldExcel) { |
| | | IDoorplateAddressService doorplateAddressService = SpringUtils.getBean(IDoorplateAddressService.class); |
| | | // 查询库中是否已存在 |
| | | QueryWrapper<HouseEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("house_code", houseAndHoldExcel.getHouseCode()) |
| | |
| | | if (null == one) { |
| | | HouseEntity houseEntity = new HouseEntity(); |
| | | houseEntity.setHouseCode(houseAndHoldExcel.getHouseCode()); |
| | | houseEntity.setHouseName(houseAndHoldExcel.getHouseName()); |
| | | houseEntity.setDistrictName(houseAndHoldExcel.getDistrictName()); |
| | | houseEntity.setUnit(houseAndHoldExcel.getUnit()); |
| | | if (Strings.isBlank(houseAndHoldExcel.getHouseName())) { |
| | | // 查询地址总表对应的数据 |
| | | QueryWrapper<DoorplateAddressEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("address_code",houseAndHoldExcel.getHouseCode()); |
| | | DoorplateAddressEntity addressEntity = doorplateAddressService.getOne(queryWrapper); |
| | | if (null!=addressEntity){ |
| | | houseEntity.setHouseName(addressEntity.getAddressName()); |
| | | houseEntity.setAddress(addressEntity.getAddressName()); |
| | | houseEntity.setDistrictCode(addressEntity.getAoiCode()); |
| | | houseEntity.setDistrictName(addressEntity.getAoiName()); |
| | | houseEntity.setLng(addressEntity.getX()); |
| | | houseEntity.setLat(addressEntity.getY()); |
| | | } |
| | | }else { |
| | | houseEntity.setHouseName(houseAndHoldExcel.getHouseName()); |
| | | houseEntity.setAddress(houseAndHoldExcel.getHouseName()); |
| | | } |
| | | if (!Strings.isBlank(houseAndHoldExcel.getDistrictName())) { |
| | | houseEntity.setDistrictName(houseAndHoldExcel.getDistrictName()); |
| | | } |
| | | if (!Strings.isBlank(houseAndHoldExcel.getUnit())) { |
| | | houseEntity.setUnit(houseAndHoldExcel.getUnit()); |
| | | } |
| | | if (!Strings.isBlank(houseAndHoldExcel.getFloor())) { |
| | | houseEntity.setFloor(houseAndHoldExcel.getFloor()); |
| | | } |
| | |
| | | houseEntity.setHouseCode(IdUtils.getIdBy36()); |
| | | houseEntity.setSource(2); |
| | | } |
| | | // 网格处理 |
| | | importGridHandle(houseAndHoldExcel,houseEntity); |
| | | // 新增 |
| | | save(houseEntity); |
| | | }else { |
| | | // 更新 |
| | | if (Strings.isBlank(houseAndHoldExcel.getHouseName())) { |
| | | // 查询地址总表对应的数据 |
| | | QueryWrapper<DoorplateAddressEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("address_code",houseAndHoldExcel.getHouseCode()); |
| | | DoorplateAddressEntity addressEntity = doorplateAddressService.getOne(queryWrapper); |
| | | if (null!=addressEntity){ |
| | | one.setHouseName(addressEntity.getAddressName()); |
| | | one.setAddress(addressEntity.getAddressName()); |
| | | one.setDistrictCode(addressEntity.getAoiCode()); |
| | | one.setDistrictName(addressEntity.getAoiName()); |
| | | one.setLng(addressEntity.getX()); |
| | | one.setLat(addressEntity.getY()); |
| | | } |
| | | }else { |
| | | one.setHouseName(houseAndHoldExcel.getHouseName()); |
| | | one.setAddress(houseAndHoldExcel.getHouseName()); |
| | | } |
| | | if (!Strings.isBlank(houseAndHoldExcel.getDistrictName())) { |
| | | one.setDistrictName(houseAndHoldExcel.getDistrictName()); |
| | | } |
| | | if (!Strings.isBlank(houseAndHoldExcel.getUnit())) { |
| | | one.setUnit(houseAndHoldExcel.getUnit()); |
| | | } |
| | | if (!Strings.isBlank(houseAndHoldExcel.getFloor())) { |
| | | one.setFloor(houseAndHoldExcel.getFloor()); |
| | | } |
| | | one.setRoom(houseAndHoldExcel.getRoom()); |
| | | one.setBuilding(houseAndHoldExcel.getBuilding()); |
| | | one.setArea(houseAndHoldExcel.getArea()); |
| | | one.setPropertyPrice(houseAndHoldExcel.getPropertyPrice()); |
| | | // 网格处理 |
| | | importGridHandle(houseAndHoldExcel,one); |
| | | // 更新 |
| | | updateById(one); |
| | | } |
| | | } |
| | | |
| | |
| | | QueryWrapper<HouseholdEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("house_code", houseAndHoldExcel.getHouseCode()) |
| | | .eq("is_deleted", 0) |
| | | .eq("phone_number", houseAndHoldExcel.getPhoneNumber()) |
| | | .eq("name", houseAndHoldExcel.getName()); |
| | | HouseholdEntity one = householdService.getOne(wrapper); |
| | | // 不存在则插入,存在则不操作 |
| | |
| | | householdEntity.setHouseCode(houseAndHoldExcel.getHouseCode()); |
| | | householdEntity.setName(houseAndHoldExcel.getName()); |
| | | householdEntity.setPhoneNumber(houseAndHoldExcel.getPhoneNumber()); |
| | | if (!Strings.isBlank(houseAndHoldExcel.getRoleType())) { |
| | | householdEntity.setRoleType(Integer.parseInt(houseAndHoldExcel.getRoleType())); |
| | | } |
| | | // 与角色关系 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getRelationship())) { |
| | | householdEntity.setRelationship(Integer.parseInt(houseAndHoldExcel.getRelationship())); |
| | |
| | | if (!Strings.isBlank(houseAndHoldExcel.getGender())) { |
| | | householdEntity.setGender(Short.parseShort(houseAndHoldExcel.getGender())); |
| | | } |
| | | householdEntity.setIdCard(houseAndHoldExcel.getIdCard()); |
| | | // 居民身份证 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getIdCard())) { |
| | | if (IdcardUtil.isValidCard(houseAndHoldExcel.getIdCard())) { |
| | | // 身份证类型为居民身份证 |
| | | householdEntity.setCardType(111); |
| | | householdEntity.setIdCard(houseAndHoldExcel.getIdCard()); |
| | | }else { |
| | | householdEntity.setIdCard(houseAndHoldExcel.getIdCard()); |
| | | } |
| | | } |
| | | // 党员 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getPartyEmber())) { |
| | | householdEntity.setPartyEmber(Integer.parseInt(houseAndHoldExcel.getPartyEmber())); |
| | | } |
| | | householdEntity.setHkmtPass(houseAndHoldExcel.getHkmtPass()); |
| | | householdEntity.setPassport(houseAndHoldExcel.getPassport()); |
| | | // householdEntity.setHkmtPass(houseAndHoldExcel.getHkmtPass()); |
| | | // householdEntity.setPassport(houseAndHoldExcel.getPassport()); |
| | | // 民族 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getEthnicity())) { |
| | | householdEntity.setEthnicity(Integer.parseInt(houseAndHoldExcel.getEthnicity())); |
| | |
| | | householdEntity.setEmployer(houseAndHoldExcel.getEmployer()); |
| | | householdEntity.setOccupation(houseAndHoldExcel.getOccupation()); |
| | | householdEntity.setCmpyRegAddr(houseAndHoldExcel.getCmpyRegAddr()); |
| | | // 外出 |
| | | householdEntity.setGoOutReason(houseAndHoldExcel.getGoOutReason()); |
| | | if (!Strings.isBlank(houseAndHoldExcel.getGoOutTime())) { |
| | | try { |
| | |
| | | if (!Strings.isBlank(houseAndHoldExcel.getMaritalStatus())) { |
| | | householdEntity.setMaritalStatus(Integer.parseInt(houseAndHoldExcel.getMaritalStatus())); |
| | | } |
| | | // 车牌号 |
| | | householdEntity.setCardNumber(houseAndHoldExcel.getCardNumber()); |
| | | // 其他联系方式 |
| | | householdEntity.setOtherContact(houseAndHoldExcel.getOtherContact()); |
| | | if (Strings.isBlank(householdEntity.getHouseCode())) { |
| | | if (!Strings.isBlank(householdEntity.getHomeAdcode())) { |
| | | // 暂时不处理,导入数据目前都有house_code |
| | | String adCode = shiftResidentHomeAdcode(houseAndHoldExcel.getHomeAdcode()); |
| | | // 转换行政区code |
| | |
| | | // 新增 |
| | | boolean save = householdService.save(householdEntity); |
| | | if (save) { |
| | | String labelId = houseAndHoldExcel.getLabelId(); |
| | | if (StringUtils.isBlank(labelId)) { |
| | | return; |
| | | } |
| | | String[] split = labelId.split(","); |
| | | IUserHouseLabelService bean = SpringUtils.getBean(IUserHouseLabelService.class); |
| | | ILabelService bean1 = SpringUtils.getBean(ILabelService.class); |
| | | for (String s : split) { |
| | | LabelEntity one1 = bean1.getOne(Wrappers.<LabelEntity>lambdaQuery().eq(LabelEntity::getLabelName, s)); |
| | | if (one1 != null) { |
| | | UserHouseLabelEntity userHouseLabelEntity = new UserHouseLabelEntity(); |
| | | userHouseLabelEntity.setLabelId(BigDecimal.valueOf(one1.getId()).longValue()); |
| | | userHouseLabelEntity.setHouseholdId(householdEntity.getId()); |
| | | // 设置默认的绿色 |
| | | userHouseLabelEntity.setColor("green"); |
| | | userHouseLabelEntity.setLableType(1); |
| | | userHouseLabelEntity.setLabelName(s); |
| | | userHouseLabelEntity.setHouseCode(houseAndHoldExcel.getHouseCode()); |
| | | bean.save(userHouseLabelEntity); |
| | | } |
| | | } |
| | | householdLabelHandle(houseAndHoldExcel, householdEntity); |
| | | } |
| | | } else { |
| | | // 更新 |
| | | one.setHouseCode(houseAndHoldExcel.getHouseCode()); |
| | | one.setName(houseAndHoldExcel.getName()); |
| | | one.setPhoneNumber(houseAndHoldExcel.getPhoneNumber()); |
| | | if (!Strings.isBlank(houseAndHoldExcel.getRoleType())) { |
| | | one.setRoleType(Integer.parseInt(houseAndHoldExcel.getRoleType())); |
| | | } |
| | | // 与角色关系 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getRelationship())) { |
| | | one.setRelationship(Integer.parseInt(houseAndHoldExcel.getRelationship())); |
| | |
| | | if (!Strings.isBlank(houseAndHoldExcel.getGender())) { |
| | | one.setGender(Short.parseShort(houseAndHoldExcel.getGender())); |
| | | } |
| | | one.setIdCard(houseAndHoldExcel.getIdCard()); |
| | | // 居民身份证 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getIdCard())) { |
| | | if (IdcardUtil.isValidCard(houseAndHoldExcel.getIdCard())) { |
| | | // 身份证类型为居民身份证 |
| | | one.setCardType(111); |
| | | one.setIdCard(houseAndHoldExcel.getIdCard()); |
| | | }else { |
| | | one.setIdCard(houseAndHoldExcel.getIdCard()); |
| | | } |
| | | } |
| | | // 党员 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getPartyEmber())) { |
| | | one.setPartyEmber(Integer.parseInt(houseAndHoldExcel.getPartyEmber())); |
| | | } |
| | | one.setHkmtPass(houseAndHoldExcel.getHkmtPass()); |
| | | one.setPassport(houseAndHoldExcel.getPassport()); |
| | | // 民族 |
| | | if (!Strings.isBlank(houseAndHoldExcel.getEthnicity())) { |
| | | one.setEthnicity(Integer.parseInt(houseAndHoldExcel.getEthnicity())); |
| | |
| | | } |
| | | one.setCardNumber(houseAndHoldExcel.getCardNumber()); |
| | | one.setOtherContact(houseAndHoldExcel.getOtherContact()); |
| | | if (Strings.isBlank(one.getHouseCode())) { |
| | | if (!Strings.isBlank(one.getHomeAdcode())) { |
| | | // 暂时不处理,导入数据目前都有house_code |
| | | String adCode = shiftResidentHomeAdcode(houseAndHoldExcel.getHomeAdcode()); |
| | | // 转换行政区code |
| | |
| | | // 新增 |
| | | boolean update = householdService.updateById(one); |
| | | if (update) { |
| | | String labelId = houseAndHoldExcel.getLabelId(); |
| | | if (StringUtils.isBlank(labelId)) { |
| | | return; |
| | | } |
| | | String[] split = labelId.split(","); |
| | | IUserHouseLabelService bean = SpringUtils.getBean(IUserHouseLabelService.class); |
| | | ILabelService bean1 = SpringUtils.getBean(ILabelService.class); |
| | | for (String s : split) { |
| | | LabelEntity one1 = bean1.getOne(Wrappers.<LabelEntity>lambdaQuery().eq(LabelEntity::getLabelName, s)); |
| | | if (one1 != null) { |
| | | // 住户标签处理 |
| | | householdLabelHandle(houseAndHoldExcel,one); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 导入是网格数据绑定处理 |
| | | * @param houseAndHoldExcel |
| | | * @param houseEntity |
| | | */ |
| | | public void importGridHandle(HouseAndHoldExcel houseAndHoldExcel, HouseEntity houseEntity) { |
| | | if (!Strings.isBlank(houseAndHoldExcel.getCommunityName()) && |
| | | !Strings.isBlank(houseAndHoldExcel.getGridName())){ |
| | | // 查询对应的网格信息 |
| | | GridEntity gridEntity = gridService.getGridInfoByParam(houseAndHoldExcel.getCommunityName(),houseAndHoldExcel.getGridName()); |
| | | if (null!=gridEntity){ |
| | | // 设置场所范围 |
| | | houseEntity.setGridId(gridEntity.getId()); |
| | | houseEntity.setGridCode(gridEntity.getGridCode()); |
| | | // 更新网格范围绑定 |
| | | GridRangeEntity gridRangeEntity = new GridRangeEntity(); |
| | | gridRangeEntity.setGridId(gridEntity.getId()); |
| | | gridRangeEntity.setGridCode(gridEntity.getGridCode()); |
| | | gridRangeEntity.setHouseCode(houseEntity.getHouseCode()); |
| | | UpdateWrapper<GridRangeEntity> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.eq("house_code",houseEntity.getHouseCode()); |
| | | gridRangeService.update(gridRangeEntity,updateWrapper); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 住户标签处理 |
| | | * @param houseAndHoldExcel |
| | | * @param householdEntity |
| | | */ |
| | | public void householdLabelHandle(HouseAndHoldExcel houseAndHoldExcel, HouseholdEntity householdEntity) { |
| | | String labelId = houseAndHoldExcel.getLabelId(); |
| | | if (!StringUtils.isBlank(labelId)) { |
| | | String[] split = labelId.split(","); |
| | | IUserHouseLabelService bean = SpringUtils.getBean(IUserHouseLabelService.class); |
| | | ILabelService bean1 = SpringUtils.getBean(ILabelService.class); |
| | | for (String s : split) { |
| | | // 查询标签信息 |
| | | LabelEntity one1 = bean1.getOne(Wrappers.<LabelEntity>lambdaQuery().eq(LabelEntity::getLabelName, s)); |
| | | if (one1 != null) { |
| | | // 判断是否已存在关联关系,没有则新增 |
| | | QueryWrapper<UserHouseLabelEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("label_id",one1.getId()) |
| | | .eq("house_code",householdEntity.getHouseCode()) |
| | | .eq("household_id",householdEntity.getId()); |
| | | UserHouseLabelEntity houseLabelEntity = bean.getOne(wrapper); |
| | | if (null==houseLabelEntity) { |
| | | UserHouseLabelEntity userHouseLabelEntity = new UserHouseLabelEntity(); |
| | | userHouseLabelEntity.setLabelId(BigDecimal.valueOf(one1.getId()).longValue()); |
| | | userHouseLabelEntity.setHouseholdId(one.getId()); |
| | | userHouseLabelEntity.setLableType(1); |
| | | userHouseLabelEntity.setLabelName(s); |
| | | userHouseLabelEntity.setHouseholdId(householdEntity.getId()); |
| | | // 设置默认的绿色 |
| | | userHouseLabelEntity.setColor("green"); |
| | | userHouseLabelEntity.setLableType(1); |
| | | userHouseLabelEntity.setLabelName(s); |
| | | userHouseLabelEntity.setHouseCode(houseAndHoldExcel.getHouseCode()); |
| | | bean.save(userHouseLabelEntity); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 住户业主信息处理,将业主人员插入到用户表 |
| | | * |
| | | * @return |
| | | */ |
| | | public void userHandle(HouseholdEntity householdEntity) { |
| | | if (!Strings.isBlank(householdEntity.getPhoneNumber())) { |
| | | // 根据手机号查询对应账号和手机号的用户信息 |
| | | List<User> userList = userService.getUserListByPhoneOrAccount(householdEntity.getPhoneNumber()); |
| | | if (userList.size() > 0) { |
| | | User user = userList.get(0); |
| | | householdEntity.setAssociatedUserId(user.getId()); |
| | | // 更新 |
| | | householdService.updateById(householdEntity); |
| | | // 判断用户是否包含了居民角色,不包含则需更新 |
| | | if (!user.getRoleId().contains("1717429059648606209")) { |
| | | user.setRoleId(user.getRoleId() + ",1717429059648606209"); |
| | | //更新 |
| | | userService.updateById(user); |
| | | } |
| | | } else { |
| | | // 插入用户信息 |
| | | //如果用户不存在,则新增一个用户 |
| | | User newUser = new User(); |
| | | newUser.setAccount(householdEntity.getPhoneNumber()); |
| | | newUser.setPhone(householdEntity.getPhoneNumber()); |
| | | newUser.setName(householdEntity.getName()); |
| | | newUser.setRealName(householdEntity.getName()); |
| | | // 社区群众部门 |
| | | newUser.setDeptId("1727979636479037441"); |
| | | // 目前暂定居民角色, |
| | | newUser.setRoleId("1717429059648606209"); |
| | | //默认密码为 123456 |
| | | newUser.setPassword("123456"); |
| | | // 用户新增 |
| | | boolean submit = userService.submit(newUser); |
| | | // 更新绑定用户信息 |
| | | householdEntity.setAssociatedUserId(newUser.getId()); |
| | | // 更新 |
| | | householdService.updateById(householdEntity); |
| | | } |
| | | } |
| | | } |
| | |
| | | * |
| | | * @param householdEntity |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void saveOrUpdateUser(HouseholdEntity householdEntity) { |
| | | if (null != householdEntity.getPhoneNumber() && !householdEntity.getPhoneNumber().equals("")) { |
| | | //根据手机号查询库里的数据 |
| | | User userParams = new User(); |
| | | userParams.setPhone(householdEntity.getPhoneNumber()); |
| | | User user = userService.getOne(Condition.getQueryWrapper(userParams)); |
| | | if (null != user) { |
| | | List<User> list = userService.getUserListByPhoneOrAccount(householdEntity.getPhoneNumber()); |
| | | if (list.size()>0) { |
| | | User user = list.get(0); |
| | | //如果用户存在,则该用户id绑定住户 |
| | | householdEntity.setAssociatedUserId(user.getId()); |
| | | // 判断用户是否包含了居民角色,不包含则需更新 |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> labelStatistics(HouseVO house) { |
| | | List<String> regionChildCodesList = SysCache.getRegionChildCodesByDeptId(AuthUtil.getDeptId()); |
| | | Integer isAdministrator = AuthUtil.isAdministrator() == true ? 1 : 2; |
| | | return baseMapper.labelStatistics(house,regionChildCodesList,isAdministrator); |
| | | public List<Map<String, Object>> labelStatistics(HouseVO house) { |
| | | CommonParamSet commonParamSet = new CommonParamSet<>().invoke(HouseVO.class, house); |
| | | return baseMapper.labelStatistics(house, commonParamSet.getRegionChildCodesList(), commonParamSet.getIsAdministrator()); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> labelCommunityStatistics(HouseVO house) { |
| | | List<String> regionChildCodesList = SysCache.getRegionChildCodesByDeptId(AuthUtil.getDeptId()); |
| | | Integer isAdministrator = AuthUtil.isAdministrator() == true ? 1 : 2; |
| | | return baseMapper.labelCommunityStatistics(house,regionChildCodesList,isAdministrator); |
| | | CommonParamSet commonParamSet = new CommonParamSet<>().invoke(HouseVO.class, house); |
| | | List<Map<String, Object>> list = baseMapper.labelCommunityStatistics(house, commonParamSet.getRegionChildCodesList()); |
| | | for (Map<String, Object> map : list) { |
| | | List<LabelVO> code = baseMapper.getlabelCount(house, |
| | | commonParamSet.getRegionChildCodesList(), |
| | | commonParamSet.getIsAdministrator(), |
| | | map.get("code").toString()); |
| | | map.put("child",code); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 房屋网格处理 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Object houseGridHandle() { |
| | | // 查询未处理的数据 |
| | | List<HouseEntity> houseEntityList = baseMapper.getNotBindGridOrJwGridList(1); |
| | | // 遍历 |
| | | for (HouseEntity houseEntity : houseEntityList) { |
| | | String point = "'POINT(" + houseEntity.getLng() + " " + houseEntity.getLat() + ")'"; |
| | | List<GridEntity> gridEntityList = SpringUtils.getBean(IGridService.class).spatialAnalysis(point); |
| | | if (gridEntityList.size()>0){ |
| | | houseEntity.setGridCode(gridEntityList.get(0).getGridCode()); |
| | | houseEntity.setGridId(gridEntityList.get(0).getId()); |
| | | // 更新 |
| | | updateById(houseEntity); |
| | | } |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 房屋警格处理 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Object houseJwGridHandle() { |
| | | // 查询未处理的数据 |
| | | List<HouseEntity> houseEntityList = baseMapper.getNotBindGridOrJwGridList(2); |
| | | // 遍历 |
| | | for (HouseEntity houseEntity : houseEntityList) { |
| | | String point = "'POINT(" + houseEntity.getLng() + " " + houseEntity.getLat() + ")'"; |
| | | List<PoliceAffairsGridEntity> policeAffairsGridEntityList = SpringUtils.getBean(IPoliceAffairsGridService.class).spatialAnalysis(point); |
| | | if (policeAffairsGridEntityList.size()>0){ |
| | | houseEntity.setJwGridCode(policeAffairsGridEntityList.get(0).getJwGridCode()); |
| | | // 更新 |
| | | updateById(houseEntity); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 房屋画像统计-按房屋标签统计 |
| | | * @param house |
| | | * @return |
| | | */ |
| | | @Override |
| | | 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()); |
| | | // 返回 |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 查询对应的社区编号 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public String getCommunityCode(Long id) { |
| | | return baseMapper.getCommunityCode(id); |
| | | } |
| | | |
| | | /** |
| | | * 查询所有房屋总数 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public int getAllListTotal() { |
| | | return baseMapper.getAllListTotal(); |
| | | } |
| | | |
| | | /** |
| | | * 查询所有的房屋 |
| | | * @param i |
| | | * @param size |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<HouseVO> getAllList(int i, int size) { |
| | | return baseMapper.getAllList(i,size); |
| | | } |
| | | |
| | | /** |
| | | * 房屋标签初始化处置-根据有租客的,初始成出租,有业主没租客的初始化成自主,业主都没的就是闲置 |
| | | * @param house |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean initHouseLabelBind(HouseVO house) { |
| | | IUserHouseLabelService userHouseLabelService = SpringUtils.getBean(IUserHouseLabelService.class); |
| | | // 查询无房屋状态的房屋数量 |
| | | int total = baseMapper.getNotBindLabelHouseNum(house); |
| | | int size = 1000; |
| | | int num = total / size; |
| | | for (int i = 1; i <= num + 1; i++) { |
| | | // 查询无房屋状态的房屋列表集合 |
| | | List<HouseVO> houseVOList = baseMapper.getNotBindLabelHouseList((i - 1) * size, size); |
| | | for (HouseVO houseEntity : houseVOList) { |
| | | //处理状态 |
| | | UserHouseLabelEntity houseLabelEntity = new UserHouseLabelEntity(); |
| | | houseLabelEntity.setHouseCode(houseEntity.getHouseCode()); |
| | | houseLabelEntity.setLableType(2); |
| | | houseLabelEntity.setCreateTime(new Date()); |
| | | if (houseEntity.getStatus()==1) { |
| | | // 闲置 |
| | | houseLabelEntity.setColor("green"); |
| | | houseLabelEntity.setLabelName("闲置"); |
| | | houseLabelEntity.setLabelId(1037L); |
| | | } |
| | | if (houseEntity.getStatus()==2) { |
| | | // 自住 |
| | | houseLabelEntity.setColor("blue"); |
| | | houseLabelEntity.setLabelName("自住"); |
| | | houseLabelEntity.setLabelId(1038L); |
| | | } |
| | | if (houseEntity.getStatus()==3) { |
| | | // 出租 |
| | | houseLabelEntity.setColor("yellow"); |
| | | houseLabelEntity.setLabelName("出租"); |
| | | houseLabelEntity.setLabelId(1039L); |
| | | } |
| | | // 查询当前房屋是否已有,有则更新,无则新增 |
| | | QueryWrapper<UserHouseLabelEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("house_code",houseEntity.getHouseCode()) |
| | | .eq("lable_type",2); |
| | | UserHouseLabelEntity userHouseLabelEntity = userHouseLabelService.getOne(wrapper); |
| | | if (null!=userHouseLabelEntity){ |
| | | // 更新 |
| | | houseLabelEntity.setId(userHouseLabelEntity.getId()); |
| | | userHouseLabelService.updateById(houseLabelEntity); |
| | | }else { |
| | | // 新增 |
| | | userHouseLabelService.save(houseLabelEntity); |
| | | } |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | } |