Commit f163e3e5673d59d10045d2a21c8ab220801560d5

Authored by 王彪总
1 parent 1701fd6a

fix(user): 修复部门层级查找逻辑

- 当找不到parentId=100的部门时,返回当前部门id作为默认值
- 修改顶级部门查找逻辑,返回顶级部门ID而不是null
- 避免因返回null导致的空指针异常问题
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/inspectionplan/InspectionPlanController.java
@@ -130,7 +130,11 @@ public class InspectionPlanController { @@ -130,7 +130,11 @@ public class InspectionPlanController {
130 if(permissionApi.hasAnyRoles(loginUserId, "super_admin")){ 130 if(permissionApi.hasAnyRoles(loginUserId, "super_admin")){
131 pageReqVO.setCompanyId( null); 131 pageReqVO.setCompanyId( null);
132 }else{ 132 }else{
133 - pageReqVO.setCompanyId(SecurityFrameworkUtils.getCompanyId()); 133 + Long companyId = SecurityFrameworkUtils.getCompanyId();
  134 + if(null == companyId || companyId == 0L || companyId == 100L){
  135 + companyId = null;
  136 + }
  137 + pageReqVO.setCompanyId(companyId);
134 } 138 }
135 } 139 }
136 PageResult<InspectionPlanRespVO> pageResult = inspectionPlanService.getInspectionPlanPage(pageReqVO); 140 PageResult<InspectionPlanRespVO> pageResult = inspectionPlanService.getInspectionPlanPage(pageReqVO);
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/maintainplan/MaintainPlanController.java
@@ -129,7 +129,11 @@ public class MaintainPlanController { @@ -129,7 +129,11 @@ public class MaintainPlanController {
129 if(permissionApi.hasAnyRoles(loginUserId, "super_admin")){ 129 if(permissionApi.hasAnyRoles(loginUserId, "super_admin")){
130 pageReqVO.setCompanyId( null); 130 pageReqVO.setCompanyId( null);
131 }else{ 131 }else{
132 - pageReqVO.setCompanyId(SecurityFrameworkUtils.getCompanyId()); 132 + Long companyId = SecurityFrameworkUtils.getCompanyId();
  133 + if(null == companyId || companyId == 0L || companyId == 100L){
  134 + companyId = null;
  135 + }
  136 + pageReqVO.setCompanyId(companyId);
133 } 137 }
134 } 138 }
135 PageResult<MaintainPlanRespVO> pageResult = maintainPlanService.getMaintainPlanPage(pageReqVO); 139 PageResult<MaintainPlanRespVO> pageResult = maintainPlanService.getMaintainPlanPage(pageReqVO);
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/road/RoadController.java
@@ -3,6 +3,8 @@ package com.zteits.urbanops.module.garden.controller.admin.road; @@ -3,6 +3,8 @@ package com.zteits.urbanops.module.garden.controller.admin.road;
3 import com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils; 3 import com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils;
4 import com.zteits.urbanops.module.system.api.permission.PermissionApi; 4 import com.zteits.urbanops.module.system.api.permission.PermissionApi;
5 import jakarta.annotation.security.PermitAll; 5 import jakarta.annotation.security.PermitAll;
  6 +import org.slf4j.Logger;
  7 +import org.slf4j.LoggerFactory;
6 import org.springframework.web.bind.annotation.*; 8 import org.springframework.web.bind.annotation.*;
7 import jakarta.annotation.Resource; 9 import jakarta.annotation.Resource;
8 import org.springframework.validation.annotation.Validated; 10 import org.springframework.validation.annotation.Validated;
@@ -37,6 +39,7 @@ import com.zteits.urbanops.module.garden.service.road.RoadService; @@ -37,6 +39,7 @@ import com.zteits.urbanops.module.garden.service.road.RoadService;
37 @RequestMapping("/garden/road") 39 @RequestMapping("/garden/road")
38 @Validated 40 @Validated
39 public class RoadController { 41 public class RoadController {
  42 + private static final Logger log = LoggerFactory.getLogger(RoadController.class);
40 43
41 @Resource 44 @Resource
42 private RoadService roadService; 45 private RoadService roadService;
@@ -94,7 +97,11 @@ public class RoadController { @@ -94,7 +97,11 @@ public class RoadController {
94 if(permissionApi.hasAnyRoles(loginUserId, "super_admin")){ 97 if(permissionApi.hasAnyRoles(loginUserId, "super_admin")){
95 pageReqVO.setCompanyId( null); 98 pageReqVO.setCompanyId( null);
96 }else{ 99 }else{
97 - pageReqVO.setCompanyId(SecurityFrameworkUtils.getCompanyId()); 100 + Long companyId = SecurityFrameworkUtils.getCompanyId();
  101 + if(null == companyId || companyId == 0L || companyId == 100L){
  102 + companyId = null;
  103 + }
  104 + pageReqVO.setCompanyId(companyId);
98 } 105 }
99 } 106 }
100 PageResult<RoadRespVO> pageResult = roadService.getRoadPage(pageReqVO); 107 PageResult<RoadRespVO> pageResult = roadService.getRoadPage(pageReqVO);
@@ -127,6 +134,7 @@ public class RoadController { @@ -127,6 +134,7 @@ public class RoadController {
127 @GetMapping("/queryAllRoadList") 134 @GetMapping("/queryAllRoadList")
128 @PermitAll 135 @PermitAll
129 public Map<String, Object> queryAllRoadList(@RequestParam(required = false) String roadName, @RequestParam(required = false) String deptCode, @RequestParam(required = false) String companyCode) { 136 public Map<String, Object> queryAllRoadList(@RequestParam(required = false) String roadName, @RequestParam(required = false) String deptCode, @RequestParam(required = false) String companyCode) {
  137 + log.info("物联网查询道路:companyCode:{},roadName:{},deptCode:{}",companyCode,roadName,deptCode);
130 RoadListReqVO reqVO = new RoadListReqVO(); 138 RoadListReqVO reqVO = new RoadListReqVO();
131 reqVO.setRoadName(roadName); 139 reqVO.setRoadName(roadName);
132 // 处理deptCode为空的情况 140 // 处理deptCode为空的情况
@@ -141,7 +149,7 @@ public class RoadController { @@ -141,7 +149,7 @@ public class RoadController {
141 roadMap.put("roadName", manager.getRoadName()); 149 roadMap.put("roadName", manager.getRoadName());
142 return roadMap; 150 return roadMap;
143 }).collect(Collectors.toList()); 151 }).collect(Collectors.toList());
144 - 152 +
145 // 构建返回格式 153 // 构建返回格式
146 Map<String, Object> result = new HashMap<>(); 154 Map<String, Object> result = new HashMap<>();
147 result.put("msg", "操作成功"); 155 result.put("msg", "操作成功");