SceneProMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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.scene.mapper.ISceneProMapper">
  4. <resultMap id="SceneProResultMap" type="com.fdkankan.scene.entity.ScenePro" >
  5. <id column="id" property="id" jdbcType="BIGINT" />
  6. <result column="scene_name" property="sceneName" jdbcType="BIGINT" />
  7. <result column="scene_dec" property="sceneDec" jdbcType="VARCHAR" />
  8. <result column="web_site" property="webSite" jdbcType="varchar" />
  9. <result column="thumb" property="thumb" jdbcType="VARCHAR" />
  10. <result column="user_id" property="userId" jdbcType="BIGINT" />
  11. <result column="camera_id" property="cameraId" jdbcType="BIGINT" />
  12. <result column="scene_logo" property="sceneLogo" jdbcType="VARCHAR" />
  13. <result column="scene_code" property="sceneCode" jdbcType="VARCHAR" />
  14. <result column="scene_type" property="sceneType" jdbcType="TINYINT" />
  15. <result column="view_count" property="viewCount" jdbcType="INTEGER" />
  16. <result column="shoot_count" property="shootCount" jdbcType="INTEGER" />
  17. <result column="videos" property="videos" jdbcType="VARCHAR" />
  18. <result column="gps" property="gps" jdbcType="VARCHAR" />
  19. <result column="scene_scheme" property="sceneScheme" jdbcType="TINYINT" />
  20. <result column="rec_status" property="recStatus" jdbcType="VARCHAR" />
  21. <result column="build_type" property="buildType" jdbcType="VARCHAR" />
  22. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  23. <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
  24. <result column="tb_status" property="tbStatus" jdbcType="TINYINT" />
  25. </resultMap>
  26. <sql id="ScenePro_column">
  27. id, scene_name, scene_dec, web_site, thumb, user_id,
  28. camera_id, scene_logo, scene_code, scene_type, view_count,
  29. shoot_count, videos, gps, scene_scheme, rec_status, build_type,
  30. create_time, update_time, tb_status
  31. </sql>
  32. <resultMap id="SceneProExtResultMap" type="com.fdkankan.scene.entity.SceneProExt" >
  33. <result column="scene_pro_id" property="sceneProId" jdbcType="BIGINT" />
  34. <result column="scene_status" property="sceneStatus" jdbcType="INTEGER" />
  35. <result column="data_source" property="dataSource" jdbcType="VARCHAR" />
  36. <result column="pay_status" property="payStatus" jdbcType="TINYINT" />
  37. <result column="phone_id" property="phoneId" jdbcType="VARCHAR" />
  38. <result column="recommend" property="recommend" jdbcType="TINYINT" />
  39. <result column="files_name" property="filesName" jdbcType="VARCHAR" />
  40. <result column="algorithm" property="algorithm" jdbcType="VARCHAR" />
  41. <result column="ecs" property="ecs" jdbcType="VARCHAR" />
  42. <result column="space" property="space" jdbcType="BIGINT" />
  43. <result column="firmware_version" property="firmwareVersion" jdbcType="VARCHAR" />
  44. <result column="compute_time" property="computeTime" jdbcType="BIGINT" />
  45. <result column="scene_source" property="sceneSource" jdbcType="INTEGER" />
  46. <result column="vrnum" property="vrnum" jdbcType="VARCHAR" />
  47. <result column="unicode" property="unicode" jdbcType="VARCHAR" />
  48. </resultMap>
  49. <sql id="SceneProExt_column" >
  50. scene_pro_id, scene_status, data_source, pay_status,
  51. phone_id, recommend, files_name, algorithm, ecs, space,
  52. firmware_version, compute_time, scene_source, vrnum, unicode
  53. </sql>
  54. <select id="findFolderIdScence">
  55. SELECT count(id)
  56. FROM t_scene_pro
  57. WHERE id in (SELECT scene_id from t_folder_scene WHERE folder_id = #{folderId})
  58. and user_id = #{userId}
  59. </select>
  60. <select id="findLikeNum" resultType="com.fdkankan.scene.entity.ScenePro">
  61. SELECT * FROM t_scene_pro
  62. WHERE scene_code like CONCAT(#{sceneCode}, '%')
  63. AND rec_status = 'A'
  64. ORDER BY id desc
  65. limit 1
  66. </select>
  67. <select id="findByNum" resultType="com.fdkankan.scene.entity.ScenePro">
  68. SELECT * FROM t_scene_pro WHERE scene_code = #{sceneCode} AND rec_status = 'A' LIMIT 1
  69. </select>
  70. <select id="getSceneStatusByUnicode" resultType="com.fdkankan.scene.entity.SceneProPO">
  71. select
  72. <include refid="ScenePro_column"/>,
  73. <include refid="SceneProExt_column"/>
  74. from t_scene_pro t
  75. left join t_scene_pro_ext ext on t.id = ext.scene_pro_id
  76. WHERE ext.data_source LIKE CONCAT('%',#{unicode},'%') AND t.rec_status = #{recStatus}
  77. order by t.create_time desc
  78. LIMIT 1
  79. </select>
  80. <select id="findByUserIdAndCameraType" resultType="com.fdkankan.scene.entity.SceneProPO">
  81. SELECT
  82. <include refid="ScenePro_column"/>,
  83. <include refid="SceneProExt_column"/>
  84. FROM t_scene_pro t
  85. LEFT JOIN t_scene_pro_ext ext ON t.id = ext.scene_pro_id
  86. WHERE t.user_id = #{userId}
  87. AND ext.camera_type = #{cameraType}
  88. AND t.rec_status = 'A'
  89. AND ext.scene_status IN (1,-2)
  90. AND t.scene_type != 99
  91. ORDER BY t.create_time DESC
  92. </select>
  93. <select id="findByUserId" resultType="com.fdkankan.scene.entity.SceneProPO">
  94. SELECT
  95. <include refid="ScenePro_column"/>,
  96. <include refid="SceneProExt_column"/>
  97. FROM t_scene_pro t
  98. LEFT JOIN t_scene_pro_ext ext ON t.id = ext.scene_pro_id
  99. WHERE t.user_id = #{userId}
  100. AND t.rec_status = 'A'
  101. AND ext.scene_status in (1, -2)
  102. AND t.scene_type != 99
  103. AND ext.scene_source = 1
  104. <if test= 'excludeNums != null and excludeNums.size > 0'>
  105. and t.scene_code not in
  106. <foreach item='num' collection='excludeNums' open='(' separator=',' close=')'>
  107. #{num}
  108. </foreach>
  109. </if>
  110. order by t.id desc
  111. </select>
  112. <select id="findBySceneNums" resultType="com.fdkankan.scene.entity.SceneProPO">
  113. SELECT
  114. <include refid="ScenePro_column"/>,
  115. <include refid="SceneProExt_column"/>
  116. FROM t_scene_pro t
  117. LEFT JOIN t_scene_pro_ext ext ON t.id = ext.scene_pro_id
  118. WHERE ext.camera_type = #{cameraType}
  119. AND t.rec_status = 'A'
  120. AND ext.scene_status IN (1,-2)
  121. AND t.scene_type != 99
  122. <if test= 'sceneCodeList != null and sceneCodeList.size > 0'>
  123. and t.scene_code in
  124. <foreach item='sceneCode' collection='sceneCodeList' open='(' separator=',' close=')'>
  125. #{sceneCode}
  126. </foreach>
  127. </if>
  128. ORDER BY t.create_time DESC
  129. </select>
  130. <select id="findLatestOneByUserId" resultType="com.fdkankan.scene.vo.SceneVO">
  131. SELECT
  132. <include refid="ScenePro_column"/>,
  133. <include refid="SceneProExt_column"/>
  134. FROM t_scene_pro t
  135. LEFT JOIN t_scene_pro_ext ext ON t.id = ext.scene_pro_id
  136. WHERE t.user_id = #{userId}
  137. AND t.rec_status = 'A'
  138. AND t.camera_id is not null
  139. ORDER BY t.create_time DESC
  140. LIMIT 1
  141. </select>
  142. <select id="findByCameraIdPro" resultType="com.fdkankan.scene.entity.SceneProPO">
  143. SELECT
  144. <include refid="ScenePro_column"/>,
  145. <include refid="SceneProExt_column"/>
  146. FROM t_scene_pro t
  147. LEFT JOIN t_scene_pro_ext ext ON t.id = ext.scene_pro_id
  148. WHERE t.camera_id = #{cameraId}
  149. AND t.rec_status = 'A'
  150. </select>
  151. <select id="findByFileId" resultType="com.fdkankan.scene.entity.SceneProPO">
  152. SELECT
  153. <include refid="ScenePro_column"/>,
  154. <include refid="SceneProExt_column"/>
  155. FROM t_scene_pro t
  156. LEFT JOIN t_scene_pro_ext ext ON t.id = ext.scene_pro_id
  157. WHERE ext.data_source LIKE CONCAT('%',#{fileId},'%')
  158. AND t.rec_status = 'A'
  159. order by create_time desc
  160. LIMIT 1
  161. </select>
  162. <select id="findTempScenes" resultType="com.fdkankan.scene.entity.ScenePro">
  163. SELECT
  164. t.id, t.scene_code
  165. FROM t_scene_pro t
  166. LEFT JOIN t_scene_pro_ext ext ON t.id = ext.scene_pro_id
  167. WHERE t.rec_status = 'A'
  168. and ext.pay_status = -2
  169. and (DATEDIFF(t.update_time,NOW()) <![CDATA[ <= ]]> -365)
  170. </select>
  171. <select id="getAppAllSceneByPage" resultType="com.fdkankan.scene.vo.SceneVO">
  172. SELECT * FROM (
  173. <if test= 'userId != null'>
  174. SELECT
  175. <include refid="ScenePro_column"/>,
  176. <include refid="SceneProExt_column"/>
  177. FROM t_scene_pro t
  178. LEFT JOIN t_scene_pro_ext ext ON t.id = ext.scene_pro_id
  179. WHERE t.user_id = #{userId} AND ext.camera_type = #{cameraType}
  180. AND t.rec_status = 'A' AND ext.scene_status in (1, -2) AND t.scene_type != 99
  181. </if>
  182. <if test= 'userId != null and cameraId != null'>
  183. UNION
  184. SELECT
  185. <include refid="ScenePro_column"/>,
  186. <include refid="SceneProExt_column"/>
  187. FROM t_scene_pro t
  188. LEFT JOIN t_scene_pro_ext ext ON t.id = ext.scene_pro_id
  189. WHERE t.camera_id = #{cameraId}
  190. AND ext.scene_status in (1, -2) AND t.scene_type != 99 AND t.rec_status = 'A'
  191. </if>
  192. <if test= 'sceneCodeList != null and sceneCodeList.size() > 0'>
  193. UNION
  194. SELECT
  195. <include refid="ScenePro_column"/>,
  196. <include refid="SceneProExt_column"/>
  197. FROM t_scene_pro t
  198. LEFT JOIN t_scene_pro_ext ext ON t.id = ext.scene_pro_id
  199. WHERE ext.scene_status in (1, -2)
  200. AND t.scene_code IN
  201. <foreach collection="sceneCodeList" item="sceneCode" open="(" close=")" separator=",">
  202. #{sceneCode}
  203. </foreach>
  204. </if>
  205. ) a WHERE rec_status = 'A'
  206. <if test= 'sceneType != null'>
  207. AND scene_type = #{sceneType}
  208. </if>
  209. <if test= 'sceneName != null'>
  210. AND scene_name like CONCAT('%', #{sceneName}, '%')
  211. </if>
  212. <if test="orderBy != null and orderBy != ''">
  213. ${orderBy}
  214. </if>
  215. </select>
  216. <select id="findLastSceneByCameraId" resultType="com.fdkankan.scene.entity.SceneProPO">
  217. select
  218. <include refid="ScenePro_column"/>,
  219. <include refid="SceneProExt_column"/>
  220. from t_scene_pro t
  221. LEFT JOIN t_scene_pro_ext ext ON t.id = ext.scene_pro_id
  222. where t.rec_status = 'A' and t.camera_id = #{cameraId}
  223. order by t.create_time desc
  224. limit 1
  225. </select>
  226. <select id="findByNumWithOutCheckRecStatus" resultType="com.fdkankan.scene.entity.SceneProPO">
  227. select
  228. <include refid="ScenePro_column"/>,
  229. <include refid="SceneProExt_column"/>
  230. from t_scene_pro t
  231. LEFT JOIN t_scene_pro_ext ext ON t.id = ext.scene_pro_id
  232. where t.scene_code = #{sceneCode}
  233. limit 1
  234. </select>
  235. </mapper>