| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | 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.node.TreeStringNode; |
| | | import org.springblade.common.utils.IdUtils; |
| | |
| | | import org.springblade.modules.grid.service.IGridService; |
| | | import org.springblade.modules.grid.service.IGridmanService; |
| | | import org.springblade.modules.grid.vo.GridVO; |
| | | import org.springblade.modules.house.entity.HouseholdEntity; |
| | | import org.springblade.modules.house.entity.UserHouseLabelEntity; |
| | | import org.springblade.modules.house.service.IHouseholdService; |
| | | import org.springblade.modules.place.entity.*; |
| | | import org.springblade.modules.place.excel.PlaceAndRelExcel; |
| | | import org.springblade.modules.place.excel.PlaceExcel; |
| | |
| | | |
| | | @Autowired |
| | | private GridMapper gridMapper; |
| | | |
| | | @Autowired |
| | | private IHouseholdService householdService; |
| | | |
| | | /** |
| | | * 自定义列表查询 |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean removePlace(List<Long> longs) { |
| | | // 删除场所负责人对应的用户 |
| | | removeUser(longs); |
| | | // 删除 |
| | | boolean removeByIds = removeByIds(longs); |
| | | // 删除对应的详情 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 删除场所负责人对应的用户 |
| | | * @param longs |
| | | */ |
| | | public void removeUser(List<Long> longs) { |
| | | // 遍历 |
| | | for (Long id : longs) { |
| | | PlaceEntity placeEntity = getById(id); |
| | | if (null!=placeEntity.getPrincipalUserId()){ |
| | | User user = userService.getById(placeEntity.getPrincipalUserId()); |
| | | // 查询场所判断是否还绑定有其他的场所 |
| | | QueryWrapper<PlaceEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("is_deleted",0).eq("principal_user_id",user.getId()); |
| | | List<PlaceEntity> placeEntityList = list(queryWrapper); |
| | | // 如果没有(1个 当前的还没有删除) |
| | | if (placeEntityList.size()==1){ |
| | | // 判断角色 |
| | | if (!Strings.isBlank(user.getRoleId())){ |
| | | // 判断是否还绑定其他的房屋,如果有,则不操作用户 |
| | | QueryWrapper<HouseholdEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("is_deleted",0).eq("associated_user_id",user.getId()); |
| | | List<HouseholdEntity> householdEntityList = householdService.list(wrapper); |
| | | // 即没有房屋和场所了就删除对应的居民角色 |
| | | if (householdEntityList.size()==0) { |
| | | List<String> stringList = Arrays.asList(user.getRoleId().split(",")); |
| | | // 查看当前用户的角色是否只有一个 |
| | | 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()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除场所对应的详情 |
| | | * @param longs |
| | | */ |