소스 검색

场景列表添加所属架构

lyhzzz 2 년 전
부모
커밋
4d3dbf75a3

+ 2 - 0
src/main/java/com/fdkankan/fusion/response/SceneVo.java

@@ -22,4 +22,6 @@ public class SceneVo extends Model {
 
     private String phone;
     private Boolean bind = true;
+    private String deptId;
+    private String deptName;
 }

+ 5 - 0
src/main/java/com/fdkankan/fusion/service/ITmCameraService.java

@@ -2,9 +2,12 @@ package com.fdkankan.fusion.service;
 
 import com.fdkankan.fusion.entity.TmCamera;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.fdkankan.fusion.entity.TmDepartment;
 import com.fdkankan.fusion.response.BindCameraDto;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Set;
 
 /**
  * <p>
@@ -35,4 +38,6 @@ public interface ITmCameraService extends IService<TmCamera> {
     List<TmCamera> getByDeptIds(List<String> deptIds);
 
     List<TmCamera> getByDeptIds();
+
+    HashMap<String, TmDepartment> getMapBySnCodes(Set<String> snCodes);
 }

+ 14 - 28
src/main/java/com/fdkankan/fusion/service/impl/SceneService.java

@@ -8,6 +8,7 @@ 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.TmCamera;
+import com.fdkankan.fusion.entity.TmDepartment;
 import com.fdkankan.fusion.exception.BusinessException;
 import com.fdkankan.fusion.common.PageInfo;
 import com.fdkankan.fusion.httpClient.FdService;
@@ -30,10 +31,7 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.security.Security;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Service
@@ -93,14 +91,7 @@ public class SceneService implements ISceneService {
         long total = 0;
         if(param.getType() == 0 || param.getType() == 1 || param.getType() == 4){      //看看,看见 ,深时obj
             //获取四维(看看,看见)场景数据
-            FdkkResponse fdkkResponse = null;
-//            if(param.getNumList() == null || param.getNumList().size()<=0){
-//                param.setStatus(2);
-//                fdkkResponse = fdKKClient.sceneList(param,fdService.getFdToken(token));
-//            }else {
-//                fdkkResponse = fdKKClient.sceneList(param);
-//            }
-            fdkkResponse = fdKKClient.sceneList(param);
+            FdkkResponse fdkkResponse = fdKKClient.sceneList(param);
             if(fdkkResponse.getCode() !=0){
                 throw new BusinessException(fdkkResponse.getCode(),fdkkResponse.getMsg());
             }
@@ -123,26 +114,12 @@ public class SceneService implements ISceneService {
             if(param.getNumList() != null && param.getNumList().size() >0){
                 laserSceneParam.setSceneCodes(param.getNumList());
             }
-            FdkkResponse fdkkResponse = null;
-//            if(param.getNumList() == null || param.getNumList().size()<=0){
-//                fdkkResponse = laserClient.sceneList(laserSceneParam, fdService.getFdToken(token));
-//            }else {
-//                fdkkResponse = laserClient.sceneList(laserSceneParam);
-//            }
-            fdkkResponse = laserClient.sceneList(laserSceneParam);
+            FdkkResponse fdkkResponse = laserClient.sceneList(laserSceneParam);
             if(fdkkResponse.getCode() !=200){
                 throw new BusinessException(fdkkResponse.getCode(),fdkkResponse.getMsg());
             }
             JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(fdkkResponse.getData()));
-            JSONArray list = null;
-//            if(param.getNumList() == null || param.getNumList().size()<=0){
-//                list = jsonObject.getJSONObject("pageInfo").getJSONArray("list");
-//                total = jsonObject.getJSONObject("pageInfo").getLong("total");
-//            }else {
-//                list = jsonObject.getJSONArray("list");
-//                total =jsonObject.getLong("total");
-//            }
-            list = jsonObject.getJSONArray("list");
+            JSONArray list = jsonObject.getJSONArray("list");
             total =jsonObject.getLong("total");
             for (Object o : list) {
                 String res = JSONObject.toJSONString(o);
@@ -157,6 +134,15 @@ public class SceneService implements ISceneService {
                 sceneVoList.add(vo);
             }
         }
+        Set<String> snCodes = sceneVoList.stream().map(SceneVo::getSnCode).collect(Collectors.toSet());
+        HashMap<String, TmDepartment> map = tmCameraService.getMapBySnCodes(snCodes);
+        for (SceneVo sceneVo : sceneVoList) {
+            TmDepartment tmDepartment = map.get(sceneVo.getSnCode().toUpperCase());
+            if(tmDepartment != null){
+                sceneVo.setDeptId(tmDepartment.getId());
+                sceneVo.setDeptName(tmDepartment.getName());
+            }
+        }
         Page<SceneVo> voPage = new Page<>(param.getPageNum(),param.getPageSize());
         voPage.setRecords(sceneVoList);
         voPage.setTotal(total);

+ 14 - 0
src/main/java/com/fdkankan/fusion/service/impl/TmCameraServiceImpl.java

@@ -221,4 +221,18 @@ public class TmCameraServiceImpl extends ServiceImpl<ITmCameraMapper, TmCamera>
         wrapper.in(TmCamera::getDeptId,deptIds);
         return this.list(wrapper);
     }
+
+    @Override
+    public HashMap<String, TmDepartment> getMapBySnCodes(Set<String> snCodes) {
+        HashMap<String, TmDepartment> map = new HashMap<>();
+        if(snCodes.size() >0){
+            LambdaQueryWrapper<TmCamera> wrapper = new LambdaQueryWrapper<>();
+            wrapper.in(TmCamera::getCameraSn,snCodes);
+            List<TmCamera> list = this.list(wrapper);
+            Set<String> deptIds = list.stream().map(TmCamera::getDeptId).collect(Collectors.toSet());
+            HashMap<String, TmDepartment> mapDept = tmDepartmentService.getMapByDeptIds(deptIds);
+            list.forEach(entity -> map.put(entity.getCameraSn().toUpperCase(),mapDept.get(entity.getDeptId())));
+        }
+        return map;
+    }
 }