ScenePlusMapper.xml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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.IScenePlusMapper">
  4. <sql id="commonWhere">
  5. left join t_user u on p.user_id = u.id
  6. left join t_camera c on p.camera_id = c.id
  7. left join t_camera_detail d on c.id = d.camera_id
  8. where p.rec_status = 'A' AND p.scene_type != 99
  9. <if test="param.sceneType !=null and param.sceneType !=''">
  10. and p.scene_type = #{param.sceneType}
  11. </if>
  12. <if test= 'param.cameraType != null' >
  13. and d.type = #{param.cameraType}
  14. </if>
  15. <if test="param.copyNumSet !=null and param.copyNumSet.size >0">
  16. and p.num not in
  17. <foreach collection="param.copyNumSet" item="num" open="(" separator="," close=")">
  18. #{num}
  19. </foreach>
  20. </if>
  21. <if test="param.cameraId != null and param.userId !=null and param.cooperationNumList !=null and param.cooperationNumList.size >0">
  22. and ( p.camera_id = #{param.cameraId} or p.user_id = #{param.userId} or p.num in
  23. <foreach collection="param.cooperationNumList" item="coNum" open="(" separator="," close=")">
  24. #{coNum}
  25. </foreach>
  26. )
  27. </if>
  28. <if test="param.cameraId != null and param.userId !=null and param.cooperationNumList !=null and param.cooperationNumList.size ==0 ">
  29. and ( p.camera_id = #{param.cameraId} or p.user_id = #{param.userId} )
  30. </if>
  31. <if test="param.cameraId != null and param.userId ==null and param.cooperationNumList !=null and param.cooperationNumList.size ==0 ">
  32. and p.camera_id = #{param.cameraId}
  33. </if>
  34. <if test="param.cameraId != null and param.userId ==null and param.cooperationNumList !=null and param.cooperationNumList.size >0 ">
  35. and ( p.camera_id = #{param.cameraId} or p.num in
  36. <foreach collection="param.cooperationNumList" item="coNum" open="(" separator="," close=")">
  37. #{coNum}
  38. </foreach>
  39. )
  40. </if>
  41. <if test="param.cameraId == null and param.userId !=null and param.cooperationNumList !=null and param.cooperationNumList.size ==0 ">
  42. and p.user_id = #{param.userId}
  43. </if>
  44. <if test="param.cameraId == null and param.userId !=null and param.cooperationNumList !=null and param.cooperationNumList.size >0 ">
  45. and ( p.user_id = #{param.userId} or p.num in
  46. <foreach collection="param.cooperationNumList" item="coNum" open="(" separator="," close=")">
  47. #{coNum}
  48. </foreach>
  49. )
  50. </if>
  51. </sql>
  52. <select id="pageList" resultType="com.fdkankan.ucenter.vo.response.AppSceneVo">
  53. SELECT p.id ,null as name ,0 as isFolder,null as type,null as parentId ,p.create_time,num,scene_name,scene_dec,
  54. p.status,pay_status,thumb,web_site,0 as is_upgrade,view_count,
  55. p.camera_id,p.user_id ,p.data_source,p.scene_type,build_type,c.sn_code,c.child_name,4 as location
  56. FROM t_scene_pro p
  57. <include refid="commonWhere"></include>
  58. and is_upgrade = 0 AND ( p.status = 1 OR p.status = -2)
  59. <if test="param.sceneName !=null and param.sceneName !=''">
  60. and p.scene_name like CONCAT('%',#{param.sceneName},'%')
  61. </if>
  62. UNION
  63. SELECT p.id as id ,null as name ,0 as isFolder,null as type,null as parentId,p.create_time ,num,title as scene_name,description as scene_dec,
  64. scene_status as status,pay_status,thumb,web_site,1 as is_upgrade,view_count,
  65. p.camera_id,p.user_id,e.data_source,p.scene_type,build_type,c.sn_code,c.child_name,e.location
  66. FROM t_scene_plus p
  67. LEFT JOIN t_scene_plus_ext e on p.id = e.plus_id
  68. <include refid="commonWhere"></include>
  69. <if test="param.queryVrPano !=null and param.queryVrPano == false">
  70. and (e.location != 7 or e.location is null )
  71. </if>
  72. AND ( p.scene_status = 1 OR p.scene_status = -2)
  73. <if test="param.sceneName !=null and param.sceneName !=''">
  74. and p.title like CONCAT('%',#{param.sceneName},'%')
  75. </if>
  76. <if test="param.orderBy !=null and param.orderBy !=''">
  77. ORDER BY ${param.orderBy}
  78. </if>
  79. <if test="param.orderBy ==null or param.orderBy ==''">
  80. ORDER BY create_time desc
  81. </if>
  82. </select>
  83. <select id="getCountByUserId" resultType="java.lang.Long">
  84. select count(*) from t_scene_plus s left join t_camera_detail d on s.camera_id = d.camera_id
  85. where s.rec_status = 'A'
  86. and s.user_id = #{userId} and d.type = #{cameraType}
  87. </select>
  88. <select id="getSpaceSumByCameraId" resultType="java.lang.Long">
  89. select sum(space) from t_scene_plus p left join t_scene_plus_ext e on p.id = e.plus_id where p.rec_status = 'A' and p.scene_status = -2 and p.camera_id = #{cameraId}
  90. </select>
  91. </mapper>