| | |
| | | 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.utils.NodeTreeUtil; |
| | | 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.grid.service.IGridService; |
| | | import org.springblade.modules.house.entity.HouseholdEntity; |
| | | import org.springblade.modules.house.entity.UserHouseLabelEntity; |
| | | import org.springblade.modules.house.excel.HouseHoldExcel; |
| | |
| | | private IUserService userService; |
| | | |
| | | @Autowired |
| | | private IDeptService deptService; |
| | | |
| | | @Autowired |
| | | private IPlaceService placeService; |
| | | |
| | | @Override |
| | | public IPage<HouseholdVO> selectHouseholdPage(IPage<HouseholdVO> page, HouseholdVO household) { |
| | | StopWatch stopWatch = new StopWatch(); |
| | | stopWatch.start(); |
| | | Dept dept = deptService.getById(AuthUtil.getDeptId()); |
| | | if (null!=dept){ |
| | | household.setRegionCode(dept.getRegionCode()); |
| | | } |
| | | List<HouseholdVO> householdVOS = baseMapper.selectHouseholdPage(page, household); |
| | | List<String> regionChildCodesList = SysCache.getRegionChildCodesByDeptId(AuthUtil.getDeptId()); |
| | | Integer isAdministrator = AuthUtil.isAdministrator()==true?1:2; |
| | | List<HouseholdVO> householdVOS = baseMapper.selectHouseholdPage(page, household,regionChildCodesList,isAdministrator); |
| | | stopWatch.stop(); |
| | | System.out.println("selectHouseholdPage:" + stopWatch.getTotalTimeMillis()); |
| | | return page.setRecords(householdVOS); |
| | |
| | | boolean flag = false; |
| | | household.setUpdateTime(new Date()); |
| | | household.setUpdateUser(AuthUtil.getUserId()); |
| | | if (!Strings.isBlank(household.getRoleName()) && household.getRoleName().equals("居民")){ |
| | | // 待审核 |
| | | household.setConfirmFlag(0); |
| | | } |
| | | if (null != household.getId()) { |
| | | // 更新 |
| | | flag = updateById(household); |
| | |
| | | if (householdEntity.getRelationship()==1){ |
| | | // 查询对应的用户 |
| | | User user = userService.getById(householdEntity.getAssociatedUserId()); |
| | | // 判断角色 |
| | | 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()); |
| | | List<PlaceEntity> placeEntityList = placeService.list(queryWrapper); |
| | | if (stringList.size()>1){ |
| | | // 查询是否对应有场所负责人,如果有则不删除,如果没有则删除对应的角色 |
| | | List<String> arrayList = new ArrayList<>(); |
| | | if (placeEntityList.size()==0){ |
| | | for (String roleId : stringList) { |
| | | if (!roleId.equals("1717429059648606209")){ |
| | | arrayList.add(roleId); |
| | | // 判断是否还绑定其他的房屋,如果有,则不操作用户 |
| | | QueryWrapper<HouseholdEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("is_deleted",0).eq("associated_user_id",user.getId()); |
| | | List<HouseholdEntity> householdEntityList = list(wrapper); |
| | | if (householdEntityList.size()==1){ |
| | | // 判断角色 |
| | | 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()); |
| | | List<PlaceEntity> placeEntityList = placeService.list(queryWrapper); |
| | | // 即没有房屋和场所了就删除对应的居民角色 |
| | | if (placeEntityList.size()==0) { |
| | | // 查看当前用户的角色是否只有一个 |
| | | if (stringList.size() > 1) { |
| | | // 查询是否对应有场所负责人,如果有则不删除,如果没有则删除对应的角色 |
| | | List<String> arrayList = new ArrayList<>(); |
| | | for (String roleId : stringList) { |
| | | if (!roleId.equals("1717429059648606209")) { |
| | | arrayList.add(roleId); |
| | | } |
| | | } |
| | | user.setRoleId(StringUtils.join(arrayList, ",")); |
| | | // 更新用户 |
| | | userService.updateById(user); |
| | | } else { |
| | | // 删除当前用户 |
| | | userService.removeById(user.getId()); |
| | | } |
| | | } |
| | | user.setRoleId(StringUtils.join(arrayList, ",")); |
| | | // 更新用户 |
| | | userService.updateById(user); |
| | | }else { |
| | | // 查询是否对应有场所负责人,如果有则不删除,如果没有则删除对应的用户 |
| | | if (placeEntityList.size()==0){ |
| | | userService.removeById(user.getId()); |
| | | } |
| | | } |
| | | } |
| | |
| | | List<HouseholdVO> householdVOS = baseMapper.selectHouseholdList(household); |
| | | // 遍历 |
| | | for (HouseholdVO householdVO : householdVOS) { |
| | | if (householdVO.getHouseholdLabelList().size()>0){ |
| | | if (householdVO.getHouseholdLabelList().size() > 0) { |
| | | List<String> labelNameList = householdVO.getHouseholdLabelList().stream().map(householdLabelVO -> householdLabelVO.getLabelName()) |
| | | .collect(Collectors.toList()); |
| | | householdVO.setLabelName(String.join(",",labelNameList)); |
| | | householdVO.setLabelName(String.join(",", labelNameList)); |
| | | } |
| | | } |
| | | // 返回 |
| | | return householdVOS; |
| | | return householdVOS; |
| | | } |
| | | |
| | | @Override |
| | | public IPage<HouseholdVO> getKeynotePersonnelPage(IPage<HouseholdVO> page, HouseholdVO household) { |
| | | // StopWatch stopWatch = new StopWatch(); |
| | | // stopWatch.start(); |
| | | // Dept dept = deptService.getById(AuthUtil.getDeptId()); |
| | | // if (null!=dept){ |
| | | // household.setRegionCode(dept.getRegionCode()); |
| | | // } |
| | | List<HouseholdVO> householdVOS = baseMapper.getKeynotePersonnelPage(page, household); |
| | | // stopWatch.stop(); |
| | | // System.out.println("selectHouseholdPage:" + stopWatch.getTotalTimeMillis()); |
| | | return page.setRecords(householdVOS); |
| | | } |
| | | |
| | | /** |
| | | * 根据人员标签编号集合查询对应的住户(按颜色区分近多少天没有发过任务的住户) |
| | | * @param list |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<HouseholdVO> getHouseholdListByParam(List<Integer> list) { |
| | | return baseMapper.getHouseholdListByParam(list); |
| | | } |
| | | |
| | | @Override |
| | | public List<TreeIntegerNode> getlabelStatistics(HouseholdVO household) { |
| | | Map<Integer, TreeIntegerNode> labelTreeList = baseMapper.getlabelStatistics(household); |
| | | List<TreeIntegerNode> nodeTree = NodeTreeUtil.getNodeTree(labelTreeList); |
| | | nodeTree.forEach(node -> recursion(node)); |
| | | return nodeTree; |
| | | } |
| | | |
| | | private void recursion(TreeIntegerNode node) { |
| | | if (node.getChildren() != null && node.getChildren().size() > 0) { |
| | | node.getChildren().forEach(node2 -> recursion(node2)); |
| | | } else { |
| | | node.setChildren(null); |
| | | } |
| | | } |
| | | } |