SceneProMapper.xml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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.manage.mapper.ISceneProMapper">
  4. <select id="getCountGroupByUserId" resultType="com.fdkankan.manage.vo.response.GroupByCount" >
  5. SELECT user_id as id, count(id) as count FROM t_scene_pro WHERE rec_status = 'A' and is_upgrade = 0
  6. and user_id in
  7. <foreach item="userId" collection="userIdList" open="(" separator="," close=")">
  8. #{userId}
  9. </foreach>
  10. <if test="isObj !=null and isObj == 0">
  11. and scene_source in (1,2,3,12,13,14)
  12. </if>
  13. <if test="isObj !=null and isObj == 1">
  14. and is_obj = 1
  15. and scene_source = 4
  16. </if>
  17. GROUP BY user_id
  18. </select>
  19. <select id="getCountGroupByCameraId" resultType="com.fdkankan.manage.vo.response.GroupByCount">
  20. SELECT camera_id as id,count(id) as count FROM t_scene_pro WHERE rec_status = 'A' and is_upgrade = 0 AND camera_id is not null
  21. and scene_source in (1,2,3,12,13,14)
  22. and camera_id in
  23. <foreach item="cameraId" collection="cameraIds" open="(" separator="," close=")">
  24. #{cameraId}
  25. </foreach>
  26. GROUP BY camera_id
  27. </select>
  28. <select id="pageList" resultType="com.fdkankan.manage.vo.response.SceneVo">
  29. SELECT * FROM(
  30. select s.scene_name ,s.num,s.create_time,c.sn_code,s.space as sceneSize
  31. ,u.user_name,s.view_count,s.status,s.pay_status,'v3' as scene_version ,s.web_site , s.thumb
  32. ,null as algorithmTime,data_source
  33. from t_scene_pro s
  34. <include refid="commonWhere"></include>
  35. <if test="param.sceneName != null and param.sceneName!='' ">
  36. and s.scene_name like concat ('%',#{param.sceneName},'%')
  37. </if>
  38. and is_upgrade = 0
  39. UNION
  40. select s.title as sceneName ,s.num,s.create_time,c.sn_code,e.space as sceneSize
  41. ,u.user_name,e.view_count,s.scene_status as status,s.pay_status,'v4' as scene_version,e.web_site,e.thumb
  42. ,algorithm_time,data_source
  43. from t_scene_plus s
  44. left join t_scene_plus_ext e on s.id = e.plus_id
  45. <include refid="commonWhere"></include>
  46. <if test="param.sceneName != null and param.sceneName!='' ">
  47. and s.title like concat ('%',#{param.sceneName},'%')
  48. </if>
  49. ) as tb
  50. order by ${param.field} ,id ${param.order}
  51. </select>
  52. <sql id="commonWhere">
  53. left join t_user u on s.user_id = u.id
  54. left join t_camera c on s.camera_id = c.id
  55. left join t_camera_detail d on c.id = d.camera_id
  56. left join t_company co on d.company_id = co.id
  57. where s.rec_status = 'A'
  58. <if test="param.snCode != null and param.snCode !='' ">
  59. and c.sn_code like concat ('%',#{param.snCode},'%')
  60. </if>
  61. <if test="param.userName != null and param.userName !='' ">
  62. and u.user_name like concat ('%',#{param.userName},'%')
  63. </if>
  64. <if test="param.type !=null and param.type == 0">
  65. and s.scene_source in (1,2,12,13,14)
  66. </if>
  67. <if test="param.type !=null and param.type == 1">
  68. and s.scene_source = 3
  69. </if>
  70. <if test="param.type !=null and param.type == 5">
  71. and s.scene_source = 4 and is_obj = 1
  72. </if>
  73. <if test="param.type !=null and param.type == 7">
  74. and s.scene_source = 5 and is_obj = 1
  75. </if>
  76. <if test="param.companyId !=null ">
  77. and co.id = #{param.companyId}
  78. </if>
  79. <if test="param.num !=null and param.num !='' ">
  80. and s.num like concat ('%',#{param.num},'%')
  81. </if>
  82. <if test="param.startTime !=null and param.startTime !='' ">
  83. and s.create_time &gt;= #{param.startTime}
  84. </if>
  85. <if test="param.endTime !=null and param.endTime !='' ">
  86. and s.create_time &lt;= #{param.endTime}
  87. </if>
  88. </sql>
  89. <select id="getProSpaceGroupByCameraId" resultType="com.fdkankan.manage.vo.response.GroupByCount">
  90. SELECT camera_id as id,sum(space) as count FROM t_scene_pro
  91. WHERE rec_status = 'A' and is_upgrade = 0 GROUP BY camera_id
  92. </select>
  93. <select id="getPlusSpaceGroupByCameraId" resultType="com.fdkankan.manage.vo.response.GroupByCount">
  94. SELECT p.camera_id as id,sum(space) as count FROM t_scene_plus p left join t_scene_plus_ext e on p.id = e.plus_id
  95. WHERE p.rec_status = 'A' GROUP BY p.camera_id
  96. </select>
  97. <select id="getSpaceSumByCameraId" resultType="java.lang.Long">
  98. select sum(space) from t_scene_pro where rec_status= 'A' and status = -2 and is_upgrade = 0 and camera_id = #{cameraId}
  99. </select>
  100. </mapper>