AppReportMonitorMapper.xml 8.0 KB

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