lyhzzz 1 năm trước cách đây
mục cha
commit
fc6b74bb98

+ 2 - 1
src/main/java/com/fdkankan/ucenter/vo/request/AppSceneParam.java

@@ -5,6 +5,7 @@ import lombok.Data;
 import lombok.ToString;
 import org.apache.commons.lang3.StringUtils;
 
+import java.util.ArrayList;
 import java.util.List;
 
 @Data
@@ -22,7 +23,7 @@ public class AppSceneParam extends RequestBase {
     private String snCode;
 
     private String cooperationNums;
-    private List<String> cooperationNumList;
+    private List<String> cooperationNumList = new ArrayList<>();
 
     private Long cameraId;
 

+ 21 - 30
src/main/resources/mapper/ucenter/ScenePlusMapper.xml

@@ -3,31 +3,27 @@
 <mapper namespace="com.fdkankan.ucenter.mapper.IScenePlusMapper">
 
     <select id="pageList" resultType="com.fdkankan.ucenter.vo.response.AppSceneVo">
+        SELECT * FROM(
         SELECT p.id ,null as name ,0 as isFolder,null as type,null as parentId ,p.create_time,num,scene_name,scene_dec,
         p.status,pay_status,thumb,web_site,0 as is_upgrade,view_count,
          p.camera_id,p.user_id ,p.data_source,p.scene_type,build_type
         FROM t_scene_pro p
-        left join `t_camera_detail` tcd on p.camera_id = tcd.camera_id
-        left join t_company com on tcd.company_id = com.id
-        WHERE is_upgrade = 0 and  p.rec_status = 'A'   AND ( p.status = 1 OR p.status = -2) AND p.scene_type != 99
         <include refid="commonWhere"></include>
         <if test="param.sceneName !=null and param.sceneName !=''">
             and (p.scene_name like concat ('%',#{param.sceneName},'%') or p.laser_title like concat ('%',#{param.sceneName},'%') )
-
         </if>
+            and is_upgrade = 0
         UNION
         SELECT p.id as id ,null as name ,0 as isFolder,null as type,null as parentId,p.create_time ,num,title as scene_name,description as scene_dec,
         scene_status as status,pay_status,thumb,web_site,1 as is_upgrade,view_count,
         p.camera_id,p.user_id,e.data_source,p.scene_type,build_type
         FROM t_scene_plus p
-        LEFT JOIN t_scene_plus_ext e on p.id = e.plus_id
-        left join `t_camera_detail` tcd on p.camera_id = tcd.camera_id
-        left join t_company com on tcd.company_id = com.id
-        WHERE  p.rec_status = 'A' AND ( p.scene_status = 1 OR p.scene_status = -2) AND p.scene_type != 99
+        left join t_scene_plus_ext e on s.id = e.plus_id
         <include refid="commonWhere"></include>
         <if test="param.sceneName !=null and param.sceneName !=''">
             and (p.title like concat ('%',#{param.sceneName},'%') or p.laser_title like concat ('%',#{param.sceneName},'%') )
         </if>
+        ) as tb
         <if test="param.orderBy !=null and param.orderBy !=''">
             ORDER BY  ${param.orderBy}
         </if>
@@ -39,36 +35,31 @@
 
 
     <sql id="commonWhere">
-        <if test= "param.userId != null or param.cooperationNumList != null or param.cameraId != null or param.companyId != null">
-           and  ( 1!=1
-        </if>
-        <if test="param.userId != null">
-            or  p.user_id =#{param.userId}
-        </if>
-        <if test= "param.companyId != null" >
-            or com.id = #{param.companyId}
-        </if>
-        <if test="param.cameraId !=null ">
-            or p.camera_id = #{param.cameraId}
-        </if>
-        <if test="param.companyId != null and param.cooperationNumList !=null and param.cooperationNumList.size >0">
-            or p.num in
-               <foreach collection="param.cooperationNumList" item="sceneNum" open="("  separator="," close=")">
-                   #{sceneNum}
-               </foreach>
-        </if>
-        <if test= "param.userId != null or param.cooperationNumList != null or param.cameraId != null or param.companyId != null">
-            )
-        </if>
+        left join t_user u on p.user_id = u.id
+        left join t_camera c on p.camera_id = c.id
+        left join t_camera_detail d on c.id = d.camera_id
+        left join t_company co on u.company_id = co.id
+        where s.rec_status = 'A'
         <if test="param.sceneType !=null and param.sceneType !=''">
             and  p.scene_type  = #{param.sceneType}
         </if>
         <if test= "param.cameraType != null" >
-            and tcd.goods_id = #{param.cameraType}
+            and d.goods_id = #{param.cameraType}
         </if>
         <if test= "param.payStatus != null">
             and p.pay_status = #{param.payStatus}
         </if>
+
+        <if test="param.userId !=null and param.companyId !=null and param.cooperationNumList !=null and param.cooperationNumList.size >0">
+            and ( p.user_id = #{param.userId} or co.id = #{param.companyId} or p.num in
+            <foreach collection="param.cooperationNumList" item="coNum" open="(" separator="," close=")">
+                #{coNum}
+            </foreach>
+            )
+        </if>
+        <if test="param.userId !=null and param.companyId !=null and param.cooperationNumList !=null and param.cooperationNumList.size ==0 ">
+            and (co.id = #{param.companyId} or p.user_id = #{param.userId} )
+        </if>
     </sql>