SceneProMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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="num" property="num" jdbcType="VARCHAR" />
  14. <result column="scene_type" property="sceneType" jdbcType="TINYINT" />
  15. <result column="scene_status" property="sceneStatus" jdbcType="INTEGER" />
  16. <result column="pay_status" property="payStatus" jdbcType="TINYINT" />
  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="build_type" property="buildType" jdbcType="VARCHAR" />
  21. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  22. <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
  23. <result column="tb_status" property="tbStatus" jdbcType="TINYINT" />
  24. </resultMap>
  25. <sql id="ScenePro_column">
  26. t.id, t.scene_name, t.scene_dec, t.web_site, t.thumb, t.user_id,
  27. t.camera_id, t.scene_logo, t.num, t.scene_type, t.scene_status,
  28. t.pay_status, t.videos, t.gps, t.scene_scheme, t.tb_status, t.build_type,
  29. t.create_time, t.update_time, t.tb_status
  30. </sql>
  31. <resultMap id="SceneProExtResultMap" type="com.fdkankan.scene.entity.SceneProExt" >
  32. <result column="scene_pro_id" property="sceneProId" jdbcType="BIGINT" />
  33. <result column="data_source" property="dataSource" jdbcType="VARCHAR" />
  34. <result column="phone_id" property="phoneId" jdbcType="VARCHAR" />
  35. <result column="recommend" property="recommend" jdbcType="TINYINT" />
  36. <result column="files_name" property="filesName" jdbcType="VARCHAR" />
  37. <result column="algorithm" property="algorithm" jdbcType="VARCHAR" />
  38. <result column="ecs" property="ecs" jdbcType="VARCHAR" />
  39. <result column="space" property="space" jdbcType="BIGINT" />
  40. <result column="firmware_version" property="firmwareVersion" jdbcType="VARCHAR" />
  41. <result column="compute_time" property="computeTime" jdbcType="BIGINT" />
  42. <result column="scene_source" property="sceneSource" jdbcType="INTEGER" />
  43. <result column="vrnum" property="vrnum" jdbcType="VARCHAR" />
  44. <result column="unicode" property="unicode" jdbcType="VARCHAR" />
  45. <result column="view_count" property="viewCount" jdbcType="INTEGER" />
  46. <result column="shoot_count" property="shootCount" jdbcType="INTEGER" />
  47. </resultMap>
  48. <sql id="SceneProExt_column" >
  49. ext.scene_pro_id, ext.data_source, ext.view_count, ext.shoot_count,
  50. ext.phone_id, ext.recommend, ext.files_name, ext.algorithm, ext.ecs, ext.space,
  51. ext.firmware_version, ext.compute_time, ext.scene_source, ext.vrnum, ext.unicode
  52. </sql>
  53. <select id="findFolderIdScence" resultType="java.lang.Integer">
  54. SELECT count(id)
  55. FROM t_scene_pro
  56. WHERE id in (SELECT scene_id from t_folder_scene WHERE folder_id = #{folderId})
  57. and user_id = #{userId}
  58. </select>
  59. <select id="findLikeNum" resultType="com.fdkankan.scene.entity.ScenePro">
  60. SELECT * FROM t_scene_pro
  61. WHERE num like CONCAT(#{sceneCode}, '%')
  62. AND tb_status = 0
  63. ORDER BY id desc
  64. limit 1
  65. </select>
  66. <select id="findByNum" resultType="com.fdkankan.scene.entity.ScenePro">
  67. SELECT * FROM t_scene_pro WHERE num = #{sceneCode} AND tb_status = 0 LIMIT 1
  68. </select>
  69. <select id="getSceneStatusByUnicode" resultType="com.fdkankan.scene.entity.SceneProPO">
  70. select
  71. <include refid="ScenePro_column"/>,
  72. <include refid="SceneProExt_column"/>
  73. from t_scene_pro t
  74. left join t_scene_pro_ext ext on t.id = ext.scene_pro_id
  75. WHERE ext.data_source LIKE CONCAT('%',#{unicode},'%') AND t.tb_status = #{tbStatus}
  76. order by t.create_time desc
  77. LIMIT 1
  78. </select>
  79. <select id="findByUserIdAndCameraType" resultType="com.fdkankan.scene.entity.SceneProPO">
  80. SELECT
  81. <include refid="ScenePro_column"/>,
  82. <include refid="SceneProExt_column"/>
  83. FROM t_scene_pro t
  84. LEFT JOIN t_scene_pro_ext ext ON t.id = ext.scene_pro_id
  85. WHERE t.user_id = #{userId}
  86. AND ext.camera_type = #{cameraType}
  87. AND t.tb_status = 0
  88. AND t.scene_status IN (1,-2)
  89. AND t.scene_type != 99
  90. ORDER BY t.create_time DESC
  91. </select>
  92. <select id="findByUserId" resultType="com.fdkankan.scene.entity.SceneProPO">
  93. SELECT
  94. <include refid="ScenePro_column"/>,
  95. <include refid="SceneProExt_column"/>
  96. FROM t_scene_pro t
  97. LEFT JOIN t_scene_pro_ext ext ON t.id = ext.scene_pro_id
  98. WHERE t.user_id = #{userId}
  99. AND t.tb_status = 0
  100. AND t.scene_status in (1, -2)
  101. AND t.scene_type != 99
  102. AND ext.scene_source = 1
  103. <if test= 'excludeNums != null and excludeNums.size > 0'>
  104. and t.num not in
  105. <foreach item='num' collection='excludeNums' open='(' separator=',' close=')'>
  106. #{num}
  107. </foreach>
  108. </if>
  109. order by t.id desc
  110. </select>
  111. <select id="findBySceneNums" resultType="com.fdkankan.scene.entity.SceneProPO">
  112. SELECT
  113. <include refid="ScenePro_column"/>,
  114. <include refid="SceneProExt_column"/>
  115. FROM t_scene_pro t
  116. LEFT JOIN t_scene_pro_ext ext ON t.id = ext.scene_pro_id
  117. WHERE ext.camera_type = #{cameraType}
  118. AND t.tb_status = 0
  119. AND t.scene_status IN (1,-2)
  120. AND t.scene_type != 99
  121. <if test= 'sceneCodeList != null and sceneCodeList.size > 0'>
  122. and t.num in
  123. <foreach item='sceneCode' collection='sceneCodeList' open='(' separator=',' close=')'>
  124. #{sceneCode}
  125. </foreach>
  126. </if>
  127. ORDER BY t.create_time DESC
  128. </select>
  129. <select id="findLatestOneByUserId" resultType="com.fdkankan.scene.vo.SceneVO">
  130. SELECT
  131. <include refid="ScenePro_column"/>,
  132. <include refid="SceneProExt_column"/>
  133. FROM t_scene_pro t
  134. LEFT JOIN t_scene_pro_ext ext ON t.id = ext.scene_pro_id
  135. WHERE t.user_id = #{userId}
  136. AND t.tb_status = 0
  137. AND t.camera_id is not null
  138. ORDER BY t.create_time DESC
  139. LIMIT 1
  140. </select>
  141. <select id="findByCameraIdPro" resultType="com.fdkankan.scene.entity.SceneProPO">
  142. SELECT
  143. <include refid="ScenePro_column"/>,
  144. <include refid="SceneProExt_column"/>
  145. FROM t_scene_pro t
  146. LEFT JOIN t_scene_pro_ext ext ON t.id = ext.scene_pro_id
  147. WHERE t.camera_id = #{cameraId}
  148. AND t.tb_status = 0
  149. </select>
  150. <select id="findByFileId" resultType="com.fdkankan.scene.entity.SceneProPO">
  151. SELECT
  152. <include refid="ScenePro_column"/>,
  153. <include refid="SceneProExt_column"/>
  154. FROM t_scene_pro t
  155. LEFT JOIN t_scene_pro_ext ext ON t.id = ext.scene_pro_id
  156. WHERE ext.data_source LIKE CONCAT('%',#{fileId},'%')
  157. AND t.tb_status = 0
  158. order by t.create_time desc
  159. LIMIT 1
  160. </select>
  161. <select id="findTempScenes" resultType="com.fdkankan.scene.entity.ScenePro">
  162. SELECT
  163. t.id, t.num
  164. FROM t_scene_pro t
  165. LEFT JOIN t_scene_pro_ext ext ON t.id = ext.scene_pro_id
  166. WHERE t.tb_status = 0
  167. and ext.pay_status = -2
  168. and (DATEDIFF(t.update_time,NOW()) <![CDATA[ <= ]]> -365)
  169. </select>
  170. <select id="getAppAllSceneByPage" resultType="com.fdkankan.scene.vo.SceneVO">
  171. SELECT * FROM (
  172. <if test= 'userId != null'>
  173. SELECT
  174. <include refid="ScenePro_column"/>,
  175. <include refid="SceneProExt_column"/>
  176. FROM t_scene_pro t
  177. LEFT JOIN t_scene_pro_ext ext ON t.id = ext.scene_pro_id
  178. WHERE t.user_id = #{userId} AND ext.camera_type = #{cameraType}
  179. AND t.tb_status = 0 AND t.scene_status in (1, -2) AND t.scene_type != 99
  180. </if>
  181. <if test= 'userId != null and cameraId != null'>
  182. UNION
  183. SELECT
  184. <include refid="ScenePro_column"/>,
  185. <include refid="SceneProExt_column"/>
  186. FROM t_scene_pro t
  187. LEFT JOIN t_scene_pro_ext ext ON t.id = ext.scene_pro_id
  188. WHERE t.camera_id = #{cameraId}
  189. AND t.scene_status in (1, -2) AND t.scene_type != 99 AND t.tb_status = 0
  190. </if>
  191. <if test= 'sceneCodeList != null and sceneCodeList.size() > 0'>
  192. UNION
  193. SELECT
  194. <include refid="ScenePro_column"/>,
  195. <include refid="SceneProExt_column"/>
  196. FROM t_scene_pro t
  197. LEFT JOIN t_scene_pro_ext ext ON t.id = ext.scene_pro_id
  198. WHERE t.scene_status in (1, -2)
  199. AND t.num IN
  200. <foreach collection="sceneCodeList" item="sceneCode" open="(" close=")" separator=",">
  201. #{sceneCode}
  202. </foreach>
  203. </if>
  204. ) a WHERE tb_status = 0
  205. <if test= 'sceneType != null'>
  206. AND scene_type = #{sceneType}
  207. </if>
  208. <if test= 'sceneName != null'>
  209. AND scene_name like CONCAT('%', #{sceneName}, '%')
  210. </if>
  211. <if test="orderBy != null and orderBy != ''">
  212. ${orderBy}
  213. </if>
  214. </select>
  215. <select id="findLastSceneByCameraId" resultType="com.fdkankan.scene.entity.SceneProPO">
  216. select
  217. <include refid="ScenePro_column"/>,
  218. <include refid="SceneProExt_column"/>
  219. from t_scene_pro t
  220. LEFT JOIN t_scene_pro_ext ext ON t.id = ext.scene_pro_id
  221. where t.tb_status = 0 and t.camera_id = #{cameraId}
  222. order by t.create_time desc
  223. limit 1
  224. </select>
  225. <select id="findByNumWithOutCheckRecStatus" resultType="com.fdkankan.scene.entity.SceneProPO">
  226. select
  227. <include refid="ScenePro_column"/>,
  228. <include refid="SceneProExt_column"/>
  229. from t_scene_pro t
  230. LEFT JOIN t_scene_pro_ext ext ON t.id = ext.scene_pro_id
  231. where t.num = #{sceneCode}
  232. limit 1
  233. </select>
  234. <select id="selectCooperationSceneList" parameterType="com.fdkankan.scene.vo.SceneParamVO" resultType="com.fdkankan.scene.entity.SceneProPO">
  235. select
  236. <include refid="ScenePro_column"/>,
  237. <include refid="SceneProExt_column"/>
  238. from t_scene_pro t
  239. left join t_scene_pro_ext ext on t.id = ext.scene_pro_id
  240. where t.tb_status = 0
  241. and ext.scene_source != 11
  242. <if test="numList != null and numList.size() != 0">
  243. and t.num in
  244. <foreach collection="numList" item="num" open="(" close=")" separator=",">
  245. #{num}
  246. </foreach>
  247. </if>
  248. <if test="sceneSourceList != null and sceneSourceList.size() != 0">
  249. and ext.scene_source in
  250. <foreach collection="sceneSourceList" item="sceneSource" open="(" close=")" separator=",">
  251. #{sceneSource}
  252. </foreach>
  253. </if>
  254. <if test="sceneIdList != null and sceneIdList.size() != 0">
  255. and t.id in
  256. <foreach collection="sceneIdList" item="id" open="(" close=")" separator=",">
  257. #{id}
  258. </foreach>
  259. </if>
  260. <if test="sceneType != null and sceneType !=''">
  261. and t.scene_type = #{sceneType}
  262. </if>
  263. <if test="startTime != null">
  264. and t.create_time >= #{startTime}
  265. </if>
  266. <if test="endTime != null">
  267. and t.create_time <![CDATA[ <= ]]> #{endTime}
  268. </if>
  269. order by t.id desc
  270. </select>
  271. <select id="selectSceneList" parameterType="com.fdkankan.scene.vo.SceneParamVO" resultType="com.fdkankan.scene.entity.SceneProPO">
  272. select
  273. <include refid="ScenePro_column"/>,
  274. <include refid="SceneProExt_column"/>
  275. from t_scene_pro t
  276. left join t_scene_pro_ext ext on t.id = ext.scene_pro_id
  277. where t.tb_status = 0
  278. and ext.scene_source != 11
  279. <if test="userId != null">
  280. and t.user_id = #{userId}
  281. </if>
  282. <if test="num != null">
  283. and t.num = #{num}
  284. </if>
  285. <if test="numList != null and numList.size() != 0">
  286. and t.num in
  287. <foreach collection="numList" item="num" open="(" close=")" separator=",">
  288. #{num}
  289. </foreach>
  290. </if>
  291. <if test="sceneSourceList != null and sceneSourceList.size() != 0">
  292. and ext.scene_source in
  293. <foreach collection="sceneSourceList" item="sceneSource" open="(" close=")" separator=",">
  294. #{sceneSource}
  295. </foreach>
  296. </if>
  297. <if test="sceneIdList != null and sceneIdList.size() != 0">
  298. and t.id in
  299. <foreach collection="sceneIdList" item="id" open="(" close=")" separator=",">
  300. #{id}
  301. </foreach>
  302. </if>
  303. <if test="sceneType != null and sceneType !=''">
  304. and t.scene_type = #{sceneType}
  305. </if>
  306. <if test="sceneName != null and sceneName != ''">
  307. and t.scene_name like concat('%', scene_name, '%')
  308. </if>
  309. <if test="startTime != null">
  310. and t.create_time >= #{startTime}
  311. </if>
  312. <if test="endTime != null">
  313. and t.create_time <![CDATA[ <= ]]> #{endTime}
  314. </if>
  315. <if test="cameraIdList != null and cameraIdList.size() != 0">
  316. and t.camera_id in
  317. <foreach collection="cameraIdList" item="cameraId" open="(" close=")" separator=",">
  318. #{cameraId}
  319. </foreach>
  320. </if>
  321. order by t.id desc
  322. </select>
  323. <select id="findByCameraIds" resultType="com.fdkankan.scene.entity.SceneProPO">
  324. SELECT * FROM t_scene_pro WHERE camera_id in (${cameraIds}) AND rec_status = 'A'
  325. <if test= 'startTime != null'>
  326. AND create_time &gt;= #{startTime}
  327. </if>
  328. <if test= 'endTime != null'>
  329. AND create_time &lt;= #{endTime}
  330. </if>
  331. ORDER BY camera_id,create_time DESC
  332. </select>
  333. <select id="getNumAndNameByCameraId" resultType="com.fdkankan.scene.vo.SceneBySnCodeVo">
  334. SELECT num AS sceneNum,scene_name AS sceneName FROM t_scene_pro
  335. WHERE rec_status = 'A' AND camera_id = #{cameraId} AND user_id = #{userId} AND scene_source!=11
  336. </select>
  337. </mapper>