| | |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.TreeMap; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private long defaultParentId = 0L; |
| | | |
| | | /** |
| | | * @Description 获取区划树 |
| | | * @Description 获取机构树 |
| | | * @Author wh |
| | | * @Date 2023/7/11 11:15 |
| | | */ |
| | | @GetMapping("/select/tree_fin_tenant") |
| | | public ResponseValue listOrgRootTree() { |
| | | List<FinSysTenant> finSysTenantList = null; |
| | | FinSysTenantUser finSysTenantUser = new FinSysTenantUser(); |
| | | finSysTenantUser.setSysUserId(this.getCurrentUser().getId()); |
| | | List<FinSysTenantUser> finSysTenantUserList = finSysTenantUserService.select(finSysTenantUser); |
| | | FinSysTenantUser user = null; // 系统用户 |
| | | FinSysTenant finSysTenant1 = null; |
| | | List<TreeNode> treeRootList = null; // 数列表 |
| | | FinSysTenant finSysTenant = new FinSysTenant(); |
| | | // 获取地区父级 |
| | | finSysTenantList = this.finSysTenantService.queryForTree(); |
| | | // 根据登陆人id获取系统用户,如果有系统用户时 |
| | | if (finSysTenantUserList.size() > 0) { |
| | | // 获取当前用户信息 |
| | | user = finSysTenantUserList.get(0); |
| | | String tenantId = user.getTenantId(); |
| | | finSysTenant.setId(new Long(tenantId)); |
| | | // 查询区域 |
| | | List<FinSysTenant> select = finSysTenantService.select(finSysTenant); |
| | | if (select.size() > 0) { |
| | | finSysTenant1 = select.get(0); |
| | | } |
| | | // 系统用户 |
| | | FinSysTenantUser user = this.getSysInfo(); |
| | | if (Objects.isNull(user)) { |
| | | return ResponseValue.error("登录用户信息不存在"); |
| | | } |
| | | if (finSysTenant1 != null) { |
| | | if (finSysTenant1.getLv() != 1 && finSysTenant1.getParentId() != 0 && user != null) { |
| | | |
| | | // 获取所有机构 |
| | | List<FinSysTenant> finSysTenantList = this.finSysTenantService.queryForTree(); |
| | | // 根据登陆人id获取系统用户,如果有系统用户时 |
| | | // 获取当前用户信息 |
| | | String tenantId = user.getTenantId(); |
| | | FinSysTenant finSysTenant = new FinSysTenant(); |
| | | finSysTenant.setId(new Long(tenantId)); |
| | | // 主键是TempId |
| | | finSysTenant.setTempId(new Long(tenantId)); |
| | | // 查询当前用户的机构 |
| | | FinSysTenant userTenant = finSysTenantService.get(finSysTenant); |
| | | // 树列表 |
| | | List<TreeNode> treeRootList; |
| | | if (userTenant != null) { |
| | | if (userTenant.getLv() != 1 && userTenant.getParentId() != 0) { |
| | | rootMap.clear(); |
| | | this.childMap.clear(); |
| | | this.defaultParentId = new Long(user.getTenantId()); |
| | |
| | | return ResponseValue.error("登录用户信息不存在"); |
| | | } |
| | | String tenantId = sysInfo.getTenantId(); |
| | | FinSysTenant finSysTenant = new FinSysTenant(); |
| | | finSysTenant.setTempId(Long.valueOf(tenantId)); |
| | | FinSysTenant userTenant = this.finSysTenantService.get(finSysTenant); |
| | | FinSysTenant userTenant = finSysTenantService.selectById(Long.valueOf(tenantId)); |
| | | Long parentId = userTenant.getParentId(); |
| | | // 第一级 |
| | | if (parentId == 0) { |
| | | return ResponseValue.success(userTenant); |
| | | } else { |
| | | FinSysTenant param = new FinSysTenant(); |
| | | param.setTempId(Long.valueOf(parentId)); |
| | | FinSysTenant result = this.finSysTenantService.get(param); |
| | | FinSysTenant result = finSysTenantService.selectById(parentId); |
| | | return ResponseValue.success(result); |
| | | } |
| | | } |