AppReportMonitorMapper.xml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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.huaxu.dao.AppReportMonitorMapper">
  4. <select id="getSceneByCompany" resultType="com.huaxu.entity.SceneEntity">
  5. select
  6. s.id,
  7. s.SCENE_NAME as "sceneName",
  8. s.PARENT_SCENE_ID as "parentSceneId"
  9. from sms_scene_type st
  10. left join sms_scene s on st.id=s.SCENE_TYPE_ID
  11. where st.STATUS = 1 and s.STATUS = 1
  12. and st.SCENE_TYPE_NAME =#{sceneType}
  13. and s.COMPANY_ORG_ID = #{companyOrgId}
  14. and s.TENANT_ID = #{tenantId}
  15. <if test="userType!=null and userType!=-999 and userType!=-9999 and programItems != null and programItems.size() > 0">
  16. <if test="permissonType == 5 or permissonType == 2">
  17. and ( s.DEPT_ORG_ID in
  18. <foreach collection="programItems" item="item" open="(" close=")" separator=",">
  19. #{item.orgId}
  20. </foreach>
  21. or
  22. s.COMPANY_ORG_ID in
  23. <foreach collection="programItems" item="item" open="(" close=")" separator=",">
  24. #{item.orgId}
  25. </foreach>
  26. )
  27. </if>
  28. <if test="permissonType == 4 or permissonType == 3">
  29. and s.DEPT_ORG_ID in
  30. <foreach collection="programItems" item="item" open="(" close=")" separator=",">
  31. #{item.orgId}
  32. </foreach>
  33. </if>
  34. <if test="permissonType == 1">
  35. and s.COMPANY_ORG_ID in
  36. <foreach collection="programItems" item="item" open="(" close=")" separator=",">
  37. #{item.orgId}
  38. </foreach>
  39. and (s.DEPT_ORG_ID is null or s.DEPT_ORG_ID =0)
  40. </if>
  41. </if>
  42. order by s.SCENE_NAME
  43. </select>
  44. <select id="getDeviceByCompany" resultType="com.huaxu.entity.DeviceEntity">
  45. select
  46. d.id
  47. ,d.DEVICE_CODE as "deviceCode"
  48. ,d.DEVICE_NAME as "deviceName"
  49. from sms_scene_type st
  50. left join sms_scene s on st.id=s.SCENE_TYPE_ID
  51. left join sms_device_scene ds on ds.SCENE_ID =s.id
  52. left join sms_device d on d.id=ds.DEVICE_ID
  53. where st.STATUS = 1 and s.STATUS = 1 and ds.`STATUS` =1 and d.`STATUS` =1 and d.ENABLE_STATE =1
  54. and st.SCENE_TYPE_NAME = '管网'
  55. and s.COMPANY_ORG_ID = #{companyOrgId}
  56. and s.TENANT_ID = #{tenantId}
  57. <if test="userType!=null and userType!=-999 and userType!=-9999 and programItems != null and programItems.size() > 0">
  58. <if test="permissonType == 5 or permissonType == 2">
  59. and ( s.DEPT_ORG_ID in
  60. <foreach collection="programItems" item="item" open="(" close=")" separator=",">
  61. #{item.orgId}
  62. </foreach>
  63. or
  64. s.COMPANY_ORG_ID in
  65. <foreach collection="programItems" item="item" open="(" close=")" separator=",">
  66. #{item.orgId}
  67. </foreach>
  68. )
  69. </if>
  70. <if test="permissonType == 4 or permissonType == 3">
  71. and s.DEPT_ORG_ID in
  72. <foreach collection="programItems" item="item" open="(" close=")" separator=",">
  73. #{item.orgId}
  74. </foreach>
  75. </if>
  76. <if test="permissonType == 1">
  77. and s.COMPANY_ORG_ID in
  78. <foreach collection="programItems" item="item" open="(" close=")" separator=",">
  79. #{item.orgId}
  80. </foreach>
  81. and (s.DEPT_ORG_ID is null or s.DEPT_ORG_ID =0)
  82. </if>
  83. </if>
  84. order by s.SCENE_NAME
  85. </select>
  86. <select id="getCompanyBySceneCondition" resultType="java.lang.Integer">
  87. select
  88. distinct
  89. s.COMPANY_ORG_ID
  90. from sms_scene_type st
  91. left join sms_scene s on st.id=s.SCENE_TYPE_ID
  92. where st.STATUS = 1 and s.STATUS = 1
  93. and st.SCENE_TYPE_NAME =#{sceneType}
  94. <if test="condition != null and condition !=''">
  95. and s.SCENE_NAME like concat('%',#{condition},'%')
  96. </if>
  97. and s.TENANT_ID = #{tenantId}
  98. <if test="userType!=null and userType!=-999 and userType!=-9999 and programItems != null and programItems.size() > 0">
  99. <if test="permissonType == 5 or permissonType == 2">
  100. and ( s.DEPT_ORG_ID in
  101. <foreach collection="programItems" item="item" open="(" close=")" separator=",">
  102. #{item.orgId}
  103. </foreach>
  104. or
  105. s.COMPANY_ORG_ID in
  106. <foreach collection="programItems" item="item" open="(" close=")" separator=",">
  107. #{item.orgId}
  108. </foreach>
  109. )
  110. </if>
  111. <if test="permissonType == 4 or permissonType == 3">
  112. and s.DEPT_ORG_ID in
  113. <foreach collection="programItems" item="item" open="(" close=")" separator=",">
  114. #{item.orgId}
  115. </foreach>
  116. </if>
  117. <if test="permissonType == 1">
  118. and s.COMPANY_ORG_ID in
  119. <foreach collection="programItems" item="item" open="(" close=")" separator=",">
  120. #{item.orgId}
  121. </foreach>
  122. and (s.DEPT_ORG_ID is null or s.DEPT_ORG_ID =0)
  123. </if>
  124. </if>
  125. </select>
  126. <select id="getCompanyByDeviceCondition" resultType="java.lang.Integer">
  127. select
  128. distinct
  129. d.COMPANY_ORG_ID
  130. from sms_scene_type st
  131. left join sms_scene s on st.id=s.SCENE_TYPE_ID
  132. left join sms_device_scene ds on ds.SCENE_ID =s.id
  133. left join sms_device d on d.id=ds.DEVICE_ID
  134. where st.STATUS = 1 and s.STATUS = 1 and ds.`STATUS` =1 and d.`STATUS` =1 and d.ENABLE_STATE =1
  135. and st.SCENE_TYPE_NAME ='管网'
  136. <if test="condition != null and condition !=''">
  137. and d.DEVICE_NAME like concat('%',#{condition},'%')
  138. </if>
  139. and s.TENANT_ID = #{tenantId}
  140. <if test="userType!=null and userType!=-999 and userType!=-9999 and programItems != null and programItems.size() > 0">
  141. <if test="permissonType == 5 or permissonType == 2">
  142. and ( s.DEPT_ORG_ID in
  143. <foreach collection="programItems" item="item" open="(" close=")" separator=",">
  144. #{item.orgId}
  145. </foreach>
  146. or
  147. s.COMPANY_ORG_ID in
  148. <foreach collection="programItems" item="item" open="(" close=")" separator=",">
  149. #{item.orgId}
  150. </foreach>
  151. )
  152. </if>
  153. <if test="permissonType == 4 or permissonType == 3">
  154. and s.DEPT_ORG_ID in
  155. <foreach collection="programItems" item="item" open="(" close=")" separator=",">
  156. #{item.orgId}
  157. </foreach>
  158. </if>
  159. <if test="permissonType == 1">
  160. and s.COMPANY_ORG_ID in
  161. <foreach collection="programItems" item="item" open="(" close=")" separator=",">
  162. #{item.orgId}
  163. </foreach>
  164. and (s.DEPT_ORG_ID is null or s.DEPT_ORG_ID =0)
  165. </if>
  166. </if>
  167. </select>
  168. </mapper>