SceneProMapper.xml 6.7 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(id) as count ,sum(space) as space ,max(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 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
  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. AND
  32. <include refid="commonSceneWhere"></include>
  33. <if test="param.sceneName !=null and param.sceneName !=''">
  34. and p.scene_name like CONCAT('%',#{param.sceneName},'%')
  35. </if>
  36. <if test="param.isObj !=null ">
  37. and p.is_obj = #{param.isObj}
  38. </if>
  39. UNION ALL
  40. SELECT 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,
  41. 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
  42. FROM t_scene_plus p
  43. LEFT JOIN t_scene_plus_ext e on p.id = e.plus_id
  44. <include refid="sceneJoinCamera"></include>
  45. WHERE p.rec_status = 'A'
  46. <include refid="commonWhere"></include>
  47. AND
  48. <include refid="commonSceneWhere"></include>
  49. <if test="param.sceneName !=null and param.sceneName !=''">
  50. and p.title like CONCAT('%',#{param.sceneName},'%')
  51. </if>
  52. <if test="param.isObj !=null ">
  53. and e.is_obj = #{param.isObj}
  54. </if>
  55. ORDER BY create_time desc ,id desc
  56. ) as scene_tb
  57. </select>
  58. <select id="getCountByUserId" resultType="java.lang.Long">
  59. select count(*) from t_scene_pro s left join t_camera_detail d on s.camera_id = d.camera_id
  60. where s.rec_status = 'A' and s.is_upgrade = 0
  61. and s.user_id = #{userId} and d.type = #{cameraType}
  62. </select>
  63. <sql id="HasFolder">
  64. <if test="param.hasFolder == 1">
  65. select * from (
  66. SELECT id,name,1 as isFolder,type,parent_id as parentId,create_time,null as num,null as scene_name,null as
  67. scene_dec,
  68. null as status,null as pay_status,null as thumb,null as web_site,null as is_upgrade,null as sn_code,null as
  69. view_count, null build_type,null as removePortrait,null as scene_source
  70. FROM t_folder WHERE rec_status = 'A' and user_id =#{param.userId}
  71. <if test="param.folderType!=null and param.folderType == 0">
  72. and (type = #{param.folderType} or type = 3)
  73. </if>
  74. <if test="param.folderType!=null and param.folderType != 0">
  75. and type = #{param.folderType}
  76. </if>
  77. <if test="param.folderId!=null">
  78. AND parent_id = #{param.folderId}
  79. </if>
  80. <if test="param.folderId == null">
  81. AND parent_id is null
  82. </if>
  83. order by create_time desc
  84. limit 1000
  85. )as tb
  86. UNION ALL
  87. </if>
  88. </sql>
  89. <sql id="sceneJoinCamera">
  90. LEFT JOIN t_camera c on p.camera_id = c.id
  91. <if test="param.userName!=null and param.userName!=''">
  92. LEFT JOIN t_scene_cooperation coo on p.num = coo.scene_num
  93. LEFT JOIN t_user u on coo.user_id = u.id
  94. </if>
  95. </sql>
  96. <sql id="commonWhere">
  97. <if test="param.numList == null and param.userId != null ">
  98. and p.user_id =#{param.userId}
  99. </if>
  100. <if test="param.cameraId != null ">
  101. and p.camera_id =#{param.cameraId}
  102. </if>
  103. and p.num not in (select num from t_scene_not_display where rec_status= 'A')
  104. </sql>
  105. <sql id="commonSceneWhere">
  106. scene_source in
  107. <foreach item="sourceId" collection="param.sourceList" open="(" separator="," close=")">
  108. #{sourceId}
  109. </foreach>
  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'
  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>