SiteMapper.xml 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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.bizmatics.persistence.mapper.SiteMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.bizmatics.model.Site">
  6. <id column="id" property="id"/>
  7. <result column="site_name" property="siteName"/>
  8. <result column="site_address" property="siteAddress"/>
  9. <result column="company_code" property="companyCode"/>
  10. <result column="user_name" property="userName"/>
  11. <result column="phone" property="phone"/>
  12. <result column="station_area_id" property="stationAreaId"/>
  13. <result column="route_id" property="routeId"/>
  14. <result column="longitude" property="longitude"/>
  15. <result column="latitude" property="latitude"/>
  16. <result column="region" property="region"/>
  17. <result column="create_time" property="createTime"/>
  18. <result column="creator" property="creator"/>
  19. <result column="enable" property="enable"/>
  20. <result column="grouping_id" property="groupingId"/>
  21. <result column="tenant_id" property="tenantId"/>
  22. </resultMap>
  23. <select id="selectCount" resultType="java.lang.Integer">
  24. select count(*)
  25. from (
  26. select us.id
  27. from user_site as us
  28. inner join device_status as ds
  29. on us.site_Id = ds.site_id
  30. <where>
  31. <if test="userId != null and userId != 0">
  32. and us.user_id = #{userId}
  33. </if>
  34. <if test="siteId != null and siteId != 0">
  35. and us.site_id = #{siteId}
  36. </if>
  37. <if test="siteStatus != null">
  38. and ds.device_status = #{siteStatus}
  39. </if>
  40. </where>
  41. group by us.site_id
  42. ) as t
  43. </select>
  44. <select id="list" resultType="com.bizmatics.model.Site">
  45. select s.id,s.site_name,s.site_address,s.company_code,s.user_name,s.phone,s.station_area_id,s.route_id,
  46. s.installed_capacity,s.rheological_change,s.longitude,s.latitude,s.region,s.create_time,s.creator,s.enable
  47. from user_site as us
  48. inner join site as s
  49. on us.site_id = s.id
  50. <where>
  51. s.enable=1
  52. and s.tenant_id=#{tenantId}
  53. <if test="userId != null and userId != 0">
  54. and us.user_id = #{userId}
  55. </if>
  56. <if test="name != null and name != ''">
  57. and s.site_name LIKE CONCAT(CONCAT('%', #{name}), '%')
  58. </if>
  59. </where>
  60. </select>
  61. <select id="list2" resultType="com.bizmatics.model.SiteTwo">
  62. SELECT
  63. a.*, b.device_status
  64. FROM
  65. (
  66. SELECT
  67. s.id,
  68. s.site_name,
  69. s.site_address,
  70. s.company_code,
  71. s.user_name,
  72. s.phone,
  73. s.station_area_id,
  74. s.route_id,
  75. s.installed_capacity,
  76. s.rheological_change,
  77. s.longitude,
  78. s.latitude,
  79. s.region,
  80. s.create_time,
  81. s.creator,
  82. s. ENABLE
  83. FROM
  84. user_site AS us
  85. INNER JOIN site AS s ON us.site_id = s.id
  86. <where>
  87. s.enable=1
  88. <if test="userId != null and userId != 0">
  89. and us.user_id = #{userId}
  90. </if>
  91. <if test="name != null and name != ''">
  92. and s.site_name LIKE CONCAT(CONCAT('%', #{name}), '%')
  93. </if>
  94. </where>) AS a
  95. LEFT JOIN device_status AS b ON a.id = b.site_id
  96. GROUP BY
  97. a.id
  98. ORDER BY
  99. a.id
  100. </select>
  101. <select id="getDeviceListOne" resultType="com.bizmatics.model.Device">
  102. SELECT
  103. a.*, b.device_status
  104. FROM
  105. device AS a
  106. JOIN device_status AS b ON a.device_code = b.device_code
  107. <where>
  108. <if test="siteId != null and siteId != 0">
  109. a.site_id = #{siteId}
  110. </if>
  111. </where>
  112. </select>
  113. <select id="Sitelist" resultType="com.bizmatics.model.SiteList">
  114. select
  115. a.user_id,
  116. b.id,
  117. b.grouping_id,
  118. b.site_name,
  119. c.grouping_name
  120. from user_site as a
  121. join site as b on a.site_id = b.id
  122. left join site_grouping as c on b.grouping_id = c.id
  123. <where>
  124. b.enable=1
  125. <if test="userId != null and userId != 0">
  126. and a.user_id = #{userId}
  127. </if>
  128. <if test="name != null and name != ''">
  129. and b.site_name like CONCAT(CONCAT('%', #{name}), '%')
  130. </if>
  131. order by b.id desc
  132. </where>
  133. </select>
  134. <select id="GroupingList" resultType="com.bizmatics.model.GroupingList">
  135. select
  136. a.id,
  137. a.grouping_name
  138. from site_grouping as a
  139. left join site as b on a.id = b.grouping_id
  140. <where>
  141. <if test="name != null and name != ''">
  142. and b.site_name like CONCAT(CONCAT('%', #{name}), '%')
  143. </if>
  144. <if test="creator != null and creator != ''">
  145. and a.creator = #{creator}
  146. </if>
  147. group by a.id
  148. order by a.id desc
  149. </where>
  150. </select>
  151. <select id="SiteGroupinglist" resultType="com.bizmatics.model.SiteList">
  152. select
  153. a.user_id,
  154. b.id,
  155. b.grouping_id,
  156. b.site_name,
  157. c.grouping_name
  158. from user_site as a
  159. join site as b on a.site_id = b.id
  160. left join site_grouping as c on b.grouping_id = c.id
  161. <where>
  162. b.enable=1
  163. and b.grouping_id=0
  164. <if test="userId != null and userId != 0">
  165. and a.user_id = #{userId}
  166. </if>
  167. <if test="name != null and name != ''">
  168. and b.site_name like CONCAT(CONCAT('%', #{name}), '%')
  169. </if>
  170. order by b.id desc
  171. </where>
  172. </select>
  173. <select id="idList" resultType="com.bizmatics.model.Site">
  174. select s.id
  175. from user_site as us
  176. inner join site as s
  177. on us.site_id = s.id
  178. <where>
  179. <if test="userId != null and userId != 0">
  180. and us.user_id = #{userId}
  181. </if>
  182. <if test="name != null and name != ''">
  183. and s.site_name LIKE CONCAT(CONCAT('%', #{name}), '%')
  184. </if>
  185. </where>
  186. </select>
  187. <select id="templateQuery" resultType="com.bizmatics.model.TemplateData">
  188. select
  189. a.id,
  190. a.site_name,
  191. a.site_address,
  192. a.company_code,
  193. a.user_name,
  194. a.phone,
  195. a.station_area_id,
  196. a.route_id,
  197. a.installed_capacity,
  198. a.rheological_change,
  199. a.longitude,
  200. a.latitude,
  201. a.region,
  202. a.grouping_id,
  203. b.id as site_dynamic_properties_id,
  204. b.fault_status,
  205. b.real_time_load,
  206. b.total_electricity,
  207. b.power_factor,
  208. b.site_id,
  209. b.site_type,
  210. b.user_company,
  211. b.operation_time,
  212. b.service_deadline,
  213. b.power_supply_type,
  214. b.voltage_level,
  215. b.demolition_standard_coal,
  216. b.demolition_standard_coal1,
  217. b.site_picture_one,
  218. b.site_picture_two,
  219. b.site_picture_three,
  220. a.spare_user_name,
  221. a.spare_phone
  222. from
  223. site AS a
  224. left join site_dynamic_properties as b on a.id = b.site_id
  225. <where>
  226. a.enable=1
  227. <if test="id != null and id != 0">
  228. and a.id = #{id}
  229. </if>
  230. </where>
  231. </select>
  232. <select id="list1" resultType="com.bizmatics.model.Site">
  233. select *
  234. from site
  235. <where>
  236. enable=1
  237. <if test="id != null and id != 0">
  238. and id = #{id}
  239. </if>
  240. </where>
  241. </select>
  242. <select id="SiteDynamicPropertieslist" resultType="com.bizmatics.model.SiteDynamicProperties">
  243. select *
  244. from site_dynamic_properties
  245. <where>
  246. <if test="siteId != null and siteId != 0">
  247. and site_id = #{siteId}
  248. </if>
  249. </where>
  250. </select>
  251. <select id="deviceAnalogVariableList" resultType="com.bizmatics.model.DeviceAnalogVariableList">
  252. SELECT
  253. a.*
  254. FROM
  255. device_analog_variable_list AS a
  256. left JOIN device AS b ON a.communication_equipment = b.id
  257. <where>
  258. a.status = 1
  259. <if test="dataArea != null and dataArea != 0">
  260. AND a.data_area = #{dataArea}
  261. </if>
  262. <if test="siteId != null and siteId != 0">
  263. AND b.site_id = #{siteId}
  264. </if>
  265. </where>
  266. </select>
  267. </mapper>