SceneProMapper.xml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.fdkankan.ucenter.mapper.ISceneProMapper">
  4. <select id="findSceneProNumByCameraIds" resultType="com.fdkankan.ucenter.vo.response.GroupByCount">
  5. SELECT camera_id as id,count(id) as count,sum(space) as space ,max(create_time) as lastTime FROM t_scene_pro
  6. WHERE rec_status = 'A' AND is_upgrade = 0
  7. and camera_id in
  8. <foreach item="cameraId" collection="cameraIds" open="(" separator="," close=")">
  9. #{cameraId}
  10. </foreach>
  11. GROUP BY camera_id
  12. </select>
  13. <select id="findScenePlusNumByCameraIds" resultType="com.fdkankan.ucenter.vo.response.GroupByCount">
  14. SELECT camera_id as id,count(s.id) as count ,sum(space) as space ,max(s.create_time) as lastTime FROM t_scene_plus s left join t_scene_plus_ext e on s.id = e.plus_id
  15. WHERE s.rec_status = 'A'
  16. and camera_id in
  17. <foreach item="cameraId" collection="cameraIds" open="(" separator="," close=")">
  18. #{cameraId}
  19. </foreach>
  20. GROUP BY camera_id
  21. </select>
  22. <select id="pageListAndFolder" resultType="com.fdkankan.ucenter.vo.response.SceneVo">
  23. <include refid="HasFolder"></include>
  24. SELECT * FROM (
  25. SELECT DISTINCT p.id ,null as name ,0 as isFolder,null as type,null as parentId ,p.create_time,num,scene_name,scene_dec,
  26. p.status,pay_status,thumb,web_site,0 as is_upgrade,sn_code,view_count,p.build_type, null as removePortrait,p.scene_source,p.laser_title
  27. FROM t_scene_pro p
  28. <include refid="sceneJoinCamera"></include>
  29. WHERE is_upgrade = 0 and p.rec_status = 'A'
  30. <include refid="commonWhere"></include>
  31. <include refid="commonSceneWhere"></include>
  32. <if test="param.sceneName !=null and param.sceneName !=''">
  33. and p.scene_name like CONCAT('%',#{param.sceneName},'%')
  34. </if>
  35. <if test="param.isObj !=null and param.isObj ==1 and param.isLaser==1">
  36. and p.is_obj = #{param.isObj}
  37. </if>
  38. UNION ALL
  39. SELECT DISTINCT p.id as id ,null as name ,0 as isFolder,null as type,null as parentId,e.algorithm_time as createTime ,num,title as scene_name,description as scene_dec,
  40. scene_status as status,pay_status,thumb,web_site,1 as is_upgrade,sn_code,view_count,e.build_type,p.remove_portrait as removePortrait,p.scene_source,p.laser_title
  41. FROM t_scene_plus p
  42. LEFT JOIN t_scene_plus_ext e on p.id = e.plus_id
  43. <include refid="sceneJoinCamera"></include>
  44. WHERE p.rec_status = 'A'
  45. <include refid="commonWhere"></include>
  46. <include refid="commonSceneWhere"></include>
  47. <if test="param.sceneName !=null and param.sceneName !=''">
  48. and p.title like CONCAT('%',#{param.sceneName},'%')
  49. </if>
  50. <if test="param.isObj !=null and param.isObj ==1 and param.isLaser==1">
  51. and e.is_obj = #{param.isObj}
  52. </if>
  53. ORDER BY create_time desc ,id desc
  54. ) as scene_tb
  55. </select>
  56. <select id="getCountByUserId" resultType="java.lang.Long">
  57. select count(*) from t_scene_pro s left join t_camera_detail d on s.camera_id = d.camera_id
  58. where s.rec_status = 'A' and s.is_upgrade = 0
  59. and s.user_id = #{userId} and d.type = #{cameraType}
  60. </select>
  61. <sql id="HasFolder">
  62. <if test="param.hasFolder == 1">
  63. select * from (
  64. SELECT id,name,1 as isFolder,type,parent_id as parentId,create_time,null as num,null as scene_name,null as
  65. scene_dec,
  66. null as status,null as pay_status,null as thumb,null as web_site,null as is_upgrade,null as sn_code,null as
  67. view_count, null build_type,null as removePortrait,null as scene_source,null as laserTitle
  68. FROM t_folder WHERE rec_status = 'A' and user_id =#{param.userId}
  69. <if test="param.folderType!=null and param.folderType == 0">
  70. and (type = #{param.folderType} or type = 3)
  71. </if>
  72. <if test="param.folderType!=null and param.folderType != 0">
  73. and type = #{param.folderType}
  74. </if>
  75. <if test="param.folderId!=null">
  76. AND parent_id = #{param.folderId}
  77. </if>
  78. <if test="param.folderId == null">
  79. AND parent_id is null
  80. </if>
  81. order by create_time desc
  82. limit 1000
  83. )as tb
  84. UNION ALL
  85. </if>
  86. </sql>
  87. <sql id="sceneJoinCamera">
  88. LEFT JOIN t_camera c on p.camera_id = c.id
  89. <if test="param.userName!=null and param.userName!=''">
  90. LEFT JOIN t_scene_cooperation coo on p.num = coo.scene_num
  91. LEFT JOIN t_user u on coo.user_id = u.id
  92. </if>
  93. </sql>
  94. <sql id="commonWhere">
  95. <if test="param.numList == null and param.userId != null ">
  96. and p.user_id =#{param.userId}
  97. </if>
  98. <if test="param.cameraId != null ">
  99. and p.camera_id =#{param.cameraId}
  100. </if>
  101. and p.num not in (select num from t_scene_not_display where rec_status= 'A')
  102. </sql>
  103. <sql id="commonSceneWhere">
  104. <if test="param.sourceList !=null and param.sourceList.size >0">
  105. AND scene_source in
  106. <foreach item="sourceId" collection="param.sourceList" open="(" separator="," close=")">
  107. #{sourceId}
  108. </foreach>
  109. </if>
  110. <if test="param.folderId == null and param.hasFolder == 1 ">
  111. AND p.id not in(SELECT scene_id FROM t_folder_scene where rec_status = 'A')
  112. </if>
  113. <if test="param.folderId != null and param.hasFolder == 1">
  114. AND p.id in (SELECT scene_id FROM t_folder_scene where rec_status= 'A' and folder_id =#{param.folderId} )
  115. </if>
  116. <if test="param.numList !=null and param.numList.size >0">
  117. and num in
  118. <foreach item="num" collection="param.numList" open="(" separator="," close=")">
  119. #{num}
  120. </foreach>
  121. </if>
  122. <if test="param.snCode !=null and param.snCode !=''">
  123. and c.sn_code like CONCAT('%',#{param.snCode},'%')
  124. </if>
  125. <if test="param.userName !=null and param.userName !=''">
  126. and u.user_name like CONCAT('%',#{param.userName},'%')
  127. and coo.rec_status = 'A' and coo.scene_type = 'mesh'
  128. </if>
  129. <if test="param.startTime !=null and param.startTime !=''">
  130. and p.create_time &gt;= #{param.startTime}
  131. </if>
  132. <if test="param.endTime !=null and param.endTime !=''">
  133. and p.create_time &lt;= #{param.endTime}
  134. </if>
  135. <if test="param.num !=null and param.num !=''">
  136. and p.num = #{param.num}
  137. </if>
  138. </sql>
  139. <select id="getSpaceSumByCameraId" resultType="java.lang.Long">
  140. select sum(space) from t_scene_pro where rec_status= 'A' and status = -2 and is_upgrade = 0 and camera_id = #{cameraId}
  141. </select>
  142. </mapper>