Преглед изворни кода

sceneList 返回添加部门ID,部门名称

lyhzzz пре 1 година
родитељ
комит
c0b2d91acd
1 измењених фајлова са 29 додато и 3 уклоњено
  1. 29 3
      src/main/java/com/fdkankan/fusion/service/impl/CaseServiceImpl.java

+ 29 - 3
src/main/java/com/fdkankan/fusion/service/impl/CaseServiceImpl.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fdkankan.fusion.common.ResultCode;
 import com.fdkankan.fusion.entity.Model;
+import com.fdkankan.fusion.entity.TmDepartment;
 import com.fdkankan.fusion.entity.TmUser;
 import com.fdkankan.fusion.exception.BusinessException;
 import com.fdkankan.fusion.common.PageInfo;
@@ -21,9 +22,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -53,6 +52,8 @@ public class CaseServiceImpl extends ServiceImpl<ICaseMapper, CaseEntity> implem
     ITmDepartmentService tmDepartmentService;
     @Autowired
     ITmUserService tmUserService;
+    @Autowired
+    ITmCameraService tmCameraService;
 
     @Override
     public PageInfo pageList(CaseParam param,String userName) {
@@ -138,6 +139,31 @@ public class CaseServiceImpl extends ServiceImpl<ICaseMapper, CaseEntity> implem
                 listAll.add(sceneVo);
             }
         }
+        Set<String> snList = listAll.stream().filter(entity ->StringUtils.isNotBlank(entity.getSnCode()))
+                .map(SceneVo::getSnCode).collect(Collectors.toSet());
+        HashMap<String, TmDepartment> mapBySnCodes = tmCameraService.getMapBySnCodes(snList);
+        for (SceneVo sceneVo : listAll) {
+            if(StringUtils.isNotBlank(sceneVo.getSnCode())){
+                TmDepartment tmDepartment = mapBySnCodes.get(sceneVo.getSnCode());
+                if(tmDepartment != null){
+                    sceneVo.setDeptId(tmDepartment.getId());
+                    sceneVo.setDeptName(tmDepartment.getName());
+                }
+            }
+        }
+
+        Set<String> deptIdset = listAll.stream().filter(entity ->StringUtils.isNotBlank(entity.getDeptId())&& StringUtils.isBlank(entity.getDeptName()))
+                .map(SceneVo::getDeptId).collect(Collectors.toSet());
+        HashMap<String, TmDepartment> mapByDept = tmDepartmentService.getMapByDeptIds(deptIdset);
+        for (SceneVo sceneVo : listAll) {
+            if(StringUtils.isNotBlank(sceneVo.getDeptId())){
+                TmDepartment tmDepartment = mapByDept.get(sceneVo.getDeptId());
+                if(tmDepartment != null){
+                    sceneVo.setDeptName(tmDepartment.getName());
+                }
+            }
+
+        }
         return listAll;
     }