Browse Source

深时用户名称查询

lyhzzz 2 years ago
parent
commit
48f430cbf1

+ 38 - 18
src/main/java/com/fdkankan/manage/httpClient/service/LaserService.java

@@ -3,13 +3,8 @@ package com.fdkankan.manage.httpClient.service;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.fdkankan.manage.common.ResultCode;
-import com.fdkankan.common.constant.HttpCode;
-import com.fdkankan.manage.exception.BusinessException;
 import com.fdkankan.common.response.PageInfo;
 import com.fdkankan.common.response.Result;
-import com.fdkankan.common.util.DateUtil;
-import com.fdkankan.manage.common.CameraTypeEnum;
 import com.fdkankan.manage.entity.Camera;
 import com.fdkankan.manage.entity.CameraDetail;
 import com.fdkankan.manage.entity.User;
@@ -17,6 +12,8 @@ import com.fdkankan.manage.httpClient.client.LaserClient;
 import com.fdkankan.manage.httpClient.param.LaserSceneMoveParam;
 import com.fdkankan.manage.httpClient.param.LaserSceneParam;
 import com.fdkankan.manage.httpClient.vo.FdkkResponse;
+import com.fdkankan.manage.service.ICameraDetailService;
+import com.fdkankan.manage.service.ICameraService;
 import com.fdkankan.manage.service.IUserService;
 import com.fdkankan.manage.vo.request.SceneParam;
 import com.fdkankan.manage.vo.response.SceneVo;
@@ -26,16 +23,11 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
-import org.springframework.util.ObjectUtils;
-import org.springframework.web.client.RestTemplate;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.stream.Collectors;
 
 @Service
 @Slf4j
@@ -47,15 +39,15 @@ public class LaserService {
     private String basePath;
     @Autowired
     IUserService userService;
+    @Autowired
+    ICameraDetailService cameraDetailService;
+    @Autowired
+    ICameraService cameraService;
 
 
     public PageInfo pageList(SceneParam param) {
-        LaserSceneParam newParam = new LaserSceneParam();
-        BeanUtils.copyProperties(param,newParam);
-        newParam.setTitle(param.getSceneName());
-        newParam.setPhone(param.getUserName());
-        FdkkResponse response = laserClient.sceneList(newParam);
-
+        LaserSceneParam laserSceneParam = getLaserSceneParam(param);
+        FdkkResponse response = laserClient.sceneList(laserSceneParam);
         JSONObject jsonObject =response.getData();
         if(jsonObject == null){
             Page<SceneVo> voPage = new Page<>(param.getPageNum(),param.getPageSize());
@@ -95,6 +87,34 @@ public class LaserService {
         return PageInfo.PageInfo(voPage);
     }
 
+    private LaserSceneParam getLaserSceneParam(SceneParam param) {
+        if(param.getCompanyId()!= null){ //客户场景
+            List<CameraDetail> cameraDetails = cameraDetailService.getListByCompanyId(param.getCompanyId());
+            param.setSnCodes(this.setSnCodes(cameraDetails));
+        }
+        if(StringUtils.isNotBlank(param.getUserName())){
+            List<CameraDetail> cameraDetails = cameraDetailService.getByUserName(param.getUserName());
+            param.setSnCodes(this.setSnCodes(cameraDetails));
+        }
+        LaserSceneParam newParam = new LaserSceneParam();
+        BeanUtils.copyProperties(param,newParam);
+        newParam.setTitle(param.getSceneName());
+        newParam.setPhone(param.getUserName());
+        return newParam;
+    }
+
+    private List<String> setSnCodes(List<CameraDetail> cameraDetails) {
+        if(cameraDetails != null && cameraDetails.size() >0){
+            Set<Long> cameraIds = cameraDetails.stream()
+                    .filter(entity -> entity.getGoodsId() == 10).map(CameraDetail::getCameraId).collect(Collectors.toSet());
+            if(cameraIds.size() >0){
+                List<Camera> cameraList = cameraService.listByIds(cameraIds);
+                return cameraList.stream().map(Camera::getSnCode).collect(Collectors.toList());
+            }
+        }
+        return null;
+    }
+
     private Integer toFdStatus(Integer status) {
         //深时状态,-1:场景被删 0:计算中 1计算失败 2计算成功 3封存 4生成OBJ中
         switch (status){

+ 2 - 0
src/main/java/com/fdkankan/manage/service/ICameraDetailService.java

@@ -33,4 +33,6 @@ public interface ICameraDetailService extends IService<CameraDetail> {
     Long getCountByCompanyId(Long companyId);
 
     List<CameraDetail> getListByCompanyId(Integer companyId);
+
+    List<CameraDetail> getByUserName(String userName);
 }

+ 16 - 0
src/main/java/com/fdkankan/manage/service/impl/CameraDetailServiceImpl.java

@@ -157,4 +157,20 @@ public class CameraDetailServiceImpl extends ServiceImpl<ICameraDetailMapper, Ca
         wrapper.eq(CameraDetail::getCompanyId,companyId);
         return this.list(wrapper);
     }
+
+    @Override
+    public List<CameraDetail> getByUserName(String userName) {
+        LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(User::getUserName,userName);
+        List<User> list = userService.list(wrapper);
+        if(list.size() >0){
+            List<Long> userIds = list.stream().map(User::getId).collect(Collectors.toList());
+            if(userIds.size() >0){
+                LambdaQueryWrapper<CameraDetail> dtW = new LambdaQueryWrapper<>();
+                dtW.in(CameraDetail::getUserId,userIds);
+                return this.list(dtW);
+            }
+        }
+        return null;
+    }
 }

+ 0 - 12
src/main/java/com/fdkankan/manage/service/impl/SceneProServiceImpl.java

@@ -269,18 +269,6 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
     @Override
     public PageInfo pageList(SceneParam param) {
         if(param.getType() == 2){  //深时
-            if(param.getCompanyId()!= null){ //客户场景
-                List<CameraDetail> cameraDetails = cameraDetailService.getListByCompanyId(param.getCompanyId());
-                if(cameraDetails.size() >0){
-                    Set<Long> cameraIds = cameraDetails.stream()
-                            .filter(entity -> entity.getGoodsId() == 10).map(CameraDetail::getCameraId).collect(Collectors.toSet());
-                    if(cameraIds.size() >0){
-                        List<Camera> cameraList = cameraService.listByIds(cameraIds);
-                        List<String> snCodes = cameraList.stream().map(Camera::getSnCode).collect(Collectors.toList());
-                        param.setSnCodes(snCodes);
-                    }
-                }
-            }
             return laserService.pageList(param);
         }
         if(param.getType() == 3){ //双目lite