| | |
| | | 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.logging.log4j.util.Strings; |
| | | import org.springblade.common.cache.SysCache; |
| | | import org.springblade.common.param.CommonParamSet; |
| | | import org.springblade.common.utils.SpringUtils; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.modules.grid.service.IGridService; |
| | |
| | | import org.springblade.modules.house.vo.HouseRentalTenantVO; |
| | | import org.springblade.modules.house.vo.HouseRentalVO; |
| | | import org.springblade.modules.house.vo.HouseholdVO; |
| | | import org.springblade.modules.system.entity.Dept; |
| | | import org.springblade.modules.system.entity.User; |
| | | import org.springblade.modules.system.service.IDeptService; |
| | | import org.springblade.modules.system.service.IUserService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | /** |
| | | * 自定义分页查询 |
| | | * |
| | | * @param page |
| | | * @param houseRental |
| | | * @return |
| | | */ |
| | | @Override |
| | | public IPage<HouseRentalTenantVO> selectHouseRentalPage(IPage<HouseRentalTenantVO> page, HouseRentalTenantVO houseRental) { |
| | | List<String> list = new ArrayList<>(); |
| | | if (null!=houseRental.getRoleName() && !houseRental.getRoleName().equals("")){ |
| | | if (houseRental.getRoleName().equals("网格员")){ |
| | | // 查询对应的房屋地址code |
| | | list = gridService.getAddressCodeListByUserId(AuthUtil.getUserId()); |
| | | } |
| | | } |
| | | if (null!=houseRental.getAuditStatus()){ |
| | | if (houseRental.getAuditStatus()==0){ |
| | | if (null != houseRental.getAuditStatus()) { |
| | | if (houseRental.getAuditStatus() == 0) { |
| | | houseRental.setAuditStatus(2); |
| | | } |
| | | } |
| | | List<HouseRentalTenantVO> houseRentalTenantVOS = baseMapper.selectHouseRentalPage(page, houseRental, list); |
| | | CommonParamSet<Object> commonParamSet = new CommonParamSet<>().invoke(HouseRentalTenantVO.class, houseRental); |
| | | List<HouseRentalTenantVO> houseRentalTenantVOS = baseMapper.selectHouseRentalPage(page, houseRental, |
| | | commonParamSet.getGridCodeList(), |
| | | commonParamSet.getRegionChildCodesList(), |
| | | commonParamSet.getIsAdministrator()); |
| | | for (HouseRentalTenantVO houseRentalTenantVO : houseRentalTenantVOS) { |
| | | if(houseRentalTenantVO.getStatus().equals(1)){ |
| | | houseRentalTenantVO.setAuditStatus(30); |
| | | if (houseRentalTenantVO.getStatus().equals(1)) { |
| | | houseRentalTenantVO.setStatus(30); |
| | | } |
| | | if(houseRentalTenantVO.getStatus().equals(0) && houseRentalTenantVO.getAuditStatus().equals(0)){ |
| | | houseRentalTenantVO.setAuditStatus(0); |
| | | if (houseRentalTenantVO.getStatus().equals(0) && houseRentalTenantVO.getAuditStatus().equals(0)) { |
| | | houseRentalTenantVO.setStatus(0); |
| | | } |
| | | if(houseRentalTenantVO.getStatus().equals(0) && houseRentalTenantVO.getAuditStatus().equals(1)){ |
| | | houseRentalTenantVO.setAuditStatus(1); |
| | | if (houseRentalTenantVO.getStatus().equals(0) && houseRentalTenantVO.getAuditStatus().equals(1)) { |
| | | houseRentalTenantVO.setStatus(1); |
| | | } |
| | | if(houseRentalTenantVO.getStatus().equals(0) && houseRentalTenantVO.getDldType().equals(3)){ |
| | | houseRentalTenantVO.setAuditStatus(20); |
| | | if (houseRentalTenantVO.getStatus().equals(0) && houseRentalTenantVO.getDldType().equals(3)) { |
| | | houseRentalTenantVO.setStatus(20); |
| | | } |
| | | if(houseRentalTenantVO.getStatus().equals(0) && houseRentalTenantVO.getDldType().equals(2)){ |
| | | houseRentalTenantVO.setAuditStatus(10); |
| | | if (houseRentalTenantVO.getStatus().equals(0) && houseRentalTenantVO.getDldType().equals(2)) { |
| | | houseRentalTenantVO.setStatus(10); |
| | | } |
| | | } |
| | | return page.setRecords(houseRentalTenantVOS); |
| | |
| | | |
| | | /** |
| | | * 查询房屋出租情况 |
| | | * |
| | | * @param code |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 自定义房屋出租新增 |
| | | * |
| | | * @param houseRentalVO |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean add(HouseRentalVO houseRentalVO) { |
| | | boolean flag = false; |
| | | houseRentalVO.setCreateUser(AuthUtil.getUserId()); |
| | | houseRentalVO.setCreateTime(new Date()); |
| | | houseRentalVO.setUpdateUser(AuthUtil.getUserId()); |
| | | houseRentalVO.setUpdateTime(new Date()); |
| | | //保存自身 |
| | | boolean save = save(houseRentalVO); |
| | | List<String> phoneList = new ArrayList<>(); |
| | | List<HouseholdEntity> householdEntityList = new ArrayList<>(); |
| | | houseRentalVO.getHouseholdVOList().forEach(e -> { |
| | | e.setHouseCode(houseRentalVO.getHouseCode()); |
| | | e.setHousingRentalId(houseRentalVO.getId()); |
| | | e.setRelationship(18); |
| | | e.setResidentialStatus(1); |
| | | e.setRoleType(2); |
| | | householdEntityList.add(e); |
| | | phoneList.add(e.getPhoneNumber()); |
| | | }); |
| | | try { |
| | | // 查询租户是否网格员身份的,给网格员设置居民角色 |
| | | IUserService bean = SpringUtils.getBean(IUserService.class); |
| | | String str = "1717429261910528001"; |
| | | List<User> list = bean.list(Wrappers.<User>lambdaQuery() |
| | | .in(User::getPhone, phoneList) |
| | | .like(User::getRoleId, str)); |
| | | for (User user : list) { |
| | | boolean contains = user.getRoleId().contains("1717429059648606209"); |
| | | if (contains) { |
| | | continue; |
| | | } |
| | | user.setRoleId(user.getRoleId() + ",1717429059648606209"); |
| | | } |
| | | bean.updateBatchById(list); |
| | | } catch (Exception e) { |
| | | log.error("保存用户角色为居民:", e); |
| | | // 网格员新增默认是审核通过 |
| | | houseRentalVO.setAuditStatus(1); |
| | | // 获取请求头中的角色别名 |
| | | String roleName = SpringUtils.getRequestParam("roleName"); |
| | | // 居民 |
| | | if (!Strings.isBlank(roleName) && roleName.equals("inhabitant")) { |
| | | // 待审核 |
| | | houseRentalVO.setAuditStatus(0); |
| | | } |
| | | boolean saveBatch = iHouseholdService.saveBatch(householdEntityList); |
| | | //保存自身 |
| | | flag = save(houseRentalVO); |
| | | //保存到住户 |
| | | flag = saveHousehold(houseRentalVO, flag); |
| | | return flag; |
| | | } |
| | | |
| | | return save && saveBatch; |
| | | /** |
| | | * 保存租户信息 |
| | | * |
| | | * @param houseRentalVO |
| | | * @param flag |
| | | * @return |
| | | */ |
| | | public boolean saveHousehold(HouseRentalVO houseRentalVO, boolean flag) { |
| | | if (flag && houseRentalVO.getHouseholdVOList().size() > 0) { |
| | | List<String> phoneList = new ArrayList<>(); |
| | | List<HouseholdEntity> householdEntityList = new ArrayList<>(); |
| | | houseRentalVO.getHouseholdVOList().forEach(e -> { |
| | | e.setHouseCode(houseRentalVO.getHouseCode()); |
| | | e.setHousingRentalId(houseRentalVO.getId()); |
| | | e.setRelationship(18); |
| | | e.setResidentialStatus(1); |
| | | e.setRoleType(2); |
| | | householdEntityList.add(e); |
| | | phoneList.add(e.getPhoneNumber()); |
| | | }); |
| | | try { |
| | | // 查询租户是否网格员身份的,给网格员设置居民角色 |
| | | IUserService bean = SpringUtils.getBean(IUserService.class); |
| | | String str = "1717429261910528001"; |
| | | List<User> list = bean.list(Wrappers.<User>lambdaQuery() |
| | | .in(User::getPhone, phoneList) |
| | | .like(User::getRoleId, str)); |
| | | for (User user : list) { |
| | | boolean contains = user.getRoleId().contains("1717429059648606209"); |
| | | if (contains) { |
| | | continue; |
| | | } |
| | | user.setRoleId(user.getRoleId() + ",1717429059648606209"); |
| | | } |
| | | bean.updateBatchById(list); |
| | | } catch (Exception e) { |
| | | log.error("保存用户角色为居民:", e); |
| | | } |
| | | flag = iHouseholdService.saveBatch(householdEntityList); |
| | | } |
| | | return flag; |
| | | } |
| | | |
| | | /** |
| | | * 出租屋 自定义删除 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | boolean update = iHouseholdService.update(Wrappers.<HouseholdEntity>lambdaUpdate() |
| | | .set(HouseholdEntity::getIsDeleted, 1) |
| | | .eq(HouseholdEntity::getHousingRentalId, id)); |
| | | if (update) { |
| | | return true && b; |
| | | } |
| | | return false; |
| | | // 返回 |
| | | return b; |
| | | } |
| | | |
| | | /** |
| | | * 出租屋 自定义修改 |
| | | * |
| | | * @param houseRental |
| | | * @return |
| | | */ |
| | |
| | | e.getId()).collect(Collectors.toList()).contains(vo.getId())).collect(Collectors.toList()); |
| | | |
| | | // 批量新增 |
| | | if (addList.size()>0) { |
| | | if (addList.size() > 0) { |
| | | addFlag = iHouseholdService.saveBatch(addList); |
| | | } |
| | | // 批量修改 |
| | |
| | | |
| | | /** |
| | | * 获取统计数据 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Object getStatistics(HouseRentalTenantVO houseRental) { |
| | | List<String> list = new ArrayList<>(); |
| | | if (null!=houseRental.getRoleName() && !houseRental.getRoleName().equals("")){ |
| | | if (houseRental.getRoleName().equals("网格员")){ |
| | | if (null != houseRental.getRoleName() && !houseRental.getRoleName().equals("")) { |
| | | if (houseRental.getRoleName().equals("网格员")) { |
| | | // 查询对应的房屋地址code |
| | | list = gridService.getAddressCodeListByUserId(AuthUtil.getUserId()); |
| | | } |
| | | } |
| | | // 查询 |
| | | List<HouseRentalStatistics> statistics = baseMapper.getStatistics(houseRental,list); |
| | | List<HouseRentalStatistics> statistics = baseMapper.getStatistics(houseRental, list); |
| | | // 返回 |
| | | return statistics; |
| | | } |
| | | |
| | | /** |
| | | * 出租屋 确认 |
| | | * |
| | | * @param houseRental |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 导出租赁信息 |
| | | * |
| | | * @param houseRentalVO |
| | | * @return |
| | | */ |
| | |
| | | |
| | | @Override |
| | | public Integer getStatisticsCount(HouseRentalTenantVO houseRental) { |
| | | return baseMapper.getStatisticsCount(AuthUtil.getUserId()); |
| | | CommonParamSet<Object> commonParamSet = new CommonParamSet<>().invoke(HouseRentalTenantVO.class, houseRental); |
| | | return baseMapper.getStatisticsCount(houseRental, commonParamSet.getGridCodeList(), |
| | | commonParamSet.getRegionChildCodesList(), commonParamSet.getIsAdministrator()); |
| | | } |
| | | } |