| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import liquibase.repackaged.org.apache.commons.lang3.StringUtils; |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.springblade.common.cache.SysCache; |
| | | import org.springblade.common.node.TreeIntegerNode; |
| | | import org.springblade.common.node.TreeStringNode; |
| | | import org.springblade.common.param.CommonParamSet; |
| | | import org.springblade.common.utils.NodeTreeUtil; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | |
| | | import org.springblade.modules.house.vo.HouseholdVO; |
| | | import org.springblade.modules.place.entity.PlaceEntity; |
| | | import org.springblade.modules.place.service.IPlaceService; |
| | | import org.springblade.modules.system.entity.Dept; |
| | | import org.springblade.modules.system.entity.DictBiz; |
| | | import org.springblade.modules.system.entity.User; |
| | | import org.springblade.modules.system.service.IDeptService; |
| | | import org.springblade.modules.system.service.IDictBizService; |
| | | import org.springblade.modules.system.service.IUserService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | public IPage<HouseholdVO> selectHouseholdPage(IPage<HouseholdVO> page, HouseholdVO household) { |
| | | StopWatch stopWatch = new StopWatch(); |
| | | stopWatch.start(); |
| | | List<String> regionChildCodesList = SysCache.getRegionChildCodesByDeptId(AuthUtil.getDeptId()); |
| | | Integer isAdministrator = AuthUtil.isAdministrator()==true?1:2; |
| | | List<HouseholdVO> householdVOS = baseMapper.selectHouseholdPage(page, household,regionChildCodesList,isAdministrator); |
| | | CommonParamSet commonParamSet = new CommonParamSet().invoke(HouseholdVO.class, household); |
| | | |
| | | // List<String> regionChildCodesList = SysCache.getRegionChildCodesByDeptId(AuthUtil.getDeptId()); |
| | | // Integer isAdministrator = AuthUtil.isAdministrator()==true?1:2; |
| | | |
| | | List<HouseholdVO> householdVOS = baseMapper.selectHouseholdPage(page, household, commonParamSet.getIsAdministrator(), |
| | | commonParamSet.getRegionChildCodesList(), commonParamSet.getGridCodeList()); |
| | | stopWatch.stop(); |
| | | System.out.println("selectHouseholdPage:" + stopWatch.getTotalTimeMillis()); |
| | | // System.out.println("selectHouseholdPage:" + stopWatch.getTotalTimeMillis()); |
| | | return page.setRecords(householdVOS); |
| | | } |
| | | |
| | | /** |
| | | * 查询房屋集合信息 |
| | | * |
| | | * @param userId |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询房屋人员情况 |
| | | * |
| | | * @param code |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 处理字典 |
| | | * |
| | | * @param householdList |
| | | */ |
| | | private void handleDictBiz(List<HouseholdVO> householdList) { |
| | | if (householdList.size()>0){ |
| | | if (householdList.size() > 0) { |
| | | // 查询角色关系字典 |
| | | List<DictBiz> dictBizList = dictBizService.getList("roleRelation",null); |
| | | if (dictBizList.size()>0) { |
| | | List<DictBiz> dictBizList = dictBizService.getList("roleRelation", null); |
| | | if (dictBizList.size() > 0) { |
| | | // 遍历 |
| | | for (HouseholdVO householdVO : householdList) { |
| | | if (null != householdVO.getRelationship()) { |
| | |
| | | |
| | | /** |
| | | * 住户 自定义新增或修改 |
| | | * |
| | | * @param household |
| | | * @return |
| | | */ |
| | |
| | | boolean flag = false; |
| | | household.setUpdateTime(new Date()); |
| | | household.setUpdateUser(AuthUtil.getUserId()); |
| | | if (!Strings.isBlank(household.getRoleName()) && household.getRoleName().equals("居民")){ |
| | | if (!Strings.isBlank(household.getRoleName()) && household.getRoleName().equals("居民")) { |
| | | // 待审核 |
| | | household.setConfirmFlag(0); |
| | | } |
| | |
| | | |
| | | /** |
| | | * 更新用户标签信息 |
| | | * |
| | | * @param household |
| | | */ |
| | | public void updateUserLabelInfo(HouseholdVO household) { |
| | | if (household.getHouseholdLabelList().size()>0){ |
| | | if (household.getHouseholdLabelList().size() > 0) { |
| | | List<HouseholdLabelVO> householdLabelList = household.getHouseholdLabelList(); |
| | | for (HouseholdLabelVO householdLabelVO : householdLabelList) { |
| | | if (!Strings.isBlank(household.getHouseCode())) { |
| | |
| | | |
| | | /** |
| | | * 更新用户信息 |
| | | * |
| | | * @param household |
| | | */ |
| | | public void updateUserInfo(HouseholdEntity household) { |
| | | // 判断用户是否为业主,如果是业主,则新增 |
| | | if (null!=household.getRelationship() && household.getRelationship()==1){ |
| | | if (null != household.getRelationship() && household.getRelationship() == 1) { |
| | | // 如果为业主 |
| | | // 新增用户 |
| | | bindUserHandle(household); |
| | |
| | | |
| | | /** |
| | | * 业主和用户绑定 |
| | | * |
| | | * @param |
| | | */ |
| | | public User bindUserHandle(HouseholdEntity householdEntity) { |
| | | User newUser = new User(); |
| | | if (null!=householdEntity.getPhoneNumber() && !householdEntity.getPhoneNumber().equals("")) { |
| | | 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) { |
| | | if (null == user) { |
| | | User userParams1 = new User(); |
| | | userParams1.setAccount(householdEntity.getPhoneNumber()); |
| | | userParams1.setIsDeleted(0); |
| | | user = userService.getOne(Condition.getQueryWrapper(userParams1)); |
| | | } |
| | | if (null!=user) { |
| | | if (null != user) { |
| | | //如果用户存在,则该用户id绑定场所 |
| | | householdEntity.setAssociatedUserId(user.getId()); |
| | | //更新住户信息 |
| | | updateById(householdEntity); |
| | | newUser = user; |
| | | // 判断用户是否包含了居民角色,不包含则需更新 |
| | | if (!user.getRoleId().contains("1717429059648606209")){ |
| | | if (!user.getRoleId().contains("1717429059648606209")) { |
| | | user.setRoleId(user.getRoleId() + ",1717429059648606209"); |
| | | //更新 |
| | | userService.updateById(user); |
| | |
| | | |
| | | /** |
| | | * 住户 自定义查询详情 |
| | | * |
| | | * @param household |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 住户审核统计 |
| | | * |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Integer statistics(Long userId,String neiCode) { |
| | | return baseMapper.statistics(userId,neiCode); |
| | | public Integer statistics(Long userId, String neiCode,Integer confirmFlag) { |
| | | HouseholdVO householdVO = new HouseholdVO(); |
| | | householdVO.setConfirmFlag(confirmFlag); |
| | | householdVO.setNeiCode(neiCode); |
| | | CommonParamSet commonParamSet = new CommonParamSet().invoke(HouseholdVO.class, householdVO); |
| | | |
| | | return baseMapper.statistics(householdVO,commonParamSet.getIsAdministrator(), |
| | | commonParamSet.getRegionChildCodesList(), commonParamSet.getGridCodeList()); |
| | | } |
| | | |
| | | /** |
| | | * 住户对应物业,网格,公安负责人查询 |
| | | * |
| | | * @param household |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 住户业主信息处理,将业主人员插入到用户表 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | |
| | | for (HouseholdEntity householdEntity : householdEntityList) { |
| | | // 根据手机号查询对应账号和手机号的用户信息 |
| | | List<User> userList = userService.getUserListByPhoneOrAccount(householdEntity.getPhoneNumber()); |
| | | if (userList.size()>0){ |
| | | if (userList.size() > 0) { |
| | | User user = userList.get(0); |
| | | householdEntity.setAssociatedUserId(user.getId()); |
| | | // 更新 |
| | | updateById(householdEntity); |
| | | // 判断用户是否包含了居民角色,不包含则需更新 |
| | | if (!user.getRoleId().contains("1717429059648606209")){ |
| | | if (!user.getRoleId().contains("1717429059648606209")) { |
| | | user.setRoleId(user.getRoleId() + ",1717429059648606209"); |
| | | //更新 |
| | | userService.updateById(user); |
| | | } |
| | | }else { |
| | | } else { |
| | | // 插入用户信息 |
| | | //如果用户不存在,则新增一个用户 |
| | | User newUser = new User(); |
| | |
| | | |
| | | /** |
| | | * 同时删除对应的用户信息 |
| | | * |
| | | * @param idList |
| | | */ |
| | | public void removeHouseholdUser(List<Long> idList) { |
| | | for (Long id : idList) { |
| | | HouseholdEntity householdEntity = getById(id); |
| | | // 如果是业主 |
| | | if (householdEntity.getRelationship()==1){ |
| | | if (householdEntity.getRelationship() == 1) { |
| | | // 查询对应的用户 |
| | | User user = userService.getById(householdEntity.getAssociatedUserId()); |
| | | // 判断是否还绑定其他的房屋,如果有,则不操作用户 |
| | | QueryWrapper<HouseholdEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("is_deleted",0).eq("associated_user_id",user.getId()); |
| | | wrapper.eq("is_deleted", 0).eq("associated_user_id", user.getId()); |
| | | List<HouseholdEntity> householdEntityList = list(wrapper); |
| | | if (householdEntityList.size()==1){ |
| | | if (householdEntityList.size() == 1) { |
| | | // 判断角色 |
| | | if (!Strings.isBlank(user.getRoleId())){ |
| | | if (!Strings.isBlank(user.getRoleId())) { |
| | | List<String> stringList = Arrays.asList(user.getRoleId().split(",")); |
| | | // 查询场所 |
| | | QueryWrapper<PlaceEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("is_deleted",0).eq("principal_user_id",user.getId()); |
| | | queryWrapper.eq("is_deleted", 0).eq("principal_user_id", user.getId()); |
| | | List<PlaceEntity> placeEntityList = placeService.list(queryWrapper); |
| | | // 即没有房屋和场所了就删除对应的居民角色 |
| | | if (placeEntityList.size()==0) { |
| | | if (placeEntityList.size() == 0) { |
| | | // 查看当前用户的角色是否只有一个 |
| | | if (stringList.size() > 1) { |
| | | // 查询是否对应有场所负责人,如果有则不删除,如果没有则删除对应的角色 |
| | |
| | | |
| | | /** |
| | | * 删除住户标签信息 |
| | | * |
| | | * @param idList |
| | | */ |
| | | public void removeHouseholdLabel(List<Long> idList) { |
| | | for (Long id : idList) { |
| | | QueryWrapper<UserHouseLabelEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("household_id",id); |
| | | wrapper.eq("household_id", id); |
| | | userHouseLabelService.remove(wrapper); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<HouseholdVO> getAllHouseHold(HouseholdVO household) { |
| | | return baseMapper.getAllHouseHold(household); |
| | | return baseMapper.getAllHouseHold(household); |
| | | } |
| | | |
| | | /** |
| | | * 住户列表查询 |
| | | * |
| | | * @param household |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据人员标签编号集合查询对应的住户(按颜色区分近多少天没有发过任务的住户) |
| | | * |
| | | * @param list |
| | | * @return |
| | | */ |
| | |
| | | |
| | | private void recursion(TreeIntegerNode node) { |
| | | if (node.getChildren() != null && node.getChildren().size() > 0) { |
| | | if(node.getId().equals(1030)){ |
| | | if (node.getId().equals(1030)) { |
| | | int sum = node.getChildren().stream().mapToInt(TreeIntegerNode::getCount).sum(); |
| | | node.setCount(sum); |
| | | } |
| | | if(node.getId().equals(1031)){ |
| | | if (node.getId().equals(1031)) { |
| | | int sum = node.getChildren().stream().mapToInt(TreeIntegerNode::getCount).sum(); |
| | | node.setCount(sum); |
| | | } |