lyhzzz 2 years ago
parent
commit
46c8a3ae2d

+ 12 - 5
src/main/java/com/fdkankan/ucenter/service/impl/AppSceneService.java

@@ -22,10 +22,8 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.io.File;
-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
@@ -50,6 +48,8 @@ public class AppSceneService {
     IUserIncrementService userIncrementService;
     @Autowired
     RedisUtil redisUtil;
+    @Autowired
+    ISceneCooperationService sceneCooperationService;
 
     @Resource
     IScenePlusMapper scenePlusMapper;
@@ -73,8 +73,15 @@ public class AppSceneService {
         if(user == null){
             throw new BusinessException(LoginConstant.FAILURE_CODE_3015, LoginConstant.FAILURE_MSG_3015);
         }
-        //param.setUserId(user.getId());
+        List<String> cooperationNumList = sceneCooperationService.getNumByUserIds(Arrays.asList(user.getId()));
+        if(cooperationNumList.size() >0){
+            String cooperationNums = cooperationNumList.stream().map(num->"'"+num+"'").collect(Collectors.joining(","));
+            param.setCooperationNums(cooperationNums );
+        }
+
+        param.setUserId(user.getId());
         param.setSnCode(camera.getSnCode());
+        param.setCameraId(camera.getId());
         Page<AppSceneVo> page =  scenePlusMapper.pageList(new Page<>(param.getPageNum(),param.getPageSize()),param);
         for (AppSceneVo record : page.getRecords()) {
 

+ 6 - 0
src/main/java/com/fdkankan/ucenter/vo/request/AppSceneParam.java

@@ -3,6 +3,8 @@ package com.fdkankan.ucenter.vo.request;
 import com.fdkankan.ucenter.common.RequestBase;
 import lombok.Data;
 
+import java.util.List;
+
 @Data
 public class AppSceneParam extends RequestBase {
 
@@ -16,4 +18,8 @@ public class AppSceneParam extends RequestBase {
     private Long userId;
     private String snCode;
 
+    private String cooperationNums;
+
+    private Long cameraId;
+
 }

+ 15 - 12
src/main/resources/mapper/ucenter/ScenePlusMapper.xml

@@ -9,7 +9,6 @@
         <include refid="sceneJoinCamera"></include>
         WHERE is_upgrade = 0 and  p.rec_status = 'A'
         <include refid="commonWhere"></include>
-        <include refid="commonSceneWhere"></include>
         <if test="param.sceneName !=null and param.sceneName !=''">
             and  p.scene_name like CONCAT('%',#{param.sceneName},'%')
         </if>
@@ -21,7 +20,6 @@
         <include refid="sceneJoinCamera"></include>
         WHERE  p.rec_status = 'A'
         <include refid="commonWhere"></include>
-        <include refid="commonSceneWhere"></include>
         <if test="param.sceneName !=null and param.sceneName !=''">
             and  p.title like CONCAT('%',#{param.sceneName},'%')
         </if>
@@ -37,20 +35,25 @@
 
     <sql id="sceneJoinCamera">
         LEFT JOIN t_camera c on p.camera_id = c.id
-        LEFT JOIN t_scene_cooperation coo on p.num = coo.scene_num
-		LEFT JOIN t_user u on coo.user_id = u.id
+		LEFT JOIN t_user u on p.user_id = u.id
     </sql>
 
     <sql id="commonWhere">
-        <if test="param.userId != null ">
-            and p.user_id =#{param.userId}
+        <if test= 'param.userId != null or param.cooperationNums != null or param.cameraId != null'>
+           and  ( 1!=1
         </if>
-    </sql>
-
-    <sql id="commonSceneWhere">
-        <if test="param.snCode !=null and param.snCode !=''">
-            and c.sn_code like CONCAT('%',#{param.snCode},'%')
+        <if test="param.userId != null">
+            or  p.user_id =#{param.userId}
+        </if>
+        <if test="param.cameraId !=null ">
+            or p.camera_id = #{param.cameraId}
+        </if>
+        <if test="param.cooperationNums !=null and param.cooperationNums !=''">
+            or p.num in ( #{param.cooperationNums} )
+        </if>
+        <if test= 'param.userId != null or param.cooperationNums != null or param.cameraId != null'>
+            )
         </if>
-        and coo.rec_status ='A'
     </sql>
+
 </mapper>