| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.common.cache.SysCache; |
| | | import org.springblade.common.node.TreeStringNode; |
| | | import org.springblade.common.utils.SpringUtils; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | import org.springblade.modules.grid.entity.GridEntity; |
| | | import org.springblade.modules.grid.service.IGridService; |
| | | import org.springblade.modules.property.entity.PropertyCompanyEntity; |
| | | import org.springblade.modules.property.service.IPropertyCompanyService; |
| | | import org.springblade.modules.system.entity.Dept; |
| | | import org.springblade.modules.system.mapper.DeptMapper; |
| | | import org.springblade.modules.system.service.IDeptService; |
| | | import org.springblade.modules.system.service.IRegionService; |
| | | import org.springblade.modules.system.vo.DeptDetailVO; |
| | | import org.springblade.modules.system.vo.DeptVO; |
| | | import org.springblade.modules.system.wrapper.DeptWrapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | @Override |
| | | public List<DeptVO> tree(String tenantId) { |
| | | Long parentId = null; |
| | | Long id = null; |
| | | // 判断数据权限控制,非超管角色只可看到本级及以下数据 |
| | | // if (!AuthUtil.isAdministrator()) { |
| | | // Long deptId = Func.firstLong(AuthUtil.getDeptId()); |
| | | // Dept dept = SysCache.getDept(deptId); |
| | | // if (dept.getParentId() != 0) { |
| | | // parentId = dept.getParentId(); |
| | | // } |
| | | // List<DeptVO> merge = ForestNodeMerger.merge(baseMapper.tree(tenantId, parentId)); |
| | | // List<DeptVO> copy = BeanUtil.copy(merge, DeptVO.class); |
| | | // copy = copy.stream().filter(item -> AuthUtil.getDeptId().contains(item.getId().toString())).collect(Collectors.toList()); |
| | | // return copy; |
| | | // } |
| | | |
| | | return ForestNodeMerger.merge(baseMapper.tree(tenantId, parentId)); |
| | | if (!AuthUtil.isAdmin()) { |
| | | id = Func.firstLong(AuthUtil.getDeptId()); |
| | | } |
| | | List<DeptVO> tree = baseMapper.tree(tenantId, id); |
| | | return ForestNodeMerger.merge(tree); |
| | | } |
| | | |
| | | @Override |
| | |
| | | // parentId = dept.getParentId(); |
| | | // } |
| | | // } |
| | | if (Func.toLong(parentId) == 0L && !AuthUtil.isAdministrator()) { |
| | | if (Func.toLong(parentId) == 0L && !AuthUtil.isAdmin()) { |
| | | Long deptId = Func.firstLong(AuthUtil.getDeptId()); |
| | | Dept dept = SysCache.getDept(deptId); |
| | | if (dept.getParentId() != 0) { |
| | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 数据处理(区域网格编号绑定) |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Object dataRegionGridCodeBindHandle() { |
| | | // 查询网格对应的机构信息(包含父级机构名称) |
| | | List<DeptVO> deptVOS = baseMapper.getGridDeptAndParentList(); |
| | | //遍历处理 |
| | | for (DeptVO deptVO : deptVOS) { |
| | | GridEntity gridEntity = SpringUtils.getBean(IGridService.class).getGridByNames(deptVO.getDeptName(), deptVO.getParentName()); |
| | | if (null != gridEntity) { |
| | | deptVO.setRegionCode(gridEntity.getGridCode()); |
| | | // 更新 |
| | | updateById(deptVO); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |