Browse Source

部门上级id

lyhzzz 2 years ago
parent
commit
fa4f51ef2b

+ 0 - 19
src/main/java/com/fdkankan/fusion/controller/TmDepartmentController.java

@@ -31,25 +31,6 @@ public class TmDepartmentController {
     @Autowired
     @Autowired
     private ITmDepartmentService departmentService;
     private ITmDepartmentService departmentService;
 
 
-    @GetMapping("/getAll")
-    public ResultData getAll(){
-        List<TmDepartment> list = departmentService.list();
-        List<TmDepartment> resultList = new ArrayList<>();
-        if(!CollectionUtils.isEmpty(list)){
-            list.stream().filter(dept -> StringUtils.equals(dept.getParentId() , "0"))
-                    .peek(dept -> dept.setChildList(getChildList(dept , list))).collect(Collectors.toList());
-            resultList.addAll(list);
-        }
-        return ResultData.ok(resultList);
-    }
-
-    private  List<TmDepartment> getChildList(TmDepartment indexDept , List<TmDepartment> deptList){
-        if(CollectionUtils.isEmpty(deptList) || null == indexDept){
-            return null;
-        }
-        return deptList.stream().filter(dept -> StringUtils.equals(dept.getParentId() , indexDept.getId()))
-                .peek(dept -> dept.setChildList(getChildList(dept , deptList))).collect(Collectors.toList());
-    }
 
 
     /**
     /**
      * 根据部门编号获取详细信息
      * 根据部门编号获取详细信息

+ 1 - 0
src/main/java/com/fdkankan/fusion/service/impl/SceneService.java

@@ -28,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
+import java.security.Security;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashMap;

+ 8 - 4
src/main/java/com/fdkankan/fusion/service/impl/TmCameraServiceImpl.java

@@ -174,6 +174,9 @@ public class TmCameraServiceImpl extends ServiceImpl<ITmCameraMapper, TmCamera>
         wrapper.in(TmCamera::getDeptId,deptIds);
         wrapper.in(TmCamera::getDeptId,deptIds);
         wrapper.orderByDesc(TmCamera::getCreateTime);
         wrapper.orderByDesc(TmCamera::getCreateTime);
         Page<TmCamera> page = this.page(new Page<>(pageNum, pageSize), wrapper);
         Page<TmCamera> page = this.page(new Page<>(pageNum, pageSize), wrapper);
+        if(page.getRecords().size()<=0){
+            return PageInfo.PageInfo(page);
+        }
         List<String> snCodes = page.getRecords().stream().map(TmCamera::getCameraSn).collect(Collectors.toList());
         List<String> snCodes = page.getRecords().stream().map(TmCamera::getCameraSn).collect(Collectors.toList());
         FdkkResponse<List<CameraVo>> fdkkResponse = fdService.getCameraDetails(snCodes);
         FdkkResponse<List<CameraVo>> fdkkResponse = fdService.getCameraDetails(snCodes);
 
 
@@ -183,11 +186,12 @@ public class TmCameraServiceImpl extends ServiceImpl<ITmCameraMapper, TmCamera>
             deptIdMap.put(record.getCameraSn(),record.getDeptId());
             deptIdMap.put(record.getCameraSn(),record.getDeptId());
         }
         }
         Set<String> strings = deptIdMap.keySet();
         Set<String> strings = deptIdMap.keySet();
-        List<TmDepartment> departments = tmDepartmentService.listByIds(strings);
-        for (TmDepartment department : departments) {
-            deptNameMap.put(department.getId(),department.getName());
+        if(strings.size() >0){
+            List<TmDepartment> departments = tmDepartmentService.listByIds(strings);
+            for (TmDepartment department : departments) {
+                deptNameMap.put(department.getId(),department.getName());
+            }
         }
         }
-
         List<CameraVo> list =  fdkkResponse.getData();
         List<CameraVo> list =  fdkkResponse.getData();
         for (CameraVo cameraVo : list) {
         for (CameraVo cameraVo : list) {
             String deptIdO = deptIdMap.get(cameraVo.getSnCode());
             String deptIdO = deptIdMap.get(cameraVo.getSnCode());

+ 7 - 6
src/main/java/com/fdkankan/fusion/service/impl/TmDepartmentServiceImpl.java

@@ -104,19 +104,19 @@ public class TmDepartmentServiceImpl extends ServiceImpl<ITmDepartmentMapper, Tm
             return new ArrayList<>();
             return new ArrayList<>();
         }
         }
         if("0".equals(dept.getId())){
         if("0".equals(dept.getId())){
-            return this.getDeptListByParentId(deptId);
+            return this.getDeptListByParentId(dept);
         }
         }
-        dept.setChildren(this.getDeptListByParentId(deptId));
+        dept.setChildren(this.getDeptListByParentId(dept));
         return Arrays.asList(dept);
         return Arrays.asList(dept);
     }
     }
 
 
 
 
-    public List<TmDepartment> getDeptListByParentId(String parentId) {
+    public List<TmDepartment> getDeptListByParentId(TmDepartment department) {
         LambdaQueryWrapper<TmDepartment> queryWrapper = new LambdaQueryWrapper<>();
         LambdaQueryWrapper<TmDepartment> queryWrapper = new LambdaQueryWrapper<>();
-        if(parentId == null){
+        if(department.getParentId() == null){
             queryWrapper.isNull(TmDepartment::getParentId);
             queryWrapper.isNull(TmDepartment::getParentId);
         }else {
         }else {
-            queryWrapper.eq(TmDepartment::getParentId,parentId);
+            queryWrapper.eq(TmDepartment::getParentId,department.getParentId());
         }
         }
         queryWrapper.orderByDesc(TmDepartment::getCreateTime);
         queryWrapper.orderByDesc(TmDepartment::getCreateTime);
         List<TmDepartment> list = this.list(queryWrapper);
         List<TmDepartment> list = this.list(queryWrapper);
@@ -124,7 +124,8 @@ public class TmDepartmentServiceImpl extends ServiceImpl<ITmDepartmentMapper, Tm
             return list;
             return list;
         }
         }
         for (TmDepartment deptVo : list) {
         for (TmDepartment deptVo : list) {
-            deptVo.setChildren(getDeptListByParentId(deptVo.getId()));
+            deptVo.setChildren(getDeptListByParentId(deptVo));
+            deptVo.setParentName(department.getName());
         }
         }
         return list;
         return list;
     }
     }